Online Forums
Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.
Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.
Do not use the Contact page for technical issues.
- Forum
- Discussions
- QuickOPC-UA in .NET
- Reading, Writing, Subscriptions
- Syntax of "SubscribeMultipleMonitoredItems" need overload with samplingInterval
Syntax of "SubscribeMultipleMonitoredItems" need overload with samplingInterval
UANodeId nodeId = new UANodeId("http://serverDomain.it/UAServer/", "IMO2134567/NavigationalData/Course/Course");
object state = null;
int[] handleArray = DataHandlers.EasyUAClientInstance.SubscribeMultipleMonitoredItems(new[]
{
new EasyUAMonitoredItemArguments(
callBackMethodHandler,
state,
DataHandlers.MainUAEndpointDescriptor,
nodeId,
100)
});
This works, because effectively it is using this overload of the constructor:
public EasyUAMonitoredItemArguments(
[CanBeNull] EasyUAMonitoredItemChangedEventHandler callback,
[CanBeNull] object state,
[NotNull] UAEndpointDescriptor endpointDescriptor,
[NotNull] UANodeDescriptor nodeDescriptor,
[NotNull] UAMonitoringParameters monitoringParameters)
Note that you can also construct all of these objects differently: There is nothing that tells you that all values must be passed in as constructor arguments. You can create e.g. an empty EasyUAMonitoredItemArguments object, and then manipulate its properties individually. The resulting code will be longer, but perhaps more readable, because the property names would be clearly visible.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
If I understand correctly, you are asking whether the event handler is only called when the underlying value changes. The answer to this is a "qualified Yes". We instruct the OPC server to send us notifications that are in accordance with the filter, and the default filter specifies that only when the value changes, the notification should be generated. We then process the notifications received from the OPC server, and ship them to you. Therefore you should not see notifications with the same value, but we ourselves do not explicitly "throw out" any duplicates: It is the server responsibility to correctly follow the instructions. Most servers I know about work well in this respect.Can you confirm that if the node inspected does not change is not generated the change event (I'm refering to "Heading_ItemChanged" in the following example)?
The answer to samplingInterval question will still be posted separately.
Please Log in or Create an account to join the conversation.
public UANodeDescriptor([NotNull] UANodeId nodeId, [NotNull] UABrowsePath browsePath)
new UANodeDescriptor("nsu=http://serverDomain.it/UAServer/;s=IMO2134567/NavigationalData/Course/Course")
I admit that it is sometimes difficult to figure out the conversions and overloads, but the reference documentation has them all.
Generally, the purpose of UANodeDescriptor is to describe which node your are interested in. It allows the nodes be specified using a node Id (UANodeId), using a browse path (UABrowsePath), or both. Therefore most our APIs accept a UANodeDescriptor on input, but it is possible to specify either UANodeId or UABrowsePath in place of it, and the implicit conversions will do the trick.
I will answer the other part of your question separately later.
Please Log in or Create an account to join the conversation.
first, I had some problem to get the correct use how method "SubscribeMultipleMonitoredItems" because the last parameter is documented like "UANodeDescriptor" type but don't work I casually found that the type correct is "UANodeId".
this don't work:
UANodeDescriptor nodeDescriptor = new UANodeDescriptor("http://serverDomain.it/UAServer/", "IMO2134567/NavigationalData/Course/Course");
object state = null;
int[] handleArray = DataHandlers.EasyUAClientInstance.SubscribeMultipleMonitoredItems(new[]
{
new EasyUAMonitoredItemArguments(callBackMethodHandler, state, DataHandlers.MainUAEndpointDescriptor, nodeDescriptor)
});
UANodeId nodeId = new UANodeId("http://serverDomain.it/UAServer/", "IMO2134567/NavigationalData/Course/Course");
object state = null;
int[] handleArray = DataHandlers.EasyUAClientInstance.SubscribeMultipleMonitoredItems(new[]
{
new EasyUAMonitoredItemArguments(callBackMethodHandler, state, DataHandlers.MainUAEndpointDescriptor, nodeId)
});
Other question. We need to use a "samplingInterval" but I don't found the correct overload of "SubscribeMultipleMonitoredItems" that allow me to indicate: callBackMethodHandler, EndpointDescriptor, nodeId and in adding 'samplingInterval' that seems is not allowed to be passed.
Can you confirm that if the node inspected does not change is not generated the change event (I'm refering to "Heading_ItemChanged" in the following example)?
private static bool StartSubscribe(string strNodeIdIdentifier, EasyUAMonitoredItemChangedEventHandler callBackMethodHandler)
{
bool ok = true;
try
{
//--------------------------------- Parte che funziona !!! --------------------
UANodeId nodeId = new UANodeId(DataHandlers.CommonNameSpaceURIString, strNodeIdIdentifier);
object state = null;
int[] handleArray = DataHandlers.EasyUAClientInstance.SubscribeMultipleMonitoredItems(new[]
{
new EasyUAMonitoredItemArguments(callBackMethodHandler, state, DataHandlers.MainUAEndpointDescriptor, nodeId)
});
}
catch (Exception ex)
{
ok = false;
m_logger.Error("StartSubscribe() NodeId='{0}', MethodHandler='{1}'\r\n'{2}'\r\n{3}\r\n",
strNodeIdIdentifier, callBackMethodHandler, ex.Message, ex.StackTrace.ToString());
}
}
private static void Heading_ItemChanged(object sender, EasyUAMonitoredItemChangedEventArgs e)
{
string itemValue = string.Empty;
string fullInfoItemValue = string.Empty;
DateTime lastUpdateUTC = DateTime.MinValue;
string mappingKey = "#Heading";
if (e.Exception != null)
{
m_dictKeySubscriptionState[mappingKey] = Enums.EnumSubscriptionState.Inactive;
m_logger.Error("[{0}_ItemChanged] Error: '{1}'", mappingKey, e.ErrorMessage);
}
else
{
m_dictKeySubscriptionState[mappingKey] = Enums.EnumSubscriptionState.Active;
UAAttributeData item = e.AttributeData;
fullInfoItemValue = e.AttributeData.ToString();
itemValue = e.AttributeData.Value.ToString();
lastUpdateUTC = e.AttributeData.SourceTimestamp;
// ??? -> van inserite nel model
m_dictKeyUpdateDate[mappingKey] = DateTime.UtcNow;
m_logger.Debug("[{0}_ItemChanged] Updated value to '{1}'.", mappingKey, itemValue);
}
}
thank you in advance
Please Log in or Create an account to join the conversation.
- Forum
- Discussions
- QuickOPC-UA in .NET
- Reading, Writing, Subscriptions
- Syntax of "SubscribeMultipleMonitoredItems" need overload with samplingInterval