00001
00002 #ifndef IOBase_H_
00003 #define IOBase_H_
00004
00005 #include <string>
00006 #include "PassiveTimer.h"
00007 #include "Trigger.h"
00008 #include "Mutex.h"
00009 #include "DigitalFilter.h"
00010 #include "Calibration.h"
00011 #include "IOController.h"
00012 #include "SMInterface.h"
00013
00014 static const int DefaultSubdev = -1;
00015 static const int DefaultChannel = -1;
00016 static const int NoSafety = -1;
00017
00019 struct IOBase
00020 {
00021 IOBase():
00022 cdiagram(0),
00023 breaklim(0),
00024 value(0),
00025 craw(0),
00026 safety(0),
00027 defval(0),
00028 df(1),
00029 nofilter(false),
00030 f_median(false),
00031 f_ls(false),
00032 f_filter_iir(false),
00033 ignore(false),
00034 invert(false),
00035 noprecision(false),
00036 jar_state(false),
00037 ondelay_state(false),
00038 offdelay_state(false),
00039 d_id(UniSetTypes::DefaultObjectId),
00040 d_value(0),
00041 d_off_value(0),
00042 d_iotype(UniversalIO::UnknownIOType),
00043 t_ai(UniSetTypes::DefaultObjectId)
00044 {}
00045
00046
00047 bool check_channel_break( long val );
00049 bool check_jar( bool val );
00050 bool check_on_delay( bool val );
00051 bool check_off_delay( bool val );
00053 bool check_depend( SMInterface* shm );
00055 IOController_i::SensorInfo si;
00056 UniversalIO::IOTypes stype;
00057 IOController_i::CalibrateInfo cal;
00058 Calibration* cdiagram;
00060 long breaklim;
00061 long value;
00062 long craw;
00063 long cprev;
00064 long safety;
00065 long defval;
00067 DigitalFilter df;
00068 bool nofilter;
00069 bool f_median;
00070 bool f_ls;
00071 bool f_filter_iir;
00073 bool ignore;
00074 bool invert;
00075 bool noprecision;
00076
00077 PassiveTimer ptJar;
00078 PassiveTimer ptOnDelay;
00079 PassiveTimer ptOffDelay;
00081 bool jar_pause;
00082 Trigger trOnDelay;
00083 Trigger trOffDelay;
00084 Trigger trJar;
00085
00086 bool jar_state;
00087 bool ondelay_state;
00088 bool offdelay_state;
00090
00091 UniSetTypes::ObjectId d_id;
00092 IOController::AIOStateList::iterator d_ait;
00093 IOController::DIOStateList::iterator d_dit;
00094 long d_value;
00095 long d_off_value;
00096 UniversalIO::IOTypes d_iotype;
00097
00098
00099 UniSetTypes::ObjectId t_ai;
00103 IONotifyController_i::ThresholdInfo ti;
00104
00105
00106 IOController::AIOStateList::iterator ait;
00107 IOController::DIOStateList::iterator dit;
00108 UniSetTypes::uniset_spin_mutex val_lock;
00110 friend std::ostream& operator<<(std::ostream& os, IOBase& inf );
00111
00112 static void processingFasAI( IOBase* it, float new_val, SMInterface* shm, bool force );
00113 static void processingAsAI( IOBase* it, long new_val, SMInterface* shm, bool force );
00114 static void processingAsDI( IOBase* it, bool new_set, SMInterface* shm, bool force );
00115 static long processingAsAO( IOBase* it, SMInterface* shm, bool force );
00116 static float processingFasAO( IOBase* it, SMInterface* shm, bool force );
00117 static bool processingAsDO( IOBase* it, SMInterface* shm, bool force );
00118 static void processingThreshold( IOBase* it, SMInterface* shm, bool force );
00119 static bool initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
00120 DebugStream* dlog=0, std::string myname="",
00121 int def_filtersize=0, float def_filterT=0.0,
00122 float def_lsparam=0.2, float def_iir_coeff_prev=0.5,
00123 float def_iir_coeff_new=0.5 );
00124 };
00125
00126
00127
00128
00129 #endif // IOBase_H_
00130