예제 #1
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;
            }
        }
예제 #2
0
        private void btBaffle_Lift_Save_Close_Click(object sender, RoutedEventArgs e)
        {
            int p = PLC_Com_CP.ReadBafflePulse_Lift();

            Config.SaveConfig(Config.Soft.MacCode, "Pulse_Baffle_Close", p.ToString());
            tbClose.Text = p.ToString();
        }
예제 #3
0
        private void btZero_Baffle_Lift_Click(object sender, RoutedEventArgs e)
        {
            Cursor = Cursors.Wait;
            if (PLC_Com_CP.BaffleOriginReset_Lift())
            {
                DateTime timeBegin = DateTime.Now;
                Thread.Sleep(1000);

                while (!PLC_Com_CP.BaffleOriginResetIsOK())
                {
                    if (DateTime.Now > timeBegin.AddSeconds(Config.Mac_C.WaitTime_Reset_Baffle))
                    {
                        break;
                    }
                    Thread.Sleep(500);
                }

                if (PLC_Com_CP.BaffleOriginResetIsOK())
                {
                    csMsg.ShowInfo("原点返回完成", false);
                    tbPulse_Baffle_Lift_Now.Text = PLC_Com_CP.ReadBafflePulse_Lift().ToString();
                }
                else
                {
                    csMsg.ShowWarning("原点返回失败", false);
                }
            }
            else
            {
                csMsg.ShowWarning("指令发送失败", false);
            }
            Cursor = null;
        }
예제 #4
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();
                }
            }
        }
예제 #5
0
        private void Baffle_Lift_AutoRun(int pulse)
        {
            Cursor = Cursors.Wait;
            //PLC_Tcp.ChangeOut(1);
            PLC_Com_CP.Baffle_Change(1);

            int pulse_Now = PLC_Com_CP.ReadBafflePulse_Lift();

            if (pulse > pulse_Now)
            {
                PLC_Com_CP.BaffleAutoMoveByPulse_Up_Lift(pulse);
                DateTime timeBegin = DateTime.Now;
                Thread.Sleep(500);
                while (!PLC_Com_CP.BaffleAutoMoveIsOK_Up())
                {
                    if (DateTime.Now > timeBegin.AddSeconds(Config.Mac_C.WaitTime_Auto_Baffle))
                    {
                        break;
                    }
                    Thread.Sleep(500);
                }
                if (DateTime.Now <= timeBegin.AddSeconds(Config.Mac_C.WaitTime_Auto_Baffle))
                {
                    tbPulse_Baffle_Lift_Now.Text = pulse.ToString();
                }
                else
                {
                    csMsg.ShowWarning("挡板未运行到指定位置", false);
                }
            }
            else
            {
                PLC_Com_CP.BaffleAutoMoveByPulse_Down_Lift(pulse);
                DateTime timeBegin = DateTime.Now;
                Thread.Sleep(500);
                while (!PLC_Com_CP.BaffleAutoMoveIsOK_Down())
                {
                    if (DateTime.Now > timeBegin.AddSeconds(Config.Mac_C.WaitTime_Auto_Baffle))
                    {
                        break;
                    }
                    Thread.Sleep(500);
                }
                if (DateTime.Now <= timeBegin.AddSeconds(Config.Mac_C.WaitTime_Auto_Baffle))
                {
                    tbPulse_Baffle_Lift_Now.Text = pulse.ToString();
                }
                else
                {
                    csMsg.ShowWarning("挡板未运行到指定位置", false);
                }
            }
            Cursor = null;
        }
예제 #6
0
 private void btBaffle_Lift_Stop_PreviewMouseUp(object sender, MouseButtonEventArgs e)
 {
     PLC_Com_CP.BaffleMove_Lift(PLC_Com_AP.BaffleMoveType_Lift.Stop);
     tbPulse_Baffle_Lift_Now.Text = PLC_Com_CP.ReadBafflePulse_Lift().ToString();
 }
예제 #7
0
 private void btBaffle_Lift_Down_PreviewMouseDown(object sender, MouseButtonEventArgs e)
 {
     PLC_Com_CP.Baffle_Change(0);
     PLC_Com_CP.BaffleMove_Lift(PLC_Com_AP.BaffleMoveType_Lift.Down);
 }
예제 #8
0
        public WinMain_CP()
        {
            InitializeComponent();

            if (!csSql.SQLIsConnected(Config.Soft.ConnString))
            {
                csMsg.ShowWarning("服务器未连接", true);

                Application.Current.Shutdown();
            }
            Config.InitialConfig_Mac_C();

            if (Config.Mac_C.PLC_Tcp == "Y")
            {
                PLC_Tcp_CP.Initial();
            }

            string[] ports = SerialPort.GetPortNames();
            if (Config.Soft.Function == "I")
            {
                if (Config.Mac_C.Scanner == "Y")
                {
                    if (ports.Contains(Config.Mac_C.Port_Scanner))
                    {
                        Scanner.InitialScanPort();
                    }
                    else
                    {
                        csMsg.ShowWarning("扫描枪串口不存在", true);
                    }
                }

                if (Config.Mac_C.Laser_Left == "Y")
                {
                    if (ports.Contains(Config.Mac_C.Port_Laser_Left))
                    {
                        Laser.InitialLaserPort_Left();
                    }
                    else
                    {
                        csMsg.ShowWarning("左侧激光串口不存在", true);
                    }
                }
                if (Config.Mac_C.Laser_Right == "Y")
                {
                    if (ports.Contains(Config.Mac_C.Port_Laser_Right))
                    {
                        Laser.InitialLaserPort_Right();
                    }
                    else
                    {
                        csMsg.ShowWarning("右侧激光串口不存在", true);
                    }
                }
            }
            else
            {
                if (Config.Mac_C.PLC_Com == "Y")
                {
                    if (ports.Contains(Config.Mac_C.Port_PLC))
                    {
                        PLC_Com_CP.Initial();
                    }
                }
                if (Config.Mac_C.DPJ == "Y")
                {
                    if (ports.Contains(Config.Mac_C.Port_DPJ))
                    {
                        DPJ_CP.Initial();
                    }
                    else
                    {
                        csMsg.ShowWarning("单片机串口不存在", true);
                    }
                }
            }
            grid_Key.Visibility = Visibility.Collapsed;
        }
