171 const std::shared_ptr<SharedMemory>& ic =
nullptr,
172 const std::string& prefix =
"opcua");
176 virtual CORBA::Boolean exist()
override;
179 static std::shared_ptr<OPCUAServer>
init_opcua_server(
int argc,
const char*
const* argv,
181 const std::shared_ptr<SharedMemory>& ic =
nullptr,
182 const std::string& prefix =
"opcua");
187 using DefaultValueType = int32_t;
188 using DefaultValueUType = uint32_t;
189 static const opcua::Type DefaultVariableType = { opcua::Type::Int32 };
191 static uint8_t firstBit( DefaultValueUType mask );
193 static DefaultValueUType getBits( DefaultValueUType value, DefaultValueUType mask, uint8_t offset );
195 static DefaultValueUType setBits( DefaultValueUType value, DefaultValueUType set, DefaultValueUType mask, uint8_t offset );
197 static DefaultValueUType forceSetBits( DefaultValueUType value, DefaultValueUType set, DefaultValueUType mask, uint8_t offset );
199 static UA_StatusCode UA_setValueMethod(UA_Server* server,
const UA_NodeId* sessionId,
void* sessionHandle,
200 const UA_NodeId* methodId,
void* methodContext,
const UA_NodeId* objectId,
201 void* objectContext,
size_t inputSize,
const UA_Variant* input,
size_t outputSize, UA_Variant* output);
206 virtual void callback()
noexcept override;
209 virtual void askSensors(UniversalIO::UIOCommand cmd)
override;
212 void serverLoopTerminate();
218 bool readItem(
const std::shared_ptr<UniXML>& xml,
UniXML::iterator& it, xmlNode* sec);
219 void readConfiguration();
221 std::shared_ptr<SMInterface> shm;
222 std::unique_ptr<ThreadCreator<OPCUAServer>> serverThread;
223 std::unique_ptr<ThreadCreator<OPCUAServer>> updateThread;
227 IOVariable(
const opcua::Node<opcua::Server>& n) : node(n) {};
228 opcua::Node<opcua::Server> node;
229 IOController::IOStateList::iterator it;
230 UniversalIO::IOType stype = { UniversalIO::AO };
233 DefaultValueType value = { 0 };
234 bool state = {
false };
235 DefaultValueUType mask = { 0 };
236 uint8_t offset = { 0 };
237 opcua::Type vtype = { DefaultVariableType };
238 uint8_t precision = { 0 };
241 std::unordered_map<ObjectId, IOVariable> variables;
242 size_t writeCount = { 0 };
246 opcua::Node<opcua::Server> node;
247 IONode(
const opcua::Node<opcua::Server>& n ): node(n) {};
254 IOController::IOStateList::iterator it;
256 uint8_t precision = { 0 };
259 std::unordered_map<uint32_t, IOMethod> methods;
260 size_t methodCount = { 0 };
263 std::unique_ptr<opcua::Server> opcServer = {
nullptr };
264 std::unique_ptr<IONode> ioNode = {
nullptr };
266 std::string propPrefix;
268 std::string s_fvalue;
269 std::optional<std::regex> s_fvalue_re;
270 std::string namePrefix;
271 uniset::timeout_t updateTime_msec = { 100 };
272 std::atomic_bool firstUpdate =
false;
274 using folderMap = std::unordered_map<std::string, std::unique_ptr<IONode>>;
virtual bool deactivateObject() override
Деактивация объекта (переопределяется для необходимых действий при завершении работы)
Definition OPCUAServer.cc:565
static std::shared_ptr< OPCUAServer > init_opcua_server(int argc, const char *const *argv, uniset::ObjectId shmID, const std::shared_ptr< SharedMemory > &ic=nullptr, const std::string &prefix="opcua")
Definition OPCUAServer.cc:620