internal NotificationEx(AdsNotificationExEventArgs args) { base.timeStamp = DateTime.FromFileTimeUtc(args.TimeStamp); base.userData = args.UserData; base.notificationHandle = (uint)args.NotificationHandle; base.val = args.Value; }
/// <summary> /// 读取PLC信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void adsClient_AdsNotificationEx(object sender, AdsNotificationExEventArgs e) { int i = Array.IndexOf(pvc.HandId, e.NotificationHandle); if (i >= 0 && i < pvc.value.Length) { pvc.value[i] = e.Value; } }
private void Client_AdsNotificationEx(object sender, AdsNotificationExEventArgs e) { if (e.Value.GetType() == typeof(Boolean)) { bPowerOn = (Boolean)e.Value; } else if (e.Value.GetType() == typeof(double)) { ((TextBox)e.UserData).Text = e.Value.ToString(); } AxisPowerIndicatior(); }
private void onNotification(object sender, AdsNotificationExEventArgs e) { foreach (Module mod in moduleList) { foreach (IO io in mod.ioList) { if (e.NotificationHandle == io.notifHandle) { io.value = (bool)e.Value; } } } }
private void Client_AdsNotificationEx(object sender, AdsNotificationExEventArgs e) { //throw new NotImplementedException(); Button btn = (Button)e.UserData; if ((bool)e.Value) { btn.BackColor = Color.Green; } else { btn.BackColor = Color.Red; } }
private void adsClient_AdsNotificationEx(object sender, AdsNotificationExEventArgs e) { TextBox textBox = (TextBox)e.UserData; Type type = e.Value.GetType(); if (type == typeof(string) || type.IsPrimitive) { textBox.Text = e.Value.ToString(); } else if (type == typeof(ComplexStruct)) { FillStructControls((ComplexStruct)e.Value); } }
private void handleNotification(object sender, AdsNotificationExEventArgs e) { String s = (String)e.UserData; int handle = handleMap[s]; if (s.Equals("MAIN.MDF_RunningError")) { YunXingChuCuoBiaoZhi = (int)adsClient.ReadAny(handle, nameDict[s]); } if (s.Equals("MAIN.MDF_online_state")) { } if (s.Equals("MAIN.MDF_Command_response")) { String msg = (String)adsClient.ReadAny(handle, nameDict[s], new int[] { ConstSettings.StringLength }); ModbusMessage message = ModbusMessageHelper.decodeModbusMessage(msg); switch (message.MsgType) { case ModbusMessage.MessageType.RESPONSE: decodeResponseMessage(message); break; case ModbusMessage.MessageType.REPORT: decodeReportMessage(message); break; case ModbusMessage.MessageType.SET: decodeSetMessage(message); break; } } if (s.Equals("MAIN.MDF_Motor_1_cur")) { MDF_Current1 = (float)adsClient.ReadAny(handle, nameDict[s]); } if (s.Equals("MAIN.MDF_Motor_2_cur")) { MDF_Current2 = (float)adsClient.ReadAny(handle, nameDict[s]); } if (s.Equals("MAIN.MDF_Motor_3_cur")) { MDF_Current3 = (float)adsClient.ReadAny(handle, nameDict[s]); } if (s.Equals("MAIN.MDF_Motor_4_cur")) { } }
public void TwinCat3Client_AdsNotificationEx(object sender, AdsNotificationExEventArgs e) { Application.Current.Dispatcher.Invoke (new Action(() => { if (e.UserData == ReferenceHandler.GetReferenceObject("controll")) { if ((Boolean)e.Value) { } } if (e.UserData == ReferenceHandler.GetReferenceObject("mode")) { Screens[0].IsEnabled = !(bool)e.Value; Screens[1].IsEnabled = !(bool)e.Value; Screens[2].IsEnabled = (bool)e.Value; Screens[3].IsEnabled = !(bool)e.Value; } })); }
void onNotification(object sender, AdsNotificationExEventArgs e) { if (e.NotificationHandle == axes[idxAxis].hdlReadyNotif) { CheckBox cbReady = e.UserData as CheckBox; if (cbReady != null) { cbReady.Checked = (bool)e.Value; } } else if (e.NotificationHandle == axes[idxAxis].hdlActPosNotif) { TextBox tbActPos = e.UserData as TextBox; if (tbActPos != null) { double pos = (double)e.Value; tbActPos.Text = pos.ToString("#0.0000"); } } else if (e.NotificationHandle == axes[idxAxis].hdlActVeloNotif) { double velo = (double)e.Value; tbActVelo.Text = velo.ToString("#0.0000"); } else if (e.NotificationHandle == axes[idxAxis].hdlErrIdNotif) { TextBox tbErrId = e.UserData as TextBox; if (tbErrId != null) { tbErrId.Text = e.Value.ToString(); if (tbErrId.Text == "0") { tbErrId.ForeColor = Color.Black; } else { tbErrId.ForeColor = Color.Red; } } } }
private void TwinCat3Client_AdsNotificationEx(object sender, AdsNotificationExEventArgs e) { Application.Current.Dispatcher.Invoke (new Action(() => { Type ObjectType = e.UserData.GetType(); this.lblist.Items.Add(e.Value.ToString()); if (this.lblist.Items.Count == 20) { this.lblist.Items.Remove(this.lblist.Items[0]); } if (ObjectType == typeof(Rectangle)) { t_Rectangle = (Rectangle)e.UserData; if ((bool)e.Value) { t_Rectangle.Fill = new SolidColorBrush(Colors.Green); } else { t_Rectangle.Fill = new SolidColorBrush(Colors.Red); } } if (ObjectType == typeof(Label)) { t_Label = (Label)e.UserData; t_Label.Content = e.Value.ToString(); } if (ObjectType == typeof(TextBox)) { t_TextBox = (TextBox)e.UserData; t_TextBox.Text = e.Value.ToString(); } } )); }
private void ads_Notification(object sender, AdsNotificationExEventArgs e) { //throw new NotImplementedException(); try { TextBox textBox = new TextBox(); textBox = (TextBox)e.UserData; Type type = e.Value.GetType(); if (type.IsPrimitive || type == typeof(String)) { textBox.Text = e.Value.ToString(); } else if (e.Value.GetType() == typeof(ComplexStruct)) { FillComplex((ComplexStruct)e.Value); } } catch (Exception err) { MessageBox.Show("ads notification " + err.Message); } }
private void handleNotification(object sender, AdsNotificationExEventArgs e) { String s = (String)e.UserData; int handle = handleMap[s]; if (s.Equals("MAIN.CCS_to_MDF_NumsperStack_listen")) { Num = (int)adsClient.ReadAny(handle, nameDict[s]); } if (s.Equals("MAIN.CCS_to_MDF_VolsperDish_listen")) { Vol = (float)adsClient.ReadAny(handle, nameDict[s]); } if (s.Equals("MAIN.CCS_to_MDF_command_listen")) { String cmd = adsClient.ReadAny(handle, nameDict[s], new int[] { ConstSettings.StringLength }).ToString(); if ("Start".Equals(cmd)) { fenZhuangTimer.Start(); } if ("Reset".Equals(cmd)) { KongBanHao = 1; PeiYangMinHao = 1; DuiMaHao = 1; } if ("Stop".Equals(cmd)) { fenZhuangTimer.Stop(); } if ("Auto".Equals(cmd)) { } //String msg = AutoDispenDeviceMessageCreator.createOKResponse(); //adsClient.WriteAny(handleMap["MAIN.MDF_Command_response"],msg,new int[]{ConstSettings.StringLength}); } }
public void callback_Notification(AdsNotificationExEventArgs e) { String plcVarName; plcHNotifyVarMap.TryGetValue(e.NotificationHandle, out plcVarName); Type t; plcVarTypeMap.TryGetValue(plcVarName, out t); Object value = e.Value; Console.WriteLine(plcVarName + " " + e.Value.ToString()); if (t.Equals(typeof(int))) { ThresHold limit; plcVarThreadHoldMap.TryGetValue(plcVarName, out limit); if (limit != null) { float fValue = Convert.ToSingle(value); value = fValue / limit.ratio; } if (plcVarName.Equals(".Store_cig_speed") || plcVarName.Equals(".Slope_cig_speed")) { //convert unsigned integer into integer int lValue = (int)value; value = lValue - ((lValue <= 32767) ? 0 : 65536); } } if (plcVarUserdataMap.ContainsKey(plcVarName)) { plcVarUserdataMap.Remove(plcVarName); } plcVarUserdataMap.Add(plcVarName, value); DispatchChanges(plcVarName); }
private void handleNotification(object sender, AdsNotificationExEventArgs e) { String s = (String)e.UserData; int handle = handleMap[s]; if (s.Equals("MAIN.CCS_to_MDF_NumsperStack_listen")) { Num = (int) adsClient.ReadAny(handle, nameDict[s]); } if (s.Equals("MAIN.CCS_to_MDF_VolsperDish_listen")) { Vol = (float)adsClient.ReadAny(handle,nameDict[s]); } if (s.Equals("MAIN.CCS_to_MDF_command_listen")) { String cmd = adsClient.ReadAny(handle, nameDict[s],new int[]{ConstSettings.StringLength}).ToString(); if ("Start".Equals(cmd)) { fenZhuangTimer.Start(); } if ("Reset".Equals(cmd)) { KongBanHao = 1; PeiYangMinHao = 1; DuiMaHao = 1; } if ("Stop".Equals(cmd)) { fenZhuangTimer.Stop(); } if ("Auto".Equals(cmd)) { } //String msg = AutoDispenDeviceMessageCreator.createOKResponse(); //adsClient.WriteAny(handleMap["MAIN.MDF_Command_response"],msg,new int[]{ConstSettings.StringLength}); } }
private void AdsNotificationEx(object sender, AdsNotificationExEventArgs e) { // }
private void TcClient_AdsNotificationEx(object sender, AdsNotificationExEventArgs e) { Send_TcClient_EventHandling(DateTime.Now, LogTextCategory.Info, string.Format("Received Extended Ads Notification: {0}", e.ToString())); }
void adsClient_AdsNotificationEx(object sender, AdsNotificationExEventArgs e) { tbWatch.Text = e.Value.ToString(); }
private void adsClient_AdsNotificationEx(object sender, AdsNotificationExEventArgs e) { mBeckHoff.callback_Notification(e); }
public void callback_Notification(AdsNotificationExEventArgs e) { String plcVarName; plcHNotifyVarMap.TryGetValue(e.NotificationHandle, out plcVarName); Type t; plcVarTypeMap.TryGetValue(plcVarName, out t); Object value = e.Value; Console.WriteLine(plcVarName + " " + e.Value.ToString()); if (t.Equals(typeof(int))) { ThresHold limit; plcVarThreadHoldMap.TryGetValue(plcVarName, out limit); if (limit != null) { float fValue = Convert.ToSingle(value); value = fValue / limit.ratio; } if (plcVarName.Equals(".Store_cig_speed") || plcVarName.Equals(".Slope_cig_speed")) { //convert unsigned integer into integer int lValue = (int)value; value = lValue - ((lValue <= 32767) ? 0 : 65536); } } if (plcVarUserdataMap.ContainsKey(plcVarName)) { plcVarUserdataMap.Remove(plcVarName); } plcVarUserdataMap.Add(plcVarName,value); DispatchChanges(plcVarName); }
private void handleNotification(object sender, AdsNotificationExEventArgs e) { String s = (String)e.UserData; int handle = handleMap[s]; if (s.Equals("MAIN.MDF_RunningError")) { YunXingChuCuoBiaoZhi = (int)adsClient.ReadAny(handle, nameDict[s]); } if (s.Equals("MAIN.MDF_online_state")) { } if (s.Equals("MAIN.MDF_Command_response")) { String msg = (String)adsClient.ReadAny(handle, nameDict[s], new int[] { ConstSettings.StringLength }); ModbusMessage message = ModbusMessageHelper.decodeModbusMessage(msg); switch (message.MsgType) { case ModbusMessage.MessageType.RESPONSE: decodeResponseMessage(message); break; case ModbusMessage.MessageType.REPORT: decodeReportMessage(message); break; case ModbusMessage.MessageType.SET: decodeSetMessage(message); break; } } if (s.Equals("MAIN.MDF_Motor_1_cur")) { MDF_Current1 = (float)adsClient.ReadAny(handle, nameDict[s]); } if (s.Equals("MAIN.MDF_Motor_2_cur")) { MDF_Current2 = (float)adsClient.ReadAny(handle, nameDict[s]); } if (s.Equals("MAIN.MDF_Motor_3_cur")) { MDF_Current3 = (float)adsClient.ReadAny(handle, nameDict[s]); } if (s.Equals("MAIN.MDF_Motor_4_cur")) { } }
private void Client_AdsNotificationEx(object sender, AdsNotificationExEventArgs e) { Var v = (Var)e.UserData; v.SetInternalValue(e.Value); }
private void Client_AdsNotificationEx(object sender, AdsNotificationExEventArgs e) { //throw new NotImplementedException(); lbMode.Text = e.Value.ToString(); }
private void ADSClient_AdsNotificationEx(object sender, AdsNotificationExEventArgs e) { if (!bInitOK) { return; } try { for (int i = 0; i < axisNumber; i++) { if (e.NotificationHandle == posInt[i])//轴当前位置 { pos[i] = (double)e.Value; return; } else if (e.NotificationHandle == isMovingInt[i])//轴运动状态 { isMoving[i] = (bool)e.Value; return; } else if (e.NotificationHandle == alarmInt[i])//轴报警状态 { isAlarm[i] = (bool)e.Value; return; } else if (e.NotificationHandle == cwInt[i])//轴正限位 { cw[i] = (bool)e.Value; return; } else if (e.NotificationHandle == ccwInt[i])//轴负限位 { ccw[i] = (bool)e.Value; return; } else if (e.NotificationHandle == homeInt[i])//轴原位 { home[i] = (bool)e.Value; return; } else if (e.NotificationHandle == homeDoneInt[i])//轴回原完成标志 { homeDone[i] = (bool)e.Value; return; } else if (e.NotificationHandle == bInterpolationFinishedInt)//轴回原完成标志 { bInterpolationFinished = (bool)e.Value; return; } else if (e.NotificationHandle == isMoveDoneInt[i]) { isMoveDone[i] = (bool)e.Value; return; } } for (int i = 1; i <= 6; i++) { for (int j = 1; j <= 16; j++) { if (e.NotificationHandle == inputIntNot[i, j]) { input[i, j] = (bool)e.Value; return; } if (e.NotificationHandle == outputIntNot[i, j]) { output[i, j] = (bool)e.Value; return; } } } } catch (Exception ex) { Close(); // Global.logger.ErrorFormat("ADS通讯错误:{0}。", ex.Message); } }
//Notice读取值 private void adsClient_AdsNotificationEx(object sender, AdsNotificationExEventArgs e) { TwinCATCoil temp = (TwinCATCoil)e.UserData; temp.CoilValue = e.Value; }
private void adsClient_AdsNotificationEx(object sender, AdsNotificationExEventArgs e) { mBeckHoff.callback_Notification(e); }
public void TwinCat3Client_AdsNotificationEx(object sender, AdsNotificationExEventArgs e) { Application.Current.Dispatcher.Invoke (new Action(() => { if (e.UserData == ReferenceHandler.GetReferenceObject("controll")) { if ((bool)e.Value) { btnControl.Background = (SolidColorBrush)FindResource("BaseGreenBrush"); } else { btnControl.Background = (SolidColorBrush)FindResource("BaseRedBrush"); } } if (e.UserData == ReferenceHandler.GetReferenceObject("mode")) { if ((bool)e.Value) { btnMode.Background = (SolidColorBrush)FindResource("BaseGreenBrush"); btnModeContent.Text = "A"; } else { btnMode.Background = (SolidColorBrush)FindResource("BaseYellowBrush"); btnModeContent.Text = "M"; } } if (e.UserData == ReferenceHandler.GetReferenceObject("deprag_status")) { mainPage.tbStatus.Text = e.Value.ToString(); } if (e.UserData == ReferenceHandler.GetReferenceObject("deprag_step")) { mainPage.tbStepNr.Text = e.Value.ToString(); } if (e.UserData == ReferenceHandler.GetReferenceObject("result_torque")) { mainPage.tbTorque.Text = Math.Round((Single)e.Value, 3).ToString(); } if (e.UserData == ReferenceHandler.GetReferenceObject("result_angle")) { mainPage.tbAngle.Text = e.Value.ToString(); } if (e.UserData == ReferenceHandler.GetReferenceObject("deprag_program")) { mainPage.tbProgramNumber.Text = e.Value.ToString(); } if (e.UserData == ReferenceHandler.GetReferenceObject("deprag_CycleTime")) { mainPage.tbProcessTime.Text = Math.Round((Single)e.Value, 3).ToString(); } if (e.UserData == ReferenceHandler.GetReferenceObject("Override")) { SpeedBar.Value = (Double)e.Value; SpeedBox.Text = Math.Round((decimal)(Double)e.Value, 0).ToString() + " %"; } if (e.UserData == ReferenceHandler.GetReferenceObject("message_number")) { if (int.Parse(e.Value.ToString()) != 0) { AdsCommunication.WriteAny(ReferenceHandler.GetReferenceAdress("confirm"), false); AdsCommunication.WriteAny(ReferenceHandler.GetReferenceAdress("ClearNotifi"), false); DisplayError(int.Parse(e.Value.ToString())); } } if (e.UserData == ReferenceHandler.GetReferenceObject("ClearNotifi") && AdsCommunication.ReadInt(ReferenceHandler.GetReferenceAdress("message_number")) == 0 && NotifiSlot.Children.Count != 0) { CloseNotification(); AdsCommunication.WriteAny(ReferenceHandler.GetReferenceAdress("confirm"), false); } })); }