Пример #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);
        }
Пример #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);
        }
Пример #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");
            }
        }
Пример #4
0
 public UaSetValueCommand(UaItem item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     _item = item;
 }
Пример #5
0
 internal void RemoveItem(UaItem item)
 {
     base.RemoveItem(item);
     item.PropertyChanged -= OnItemPropertyChanged;
     _customType           = null;
     if (Created)
     {
         DeleteItems();
     }
 }
Пример #6
0
 internal void AddItem(UaItem item)
 {
     base.AddItem(item);
     item.PropertyChanged += OnItemPropertyChanged;
     _customType           = null;
     if (Created)
     {
         CreateItems();
     }
 }
Пример #7
0
 private static object GetValue(UaSubscription subscription, UaItem item)
 {
     return(item.CacheQueue);
 }
Пример #8
0
 public UaItemDataSourceInfo(UaItem item)
 {
     _item = item;
 }
Пример #9
0
 public UaItemCommandInfo(UaItem item)
 {
     _item    = item;
     _command = new UaSetValueCommand(item);
 }
Пример #10
0
 public UaItemMethodInfo(UaItem item)
 {
     _item = item;
 }
Пример #11
0
        private static object GetValueImpl(UaSubscription subscription, UaItem item)
        {
            var dataValue = subscription.GetValue(item);

            return(dataValue.StatusCode != StatusCodes.BadWaitingForInitialData ? dataValue.Value : DependencyProperty.UnsetValue);
        }
Пример #12
0
 public UaItemPropertyInfo(UaItem item)
 {
     _item = item;
 }
Пример #13
0
 internal DataValue GetValue(UaItem item)
 {
     return(item.CacheValue);
 }