Beispiel #1
0
 internal NotificationEx(AdsNotificationExEventArgs args)
 {
     base.timeStamp          = DateTime.FromFileTimeUtc(args.TimeStamp);
     base.userData           = args.UserData;
     base.notificationHandle = (uint)args.NotificationHandle;
     base.val = args.Value;
 }
Beispiel #2
0
        /// <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;
            }
        }
Beispiel #3
0
        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();
        }
Beispiel #4
0
 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;
            }
        }
Beispiel #6
0
        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);
            }
        }
Beispiel #7
0
        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;
         }
     }));
 }
Beispiel #9
0
 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;
             }
         }
     }
 }
Beispiel #10
0
        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();
                }
            }
                            ));
        }
Beispiel #11
0
 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);
     }
 }
Beispiel #12
0
        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});
            }
        }
Beispiel #13
0
        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);
        }
Beispiel #14
0
        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});
            }
        }
Beispiel #15
0
 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();
 }
Beispiel #18
0
 private void adsClient_AdsNotificationEx(object sender, AdsNotificationExEventArgs e)
 {
     mBeckHoff.callback_Notification(e);
 }
Beispiel #19
0
        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);
        }
Beispiel #20
0
        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"))
            {

            }
        }
Beispiel #21
0
        private void Client_AdsNotificationEx(object sender, AdsNotificationExEventArgs e)
        {
            Var v = (Var)e.UserData;

            v.SetInternalValue(e.Value);
        }
Beispiel #22
0
 private void Client_AdsNotificationEx(object sender, AdsNotificationExEventArgs e)
 {
     //throw new NotImplementedException();
     lbMode.Text = e.Value.ToString();
 }
Beispiel #23
0
 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);
     }
 }
Beispiel #24
0
        //Notice读取值
        private void adsClient_AdsNotificationEx(object sender, AdsNotificationExEventArgs e)
        {
            TwinCATCoil temp = (TwinCATCoil)e.UserData;

            temp.CoilValue = e.Value;
        }
Beispiel #25
0
 private void adsClient_AdsNotificationEx(object sender, AdsNotificationExEventArgs e)
 {
     mBeckHoff.callback_Notification(e);
 }
Beispiel #26
0
        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);
                }
            }));
        }