Exemplo n.º 1
0
        internal async Task <object[]> CallMethodAsync(UaItem item, object[] inputArguments)
        {
            var session = Session;

            if (session != null && session.Connected)
            {
                try
                {
                    var callRequest = new CallRequest {
                        MethodsToCall = { new CallMethodRequest {
                                              ObjectId = item.StartNodeId, MethodId = item.ResolvedNodeId, InputArguments = inputArguments.Select(a => new Variant(a)).ToArray()
                                          } }
                    };
                    var callResponse = await session.CallAsync(callRequest).ConfigureAwait(false);

                    for (int i = 0; i < callResponse.Results.Count; i++)
                    {
                        if (StatusCode.IsNotGood(callResponse.Results[i].StatusCode))
                        {
                            Trace.TraceError("Error calling method with MethodId {0} : {1}", callRequest.MethodsToCall[i].MethodId, callResponse.Results[i].StatusCode);
                        }
                    }
                    return(callResponse.Results[0].OutputArguments.Select(a => a.Value).ToArray());
                }
                catch (Exception ex)
                {
                    Trace.TraceError("Error calling method with MethodId {0} : {1}", item.ResolvedNodeId, ex.Message);
                }
            }
            else
            {
                Trace.TraceError("Error calling method with MethodId {0} : {1}", item.ResolvedNodeId, "Session is null or not connected");
            }
            return(null);
        }
Exemplo n.º 2
0
        private static async void SetValueImpl(UaSubscription subscription, UaItem item, object value)
        {
            // as discovered by rdgerken, Kepware doesn't like getting a WriteValue with a SourceTimeStamp
            await subscription.SetValueAsync(item, new DataValue(new Variant(value))).ConfigureAwait(false);

            //await subscription.SetValueAsync(item, new DataValue(new Variant(value), StatusCodes.Good, DateTime.UtcNow)).ConfigureAwait(false);
        }
Exemplo n.º 3
0
        internal async Task SetValueAsync(UaItem item, DataValue value)
        {
            item.CacheValue = value;
            NotifyPropertyChanged(item.DisplayName);
            var session = Session;

            if (session != null && session.Connected)
            {
                try
                {
                    var writeRequest = new WriteRequest {
                        NodesToWrite = { new WriteValue {
                                             NodeId = item.ResolvedNodeId, AttributeId = (uint)item.AttributeId, Value = value
                                         } }
                    };
                    var writeResponse = await session.WriteAsync(writeRequest).ConfigureAwait(false);

                    for (int i = 0; i < writeResponse.Results.Count; i++)
                    {
                        if (StatusCode.IsNotGood(writeResponse.Results[i]))
                        {
                            Trace.TraceError("Error writing value for NodeId {0} : {1}", writeRequest.NodesToWrite[i].NodeId, writeResponse.Results[i]);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Trace.TraceError("Error writing value for NodeId {0} : {1}", item.ResolvedNodeId, ex.Message);
                }
            }
            else
            {
                Trace.TraceError("Error writing value for NodeId {0} : {1}", item.ResolvedNodeId, "Session is null or not connected");
            }
        }
Exemplo n.º 4
0
 public UaSetValueCommand(UaItem item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     _item = item;
 }
Exemplo n.º 5
0
 internal void RemoveItem(UaItem item)
 {
     base.RemoveItem(item);
     item.PropertyChanged -= OnItemPropertyChanged;
     _customType           = null;
     if (Created)
     {
         DeleteItems();
     }
 }
Exemplo n.º 6
0
 internal void AddItem(UaItem item)
 {
     base.AddItem(item);
     item.PropertyChanged += OnItemPropertyChanged;
     _customType           = null;
     if (Created)
     {
         CreateItems();
     }
 }
Exemplo n.º 7
0
 private static object GetValue(UaSubscription subscription, UaItem item)
 {
     return(item.CacheQueue);
 }
Exemplo n.º 8
0
 public UaItemDataSourceInfo(UaItem item)
 {
     _item = item;
 }
Exemplo n.º 9
0
 public UaItemCommandInfo(UaItem item)
 {
     _item    = item;
     _command = new UaSetValueCommand(item);
 }
Exemplo n.º 10
0
 public UaItemMethodInfo(UaItem item)
 {
     _item = item;
 }
Exemplo n.º 11
0
        private static object GetValueImpl(UaSubscription subscription, UaItem item)
        {
            var dataValue = subscription.GetValue(item);

            return(dataValue.StatusCode != StatusCodes.BadWaitingForInitialData ? dataValue.Value : DependencyProperty.UnsetValue);
        }
Exemplo n.º 12
0
 public UaItemPropertyInfo(UaItem item)
 {
     _item = item;
 }
Exemplo n.º 13
0
 internal DataValue GetValue(UaItem item)
 {
     return(item.CacheValue);
 }