UniSet 2.32.1
UniExchange.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 UniExchange_H_
18#define UniExchange_H_
19// -----------------------------------------------------------------------------
20#include <list>
21#include <memory>
22#include "UniXML.h"
23#include "IOController.h"
24#include "SMInterface.h"
25#include "SharedMemory.h"
26#include "PassiveTimer.h"
27// --------------------------------------------------------------------------
28namespace uniset
29{
30 // -----------------------------------------------------------------------------
53 // -----------------------------------------------------------------------------
55 public IOController
56 {
57 public:
59 const std::shared_ptr<SharedMemory>& ic = nullptr, const std::string& prefix = "unet" );
60 virtual ~UniExchange();
61
62 void execute();
63
64 static std::shared_ptr<UniExchange> init_exchange( int argc, const char* const* argv,
65 uniset::ObjectId shmID, const std::shared_ptr<SharedMemory>& ic = nullptr,
66 const std::string& prefix = "unet" );
67
69 static void help_print( int argc, const char** argv );
70
71 virtual IOController_i::ShortMapSeq* getSensors() override;
72
73 protected:
74
75 virtual void sysCommand( const uniset::SystemMessage* sm ) override;
76 virtual void askSensors( UniversalIO::UIOCommand cmd );
77 virtual bool deactivateObject() override;
78
79 xmlNode* cnode = { 0 };
80 std::string s_field = { "" };
81 std::string s_fvalue = { "" };
82 std::shared_ptr<SMInterface> shm;
83
84 struct SInfo
85 {
86 // т.к. содержится rwmutex с запрещённым конструктором копирования
87 // приходится здесь тоже объявлять разрешенными только операции "перемещения"
88 SInfo( const SInfo& r ) = delete;
89 SInfo& operator=(const SInfo& r) = delete;
90 SInfo( SInfo&& r ) = default;
91 SInfo& operator=(SInfo&& r) = default;
92
93 SInfo():
94 val(0),
96 type(UniversalIO::UnknownIOType)
97 {}
98
99 IOController::IOStateList::iterator ioit;
100 long val;
101 long id;
102 UniversalIO::IOType type;
103 mutable uniset::uniset_rwmutex val_lock;
104 };
105
106 typedef std::vector<SInfo> SList;
107
109 {
110 // т.к. содержится SList в котором rwmutex с запрещённым конструктором копирования
111 // приходится здесь тоже объявлять разрешенными только операции "перемещения"
112 NetNodeInfo( const NetNodeInfo& r ) = delete;
113 NetNodeInfo& operator=(const NetNodeInfo& r) = delete;
114 NetNodeInfo( NetNodeInfo&& r ) = default;
115 NetNodeInfo& operator=(NetNodeInfo&& r) = default;
116
117 NetNodeInfo();
118
119 CORBA::Object_var oref;
120 IOController_i_var shm;
122 uniset::ObjectId node;
124 IOController::IOStateList::iterator conn_it;
125 SList smap;
126
127 void update(IOController_i::ShortMapSeq_var& map, const std::shared_ptr<SMInterface>& shm );
128 };
129
130 typedef std::list<NetNodeInfo> NetNodeList;
131 NetNodeList nlst;
132
133 void readConfiguration();
134 bool readItem( const std::shared_ptr<UniXML>& xml, UniXML::iterator& it, xmlNode* sec );
135 bool initItem( UniXML::iterator& it );
136 void updateLocalData();
137 void initIterators();
138
139 timeout_t polltime = { 200 };
140 PassiveTimer ptUpdate;
141 bool init_ok = { false };
142
143 SList mymap;
144 size_t maxIndex = { 0 };
145 timeout_t smReadyTimeout = { 60000 }; // msec
146
147 std::atomic_bool cancelled = { false };
148
149 private:
150 };
151 // --------------------------------------------------------------------------
152} // end of namespace uniset
153// -----------------------------------------------------------------------------
154#endif // UniExchange_H_
Definition IOController.h:50
Пассивный таймер
Definition PassiveTimer.h:94
Definition MessageType.h:171
Definition UniExchange.h:56
static void help_print(int argc, const char **argv)
Definition UniExchange.cc:470
virtual bool deactivateObject() override
Definition UniExchange.cc:339
Definition UniXML.h:44
Definition Mutex.h:32
Definition Calibration.h:27
const ObjectId DefaultObjectId
Definition UniSetTypes.h:71
long ObjectId
Definition UniSetTypes_i.idl:30
Definition UniExchange.h:109
uniset::ObjectId sidConnection
Definition UniExchange.h:123
Definition UniExchange.h:85