UniSet 2.32.1
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 <atomic>
23#include "UniSetTypes.h"
24#include "Mutex.h"
25#include "IONotifyController.h"
26#include "UInterface.h"
27// --------------------------------------------------------------------------
28namespace uniset
29{
30 // --------------------------------------------------------------------------
32 {
33 public:
34
35 SMInterface( uniset::ObjectId _shmID, const std::shared_ptr<UInterface>& ui,
36 uniset::ObjectId myid, const std::shared_ptr<IONotifyController> ic = nullptr );
38
39 void setValue ( uniset::ObjectId, long value );
40 void setUndefinedState( const IOController_i::SensorInfo& si, bool undefined, uniset::ObjectId supplier );
41
42 long getValue ( uniset::ObjectId id );
43
44 void askSensor( uniset::ObjectId id, UniversalIO::UIOCommand cmd,
46
47 void freezeValue( uniset::ObjectId id, bool set, long value, uniset::ObjectId supplier );
48
49 IOController_i::SensorInfoSeq* getSensorsMap();
50 IONotifyController_i::ThresholdsListSeq* getThresholdsList();
51
52 void localSetValue( IOController::IOStateList::iterator& it,
54 CORBA::Long newvalue, uniset::ObjectId sup_id );
55
56 long localGetValue( IOController::IOStateList::iterator& it,
57 uniset::ObjectId sid );
58
63 void localSetUndefinedState( IOController::IOStateList::iterator& it,
64 bool undefined, uniset::ObjectId sid );
65
66 // специальные функции
67 IOController::IOStateList::iterator ioEnd();
68 void initIterator( IOController::IOStateList::iterator& it );
69
70 bool exist();
71 bool waitSMready( int msec, int pause = 5000 );
72 bool waitSMworking( uniset::ObjectId, int msec, int pause = 3000 );
73 bool waitSMreadyWithCancellation( int msec, std::atomic_bool& cancelFlag, int pause = 5000 );
74 bool waitSMworkingWithCancellation( uniset::ObjectId sid, int ready_timeout, std::atomic_bool& cancelFlag, int pmsec );
75
76 inline bool isLocalwork() const noexcept
77 {
78 return (ic == NULL);
79 }
80 inline uniset::ObjectId ID() const noexcept
81 {
82 return myid;
83 }
84 inline const std::shared_ptr<IONotifyController> SM() noexcept
85 {
86 return ic;
87 }
88 inline uniset::ObjectId getSMID() const noexcept
89 {
90 return shmID;
91 }
92
93#ifndef DISABLE_REST_API
94 std::string apiRequest( const std::string& query );
95#endif
96
97 protected:
98 const std::shared_ptr<IONotifyController> ic;
99 const std::shared_ptr<UInterface> ui;
100 CORBA::Object_var oref;
101 uniset::ObjectId shmID;
102 uniset::ObjectId myid;
103 uniset::uniset_rwmutex shmMutex;
104 };
105 // --------------------------------------------------------------------------
106} // end of namespace uniset
107//--------------------------------------------------------------------------
108#endif
Definition SMInterface.h:32
void localSetUndefinedState(IOController::IOStateList::iterator &it, bool undefined, uniset::ObjectId sid)
Definition SMInterface.cc:267
Definition Mutex.h:32
Definition Calibration.h:27
const ObjectId DefaultObjectId
Definition UniSetTypes.h:71
long ObjectId
Definition UniSetTypes_i.idl:30
Definition IOController_i.idl:58