libFAUDES

Sections

Index

faudes::sDevice Class Reference
[IO Device PlugIn]

#include <iop_sdevice.h>

Inherits faudes::vDevice.

Inherited by faudes::cDevice.

List of all members.


Detailed Description

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.


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-configuration to TokenWriter.
virtual void DoReadPreface (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Reads non-event-configuration data 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, EventSetmSensorPosEdgeIndexMap
 Reverse sensor map: map signal edges to logical event sets.
std::map< int, EventSetmSensorNegEdgeIndexMap
 Reverse sensor map: map signal edges to logical event sets.
int mMaxBitAddress
 Address range.

Private Member Functions

void ClrSensorSignals (void)
 clear all sensor states
void ClrActuatorSignals (void)
 clear all actuator values

Private Attributes

pthread_mutex_t mMutex
 Background: mutex for below shared variables.
pthread_t mThreadSynchro
 Background: thread handle (global).
int mCycleTime
 Cycle time of background thread in usecs (shared).
int mCycleCount
 Background: cycle counter (shared).
int mRecentCycleCount
 Background: cycle counte (global only).
EdgesmpSensorEdges
 Background: accumulated edges (shared).
EdgesmpRecentSensorEdges
 Background: recently accumulated edges (global only).
bool mSensorReady
 Background: some sensor event did occur (shared).
bool mCancelRequest
 Background: terminate-flag for endless-loop.

Friends

void * SDeviceSynchro (void *)

Classes

struct  Edges
 Background: type def for edge detection. More...

Constructor & Destructor Documentation

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 299 of file iop_sdevice.cpp.


Member Function Documentation

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

Clear all configuration.

This implies Stop().

Reimplemented from faudes::vDevice.

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

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

Report max bit address.

Returns:
Set of all configured sensors

Definition at line 324 of file iop_sdevice.h.

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.

Exceptions:
Exception 
  • Not yet configured (id 551)

Reimplemented from faudes::vDevice.

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

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

Clear dynamic data and restart device.

Reimplemented from faudes::vDevice.

Definition at line 406 of file iop_sdevice.cpp.

void faudes::sDevice::WriteActuator ( Idx  actuator  )  [virtual]

Run actuator command.

Exceptions:
Exception 
  • unknown actuator event (id 65)

Implements faudes::vDevice.

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

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

Definition at line 512 of file iop_sdevice.cpp.

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).

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

Definition at line 492 of file iop_sdevice.cpp.

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

Report cycle time.

Returns:
Actual cycle time in ms

Definition at line 471 of file iop_sdevice.cpp.

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

Set cycle time.

Parameters:
cycleTime Desired cycle time in ms

Definition at line 479 of file iop_sdevice.cpp.

void faudes::sDevice::DoWritePreface ( TokenWriter rTw,
const std::string &  rLabel,
const Type pContext = 0 
) const [protected, virtual]

Writes non-event-configuration to TokenWriter.

This function is part of the non-event-configuration data output-system. Device data will be written w.r.t the class-hierarchy. Therefore first thing to do is to the base class. See vDevice::DoWritePreface for further information.

After base-class function returned the mMaxBitAdress and mCycleTime will be written to tokenwriter.

Note: in order to keep the outputfile-layout as easy as possible no label will be used to separate this data-section. Never the less a default-label ("SignalDevice") is specified.

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

Reimplemented from faudes::vDevice.

Definition at line 312 of file iop_sdevice.cpp.

void faudes::sDevice::DoReadPreface ( TokenReader rTr,
const std::string &  rLabel = "",
const Type pContext = 0 
) [protected, virtual]

Reads non-event-configuration data from TokenReader.

This function is part of the non-event-configuration data input-system. Device data will be read w.r.t the class-hierarchy. Therefore first thing to do is to call the base class. See vDevice::DoReadPreface for further information.

After base-class returned the mMaxBitAddress and mCycleTime will be read. The max. bit-address depends on the IO-card used while the cycle-time should be chosen depending on the physical plant to control.

Note: in order to keep the inputfile-layout as easy as possible no label will be used to separate this data-section. Never the less a default-label ("SignalDevice") is specified.

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

Reimplemented from faudes::vDevice.

Definition at line 323 of file iop_sdevice.cpp.

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.

Returns:
True on success, false on error

Definition at line 472 of file iop_sdevice.h.

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 482 of file iop_sdevice.h.

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 and post hook is executed before/afterwards.

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

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

IO Hook, actuators.

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

Returns:
True on success, false on error

Definition at line 508 of file iop_sdevice.h.

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

IO Hook, actuator.

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 518 of file iop_sdevice.h.

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 executoed appropriately.

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

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

clear all sensor states

Definition at line 753 of file iop_sdevice.cpp.

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

clear all actuator values

Definition at line 796 of file iop_sdevice.cpp.


Friends And Related Function Documentation

void* SDeviceSynchro ( void *   )  [friend]

Definition at line 531 of file iop_sdevice.cpp.


Member Data Documentation

Overall configuration (with actual type).

Definition at line 407 of file iop_sdevice.h.

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

Definition at line 410 of file iop_sdevice.h.

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

Definition at line 413 of file iop_sdevice.h.

Address range.

Definition at line 416 of file iop_sdevice.h.

pthread_mutex_t faudes::sDevice::mMutex [private]

Background: mutex for below shared variables.

Definition at line 538 of file iop_sdevice.h.

pthread_t faudes::sDevice::mThreadSynchro [private]

Background: thread handle (global).

Definition at line 541 of file iop_sdevice.h.

Cycle time of background thread in usecs (shared).

Definition at line 544 of file iop_sdevice.h.

Background: cycle counter (shared).

Definition at line 547 of file iop_sdevice.h.

Background: cycle counte (global only).

Definition at line 550 of file iop_sdevice.h.

Background: accumulated edges (shared).

Definition at line 564 of file iop_sdevice.h.

Background: recently accumulated edges (global only).

Definition at line 567 of file iop_sdevice.h.

Background: some sensor event did occur (shared).

Definition at line 570 of file iop_sdevice.h.

Background: terminate-flag for endless-loop.

Definition at line 573 of file iop_sdevice.h.


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

libFAUDES 2.14g --- 2009-12-3 --- c++ source docu by doxygen 1.5.6