Exemplo n.º 1
0
 public void Initial()
 {
     Fixture = new FixturePLC(fixtureStartAddress, Cp_descr, Cref, Orderid);
     Com     = new ComPLC(comStartAddress, Cp_descr, Cref, Orderid);
     Rail1   = new RailPLC(RailStartAddress[0], Cp_descr, Cref, Orderid);
     Rail2   = new RailPLC(RailStartAddress[1], Cp_descr, Cref, Orderid);
     InitialReadPara();
 }
Exemplo n.º 2
0
        /// <summary>
        /// 将读取的数据存至各PLC(导轨PLC包含于机器人类)
        /// </summary>
        /// <param name="Read_Var"></param>
        /// <param name="comPLC"></param>
        /// <param name="fixurePLC"></param>
        /// <param name="railPLC1"></param>
        /// <param name="railPLC2"></param>
        public static void ByteToPLCsys(Byte[] Read_Var, ComPLC comPLC, FixturePLC fixurePLC, RailPLC railPLC1, RailPLC railPLC2)
        {
            //将字节转化为bool值,存入到对应的plc中

            //读取Rail1 PLC中的值
            if (railPLC1 != null)
            {
                BitArray TEMP1 = new BitArray(new Byte[1] {
                    Read_Var[0]
                });
                BitArray TEMP2 = new BitArray(new Byte[1] {
                    Read_Var[1]
                });
                Byte[] BTEMP1 = new Byte[4];
                float  FTEMP1 = 0;
                railPLC1.Touch_Sensor_SG           = TEMP1[0];
                railPLC1.TeleCylin_Max_On          = TEMP1[1];
                railPLC1.TeleCylin_Min_On          = TEMP1[2];
                railPLC1.Laser_Sensor_CH1_On       = TEMP1[3];
                railPLC1.Laser_Sensor_CH2_On       = TEMP1[4];
                railPLC1.FlapWheel_RotaDrect       = TEMP1[5];
                railPLC1.FlapWheel_Servo_Warn_SG   = TEMP1[6];
                railPLC1.Rail_Servo_Warn_SG        = TEMP1[7];
                railPLC1.Rail_MotionDrect          = TEMP2[0];
                railPLC1.Rail_Position_Match_Done  = TEMP2[1];
                railPLC1.Rail_Search_OriginPT_Done = TEMP2[2];
                railPLC1.Rail_To_Desti_Done        = TEMP2[3];
                railPLC1.Device_Elec_Off           = TEMP2[4];
                railPLC1.Local_Communication_OK    = TEMP2[5];
                railPLC1.Local_PLC_ERR             = TEMP2[6];
                railPLC1.Local_Device_ERR          = TEMP2[7];
                //读取错误代码
                railPLC1.FlapWheel_Error_Code         = Read_Var[7];
                railPLC1.Rail_Read_Coder_ErrCode      = Read_Var[20];
                railPLC1.Rail_Position_Match_ErrCode  = Read_Var[21];
                railPLC1.Rail_Search_OriginPT_ErrCode = Read_Var[22];
                railPLC1.Rail_Jog_ErrCode             = Read_Var[23];
                railPLC1.Rail_To_Desti_ErrCode        = Read_Var[24];
                //读取实数

                //激光器1
                for (int i = 0; i <= 3; i++)
                {
                    BTEMP1[i] = Read_Var[3 + i];
                }
                Byte_ExRank(ref BTEMP1, 4);
                Byte_To_Float(BTEMP1, ref FTEMP1);
                railPLC1.Laser_Sensor_Value = FTEMP1;

                //激光器2
                for (int i = 0; i <= 3; i++)
                {
                    BTEMP1[i] = Read_Var[25 + i];
                }
                Byte_ExRank(ref BTEMP1, 4);
                Byte_To_Float(BTEMP1, ref FTEMP1);
                railPLC1.Laser_Sensor2_Value = FTEMP1;

                //百叶轮转速(或转矩)
                for (int i = 0; i <= 3; i++)
                {
                    BTEMP1[i] = Read_Var[8 + i];
                }
                Byte_ExRank(ref BTEMP1, 4);
                Byte_To_Float(BTEMP1, ref FTEMP1);
                railPLC1.FlapWheel_SpeedOrTorque = FTEMP1;

                for (int i = 0; i <= 3; i++)
                {
                    BTEMP1[i] = Read_Var[12 + i];
                }
                Byte_ExRank(ref BTEMP1, 4);
                Byte_To_Float(BTEMP1, ref FTEMP1);
                railPLC1.Rail_Robot_Position = FTEMP1;

                for (int i = 0; i <= 3; i++)
                {
                    BTEMP1[i] = Read_Var[16 + i];
                }
                Byte_ExRank(ref BTEMP1, 4);
                Byte_To_Float(BTEMP1, ref FTEMP1);
                railPLC1.Rail_Robot_Speed = FTEMP1;
            }

            //读取Rail2 PLC中的值
            if (railPLC2 != null)
            {
                BitArray TEMP1 = new BitArray(new Byte[1] {
                    Read_Var[0]
                });
                BitArray TEMP2 = new BitArray(new Byte[1] {
                    Read_Var[1]
                });
                Byte[] BTEMP1 = new Byte[4];
                float  FTEMP1 = 0;
                //读取bool值
                BitArray TEMP3 = new BitArray(new Byte[1] {
                    Read_Var[50]
                });
                BitArray TEMP4 = new BitArray(new Byte[1] {
                    Read_Var[51]
                });
                railPLC2.Touch_Sensor_SG           = TEMP3[0];
                railPLC2.TeleCylin_Max_On          = TEMP3[1];
                railPLC2.TeleCylin_Min_On          = TEMP3[2];
                railPLC2.Laser_Sensor_CH1_On       = TEMP3[3];
                railPLC2.Laser_Sensor_CH2_On       = TEMP3[4];
                railPLC2.FlapWheel_RotaDrect       = TEMP3[5];
                railPLC2.FlapWheel_Servo_Warn_SG   = TEMP3[6];
                railPLC2.Rail_Servo_Warn_SG        = TEMP3[7];
                railPLC2.Rail_MotionDrect          = TEMP4[0];
                railPLC2.Rail_Position_Match_Done  = TEMP4[1];
                railPLC2.Rail_Search_OriginPT_Done = TEMP4[2];
                railPLC2.Rail_To_Desti_Done        = TEMP4[3];
                railPLC2.Device_Elec_Off           = TEMP4[4];
                railPLC2.Local_Communication_OK    = TEMP4[5];
                railPLC2.Local_PLC_ERR             = TEMP4[6];
                railPLC2.Local_Device_ERR          = TEMP4[7];
                //读取错误代码
                railPLC2.FlapWheel_Error_Code         = Read_Var[57];
                railPLC2.Rail_Read_Coder_ErrCode      = Read_Var[70];
                railPLC2.Rail_Position_Match_ErrCode  = Read_Var[71];
                railPLC2.Rail_Search_OriginPT_ErrCode = Read_Var[72];
                railPLC2.Rail_Jog_ErrCode             = Read_Var[73];
                railPLC2.Rail_To_Desti_ErrCode        = Read_Var[74];
                //读取实数
                //激光器1
                Byte[] BTEMP2 = new Byte[4];
                float  FTEMP2 = 0;
                for (int i = 0; i <= 3; i++)
                {
                    BTEMP2[i] = Read_Var[53 + i];
                }
                Byte_ExRank(ref BTEMP2, 4);
                Byte_To_Float(BTEMP2, ref FTEMP2);
                railPLC2.Laser_Sensor_Value = FTEMP2;

                //激光器2
                for (int i = 0; i <= 3; i++)
                {
                    BTEMP1[i] = Read_Var[75 + i];
                }
                Byte_ExRank(ref BTEMP1, 4);
                Byte_To_Float(BTEMP1, ref FTEMP1);
                railPLC2.Laser_Sensor2_Value = FTEMP1;

                for (int i = 0; i <= 3; i++)
                {
                    BTEMP2[i] = Read_Var[58 + i];
                }
                Byte_ExRank(ref BTEMP2, 4);
                Byte_To_Float(BTEMP2, ref FTEMP2);
                railPLC2.FlapWheel_SpeedOrTorque = FTEMP2;

                for (int i = 0; i <= 3; i++)
                {
                    BTEMP2[i] = Read_Var[62 + i];
                }
                Byte_ExRank(ref BTEMP2, 4);
                Byte_To_Float(BTEMP2, ref FTEMP2);
                railPLC2.Rail_Robot_Position = FTEMP2;

                for (int i = 0; i <= 3; i++)
                {
                    BTEMP2[i] = Read_Var[66 + i];
                }
                Byte_ExRank(ref BTEMP2, 4);
                Byte_To_Float(BTEMP2, ref FTEMP2);
                railPLC2.Rail_Robot_Speed = FTEMP2;
            }

            //读取叶片夹持小车PLC中的值
            if (fixurePLC != null)
            {
                BitArray TEMP1 = new BitArray(new Byte[1] {
                    Read_Var[0]
                });
                BitArray TEMP2 = new BitArray(new Byte[1] {
                    Read_Var[1]
                });
                Byte[] BTEMP1 = new Byte[4];
                float  FTEMP1 = 0;
                //读取bool值
                BitArray TEMP5 = new BitArray(new Byte[1] {
                    Read_Var[100]
                });
                BitArray TEMP6 = new BitArray(new Byte[1] {
                    Read_Var[101]
                });
                fixurePLC.Fixture_Local_Reset_SG  = TEMP5[0];
                fixurePLC.Fixture_Jog_Rota_CW_SG  = TEMP5[1];
                fixurePLC.Fixture_Jog_Rota_CWW_SG = TEMP5[2];
                fixurePLC.Fixture_LRota_CW_SG     = TEMP5[3];
                fixurePLC.Fixture_LRota_CWW_SG    = TEMP5[4];
                fixurePLC.Fixture_Rota_CW_SG      = TEMP5[5];
                fixurePLC.Fixture_Rota_CWW_SG     = TEMP5[6];
                fixurePLC.Fixture1_Rotation_Done  = TEMP5[7];
                fixurePLC.Fixture2_Rotation_Done  = TEMP6[0];
                fixurePLC.Fixture_Rotation_Done   = TEMP6[1];
                fixurePLC.Fixture_Current_Mode    = TEMP6[2];
                fixurePLC.Fixture_Stop_SG         = TEMP6[3];
                fixurePLC.Local_Communication_OK  = TEMP6[4];
                fixurePLC.Local_PLC_ERR           = TEMP6[5];
                fixurePLC.Fixture_ERR_SG          = TEMP6[6];
                //读角度传感器
                for (int i = 0; i <= 3; i++)
                {
                    BTEMP1[i] = Read_Var[102 + i];
                }
                Byte_ExRank(ref BTEMP1, 4);
                Byte_To_Float(BTEMP1, ref FTEMP1);
                fixurePLC.Fixture_XAngle = FTEMP1;

                for (int i = 0; i <= 3; i++)
                {
                    BTEMP1[i] = Read_Var[106 + i];
                }
                Byte_ExRank(ref BTEMP1, 4);
                Byte_To_Float(BTEMP1, ref FTEMP1);
                fixurePLC.Fixture_YAngle = FTEMP1;
            }
            //读取通信PLC中的数值
            if (comPLC != null)
            {
                BitArray TEMP7 = new BitArray(new Byte[1] {
                    Read_Var[110]
                });
                comPLC.PLC_Communication_OK = TEMP7[0];
                comPLC.PLC_ERR_SG           = TEMP7[1];
                comPLC.System_ERR_SG        = TEMP7[2];
                comPLC.Enmergency_Stop_SG   = TEMP7[3];
            }
        }