Exemple #1
0
        private void btBaffle_Lift_Save_Close_Click(object sender, RoutedEventArgs e)
        {
            int p = PLC_Com_AP.ReadBafflePulse_Lift();

            Config.SaveConfig(Config.Soft.MacCode, "Pulse_Baffle_Close", p.ToString());
            tbClose.Text = p.ToString();
        }
Exemple #2
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_A.PLC_Tcp == "Y")
            {
                tbPulse_Lift_Now.Text = PLC_Tcp_AP.ReadLiftPulse().ToString();
            }
            if (Config.Mac_A.PLC_Com == "Y")
            {
                tbPulse_Baffle_Lift_Now.Text = PLC_Com_AP.ReadBafflePulse_Lift().ToString();
            }

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

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

            if (Config.Mac_A.ShowTest == "Y")
            {
                gbTest.Visibility = Visibility.Visible;
            }
            else
            {
                gbTest.Visibility = Visibility.Hidden;
            }
        }
Exemple #3
0
        private void btZero_Baffle_Lift_Click(object sender, RoutedEventArgs e)
        {
            Cursor = Cursors.Wait;
            if (PLC_Com_AP.BaffleOriginReset_Lift())
            {
                DateTime timeBegin = DateTime.Now;
                Thread.Sleep(1000);

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

                if (PLC_Com_AP.BaffleOriginResetIsOK())
                {
                    csMsg.ShowInfo("原点返回完成", false);
                    tbPulse_Baffle_Lift_Now.Text = PLC_Com_AP.ReadBafflePulse_Lift().ToString();
                }
                else
                {
                    csMsg.ShowWarning("原点返回失败", false);
                }
            }
            else
            {
                csMsg.ShowWarning("指令发送失败", false);
            }
            Cursor = null;
        }
Exemple #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 = sp_PD.Visibility = sp_Error_PD.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_AP.ThrowMsg   += new PLC_Tcp_AP.ShowMsg(MsgChanged);
            PLC_Com_AP.ThrowMsg   += new PLC_Com_AP.ShowMsg(MsgChanged);
            DPJ_AP.ThrowMsg       += new DPJ_AP.ShowMsg(MsgChanged);
            Scanner.ThrowMsg      += new Scanner.ShowMsg(MsgChanged);
            Laser.ThrowMsg        += new Laser.ShowMsg(MsgChanged);
            CSHelper.SQL.ThrowMsg += new CSHelper.SQL.ShowMsg(MsgChanged);
            OutDrug_AP.ThrowMsg   += new OutDrug_AP.ShowMsg(MsgChanged);

            UCDebug_Add.ShowKey  += new UCDebug_Add.SetKey(KeyShow);
            UCAdd.ShowKey        += new UCAdd.SetKey(KeyShow);
            UCOut_Manual.ShowKey += new UCOut_Manual.SetKey(KeyShow);
            UCDebug_Out.ShowKey  += new UCDebug_Out.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_AP.ExtramanOriginReset();
                    Thread.Sleep(1000);
                    PLC_Tcp_AP.PlateOriginReset();
                }
                else
                {
                    PLC_Tcp_AP.LiftOriginReset();
                    Thread.Sleep(1000);
                    PLC_Com_AP.BaffleOriginReset_Lift();
                }
            }
        }
Exemple #5
0
        private void Baffle_Lift_AutoRun(int pulse)
        {
            Cursor = Cursors.Wait;
            //PLC_Tcp.ChangeOut(1);
            PLC_Com_AP.Baffle_Change(1);

            int pulse_Now = PLC_Com_AP.ReadBafflePulse_Lift();

            if (pulse > pulse_Now)
            {
                PLC_Com_AP.BaffleAutoMoveByPulse_Up_Lift(pulse);
                DateTime timeBegin = DateTime.Now;
                Thread.Sleep(500);
                while (!PLC_Com_AP.BaffleAutoMoveIsOK_Up())
                {
                    if (DateTime.Now > timeBegin.AddSeconds(Config.Mac_A.WaitTime_Auto_Baffle))
                    {
                        break;
                    }
                    Thread.Sleep(500);
                }
                if (DateTime.Now <= timeBegin.AddSeconds(Config.Mac_A.WaitTime_Auto_Baffle))
                {
                    tbPulse_Baffle_Lift_Now.Text = pulse.ToString();
                }
                else
                {
                    csMsg.ShowWarning("挡板未运行到指定位置", false);
                }
            }
            else
            {
                PLC_Com_AP.BaffleAutoMoveByPulse_Down_Lift(pulse);
                DateTime timeBegin = DateTime.Now;
                Thread.Sleep(500);
                while (!PLC_Com_AP.BaffleAutoMoveIsOK_Down())
                {
                    if (DateTime.Now > timeBegin.AddSeconds(Config.Mac_A.WaitTime_Auto_Baffle))
                    {
                        break;
                    }
                    Thread.Sleep(500);
                }
                if (DateTime.Now <= timeBegin.AddSeconds(Config.Mac_A.WaitTime_Auto_Baffle))
                {
                    tbPulse_Baffle_Lift_Now.Text = pulse.ToString();
                }
                else
                {
                    csMsg.ShowWarning("挡板未运行到指定位置", false);
                }
            }
            Cursor = null;
        }
