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