Exemple #1
0
        private void btZero_Click(object sender, RoutedEventArgs e)
        {
            Cursor = Cursors.Wait;
            if (PLC_Tcp_CP.LiftOriginReset())
            {
                DateTime timeBegin = DateTime.Now;
                Thread.Sleep(1000);

                while (!PLC_Tcp_CP.LiftOriginResetIsOK())
                {
                    if (DateTime.Now > timeBegin.AddSeconds(Config.Mac_C.WaitTime_Reset_Lift))
                    {
                        break;
                    }
                    Thread.Sleep(500);
                }

                if (PLC_Tcp_CP.LiftOriginResetIsOK())
                {
                    csMsg.ShowInfo("原点返回完成", false);
                    tbPulse_Lift_Now.Text = PLC_Tcp_CP.ReadLiftPulse().ToString();
                }
                else
                {
                    csMsg.ShowWarning("原点返回失败", false);
                }
            }
            else
            {
                csMsg.ShowWarning("指令发送失败", false);
            }
            Cursor = null;
        }
Exemple #2
0
 //测试
 private void btTest_Click(object sender, RoutedEventArgs e)
 {
     if (lvPos.SelectedItems.Count > 0)
     {
         ErrorPos p       = lvPos.SelectedItems[0] as ErrorPos;
         string   poscode = p.PosCode;
         PLC_Tcp_CP.ClearRecordSingle(poscode);
         Thread.Sleep(100);
         PLC_Tcp_CP.DCTMoveDownSingle(poscode);
         Thread.Sleep(1000);
         int n = PLC_Tcp_CP.ReadRecordSingle(poscode);
         if (n == 1)
         {
             csMsg.ShowInfo("出药成功", true);
         }
         else if (n > 1)
         {
             csMsg.ShowWarning("多出药", true);
         }
         else
         {
             csMsg.ShowWarning("未出药", true);
         }
     }
 }
Exemple #3
0
        const int Speed_Manual_Baffle_Lift = 504; //D-2

        public static void SetSpeeds()
        {
            string speed = "";
            string send  = "";
            string response;

            //速度
            speed = PLC_Tcp_CP.Get16String(int.Parse(Config.Mac_C.Speed_Auto_Baffle_Belt), 8);
            send  = RegDMW + PLC_Tcp_CP.GetAdrD_1000(Speed_Auto_Baffle_Belt) + "0002" + "04" + speed.Substring(4, 4) + speed.Substring(0, 4);
            if (!SendPLC(send, "传送带挡板自动速度", out response))
            {
                return;
            }
            speed = PLC_Tcp_CP.Get16String(int.Parse(Config.Mac_C.Speed_Manual_Baffle_Belt), 8);
            send  = RegDMW + PLC_Tcp_CP.GetAdrD_1000(Speed_Manual_Baffle_Belt) + "0002" + "04" + speed.Substring(4, 4) + speed.Substring(0, 4);
            if (!SendPLC(send, "传送带挡板手动速度", out response))
            {
                return;
            }

            speed = PLC_Tcp_CP.Get16String(int.Parse(Config.Mac_C.Speed_Auto_Baffle_Lift), 8);
            send  = RegDMW + PLC_Tcp_CP.GetAdrD_1000(Speed_Auto_Baffle_Lift) + "0002" + "04" + speed.Substring(4, 4) + speed.Substring(0, 4);
            if (!SendPLC(send, "出药斗挡板自动速度", out response))
            {
                return;
            }
            speed = PLC_Tcp_CP.Get16String(int.Parse(Config.Mac_C.Speed_Manual_Baffle_Lift), 8);
            send  = RegDMW + PLC_Tcp_CP.GetAdrD_1000(Speed_Manual_Baffle_Lift) + "0002" + "04" + speed.Substring(4, 4) + speed.Substring(0, 4);
            if (!SendPLC(send, "出药斗挡板手动速度", out response))
            {
                return;
            }
        }
