ClearCore Library
|
The ClearCore board has several different kinds of hardware connectors that range from simple digital inputs to complex ClearPath motor connectors. To facilitate easier coding the ClearCore
library implements a Connector interface that is common to all connectors on the board. All classes representing a ClearCore hardware connector are derived, or inherit, from the common Connector
class.
In C++ class inheritance, there is always a parent class and a child class. For the connector interface the parent class is Connector whereas all other classes, such as DigitalIn or MotorDriver,
are the children. A child class must implement the functionality of its parents, but it may also modify and extend that functionality.
Because each child class implements the functionality of its parent all child classes have the same base set of functions and members. These functions typically perform the same actions as each
other for similar hardware connectors, but some may have different behavior. These shared functions make using groups of connectors much simpler, such as looping through an array of connectors to
call a common function.
While all child classes share function definitions, the child implementations of those functions may not be the same. The common functions may be changed, or overriden, by child classes when extra
operations need to be performed. For instance, DigitalIn's Mode() function will slightly differ from DigitalInOut's because DigitalIn only has one valid operational mode.
Child classes may also contain additional functions and members that other child classes do not. These functions and members perform specific actions that would not be useful in the other child
classes, such as MotorDriver's EnableRequest() function for enabling attached motors.
The functions and types shared between the Connector child classes provide a good base for operating hardware connectors as groups.