libFAUDES

Sections

Index

iop_vdevice.h

Go to the documentation of this file.
00001 /** @file iop_vdevice.h Virtual device for interface definition  */
00002 
00003 /*
00004    FAU Discrete Event Systems Library (libfaudes)
00005 
00006    Copyright (C) 2008, Thomas Moor
00007    Exclusive copyright is granted to Klaus Schmidt
00008 
00009 */
00010 
00011 
00012 
00013 #ifndef FAUDES_VDEVICE_H
00014 #define FAUDES_VDEVICE_H
00015 
00016 #include "corefaudes.h"
00017 #include "tp_include.h"
00018 #include "sp_densityfnct.h"
00019 
00020 // windows needs this
00021 #include <pthread.h>
00022 
00023 // debugging: io level
00024 #ifdef FAUDES_DEBUG_IODEVICE
00025 #define FD_DH(message) std::cerr << "FAUDES_IODEVICE: " << message << std::endl
00026 #else
00027 #define FD_DH(message)
00028 #endif
00029 
00030 
00031 // debugging: io level
00032 #ifdef FAUDES_DEBUG_IOVERBOSE
00033 #define FD_DHV(message) std::cerr << "FAUDES_IODEVICE: " << message << std::endl
00034 #else
00035 #define FD_DHV(message)
00036 #endif
00037 
00038 
00039 // debugging: io performance  (currently broken due to redesign of vdevice)
00040 #ifdef FAUDES_DEBUG_IOPERF
00041 #define FD_DHT(message) std::cerr << "FAUDES_IODEVICE: TIMING: " << message << std::endl
00042 #else
00043 #define FD_DHT(message)
00044 #endif
00045 
00046 
00047 
00048 namespace faudes {
00049 
00050 
00051 
00052 /**
00053  * Attribute for the configuration of a sensor or actuator mapping
00054  *
00055  * The base class for all device event attributes only distinguishes between
00056  * actuator and sensor events. The actual attribute is of type AttributeVoid.
00057  * Derived classes are meant to override this type in order to provide the
00058  * defining data for the actual mapping of physical and logical events.
00059  *
00060  */
00061 
00062 class AttributeDeviceEvent : public AttributeVoid {
00063 
00064 FAUDES_TYPE_DECLARATION(AttributeDeviceEvent,AttributeVoid)
00065 
00066   public:
00067 
00068     /** Default constructor (no attributes, aka undefined) */
00069     AttributeDeviceEvent(void);
00070     /** Copy constructor */
00071     AttributeDeviceEvent(const AttributeDeviceEvent& rOtherAttr);
00072 
00073     /** Destructor */
00074     virtual ~AttributeDeviceEvent(void);
00075 
00076     /** Clear */
00077     virtual void Clear(void);
00078 
00079     /** Test for default value (undefined) */
00080     virtual bool IsDefault(void) const {return (!mpActuatorAttribute &&  !mpSensorAttribute); };
00081 
00082     /** Does this attribute define an actuator mapping? */
00083     bool IsActuator(void) const {return mpActuatorAttribute!=0; };
00084 
00085     /** Does this attribute define a sensor mapping? */
00086     bool IsSensor(void) const {return mpSensorAttribute!=0; };
00087 
00088     /** Set to default actuator attribute */
00089     void DefaultActuator(void) {
00090       Clear();
00091       mpActuatorAttribute= pActuatorPrototype->New();
00092     };
00093 
00094     /** Set to default sensor attribute */
00095     void DefaultSensor(void) {
00096       Clear();
00097       mpSensorAttribute= pSensorPrototype->New();
00098     };
00099 
00100     /** Set actuator attribute */
00101     virtual void Actuator(const AttributeVoid&  rActuatorAttribute) {
00102       DefaultActuator();
00103       mpActuatorAttribute->Assign(rActuatorAttribute);
00104     };
00105 
00106     /** Set sensor attribute */
00107     virtual void Sensor(const AttributeVoid&  rSensorAttribute) {
00108       DefaultSensor();
00109       mpSensorAttribute->Assign(rSensorAttribute);
00110     };
00111 
00112     /**  Get actuator mapping (return 0 if its not an actuator) */
00113     const AttributeVoid*  Actuatorp(void) const {return mpActuatorAttribute; };
00114 
00115     /**  Get sensor mapping (return 0 if its not a sensor) */
00116     const AttributeVoid*  Sensorp(void) const {return mpSensorAttribute; };
00117 
00118 
00119 protected:
00120 
00121     /** Actuator Attribute (use cast in derived classes) */
00122     AttributeVoid* mpActuatorAttribute;
00123 
00124     /** Sensor Attribute (use cast in derived classes) */
00125     AttributeVoid* mpSensorAttribute;
00126 
00127     /** Actuator Prototype (set to nontrivial attribute in derived classes) */
00128     AttributeVoid* pActuatorPrototype;
00129 
00130     /** Sensor Prototype (set to nontrivial attribute in derived classes) */
00131     AttributeVoid* pSensorPrototype;
00132 
00133     /** Fallback attribute type */
00134     static AttributeVoid sFallbackAttribute;
00135 
00136   /**
00137    * Copy method
00138    *
00139    * @param rSrcAttr
00140    *   Source to copy from
00141    * @return
00142    *   Ref to this attribute
00143    */
00144    virtual AttributeDeviceEvent& DoAssign(const AttributeDeviceEvent& rSrcAttr);
00145 
00146 
00147   /**
00148    * Reads the attribute from TokenReader, see AttributeVoid for public wrappers.
00149    *
00150    * If the current token indicates a "Sensor" or "Actuator" section, the method reads that
00151    * section. Else it does nothing. Exceptions may only be thrown
00152    * on invalid data within the section. The label argument is ignored.
00153    * The context argument is ignored.
00154    *
00155    * @param rTr
00156    *   TokenReader to read from
00157    * @param rLabel
00158    *   Section to read
00159    * @param pContext
00160    *   Read context to provide contextual information
00161    *
00162    * @exception Exception
00163    *   - IO error (id 1)
00164    */
00165    virtual void DoRead(TokenReader& rTr,const std::string& rLabel="", const Type* pContext=0);
00166 
00167   /**
00168    * Writes the attribute to TokenWriter, see AttributeVoid for public wrappers.
00169    *
00170    * Writes all present device event attributes to include the defining data.
00171    * The label argument is ignored, we use hardcoded lebels "Sensor" or "Actuator".
00172    * The context argument is ignored.
00173    *
00174    * @param rTw
00175    *   TokenWriter to write to
00176    * @param rLabel
00177    *   Section to write
00178    * @param pContext
00179    *   Read context to provide contextual information
00180    *
00181    * @exception Exception
00182    *   - IO error (id 2)
00183    */
00184    virtual void DoWrite(TokenWriter& rTw,const std::string& rLabel="", const Type* pContext=0) const;
00185 
00186 
00187 
00188 }; // class AttributeDeviceEvent
00189 
00190 
00191 
00192 /**
00193  * Virtual base class to define the interface for event io.
00194  *
00195  * @section IOPvdeviceA Sensor and Actuator event IO
00196  *
00197  * A vDevice provides an virtual interface to execute actuator events and sense
00198  * sensor events, ie ReadSensor() and WriteActuator(). The latter is prepared to
00199  * be organized as a background thread that accumulates events in an internal fifo buffer.
00200  * Once a sensor event has been read by the application, the buffer is cleared.
00201  * A device is configured by passing an event set with device event attributes. The virtual
00202  * base class formalls takes void attributes, and uses a dynamic cast to the actual attribute 
00203  * type that is provided by any derived class.
00204  *
00205  * @section IOPvdeviceB Physical Time
00206  *
00207  * The vDevice defines an interface to access the current physical time. The default
00208  * implementation has msec resolution and is based on the system clock. Time may be queried
00209  * in ms by CurrentTimeMs() or in faudes time unis (ftu) by CurrentTime(). Faudes time units
00210  * refer to defining data in eg guards and invariants of timed automata or stochastical
00211  * execution properties. Conversion to physical time is by the factor mTimeScale given in
00212  * msecs per ftu. There is also a default implementation WaitSensors() for timed waiting
00213  * for events based on pthread conditions.
00214  * This requires a derived class to send the according pthread signal. Both, physical
00215  * time and waiting for events, may be overwritten in derived classes.
00216  *
00217  * @section IOPvdeviceC Operating Status
00218  *
00219  * The device may be in one of four operating states Down, StartUp, Up or ShutDown. Once configured
00220  * you may Start() the device. The device will assychonously allocate required resources
00221  * and if successful eventually be in state Up. While the device is Up, you can write
00222  * actuators and read events. You can request the device to release resources by calling
00223  * Stop(). While Up, you may also Reset() the device, to set actuators in passive state,
00224  * to reset physical time to zero and tu flush the sensor fifo buffer.
00225  *
00226  * @section IOPvdeviceD File IO
00227  *
00228  * The vDevice provides std faudes token io interface via faudes::Type. In addition,
00229  * there is a static constructor FromTokenreader() to construct a vDevice
00230  * object of specific type as indentifies by the token section.
00231  *
00232  * @ingroup IODevicePlugin
00233  */
00234 
00235 class vDevice : public Type {
00236 
00237    friend class xDevice;
00238 
00239 
00240  public:
00241 
00242   /** Enum for device stages */
00243   typedef enum { Down, StartUp, Up , ShutDown } DeviceState;
00244 
00245   /**
00246    * Default constructor
00247    */
00248   vDevice(void);
00249 
00250   /**
00251    * Construct on heap from token reader.
00252    *
00253    * This constructor examines the token strean, determines the coressponding
00254    * class and constructs the device on the heap. Todo: the implementation
00255    * of this function is a hack, there must be proper
00256    * solution to this issue.
00257    *
00258    * @param rTr
00259    *   TokenReader to read from
00260    * @return
00261    *  vDevice pointer
00262    *
00263    * @exception Exception
00264    *   - token mismatch (id 552)
00265    *   - IO errors (id 1)
00266    */
00267   static vDevice* FromTokenReader(TokenReader& rTr);
00268 
00269   /**
00270    * Construct on heap from file.
00271    *
00272    * This constructor examines the file, determines the coressponding
00273    * class and constructs the device on the heap.
00274    *
00275    * @param rFileName
00276    *   Filename
00277    * @return
00278    *  vDevice pointer
00279    *
00280    * @exception Exception
00281    *   - token mismatch (id 552)
00282    *   - IO errors (id 1)
00283    */
00284   static vDevice* FromFile(const std::string& rFileName);
00285 
00286 
00287   /**
00288    * Explicit destructor.
00289    */
00290   virtual ~vDevice(void);
00291 
00292 
00293   /**
00294    * Set the device name
00295    *
00296    * @param rName
00297    *   Generator name
00298    */
00299   void Name(const std::string& rName);
00300 
00301   /**
00302    * Get device name
00303    *
00304    * @return
00305    *   Name of generator
00306    */
00307   const std::string& Name(void) const;
00308 
00309 
00310   /**
00311    * Set tolerance for time synchonisation.
00312    *
00313    * @param maxgap
00314    *   Max acceptable amount of time by which the generator may be behind device time.
00315    *
00316    */
00317   void Tolerance(tpTime::Type maxgap) {mMaxSyncGap=maxgap;};
00318 
00319 
00320   /**
00321    * Get tolerance.
00322    *
00323    * @return
00324    *   Max acceptable amount of time by which the generator may be behind device time
00325    *
00326    */
00327   int Tolerance(void) {return mMaxSyncGap;};
00328 
00329 
00330   /**
00331    * Set timescale.
00332    *
00333    * @param scale
00334    *   Conversion factor in msecs/ftu  (faudes time units)
00335    *
00336    */
00337   virtual void TimeScale(unsigned int scale) {mTimeScale=scale; CurrentTime(0); };
00338 
00339 
00340   /**
00341    * Get timescale.
00342    *
00343    * @return
00344    *   Conversion factor in msecs/ftu  (faudes time units)
00345    *
00346    */
00347   virtual int TimeScale(void) {return mTimeScale;};
00348 
00349 
00350   /**
00351    * Clear all configuration.
00352    * This implies Stop().
00353    */
00354   virtual void Clear(void);
00355 
00356   /**
00357    * Insert/edit sensor or actuator configuration
00358    *
00359    * For a nontrivial device, a dynamic cast is used to
00360    * access the attribute parameter.
00361    *
00362    * @param event
00363    *   Sensor or actuator event by faudes index
00364    * @param attr
00365    *   Configuration attribute
00366    * @exception Exception
00367    *   - unknown event (id 65)
00368    *   - Cannot cast attribute (id 550)
00369    */
00370   virtual void Configure(Idx event, const AttributeDeviceEvent& attr);
00371 
00372   /**
00373    * Configure by alphabet
00374    *
00375    * For a nontrivial device, a dynamic cast is used to
00376    * access atributes of the alphabet parameter.
00377    *
00378    * @param rPhysicalEvents
00379    *   Event set with configuration attributes
00380    * @exception Exception
00381    *   - Cannot cast argument (id 550)
00382    */
00383   virtual void Configure(const EventSet& rPhysicalEvents);
00384 
00385 
00386    /**
00387     * Compile inner data-structures. 
00388     *
00389     * As every derived class may have its own individual inner data-structures to
00390     * set up, it has to reimplement its own Compile()-function if needed.
00391     *
00392     * In the base class Compile() builds up the sensor- and actuator event set.
00393     * 
00394     */
00395   virtual void Compile(void);
00396 
00397 
00398   /**
00399    * Get actuators as plain set.
00400    *
00401    * @return
00402    *   Set of all configured actuators
00403    */
00404   virtual const EventSet& Actuators(void) const;
00405 
00406   /**
00407    * Get sensors as plain set.
00408    *
00409    * @return
00410    *   Set of all configured sensors
00411    */
00412   virtual const EventSet& Sensors(void) const;
00413 
00414 
00415   /**
00416    * Reset device. Resets any dynamic state such as edge detection.
00417    * Since the vDevice only provides timing, it only resets the current faudes
00418    * time to zero. Does not stop the device.
00419    *
00420    */
00421   virtual void Reset(void);
00422 
00423   /**
00424    * Activate the device. This function enables actuator execution and sensor reading.
00425    * It will allocate device specific necessary resources eg start a background thread,
00426    * initialise operating system device drivers etc.
00427    *
00428    * @exception Exception
00429    *   - Not yet configured (id 551)
00430    */
00431   virtual void Start(void);
00432 
00433   /**
00434    * Deactivate the device. This function disables actuator execution and sensor reading.
00435    * Stop also runs Reset.
00436    *
00437    */
00438   virtual void Stop(void);
00439 
00440   /**
00441    * Get status. This function returns the current status of the device.
00442    * In derived classes that use background threads for sensor reading etc,
00443    * a device may change its status without notice. Stop runs Reset()
00444    *
00445    */
00446   virtual DeviceState Status(void) { return mState;};
00447 
00448   /**
00449    * Get status as infromal string.
00450    *
00451    */
00452   virtual std::string StatusString(void);
00453 
00454 
00455   /**
00456    * Run actuator command.
00457    *
00458    * @exception Exception
00459    *   - unknown actuator event (id 65)
00460    *
00461    */
00462   virtual void WriteActuator(Idx actuator)=0;
00463 
00464   /**
00465    * Read sensed sensor events.
00466    * Report the oldest event from the internal sensor buffer.
00467    * The event is removed from the buffer. The function returns
00468    * 0 if the buffer is empty.
00469    *
00470    */
00471   virtual Idx ReadSensor(void);
00472 
00473   /**
00474    * Peek for sensed events.
00475    * Report the oldest sensor-event from the buffer. However,
00476    * dont remove the event.
00477    *
00478    * @return
00479    *   Sensor-event index or 0 if no such available.
00480    */
00481   virtual Idx PeekSensor(void);
00482 
00483 
00484   /**
00485    * Report whether a sensor-event is ready
00486    */
00487   virtual bool SensorReady(void);
00488 
00489 
00490   /**
00491    * Wait for sensor trigger.
00492    *
00493    * The default implementation assumes that sensors events are
00494    * notified via the pthread condition signal. The duration to wait
00495    * is specified in faudes time units (ftu) and is converted to a pthraed
00496    * time spec by the scaling factor mTimeScale (ms/ftu).
00497    *
00498    * @return
00499    *   True, if events are available for read.
00500    */
00501   virtual bool WaitSensors(tpTime::Type duration);
00502 
00503   /**
00504    * Wait for sensor trigger.
00505    *
00506    * Same as WaitSensors, but with the maximum time to wait given in
00507    * msecs.
00508    *
00509    * @return
00510    *   True, if events are available for read.
00511    */
00512   virtual bool WaitSensorsMs(long int duration);
00513 
00514 
00515   /**
00516    * Report physical time in ftu.
00517    *
00518    * The time elapsed since the last reset is retunred
00519    * in faudes time units (ftu).
00520    *
00521    * @return
00522    *   Physical time.
00523    */
00524   virtual tpTime::Type CurrentTime(void);
00525 
00526   /**
00527    * Report physical time in ms
00528    *
00529    * The time elapsed since the last reset is returned
00530    * in msecs.
00531    *
00532    * @return
00533    *   Physical time.
00534    */
00535   virtual long int CurrentTimeMs(void);
00536 
00537   /**
00538    * Set physical time in ftu.
00539    * @param now
00540    *   physical time in faudes time units (ftu).
00541    */
00542   virtual void CurrentTime(tpTime::Type now);
00543 
00544 
00545   /**
00546    * Set physical time in ms.
00547    * @param nowms
00548    *   physical time in msec
00549    */
00550   virtual void CurrentTimeMs(long int nowms);
00551 
00552 
00553   /**
00554    * Compute time difference
00555    *
00556    * @return
00557    *   time difference
00558    * @param end
00559    *   end of time measurement
00560    * @param start
00561    *   begin of time measurement
00562    */
00563  static timeval DiffTime(timeval end, timeval start);
00564 
00565  /**
00566   * Compute time sum
00567   *
00568   * @return
00569   *   time sum
00570   * @param start
00571   *   Summand 1
00572   * @param duration
00573   *   Summand 2
00574   */
00575   static timeval SumTime(timeval start, timeval duration);
00576 
00577   /**
00578    * Convert faudes time unit duration to a pthread time spec
00579    *
00580    * Note: this helper function is not static since it refers to
00581    * the parameter mTimeScale.
00582    *
00583    * @return
00584    *  Absolut system-time form now + duration in the future
00585    * @param duration
00586    *  Time in fauDes-time
00587    */
00588   virtual timespec FtuToTimeSpec(tpTime::Type duration);
00589 
00590   /**
00591    * Convert msec duration to pthread timespec
00592    *
00593    * @return
00594    *  Absolut system-time form now + duration in the future
00595    * @param duration
00596    *  Time in msec
00597    */
00598    static timespec MsToTimeSpec(long int duration);
00599 
00600 
00601   /** Tell the device which condition to use for waiting*/
00602   void UseCondition(pthread_mutex_t* wmutex, pthread_cond_t* wcond);
00603 
00604   /** Tell the device which buffer to use for sensors */
00605   void UseBuffer(pthread_mutex_t* bmutex, std::deque<Idx>* bbuffer);
00606 
00607   /** Convenience method */
00608   virtual std::string EStr(Idx ev) {return Sensors().Str(ev);};
00609 
00610   /** Get performance (need compiletime option) */
00611   SampledDensityFunction Performance(void);
00612 
00613   /** Convenience method */
00614   void WritePerformance(void);
00615 
00616   /** 
00617    * Stop all devices.
00618    * This function is intended to be called on ungraceful termination of a
00619    * simulater application. It uses a global variable that tracks all device 
00620    * instances. 
00621    *
00622    */
00623   static void StopAll(void);
00624 
00625 protected:
00626 
00627   /**
00628    * Token output, see Type::Write for public wrappers.
00629    * The vDevice inplements token writing to consist of  DoWritePreface (device name and time scale).
00630    * and DoWriteConfiguration (device specific event attributes). The default label is taken from the 
00631    * member variable mDefaultLabel. Derived classes are meant to set mDefaultLabel in their constructor
00632    * and to reimplement DoWritePreface to add additional data eg cycle time or network address.
00633    * The parameter pContext is ignored and passed on.
00634    *
00635    * @param rTw
00636    *   Reference to TokenWriter
00637    * @param rLabel
00638    *   Label of section to write, defaults to name of set
00639    * @param pContext
00640    *   Write context to provide contextual information
00641    */
00642   virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="", const Type* pContext=0) const;
00643 
00644   /**  Writes non-event-configuration data from TokenWriter
00645    *
00646    * This function is part of the non-event-configuration token-output mechanism. The vDevice will write
00647    * its name and the time scale, derived classes are meant to first call the base class method and then
00648    * add additional configuration parameter. 
00649    *
00650    * Note: in order to keep the inputfile-layout as easy as possible no label will be used to separate
00651    * this data-section. Never the less a default-label ("Device") is specified.
00652    *
00653    * @param rTw
00654    *   TokenWriter to write to
00655    * @param rLabel
00656    *   Section to read
00657    * @param pContext
00658    *   Provide contextual information
00659    *
00660    * */
00661   virtual void DoWritePreface(TokenWriter& rTw, const std::string& rLabel="", const Type* pContext=0) const;
00662 
00663 
00664   /** Writes event-configuration to TokenWriter
00665    *
00666    * This function is part of the event-configuration token-output mechanism. It writes the device-specific
00667    * event-configuration to provided TokenWriter. It uses the virtual interface of TBaseSet to figure the
00668    * actual attribute type.
00669    *
00670    * Note: the event-configuration will be labeled by "EventConfiguration"
00671    *
00672    * @param rTw
00673    *   TokenWriter to write to
00674    * @param rLabel
00675    *   Section to write
00676    * @param pContext
00677    *   Provide contextual information
00678    *
00679    */
00680   virtual void DoWriteConfiguration(TokenWriter& rTw, const std::string& rLabel="", const Type* pContext=0) const;
00681 
00682   /**
00683    * Token input, see Type::DRead for public wrappers.
00684    * The vDevice implkements token input to consist of DoReadPreface (name, time scale etc) and DoReadConfiguration
00685    * (events attributes), followed by Compile (set up internal data structures). The default label is given by
00686    * the member variable mDefaultLabel. Derived classes arte meant to set mDefaultLabel in their constructor and
00687    * to reimplement DoReadPreface to cover additional parameters. The pContext parameter is ignored.
00688    *
00689    * @param rTr
00690    *   Reference to TokenReader
00691    * @param rLabel
00692    *   Label of section to write, defaults to name of set
00693    * @param pContext
00694    *   Write context to provide contextual information
00695    */
00696   virtual void DoRead(TokenReader& rTr, const std::string& rLabel = "", const Type* pContext=0);
00697 
00698   /** Default label for token io */
00699   std::string mDefaultLabel;
00700 
00701   /**  Reads non-event-configuration data from TokenReader
00702    *
00703    * This function is part of the non-event-configuration token-input mechanism and located at the top
00704    * of the class hierarchy. The vDevice will read its name and the time scale, derived classes are meant 
00705    * to first call the base class method and then read add additional configuration parameters. 
00706    *
00707    * Note: in order to keep the inputfile-layout as easy as possible no label will be used to separate
00708    *     this data-section. Never the less a default-label ("Device") is specified.
00709    *
00710    * @param rTr
00711    *   TokenReader to write
00712    * @param rLabel
00713    *   Section to read
00714    * @param pContext
00715    *   Provide contextual information
00716    *
00717    */
00718   virtual void DoReadPreface(TokenReader& rTr, const std::string& rLabel = "", const Type* pContext=0);
00719 
00720   /** Reads event-configuration data from TokenReader
00721    *
00722    * This function is part of the token-input mechanism and reads the device-specific event-configuration.
00723    * It uses the virtual interface of TBaseSet to figure the actual attribute type. The section defaults to
00724    * "EventConfiguration".
00725    *
00726    * @param rTr
00727    *   TokenReader to read
00728    * @param rLabel
00729    *   Section to read
00730    * @param pContext
00731       Provide contextual information
00732    * */
00733   virtual void DoReadConfiguration(TokenReader& rTr, const std::string& rLabel = "", const Type* pContext=0);
00734 
00735   /** Name */
00736   std::string mName;
00737 
00738   /** Overall event configuration (uses cast for type) */
00739   EventSet* mpConfiguration;
00740 
00741   /** All sensors */
00742   EventSet mSensors;
00743 
00744   /** All actuators */
00745   EventSet mActuators;
00746 
00747   /** Status: running, starting etc */
00748   DeviceState mState;
00749 
00750   /** Default Wait Condition Mutex */
00751   pthread_mutex_t mWaitMutex;
00752 
00753   /** Default Wait Condition */
00754   pthread_cond_t mWaitCondition;
00755 
00756   /** Actual  Wait Condition Mutex*/
00757   pthread_mutex_t* pWaitMutex;
00758 
00759   /** Actual Wait Condition */
00760   pthread_cond_t* pWaitCondition;
00761 
00762   /** physical timepoint zero  */
00763   timeval mTimeZero;
00764 
00765   /** FauDES-time: scaling factor in ms/ftu */
00766   int mTimeScale;
00767 
00768   /** Toleance for time sync */
00769   tpTime::Type mMaxSyncGap;
00770 
00771   /** Default Fifo buffer for sensor readings */
00772   std::deque<Idx> mSensorBuffer;
00773 
00774   /** Actual Fifo buffer for sensor readings */
00775   std::deque<Idx>* pSensorBuffer;
00776 
00777   /** Default mutex for sensor buffer (mutexted) */
00778   pthread_mutex_t mBufferMutex;
00779 
00780   /** Actual mutex for sensor buffer (mutexted) */
00781   pthread_mutex_t* pBufferMutex;
00782   
00783   /**
00784   * convert duration from fauDES-time units to ms
00785   *
00786   */
00787   virtual long int FtuToMs(tpTime::Type faudes_time);
00788 
00789   /**
00790    * convert duration in ms to faudes-time units
00791    *
00792    */
00793   virtual tpTime::Type MsToFtu(long int real_time);
00794 
00795 
00796 #ifdef FAUDES_DEBUG_IOPERF
00797 
00798   /** Max number of time stamps */
00799   #define FAUDES_DEBUG_IOPERF_SAMPLES 10000
00800 
00801   /** Filename for performance log */
00802   #define FAUDES_DEBUG_IOPERF_LOG "tmp_ioperformance.txt"
00803 
00804   /** Structures to store time-samples in */
00805   timeval* mpPerformanceWaitEnter;
00806   timeval* mpPerformanceWaitExit;
00807 
00808   /** Global iterator */
00809   int mPerformanceIterator;
00810 
00811 #endif
00812 
00813 private:
00814 
00815   static std::set<vDevice*> msAllDevices;
00816 
00817 }; // end class vDevice
00818 
00819 
00820 
00821 } // namespace faudes
00822 
00823 
00824 #endif
00825 

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