faudes::sDevice Class Reference
[I/O Device PlugIn]

An sDevice implements signal based semantics for faudes events. More...

#include <iop_sdevice.h>

List of all members.

Classes

struct  Edges
 Background: type def for edge detection. More...
struct  Levels
 Background: type def output values. More...

Public Types

typedef
AttributeSignalInput::Trigger 
Trigger
typedef
AttributeSignalOutput::Action 
Action
typedef
AttributeSignalOutput::Value 
Value

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.
void InsInputEvent (const std::string &event)
 Insert event as input event.
void AppendTrigger (const std::string &event, const Trigger &trigger)
 Add a trigger condition.
void InsOutputEvent (const std::string &event)
 Insert event as output event.
void AppendAction (const std::string &event, const Action &action)
 Add an action.
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 WriteOutput (Idx output)
 Run output 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, inputs.
virtual void DoReadSignalsPost (void)
 IO Hook, inputs.
virtual bool DoReadSignal (int bitaddr)=0
 Sample input signal.
virtual bool DoWriteSignalsPre (void)
 IO Hook, outputs.
virtual void DoWriteSignalsPost (void)
 IO Hook, output.
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.
virtual void DoLoopCallback (void)
 Loop hook.

Protected Attributes

TaNameSet< AttributeSignalEvent > * pConfiguration
 Overall configuration (with actual type).
std::map< int, EventSetmInputPosEdgeIndexMap
 Reverse input map: map signal edges to logical event sets.
std::map< int, EventSetmInputNegEdgeIndexMap
 Reverse input map: map signal edges to logical event sets.
std::map< int, EventSetmOutputLevelIndexMap
 Reverse output map: map signal addres to events that affect the resp.
int mMaxBitAddress
 Address range.
faudes_mutex_t mMutex
 Background: mutex for below shared variables.
bool mSyncWrite
 True for synchronous output writes.

Private Member Functions

void ClrInputSignals (void)
 clear all input states
void ClrOutputSignals (void)
 clear all output values

Private Attributes

faudes_thread_t mThreadSynchro
 Background: thread handle (global).
int mCycleTime
 Cycle time of background thread in nsecs (shared).
int mCycleCount
 Background: cycle counter (shared).
int mRecentCycleCount
 Background: cycle count (global only).
EdgesmpInputEdges
 Background: accumulated edges (shared).
EdgesmpRecentInputEdges
 Background: recently accumulated edges (global only).
bool mInputReady
 Background: some input event did occur (shared).
LevelsmpOutputLevels
 Background: accumulated output values (shared).
bool mCancelRequest
 Background: terminate-flag for background task.

Friends

void * SDeviceSynchro (void *)

Detailed Description

An sDevice implements signal based semantics for faudes events.

The class is configured by AttributeSignalEvents, which in turn consist of either a AttributeSignalInput or a AttributeSignalOutput. Thus, we set and clear output signals for output events, while edges on input signals trigger input 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 291 of file iop_sdevice.h.


Member Typedef Documentation


Constructor & Destructor Documentation

faudes::sDevice::sDevice ( void   ) 

Default constructor.

Definition at line 383 of file iop_sdevice.cpp.

faudes::sDevice::sDevice ( const sDevice rOtherDevice  ) 

copy-constructor

faudes::sDevice::~sDevice ( void   )  [virtual]

Explicit destructor.

Definition at line 409 of file iop_sdevice.cpp.


Member Function Documentation

void faudes::sDevice::AppendAction ( const std::string &  event,
const Action action 
)

Add an action.

Note: you can only add a actions to an output event; you can only (re)-configure events while the device is down.

Parameters:
event Event
action Action to append

Definition at line 674 of file iop_sdevice.cpp.

void faudes::sDevice::AppendTrigger ( const std::string &  event,
const Trigger trigger 
)

Add a trigger condition.

Note: you can only add a trigger condition to an input event; you can only (re)-configure events while the device is down.

Parameters:
event Event
trigger Trigger to append

Definition at line 653 of file iop_sdevice.cpp.

void faudes::sDevice::Clear ( void   )  [virtual]

Clear all configuration.

This implies Stop().

Reimplemented from faudes::vDevice.

Definition at line 574 of file iop_sdevice.cpp.

void faudes::sDevice::ClrInputSignals ( void   )  [private]

clear all input states

Definition at line 1113 of file iop_sdevice.cpp.

void faudes::sDevice::ClrOutputSignals ( void   )  [private]

clear all output values

Definition at line 1168 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 588 of file iop_sdevice.cpp.

void faudes::sDevice::CycleTime ( int  cycleTime  )  [virtual]

Set cycle time.

Parameters:
cycleTime Desired cycle time in usecs

Definition at line 694 of file iop_sdevice.cpp.

int faudes::sDevice::CycleTime ( void   )  const [virtual]

Report cycle time.

Returns:
Actual cycle time in ussecs

Definition at line 687 of file iop_sdevice.cpp.

virtual void faudes::sDevice::DoLoopCallback ( void   )  [inline, protected, virtual]

Loop hook.

This function is called once during each cycle of the backgroud thread

Definition at line 609 of file iop_sdevice.h.

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.

Parameters:
rTr TokenReader to read from
rLabel Section to read
pContext Read context to provide contextual information

