UniSet  2.6.0
SMInterface.h
1 /*
2  * Copyright (c) 2015 Pavel Vainerman.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as
6  * published by the Free Software Foundation, version 2.1.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Lesser Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 //--------------------------------------------------------------------------
17 #ifndef SMInterface_H_
18 #define SMInterface_H_
19 //--------------------------------------------------------------------------
20 #include <string>
21 #include <memory>
22 #include "UniSetTypes.h"
23 #include "Mutex.h"
24 #include "IONotifyController.h"
25 #include "UInterface.h"
26 // --------------------------------------------------------------------------
27 namespace uniset
28 {
29  // --------------------------------------------------------------------------
31  {
32  public:
33 
34  SMInterface( uniset::ObjectId _shmID, const std::shared_ptr<UInterface>& ui,
35  uniset::ObjectId myid, const std::shared_ptr<IONotifyController> ic = nullptr );
36  ~SMInterface();
37 
38  void setValue ( uniset::ObjectId, long value );
39  void setUndefinedState( const IOController_i::SensorInfo& si, bool undefined, uniset::ObjectId supplier );
40 
41  long getValue ( uniset::ObjectId id );
42 
43  void askSensor( uniset::ObjectId id, UniversalIO::UIOCommand cmd,
45 
46  IOController_i::SensorInfoSeq* getSensorsMap();
47  IONotifyController_i::ThresholdsListSeq* getThresholdsList();
48 
49  void localSetValue( IOController::IOStateList::iterator& it,
50  uniset::ObjectId sid,
51  CORBA::Long newvalue, uniset::ObjectId sup_id );
52 
53  long localGetValue( IOController::IOStateList::iterator& it,
54  uniset::ObjectId sid );
55 
60  void localSetUndefinedState( IOController::IOStateList::iterator& it,
61  bool undefined, uniset::ObjectId sid );
62 
63  // специальные функции
64  IOController::IOStateList::iterator ioEnd();
65  void initIterator( IOController::IOStateList::iterator& it );
66 
67  bool exist();
68  bool waitSMready( int msec, int pause = 5000 );
69  bool waitSMworking( uniset::ObjectId, int msec, int pause = 3000 );
70 
71  inline bool isLocalwork() const noexcept
72  {
73  return (ic == NULL);
74  }
75  inline uniset::ObjectId ID() const noexcept
76  {
77  return myid;
78  }
79  inline const std::shared_ptr<IONotifyController> SM() noexcept
80  {
81  return ic;
82  }
83  inline uniset::ObjectId getSMID() const noexcept
84  {
85  return shmID;
86  }
87 
88 #ifndef DISABLE_REST_API
89  std::string apiRequest( const std::string& query );
90 #endif
91 
92  protected:
93  const std::shared_ptr<IONotifyController> ic;
94  const std::shared_ptr<UInterface> ui;
95  CORBA::Object_var oref;
96  uniset::ObjectId shmID;
97  uniset::ObjectId myid;
98  uniset::uniset_rwmutex shmMutex;
99  };
100  // --------------------------------------------------------------------------
101 } // end of namespace uniset
102 //--------------------------------------------------------------------------
103 #endif
Definition: SMInterface.h:30
Definition: CallbackTimer.h:29
const ObjectId DefaultObjectId
Definition: UniSetTypes.h:56
void localSetUndefinedState(IOController::IOStateList::iterator &it, bool undefined, uniset::ObjectId sid)
Definition: SMInterface.cc:251
Definition: Mutex.h:32
Definition: IOController_i.idl:56
long ObjectId
Definition: UniSetTypes_i.idl:30