Exemple #4
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            timer_Presc.Interval = TimeSpan.FromSeconds(3);
            timer_Presc.Tick    += new EventHandler(timer_Presc_Tick);

            timer_Test.Tick += new EventHandler(timer_Test_Tick);

            cbLayer.SelectedIndex = 0;
            if (Config.Mac_C.PLC_Tcp == "Y")
            {
                tbPulse_Lift_Now.Text = PLC_Tcp_CP.ReadLiftPulse().ToString();
            }
            if (Config.Mac_C.PLC_Com == "Y")
            {
                tbPulse_Baffle_Lift_Now.Text = PLC_Com_CP.ReadBafflePulse_Lift().ToString();
            }

            tbTop.Text  = Config.Mac_C.Pulse_Lift_Top;
            tbUp.Text   = Config.Mac_C.Pulse_Lift_Up;
            tbDown.Text = Config.Mac_C.Pulse_Lift_Down;
            tbMeet.Text = Config.Mac_C.Pulse_Lift_Meet;

            tbOpen.Text  = Config.Mac_C.Pulse_Baffle_Open;
            tbClose.Text = Config.Mac_C.Pulse_Baffle_Close;

            if (Config.Mac_C.ShowTest == "Y")
            {
                gbTest.Visibility = Visibility.Visible;
            }
            else
            {
                gbTest.Visibility = Visibility.Hidden;
            }
        }
Exemple #5
0
        public static bool ClearRecordSingle(int master, int dct)
        {
            bool result = false;

            try
            {
                string send = PLC_Tcp_CP.Get16String(master, 2) + Order_Record_Write_Master + PLC_Tcp_CP.Get16String(dct, 2) + "00";
                string response;
                int    err; string errStr;
                int    num = 0;
                do
                {
                    num++;
                    bool b = SendPLC_DPJ_485(send, new StackTrace().GetFrame(0).GetMethod().ToString(), out response, out err, out errStr);
                    if (b)
                    {
                        result = true;
                        break;
                    }
                    else if (err != 3)
                    {
                        result = false;
                        //csLog.WriteLog(errStr);
                        break;
                    }
                } while (err == 3 && num < 3);
            }
            catch (Exception ex)
            {
                csLog.WriteLog(ex.Message);
            }
            return(result);
        }
Exemple #6
0
        private void btLift_Save_Meet_Click(object sender, RoutedEventArgs e)
        {
            float p = PLC_Tcp_CP.ReadLiftPulse();

            Config.SaveConfig(Config.Soft.MacCode, "Pulse_Lift_Meet", p.ToString());
            tbMeet.Text = p.ToString();
        }
Exemple #7
0
        private void btZero_Extraman_Click(object sender, RoutedEventArgs e)
        {
            Cursor = Cursors.Wait;

            if (PLC_Tcp_CP.ExtramanOriginReset())
            {
                DateTime timeBegin = DateTime.Now;
                Thread.Sleep(1000);
                while (!PLC_Tcp_CP.ExtramanOriginResetIsOK())
                {
                    if (DateTime.Now > timeBegin.AddSeconds(Config.Mac_C.WaitTime_Reset_Extraman))
                    {
                        break;
                    }
                    Thread.Sleep(200);
                }
                if (DateTime.Now <= timeBegin.AddSeconds(Config.Mac_C.WaitTime_Reset_Extraman))
                {
                    //关闭使能
                    //PLC.ExtramanOriginReset_OFF();
                    tbNowX.Text = PLC_Tcp_CP.ReadExtramanPulseX().ToString();
                    tbNowZ.Text = PLC_Tcp_CP.ReadExtramanPulseZ().ToString();
                    csMsg.ShowInfo("原点返回完成", false);
                }
            }
            else
            {
                csMsg.ShowWarning("指令发送失败", false);
            }
            Cursor = null;
        }
Exemple #8
0
 //推药板原点返回
 private void btZero_Plate_Click(object sender, RoutedEventArgs e)
 {
     Cursor = Cursors.Wait;
     if (PLC_Tcp_CP.PlateOriginReset())
     {
         DateTime timeBegin = DateTime.Now;
         Thread.Sleep(1000);
         while (!PLC_Tcp_CP.PlateOriginResetIsOK())
         {
             if (DateTime.Now > timeBegin.AddSeconds(Config.Mac_C.WaitTime_Reset_Plate))
             {
                 break;
             }
             Thread.Sleep(200);
         }
         if (DateTime.Now <= timeBegin.AddSeconds(Config.Mac_C.WaitTime_Reset_Plate))
         {
             tbNowL.Text = PLC_Tcp_CP.ReadPlatePulse(PLC_Tcp_AP.PlateType.Left).ToString();
             tbNowR.Text = PLC_Tcp_CP.ReadPlatePulse(PLC_Tcp_AP.PlateType.Right).ToString();
             csMsg.ShowInfo("原点返回完成", false);
         }
     }
     else
     {
         csMsg.ShowWarning("指令发送失败", false);
     }
     Cursor = null;
 }
