You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
937 lines
38 KiB
C#
937 lines
38 KiB
C#
using Rs.Motion.GugaoEcat;
|
|
using Rs.Motion;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using Rs.Controls;
|
|
using Rs.MotionPlat.Flow;
|
|
using Rs.Framework;
|
|
using Rs.Camera;
|
|
using System.Threading;
|
|
using Rs.MotionPlat.Commom;
|
|
using static System.Runtime.CompilerServices.RuntimeHelpers;
|
|
using Rs.Motion.GugaoPulse;
|
|
using Rs.MotionPlat.SysConfig;
|
|
using System.Runtime.InteropServices;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using Rs.MotionPlat.Entitys;
|
|
using static Rs.MotionPlat.Commom.SchedulingMessageBox;
|
|
using ICSharpCode.SharpZipLib.Zip;
|
|
|
|
namespace Rs.MotionPlat
|
|
{
|
|
public partial class Home : BaseFormHeader
|
|
{
|
|
ButtonEx selectedButton;
|
|
public Home()
|
|
{
|
|
this.StartPosition = FormStartPosition.Manual;
|
|
InitializeComponent();
|
|
this.FormBorderStyle = FormBorderStyle.None;
|
|
this.MaximizedBounds = Screen.PrimaryScreen.WorkingArea;
|
|
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
|
}
|
|
|
|
void CloseSubWindow()
|
|
{
|
|
foreach(Control f in panel_main.Controls)
|
|
{
|
|
if(f is Form && ((Form)f).Name!= "FormMain")
|
|
{
|
|
((Form)f).Close();
|
|
}
|
|
}
|
|
panel_main.Controls.Clear();
|
|
}
|
|
protected void Menu_Clicked(object sender, EventArgs e)
|
|
{
|
|
ButtonEx button = (ButtonEx)sender;
|
|
|
|
if (button == btnSystem)
|
|
{
|
|
selectedButton = btnSystem;
|
|
ClearSelectBtn();
|
|
button.Selected = true;
|
|
CloseSubWindow();
|
|
BaseForm from = new SubMenuForm("SysConfig");
|
|
from.TopLevel = false;
|
|
from.Dock = DockStyle.Fill;
|
|
panel_main.Controls.Add(from);
|
|
from.Visible = true;
|
|
}
|
|
|
|
if (button == btnData)
|
|
{
|
|
if (Properties.Settings.Default.DefaultLanguage== "zh-CN")
|
|
{
|
|
LanguageHelper.SetDefaultLanguage("en-US");
|
|
}
|
|
else
|
|
{
|
|
LanguageHelper.SetDefaultLanguage("zh-CN");
|
|
}
|
|
FormCollection forms = Application.OpenForms;
|
|
foreach (Form fm in forms)
|
|
{
|
|
if (fm is SubMenuForm)
|
|
{
|
|
((SubMenuForm)fm).ReloadMenu();
|
|
}
|
|
else
|
|
{
|
|
if(fm.Name!= "Home")
|
|
{
|
|
LanguageHelper.LoadLanguage(fm, fm.GetType());
|
|
}
|
|
else
|
|
{
|
|
ChangeLang();
|
|
}
|
|
|
|
//if (fm is Home)
|
|
//{
|
|
// fm.FormBorderStyle = FormBorderStyle.None;
|
|
// //fm.MaximizedBounds = Screen.PrimaryScreen.WorkingArea;
|
|
// fm.ResumeLayout();
|
|
// fm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
|
//}
|
|
}
|
|
|
|
}
|
|
//btnMain.PerformClick();
|
|
//if(selectedButton!=null)
|
|
//{
|
|
// selectedButton.PerformClick();
|
|
//}
|
|
forms = Application.OpenForms;
|
|
foreach (Form fm in forms)
|
|
{
|
|
if (fm is SubMenuForm)
|
|
{
|
|
((SubMenuForm)fm).SelectTab();
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
//ClearSelectBtn();
|
|
//button.Selected = true;
|
|
//CloseSubWindow();
|
|
//BaseForm from = new SubMenuForm("Data");
|
|
//from.TopLevel = false;
|
|
//from.Dock = DockStyle.Fill;
|
|
//panel_main.Controls.Add(from);
|
|
//from.Visible = true;
|
|
}
|
|
|
|
else if (button == btnMain)
|
|
{
|
|
selectedButton = btnMain;
|
|
ClearSelectBtn();
|
|
button.Selected = true;
|
|
CloseSubWindow();
|
|
BaseForm form = ActiveForms.Get("FormMain");
|
|
if(form!=null)
|
|
{
|
|
panel_main.Controls.Add(form);
|
|
form.TopLevel = false;
|
|
form.Dock = DockStyle.Fill;
|
|
form.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
form = new FormMain();
|
|
form.Name = "FormMain";
|
|
form.TopLevel = false;
|
|
form.Dock = DockStyle.Fill;
|
|
panel_main.Controls.Add(form);
|
|
form.Visible = true;
|
|
ActiveForms.Add(form);
|
|
}
|
|
|
|
}
|
|
else if (button == btnQuit)
|
|
{
|
|
selectedButton = null;
|
|
button.Selected = false;
|
|
if(WindowsClose())
|
|
{
|
|
System.Environment.Exit(-1);
|
|
}
|
|
}
|
|
else if (button == btnRecipe)
|
|
{
|
|
selectedButton = btnRecipe;
|
|
ClearSelectBtn();
|
|
button.Selected = true;
|
|
CloseSubWindow();
|
|
BaseForm from = new SubMenuForm("Recipe");
|
|
from.TopLevel = false;
|
|
from.Dock = DockStyle.Fill;
|
|
panel_main.Controls.Add(from);
|
|
from.Visible = true;
|
|
}
|
|
else if (button == btnAbout)
|
|
{
|
|
selectedButton = null;
|
|
btnAbout.Enabled = false;
|
|
BaseFormHeader form;
|
|
form = new DebugMove(ShowBtn);
|
|
//form = DebugMove.Instance;
|
|
form.HeaderBackgroundColor = Color.Gray;
|
|
form.TopMost = true;
|
|
form.ShowMax = false;
|
|
form.ShowMin = false;
|
|
form.ShowInTaskbar = false;
|
|
form.Location = new Point(this.Width - form.Width, this.Height - form.Height);
|
|
form.Show(this);
|
|
}
|
|
else if (button == btnPermission)
|
|
{
|
|
if(btnPermission.ShowText.IndexOf("-")>0)
|
|
{
|
|
DialogResult dr = Msg.ShowQuestion("Are you sure to exit login?");
|
|
if(dr== DialogResult.OK)
|
|
{
|
|
GlobalUser.UserName = "";
|
|
btnPermission.ShowText=btnPermission.ShowText.Substring(0,btnPermission.ShowText.IndexOf("-"));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
selectedButton = null;
|
|
UserForm form;
|
|
form = new UserForm();
|
|
form.OnloginSuccessEvent += (uname) => {
|
|
btnPermission.ShowText += $"-({uname})";
|
|
};
|
|
form.StartPosition = FormStartPosition.CenterScreen;
|
|
form.Opacity = 1;
|
|
form.TopMost = true;
|
|
form.ShowDialog(this);
|
|
}
|
|
|
|
}
|
|
else if (button == btnLanguage)
|
|
{
|
|
selectedButton = null;
|
|
if (GlobalUser.IsVender() || GlobalUser.IsSuper())
|
|
{
|
|
ClearSelectBtn();
|
|
button.Selected = true;
|
|
CloseSubWindow();
|
|
BaseForm from = new SubMenuForm("Calib");
|
|
from.TopLevel = false;
|
|
from.Dock = DockStyle.Fill;
|
|
panel_main.Controls.Add(from);
|
|
from.Visible = true;
|
|
}
|
|
|
|
// btnLanguage.Enabled = false;
|
|
//VarConfig vc = new VarConfig(ShowBtn);
|
|
// vc.StartPosition = FormStartPosition.CenterScreen;
|
|
// vc.Show();
|
|
}
|
|
}
|
|
|
|
private void Form_OnloginSuccessEvent(string obj)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
private void ShowBtn(string btnname)
|
|
{
|
|
if(btnname== "DebugMove")
|
|
{
|
|
btnAbout.Enabled = true;
|
|
}
|
|
else if(btnname== "VarConfig")
|
|
{
|
|
btnLanguage.Enabled = true ;
|
|
}
|
|
}
|
|
|
|
private void ClearSelectBtn()
|
|
{
|
|
btnMain.Selected = false;
|
|
btnData.Selected = false;
|
|
btnRecipe.Selected = false;
|
|
btnSystem.Selected = false;
|
|
btnAbout.Selected = false;
|
|
btnPermission.Selected = false;
|
|
btnLanguage.Selected = false;
|
|
btnQuit.Selected = false;
|
|
}
|
|
|
|
private void Home2_Load(object sender, EventArgs e)
|
|
{
|
|
string language = Properties.Settings.Default.DefaultLanguage;
|
|
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(language);
|
|
LanguageHelper.LoadLanguage(this, typeof(Home));
|
|
if(language=="zh-CN")
|
|
{
|
|
btnMain.ShowText = "主页";
|
|
btnRecipe.ShowText = "配方";
|
|
btnSystem.ShowText = "系统配置";
|
|
btnAbout.ShowText = "调试";
|
|
btnData.ShowText = "English";
|
|
btnLanguage.ShowText = "标定";
|
|
btnPermission.ShowText = "用户";
|
|
btnQuit.ShowText = "退出";
|
|
}
|
|
else
|
|
{
|
|
btnMain.ShowText = "Home";
|
|
btnRecipe.ShowText = "Recipe";
|
|
btnSystem.ShowText = "Settings";
|
|
btnAbout.ShowText = "Debuger";
|
|
btnLanguage.ShowText = "Vision calibration";
|
|
btnPermission.ShowText = "User";
|
|
btnQuit.ShowText = "Quit";
|
|
btnData.ShowText = "中文";
|
|
}
|
|
timer1.Enabled = false;
|
|
Ops.Init();
|
|
//SetFormStyle();
|
|
panel_main.Controls.Clear();
|
|
BaseForm form = ActiveForms.Get("FormMain");
|
|
if (form != null)
|
|
{
|
|
panel_main.Controls.Add(form);
|
|
form.TopLevel = false;
|
|
form.Dock = DockStyle.Fill;
|
|
form.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
form = new FormMain();
|
|
form.Name = "FormMain";
|
|
form.TopLevel = false;
|
|
form.Dock = DockStyle.Fill;
|
|
panel_main.Controls.Add(form);
|
|
form.Visible = true;
|
|
ActiveForms.Add(form);
|
|
btnMain.Selected = true;
|
|
}
|
|
timer1.Enabled = true;
|
|
lblVersion.Text ="Version:"+System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
|
|
|
new HotKeyManager(Keys.P, 1, (o,arg) => {
|
|
LookCamera lookCamera = new LookCamera();
|
|
lookCamera.HeaderBackgroundColor = Color.Gray;
|
|
lookCamera.TopMost = true;
|
|
lookCamera.ShowMax = false;
|
|
lookCamera.ShowMin = false;
|
|
lookCamera.ShowInTaskbar = false;
|
|
lookCamera.Show();
|
|
});
|
|
new HotKeyManager(Keys.T, 1, (o, arg) => {
|
|
MonitorTray monitorTray = new MonitorTray();
|
|
//monitorTray.TopMost = true;
|
|
//monitorTray.ShowMax = false;
|
|
//monitorTray.ShowMin = false;
|
|
//monitorTray.ShowInTaskbar = false;
|
|
monitorTray.Show();
|
|
});
|
|
|
|
new HotKeyManager(Keys.F, 1, (o, arg) => {
|
|
MonitorFlow mf = new MonitorFlow();
|
|
mf.StartPosition= FormStartPosition.CenterParent;
|
|
mf.HeaderBackgroundColor = Color.Gray;
|
|
mf.Show();
|
|
});
|
|
|
|
|
|
timer2.Interval = 500;
|
|
timer2.Enabled = true;
|
|
timer3.Interval = 1000 * 60 * 60 * 2;
|
|
timer3.Enabled = true;
|
|
Task.Run(() =>
|
|
{
|
|
timer3_Tick(null, null);
|
|
});
|
|
if(File.Exists("breakdown.csv"))
|
|
{
|
|
File.Delete("breakdown.csv");
|
|
}
|
|
}
|
|
|
|
void ChangeLang()
|
|
{
|
|
string language = Properties.Settings.Default.DefaultLanguage;
|
|
if (language == "zh-CN")
|
|
{
|
|
btnMain.ShowText = "主页";
|
|
btnMain.Invalidate();
|
|
btnRecipe.ShowText = "配方";
|
|
btnRecipe.Invalidate();
|
|
btnSystem.ShowText = "系统配置";
|
|
btnSystem.Invalidate();
|
|
btnAbout.ShowText = "调试";
|
|
btnAbout.Invalidate();
|
|
btnData.ShowText = "English";
|
|
btnData.Invalidate();
|
|
btnLanguage.ShowText = "标定";
|
|
btnLanguage.Invalidate();
|
|
btnPermission.ShowText = "用户";
|
|
btnPermission.Invalidate();
|
|
btnQuit.ShowText = "退出";
|
|
btnQuit.Invalidate();
|
|
}
|
|
else
|
|
{
|
|
btnMain.ShowText = "Home";
|
|
btnMain.Invalidate();
|
|
btnRecipe.ShowText = "Recipe";
|
|
btnRecipe.Invalidate();
|
|
btnSystem.ShowText = "Settings";
|
|
btnSystem.Invalidate();
|
|
btnAbout.ShowText = "Debugger";
|
|
btnAbout.Invalidate();
|
|
btnLanguage.ShowText = "Vision calibration";
|
|
btnLanguage.Invalidate();
|
|
btnPermission.ShowText = "User";
|
|
btnPermission.Invalidate();
|
|
btnQuit.ShowText = "Quit";
|
|
btnQuit.Invalidate();
|
|
btnData.ShowText = "中文";
|
|
btnData.Invalidate();
|
|
}
|
|
}
|
|
private void SetFormStyle()
|
|
{
|
|
this.StartPosition = FormStartPosition.Manual;
|
|
this.FormBorderStyle = FormBorderStyle.None;//设置无边框
|
|
this.WindowState = FormWindowState.Maximized;//设置窗体最大化显示
|
|
this.MaximizedBounds = Screen.PrimaryScreen.WorkingArea;//设置窗体在无边框和最大化时不遮挡任务栏
|
|
}
|
|
|
|
private void timer1_Tick(object sender, EventArgs e)
|
|
{
|
|
GC.Collect();
|
|
if(MachineManage.Instance.MachineStatus.ToString()!=lblMachineState.Text)
|
|
{
|
|
if(MachineManage.Instance.MachineStatus== EMachineStatus.NotInit)
|
|
{
|
|
this.panel1.BackColor = Color.Red;
|
|
}
|
|
else if(MachineManage.Instance.MachineStatus== EMachineStatus.Homing || MachineManage.Instance.MachineStatus == EMachineStatus.Stop)
|
|
{
|
|
this.panel1.BackColor = Color.FromArgb(192, 192, 0);
|
|
}
|
|
else
|
|
{
|
|
this.panel1.BackColor = Color.FromArgb(46, 46, 46);
|
|
}
|
|
lblMachineState.Text=MachineManage.Instance.MachineStatus.ToString();
|
|
}
|
|
|
|
if(MachineManage.Instance.GetLoadUnloadStatus().ToString() != lblRunState.Text.Replace("RunState:",""))
|
|
{
|
|
lblRunState.Text = "RunState:" + MachineManage.Instance.GetLoadUnloadStatus().ToString();
|
|
}
|
|
if(DischargeFlow.Instance.GetCurStep().ToString()!=lblDischargeFlow.Text.Replace("Discharge:",""))
|
|
{
|
|
lblDischargeFlow.Text = "Discharge:"+DischargeFlow.Instance.GetCurStep().ToString();
|
|
}
|
|
|
|
if (TurnoverFlow.Instance.GetStep().ToString() != lblTurnoverFlow.Text.Replace("Turnover:", ""))
|
|
{
|
|
lblTurnoverFlow.Text = "Turnover:" + TurnoverFlow.Instance.GetStep().ToString();
|
|
}
|
|
if (MonitorSystemButton.Instance.GetStep() != lblMonitorFlow.Text.Replace("Monitor:", ""))
|
|
{
|
|
lblMonitorFlow.Text = "Monitor:" + MonitorSystemButton.Instance.GetStep();
|
|
}
|
|
|
|
if (MachineManage.Instance.InitializeState.ToString()!= lblInitializeState.Text.Replace("InitializeState:", ""))
|
|
{
|
|
lblInitializeState.Text = $"InitializeState:{MachineManage.Instance.InitializeState.ToString()}";
|
|
}
|
|
Process proc = Process.GetCurrentProcess();
|
|
if (proc != null)
|
|
{
|
|
long userdMem = proc.WorkingSet64;
|
|
lblMemory.Text = $"Mem:{(userdMem/1024)/1024} MB";
|
|
}
|
|
}
|
|
|
|
public override bool WindowsClose()
|
|
{
|
|
DialogResult dr = MessageBox.Show("Are you sure to exit?", "tip", MessageBoxButtons.OKCancel);
|
|
if (dr == DialogResult.OK)
|
|
{
|
|
LogHelper.Debug("手动退出软件");
|
|
Ops.Quit();
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
#region 内存回收
|
|
[DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize")]
|
|
public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
|
|
/// <summary>
|
|
/// 释放内存
|
|
/// </summary>
|
|
public static void ClearMemory()
|
|
{
|
|
GC.Collect();
|
|
GC.WaitForPendingFinalizers();
|
|
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
|
{
|
|
SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 离子风扇报警
|
|
/// </summary>
|
|
bool fanAlarm = false;
|
|
/// <summary>
|
|
/// 正压报警
|
|
/// </summary>
|
|
bool pPressvacAlarm = false;
|
|
/// <summary>
|
|
/// 负压报警
|
|
/// </summary>
|
|
bool nPressvacAlarm = false;
|
|
/// <summary>
|
|
/// 安全们报警
|
|
/// </summary>
|
|
bool doorAlarm = false;
|
|
bool frontDoorAlarm = false;
|
|
bool backDoorAlarm = false;
|
|
bool front_leftDoorAlarm = false;
|
|
bool back_leftDoorAlarm = false;
|
|
bool front_rightDoorAlarm = false;
|
|
bool back_rightDoorAlarm = false;
|
|
|
|
/// <summary>
|
|
/// 固定气缸报警
|
|
/// </summary>
|
|
bool fixedCylinderAlarm = false;
|
|
private void timer2_Tick(object sender, EventArgs e)
|
|
{
|
|
//ClearMemory();
|
|
if(!GlobalVar.DisableIonFanCheck)
|
|
{
|
|
if (MachineManage.Instance.MachineStatus != EMachineStatus.NotInit)
|
|
{
|
|
List<string> fanAlarms = new List<string>();
|
|
if (!fanAlarm)
|
|
{
|
|
if (Ops.IsOn("1号离子风报警"))
|
|
{
|
|
fanAlarms.Add("fan no.1 alarm\r\n");
|
|
}
|
|
if (Ops.IsOn("2号离子风报警"))
|
|
{
|
|
fanAlarms.Add("fan no.2 alarm\r\n");
|
|
}
|
|
if (Ops.IsOn("3号离子风报警"))
|
|
{
|
|
fanAlarms.Add("fan no.3 alarm\r\n");
|
|
}
|
|
if (Ops.IsOn("4号离子风报警"))
|
|
{
|
|
fanAlarms.Add("fan no.4 alarm\r\n");
|
|
}
|
|
if (Ops.IsOn("5号离子风报警"))
|
|
{
|
|
fanAlarms.Add("fan no.5 alarm\r\n");
|
|
}
|
|
if (Ops.IsOn("6号离子风报警"))
|
|
{
|
|
fanAlarms.Add("fan no.6 alarm");
|
|
}
|
|
if(fanAlarms.Count > 0)
|
|
{
|
|
fanAlarm = true;
|
|
MessageQueue.Instance.Warn(string.Join(" ", fanAlarms));
|
|
//Msg.ShowError(string.Join(" ", fanAlarms));
|
|
string alarminfo = string.Join(" ", fanAlarms);
|
|
PromptMessageBox.Show(AlarmConstID.离子风扇报警, alarminfo, SchedulingMessageBox.ETipButton.None);
|
|
fanAlarm = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (Ops.IsOn("1号离子风报警")==false
|
|
&& Ops.IsOn("2号离子风报警") == false
|
|
&& Ops.IsOn("3号离子风报警") == false
|
|
&& Ops.IsOn("4号离子风报警") == false
|
|
&& Ops.IsOn("5号离子风报警") == false
|
|
&& Ops.IsOn("6号离子风报警") == false)
|
|
{
|
|
fanAlarm = false;
|
|
PromptMessageBox.CloseWindow(AlarmConstID.离子风扇报警, ETipButton.None);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!GlobalVar.DisablePPressCheck)
|
|
{
|
|
if (MachineManage.Instance.MachineStatus != EMachineStatus.NotInit)
|
|
{
|
|
if (!pPressvacAlarm)
|
|
{
|
|
if (Ops.IsOn("正压输入"))
|
|
{
|
|
pPressvacAlarm = true;
|
|
Ops.Stop();
|
|
string alarminfo = string.Format(AlarmCollection.GetAlarm(AlarmConstID.正压输入偏低));
|
|
PromptMessageBox.Show(AlarmConstID.正压输入偏低, alarminfo, SchedulingMessageBox.ETipButton.None);
|
|
MessageQueue.Instance.Warn("正压输入偏低");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (Ops.IsOff("正压输入"))
|
|
{
|
|
pPressvacAlarm = false;
|
|
MessageQueue.Instance.Warn("正压输入偏低解除");
|
|
PromptMessageBox.CloseWindow(AlarmConstID.正压输入偏低, ETipButton.None);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (!GlobalVar.DisableNPressCheck)
|
|
{
|
|
if (MachineManage.Instance.MachineStatus != EMachineStatus.NotInit)
|
|
{
|
|
if (!nPressvacAlarm)
|
|
{
|
|
if (Ops.IsOn("负压输入"))
|
|
{
|
|
nPressvacAlarm = true;
|
|
Ops.Stop();
|
|
string alarminfo = string.Format(AlarmCollection.GetAlarm(AlarmConstID.负压输入偏低));
|
|
PromptMessageBox.Show(AlarmConstID.负压输入偏低, alarminfo, SchedulingMessageBox.ETipButton.None);
|
|
MessageQueue.Instance.Warn("负压输入偏低");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (Ops.IsOff("负压输入"))
|
|
{
|
|
nPressvacAlarm = false;
|
|
MessageQueue.Instance.Warn("负压输入偏低解除");
|
|
PromptMessageBox.CloseWindow(AlarmConstID.负压输入偏低, ETipButton.None);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!GlobalVar.DisableDoor)
|
|
{
|
|
if(MachineManage.Instance.MachineStatus != EMachineStatus.NotInit && MachineManage.Instance.MachineStatus!= EMachineStatus.Stop)
|
|
{
|
|
if (!frontDoorAlarm)
|
|
{
|
|
if (IoManager.Instance.ReadIn("前安全门禁") == 0)
|
|
{
|
|
frontDoorAlarm = true;
|
|
Ops.Stop();
|
|
string alarminfo = string.Format(AlarmCollection.GetAlarm(AlarmConstID.前安全门禁));
|
|
PromptMessageBox.Show(AlarmConstID.前安全门禁, alarminfo, SchedulingMessageBox.ETipButton.None);
|
|
MessageQueue.Instance.Warn($"前安全门禁已触发,{alarminfo}");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (IoManager.Instance.ReadIn("前安全门禁") == 1)
|
|
{
|
|
frontDoorAlarm = false;
|
|
MessageQueue.Instance.Warn("前安全门禁已解除");
|
|
PromptMessageBox.CloseWindow(AlarmConstID.前安全门禁, ETipButton.None);
|
|
}
|
|
}
|
|
if (!backDoorAlarm)
|
|
{
|
|
if (IoManager.Instance.ReadIn("后安全门禁") == 0)
|
|
{
|
|
backDoorAlarm = true;
|
|
Ops.Stop();
|
|
string alarminfo = string.Format(AlarmCollection.GetAlarm(AlarmConstID.后安全门禁));
|
|
PromptMessageBox.Show(AlarmConstID.后安全门禁, alarminfo, SchedulingMessageBox.ETipButton.None);
|
|
MessageQueue.Instance.Warn($"后安全门禁已触发,{alarminfo}");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (IoManager.Instance.ReadIn("后安全门禁") == 1)
|
|
{
|
|
backDoorAlarm = false;
|
|
MessageQueue.Instance.Warn("后安全门禁已解除");
|
|
PromptMessageBox.CloseWindow(AlarmConstID.后安全门禁, ETipButton.None);
|
|
}
|
|
}
|
|
if (!front_leftDoorAlarm)
|
|
{
|
|
if (IoManager.Instance.ReadIn("左前安全门禁") == 0)
|
|
{
|
|
front_leftDoorAlarm = true;
|
|
Ops.Stop();
|
|
string alarminfo = string.Format(AlarmCollection.GetAlarm(AlarmConstID.左前安全门禁));
|
|
PromptMessageBox.Show(AlarmConstID.左前安全门禁, alarminfo, SchedulingMessageBox.ETipButton.None);
|
|
MessageQueue.Instance.Warn($"左前安全门禁已触发,{alarminfo}");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (IoManager.Instance.ReadIn("左前安全门禁") == 1)
|
|
{
|
|
front_leftDoorAlarm = false;
|
|
MessageQueue.Instance.Warn("左前安全门禁已解除");
|
|
PromptMessageBox.CloseWindow(AlarmConstID.左前安全门禁, ETipButton.None);
|
|
}
|
|
}
|
|
if (!front_rightDoorAlarm)
|
|
{
|
|
if (IoManager.Instance.ReadIn("左后安全门禁") == 0)
|
|
{
|
|
front_rightDoorAlarm = true;
|
|
Ops.Stop();
|
|
string alarminfo = string.Format(AlarmCollection.GetAlarm(AlarmConstID.左后安全门禁));
|
|
PromptMessageBox.Show(AlarmConstID.左后安全门禁, alarminfo, SchedulingMessageBox.ETipButton.None);
|
|
MessageQueue.Instance.Warn($"左后安全门禁已触发,{alarminfo}");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (IoManager.Instance.ReadIn("左后安全门禁") == 1)
|
|
{
|
|
front_rightDoorAlarm = false;
|
|
MessageQueue.Instance.Warn("左后安全门禁已解除");
|
|
PromptMessageBox.CloseWindow(AlarmConstID.左后安全门禁, ETipButton.None);
|
|
}
|
|
}
|
|
if (!back_leftDoorAlarm)
|
|
{
|
|
if (IoManager.Instance.ReadIn("右前安全门禁") == 0)
|
|
{
|
|
back_leftDoorAlarm = true;
|
|
Ops.Stop();
|
|
string alarminfo = string.Format(AlarmCollection.GetAlarm(AlarmConstID.右前安全门禁));
|
|
PromptMessageBox.Show(AlarmConstID.右前安全门禁, alarminfo, SchedulingMessageBox.ETipButton.None);
|
|
MessageQueue.Instance.Warn($"左后安全门禁已触发,{alarminfo}");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (IoManager.Instance.ReadIn("右前安全门禁") == 1)
|
|
{
|
|
back_leftDoorAlarm = false;
|
|
MessageQueue.Instance.Warn("右前安全门禁已解除");
|
|
PromptMessageBox.CloseWindow(AlarmConstID.右前安全门禁, ETipButton.None);
|
|
}
|
|
}
|
|
if (!back_rightDoorAlarm)
|
|
{
|
|
if (IoManager.Instance.ReadIn("右后安全门禁") == 0)
|
|
{
|
|
back_rightDoorAlarm = true;
|
|
Ops.Stop();
|
|
string alarminfo = string.Format(AlarmCollection.GetAlarm(AlarmConstID.右后安全门禁));
|
|
PromptMessageBox.Show(AlarmConstID.右后安全门禁, alarminfo, SchedulingMessageBox.ETipButton.None);
|
|
MessageQueue.Instance.Warn($"右后安全门禁已触发,{alarminfo}");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (IoManager.Instance.ReadIn("右后安全门禁") == 1)
|
|
{
|
|
back_rightDoorAlarm = false;
|
|
MessageQueue.Instance.Warn("右后安全门禁已解除");
|
|
PromptMessageBox.CloseWindow(AlarmConstID.右后安全门禁, ETipButton.None);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
if (!GlobalVar.DisableCheckSocketLock)
|
|
{
|
|
if (MachineManage.Instance.MachineStatus != EMachineStatus.NotInit)
|
|
{
|
|
List<string> fixedCylinderAlarms = new List<string>();
|
|
if (!fixedCylinderAlarm)
|
|
{
|
|
if (IoManager.Instance.ReadIn("左前固定气缸动位") == 0)
|
|
{
|
|
fixedCylinderAlarms.Add("front-Left socket unlock\r\n");
|
|
}
|
|
if (IoManager.Instance.ReadIn("左后固定气缸动位") == 0)
|
|
{
|
|
fixedCylinderAlarms.Add("back-Left socket unlock\r\n");
|
|
}
|
|
if (IoManager.Instance.ReadIn("右前固定气缸动位") == 0)
|
|
{
|
|
fixedCylinderAlarms.Add("front-right socket unlock\r\n");
|
|
}
|
|
if (IoManager.Instance.ReadIn("右后固定气缸动位") == 0)
|
|
{
|
|
fixedCylinderAlarms.Add("back-right socket unlock");
|
|
}
|
|
if(fixedCylinderAlarms.Count > 0)
|
|
{
|
|
fixedCylinderAlarm = true;
|
|
Ops.Stop();
|
|
PromptMessageBox.Show(AlarmConstID.治具未锁紧, string.Join(" ",fixedCylinderAlarms), SchedulingMessageBox.ETipButton.None);
|
|
}
|
|
|
|
//if (IoManager.Instance.ReadIn("左前固定气缸动位") == 0 || IoManager.Instance.ReadIn("左后固定气缸动位") == 0 || IoManager.Instance.ReadIn("右前固定气缸动位") == 0 || IoManager.Instance.ReadIn("右后固定气缸动位") == 0)
|
|
//{
|
|
|
|
// string alarmInfo = string.Empty;
|
|
// if (IoManager.Instance.ReadIn("左前固定气缸动位") == 0)
|
|
// {
|
|
// alarmInfo = "LeftFrontSocketUnlock\r\n";
|
|
// }
|
|
// if (IoManager.Instance.ReadIn("左后固定气缸动位") == 0)
|
|
// {
|
|
// alarmInfo += "LeftAfterSocketUnlock\r\n";
|
|
// }
|
|
// if (IoManager.Instance.ReadIn("右前固定气缸动位") == 0)
|
|
// {
|
|
// alarmInfo += "RightFrontSocketUnlock\r\n";
|
|
// }
|
|
// if (IoManager.Instance.ReadIn("右后固定气缸动位") == 0)
|
|
// {
|
|
// alarmInfo += "RightAfterSocketUnlock\r\n";
|
|
// }
|
|
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
if (IoManager.Instance.ReadIn("左前固定气缸动位") == 1
|
|
&& IoManager.Instance.ReadIn("左后固定气缸动位") == 1
|
|
&& IoManager.Instance.ReadIn("右前固定气缸动位") == 1
|
|
&& IoManager.Instance.ReadIn("右后固定气缸动位") == 1)
|
|
{
|
|
fixedCylinderAlarm = false;
|
|
PromptMessageBox.CloseWindow(AlarmConstID.治具未锁紧, ETipButton.None);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override CreateParams CreateParams
|
|
{
|
|
get
|
|
{
|
|
const int WS_MINIMIZEBOX = 0x00020000; // Winuser.h中定义
|
|
CreateParams cp = base.CreateParams;
|
|
cp.Style = cp.Style | WS_MINIMIZEBOX; // 允许最小化操作
|
|
return cp;
|
|
}
|
|
}
|
|
|
|
private void timer3_Tick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string dirpath = GlobalVar.ImageSavePath;// "D://images";
|
|
if(!string.IsNullOrEmpty(dirpath))
|
|
{
|
|
string[] dirs = Directory.GetDirectories(dirpath);
|
|
if (!Directory.Exists(dirpath))
|
|
{
|
|
Directory.CreateDirectory(dirpath);
|
|
}
|
|
foreach (var dir in dirs)
|
|
{
|
|
DirectoryInfo di = new DirectoryInfo(dir);
|
|
DateTime dtCreate = di.CreationTime;
|
|
if ((DateTime.Now - dtCreate).Days > GlobalVar.ImageSaveDays)
|
|
{
|
|
di.Delete(true);
|
|
}
|
|
}
|
|
dirpath = "D://软件备份";
|
|
if (!Directory.Exists(dirpath))
|
|
{
|
|
Directory.CreateDirectory(dirpath);
|
|
}
|
|
dirs = Directory.GetDirectories(dirpath);
|
|
foreach (var dir in dirs)
|
|
{
|
|
DirectoryInfo di = new DirectoryInfo(dir);
|
|
DateTime dtCreate = di.CreationTime;
|
|
if ((DateTime.Now - dtCreate).Days > GlobalVar.ImageSaveDays)
|
|
{
|
|
di.Delete(true);
|
|
}
|
|
}
|
|
|
|
//配置文件备份
|
|
string workDir = System.Environment.CurrentDirectory;
|
|
string zipFileName = DateTime.Now.ToString("yyyyMMddHH");
|
|
string bakDir = $"d://软件备份//{DateTime.Now.ToString("yyyyMMdd")}//{zipFileName}";
|
|
if (!Directory.Exists(bakDir))
|
|
{
|
|
Directory.CreateDirectory(bakDir);
|
|
CopyDirectory(workDir, bakDir);
|
|
string toDir = Path.Combine(Directory.GetParent(bakDir).FullName, zipFileName + ".zip");
|
|
ZipHelper.ZipDirectory(bakDir, toDir);
|
|
Directory.Delete(bakDir, true);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex.Message + ex.StackTrace);
|
|
}
|
|
}
|
|
|
|
public static void CopyDirectory(string sourceDir, string targetDir)
|
|
{
|
|
DirectoryInfo dir = new DirectoryInfo(sourceDir);
|
|
DirectoryInfo[] dirs = dir.GetDirectories();
|
|
|
|
// If the source directory does not exist, throw an exception.
|
|
if (!dir.Exists)
|
|
{
|
|
throw new DirectoryNotFoundException($"Source directory does not exist or could not be found: {sourceDir}");
|
|
}
|
|
|
|
// If the destination directory does not exist, create it.
|
|
if (!Directory.Exists(targetDir))
|
|
{
|
|
Directory.CreateDirectory(targetDir);
|
|
}
|
|
|
|
// Get the files in the directory and copy them to the new location.
|
|
FileInfo[] files = dir.GetFiles();
|
|
foreach (FileInfo file in files)
|
|
{
|
|
string tempPath = Path.Combine(targetDir, file.Name);
|
|
file.CopyTo(tempPath, false);
|
|
}
|
|
|
|
// If copying subdirectories, copy them and their contents to the new location.
|
|
foreach (DirectoryInfo subdir in dirs)
|
|
{
|
|
string tempPath = Path.Combine(targetDir, subdir.Name);
|
|
CopyDirectory(subdir.FullName, tempPath);
|
|
}
|
|
}
|
|
}
|
|
}
|