コード例 #1
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;
        }
コード例 #2
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;
                }
            }
コード例 #3
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;
        }
コード例 #4
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));
        }
コード例 #5
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;
        }
コード例 #6
0
        //加药
        private void btAdd_Click(object sender, RoutedEventArgs e)
        {
            Cursor     = Cursors.Wait;
            upLeftIsOK = upRightIsOK = true;
            //推药板上移
            bool toUp = false;

            foreach (Plate p in Plates)
            {
                if (p.Num > 0)
                {
                    toUp = true;
                    break;
                }
            }
            if (toUp)
            {
                IsBusy = true;
                foreach (Plate p in Plates)
                {
                    if (p.Num > 0)
                    {
                        if (p.PlateType == PLC_Tcp_AP.PlateType.Left)
                        {
                            upLeftIsOK = false;
                            p.Batch    = tbBatchL.Text.Trim();
                            p.QZ       = (bool)chkBatchL.IsChecked;

                            PlateUp clspu = new PlateUp(p);
                            thUpL = new Thread(clspu.Up);
                            thUpL.IsBackground = true;
                            thUpL.Start();
                        }
                        else
                        {
                            upRightIsOK = false;
                            p.Batch     = tbBatchR.Text.Trim();
                            p.QZ        = (bool)chkBatchR.IsChecked;

                            PlateUp clspu = new PlateUp(p);
                            thUpR = new Thread(clspu.Up);
                            thUpR.IsBackground = true;
                            thUpR.Start();
                        }
                    }
                }

                DateTime timeBegin = DateTime.Now;
                //机械手加药
                while (!upLeftIsOK || !upRightIsOK)
                {
                    if (DateTime.Now > timeBegin.AddSeconds(Config.Mac_C.WaitTime_Up_Plate))
                    {
                        break;
                    }
                    Thread.Sleep(100);
                }
                if (upLeftIsOK && upRightIsOK)
                {
                    SetNumL(plate_Left.Num);
                    SetNumR(plate_Right.Num);

                    PLC_Tcp_CP.ChangeAdd(1);
                    //先设定当前位置
                    float pulse = PLC_Tcp_CP.ReadPlatePulse(PLC_Tcp_AP.PlateType.Left);
                    PLC_Tcp_CP.PlateAutoMoveToPulse(PLC_Tcp_AP.PlateType.Left, pulse);
                    pulse = PLC_Tcp_CP.ReadPlatePulse(PLC_Tcp_AP.PlateType.Right);
                    PLC_Tcp_CP.PlateAutoMoveToPulse(PLC_Tcp_AP.PlateType.Right, pulse);

                    bool toAdd = false;
                    foreach (Plate p in Plates)
                    {
                        if (p.Num > 0)
                        {
                            toAdd = true;
                            break;
                        }
                    }
                    if (toAdd)
                    {
                        Thread thAdd = new Thread(Add);
                        thAdd.IsBackground = true;
                        thAdd.Start();
                        //Add();
                    }
                    else
                    {
                        IsBusy = false;
                    }
                }
                else
                {
                    IsBusy = false;
                    Cursor = null;
                }
                if (IsBusy)
                {
                    timer_Num.Start();
                }
            }
            else
            {
                Cursor = null;
            }
        }
コード例 #7
0
 //推药板向下
 private void btPlateDownR_MouseDown(object sender, MouseButtonEventArgs e)
 {
     PLC_Tcp_CP.ChangeAdd(0);
     PLC_Tcp_CP.PlateManualMove(PLC_Tcp_AP.PlateType.Right, PLC_Tcp_AP.PlateMoveDir.Down);
 }
コード例 #8
0
 //向右
 private void btExtraman_Manual_Right_PreviewMouseDown(object sender, MouseButtonEventArgs e)
 {
     PLC_Tcp_CP.ChangeAdd(0);
     PLC_Tcp_CP.ExtramanManualMove(PLC_Tcp_AP.ExtramanMoveDir.Right);
 }