Exemple #9
0
        private void Lift_Run_Auto(float p)
        {
            Cursor = Cursors.Wait;
            PLC_Tcp_CP.ChangeOut(1);
            PLC_Tcp_CP.LiftAutoMoveByPulse(p);
            DateTime timeBegin = DateTime.Now;

            Thread.Sleep(200);
            while (!PLC_Tcp_CP.LiftAutoMoveIsOK())
            {
                if (DateTime.Now > timeBegin.AddSeconds(Config.Mac_C.WaitTime_Auto_Lift))
                {
                    break;
                }
                Thread.Sleep(200);
            }
            if (DateTime.Now <= timeBegin.AddSeconds(Config.Mac_C.WaitTime_Auto_Lift))
            {
                tbPulse_Lift_Now.Text = PLC_Tcp_CP.ReadLiftPulse().ToString();
            }
            else
            {
                csMsg.ShowWarning("提升机未运行到指定位置", false);
            }
            Cursor = null;
        }
Exemple #10
0
        public static bool BaffleOriginResetOFF_Lift()
        {
            string send = RegMSW + PLC_Tcp_CP.GetAdrM(BaffleOrigin) + "0000";
            string response;

            return(SendPLC(send, "提升机挡板原点复位", out response));
        }
Exemple #11
0
        const int BaffleManualMoveStatus_Down = 6;//D-1
        public static bool Baffle_Lift_IsMinDown()
        {
            bool   result = false;
            string send   = RegDR + PLC_Tcp_CP.GetAdrD_1000(BaffleManualMoveStatus_Down) + "0001";
            string response;

            if (SendPLC(send, "出药挡板状态", out response))
            {
                int i = response.IndexOf(":");
                if (i >= 0)
                {
                    if (PLC_Tcp_CP.Get16Int(response.Substring(i + 7, 4)) == 1)
                    {
                        result = true;
                    }
                }
            }
            if (!result)
            {
                send = RegDR + PLC_Tcp_CP.GetAdrD_1000(BaffleAutoMoveStatus_Down) + "0001";
                if (SendPLC(send, "出药挡板状态", out response))
                {
                    int i = response.IndexOf(":");
                    if (i >= 0)
                    {
                        if (PLC_Tcp_CP.Get16Int(response.Substring(i + 7, 4)) == 2)
                        {
                            result = true;
                        }
                    }
                }
            }
            return(result);
        }
Exemple #12
0
        private void btUp_Click(object sender, RoutedEventArgs e)
        {
            Cursor = Cursors.Wait;
            PLC_Tcp_CP.ChangeAdd(2);

            //自动上推
            //PLC.PlateMoveUpBegin();
            PLC_Tcp_CP.PlateMoveUp(PLC_Tcp_AP.PlateType.Left);
            PLC_Tcp_CP.PlateMoveUp(PLC_Tcp_AP.PlateType.Right);
            DateTime timeBegin = DateTime.Now;

            Thread.Sleep(1000);
            while (!PLC_Tcp_CP.PlateMoveUpIsOK(PLC_Tcp_AP.PlateType.Left) || !PLC_Tcp_CP.PlateMoveUpIsOK(PLC_Tcp_AP.PlateType.Right))
            {
                if (DateTime.Now > timeBegin.AddSeconds(Config.Mac_C.WaitTime_Up_Plate))
                {
                    break;
                }
                Thread.Sleep(200);
            }
            if (DateTime.Now <= timeBegin.AddSeconds(Config.Mac_C.WaitTime_Up_Plate))
            {
                tbNowL.Text = PLC_Tcp_CP.ReadPlatePulse(PLC_Tcp_AP.PlateType.Left).ToString();
                tbNowR.Text = PLC_Tcp_CP.ReadPlatePulse(PLC_Tcp_AP.PlateType.Right).ToString();
            }
            else
            {
                csMsg.ShowWarning("推板上推失败", false);
            }
            Cursor = null;
        }
Exemple #13
0
        private void btSaveR_Click(object sender, RoutedEventArgs e)
        {
            float x = PLC_Tcp_CP.ReadPlatePulse(PLC_Tcp_AP.PlateType.Right);

            Config.SaveConfig(Config.Soft.MacCode, "Pulse_Plate_Max_Right", x.ToString());
            tbPlatePulseMaxR.Text = x.ToString();
        }