Exemple #6
0
        public WinMain_AP()
        {
            InitializeComponent();

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

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

            if (Config.Mac_A.PLC_Tcp == "Y")
            {
                PLC_Tcp_AP.Initial(true);
            }

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

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

            bool error = false;

            if (Config.Soft.Function == "I")
            {
                if (Config.Mac_A.PLC_Tcp == "Y")
                {
                    //X轴
                    if (PLC_Tcp_AP.TrackStateIsOK(PLC_Tcp_AP.TrackErrorType.X1) && PLC_Tcp_AP.TrackStateIsOK(PLC_Tcp_AP.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_AP.ReadTrackErrorCode(PLC_Tcp_AP.TrackErrorType.X1);
                        tbX_Down.Text     = PLC_Tcp_AP.ReadTrackErrorCode(PLC_Tcp_AP.TrackErrorType.X2);
                        grid_X.Visibility = Visibility.Visible;
                    }
                    //Z轴
                    if (PLC_Tcp_AP.TrackStateIsOK(PLC_Tcp_AP.TrackErrorType.Z))// && PLC.ExtramanOriginResetState(PLC.TrackErrorType.Z))
                    {
                        grid_Z.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        error             = true;
                        tbZ.Text          = PLC_Tcp_AP.ReadTrackErrorCode(PLC_Tcp_AP.TrackErrorType.Z);
                        grid_Z.Visibility = Visibility.Visible;
                    }
                    //左臂
                    if (PLC_Tcp_AP.PlateStateIsOK(PLC_Tcp_AP.PlateType.Left))// && PLC.PlateOriginResetState(PLC.PlateType.Left))
                    {
                        grid_Left.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        error                = true;
                        tbLeft.Text          = PLC_Tcp_AP.ReadPlateErrorCode(PLC_Tcp_AP.PlateType.Left);
                        grid_Left.Visibility = Visibility.Visible;
                    }
                    //右臂
                    if (PLC_Tcp_AP.PlateStateIsOK(PLC_Tcp_AP.PlateType.Right))// && PLC.PlateOriginResetState(PLC.PlateType.Right))
                    {
                        grid_Right.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        error                 = true;
                        tbRight.Text          = PLC_Tcp_AP.ReadPlateErrorCode(PLC_Tcp_AP.PlateType.Right);
                        grid_Right.Visibility = Visibility.Visible;
                    }
                    //加药障碍
                    if (PLC_Tcp_AP.PlateErrorZHA())
                    {
                        grid_ZHA.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        error = true;
                        grid_ZHA.Visibility = Visibility.Visible;
                    }
                }
            }
            else
            {
                if (Config.Mac_A.PLC_Tcp == "Y")
                {
                    //提升机
                    if (PLC_Tcp_AP.LiftStateIsOK())// && PLC.LiftOriginResetState())
                    {
                        grid_Lift.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        error                = true;
                        tbLift.Text          = PLC_Tcp_AP.ReadLiftErrorCode();
                        grid_Lift.Visibility = Visibility.Visible;
                    }
                }
                if (Config.Mac_A.PLC_Com == "Y")
                {
                    //提升机挡板
                    if (!PLC_Com_AP.Baffle_Lift_IsMaxUp())
                    {
                        grid_Max_Baffle.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        error = true;
                        grid_Max_Baffle.Visibility = Visibility.Visible;
                    }
                    if (!PLC_Com_AP.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_A.PLC_Tcp == "Y")
            {
                //光幕监控
                if (Config.Soft.Function == "I")
                {
                    gm_new = PLC_Tcp_AP.GMIsStop();
                    if (gm_new != gm_old)
                    {
                        gm_old = gm_new;
                        ShowGM(gm_new);
                    }
                }
                //急停监控
                if (Config.Soft.Function == "I")
                {
                    stop_new = PLC_Tcp_AP.MacIsStop(PLC_Tcp_AP.MacType.Add);
                }
                else
                {
                    stop_new = PLC_Tcp_AP.MacIsStop(PLC_Tcp_AP.MacType.Out);
                }
                if (stop_new != stop_old)
                {
                    stop_old = stop_new;
                    ShowStop(stop_new);
                }
            }
        }
Exemple #8
0
 private void btBaffle_Lift_Stop_PreviewMouseUp(object sender, MouseButtonEventArgs e)
 {
     PLC_Com_AP.BaffleMove_Lift(PLC_Com_AP.BaffleMoveType_Lift.Stop);
     tbPulse_Baffle_Lift_Now.Text = PLC_Com_AP.ReadBafflePulse_Lift().ToString();
 }
Exemple #9
0
 private void btBaffle_Lift_Down_PreviewMouseDown(object sender, MouseButtonEventArgs e)
 {
     PLC_Com_AP.Baffle_Change(0);
     PLC_Com_AP.BaffleMove_Lift(PLC_Com_AP.BaffleMoveType_Lift.Down);
 }