UniSet  2.2.1
SMInterface.h
00001 #ifndef SMInterface_H_
00002 #define SMInterface_H_
00003 //--------------------------------------------------------------------------
00004 #include <string>
00005 #include <memory>
00006 #include "UniSetTypes.h"
00007 #include "Mutex.h"
00008 #include "IONotifyController.h"
00009 #include "UInterface.h"
00010 class SMInterface
00011 {
00012     public:
00013 
00014         SMInterface( UniSetTypes::ObjectId _shmID, const std::shared_ptr<UInterface>& ui,
00015                      UniSetTypes::ObjectId myid, const std::shared_ptr<IONotifyController> ic = nullptr );
00016         ~SMInterface();
00017 
00018         void setValue ( UniSetTypes::ObjectId, long value );
00019         void setUndefinedState( const IOController_i::SensorInfo& si, bool undefined, UniSetTypes::ObjectId supplier );
00020 
00021         long getValue ( UniSetTypes::ObjectId id );
00022 
00023         void askSensor( UniSetTypes::ObjectId id, UniversalIO::UIOCommand cmd,
00024                         UniSetTypes::ObjectId backid = UniSetTypes::DefaultObjectId );
00025 
00026         IOController_i::SensorInfoSeq* getSensorsMap();
00027         IONotifyController_i::ThresholdsListSeq* getThresholdsList();
00028 
00029         void localSetValue( IOController::IOStateList::iterator& it,
00030                             UniSetTypes::ObjectId sid,
00031                             CORBA::Long newvalue, UniSetTypes::ObjectId sup_id );
00032 
00033         long localGetValue( IOController::IOStateList::iterator& it,
00034                             UniSetTypes::ObjectId sid );
00035 
00040         void localSetUndefinedState( IOController::IOStateList::iterator& it,
00041                                      bool undefined, UniSetTypes::ObjectId sid );
00042 
00043         // специальные функции
00044         IOController::IOStateList::iterator ioEnd();
00045         void initIterator( IOController::IOStateList::iterator& it );
00046 
00047         bool exist();
00048         bool waitSMready( int msec, int pause = 5000 );
00049         bool waitSMworking( UniSetTypes::ObjectId, int msec, int pause = 3000 );
00050 
00051         inline bool isLocalwork()
00052         {
00053             return (ic == NULL);
00054         }
00055         inline UniSetTypes::ObjectId ID()
00056         {
00057             return myid;
00058         }
00059         inline const std::shared_ptr<IONotifyController> SM()
00060         {
00061             return ic;
00062         }
00063         inline UniSetTypes::ObjectId getSMID()
00064         {
00065             return shmID;
00066         }
00067 
00068     protected:
00069         const std::shared_ptr<IONotifyController> ic;
00070         const std::shared_ptr<UInterface> ui;
00071         CORBA::Object_var oref;
00072         UniSetTypes::ObjectId shmID;
00073         UniSetTypes::ObjectId myid;
00074         UniSetTypes::uniset_rwmutex shmMutex;
00075 };
00076 
00077 //--------------------------------------------------------------------------
00078 #endif