Exemple #14
0
        const int Baffle_Manual_Lift_Down = 7; //M-1
        public static void BaffleMove_Lift(PLC_Com_AP.BaffleMoveType_Lift type)
        {
            int adr = 0;

            switch (type)
            {
            case PLC_Com_AP.BaffleMoveType_Lift.Up:
                adr = Baffle_Manual_Lift_Up;
                break;

            case PLC_Com_AP.BaffleMoveType_Lift.Down:
                adr = Baffle_Manual_Lift_Down;
                break;
            }
            string send = "";
            string response;

            if (type == PLC_Com_AP.BaffleMoveType_Lift.Stop) //停止,两个地址置0
            {
                send = RegMMW + PLC_Tcp_CP.GetAdrM(Baffle_Manual_Lift_Up) + "0002" + "01" + "00";
            }
            else
            {
                send = RegMSW + PLC_Tcp_CP.GetAdrM(adr) + "FF00";
            }
            SendPLC(send, "挡板手动运行使能开启", out response);
        }
Exemple #15
0
        public static bool DCTMoveDownSingle(int master, int dct, int time)
        {
            bool result = false;

            try
            {
                string send = PLC_Tcp_CP.Get16String(master, 2) + Order_DCT_Master + PLC_Tcp_CP.Get16String(dct, 2) + PLC_Tcp_CP.Get16String(time / 10, 2) + PLC_Tcp_CP.Get16String(Config.Mac_C.DelayTime_Record / 10, 2) + PLC_Tcp_CP.Get16String(Config.Mac_C.StopTime_Record / 10, 2);
                string response;
                int    err; string errStr;
                int    num = 0;
                do
                {
                    num++;
                    bool b = SendPLC_DPJ_485(send, new StackTrace().GetFrame(0).GetMethod().ToString(), out response, out err, out errStr);
                    if (b)
                    {
                        result = true;
                        break;
                    }
                    else if (err != 3)
                    {
                        result = false;
                        //csLog.WriteLog(errStr);
                        break;
                    }
                } while (err == 3 && num < 3);
            }
            catch (Exception ex)
            {
                csMsg.ShowWarning(ex.Message, true);
            }
            return(result);
        }
Exemple #16
0
        private void btPD_Click(object sender, RoutedEventArgs e)
        {
            PLC_Tcp_CP.LaserOn();
            toPD = true;

            PDItem();
            timer_PD.Start();
        }
Exemple #17
0
            public void Up()
            {
                //获取药盒厚度
                double drugThickness = 10;
                string sql           = "select height from drug_infoannex where drugonlycode='" + plate.DrugOnlyCode + "'";
                string s;

                csSql.ExecuteScalar(sql, Config.Soft.ConnString, out s);
                if (!string.IsNullOrEmpty(s))
                {
                    drugThickness = double.Parse(s);
                }

                PLC_Tcp_CP.ChangeAdd(2);
                //自动上推
                //PLC.PlateMoveUpBegin();
                PLC_Tcp_CP.PlateMoveUp(plate.PlateType);
                DateTime timeBegin = DateTime.Now;

                Thread.Sleep(200);
                //等待就位
                while (!PLC_Tcp_CP.PlateMoveUpIsOK(plate.PlateType))
                {
                    if (DateTime.Now > timeBegin.AddSeconds(Config.Mac_C.WaitTime_Up_Plate))
                    {
                        return;
                    }
                    Thread.Sleep(200);
                }
                Thread.Sleep(100);
                //当前脉冲
                float nowPulse = PLC_Tcp_CP.ReadPlatePulse(plate.PlateType);
                //获取脉冲上限
                float maxPulse = 0f;

                if (plate.PlateType == PLC_Tcp_AP.PlateType.Left)
                {
                    maxPulse = float.Parse(Config.Mac_C.Pulse_Plate_Max_Left);
                }
                else
                {
                    maxPulse = float.Parse(Config.Mac_C.Pulse_Plate_Max_Right);
                }
                //计算仓内数量
                double sumHeight = Math.Round((maxPulse - nowPulse) * 1.0 / Config.Mac_C.OneMMPulse_Plate, 2);
                int    boxNum    = (int)Math.Round((double)sumHeight / drugThickness);

                plate.Num = boxNum;

                if (plate.PlateType == PLC_Tcp_AP.PlateType.Left)
                {
                    upLeftIsOK = true;
                }
                else
                {
                    upRightIsOK = true;
                }
            }
