libFAUDES

Sections

Index

faudes::sDevice Class Reference
[IO 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 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 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.

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.
int mMaxBitAddress
 Address range.
pthread_mutex_t mMutex
 Background: mutex for below shared variables.

Private Member Functions

void ClrInputSignals (void)
 clear all input states
void ClrOutputSignals (void)
 clear all output 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 output writes (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 endless-loop.

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


Constructor & Destructor Documentation

faudes::sDevice::sDevice ( void   ) 

Default constructor.

Definition at line 376 of file iop_sdevice.cpp.

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

copy-constructor

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

Explicit destructor.

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

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

clear all input states

Definition at line 1010 of file iop_sdevice.cpp.

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

clear all output values

Definition at line 1065 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 576 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 626 of file iop_sdevice.cpp.

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

Report cycle time.

Returns:
Actual cycle time in ms

Definition at line 618 of file iop_sdevice.cpp.

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 431 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 476 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 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.

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

Reimplemented from faudes::vDevice.

Definition at line 416 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 514 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 504 of file iop_sdevice.h.

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

Report max bit address.

Returns:
Set of all configured inputs

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

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

Definition at line 639 of file iop_sdevice.cpp.

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

Clear dynamic data and restart device.

Reimplemented from faudes::vDevice.

Definition at line 550 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 499 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 527 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 957 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 659 of file iop_sdevice.cpp.


Friends And Related Function Documentation

void* SDeviceSynchro ( void *   )  [friend]

Member Data Documentation

Background: terminate-flag for endless-loop.

Definition at line 585 of file iop_sdevice.h.

Background: cycle counter (shared).

Definition at line 548 of file iop_sdevice.h.

Cycle time of background thread in nsecs (shared).

Definition at line 542 of file iop_sdevice.h.

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

Definition at line 413 of file iop_sdevice.h.

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

Definition at line 410 of file iop_sdevice.h.

Background: some input event did occur (shared).

Definition at line 571 of file iop_sdevice.h.

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.

Background: accumulated edges (shared).

Definition at line 565 of file iop_sdevice.h.

Background: accumulated output values (shared).

Definition at line 582 of file iop_sdevice.h.

Background: recently accumulated edges (global only).

Definition at line 568 of file iop_sdevice.h.

Background: cycle count (global only).

Definition at line 551 of file iop_sdevice.h.

True for synchronous output 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.

Overall configuration (with actual type).

Definition at line 407 of file iop_sdevice.h.


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

libFAUDES 2.18b --- 2010-12-17 --- c++ source docu by doxygen 1.6.3