Hi Supported Team,
I've a problem with the function Subscription and Monitoritem in the lesson06 of client_gettingstarted.
I'd like calls two clients and one server.
The first client calls the subscription function for monitoring a variable. At the same time, I'd like that the second client call the function "write" for the variable that the first client is monitoring. Can I monitoring the variables AirConditioner_1.HumiditySetPoint
and AirConditioner_1.TemperatureSetPoint?
Thank you,
getting started lessons: Subscription and Monitoritem
Moderator: uasdkcpp
-
- Sr. Member
- Posts: 11
- Joined: 27 Nov 2012, 08:16
- Support Team
- Hero Member
- Posts: 3072
- Joined: 18 Mar 2011, 15:09
Re:getting started lessons: Subscription and Monitoritem
Hello Diana,
I guess what you want is
- monitor one node with client A
- write values to the very same node with client B
- see the written values change in client A
You have to use the same NodeId for monitoring and writing. You can use either of the 2 NodeIds you posted above.
Best Regards,
Unified Automation Support Team
I guess what you want is
- monitor one node with client A
- write values to the very same node with client B
- see the written values change in client A
You have to use the same NodeId for monitoring and writing. You can use either of the 2 NodeIds you posted above.
Best Regards,
Unified Automation Support Team
Best regards
Unified Automation Support Team
Unified Automation Support Team
-
- Sr. Member
- Posts: 11
- Joined: 27 Nov 2012, 08:16
Re:getting started lessons: Subscription and Monitoritem
ok, perfect! I'd like print the value of either variable when the subscription is called; in the code there is:
In the last "printf", the funcion print the "monitoredItemCreateResults[count].MonitoredItemId".
My question is: How I can print the other attributes of the monitoring variable?
thank you!
Diana
Code: Select all
else
{
printf("** UaSession::createMonitoredItems result **********************n");
for ( i=0; i<count; i++ )
{
UaNodeId node(monitoredItemCreateRequests[i].ItemToMonitor.NodeId);
if (
OpcUa_IsGood(monitoredItemCreateResults[i].StatusCode) )
{
printf("** Variable %s MonitoredItemId = %dn", node.toString().toUtf8(), monitoredItemCreateResults[i].MonitoredItemId);
}
else
{
printf("** Variable %s failed!n", node.toString().toUtf8());
}
}
if ( OpcUa_IsGood(monitoredItemCreateResults[count].StatusCode) )
{
printf("** Event MonitoredItemId = %dn", monitoredItemCreateResults[count].MonitoredItemId);
}
else
{
printf("** Event MonitoredItem for Server Object failed!n");
}
In the last "printf", the funcion print the "monitoredItemCreateResults[count].MonitoredItemId".
My question is: How I can print the other attributes of the monitoring variable?
thank you!
Diana
- Support Team
- Hero Member
- Posts: 3072
- Joined: 18 Mar 2011, 15:09
Re:getting started lessons: Subscription and Monitoritem
Hello Diana,
in the same way you can print the other parameters.
Looking at the ExtensionObject is a bit tricky. We're currently working on an easier way to work with ExtensionObjects.
Best Regards,
Unified Automation Support Team
in the same way you can print the other parameters.
Looking at the ExtensionObject is a bit tricky. We're currently working on an easier way to work with ExtensionObjects.
Code: Select all
if ( OpcUa_IsGood(monitoredItemCreateResults[count].StatusCode) )
{
printf("** Event MonitoredItemId = %dn", monitoredItemCreateResults[count].MonitoredItemId);
printf("** Event RevisedQueueSize = %dn", monitoredItemCreateResults[count].RevisedQueueSize);
printf("** Event RevisedSamplingInterval = %dn", monitoredItemCreateResults[count].RevisedSamplingInterval);
printf("** Event StatusCode = %sn", UaStatusCode(monitoredItemCreateResults[count].StatusCode).toString().toUtf8());
// check if we have an EventFilterResult
if( monitoredItemCreateResults[count].FilterResult.Encoding == OpcUa_ExtensionObjectEncoding_EncodeableObject &&
monitoredItemCreateResults[count].FilterResult.Body.EncodeableObject.Type->TypeId == OpcUaId_EventFilterResult &&
monitoredItemCreateResults[count].FilterResult.Body.EncodeableObject.Object != OpcUa_Null)
{
OpcUa_EventFilterResult *pEventFilterResult = (OpcUa_EventFilterResult*)monitoredItemCreateResults[count].FilterResult.Body.EncodeableObject.Object;
OpcUa_Int32 j;
for(j = 0; j < pEventFilterResult->NoOfSelectClauseResults; j++)
{
printf("** SelectClause[%d] Status = %sn", j, UaStatusCode(pEventFilterResult->SelectClauseResults[j]).toString().toUtf8());
}
}
}
Unified Automation Support Team
Best regards
Unified Automation Support Team
Unified Automation Support Team