|
libFAUDES
Sections
Index
|
faudes::sDevice Class Reference
|
Classes | |
struct | Edges |
Background: type def for edge detection. More... | |
struct | Levels |
Background: type def actuator values. More... | |
Public Member Functions | |
sDevice (void) | |
Default constructor. | |
sDevice (const sDevice &rOtherDevice) | |
copy-constructor | |
virtual | ~sDevice (void) |
Explicit destructor. | |
virtual void | Clear (void) |
Clear all configuration. | |
virtual void | Compile (void) |
Build up internal data-structure(e.g. | |
int | MaxBitAddress (void) const |
Report max bit address. | |
virtual void | Start (void) |
Activate the device. | |
virtual void | Stop (void) |
Deactivate the device. | |
virtual void | Reset (void) |
Clear dynamic data and restart device. | |
virtual void | WriteActuator (Idx actuator) |
Run actuator command. | |
void | WriteSignal (int bitaddr, bool value) |
Set output signal. | |
bool | ReadSignal (int bitaddr) |
Get input signal. | |
virtual int | CycleTime () const |
Report cycle time. | |
virtual void | CycleTime (int cycleTime) |
Set cycle time. | |
Protected Member Functions | |
void | DoWritePreface (TokenWriter &rTw, const std::string &rLabel, const Type *pContext=0) const |
Writes non-event-related configuration to TokenWriter. | |
virtual void | DoReadPreface (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0) |
Reads non-event-related configuration from TokenReader. | |
virtual bool | DoReadSignalsPre (void) |
IO Hook, sensors. | |
virtual void | DoReadSignalsPost (void) |
IO Hook, sensors. | |
virtual bool | DoReadSignal (int bitaddr)=0 |
Sample input signal. | |
virtual bool | DoWriteSignalsPre (void) |
IO Hook, actuators. | |
virtual void | DoWriteSignalsPost (void) |
IO Hook, actuator. | |
virtual void | DoWriteSignal (int bitaddr, bool value)=0 |
Reimplement this function in a derived class for actual harware access to set or clear an output signal. | |
Protected Attributes | |
TaNameSet< AttributeSignalEvent > * | pConfiguration |
Overall configuration (with actual type). | |
std::map< int, EventSet > | mSensorPosEdgeIndexMap |
Reverse sensor map: map signal edges to logical event sets. | |
std::map< int, EventSet > | mSensorNegEdgeIndexMap |
Reverse sensor map: map signal edges to logical event sets. | |
int | mMaxBitAddress |
Address range. | |
pthread_mutex_t | mMutex |
Background: mutex for below shared variables. | |
Private Member Functions | |
void | ClrSensorSignals (void) |
clear all sensor states | |
void | ClrActuatorSignals (void) |
clear all actuator values | |
Private Attributes | |
pthread_t | mThreadSynchro |
Background: thread handle (global). | |
int | mCycleTime |
Cycle time of background thread in nsecs (shared). | |
bool | mSyncWrite |
True for synchronous actuator writes (shared). | |
int | mCycleCount |
Background: cycle counter (shared). | |
int | mRecentCycleCount |
Background: cycle count (global only). | |
Edges * | mpSensorEdges |
Background: accumulated edges (shared). | |
Edges * | mpRecentSensorEdges |
Background: recently accumulated edges (global only). | |
bool | mSensorReady |
Background: some sensor event did occur (shared). | |
Levels * | mpActuatorLevels |
Background: accumulated actuator values (shared). | |
bool | mCancelRequest |
Background: terminate-flag for endless-loop. | |
Friends | |
void * | SDeviceSynchro (void *) |
An sDevice implements signal based semantics for faudes events.
The class is configured by AttributeSignalEvents, which in turn consist of either a AttributeSignalSensor or a AttributeSignalActuator. Thus, we set and clear output signals for actuator events, while edges on input signals trigger sensor events.
Sensing edges is done by separate thread that is started by Start().
This class is still virtual in that it does not provide the code for actually reading or writing signals. See cDevice and pDevice for derived device classes that implement digital io via comedi or the parallel printer port, respectively.
Definition at line 280 of file iop_sdevice.h.
faudes::sDevice::sDevice | ( | void | ) |
Default constructor.
Definition at line 275 of file iop_sdevice.cpp.
faudes::sDevice::sDevice | ( | const sDevice & | rOtherDevice | ) |
copy-constructor
faudes::sDevice::~sDevice | ( | void | ) | [virtual] |
Explicit destructor.
Definition at line 301 of file iop_sdevice.cpp.
void faudes::sDevice::Clear | ( | void | ) | [virtual] |
Clear all configuration.
This implies Stop().
Reimplemented from faudes::vDevice.
Definition at line 430 of file iop_sdevice.cpp.
void faudes::sDevice::ClrActuatorSignals | ( | void | ) | [private] |
clear all actuator values
Definition at line 930 of file iop_sdevice.cpp.
void faudes::sDevice::ClrSensorSignals | ( | void | ) | [private] |
clear all sensor states
Definition at line 875 of file iop_sdevice.cpp.
void faudes::sDevice::Compile | ( | void | ) | [virtual] |
Build up internal data-structure(e.g.
signal-event - mapping)
Reimplemented from faudes::vDevice.
Definition at line 443 of file iop_sdevice.cpp.
void faudes::sDevice::CycleTime | ( | int | cycleTime | ) | [virtual] |
Set cycle time.
cycleTime | Desired cycle time in ms |
Definition at line 493 of file iop_sdevice.cpp.
int faudes::sDevice::CycleTime | ( | void | ) | const [virtual] |
void faudes::sDevice::DoReadPreface | ( | TokenReader & | rTr, | |
const std::string & | rLabel = "" , |
|||
const Type * | pContext = 0 | |||
) | [protected, virtual] |
Reads non-event-related configuration from TokenReader.
Device date is read bottom-to-top along the class-hierarchy; see also vDevice::DoReadPreface.
Note: in order to keep the inputfile-layout as simple as possible no label will be used to separate this data-section.
rTr | TokenReader to read from | |
rLabel | Section to read | |
pContext | Read context to provide contextual information |
Reimplemented from faudes::vDevice.
Definition at line 328 of file iop_sdevice.cpp.
virtual bool faudes::sDevice::DoReadSignal | ( | int | bitaddr | ) | [protected, pure virtual] |
Sample input signal.
Reimplement this function to implements actual harware access to sample an input signal. This function gets called from the periodic background thread to sense edges. It is guaranteed that the pre-hook was called befor and returned "true". The post-hook will be invoked after relevant signals have been sampled.
bitaddr | Abstract bit address |
virtual void faudes::sDevice::DoReadSignalsPost | ( | void | ) | [inline, protected, virtual] |
IO Hook, sensors.
The background thread calls this hook after reading sensor signals. You may reimplement this method to e.g. release a process image.
Definition at line 476 of file iop_sdevice.h.
virtual bool faudes::sDevice::DoReadSignalsPre | ( | void | ) | [inline, protected, virtual] |
IO Hook, sensors.
The background thread calls this hook before reading sensor signals. You may reimplement this method to e.g. prepare a process image.
Definition at line 466 of file iop_sdevice.h.
void faudes::sDevice::DoWritePreface | ( | TokenWriter & | rTw, | |
const std::string & | rLabel, | |||
const Type * | pContext = 0 | |||
) | const [protected, virtual] |
Writes non-event-related configuration to TokenWriter.
Device data will be written bottom-to-top along the class-hierarchy, see also vDevice::DoWritePreface.
Note: in order to keep the outputfile-layout as simple as possible no label will be used to separate this data-section.
rTw | TokenWriter to write | |
rLabel | Section to write | |
pContext | Context to provide contextual information |
Reimplemented from faudes::vDevice.
Definition at line 315 of file iop_sdevice.cpp.
virtual void faudes::sDevice::DoWriteSignal | ( | int | bitaddr, | |
bool | value | |||
) | [protected, pure virtual] |
Reimplement this function in a derived class for actual harware access to set or clear an output signal.
Hooks are executed appropriately. If the device is configured for synchronous write, the background task is used to write signals. Otherwise, signal values are written instantly.
bitaddr | Abstract bit address | |
value | True for active/high/1/set; false for passive/low/0/clr; |
virtual void faudes::sDevice::DoWriteSignalsPost | ( | void | ) | [inline, protected, virtual] |
IO Hook, actuator.
This hook is invoked after writing a signal value. You may reimplement this method to e.g. assemble a process image.
Definition at line 514 of file iop_sdevice.h.
virtual bool faudes::sDevice::DoWriteSignalsPre | ( | void | ) | [inline, protected, virtual] |
IO Hook, actuators.
This hook is invoked before writing a signal value. You may reimplement this method to e.g. assemble a process image.
Definition at line 504 of file iop_sdevice.h.
int faudes::sDevice::MaxBitAddress | ( | void | ) | const [inline] |
Report max bit address.
Definition at line 324 of file iop_sdevice.h.
bool faudes::sDevice::ReadSignal | ( | int | bitaddr | ) |
Get input signal.
This function provides user level access to input signals. It executes the virtual pre and post hook methods and the likewise virtual actual harware access to sample an input signal via DoReadSignal(int).
bitaddr | Abstract bit address |
Definition at line 506 of file iop_sdevice.cpp.
void faudes::sDevice::Reset | ( | void | ) | [virtual] |
Clear dynamic data and restart device.
Reimplemented from faudes::vDevice.
Definition at line 419 of file iop_sdevice.cpp.
void faudes::sDevice::Start | ( | void | ) | [virtual] |
Activate the device.
This function enables actuator execution and sensor reading. It starts the background thread for edge detection and sensor event buffer.
Exception |
|
Reimplemented from faudes::vDevice.
Definition at line 369 of file iop_sdevice.cpp.
void faudes::sDevice::Stop | ( | void | ) | [virtual] |
Deactivate the device.
This function disables actuator execution and sensor reading. It stops the backhround thread and resets all actuator signals to 0.
Reimplemented from faudes::vDevice.
Definition at line 396 of file iop_sdevice.cpp.
void faudes::sDevice::WriteActuator | ( | Idx | actuator | ) | [virtual] |
Run actuator command.
Exception |
|
Implements faudes::vDevice.
Definition at line 822 of file iop_sdevice.cpp.
void faudes::sDevice::WriteSignal | ( | int | bitaddr, | |
bool | value | |||
) |
Set output signal.
This function provides user level access to output signals. It executes the virtual pre and post hook methods and the likewise virtual actual harware access to set the signal level via DoWriteSignal(int,bool).
bitaddr | Abstract bit address | |
value | True for active/high/1/set; false for passive/low/0/clr; |
Definition at line 526 of file iop_sdevice.cpp.
void* SDeviceSynchro | ( | void * | ) | [friend] |
bool faudes::sDevice::mCancelRequest [private] |
Background: terminate-flag for endless-loop.
Definition at line 585 of file iop_sdevice.h.
int faudes::sDevice::mCycleCount [private] |
Background: cycle counter (shared).
Definition at line 548 of file iop_sdevice.h.
int faudes::sDevice::mCycleTime [private] |
Cycle time of background thread in nsecs (shared).
Definition at line 542 of file iop_sdevice.h.
int faudes::sDevice::mMaxBitAddress [protected] |
Address range.
Definition at line 416 of file iop_sdevice.h.
pthread_mutex_t faudes::sDevice::mMutex [protected] |
Background: mutex for below shared variables.
Definition at line 533 of file iop_sdevice.h.
Levels* faudes::sDevice::mpActuatorLevels [private] |
Background: accumulated actuator values (shared).
Definition at line 582 of file iop_sdevice.h.
Edges* faudes::sDevice::mpRecentSensorEdges [private] |
Background: recently accumulated edges (global only).
Definition at line 568 of file iop_sdevice.h.
Edges* faudes::sDevice::mpSensorEdges [private] |
Background: accumulated edges (shared).
Definition at line 565 of file iop_sdevice.h.
int faudes::sDevice::mRecentCycleCount [private] |
Background: cycle count (global only).
Definition at line 551 of file iop_sdevice.h.
std::map<int, EventSet> faudes::sDevice::mSensorNegEdgeIndexMap [protected] |
Reverse sensor map: map signal edges to logical event sets.
Definition at line 413 of file iop_sdevice.h.
std::map<int, EventSet> faudes::sDevice::mSensorPosEdgeIndexMap [protected] |
Reverse sensor map: map signal edges to logical event sets.
Definition at line 410 of file iop_sdevice.h.
bool faudes::sDevice::mSensorReady [private] |
Background: some sensor event did occur (shared).
Definition at line 571 of file iop_sdevice.h.
bool faudes::sDevice::mSyncWrite [private] |
True for synchronous actuator writes (shared).
Definition at line 545 of file iop_sdevice.h.
pthread_t faudes::sDevice::mThreadSynchro [private] |
Background: thread handle (global).
Definition at line 539 of file iop_sdevice.h.
TaNameSet<AttributeSignalEvent>* faudes::sDevice::pConfiguration [protected] |
Overall configuration (with actual type).
Definition at line 407 of file iop_sdevice.h.
libFAUDES 2.16b --- 2010-9-8 --- c++ source docu by doxygen 1.6.3