Exemple #18
0
        private void btPos_ClearRecord_Click(object sender, RoutedEventArgs e)
        {
            Button b    = sender as Button;
            string unit = cbUnit.Text;
            string lay  = cbLayer.Text;
            string col  = b.Tag.ToString();
            string pos  = unit + lay + col;

            PLC_Tcp_CP.ClearRecordSingle(pos);
        }
Exemple #19
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            timer_Monitor.Interval = TimeSpan.FromSeconds(3);
            timer_Monitor.Tick    += new EventHandler(timer_Monitor_Tick);
            timer_Monitor.Start();

            grid_Monitor.Visibility = Visibility.Collapsed;
            if (Config.Soft.Function == "I")
            {
                sp_Out_Auto.Visibility = sp_Out_Manul.Visibility = sp_Error_Out.Visibility = Visibility.Hidden;
                grid_Lift.Visibility   = grid_Max_Baffle.Visibility = grid_Min_Baffle.Visibility = Visibility.Collapsed;
            }
            else
            {
                sp_Add_List.Visibility = sp_Add.Visibility = Visibility.Hidden;
                grid_X.Visibility      = grid_Z.Visibility = grid_Left.Visibility = grid_Right.Visibility = grid_ZHA.Visibility = Visibility.Collapsed;

                ellipseGM.Visibility = tb_GM.Visibility = Visibility.Collapsed;
            }

            PLC_Tcp_CP.ThrowMsg += new PLC_Tcp_CP.ShowMsg(MsgChanged);
            PLC_Com_CP.ThrowMsg += new PLC_Com_CP.ShowMsg(MsgChanged);
            DPJ_CP.ThrowMsg     += new DPJ_CP.ShowMsg(MsgChanged);
            //Scanner.ThrowMsg += new Scanner.ShowMsg(MsgChanged);
            //Laser.ThrowMsg += new Laser.ShowMsg(MsgChanged);
            CSHelper.SQL.ThrowMsg += new CSHelper.SQL.ShowMsg(MsgChanged);
            OutDrug_CP.ThrowMsg   += new OutDrug_CP.ShowMsg(MsgChanged);

            UCDebug_Add_CP.ShowKey  += new UCDebug_Add_CP.SetKey(KeyShow);
            UCAdd_CP.ShowKey        += new UCAdd_CP.SetKey(KeyShow);
            UCOut_Manual_CP.ShowKey += new UCOut_Manual_CP.SetKey(KeyShow);
            UCDebug_Out_CP.ShowKey  += new UCDebug_Out_CP.SetKey(KeyShow);

            if (Config.Soft.Function == "O")
            {
                ellipseGM.Visibility = Visibility.Collapsed;
                tb_GM.Visibility     = Visibility.Collapsed;
            }

            if (csMsg.ShowQuestion("设备在断电后的第一次启动时,运动部件需要原点复位。\r\n是否要原点复位?", false))
            {
                if (Config.Soft.Function == "I")
                {
                    PLC_Tcp_CP.ExtramanOriginReset();
                    Thread.Sleep(1000);
                    PLC_Tcp_CP.PlateOriginReset();
                }
                else
                {
                    PLC_Tcp_CP.LiftOriginReset();
                    Thread.Sleep(1000);
                    PLC_Com_CP.BaffleOriginReset_Lift();
                }
            }
        }
Exemple #20
0
        //保存接药位置脉冲
        private void btSaveMeet_Click(object sender, RoutedEventArgs e)
        {
            float x = PLC_Tcp_CP.ReadExtramanPulseX();

            Config.SaveConfig(Config.Soft.MacCode, "Pulse_Meet_X", x.ToString());
            tbMeetX.Text = x.ToString();
            float z = PLC_Tcp_CP.ReadExtramanPulseZ();

            Config.SaveConfig(Config.Soft.MacCode, "Pulse_Meet_Z", z.ToString());
            tbMeetZ.Text = z.ToString();
        }
