174 const std::shared_ptr<SharedMemory>& ic =
nullptr,
175 const std::string& prefix =
"opcua");
179 virtual CORBA::Boolean exist()
override;
182 static std::shared_ptr<OPCUAServer>
init_opcua_server(
int argc,
const char*
const* argv,
184 const std::shared_ptr<SharedMemory>& ic =
nullptr,
185 const std::string& prefix =
"opcua");
190 using DefaultValueType = int32_t;
191 using DefaultValueUType = uint32_t;
192 static const opcua::DataTypeId DefaultVariableType = { opcua::DataTypeId::Int32 };
194 static uint8_t firstBit( DefaultValueUType mask );
196 static DefaultValueUType getBits( DefaultValueUType value, DefaultValueUType mask, uint8_t offset );
198 static DefaultValueUType setBits( DefaultValueUType value, DefaultValueUType set, DefaultValueUType mask, uint8_t offset );
200 static DefaultValueUType forceSetBits( DefaultValueUType value, DefaultValueUType set, DefaultValueUType mask, uint8_t offset );
202 static UA_StatusCode UA_setValueMethod(UA_Server* server,
const UA_NodeId* sessionId,
void* sessionHandle,
203 const UA_NodeId* methodId,
void* methodContext,
const UA_NodeId* objectId,
204 void* objectContext,
size_t inputSize,
const UA_Variant* input,
size_t outputSize, UA_Variant* output);
206#ifndef DISABLE_REST_API
208 virtual Poco::JSON::Object::Ptr httpHelp(
const Poco::URI::QueryParameters& p )
override;
210 virtual Poco::JSON::Object::Ptr httpGetMyInfo( Poco::JSON::Object::Ptr root )
override;
213 Poco::JSON::Object::Ptr httpSensors(
const Poco::URI::QueryParameters& p );
214 Poco::JSON::Object::Ptr httpGet(
const Poco::URI::QueryParameters& p );
220 virtual void callback()
noexcept override;
223 virtual void askSensors(UniversalIO::UIOCommand cmd)
override;
226 void serverLoopTerminate();
231#ifndef DISABLE_REST_API
233 virtual Poco::JSON::Object::Ptr httpGetParam(
const Poco::URI::QueryParameters& p );
234 virtual Poco::JSON::Object::Ptr httpSetParam(
const Poco::URI::QueryParameters& p );
237 Poco::JSON::Object::Ptr httpStatus();
238 Poco::JSON::Object::Ptr buildLogServerInfo();
241 bool httpEnabledSetParams {
true };
244 bool readItem(
const std::shared_ptr<UniXML>& xml,
UniXML::iterator& it, xmlNode* sec);
245 void readConfiguration();
247 std::shared_ptr<SMInterface> shm;
248 std::unique_ptr<ThreadCreator<OPCUAServer>> serverThread;
249 std::unique_ptr<ThreadCreator<OPCUAServer>> updateThread;
253 IOVariable(
const opcua::Node<opcua::Server>& n) : node(n) {};
254 opcua::Node<opcua::Server> node;
255 IOController::IOStateList::iterator it;
256 UniversalIO::IOType stype = { UniversalIO::AO };
259 DefaultValueType value = { 0 };
260 bool state = {
false };
261 DefaultValueUType mask = { 0 };
262 uint8_t offset = { 0 };
263 opcua::DataTypeId vtype = { DefaultVariableType };
264 uint8_t precision = { 0 };
267 std::unordered_map<ObjectId, IOVariable> variables;
268 size_t writeCount = { 0 };
272 opcua::Node<opcua::Server> node;
273 IONode(
const opcua::Node<opcua::Server>& n ): node(n) {};
280 IOController::IOStateList::iterator it;
282 uint8_t precision = { 0 };
285 std::unordered_map<uint32_t, IOMethod> methods;
286 size_t methodCount = { 0 };
289 opcua::Server opcServer;
290 std::unique_ptr<IONode> ioNode = {
nullptr };
292 std::string propPrefix;
294 std::string s_fvalue;
295 std::optional<std::regex> s_fvalue_re;
296 std::string namePrefix;
297 uniset::timeout_t updateTime_msec = { 100 };
298 std::atomic_bool firstUpdate =
false;
299 std::shared_ptr<LogServer> logserv;
300 std::string logserv_host = {
""};
301 int logserv_port = {0};
303 using folderMap = std::unordered_map<std::string, std::unique_ptr<IONode>>;
341 case opcua::LogCategory::Network:
344 case opcua::LogCategory::SecureChannel:
347 case opcua::LogCategory::Session:
350 case opcua::LogCategory::Server:
353 case opcua::LogCategory::Client:
356 case opcua::LogCategory::Userland:
359 case opcua::LogCategory::SecurityPolicy:
360 return "securitypolicy";
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:669
Definition UHttpRequestHandler.h:87