Reimplemented from faudes::vDevice.

Definition at line 444 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.

Parameters:
bitaddr Abstract bit address
Returns:
True for logic level high;
virtual void faudes::sDevice::DoReadSignalsPost ( void   )  [inline, protected, virtual]

IO Hook, inputs.

The background thread calls this hook after reading input signals. You may reimplement this method to e.g. release a process image.

Definition at line 547 of file iop_sdevice.h.

virtual bool faudes::sDevice::DoReadSignalsPre ( void   )  [inline, protected, virtual]

IO Hook, inputs.

The background thread calls this hook before reading input signals. You may reimplement this method to e.g. prepare a process image.

Returns:
True on success, false on error

Definition at line 537 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.

Parameters:
rTw TokenWriter to write
rLabel Section to write
pContext Context to provide contextual information

Reimplemented from faudes::vDevice.

Definition at line 424 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.

Parameters:
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, output.

This hook is invoked after writing a signal value. You may reimplement this method to e.g. assemble a process image.

Definition at line 585 of file iop_sdevice.h.

virtual bool faudes::sDevice::DoWriteSignalsPre ( void   )  [inline, protected, virtual]

IO Hook, outputs.

This hook is invoked before writing a signal value. You may reimplement this method to e.g. assemble a process image.

Returns:
True on success, false on error

Definition at line 575 of file iop_sdevice.h.

void faudes::sDevice::InsInputEvent ( const std::string &  event  ) 

Insert event as input event.

Note: you can only configure events while the device is down.

Parameters:
event Event by name.

Definition at line 643 of file iop_sdevice.cpp.

void faudes::sDevice::InsOutputEvent ( const std::string &  event  ) 

Insert event as output event.

Note: you can only configure event while the device is down.

Parameters:
event Event by name.

Definition at line 664 of file iop_sdevice.cpp.

int faudes::sDevice::MaxBitAddress ( void   )  const [inline]

Report max bit address.

Returns:
Set of all configured inputs

Definition at line 385 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 virtual actual harware access to sample an input signal via DoReadSignal(int).

Parameters:
bitaddr Abstract bit address
Returns:
True for logic level high;

Definition at line 707 of file iop_sdevice.cpp.

void faudes::sDevice::Reset ( void   )  [virtual]

Clear dynamic data and restart device.

Reimplemented from faudes::vDevice.

Definition at line 560 of file iop_sdevice.cpp.

void faudes::sDevice::Start ( void   )  [virtual]

Activate the device.

This function enables output execution and input reading. It starts the background thread for edge detection and input event buffer.

Exceptions:
Exception 
  • Not yet configured (id 551)

Reimplemented from faudes::vDevice.

Definition at line 515 of file iop_sdevice.cpp.

void faudes::sDevice::Stop ( void   )  [virtual]

Deactivate the device.

This function disables output execution and input reading. It stops the backhround thread and resets all output signals to 0.

Reimplemented from faudes::vDevice.

Definition at line 535 of file iop_sdevice.cpp.

void faudes::sDevice::WriteOutput ( Idx  output  )  [virtual]

Run output command.

Exceptions:
Exception 
  • unknown output event (id 65)

Implements faudes::vDevice.

Definition at line 1052 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 virtual actual harware access to set the signal level via DoWriteSignal(int,bool).

Parameters:
bitaddr Abstract bit address
value True for active/high/1/set; false for passive/low/0/clr;

Definition at line 735 of file iop_sdevice.cpp.


Friends And Related Function Documentation

void* SDeviceSynchro ( void *   )  [friend]

Member Data Documentation

Background: terminate-flag for background task.

Definition at line 665 of file iop_sdevice.h.

Background: cycle counter (shared).

Definition at line 627 of file iop_sdevice.h.

Cycle time of background thread in nsecs (shared).

Definition at line 624 of file iop_sdevice.h.

Reverse input map: map signal edges to logical event sets.

Definition at line 480 of file iop_sdevice.h.

Reverse input map: map signal edges to logical event sets.

Definition at line 477 of file iop_sdevice.h.

Background: some input event did occur (shared).

Definition at line 650 of file iop_sdevice.h.

Address range.

Definition at line 486 of file iop_sdevice.h.

faudes_mutex_t faudes::sDevice::mMutex [protected]

Background: mutex for below shared variables.

Definition at line 609 of file iop_sdevice.h.

std::map<int, EventSet> faudes::sDevice::mOutputLevelIndexMap [protected]

Reverse output map: map signal addres to events that affect the resp.

line

Definition at line 483 of file iop_sdevice.h.

Background: accumulated edges (shared).

Definition at line 644 of file iop_sdevice.h.

Background: accumulated output values (shared).

Definition at line 662 of file iop_sdevice.h.

Background: recently accumulated edges (global only).

Definition at line 647 of file iop_sdevice.h.

Background: cycle count (global only).

Definition at line 630 of file iop_sdevice.h.

bool faudes::sDevice::mSyncWrite [protected]

True for synchronous output writes.

Definition at line 616 of file iop_sdevice.h.

faudes_thread_t faudes::sDevice::mThreadSynchro [private]

Background: thread handle (global).

Definition at line 621 of file iop_sdevice.h.

Overall configuration (with actual type).

Definition at line 474 of file iop_sdevice.h.


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

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen