/// <summary> /// 根据点表变化更新界面的内容TTODO /// 包括车辆列表内容,报警内容,动画内容 /// </summary> /// <param name="o"></param> private void upUiData(SocketJsonParamEntity socketJsonParamEntity) { //socketJsonParamEntity.SubScriptionList //AlarmInfoList.Add(new AlarmInfoModel() { AgvInfo_Id }) //if (CommOpcUaBusinessInfoList[i].NodeId.Equals(socketJsonParamEntity.KeyId)) //{ // CommOpcUaBusinessInfoList[i].Value = socketJsonParamEntity.Value.ToString(); //} }
private void ReadBtn_Click(object sender, RoutedEventArgs e) { SocketJsonParamEntity socketJsonParamEntity = new SocketJsonParamEntity(); socketJsonParamEntity.KeyId = Guid.Parse("2B68E863-6F5D-E811-8BA9-F8A005475E49"); socketJsonParamEntity.NodeId = "ns=2;s=TestChannel.TestDevice.word_1"; socketJsonParamEntity.ValueType = typeof(short); socketJsonParamEntity.FunctionCode = Core.FuncCode.Read; client.Send(GetMessage(JsonConvert.SerializeObject(socketJsonParamEntity))); }
private void SubScriptionBtn_Click(object sender, RoutedEventArgs e) { SocketJsonParamEntity socketJsonParamEntity = new SocketJsonParamEntity(); //socketJsonParamEntity.KeyId = Guid.Parse("2B68E863-6F5D-E811-8BA9-F8A005475E49"); //socketJsonParamEntity.NodeId = "ns=2;s=TestChannel.TestDevice.word_1"; socketJsonParamEntity.FunctionCode = Core.FuncCode.SubScription; List <Guid> subIdList = new List <Guid>(); subIdList.Add(Guid.Parse("49ad2434-7964-e811-8bad-973b85bbda56")); socketJsonParamEntity.SubScriptionList = subIdList; client.Send(GetMessage(JsonConvert.SerializeObject(socketJsonParamEntity))); }
private void SubScription() { SocketJsonParamEntity socketJsonParamEntity = new SocketJsonParamEntity(); //socketJsonParamEntity.KeyId = Guid.Parse("2B68E863-6F5D-E811-8BA9-F8A005475E49"); //socketJsonParamEntity.NodeId = "ns=2;s=TestChannel.TestDevice.word_1"; socketJsonParamEntity.FunctionCode = FuncCode.SubScription; List <Guid> subIdList = new List <Guid>(); for (int i = 0; i < CommOpcUaBusinessInfoList.Count; i++) { subIdList.Add(CommOpcUaBusinessInfoList[i].Id); } socketJsonParamEntity.SubScriptionList = subIdList; client.Send(GetMessage(Utility.JsonHelper.ToJson(socketJsonParamEntity))); }
private void OnReceive(object sender, DataEventArgs args) { Task.Run(() => { String jsonStr = args.PackageInfo.Data; SocketJsonParamEntity socketJsonParamEntity = Utility.JsonHelper.FromJson <SocketJsonParamEntity>(jsonStr); switch (socketJsonParamEntity.FunctionCode) { case FuncCode.Read: break; case FuncCode.Write: break; case FuncCode.SubScription: { if (socketJsonParamEntity.StatusCode == (uint)DeviceStatusCode.SubscriptionOK) { Application.Current.Resources["UiMessage"] = "订阅成功!"; } else { for (int i = 0; i < CommOpcUaBusinessInfoList.Count; i++) { if (CommOpcUaBusinessInfoList[i].NodeId.Equals(socketJsonParamEntity.KeyId)) { CommOpcUaBusinessInfoList[i].Value = socketJsonParamEntity.Value.ToString(); } } } } break; default: break; } }); }
private void OnReceive(object sender, DataEventArgs args) { String jsonStr = args.PackageInfo.Data; SocketJsonParamEntity socketJsonParamEntity = JsonConvert.DeserializeObject <SocketJsonParamEntity>(jsonStr); switch (socketJsonParamEntity.FunctionCode) { case FuncCode.Read: { if (socketJsonParamEntity.StatusCode == (uint)DeviceStatusCode.ReadOk) { ResultTextBlock.Dispatcher.Invoke( new Action( delegate { ResultTextBlock.Text += Environment.NewLine; ResultTextBlock.Text += $"读取成功!值为:{socketJsonParamEntity.Value}!"; ResultTextBlock.Text += Environment.NewLine; } )); } else { ResultTextBlock.Dispatcher.Invoke( new Action( delegate { ResultTextBlock.Text += $"读取失败!"; ResultTextBlock.Text += Environment.NewLine; } )); } } break; case FuncCode.Write: { if (socketJsonParamEntity.StatusCode == (uint)DeviceStatusCode.WriteOk) { ResultTextBlock.Dispatcher.Invoke( new Action( delegate { ResultTextBlock.Text += $"写入成功!值为:{socketJsonParamEntity.Value}!"; ResultTextBlock.Text += Environment.NewLine; } )); } else { ResultTextBlock.Dispatcher.Invoke( new Action( delegate { ResultTextBlock.Text += $"写入失败!"; ResultTextBlock.Text += Environment.NewLine; } )); } } break; case FuncCode.SubScription: { if (socketJsonParamEntity.StatusCode == (uint)DeviceStatusCode.SubscriptionOK) { ResultTextBlock.Dispatcher.Invoke( new Action( delegate { ResultTextBlock.Text += $"{DateTime.Now} 订阅成功!"; ResultTextBlock.Text += Environment.NewLine; } )); } else { subscriptionValue.Dispatcher.Invoke( new Action( delegate { subscriptionValue.Content = $"{DateTime.Now} 订阅值:{socketJsonParamEntity.Value}!"; } )); // ResultTextBlock.Dispatcher.Invoke( // new Action( // delegate // { // ResultTextBlock.Text += $"{DateTime.Now} 订阅值:{socketJsonParamEntity.Value}!"; // ResultTextBlock.Text += Environment.NewLine; // } //)); } } break; default: break; } }