DUDS
Distributed Update of Data from Something
duds::hardware::interface::ChipMultiplexerSelectManager Class Reference

Selects one of several chips using several pins for parallel output of a number. More...

#include <ChipMultiplexerSelectManager.hpp>

Inheritance diagram for duds::hardware::interface::ChipMultiplexerSelectManager:
Collaboration diagram for duds::hardware::interface::ChipMultiplexerSelectManager:

Public Member Functions

 ChipMultiplexerSelectManager ()=default
 Default constructor. More...
 
 ChipMultiplexerSelectManager (std::unique_ptr< DigitalPinSetAccess > &&acc)
 Constructs the manager and sets the access object used to output the number of the chip to select. More...
 
std::unique_ptr< DigitalPinSetAccessreleaseAccess ()
 Returns the access object that was used by this chip select manager. More...
 
void setAccess (std::unique_ptr< DigitalPinSetAccess > &&acc)
 Sets the access object used to output the number of the chip to select. More...
 
virtual bool validChip (int chipId) const noexcept
 Valid chip IDs are greater than zero and can be represented in the same number of bits as there are pins provided to the multiplexer. More...
 
- Public Member Functions inherited from duds::hardware::interface::ChipSelectManager
 ChipSelectManager ()
 
virtual ~ChipSelectManager ()=0
 Derived non-abstract classes must call shutdown() in thier destructor. More...
 
std::unique_ptr< ChipAccessaccess (int chipId)
 Acquires access to the requested chip and issues a ChipAccess object. More...
 
void access (ChipAccess &acc, int chipId)
 Acquires access to the requested chip and modifies an existing ChipAccess object to provide that access. More...
 
bool inUse () const
 Returns true if an access object provided by this manager exists. More...
 
std::unique_ptr< ChipAccessselect (int chipId)
 Selects the requested chip and issues a ChipAccess object. More...
 
void select (ChipAccess &acc, int chipId)
 Selects the requested chip and modifies a ChipAccess object to further control chip selection. More...
 

Protected Member Functions

virtual void deselect ()
 Deselects the chip identified by cid. More...
 
virtual void select ()
 Selects the chip identified by cid. More...
 
- Protected Member Functions inherited from duds::hardware::interface::ChipSelectManager
void baseAccess (std::unique_lock< std::mutex > &lock, int chipId)
 Obtains the resources for providing an access object, but does not make an access object. More...
 
void changeChip (int chipId)
 Changes the chip in use while continuing to use an existing access object. More...
 
void shutdown ()
 Waits on a ChipAccess object if one is in use, then begins forcing any threads waiting on access to wake up and throw exceptions. More...
 

Private Attributes

std::unique_ptr< DigitalPinSetAccessoutacc
 Access used for parallel output. More...
 

Additional Inherited Members

- Protected Attributes inherited from duds::hardware::interface::ChipSelectManager
std::mutex block
 Used to synchonize access. More...
 
int cid
 Selected chip ID, or -1 to terminate. More...
 

Detailed Description

Selects one of several chips using several pins for parallel output of a number.

This implementation requires a multiplexer, but uses the fewest number of pins for two chips or more.

Warning
If the DigitalPort implementation does not support simultaneous operations, then the output state will change one pin at a time in an unspecified order. This can cause brief selection states on chips other than the one intended for selection.
Author
Jeff Jackowski

Definition at line 26 of file ChipMultiplexerSelectManager.hpp.

Constructor & Destructor Documentation

◆ ChipMultiplexerSelectManager() [1/2]

duds::hardware::interface::ChipMultiplexerSelectManager::ChipMultiplexerSelectManager ( )
default

Default constructor.

◆ ChipMultiplexerSelectManager() [2/2]

duds::hardware::interface::ChipMultiplexerSelectManager::ChipMultiplexerSelectManager ( std::unique_ptr< DigitalPinSetAccess > &&  acc)

Constructs the manager and sets the access object used to output the number of the chip to select.

Parameters
accThe access object to use. It must provide access to at least one pin.
Exceptions
PinDoesNotExistEither the access object does not have any pins, or acc is empty. If thrown, no changes to this chip select manager will be made.
DigitalPinCannotOutputErrorOne of the provided pins is incapable of output.

Definition at line 14 of file ChipMultiplexerSelectManager.cpp.

Member Function Documentation

◆ deselect()

void duds::hardware::interface::ChipMultiplexerSelectManager::deselect ( )
protectedvirtual

Deselects the chip identified by cid.

If the chip is already deselected, it must remain deselected.

Note
There is no need for thread synchronization in this function.

Implements duds::hardware::interface::ChipSelectManager.

Definition at line 86 of file ChipMultiplexerSelectManager.cpp.

◆ releaseAccess()

std::unique_ptr< DigitalPinSetAccess > duds::hardware::interface::ChipMultiplexerSelectManager::releaseAccess ( )

Returns the access object that was used by this chip select manager.

Precondition
No chip is currently selected by this manager.
Postcondition
This manager cannot select chips until another access object is provided.
Exceptions
ChipSelectInUseA ChipAccess object provided by this manager currently exists.

Definition at line 71 of file ChipMultiplexerSelectManager.cpp.

◆ select()

void duds::hardware::interface::ChipMultiplexerSelectManager::select ( )
protectedvirtual

Selects the chip identified by cid.

If the chip is already selected, it must remain selected.

Note
There is no need for thread synchronization in this function.

Implements duds::hardware::interface::ChipSelectManager.

Definition at line 82 of file ChipMultiplexerSelectManager.cpp.

◆ setAccess()

void duds::hardware::interface::ChipMultiplexerSelectManager::setAccess ( std::unique_ptr< DigitalPinSetAccess > &&  acc)

Sets the access object used to output the number of the chip to select.

Precondition
No chip is currently selected by this manager.
Parameters
accThe access object to use. It must provide access to at least one pin.
Exceptions
ChipSelectInUseA ChipAccess object provided by this manager currently exists.
PinDoesNotExistEither the access object does not have any pins, or acc is empty. If thrown, no changes to this chip select manager will be made.
DigitalPinCannotOutputErrorOne of the provided pins is incapable of output.

Definition at line 27 of file ChipMultiplexerSelectManager.cpp.

Referenced by ChipMultiplexerSelectManager().

◆ validChip()

bool duds::hardware::interface::ChipMultiplexerSelectManager::validChip ( int  chipId) const
virtualnoexcept

Valid chip IDs are greater than zero and can be represented in the same number of bits as there are pins provided to the multiplexer.

Implements duds::hardware::interface::ChipSelectManager.

Definition at line 20 of file ChipMultiplexerSelectManager.cpp.

Member Data Documentation

◆ outacc

std::unique_ptr<DigitalPinSetAccess> duds::hardware::interface::ChipMultiplexerSelectManager::outacc
private

Access used for parallel output.

Definition at line 30 of file ChipMultiplexerSelectManager.hpp.

Referenced by deselect(), releaseAccess(), select(), setAccess(), and validChip().


The documentation for this class was generated from the following files: