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