Beispiel #1
0
        public SendParameter MonitorCard()
        {
            SendParameter data   = new SendParameter();
            Random        random = new Random();

            ushort[] bit = new ushort[8];
            data.AxisPosition = new double[5];
            data.AxisStatu    = new ushort[5];
            data.AxisPosition = new double[5];
            bool[] sing = new bool[3];
            data.AxisSensorX = new bool[3];
            data.AxisSensorY = new bool[3];
            data.AxisSensorZ = new bool[3];
            data.AxisSensorA = new bool[3];
            data.AxisSensorB = new bool[3];
            try
            {
                //输入
                Global.Ccard1.InputerMethod(ref bit);
                data.inputdata = bit;

                //当前位置
                data.AxisPosition[0] = Global.X.GetPosition();
                data.AxisPosition[1] = Global.Y.GetPosition();
                data.AxisPosition[2] = Global.Z.GetPosition();
                data.AxisPosition[3] = Global.A.GetPosition();
                data.AxisPosition[4] = Global.B.GetPosition();

                //轴状态
                data.AxisStatu[0] = Global.X.GetAxisStatus();
                data.AxisStatu[1] = Global.Y.GetAxisStatus();
                data.AxisStatu[2] = Global.Z.GetAxisStatus();
                data.AxisStatu[3] = Global.A.GetAxisStatus();
                data.AxisStatu[4] = Global.B.GetAxisStatus();

                //卡状态
                data.CardStatu = Global.Ccard1.GetErrorCode();

                //马达感应器

                Global.X.Getsing(ref sing);
                data.AxisSensorX = sing;
                Global.Y.Getsing(ref sing);
                data.AxisSensorY = sing;
                Global.Z.Getsing(ref sing);
                data.AxisSensorZ = sing;
                Global.A.Getsing(ref sing);
                data.AxisSensorA = sing;
                Global.B.Getsing(ref sing);
                data.AxisSensorB = sing;

                Thread.Sleep(100);
                return(data);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Beispiel #2
0
 public void RecieveData(SendParameter sendParameter)
 {
     BtnBreakColor(Xp_button, sendParameter.AxisSensorX[0]);
     BtnBreakColor(Xs_button, sendParameter.AxisSensorX[1]);
     BtnBreakColor(Yp_button, sendParameter.AxisSensorY[0]);
     BtnBreakColor(Ys_button, sendParameter.AxisSensorY[1]);
     BtnBreakColor(Zp_button, sendParameter.AxisSensorZ[0]);
     BtnBreakColor(Zs_button, sendParameter.AxisSensorZ[1]);
 }
Beispiel #3
0
        public void DoSomething()
        {
            SendParameter sen = new SendParameter();

            // Write some code that does something useful here
            // then raise the event. You can also raise an event
            // before you execute a block of code.
            sen = action();
            OnRaiseCustomEvent(new CustomEventArgs(sen));
        }
Beispiel #4
0
 public void RevMess(SendParameter sendPara)
 {
     if (rich_Mess.InvokeRequired)
     {
         rich_Mess.BeginInvoke(new Action(() =>
         {
             rich_Mess.Text += sendPara.Mess;
         }
                                          ));
     }
 }
Beispiel #5
0
        public void RecieveData(SendParameter sendPara)
        {
            var Bit = sendPara.inputdata;

            #region    //位值转显示
            //启动
            if (Bit[0] == 1)
            {
                lable0.ForeColor = Color.LawnGreen;
            }
            else
            {
                lable0.ForeColor = Color.Black;
            }
            //复位
            if (Bit[1] == 1)
            {
                lable1.ForeColor = Color.LawnGreen;
            }
            else
            {
                lable1.ForeColor = Color.Black;
            }

            //气压
            if (Bit[2] == 1)
            {
                lable2.ForeColor = Color.LawnGreen;
            }
            else
            {
                lable2.ForeColor = Color.Black;
            }

            //门
            if (Bit[3] == 1)
            {
                lable3.ForeColor = Color.LawnGreen;
            }
            else
            {
                lable3.ForeColor = Color.Black;
            }
            //  press down
            if (Bit[4] == 1)
            {
                lable4.ForeColor = Color.LawnGreen;
            }
            else
            {
                lable4.ForeColor = Color.Black;
            }
            //  press up
            if (Bit[5] == 1)
            {
                lable5.ForeColor = Color.LawnGreen;
            }
            else
            {
                lable5.ForeColor = Color.Black;
            }
            //Material-R
            if (Bit[6] == 1)
            {
                lable6.ForeColor = Color.LawnGreen;
            }
            else
            {
                lable6.ForeColor = Color.Black;
            }
            //Material-L
            if (Bit[7] == 1)
            {
                lable7.ForeColor = Color.LawnGreen;
            }
            else
            {
                lable7.ForeColor = Color.Black;
            }
            #endregion

            //if (textBox1.InvokeRequired)
            //{
            //    textBox1.BeginInvoke(new Action(() =>
            //    {
            //        textBox1.Text = sendPara.db.ToString();
            //    }
            //        ));
            //}
        }
Beispiel #6
0
        public void RevCurrentPos(SendParameter sendPara)
        {
            #region SetPos


            if (Xcur_textBox.InvokeRequired)
            {
                Xcur_textBox.BeginInvoke(new Action(() =>
                {
                    Xcur_textBox.Text = sendPara.AxisPosition[0].ToString("#0.000");
                    SetAxisStutic(Xcur_textBox, sendPara.AxisStatu[0]);
                }
                                                    ));
            }
            if (Ycur_textBox.InvokeRequired)
            {
                Ycur_textBox.BeginInvoke(new Action(() =>
                {
                    Ycur_textBox.Text = sendPara.AxisPosition[1].ToString("#0.000");
                    SetAxisStutic(Ycur_textBox, sendPara.AxisStatu[1]);
                }
                                                    ));
            }
            if (Zcur_textBox.InvokeRequired)
            {
                Zcur_textBox.BeginInvoke(new Action(() =>
                {
                    Zcur_textBox.Text = sendPara.AxisPosition[2].ToString("#0.000");
                    SetAxisStutic(Zcur_textBox, sendPara.AxisStatu[2]);
                }
                                                    ));
            }
            if (Acur_textBox.InvokeRequired)
            {
                Acur_textBox.BeginInvoke(new Action(() =>
                {
                    Acur_textBox.Text = sendPara.AxisPosition[3].ToString("#0.000");
                    SetAxisStutic(Acur_textBox, sendPara.AxisStatu[3]);
                }
                                                    ));
            }
            if (Bcur_textBox.InvokeRequired)
            {
                Bcur_textBox.BeginInvoke(new Action(() =>
                {
                    Bcur_textBox.Text = sendPara.AxisPosition[4].ToString("#0.000");
                    SetAxisStutic(Bcur_textBox, sendPara.AxisStatu[4]);
                }
                                                    ));
            }

            #endregion


            #region EtherCAT status


            if (textBox4.InvokeRequired)
            {
                textBox4.BeginInvoke(new Action(() =>
                {
                    if (sendPara.CardStatu == 0)
                    {
                        textBox4.Text      = "EtherCAT总线正常";
                        textBox4.BackColor = Color.Green;
                    }
                    else
                    {
                        textBox4.Text      = "EtherCAT总线出错";
                        textBox4.BackColor = Color.Red;
                    }
                }
                                                ));
            }
            #endregion
        }
Beispiel #7
0
 public CustomEventArgs(SendParameter sendParameter)
 {
     SendParat = sendParameter;
 }