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(); }
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; } }
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; }
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; }
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(); }