1222 lines
48 KiB
C#
1222 lines
48 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Windows.Forms;
|
||
using AGVSystem.Cls;
|
||
using System.Reflection;
|
||
using System.IO;
|
||
using Automation.BDaq;
|
||
using System.Diagnostics;
|
||
//using Microsoft.Win32;
|
||
|
||
namespace AGVSystem
|
||
{
|
||
public partial class mainfrm : Form
|
||
{
|
||
public static mainfrm newmainfrm;
|
||
public static ToolStrip toolStrip;
|
||
public static ToolStripStatusLabel Lab_location;
|
||
public static ToolStripStatusLabel toolStripStatusLabel;
|
||
public static ToolStripStatusLabel toolStrip_info;
|
||
private static ClsDBConn_sql db;
|
||
public static Panel Map1, Map2, Map3;
|
||
public static int[] All_Agv_Reset;//一键复位
|
||
public static int[] All_Agv_Stop;//一键停止
|
||
public static int[] All_Agv_Close;//一键关机
|
||
|
||
public static System.Data.DataSet ds_AGVGo = new System.Data.DataSet(); //AGV放行信息
|
||
public static System.Data.DataSet ds_AgvWarn = new System.Data.DataSet(); //AGV报警信息
|
||
public static System.Data.DataSet ds_WarnList = new System.Data.DataSet(); //AGV报警信息
|
||
public static System.Data.DataSet ds_WarnList_Plc = new System.Data.DataSet(); //AGV报警信息
|
||
public static System.Data.DataSet ds_Agvlist = new System.Data.DataSet();//保存所有AGV信息
|
||
public static System.Data.DataSet ds_CrossInfo = new System.Data.DataSet();//保存所有需要确认的路口信息
|
||
public static System.Data.DataSet ds_CrossInfo1 = new System.Data.DataSet();//保存所有需要确认的路口信息
|
||
public static System.Data.DataSet ds_CrossInfo2 = new System.Data.DataSet();//保存所有需要确认的路口信息
|
||
public static System.Data.DataSet ds_CrossInfo3 = new System.Data.DataSet();//保存所有需要确认的路口信息
|
||
public static System.Data.DataSet ds_ProductLine = new System.Data.DataSet();
|
||
public static System.Data.DataSet ds_linelandmark = new System.Data.DataSet();
|
||
public static System.Data.DataSet ds_AGV_INFO = new System.Data.DataSet();//AGV 信息
|
||
public static System.Data.DataSet ds_Change = new DataSet();//充电地标信息
|
||
public static System.Data.DataSet ds_Card_DO = new DataSet();
|
||
public static System.Data.DataSet ds_Card_DI_Call = new DataSet();
|
||
public static System.Data.DataSet ds_Card_DI_Fx = new DataSet();
|
||
public static System.Data.DataSet ds_Location = new DataSet();
|
||
|
||
public static byte[,] Card_DI1 = new byte[4, 8];
|
||
public static byte[,] Card_DI2 = new byte[4, 8];
|
||
public static byte[,] Card_DI3 = new byte[4, 8];
|
||
|
||
public static byte[,] Card_DO1 = new byte[4, 8];
|
||
public static byte[,] Card_DO2 = new byte[4, 8];
|
||
public static byte[,] Card_DO3 = new byte[4, 8];
|
||
|
||
public static DataSet ds_Reset_Relation = new DataSet();
|
||
public static DataSet ds_Mileage = new DataSet();
|
||
|
||
public static DeviceInformation myDevice_DI0;
|
||
public static DeviceInformation myDevice_DI1;
|
||
public static DeviceInformation myDevice_DI2;
|
||
|
||
public static DeviceInformation myDevice_DO0;
|
||
public static DeviceInformation myDevice_DO1;
|
||
public static DeviceInformation myDevice_DO2;
|
||
|
||
private static string strsql;
|
||
public mainfrm()
|
||
{
|
||
InitializeComponent();
|
||
toolStrip = toolStrip1;
|
||
newmainfrm = this;
|
||
Lab_location = toolStripStatusLabel2;
|
||
mainfrm.toolStripStatusLabel = toolStripStatusLabel7;
|
||
toolStrip_info = toolStripStatusLabel3;
|
||
|
||
try
|
||
{
|
||
for (byte i = 1; i < 40; i++)
|
||
{
|
||
string info = Cls.FileRW.ReadIniValue("Item", "Item" + i.ToString(), Application.StartupPath + @"\item.ini");
|
||
if (info != "")
|
||
{
|
||
ToolStripMenuItem toolSubItem = new ToolStripMenuItem();
|
||
toolSubItem.Name = "Item" + i.ToString();
|
||
toolSubItem.Text = info;
|
||
toolSubItem.Click += new EventHandler(ToolStripMenuItem_Click);
|
||
itemList.DropDownItems.Add(toolSubItem);
|
||
|
||
}
|
||
else
|
||
{
|
||
if (i == 1 || i == 2)
|
||
{
|
||
itemList.Visible = false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
catch
|
||
{
|
||
|
||
}
|
||
if (init2())
|
||
{
|
||
lab_project_info.Text = " 本软件仅适用于" + Cls.Param.Pro_factory + " " + Cls.Param.Pro_remark + " 项目代码:" + Cls.Param.Pro_id;
|
||
this.Text = "AGV调度管理系统 " + Cls.Param.Pro_factory;
|
||
if (File.Exists(Application.StartupPath + "\\background\\" + Cls.Param.Pro_id + ".png"))
|
||
{
|
||
this.BackgroundImage = Image.FromFile(Application.StartupPath + "\\background\\" + Cls.Param.Pro_id + ".png");
|
||
}
|
||
if (Cls.Param.map2_status)
|
||
cmb_map.Items.Add("Map Page 2.");
|
||
if (Cls.Param.map3_status)
|
||
cmb_map.Items.Add("Map Page 3.");
|
||
toolStripButton18_Click(null, null);
|
||
|
||
timer1.Enabled = true;
|
||
}
|
||
else
|
||
{
|
||
mainfrm.newmainfrm = null;
|
||
DatabaseSet db1 = new DatabaseSet();
|
||
db1.ShowDialog();
|
||
}
|
||
}
|
||
|
||
public static bool init2()
|
||
{
|
||
Cls.Param.connectStr = Cls.FileRW.ReadIniValue("conn", "conn", Application.StartupPath + @"\info.ini");
|
||
Cls.Param.Pro_id = Cls.FileRW.ReadIniValue("item_id", "item_id", Application.StartupPath + @"\info.ini");
|
||
Cls.Param.connectStr = Cls.Param.connectStr.Replace("XXXXX", Cls.Param.Pro_id);
|
||
if (Cls.Param.connectStr == "")
|
||
{
|
||
DatabaseSet db = new DatabaseSet();
|
||
db.ShowDialog();
|
||
return false;
|
||
}
|
||
|
||
for (byte i = 0; i < 4; ++i)
|
||
{
|
||
for (byte j = 0; j < 8; ++j)
|
||
{
|
||
Card_DI1[i, j] = 0;
|
||
Card_DI2[i, j] = 0;
|
||
Card_DI3[i, j] = 0;
|
||
Card_DO1[i, j] = 0;
|
||
Card_DO2[i, j] = 0;
|
||
Card_DO3[i, j] = 0;
|
||
}
|
||
}
|
||
|
||
try
|
||
{
|
||
//AGV信息
|
||
strsql = "SELECT AgvInfo.[IPAddress], AgvInfo.[Status],'false' as 联网状态 , AgvInfo.[Internal_ID], " +
|
||
" AgvInfo.[Assembly_Line],assembly_line.[line_Name],AgvInfo.[Type],AgvInfo.[ID] ,Assembly_Line.AREA, " +
|
||
" AgvInfo.[Loc_id] , AgvInfo.[warn_id] , AgvInfo.Mileage , agvinfo.port , agvinfo.WorkType FROM AgvInfo , Assembly_Line " +
|
||
" where assembly_line.[id] = AgvInfo.[Assembly_Line] " +
|
||
" order by AgvInfo.[ID]";
|
||
ClsDBConn_sql conn = new ClsDBConn_sql();
|
||
ds_Agvlist = conn.connDt(strsql).Copy();
|
||
//获取AGV总数量
|
||
Cls.Param.AGV_Qty = Convert.ToByte(mainfrm.ds_Agvlist.Tables[0].Rows.Count);
|
||
|
||
//初始化小车信息类
|
||
Func.AgvInfo = new Cls.AgvInfo[Cls.Param.AGV_Qty];
|
||
All_Agv_Close = new int[Cls.Param.AGV_Qty];
|
||
All_Agv_Reset = new int[Cls.Param.AGV_Qty];
|
||
All_Agv_Stop = new int[Cls.Param.AGV_Qty];
|
||
for (int row = 0; row < mainfrm.ds_Agvlist.Tables[0].Rows.Count; row++)
|
||
{
|
||
Func.AgvInfo[row] = new Cls.AgvInfo(); ;
|
||
Func.AgvInfo[row].Agv_ID = Convert.ToInt16(mainfrm.ds_Agvlist.Tables[0].Rows[row]["ID"].ToString());
|
||
Func.AgvInfo[row].AssemblyLine = Convert.ToInt16(mainfrm.ds_Agvlist.Tables[0].Rows[row]["Assembly_Line"].ToString());
|
||
Func.AgvInfo[row].AssemblyName = mainfrm.ds_Agvlist.Tables[0].Rows[row]["line_Name"].ToString();
|
||
Func.AgvInfo[row].Enable = Convert.ToBoolean(mainfrm.ds_Agvlist.Tables[0].Rows[row]["Status"].ToString());
|
||
Func.AgvInfo[row].Internal_ID = Convert.ToInt16(mainfrm.ds_Agvlist.Tables[0].Rows[row]["Internal_ID"].ToString());
|
||
Func.AgvInfo[row].IP = mainfrm.ds_Agvlist.Tables[0].Rows[row]["IPAddress"].ToString();
|
||
Func.AgvInfo[row].Area = Convert.ToInt16(mainfrm.ds_Agvlist.Tables[0].Rows[row]["area"].ToString());
|
||
Func.AgvInfo[row].Cross_Location_Go = Convert.ToInt16(mainfrm.ds_Agvlist.Tables[0].Rows[row]["LOC_ID"].ToString());
|
||
Func.AgvInfo[row].Cross_Path_Id = Convert.ToInt16(mainfrm.ds_Agvlist.Tables[0].Rows[row]["Warn_ID"].ToString());
|
||
Func.AgvInfo[row].Mileage = Convert.ToDouble(mainfrm.ds_Agvlist.Tables[0].Rows[row]["Mileage"].ToString());
|
||
Func.AgvInfo[row].Port = Convert.ToInt16(mainfrm.ds_Agvlist.Tables[0].Rows[row]["port"].ToString());
|
||
Func.AgvInfo[row].Type = Convert.ToInt16(mainfrm.ds_Agvlist.Tables[0].Rows[row]["Type"].ToString());
|
||
Func.AgvInfo[row].WorkType = Convert.ToInt16(mainfrm.ds_Agvlist.Tables[0].Rows[row]["WorkType"].ToString());
|
||
Func.AgvInfo[row].Location_Display = 0;
|
||
Func.AgvInfo[row].Warn_info = "未上线";
|
||
Func.AgvInfo[row].Task_Descrption = "无任务";
|
||
Func.AgvInfo[row].Warn_Level = 4;
|
||
Func.AgvInfo[row].Control_PLC = Convert.ToInt16(mainfrm.ds_Agvlist.Tables[0].Rows[row]["Type"].ToString());
|
||
All_Agv_Stop[row] = 0;
|
||
All_Agv_Reset[row] = 0;
|
||
All_Agv_Close[row] = 0;
|
||
}
|
||
|
||
strsql = "SELECT [Loc_ID] ,[Card_ID],[Port] ,[Bit] ,[Value] FROM [IO_Set]";
|
||
ds_Card_DO = conn.connDt(strsql).Copy();
|
||
|
||
strsql = "SELECT [Card_ID] ,[Port] ,[Bit] ,[Value] ,[Class] ,[Loc1] ,[Loc2] ,[Loc3] ,[loc4] ,[loc5] FROM [IO_Accept] where class = 0";
|
||
ds_Card_DI_Call = conn.connDt(strsql).Copy();
|
||
|
||
strsql = "SELECT [Card_ID] ,[Port] ,[Bit] ,[Value] ,[Class] ,[Loc1] FROM [IO_Accept] where class =1";
|
||
ds_Card_DI_Fx = conn.connDt(strsql).Copy();
|
||
|
||
strsql = "SELECT [Landmark] FROM [Change_LandMark]";
|
||
ds_Change = conn.connDt(strsql).Copy();
|
||
|
||
//枚举所有可提示的报警信息
|
||
strsql = "SELECT [Warn_ID] ,[Warn_Info] ,[Warn_Level] FROM [Warn_Info] order by Warn_ID";
|
||
ds_WarnList = conn.connDt(strsql).Copy();
|
||
|
||
|
||
strsql = "SELECT [Warn_ID] ,[Warn_Info] ,[Warn_Level] FROM [Warn_InfoPlc] order by Warn_ID";
|
||
ds_WarnList_Plc = conn.connDt(strsql).Copy();
|
||
|
||
//所有位置信息
|
||
strsql = "SELECT [Assembly_Line],[Loc_ID] ,[Flag_Value] ,[Loc_X] ,[Loc_Y] ,[Binding] ,[Area] " +
|
||
",[Assembly_ID] ,[Bank] ,[Speed] ,[Next_Station1] ,[Drict1] ,[LongTime1] " +
|
||
",[Next_Station2],[Drict2] ,[LongTime2] ,[Next_Station3] ,[Drict3] ,[LongTime3] " +
|
||
" FROM [LandMarkInfo]";
|
||
ds_linelandmark = conn.connDt(strsql).Copy();
|
||
|
||
|
||
//获取所有放行时需要确认的Cross信息
|
||
strsql = "SELECT [Assembly_ID] as 当前产线编号, [LandMark_ID] as 当前地标编号, [Assembly_ID2] as 参考产线编号, [LandMark_ID2] as 参考地标编号 , agv_no as AGV编号 ,reset_mode as 复位模式" +
|
||
" FROM Crossing_LandMark " +
|
||
" order by [Assembly_ID] , [LandMark_ID] ";
|
||
mainfrm.ds_CrossInfo = conn.connDt(strsql).Copy();
|
||
mainfrm.ds_CrossInfo1 = mainfrm.ds_CrossInfo;
|
||
mainfrm.ds_CrossInfo2 = mainfrm.ds_CrossInfo;
|
||
mainfrm.ds_CrossInfo3 = mainfrm.ds_CrossInfo;
|
||
|
||
|
||
|
||
//初始化AGV位置信息Temp
|
||
Func.Agv_Location_Temp = new int[Cls.Param.AGV_Qty];
|
||
for (int i = 0; i < Cls.Param.AGV_Qty; i++)
|
||
{
|
||
Func.Agv_Location_Temp[i] = 0;
|
||
}
|
||
|
||
//Cls.Param.connectStr = Properties.Settings.Default.connectStr;
|
||
Init();
|
||
Delog();
|
||
|
||
DataSet ds = new DataSet();
|
||
strsql = "SELECT ProjectInfo.[Prj_ID], ProjectInfo.[Prj_Name], ProjectInfo.[Remark] FROM ProjectInfo";
|
||
|
||
ds = db.connDt(strsql);
|
||
if (ds == null)
|
||
{
|
||
DatabaseSet db1 = new DatabaseSet();
|
||
db1.ShowDialog();
|
||
return false;
|
||
}
|
||
if (ds.Tables[0].Rows.Count > 0)
|
||
{
|
||
Cls.Param.Pro_id = ds.Tables[0].Rows[0][0].ToString();
|
||
Cls.Param.Pro_factory = ds.Tables[0].Rows[0][1].ToString();
|
||
Cls.Param.Pro_remark = ds.Tables[0].Rows[0][2].ToString();
|
||
|
||
}
|
||
strsql = "SELECT '' as 时间 ,'' as 线体编号 , '' as 线体名称 , '' as 设备编号, '' as 内部编号, '' as 报警信息";
|
||
ds_AgvWarn = db.connDt(strsql).Copy();
|
||
ds_AgvWarn.Tables[0].Rows.RemoveAt(0);
|
||
|
||
strsql = "SELECT '' as 时间 ,'' as 线体编号 , '' as 线体名称 , '' as 设备编号, '' as 内部编号, '' as 位置, '' as 放行结果";
|
||
ds_AGVGo = db.connDt(strsql).Copy();
|
||
ds_AGVGo.Tables[0].Rows.RemoveAt(0);
|
||
}
|
||
catch
|
||
{
|
||
MessageBox.Show("系统数据库连接参数可能尚未配置,请配置数据库参数!", "华晓AGV管理系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
return false;
|
||
}
|
||
|
||
|
||
|
||
if (Cls.Param.Card1_Interval > 0)
|
||
{
|
||
myDevice_DI0 = new DeviceInformation();
|
||
myDevice_DI0.Description = "PCI-1730,BID#0";//板卡名称,可以从DAQ上面找到
|
||
myDevice_DI0.DeviceMode = AccessMode.ModeRead;//板卡模式
|
||
myDevice_DI0.DeviceNumber = 0;//板卡编号,可以从DAQ上面找到
|
||
myDevice_DI0.ModuleIndex = 0;
|
||
|
||
myDevice_DO0 = new DeviceInformation();
|
||
myDevice_DO0.Description = "PCI-1730,BID#0";//板卡名称,可以从DAQ上面找到
|
||
myDevice_DO0.DeviceMode = AccessMode.ModeWrite;//板卡模式
|
||
myDevice_DO0.DeviceNumber = 0;//板卡编号,可以从DAQ上面找到
|
||
myDevice_DO0.ModuleIndex = 0;
|
||
}
|
||
if (Cls.Param.Card2_Interval > 0)
|
||
{
|
||
myDevice_DI1 = new DeviceInformation();
|
||
myDevice_DI1.Description = "PCI-1730,BID#1";//板卡名称,可以从DAQ上面找到
|
||
myDevice_DI1.DeviceMode = AccessMode.ModeRead;//板卡模式
|
||
myDevice_DI1.DeviceNumber = 0;//板卡编号,可以从DAQ上面找到
|
||
myDevice_DI1.ModuleIndex = 0;
|
||
|
||
myDevice_DO1 = new DeviceInformation();
|
||
myDevice_DO1.Description = "PCI-1730,BID#1";//板卡名称,可以从DAQ上面找到
|
||
myDevice_DO1.DeviceMode = AccessMode.ModeWrite;//板卡模式
|
||
myDevice_DO1.DeviceNumber = 0;//板卡编号,可以从DAQ上面找到
|
||
myDevice_DO1.ModuleIndex = 0;
|
||
}
|
||
if (Cls.Param.Card3_Interval > 0)
|
||
{
|
||
myDevice_DI2 = new DeviceInformation();
|
||
myDevice_DI2.Description = "PCI-1730,BID#2";//板卡名称,可以从DAQ上面找到
|
||
myDevice_DI2.DeviceMode = AccessMode.ModeRead;//板卡模式
|
||
myDevice_DI2.DeviceNumber = 0;//板卡编号,可以从DAQ上面找到
|
||
myDevice_DI2.ModuleIndex = 0;
|
||
|
||
myDevice_DO2 = new DeviceInformation();
|
||
myDevice_DO2.Description = "PCI-1730,BID#2";//板卡名称,可以从DAQ上面找到
|
||
myDevice_DO2.DeviceMode = AccessMode.ModeWrite;//板卡模式
|
||
myDevice_DO2.DeviceNumber = 0;//板卡编号,可以从DAQ上面找到
|
||
myDevice_DO2.ModuleIndex = 0;
|
||
}
|
||
return true;
|
||
|
||
}
|
||
|
||
|
||
private void yunxingjiankongToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
foreach (ToolStripMenuItem tlm in menuStrip1.Items)
|
||
{
|
||
tlm.BackColor = Color.WhiteSmoke;
|
||
}
|
||
}
|
||
catch { }
|
||
((ToolStripMenuItem)sender).BackColor = Color.White;
|
||
tool_display('R');
|
||
}
|
||
|
||
private void toolStripButton1_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void toolStripButton2_Click(object sender, EventArgs e)
|
||
{
|
||
Cls.Param.StartFlag = false;
|
||
tbtn_start.Text = "开始调度";
|
||
tbtn_stop2.Enabled = false;
|
||
tbtn_stop1.Enabled = false;
|
||
tbtn_start.Enabled = true;
|
||
}
|
||
|
||
private void 资料管理ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
foreach (ToolStripMenuItem tlm in menuStrip1.Items)
|
||
{
|
||
tlm.BackColor = Color.WhiteSmoke;
|
||
}
|
||
}
|
||
catch { }
|
||
((ToolStripMenuItem)sender).BackColor = Color.White;
|
||
tool_display('M');
|
||
}
|
||
|
||
private void 系统设置ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
foreach (ToolStripMenuItem tlm in menuStrip1.Items)
|
||
{
|
||
tlm.BackColor = Color.WhiteSmoke;
|
||
}
|
||
}
|
||
catch { }
|
||
((ToolStripMenuItem)sender).BackColor = Color.White;
|
||
tool_display('S');
|
||
}
|
||
|
||
private void 帮助ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
foreach (ToolStripMenuItem tlm in menuStrip1.Items)
|
||
{
|
||
tlm.BackColor = Color.WhiteSmoke;
|
||
}
|
||
}
|
||
catch { }
|
||
((ToolStripMenuItem)sender).BackColor = Color.White;
|
||
tool_display('H');
|
||
}
|
||
|
||
private void 报表查询RToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
foreach (ToolStripMenuItem tlm in menuStrip1.Items)
|
||
{
|
||
tlm.BackColor = Color.WhiteSmoke;
|
||
}
|
||
}
|
||
catch { }
|
||
((ToolStripMenuItem)sender).BackColor = Color.White;
|
||
tool_display('P');
|
||
}
|
||
|
||
|
||
|
||
private void toolStripButton5_Click(object sender, EventArgs e)
|
||
{
|
||
AGVManage agvmanage = new AGVManage();
|
||
agvmanage.MdiParent = this;
|
||
agvmanage.Show();
|
||
}
|
||
|
||
private void toolStripButton7_Click(object sender, EventArgs e)
|
||
{
|
||
APInfo apinfo = new APInfo();
|
||
apinfo.MdiParent = this;
|
||
apinfo.Show();
|
||
}
|
||
|
||
private void toolStripButton4_Click(object sender, EventArgs e)
|
||
{
|
||
APTest aptest = new APTest();
|
||
aptest.MdiParent = this;
|
||
aptest.Show();
|
||
}
|
||
|
||
private void toolStripButton8_Click(object sender, EventArgs e)
|
||
{
|
||
//SetControl setcontrol = new SetControl();
|
||
SetControl setcontrol = new SetControl(this.ClientSize.Width - 5, this.ClientSize.Height - menuStrip1.Height - toolStrip1.Height - statusStrip1.Height - 5);
|
||
setcontrol.MdiParent = this;
|
||
setcontrol.Show();
|
||
}
|
||
|
||
private void toolStripButton6_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
Linemanage linemanage = new Linemanage();
|
||
linemanage.MdiParent = this;
|
||
linemanage.Show();
|
||
}
|
||
|
||
private void toolStripButton11_Click(object sender, EventArgs e)
|
||
{
|
||
Control_Point control_point = new Control_Point(this.ClientSize.Width - 5, this.ClientSize.Height - menuStrip1.Height - toolStrip1.Height - statusStrip1.Height - 5);
|
||
control_point.MdiParent = this;
|
||
control_point.Show();
|
||
}
|
||
|
||
Form frm1;
|
||
private void toolStripButton18_Click(object sender, EventArgs e)
|
||
{
|
||
//Frm_A111 aa = new Frm_A111();
|
||
//aa.MdiParent = this;
|
||
//aa.Show();
|
||
//return;
|
||
//toolStrip1.Visible = false;
|
||
tbtn_stop2.ToolTipText = "停止调度";
|
||
if (frm1 == null)
|
||
{
|
||
Cls.Param.StartFlag = true;
|
||
//bgcmb.Enabled = true;
|
||
tbtn_start.Text = "正在调度";
|
||
cmb_map.Enabled = true;
|
||
try
|
||
{
|
||
frm1 = (Form)Assembly.Load("华晓AGV管理系统").CreateInstance("AGVSystem.Frm_" + Cls.Param.Pro_id);
|
||
if (frm1 == null)
|
||
{
|
||
MessageBox.Show("没有找到对应的窗体,frm1 = null!");
|
||
return;
|
||
}
|
||
}
|
||
catch
|
||
{
|
||
MessageBox.Show("没有找到对应的窗体!");
|
||
return;
|
||
}
|
||
if (!Cls.Param.Frm_Ischild)
|
||
{
|
||
frm1.MdiParent = this;
|
||
}
|
||
frm1.StartPosition = FormStartPosition.CenterScreen;
|
||
frm1.Show();
|
||
cmb_map.SelectedIndex = 0;
|
||
tbtn_stop2.Enabled = true;
|
||
tbtn_stop1.Enabled = true;
|
||
tbtn_start.Enabled = false;
|
||
}
|
||
else
|
||
{
|
||
frm1.Activate();
|
||
Cls.Param.StartFlag = true;
|
||
tbtn_start.Text = "正在调度";
|
||
tbtn_stop2.Enabled = true;
|
||
tbtn_stop1.Enabled = true;
|
||
tbtn_start.Enabled = false;
|
||
}
|
||
}
|
||
|
||
private void toolStripButton14_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
System.Diagnostics.Process.Start(Application.StartupPath + @"\华晓AGV管理系统操作手册.pdf");
|
||
}
|
||
catch
|
||
{
|
||
MessageBox.Show("没有找到制定文件!");
|
||
}
|
||
}
|
||
|
||
private void toolStripButton16_Click(object sender, EventArgs e)
|
||
{
|
||
AboutBox1 AboutBox = new AboutBox1();
|
||
AboutBox.ShowDialog();
|
||
}
|
||
|
||
private void mainfrm_Load(object sender, EventArgs e)
|
||
{
|
||
tool_display('R');
|
||
if (Cls.Param.Auto_Control)
|
||
{
|
||
toolStripButton18_Click(null, null);
|
||
}
|
||
}
|
||
private static void Init()
|
||
{
|
||
|
||
db = new ClsDBConn_sql();
|
||
DataSet ds = new DataSet();
|
||
string strsql = "SELECT [Col_Name],[Col_Value] FROM [SysParam]";
|
||
try
|
||
{
|
||
ds = db.connDt(strsql);
|
||
if (ds == null) return;
|
||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||
{
|
||
if (dr["Col_Name"].ToString().Trim() == "Day_Count")
|
||
Cls.Param.Day_Count = Convert.ToInt16(dr["Col_Value"]);
|
||
else if (dr["Col_Name"].ToString().Trim() == "Card1_Interval")
|
||
Cls.Param.Card1_Interval = Convert.ToInt16(dr["Col_Value"]);
|
||
else if (dr["Col_Name"].ToString().Trim() == "Card2_Interval")
|
||
Cls.Param.Card2_Interval = Convert.ToInt16(dr["Col_Value"]);
|
||
else if (dr["Col_Name"].ToString().Trim() == "Card3_Interval")
|
||
Cls.Param.Card3_Interval = Convert.ToInt16(dr["Col_Value"]);
|
||
else if (dr["Col_Name"].ToString().Trim() == "Auto_Control")
|
||
Cls.Param.Auto_Control = Convert.ToBoolean(dr["Col_Value"]);
|
||
else if (dr["Col_Name"].ToString().Trim() == "map1_status")
|
||
Cls.Param.map1_status = Convert.ToBoolean(dr["Col_Value"]);
|
||
else if (dr["Col_Name"].ToString().Trim() == "map2_status")
|
||
Cls.Param.map2_status = Convert.ToBoolean(dr["Col_Value"]);
|
||
else if (dr["Col_Name"].ToString().Trim() == "map3_status")
|
||
Cls.Param.map3_status = Convert.ToBoolean(dr["Col_Value"]);
|
||
else if (dr["Col_Name"].ToString().Trim() == "Load_Path_His")
|
||
Cls.Param.Load_Path_His = Convert.ToBoolean(dr["Col_Value"]);
|
||
else if (dr["Col_Name"].ToString().Trim() == "AgvLoc_Dynamic_Display")
|
||
Cls.Param.Agv_Location_Auto_Display = Convert.ToBoolean(dr["Col_Value"]);
|
||
else if (dr["Col_Name"].ToString().Trim() == "PLC_Type")
|
||
Cls.Param.PLC_Type = Convert.ToByte(dr["Col_Value"]);
|
||
else if (dr["Col_Name"].ToString().Trim() == "Frm_Ischild")
|
||
Cls.Param.Frm_Ischild = Convert.ToBoolean(dr["Col_Value"]);
|
||
else if (dr["Col_Name"].ToString().Trim() == "Xj_Time1")
|
||
Cls.Param.Xj_Time1 = dr["Col_Value"].ToString();
|
||
else if (dr["Col_Name"].ToString().Trim() == "Xj_Time2")
|
||
Cls.Param.Xj_Time2 = dr["Col_Value"].ToString();
|
||
else if (dr["Col_Name"].ToString().Trim() == "Car_Size")
|
||
{
|
||
Cls.Param.Icon_Size = Convert.ToInt16(dr["Col_Value"].ToString());
|
||
if (Cls.Param.Icon_Size < 21) Cls.Param.Icon_Size = 21;
|
||
if (Cls.Param.Icon_Size > 150) Cls.Param.Icon_Size = 150;
|
||
}
|
||
else if (dr["Col_Name"].ToString().Trim() == "Location_ID_Dispaly")
|
||
Cls.Param.Location_ID_Dispaly = Convert.ToBoolean(dr["Col_Value"]);
|
||
else if (dr["Col_Name"].ToString().Trim() == "Wait_Time1")
|
||
Cls.Param.Wait_Time1 = Convert.ToInt16(dr["Col_Value"]);
|
||
else if (dr["Col_Name"].ToString().Trim() == "Wait_Time2")
|
||
Cls.Param.Wait_Time2 = Convert.ToInt16(dr["Col_Value"]);
|
||
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageBox.Show(ex.Message, "华晓AGV管理系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
private void toolStripButton12_Click(object sender, EventArgs e)
|
||
{
|
||
SysSet sysset = new SysSet();
|
||
sysset.MdiParent = this;
|
||
sysset.Show();
|
||
}
|
||
|
||
private void tool_display(char a)
|
||
{
|
||
if (a == 'R')
|
||
{
|
||
tbtn_start.Visible = true;
|
||
toolS1.Visible = true;
|
||
tbtn_stop1.Visible = true;
|
||
toolS2.Visible = true;
|
||
tbtn_stop2.Visible = true;
|
||
toolS3.Visible = true;
|
||
tbtn_warn.Visible = true;
|
||
toolS4.Visible = true;
|
||
tbtn_ap_st.Visible = true;
|
||
toolS5.Visible = true;
|
||
|
||
tbtn_agvm.Visible = false;
|
||
toolS6.Visible = false;
|
||
tbtn_xt.Visible = false;
|
||
toolS7.Visible = false;
|
||
tbtn_ap_info.Visible = false;
|
||
toolS8.Visible = false;
|
||
tbtn_pathset.Visible = false;
|
||
toolS9.Visible = false;
|
||
tbtn_dbset.Visible = false;
|
||
toolS10.Visible = false;
|
||
|
||
tbtn_yc_log.Visible = false;
|
||
toolS11.Visible = false;
|
||
tbtn_lj_log.Visible = false;
|
||
toolS12.Visible = false;
|
||
tbtn_database_set.Visible = false;
|
||
toolS13.Visible = false;
|
||
tbtn_param_set.Visible = false;
|
||
toolS14.Visible = false;
|
||
|
||
//toolS_inter.Visible = true;
|
||
toolS17.Visible = true;
|
||
|
||
toolStripButton1.Visible = false;
|
||
toolStripSeparator1.Visible = false;
|
||
toolStripButton2.Visible = false;
|
||
toolStripSeparator2.Visible = false;
|
||
toolStripButton3.Visible = true;
|
||
toolStripSeparator3.Visible = true;
|
||
toolStripButton4.Visible = false;
|
||
toolStripSeparator4.Visible = false;
|
||
|
||
toolS18.Visible = false;
|
||
tbtn_change.Visible = false;
|
||
}
|
||
else if (a == 'M')
|
||
{
|
||
tbtn_start.Visible = false;
|
||
toolS1.Visible = false;
|
||
tbtn_stop1.Visible = false;
|
||
toolS2.Visible = false;
|
||
tbtn_stop2.Visible = false;
|
||
toolS3.Visible = false;
|
||
tbtn_warn.Visible = false;
|
||
toolS4.Visible = false;
|
||
tbtn_ap_st.Visible = false;
|
||
toolS5.Visible = false;
|
||
|
||
tbtn_agvm.Visible = true;
|
||
toolS6.Visible = true;
|
||
tbtn_xt.Visible = true;
|
||
toolS7.Visible = true;
|
||
tbtn_ap_info.Visible = true;
|
||
toolS8.Visible = true;
|
||
tbtn_pathset.Visible = true;
|
||
toolS9.Visible = true;
|
||
tbtn_dbset.Visible = true;
|
||
toolS10.Visible = true;
|
||
|
||
tbtn_yc_log.Visible = false;
|
||
toolS11.Visible = false;
|
||
tbtn_lj_log.Visible = false;
|
||
toolS12.Visible = false;
|
||
tbtn_database_set.Visible = false;
|
||
toolS13.Visible = false;
|
||
tbtn_param_set.Visible = false;
|
||
toolS14.Visible = false;
|
||
|
||
toolS_inter.Visible = false;
|
||
toolS17.Visible = false;
|
||
|
||
toolStripButton1.Visible = false;
|
||
toolStripSeparator1.Visible = false;
|
||
toolStripButton2.Visible = false;
|
||
toolStripSeparator2.Visible = false;
|
||
toolStripButton3.Visible = false;
|
||
toolStripSeparator3.Visible = false;
|
||
toolStripButton4.Visible = false;
|
||
toolStripSeparator4.Visible = false;
|
||
|
||
toolS18.Visible = false;
|
||
tbtn_change.Visible = false;
|
||
}
|
||
else if (a == 'S')
|
||
{
|
||
tbtn_start.Visible = false;
|
||
toolS1.Visible = false;
|
||
tbtn_stop1.Visible = false;
|
||
toolS2.Visible = false;
|
||
tbtn_stop2.Visible = false;
|
||
toolS3.Visible = false;
|
||
tbtn_warn.Visible = false;
|
||
toolS4.Visible = false;
|
||
tbtn_ap_st.Visible = false;
|
||
toolS5.Visible = false;
|
||
|
||
tbtn_agvm.Visible = false;
|
||
toolS6.Visible = false;
|
||
tbtn_xt.Visible = false;
|
||
toolS7.Visible = false;
|
||
tbtn_ap_info.Visible = false;
|
||
toolS8.Visible = false;
|
||
tbtn_pathset.Visible = false;
|
||
toolS9.Visible = false;
|
||
tbtn_dbset.Visible = false;
|
||
toolS10.Visible = false;
|
||
|
||
tbtn_yc_log.Visible = false;
|
||
toolS11.Visible = false;
|
||
tbtn_lj_log.Visible = false;
|
||
toolS12.Visible = false;
|
||
|
||
tbtn_database_set.Visible = true;
|
||
toolS13.Visible = true;
|
||
tbtn_param_set.Visible = true;
|
||
toolS14.Visible = true;
|
||
|
||
toolS_inter.Visible = false;
|
||
toolS17.Visible = false;
|
||
|
||
toolStripButton1.Visible = false;
|
||
toolStripSeparator1.Visible = false;
|
||
toolStripButton2.Visible = false;
|
||
toolStripSeparator2.Visible = false;
|
||
toolStripButton3.Visible = false;
|
||
toolStripSeparator3.Visible = false;
|
||
toolStripButton4.Visible = true;
|
||
toolStripSeparator4.Visible = true;
|
||
|
||
toolS18.Visible = false;
|
||
tbtn_change.Visible = false;
|
||
}
|
||
else if (a == 'P')
|
||
{
|
||
tbtn_start.Visible = false;
|
||
toolS1.Visible = false;
|
||
tbtn_stop1.Visible = false;
|
||
toolS2.Visible = false;
|
||
tbtn_stop2.Visible = false;
|
||
toolS3.Visible = false;
|
||
tbtn_warn.Visible = false;
|
||
toolS4.Visible = false;
|
||
tbtn_ap_st.Visible = false;
|
||
toolS5.Visible = false;
|
||
|
||
tbtn_agvm.Visible = false;
|
||
toolS6.Visible = false;
|
||
tbtn_xt.Visible = false;
|
||
toolS7.Visible = false;
|
||
tbtn_ap_info.Visible = false;
|
||
toolS8.Visible = false;
|
||
tbtn_pathset.Visible = false;
|
||
toolS9.Visible = false;
|
||
tbtn_dbset.Visible = false;
|
||
toolS10.Visible = false;
|
||
|
||
tbtn_yc_log.Visible = true;
|
||
toolS11.Visible = true;
|
||
tbtn_lj_log.Visible = true;
|
||
toolS12.Visible = true;
|
||
|
||
tbtn_database_set.Visible = false;
|
||
toolS13.Visible = false;
|
||
tbtn_param_set.Visible = false;
|
||
toolS14.Visible = false;
|
||
|
||
toolS_inter.Visible = false;
|
||
toolS17.Visible = false;
|
||
|
||
toolStripButton1.Visible = true;
|
||
toolStripSeparator1.Visible = true;
|
||
toolStripButton2.Visible = true;
|
||
toolStripSeparator2.Visible = true;
|
||
toolStripButton3.Visible = false;
|
||
toolStripSeparator3.Visible = false;
|
||
toolStripButton4.Visible = false;
|
||
toolStripSeparator4.Visible = false;
|
||
toolS18.Visible = true;
|
||
tbtn_change.Visible = true;
|
||
}
|
||
else if (a == 'H')
|
||
{
|
||
tbtn_start.Visible = false;
|
||
toolS1.Visible = false;
|
||
tbtn_stop1.Visible = false;
|
||
toolS2.Visible = false;
|
||
tbtn_stop2.Visible = false;
|
||
toolS3.Visible = false;
|
||
tbtn_warn.Visible = false;
|
||
toolS4.Visible = false;
|
||
tbtn_ap_st.Visible = false;
|
||
toolS5.Visible = false;
|
||
|
||
tbtn_agvm.Visible = false;
|
||
toolS6.Visible = false;
|
||
tbtn_xt.Visible = false;
|
||
toolS7.Visible = false;
|
||
tbtn_ap_info.Visible = false;
|
||
toolS8.Visible = false;
|
||
tbtn_pathset.Visible = false;
|
||
toolS9.Visible = false;
|
||
tbtn_dbset.Visible = false;
|
||
toolS10.Visible = false;
|
||
|
||
tbtn_yc_log.Visible = false;
|
||
toolS11.Visible = false;
|
||
tbtn_lj_log.Visible = false;
|
||
toolS12.Visible = false;
|
||
|
||
tbtn_database_set.Visible = false;
|
||
toolS13.Visible = false;
|
||
tbtn_param_set.Visible = false;
|
||
toolS14.Visible = false;
|
||
|
||
toolS_inter.Visible = false;
|
||
toolS17.Visible = false;
|
||
|
||
toolStripButton1.Visible = false;
|
||
toolStripSeparator1.Visible = false;
|
||
toolStripButton2.Visible = false;
|
||
toolStripSeparator2.Visible = false;
|
||
toolStripButton3.Visible = false;
|
||
toolStripSeparator3.Visible = false;
|
||
toolStripButton4.Visible = false;
|
||
toolStripSeparator4.Visible = false;
|
||
toolS18.Visible = false;
|
||
tbtn_change.Visible = false;
|
||
}
|
||
}
|
||
|
||
private void cmb_map_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
Cls.Param.Map_ID = (byte)cmb_map.SelectedIndex;
|
||
}
|
||
|
||
private void toolStripButton13_Click(object sender, EventArgs e)
|
||
{
|
||
Application.Exit();
|
||
}
|
||
|
||
private void tbtn_warn_Click(object sender, EventArgs e)
|
||
{
|
||
warnlist warnlist1 = new warnlist();
|
||
warnlist1.Show();
|
||
}
|
||
|
||
private void tbtn_stop2_Click(object sender, EventArgs e)
|
||
{
|
||
if (Cls.Param.Thread_Count == -1)
|
||
{
|
||
Cls.Param.Thread_Count = Cls.Param.AGV_Qty;
|
||
Cls.Param.StartFlag = false;
|
||
tbtn_start.Enabled = true;
|
||
tbtn_stop1.Enabled = false;
|
||
tbtn_stop2.Enabled = false;
|
||
}
|
||
}
|
||
|
||
private void tbtn_database_set_Click(object sender, EventArgs e)
|
||
{
|
||
DatabaseSet databaseset = new DatabaseSet();
|
||
databaseset.MdiParent = this;
|
||
databaseset.Show();
|
||
}
|
||
|
||
byte day = 0, day_temp = 0;
|
||
private void timer1_Tick(object sender, EventArgs e)
|
||
{
|
||
toolS_timer.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss ");
|
||
if (Cls.Param.Thread_Count != -1)
|
||
tbtn_stop2.ToolTipText = "停止调度..." + Cls.Param.Thread_Count.ToString();
|
||
day = (byte)DateTime.Now.Day;
|
||
if (day - day_temp == 1)
|
||
{
|
||
day_temp = day;
|
||
Delog();
|
||
}
|
||
else
|
||
{
|
||
day_temp = day;
|
||
}
|
||
}
|
||
|
||
public static frm_card frm_card1;
|
||
private void toolS_inter_Click(object sender, EventArgs e)
|
||
{
|
||
if (frm_card1 == null)
|
||
{
|
||
frm_card1 = new frm_card();
|
||
frm_card1.MdiParent = this;
|
||
frm_card1.Show();
|
||
}
|
||
else
|
||
{
|
||
frm_card1.Activate();
|
||
}
|
||
}
|
||
|
||
private void mainfrm_MouseMove(object sender, MouseEventArgs e)
|
||
{
|
||
mainfrm.Lab_location.Text = "X: " + e.X.ToString() + " ,Y: " + e.Y.ToString() + " ]";
|
||
}
|
||
|
||
public static void Delog()
|
||
{
|
||
string sqlstr;
|
||
db = new ClsDBConn_sql();
|
||
sqlstr = "Delete FROM Go_Log where datediff( day,Dt , SYSDATETIME()) >" + Cls.Param.Day_Count;
|
||
db.Command(sqlstr);
|
||
sqlstr = "Delete FROM Location_log where datediff( day,Dt , SYSDATETIME()) >" + Cls.Param.Day_Count;
|
||
db.Command(sqlstr);
|
||
sqlstr = "Delete FROM net_log where datediff( day,Dt , SYSDATETIME()) >" + Cls.Param.Day_Count;
|
||
db.Command(sqlstr);
|
||
sqlstr = "Delete FROM warn_log where datediff( day,Dt , SYSDATETIME()) >" + Cls.Param.Day_Count;
|
||
db.Command(sqlstr);
|
||
sqlstr = "Delete FROM change_log where datediff( day,Start_time , SYSDATETIME()) >" + Cls.Param.Day_Count;
|
||
db.Command(sqlstr);
|
||
}
|
||
|
||
private void tbtn_yc_log_Click(object sender, EventArgs e)
|
||
{
|
||
frmwarnfind frmfind1 = new frmwarnfind();
|
||
frmfind1.MdiParent = this;
|
||
frmfind1.Show();
|
||
}
|
||
|
||
private void tbtn_lj_log_Click(object sender, EventArgs e)
|
||
{
|
||
frmfind frmfind1 = new frmfind("地标读取日志");
|
||
frmfind1.MdiParent = this;
|
||
frmfind1.Show();
|
||
}
|
||
|
||
private void toolStripButton1_Click_1(object sender, EventArgs e)
|
||
{
|
||
frmfind frmfind1 = new frmfind("AGV放行日志");
|
||
frmfind1.MdiParent = this;
|
||
frmfind1.Show();
|
||
}
|
||
|
||
private void toolStripButton2_Click_1(object sender, EventArgs e)
|
||
{
|
||
frmnetfind frmfind1 = new frmnetfind("网络异常日志");
|
||
frmfind1.MdiParent = this;
|
||
frmfind1.Show();
|
||
}
|
||
|
||
public static Frm_Path_Status frm_Path_Status;
|
||
private void toolStripButton3_Click(object sender, EventArgs e)
|
||
{
|
||
if (frm_Path_Status == null)
|
||
{
|
||
frm_Path_Status = new Frm_Path_Status();
|
||
frm_Path_Status.MdiParent = this;
|
||
frm_Path_Status.Width = this.ClientSize.Width - 5;
|
||
frm_Path_Status.Height = this.ClientSize.Height - menuStrip1.Height - toolStrip1.Height - statusStrip1.Height - 5;
|
||
frm_Path_Status.StartPosition = FormStartPosition.CenterScreen;
|
||
frm_Path_Status.Show();
|
||
}
|
||
else
|
||
{
|
||
frm_Path_Status.Activate();
|
||
}
|
||
}
|
||
|
||
private void toolStripButton4_Click_1(object sender, EventArgs e)
|
||
{
|
||
logon logon1 = new logon();
|
||
//logon1.MdiParent = this;
|
||
logon1.StartPosition = FormStartPosition.CenterScreen;
|
||
logon1.Show();
|
||
}
|
||
|
||
private void toolStripStatusLabel2_TextChanged(object sender, EventArgs e)
|
||
{
|
||
if (!toolStripStatusLabel2.Visible)
|
||
toolStripStatusLabel2.Visible = !toolStripStatusLabel2.Visible;
|
||
}
|
||
|
||
private void tbtn_change_Click(object sender, EventArgs e)
|
||
{
|
||
frmchangefind frmfind1 = new frmchangefind("充电记录");
|
||
frmfind1.MdiParent = this;
|
||
frmfind1.Show();
|
||
}
|
||
|
||
bool Force_Closed_Flag = false;
|
||
private void mainfrm_FormClosing(object sender, FormClosingEventArgs e)
|
||
{
|
||
if (!Force_Closed_Flag)
|
||
{
|
||
if (MessageBox.Show("是否确定要退出AGV调度管理系统?", "警告!", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
|
||
{
|
||
e.Cancel = true;
|
||
return;
|
||
|
||
}
|
||
Application.ExitThread();
|
||
}
|
||
}
|
||
|
||
private void mainfrm_Resize(object sender, EventArgs e)
|
||
{
|
||
if (frm1 != null)
|
||
{
|
||
frm1.Width = mainfrm.newmainfrm.ClientSize.Width - 5;
|
||
frm1.Height = mainfrm.newmainfrm.ClientSize.Height - 29 - 74 - 22 - 5;
|
||
}
|
||
}
|
||
|
||
private void mainfrm_FormClosing(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private static void ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
string info = ((ToolStripMenuItem)sender).Text.Split('-')[0].Trim();
|
||
if (MessageBox.Show("当前启动项目:" + Cls.Param.Pro_id + ", 是否要变更启动项目=" + info, "启动项目选择", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
|
||
{
|
||
//RegistryKey key = Registry.LocalMachine;
|
||
//RegistryKey software = key.CreateSubKey("Software\\AGV Manager System");
|
||
//software.SetValue("item_id", info);
|
||
Cls.FileRW.WriteIniValue("item_id", "item_id", info, Application.StartupPath + @"\info.ini");
|
||
}
|
||
}
|
||
|
||
private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void toolStripMenuItem1_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void toolStripMenuItem2_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void output设置ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
OutputSet ioutput = new OutputSet();
|
||
ioutput.Show();
|
||
}
|
||
|
||
private void input设置ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
InputSet ioinput = new InputSet();
|
||
ioinput.Show();
|
||
}
|
||
|
||
private void aGV列表ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
Agv_Status st = new Agv_Status();
|
||
st.Show();
|
||
}
|
||
|
||
private void timer2_Tick(object sender, EventArgs e)
|
||
{
|
||
memory_Check();
|
||
}
|
||
|
||
private void 一键复位ToolStripMenuItem1_Click(object sender, EventArgs e)
|
||
{
|
||
if (All_Agv_Reset[0] == 0)
|
||
{
|
||
if (MessageBox.Show("是否复位所有AGV?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
|
||
{
|
||
toolStripStatusLabel3.Text = "正在复位所有AGV!";
|
||
for (int i = 0; i < Cls.Param.AGV_Qty; i++)
|
||
{
|
||
All_Agv_Reset[i] = 1;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
toolStripStatusLabel3.Text = "";
|
||
for (int i = 0; i < Cls.Param.AGV_Qty; i++)
|
||
{
|
||
All_Agv_Reset[i] = 0;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
private void 一键停止ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
if (All_Agv_Stop[0] == 0)
|
||
{
|
||
if (MessageBox.Show("所有AGV是否紧急停止运行?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
|
||
{
|
||
toolStripStatusLabel3.Text = "所有AGV正在停止运行!";
|
||
for (int i = 0; i < Cls.Param.AGV_Qty; i++)
|
||
{
|
||
All_Agv_Stop[i] = 1;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
toolStripStatusLabel3.Text = "";
|
||
for (int i = 0; i < Cls.Param.AGV_Qty; i++)
|
||
{
|
||
All_Agv_Stop[i] = 0;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
private void 一键关机ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
if (All_Agv_Close[0] == 0)
|
||
{
|
||
if (MessageBox.Show("是否关闭所有AGV?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
|
||
{
|
||
toolStripStatusLabel3.Text = "所有AGV正在关机!";
|
||
for (int i = 0; i < Cls.Param.AGV_Qty; i++)
|
||
{
|
||
All_Agv_Close[i] = 1;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
toolStripStatusLabel3.Text = "";
|
||
for (int i = 0; i < Cls.Param.AGV_Qty; i++)
|
||
{
|
||
All_Agv_Close[i] = 0;
|
||
}
|
||
}
|
||
}
|
||
|
||
private void bgcmb_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void memory_Check()
|
||
{
|
||
Process[] processes;
|
||
processes = System.Diagnostics.Process.GetProcesses();
|
||
Process process;
|
||
int count = 0;
|
||
try
|
||
{
|
||
if (Func.AgvInfo.Length == 0) return;
|
||
for (int i = 0; i < processes.Length - 1; i++)
|
||
{
|
||
process = processes[i];
|
||
if (process.ProcessName.Contains("AGV管理系统"))
|
||
{
|
||
var p1 = new PerformanceCounter("Process", "Working Set - Private", process.ProcessName);
|
||
float aa = p1.NextValue();
|
||
if (p1.NextValue() >= 1000000000)
|
||
{
|
||
for (int j = 0; j < Func.AgvInfo.Length; j++)
|
||
{
|
||
if (Func.AgvInfo[j].bPlcLinked)
|
||
count++;
|
||
}
|
||
count = 3;
|
||
float a = (float)count / (float)Func.AgvInfo.Length;
|
||
if ((float)count / (float)Func.AgvInfo.Length <= 0.3)
|
||
{
|
||
Force_Closed_Flag = true;
|
||
System.Windows.Forms.Application.Exit();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
catch
|
||
{ }
|
||
}
|
||
|
||
public void Display()
|
||
{
|
||
if (menuStrip1.Visible)
|
||
{
|
||
menuStrip1.Visible = false;
|
||
toolStrip1.Visible = false;
|
||
statusStrip1.Visible = false;
|
||
this.FormBorderStyle = FormBorderStyle.None;
|
||
}
|
||
}
|
||
|
||
public void Display2()
|
||
{
|
||
if (!menuStrip1.Visible)
|
||
{
|
||
menuStrip1.Visible = true;
|
||
toolStrip1.Visible = true;
|
||
statusStrip1.Visible = true;
|
||
this.FormBorderStyle = FormBorderStyle.Sizable;
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|