SMInterface.h
00001 #ifndef SMInterface_H_
00002 #define SMInterface_H_
00003
00004 #include <string>
00005 #include "UniSetTypes.h"
00006 #include "Mutex.h"
00007 #include "IONotifyController.h"
00008 #include "UniversalInterface.h"
00009 class SMInterface
00010 {
00011 public:
00012
00013 SMInterface( UniSetTypes::ObjectId _shmID, UniversalInterface* ui,
00014 UniSetTypes::ObjectId myid, IONotifyController* ic=0 );
00015 ~SMInterface();
00016
00017 void setState ( UniSetTypes::ObjectId, bool state );
00018 void setValue ( UniSetTypes::ObjectId, long value );
00019 bool saveState ( IOController_i::SensorInfo& si, bool state, UniversalIO::IOTypes type, UniSetTypes::ObjectId supplier );
00020 bool saveValue ( IOController_i::SensorInfo& si, long value, UniversalIO::IOTypes type, UniSetTypes::ObjectId supplier );
00021
00022 bool saveLocalState ( UniSetTypes::ObjectId id, bool state, UniversalIO::IOTypes type=UniversalIO::DigitalInput );
00023 bool saveLocalValue ( UniSetTypes::ObjectId id, long value, UniversalIO::IOTypes type=UniversalIO::AnalogInput );
00024
00025 void setUndefinedState( IOController_i::SensorInfo& si, bool undefined, UniSetTypes::ObjectId supplier );
00026
00027 long getValue ( UniSetTypes::ObjectId id );
00028 bool getState ( UniSetTypes::ObjectId id );
00029
00030 void askSensor( UniSetTypes::ObjectId id, UniversalIO::UIOCommand cmd,
00031 UniSetTypes::ObjectId backid = UniSetTypes::DefaultObjectId );
00032
00033 inline bool alarm( UniSetTypes::AlarmMessage& msg, UniSetTypes::ObjectId messenger )
00034 {
00035 return ui->alarm(msg,messenger);
00036 }
00037
00038 IOController_i::DSensorInfoSeq* getDigitalSensorsMap();
00039 IOController_i::ASensorInfoSeq* getAnalogSensorsMap();
00040 IONotifyController_i::ThresholdsListSeq* getThresholdsList();
00041
00042 void localSaveValue( IOController::AIOStateList::iterator& it,
00043 UniSetTypes::ObjectId sid,
00044 CORBA::Long newvalue, UniSetTypes::ObjectId sup_id );
00045
00046 void localSaveState( IOController::DIOStateList::iterator& it,
00047 UniSetTypes::ObjectId sid,
00048 CORBA::Boolean newstate, UniSetTypes::ObjectId sup_id );
00049
00050 void localSetState( IOController::DIOStateList::iterator& it,
00051 UniSetTypes::ObjectId sid,
00052 CORBA::Boolean newstate, UniSetTypes::ObjectId sup_id );
00053
00054 void localSetValue( IOController::AIOStateList::iterator& it,
00055 UniSetTypes::ObjectId sid,
00056 CORBA::Long value, UniSetTypes::ObjectId sup_id );
00057
00058 bool localGetState( IOController::DIOStateList::iterator& it,
00059 UniSetTypes::ObjectId sid );
00060 long localGetValue( IOController::AIOStateList::iterator& it,
00061 UniSetTypes::ObjectId sid );
00062
00067 void localSetUndefinedState( IOController::AIOStateList::iterator& it,
00068 bool undefined, UniSetTypes::ObjectId sid );
00069
00070
00071 IOController::DIOStateList::iterator dioEnd();
00072 IOController::AIOStateList::iterator aioEnd();
00073 void initAIterator( IOController::AIOStateList::iterator& it );
00074 void initDIterator( IOController::DIOStateList::iterator& it );
00075
00076 bool exist();
00077 bool waitSMready( int msec, int pause=5000 );
00078 bool waitSMworking( UniSetTypes::ObjectId, int msec, int pause=3000 );
00079
00080 inline bool isLocalwork(){ return (ic==NULL); }
00081 inline UniSetTypes::ObjectId ID(){ return myid; }
00082 inline IONotifyController* SM(){ return ic; }
00083 inline UniSetTypes::ObjectId getSMID(){ return shmID; }
00084
00085 protected:
00086 IONotifyController* ic;
00087 UniversalInterface* ui;
00088 CORBA::Object_var oref;
00089 UniSetTypes::ObjectId shmID;
00090 UniSetTypes::ObjectId myid;
00091 UniSetTypes::uniset_mutex shmMutex;
00092 };
00093
00094
00095 #endif