open62541 server -- probelm with UA_Server_readValue
-
I have a client write based on qtopcua and open62541 example .... working good with many plc server ..... read and write some bool, string and uint16 or uint32 variable ...
Now i try to write my own server, based on example /qtopcua/examples/opcua/waterpump/simulationserver. .... server go on, can write variable from server gui and see these one change in many qt client (2 test pc's ) .... but unable to see variable change on to server gui when var are change by client. I add only a test mainwindows over example ....
Server gui I use is composed with a server class, extern var and mainwindows .... mainwindows and server calss start from main ... than server run on qtimer event exactly as example .... from main can change extern var and inside mycall::processServerEvents() can write and read these ....
When client try to change these variable .... i see GOOD as debug response (from qDebug() << "write or not? ..." << QOpcUa::UaStatusCode();), I see the same on other client connect on same server.
I can change same var many time from remote 2 client and one client start on same pc where run server .... change in one and see change on other two .... end vice versa .... only Mainwindows of server not perform the change ....
Variable change (so for sure server perform the change) .... but unable to capture these change event of variable .... example of my node:
myserver.h extern bool Start_t; ***** UA_NodeId m_var; myserver.cpp bool Start_t = 0; void myserver::::launch() { s = UA_Server_run_startup(m_server); if (s != UA_STATUSCODE_GOOD) qFatal("Could not launch server"); m_running = true; m_timer.start(); UA_NodeId machineObject = addObject(QOpcUa::namespace0Id(QOpcUa::NodeIds::Namespace0::ObjectsFolder), "ns=2;s=a_OpcUa", "a_OpcUa", "a_OpcUa", "The machine I/O shared", UA_NS0ID_ORGANIZES); UA_NodeId In = addObject("ns=2;s=a_OpcUa", "ns=2;s=a_OpcUa.In", "In", "In 2"); m_St = addVariable(machineObject, "ns=2;s=a_OpcUa.In.Start", "BoolStart", "Start", Start_t, QOpcUa::Types::Boolean); UA_NodeId tempId; tempId = addVariable(machineObject, "ns=2;s=a_OpcUa.varInt", "varInt", "var Int", Num_t, QOpcUa::Types::UInt32); UA_NodeId_deleteMembers(&tempId); UA_MonitoredItemCreateRequest_default(m_St); }for st_t variable i'm not able to grab an event to force an update of value when change is performed from one or other client .... but every client can see st_t change when write from server gui but when is write from other client too .... so think only gui is unable to get a return value of st_t after client change.
for sure I've cancel every "method" inside void launch .... because in my mind I hope
UA_Server_run_iterate(m_server, true);inside void myserver::procesevent .... can change every variable on node declared .... so I try to grab the change with UA_Server_readValue write just after iterate call.
-
@gfxx add some other test ....
bool bv = false; bool bv1 = false; UA_Variant vb1; UA_Variant *val2 = UA_Variant_new(); int check = 0; retval = UA_Server_readValue(this->m_server, this->m_StopCiclo, val2); vb1 = *(UA_Variant*)val2->data; if(retval == UA_STATUSCODE_GOOD) bv = true; if(val2->type == &UA_TYPES[UA_TYPES_BOOLEAN]) bv1 = true; if((retval == UA_STATUSCODE_GOOD) && (val2->type == &UA_TYPES[UA_TYPES_BOOLEAN])) { vb1 = *(UA_Variant*)val2->data;} qDebug() << "status code right? ..." << bv << " variant type is [UA_TYPES_BOOLEAN]) " << bv1 << " array size is " << val2->arrayDimensionsSize <<" data " << val2->data;I have always same result .... retval TRUE, TYPE true (so UA_TYPES_BOOLEAN), array leght "0" and val2-> data number change continuosly and randomly .... someone can send me in right directions??
regards
@gfxx for bool var only solution seems easy ...
retval = UA_Server_readValue(this->m_server, this->m_StopCiclo, &val2); if((retval == UA_STATUSCODE_GOOD) && (val2.type == &UA_TYPES[UA_TYPES_BOOLEAN])) {Stop_bv = (((UA_Boolean*)val2.data)[0]); Stop = Stop_bv; }where Stop_bv and is bool var used for manipulate gui .... Stop is bool var used for write server node;
-
I have a client write based on qtopcua and open62541 example .... working good with many plc server ..... read and write some bool, string and uint16 or uint32 variable ...
Now i try to write my own server, based on example /qtopcua/examples/opcua/waterpump/simulationserver. .... server go on, can write variable from server gui and see these one change in many qt client (2 test pc's ) .... but unable to see variable change on to server gui when var are change by client. I add only a test mainwindows over example ....
Server gui I use is composed with a server class, extern var and mainwindows .... mainwindows and server calss start from main ... than server run on qtimer event exactly as example .... from main can change extern var and inside mycall::processServerEvents() can write and read these ....
When client try to change these variable .... i see GOOD as debug response (from qDebug() << "write or not? ..." << QOpcUa::UaStatusCode();), I see the same on other client connect on same server.
I can change same var many time from remote 2 client and one client start on same pc where run server .... change in one and see change on other two .... end vice versa .... only Mainwindows of server not perform the change ....
Variable change (so for sure server perform the change) .... but unable to capture these change event of variable .... example of my node:
myserver.h extern bool Start_t; ***** UA_NodeId m_var; myserver.cpp bool Start_t = 0; void myserver::::launch() { s = UA_Server_run_startup(m_server); if (s != UA_STATUSCODE_GOOD) qFatal("Could not launch server"); m_running = true; m_timer.start(); UA_NodeId machineObject = addObject(QOpcUa::namespace0Id(QOpcUa::NodeIds::Namespace0::ObjectsFolder), "ns=2;s=a_OpcUa", "a_OpcUa", "a_OpcUa", "The machine I/O shared", UA_NS0ID_ORGANIZES); UA_NodeId In = addObject("ns=2;s=a_OpcUa", "ns=2;s=a_OpcUa.In", "In", "In 2"); m_St = addVariable(machineObject, "ns=2;s=a_OpcUa.In.Start", "BoolStart", "Start", Start_t, QOpcUa::Types::Boolean); UA_NodeId tempId; tempId = addVariable(machineObject, "ns=2;s=a_OpcUa.varInt", "varInt", "var Int", Num_t, QOpcUa::Types::UInt32); UA_NodeId_deleteMembers(&tempId); UA_MonitoredItemCreateRequest_default(m_St); }for st_t variable i'm not able to grab an event to force an update of value when change is performed from one or other client .... but every client can see st_t change when write from server gui but when is write from other client too .... so think only gui is unable to get a return value of st_t after client change.
for sure I've cancel every "method" inside void launch .... because in my mind I hope
UA_Server_run_iterate(m_server, true);inside void myserver::procesevent .... can change every variable on node declared .... so I try to grab the change with UA_Server_readValue write just after iterate call.
@gfxx add some other test ....
bool bv = false; bool bv1 = false; UA_Variant vb1; UA_Variant *val2 = UA_Variant_new(); int check = 0; retval = UA_Server_readValue(this->m_server, this->m_StopCiclo, val2); vb1 = *(UA_Variant*)val2->data; if(retval == UA_STATUSCODE_GOOD) bv = true; if(val2->type == &UA_TYPES[UA_TYPES_BOOLEAN]) bv1 = true; if((retval == UA_STATUSCODE_GOOD) && (val2->type == &UA_TYPES[UA_TYPES_BOOLEAN])) { vb1 = *(UA_Variant*)val2->data;} qDebug() << "status code right? ..." << bv << " variant type is [UA_TYPES_BOOLEAN]) " << bv1 << " array size is " << val2->arrayDimensionsSize <<" data " << val2->data;I have always same result .... retval TRUE, TYPE true (so UA_TYPES_BOOLEAN), array leght "0" and val2-> data number change continuosly and randomly .... someone can send me in right directions??
regards
-
@gfxx add some other test ....
bool bv = false; bool bv1 = false; UA_Variant vb1; UA_Variant *val2 = UA_Variant_new(); int check = 0; retval = UA_Server_readValue(this->m_server, this->m_StopCiclo, val2); vb1 = *(UA_Variant*)val2->data; if(retval == UA_STATUSCODE_GOOD) bv = true; if(val2->type == &UA_TYPES[UA_TYPES_BOOLEAN]) bv1 = true; if((retval == UA_STATUSCODE_GOOD) && (val2->type == &UA_TYPES[UA_TYPES_BOOLEAN])) { vb1 = *(UA_Variant*)val2->data;} qDebug() << "status code right? ..." << bv << " variant type is [UA_TYPES_BOOLEAN]) " << bv1 << " array size is " << val2->arrayDimensionsSize <<" data " << val2->data;I have always same result .... retval TRUE, TYPE true (so UA_TYPES_BOOLEAN), array leght "0" and val2-> data number change continuosly and randomly .... someone can send me in right directions??
regards
@gfxx for bool var only solution seems easy ...
retval = UA_Server_readValue(this->m_server, this->m_StopCiclo, &val2); if((retval == UA_STATUSCODE_GOOD) && (val2.type == &UA_TYPES[UA_TYPES_BOOLEAN])) {Stop_bv = (((UA_Boolean*)val2.data)[0]); Stop = Stop_bv; }where Stop_bv and is bool var used for manipulate gui .... Stop is bool var used for write server node;
-
G gfxx has marked this topic as solved on