예제 #9
0
        void timer_Monitor_Tick(object sender, EventArgs e)
        {
            GC.Collect();

            bool error = false;

            if (Config.Soft.Function == "I")
            {
                if (Config.Mac_C.PLC_Tcp == "Y")
                {
                    //X轴
                    if (PLC_Tcp_CP.TrackStateIsOK(PLC_Tcp_CP.TrackErrorType.X1) && PLC_Tcp_CP.TrackStateIsOK(PLC_Tcp_CP.TrackErrorType.X2))// && PLC.ExtramanOriginResetState(PLC.TrackErrorType.X1) && PLC.ExtramanOriginResetState(PLC.TrackErrorType.X2))
                    {
                        grid_X.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        error             = true;
                        tbX_Up.Text       = PLC_Tcp_CP.ReadTrackErrorCode(PLC_Tcp_CP.TrackErrorType.X1);
                        tbX_Down.Text     = PLC_Tcp_CP.ReadTrackErrorCode(PLC_Tcp_CP.TrackErrorType.X2);
                        grid_X.Visibility = Visibility.Visible;
                    }
                    //Z轴
                    if (PLC_Tcp_CP.TrackStateIsOK(PLC_Tcp_CP.TrackErrorType.Z))// && PLC.ExtramanOriginResetState(PLC.TrackErrorType.Z))
                    {
                        grid_Z.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        error             = true;
                        tbZ.Text          = PLC_Tcp_CP.ReadTrackErrorCode(PLC_Tcp_CP.TrackErrorType.Z);
                        grid_Z.Visibility = Visibility.Visible;
                    }
                    //左臂
                    if (PLC_Tcp_CP.PlateStateIsOK(PLC_Tcp_AP.PlateType.Left))// && PLC.PlateOriginResetState(PLC.PlateType.Left))
                    {
                        grid_Left.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        error                = true;
                        tbLeft.Text          = PLC_Tcp_CP.ReadPlateErrorCode(PLC_Tcp_AP.PlateType.Left);
                        grid_Left.Visibility = Visibility.Visible;
                    }
                    //右臂
                    if (PLC_Tcp_CP.PlateStateIsOK(PLC_Tcp_AP.PlateType.Right))// && PLC.PlateOriginResetState(PLC.PlateType.Right))
                    {
                        grid_Right.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        error                 = true;
                        tbRight.Text          = PLC_Tcp_CP.ReadPlateErrorCode(PLC_Tcp_AP.PlateType.Right);
                        grid_Right.Visibility = Visibility.Visible;
                    }
                    //加药障碍
                    if (PLC_Tcp_CP.PlateErrorZHA())
                    {
                        grid_ZHA.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        error = true;
                        grid_ZHA.Visibility = Visibility.Visible;
                    }
                }
            }
            else
            {
                if (Config.Mac_C.PLC_Tcp == "Y")
                {
                    //提升机
                    if (PLC_Tcp_CP.LiftStateIsOK())// && PLC.LiftOriginResetState())
                    {
                        grid_Lift.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        error                = true;
                        tbLift.Text          = PLC_Tcp_CP.ReadLiftErrorCode();
                        grid_Lift.Visibility = Visibility.Visible;
                    }
                }
                if (Config.Mac_C.PLC_Com == "Y")
                {
                    //提升机挡板
                    if (!PLC_Com_CP.Baffle_Lift_IsMaxUp())
                    {
                        grid_Max_Baffle.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        error = true;
                        grid_Max_Baffle.Visibility = Visibility.Visible;
                    }
                    if (!PLC_Com_CP.Baffle_Lift_IsMinDown())
                    {
                        grid_Min_Baffle.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        error = true;
                        grid_Min_Baffle.Visibility = Visibility.Visible;
                    }
                }
            }
            if (error)
            {
                grid_Monitor.Visibility = Visibility.Visible;
            }
            else
            {
                grid_Monitor.Visibility = Visibility.Collapsed;
            }

            if (Config.Mac_C.PLC_Tcp == "Y")
            {
                //光幕监控
                if (Config.Soft.Function == "I")
                {
                    gm_new = PLC_Tcp_CP.GMIsStop();
                    if (gm_new != gm_old)
                    {
                        gm_old = gm_new;
                        ShowGM(gm_new);
                    }
                }
                //急停监控
                if (Config.Soft.Function == "I")
                {
                    stop_new = PLC_Tcp_CP.MacIsStop(PLC_Tcp_CP.MacType.Add);
                }
                else
                {
                    stop_new = PLC_Tcp_CP.MacIsStop(PLC_Tcp_CP.MacType.Out);
                }
                if (stop_new != stop_old)
                {
                    stop_old = stop_new;
                    ShowStop(stop_new);
                }
            }
        }