Exemple #21
0
        const int BaffleAutoMovePulse_Down_Lift_On = 13;  //M-1
        public static void BaffleAutoMoveByPulse_Down_Lift(int pulse)
        {
            string s    = PLC_Tcp_CP.Get16String(pulse, 8);
            string send = RegDMW + PLC_Tcp_CP.GetAdrD_1000(BaffleAutoMovePulse_Down_Lift) + "0002" + "04" + s.Substring(4, 4) + s.Substring(0, 4);
            string response;

            if (SendPLC(send, "挡板自动运行脉冲", out response))
            {
                send = RegMSW + PLC_Tcp_CP.GetAdrM(BaffleAutoMovePulse_Down_Lift_On) + "FF00";
                SendPLC(send, "挡板自动运行使能", out response);
            }
        }
Exemple #22
0
        //机械手运行到指定脉冲
        private void btRunAuto_Click(object sender, RoutedEventArgs e)
        {
            ShowKey(false);
            //csKey.Close();
            Cursor = Cursors.Wait;
            PLC_Tcp_CP.ChangeAdd(1);
            string x = tbTargetX.Text.Trim();
            string z = tbTargetZ.Text.Trim();

            if (string.IsNullOrEmpty(x))
            {
                csMsg.ShowWarning("X轴脉冲不能为空", false);
                Cursor = null;
                return;
            }
            if (string.IsNullOrEmpty(z))
            {
                csMsg.ShowWarning("Z轴脉冲不能为空", false);
                Cursor = null;
                return;
            }
            float xp; float zp;

            if (float.TryParse(x, out xp) && float.TryParse(z, out zp))
            {
                PLC_Tcp_CP.ExtramanAutoMoveToPulse(xp, zp);
                DateTime timeBegin = DateTime.Now;
                Thread.Sleep(200);
                while (!PLC_Tcp_CP.ExtramanAutoMoveIsOK())
                {
                    if (DateTime.Now > timeBegin.AddSeconds(Config.Mac_C.WaitTime_Auto_Extraman))
                    {
                        break;
                    }
                    Thread.Sleep(200);
                }
                if (DateTime.Now <= timeBegin.AddSeconds(Config.Mac_C.WaitTime_Auto_Extraman))
                {
                    tbNowX.Text = PLC_Tcp_CP.ReadExtramanPulseX().ToString();
                    tbNowZ.Text = PLC_Tcp_CP.ReadExtramanPulseZ().ToString();
                }
                else
                {
                    csMsg.ShowWarning("机械手未运行到指定位置", false);
                }
            }
            else
            {
                csMsg.ShowWarning("脉冲值格式不正确", false);
            }

            Cursor = null;
        }
Exemple #23
0
        const int Baffle_Manual = 102; //M-1
        //挡板手自动切换(与传送带挡板共用)
        public static void Baffle_Change(int auto)
        {
            int adr = Baffle_Auto;

            if (auto == 0)
            {
                adr = Baffle_Manual;
            }

            string send = RegMSW + PLC_Tcp_CP.GetAdrM(adr) + "FF00";
            string response;

            SendPLC(send, "挡板手自动切换", out response);
        }
Exemple #24
0
        //计算FCS码
        static string GetFCS(String value)
        {
            int f = 0;
            int j = value.Length;

            for (int i = 0; i < j; i += 2)
            {
                int x = PLC_Tcp_CP.Get16Int(value.Substring(i, 2));
                //每次进行异或运算
                f = f ^ x;
            }
            //转换为16进制
            return(f.ToString("X"));
        }
Exemple #25
0
        private void Back()
        {
            SetErrorVisibility(Visibility.Hidden);

            ShowPlate(PLC_Tcp_AP.PlateType.Left, "", 0);

            ShowPlate(PLC_Tcp_AP.PlateType.Right, "", 0);

            PLC_Tcp_CP.ChangeAdd(1);
            //运行到接药口
            PLC_Tcp_CP.ExtramanAutoMoveToPulse(float.Parse(Config.Mac_C.Pulse_Meet_X), float.Parse(Config.Mac_C.Pulse_Meet_Z));
            //推药板复位
            PLC_Tcp_CP.PlateAutoMoveToPulse(PLC_Tcp_AP.PlateType.Left, float.Parse(Config.Mac_C.Pulse_Plate_Min_Left));
            PLC_Tcp_CP.PlateAutoMoveToPulse(PLC_Tcp_AP.PlateType.Right, float.Parse(Config.Mac_C.Pulse_Plate_Min_Right));
        }
Exemple #26
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            rbAdd.IsChecked          = true; rbHandL.IsChecked = true;
            cbUnitCode.SelectedIndex = cbLayerCode.SelectedIndex = cbColumnCode.SelectedIndex = 0;

            tbNowX.Text = PLC_Tcp_CP.ReadExtramanPulseX().ToString();
            tbNowZ.Text = PLC_Tcp_CP.ReadExtramanPulseZ().ToString();
            tbNowL.Text = PLC_Tcp_CP.ReadPlatePulse(PLC_Tcp_AP.PlateType.Left).ToString();
            tbNowR.Text = PLC_Tcp_CP.ReadPlatePulse(PLC_Tcp_AP.PlateType.Right).ToString();

            tbMeetX.Text          = Config.Mac_C.Pulse_Meet_X;
            tbMeetZ.Text          = Config.Mac_C.Pulse_Meet_Z;
            tbPlatePulseMaxL.Text = Config.Mac_C.Pulse_Plate_Max_Left;
            tbPlatePulseMaxR.Text = Config.Mac_C.Pulse_Plate_Max_Right;
        }
Exemple #27
0
        const int BaffleOrigin = 2;//M-1
        public static bool BaffleOriginReset_Lift()
        {
            //BaffleOriginResetOFF_Lift();
            //PLC_Tcp.Origin_Out_On();

            string send = RegMSW + PLC_Tcp_CP.GetAdrM(BaffleOrigin) + "FF00";
            string response;

            return
                (SendPLC(send, "提升机挡板原点复位", out response));

            //send = RegMR + PLC_Tcp.GetAdrM(BaffleOrigin) + "0001";
            //SendPLC(send, "提升机挡板原点复位", out response);

            //return true;
        }
Exemple #28
0
        const int BafflePulse_Lift = 1336;//D-2
        //读取脉冲
        public static int ReadBafflePulse_Lift()
        {
            int    result = 0;
            string send   = RegDR + PLC_Tcp_CP.GetAdrD_1000(BafflePulse_Lift) + "0002";
            string response;

            if (SendPLC(send, "挡板脉冲", out response))
            {
                int i = response.IndexOf(":");
                if (i >= 0)
                {
                    string s = response.Substring(i + 7, 8);
                    result = PLC_Tcp_CP.Get16Int(s.Substring(4, 4) + s.Substring(0, 4));
                }
            }
            return(result);
        }
Exemple #29
0
        private void Test()
        {
            string unit   = cbUnit.Text;
            string lay    = cbLayer.Text;
            string record = "";

            for (int i = 23; i >= 1; i--)
            {
                string pos = unit + lay + i.ToString().PadLeft(2, '0');
                PLC_Tcp_CP.DCTMoveDownSingle(pos);
                Thread.Sleep(100);
                record += PLC_Tcp_CP.ReadRecordSingle(pos) + " ";
                Thread.Sleep(100);
            }
            tbRecord.Text = record;
            num++;
            tbNum.Text = num.ToString();
        }
Exemple #30
0
        //推药板自动运行
        private void btRunR_Click(object sender, RoutedEventArgs e)
        {
            ShowKey(false);
            //csKey.Close();
            Cursor = Cursors.Wait;
            PLC_Tcp_CP.ChangeAdd(1);
            string p = tbTargetR.Text.Trim();

            if (string.IsNullOrEmpty(p))
            {
                csMsg.ShowWarning("脉冲不能为空", false);
                Cursor = null;
                return;
            }
            float pp;

            if (float.TryParse(p, out pp))
            {
                PLC_Tcp_CP.PlateAutoMoveToPulse(PLC_Tcp_AP.PlateType.Right, pp);
                DateTime timeBegin = DateTime.Now;
                Thread.Sleep(200);
                while (!PLC_Tcp_CP.PlateAutoMoveToPulseIsOK(PLC_Tcp_AP.PlateType.Right))
                {
                    if (DateTime.Now > timeBegin.AddSeconds(Config.Mac_C.WaitTime_Auto_Plate))
                    {
                        break;
                    }
                    Thread.Sleep(200);
                }
                if (DateTime.Now <= timeBegin.AddSeconds(Config.Mac_C.WaitTime_Auto_Plate))
                {
                    tbNowR.Text = PLC_Tcp_CP.ReadPlatePulse(PLC_Tcp_AP.PlateType.Right).ToString();
                }
                else
                {
                    csMsg.ShowWarning("推药板未运行到指定位置", false);
                }
            }
            else
            {
                csMsg.ShowWarning("脉冲格式不正确", false);
            }
            Cursor = null;
        }