Commit cd2c32e9 刘韬

1

1 个父辈 e5f96595
...@@ -306,6 +306,7 @@ namespace DeviceLibrary ...@@ -306,6 +306,7 @@ namespace DeviceLibrary
return dstobject; return dstobject;
} }
} }
[Serializable]
public class Msg public class Msg
{ {
public string msgtxt; public string msgtxt;
...@@ -316,6 +317,7 @@ namespace DeviceLibrary ...@@ -316,6 +317,7 @@ namespace DeviceLibrary
public class MsgService public class MsgService
{ {
public static Dictionary<string, MsgService> MSList = new Dictionary<string, MsgService>(); public static Dictionary<string, MsgService> MSList = new Dictionary<string, MsgService>();
public static Dictionary<string, List<Msg>> LastMSGList = new Dictionary<string, List<Msg>>();
public static void Add(string m, MsgLevel ml, ErrInfo errInfo = ErrInfo.Empty) public static void Add(string m, MsgLevel ml, ErrInfo errInfo = ErrInfo.Empty)
{ {
MSList.Values.ToList().ForEach(msl => MSList.Values.ToList().ForEach(msl =>
...@@ -332,11 +334,13 @@ namespace DeviceLibrary ...@@ -332,11 +334,13 @@ namespace DeviceLibrary
} }
return l; return l;
} }
public static event EventHandler<Dictionary<string, List<Msg>>> ShowMsg;
public string Device { get; } public string Device { get; }
public MsgService(string device) public MsgService(string device)
{ {
Device = device; Device = device;
MSList.Add(Device, this); MSList.Add(Device, this);
LastMSGList.Add(Device, get());
} }
public List<Msg> msg = new List<Msg>(); public List<Msg> msg = new List<Msg>();
public List<Msg> get() public List<Msg> get()
...@@ -361,18 +365,38 @@ namespace DeviceLibrary ...@@ -361,18 +365,38 @@ namespace DeviceLibrary
} }
} }
bool _setlogones = false; bool _setlogones = false;
internal void setlogones() internal void setlogones()
{ {
_setlogones = true; _setlogones = true;
} }
public void Show()
{
Dictionary<string, List<Msg>> clonemsglist;
lock (LastMSGList)
{
LastMSGList[Device] = get();
clonemsglist = Clone(LastMSGList);
}
ShowMsg?.Invoke(Device, clonemsglist);
}
public void clear() public void clear()
{ {
msg.Clear(); msg.Clear();
} }
/// <summary>
/// 得到一个对象的克隆(二进制的序列化和反序列化)--需要标记可序列化
/// </summary>
public static T Clone<T>(T obj)
{
MemoryStream memoryStream = new MemoryStream();
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(memoryStream, obj);
memoryStream.Position = 0;
return (T)formatter.Deserialize(memoryStream);
}
} }
public enum MsgLevel { public enum MsgLevel {
......
...@@ -16,8 +16,6 @@ namespace DeviceLibrary ...@@ -16,8 +16,6 @@ namespace DeviceLibrary
public static List<ManualResetEvent> manualResets = new List<ManualResetEvent>(); public static List<ManualResetEvent> manualResets = new List<ManualResetEvent>();
List<IDevice> DevicesList; List<IDevice> DevicesList;
string DeviceListName; string DeviceListName;
public delegate void ProcessMsg(List<Msg> msg);
public event ProcessMsg ProcessMsgEvent;
ManualResetEvent resetEvent = new ManualResetEvent(false); ManualResetEvent resetEvent = new ManualResetEvent(false);
public DeviceRunControl(string name, List<IDevice> device) { public DeviceRunControl(string name, List<IDevice> device) {
DevicesList = device; DevicesList = device;
...@@ -51,9 +49,7 @@ namespace DeviceLibrary ...@@ -51,9 +49,7 @@ namespace DeviceLibrary
} }
finally finally
{ {
var m = MsgService.MSList[x.GroupName].get(); MsgService.MSList[x.GroupName].Show();
ProcessMsgEvent?.Invoke(m);
} }
}); });
......
...@@ -29,7 +29,7 @@ namespace DeviceLibrary ...@@ -29,7 +29,7 @@ namespace DeviceLibrary
} }
LogUtil.info("按下复位按钮"); LogUtil.info("按下复位按钮");
ProcessMsgEvent?.Invoke(Msg.get()); Msg.Show();
//暂停时按下reaet按钮 //暂停时按下reaet按钮
if (RobotManage.isRunning && RobotManage.mainMachine.UserPause) if (RobotManage.isRunning && RobotManage.mainMachine.UserPause)
...@@ -50,7 +50,7 @@ namespace DeviceLibrary ...@@ -50,7 +50,7 @@ namespace DeviceLibrary
Msg.add(crc.GetString("Res0165","急停中,按下启动按钮,无法启动."), MsgLevel.warning); Msg.add(crc.GetString("Res0165","急停中,按下启动按钮,无法启动."), MsgLevel.warning);
} }
LogUtil.info("按下启动按钮"); LogUtil.info("按下启动按钮");
ProcessMsgEvent?.Invoke(Msg.get()); Msg.Show();
} }
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -33,9 +33,6 @@ namespace DeviceLibrary ...@@ -33,9 +33,6 @@ namespace DeviceLibrary
public Dictionary<string, DeviceGroup> DeviceGroup { get=>RobotManage.DeviceGroup; } public Dictionary<string, DeviceGroup> DeviceGroup { get=>RobotManage.DeviceGroup; }
public bool UserPause { get; set; } = false; public bool UserPause { get; set; } = false;
public delegate void ProcessMsg(List<Msg> msg);
public event ProcessMsg ProcessMsgEvent;
ServerCommunication ServerCM = new ServerCommunication(); ServerCommunication ServerCM = new ServerCommunication();
public ManualResetEvent ResetEvent = new ManualResetEvent(true); public ManualResetEvent ResetEvent = new ManualResetEvent(true);
...@@ -115,7 +112,7 @@ namespace DeviceLibrary ...@@ -115,7 +112,7 @@ namespace DeviceLibrary
} }
finally { finally {
var m = Msg.get(); var m = Msg.get();
ProcessMsgEvent?.Invoke(m); Msg.Show();
ServerCM.ProcessMsg(m); ServerCM.ProcessMsg(m);
StoreStatus currnetstoreStatus= StoreStatus.None; StoreStatus currnetstoreStatus= StoreStatus.None;
if (m.Find((aa) => aa.msgLevel == MsgLevel.alarm) == null) if (m.Find((aa) => aa.msgLevel == MsgLevel.alarm) == null)
......
...@@ -65,6 +65,8 @@ namespace DeviceLibrary ...@@ -65,6 +65,8 @@ namespace DeviceLibrary
//IsLoadOk = true; //IsLoadOk = true;
} }
catch (Exception ex) { catch (Exception ex) {
LogUtil.error(ex.ToString());
MessageBox.Show(ex.ToString());
LoadFinishEvent?.Invoke(false, ex.Message); LoadFinishEvent?.Invoke(false, ex.Message);
return; return;
} }
......
using OnlineStore.Common; using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -16,13 +17,14 @@ namespace DeviceLibrary ...@@ -16,13 +17,14 @@ namespace DeviceLibrary
/// <param name="rfid"></param> /// <param name="rfid"></param>
/// <param name="addr"></param> /// <param name="addr"></param>
/// <param name="trayInfo"></param> /// <param name="trayInfo"></param>
/// <returns>是否放行</returns> /// <returns>是否放行 放行true, 拦截false</returns>
public static bool Process(string rfid, int addr, out TrayInfo trayInfo) { public static bool Process(string rfid, int addr, out TrayInfo trayInfo) {
if (!Traylist.ContainsKey(rfid)) { if (!Traylist.ContainsKey(rfid)) {
Traylist.Add(rfid, new TrayInfo()); Traylist.Add(rfid, new TrayInfo());
Traylist[rfid].RFID = rfid; Traylist[rfid].RFID = rfid;
} }
Traylist[rfid].LastUpdateTime = DateTime.Now; Traylist[rfid].LastUpdateTime = DateTime.Now;
Traylist[rfid].LastAddr = addr;
trayInfo = Traylist[rfid]; trayInfo = Traylist[rfid];
return true; return true;
...@@ -45,6 +47,7 @@ namespace DeviceLibrary ...@@ -45,6 +47,7 @@ namespace DeviceLibrary
} }
public string Destination; public string Destination;
public int DestinationAddr; public int DestinationAddr;
public int LastAddr;
public bool HasLoad; public bool HasLoad;
public LoadTypeE LoadType; public LoadTypeE LoadType;
public TrayTypeE TrayType; public TrayTypeE TrayType;
...@@ -52,6 +55,7 @@ namespace DeviceLibrary ...@@ -52,6 +55,7 @@ namespace DeviceLibrary
public ReelParam ReelParam; public ReelParam ReelParam;
} }
public enum LoadTypeE { public enum LoadTypeE {
None,
MTP2, //流水线治具托盘 MTP2, //流水线治具托盘
MTP1, //流水线料盘托盘 MTP1, //流水线料盘托盘
S007, //料串 S007, //料串
...@@ -71,7 +75,9 @@ namespace DeviceLibrary ...@@ -71,7 +75,9 @@ namespace DeviceLibrary
{ {
public static Dictionary<LoadTypeE, string> LoadTypeDesc = new Dictionary<LoadTypeE, string>(); public static Dictionary<LoadTypeE, string> LoadTypeDesc = new Dictionary<LoadTypeE, string>();
public static Dictionary<TrayTypeE, string> TrayTypeDesc = new Dictionary<TrayTypeE, string>(); public static Dictionary<TrayTypeE, string> TrayTypeDesc = new Dictionary<TrayTypeE, string>();
public static Dictionary<int, string> AddrDesc = new Dictionary<int, string>();
static TrayManager() { static TrayManager() {
LoadTypeDesc.Add(LoadTypeE.None, "空");
LoadTypeDesc.Add(LoadTypeE.MTP2, "流水线治具托盘"); LoadTypeDesc.Add(LoadTypeE.MTP2, "流水线治具托盘");
LoadTypeDesc.Add(LoadTypeE.MTP1, "流水线料盘托盘"); LoadTypeDesc.Add(LoadTypeE.MTP1, "流水线料盘托盘");
LoadTypeDesc.Add(LoadTypeE.S007, "料串"); LoadTypeDesc.Add(LoadTypeE.S007, "料串");
...@@ -83,6 +89,19 @@ namespace DeviceLibrary ...@@ -83,6 +89,19 @@ namespace DeviceLibrary
TrayTypeDesc.Add(TrayTypeE.C02, "Pizza治具"); TrayTypeDesc.Add(TrayTypeE.C02, "Pizza治具");
TrayTypeDesc.Add(TrayTypeE.C03, "Tray治具"); TrayTypeDesc.Add(TrayTypeE.C03, "Tray治具");
TrayTypeDesc.Add(TrayTypeE.C04, "ShoeBOX治具"); TrayTypeDesc.Add(TrayTypeE.C04, "ShoeBOX治具");
}
public static void Init(Dictionary<string, DeviceGroup> deviceGroup) {
foreach (var dg in deviceGroup) {
if (dg.Value.addr_2 >= 0)
{
AddrDesc.Add(dg.Value.addr_1, dg.Value.GroupName + "-1");
AddrDesc.Add(dg.Value.addr_2, dg.Value.GroupName + "-2");
}
else {
AddrDesc.Add(dg.Value.addr_1, dg.Value.GroupName);
}
}
} }
} }
} }
...@@ -196,6 +196,7 @@ namespace DeviceLibrary ...@@ -196,6 +196,7 @@ namespace DeviceLibrary
var Ls_B_Tray_Check = $"Ls_{sideb}_Tray_Check"; var Ls_B_Tray_Check = $"Ls_{sideb}_Tray_Check";
var RFID = Minfo == LSAMoveInfo ? RFID_1 : RFID_2; var RFID = Minfo == LSAMoveInfo ? RFID_1 : RFID_2;
var lsb = (Minfo == LSAMoveInfo ? LSBMoveInfo : LSAMoveInfo); var lsb = (Minfo == LSAMoveInfo ? LSBMoveInfo : LSAMoveInfo);
var addr = (Minfo == LSAMoveInfo ? DeviceGroup.addr_1 : DeviceGroup.addr_2);
switch (Minfo.MoveStep) switch (Minfo.MoveStep)
{ {
case MoveStep.Wait: case MoveStep.Wait:
...@@ -233,8 +234,8 @@ namespace DeviceLibrary ...@@ -233,8 +234,8 @@ namespace DeviceLibrary
if (RFID.TryRead(out string rfid, out _) == 1) if (RFID.TryRead(out string rfid, out _) == 1)
{ {
TrayManager.Process(rfid, DeviceGroup.addr_1, out TrayInfo trayInfo); var through = TrayManager.Process(rfid, addr, out TrayInfo trayInfo);
if (rfid == "通过") if (through)
Minfo.NextMoveStep(MoveStep.SideMove_04); Minfo.NextMoveStep(MoveStep.SideMove_04);
else else
Minfo.NextMoveStep(MoveStep.SideMove_10); Minfo.NextMoveStep(MoveStep.SideMove_10);
...@@ -244,6 +245,7 @@ namespace DeviceLibrary ...@@ -244,6 +245,7 @@ namespace DeviceLibrary
{ {
Minfo.CanWhileCount--; Minfo.CanWhileCount--;
Minfo.log($"RFid读取失败,重试第{3- Minfo.CanWhileCount}次"); Minfo.log($"RFid读取失败,重试第{3- Minfo.CanWhileCount}次");
Minfo.WaitList.Add(WaitResultInfo.WaitMsg("RFid读取失败",MsgLevel.warning));
} }
else { else {
Minfo.log("RFid读取失败,直接通过"); Minfo.log("RFid读取失败,直接通过");
......
...@@ -105,7 +105,8 @@ namespace DeviceLibrary ...@@ -105,7 +105,8 @@ namespace DeviceLibrary
case MoveStep.TransplantMove_02: case MoveStep.TransplantMove_02:
if (RFID_1.TryRead(out string rfid, out _) == 1) if (RFID_1.TryRead(out string rfid, out _) == 1)
{ {
if (rfid == "通过") var through = TrayManager.Process(rfid, DeviceGroup.addr_1, out TrayInfo trayInfo);
if (through)
MoveInfo.NextMoveStep(MoveStep.TransplantMove_03); MoveInfo.NextMoveStep(MoveStep.TransplantMove_03);
else if (IOValue(IO_Type.AMH_Reel_Check).Equals(IO_VALUE.HIGH)) else if (IOValue(IO_Type.AMH_Reel_Check).Equals(IO_VALUE.HIGH))
MoveInfo.NextMoveStep(MoveStep.TransplantMove_10); MoveInfo.NextMoveStep(MoveStep.TransplantMove_10);
...@@ -117,11 +118,12 @@ namespace DeviceLibrary ...@@ -117,11 +118,12 @@ namespace DeviceLibrary
{ {
MoveInfo.CanWhileCount--; MoveInfo.CanWhileCount--;
MoveInfo.log($"RFid读取失败,重试第{3 - MoveInfo.CanWhileCount}次"); MoveInfo.log($"RFid读取失败,重试第{3 - MoveInfo.CanWhileCount}次");
MoveInfo.WaitList.Add(WaitResultInfo.WaitMsg("RFid读取失败", MsgLevel.warning));
} }
else else
{ {
MoveInfo.log("RFid读取失败,直接通过"); MoveInfo.log("RFid读取失败,直接通过");
MoveInfo.NextMoveStep(MoveStep.TransplantMove_04); MoveInfo.NextMoveStep(MoveStep.TransplantMove_03);
} }
break; break;
case MoveStep.TransplantMove_03: case MoveStep.TransplantMove_03:
......
...@@ -104,7 +104,8 @@ namespace DeviceLibrary ...@@ -104,7 +104,8 @@ namespace DeviceLibrary
case MoveStep.TrayStop_02: case MoveStep.TrayStop_02:
if (RFID_1.TryRead(out string rfid, out _) == 1) if (RFID_1.TryRead(out string rfid, out _) == 1)
{ {
if (rfid == "通过") var through = TrayManager.Process(rfid, DeviceGroup.addr_1, out TrayInfo trayInfo);
if (through)
MoveInfo.NextMoveStep(MoveStep.TrayStop_03); MoveInfo.NextMoveStep(MoveStep.TrayStop_03);
else else
MoveInfo.NextMoveStep(MoveStep.TrayStop_WaitLoadLeave); MoveInfo.NextMoveStep(MoveStep.TrayStop_WaitLoadLeave);
...@@ -114,6 +115,7 @@ namespace DeviceLibrary ...@@ -114,6 +115,7 @@ namespace DeviceLibrary
{ {
MoveInfo.CanWhileCount--; MoveInfo.CanWhileCount--;
MoveInfo.log($"RFid读取失败,重试第{3 - MoveInfo.CanWhileCount}次"); MoveInfo.log($"RFid读取失败,重试第{3 - MoveInfo.CanWhileCount}次");
MoveInfo.WaitList.Add(WaitResultInfo.WaitMsg("RFid读取失败", MsgLevel.warning));
} }
else else
{ {
......
...@@ -48,6 +48,7 @@ namespace TheMachine ...@@ -48,6 +48,7 @@ namespace TheMachine
configControl1.Config = RobotManage.Config; configControl1.Config = RobotManage.Config;
LogUtil.info("伺服面板加载完成."); LogUtil.info("伺服面板加载完成.");
} }
......
...@@ -42,10 +42,10 @@ namespace TheMachine ...@@ -42,10 +42,10 @@ namespace TheMachine
this.tabP1 = new System.Windows.Forms.TabPage(); this.tabP1 = new System.Windows.Forms.TabPage();
this.pnl = new System.Windows.Forms.Panel(); this.pnl = new System.Windows.Forms.Panel();
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.stateView = new System.Windows.Forms.ListView(); this.stateView = new TheMachine.DoubleBufferListView();
this.listView1 = new TheMachine.DoubleBufferListView();
this.cb_EnableBuzzer = new System.Windows.Forms.CheckBox(); this.cb_EnableBuzzer = new System.Windows.Forms.CheckBox();
this.btn_PauseBuzzer = new System.Windows.Forms.Button(); this.btn_PauseBuzzer = new System.Windows.Forms.Button();
this.listView1 = new System.Windows.Forms.ListView();
this.btn_stop = new System.Windows.Forms.Button(); this.btn_stop = new System.Windows.Forms.Button();
this.btn_run = new System.Windows.Forms.Button(); this.btn_run = new System.Windows.Forms.Button();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
...@@ -161,8 +161,7 @@ namespace TheMachine ...@@ -161,8 +161,7 @@ namespace TheMachine
// pnl // pnl
// //
this.pnl.Controls.Add(this.groupBox1); this.pnl.Controls.Add(this.groupBox1);
this.pnl.Controls.Add(this.cb_EnableBuzzer); this.pnl.Controls.Add(this.listView1);
this.pnl.Controls.Add(this.btn_PauseBuzzer);
this.pnl.Dock = System.Windows.Forms.DockStyle.Fill; this.pnl.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnl.Location = new System.Drawing.Point(0, 0); this.pnl.Location = new System.Drawing.Point(0, 0);
this.pnl.Name = "pnl"; this.pnl.Name = "pnl";
...@@ -172,7 +171,7 @@ namespace TheMachine ...@@ -172,7 +171,7 @@ namespace TheMachine
// groupBox1 // groupBox1
// //
this.groupBox1.Controls.Add(this.stateView); this.groupBox1.Controls.Add(this.stateView);
this.groupBox1.Location = new System.Drawing.Point(3, 4); this.groupBox1.Location = new System.Drawing.Point(776, 336);
this.groupBox1.Name = "groupBox1"; this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(598, 244); this.groupBox1.Size = new System.Drawing.Size(598, 244);
this.groupBox1.TabIndex = 1; this.groupBox1.TabIndex = 1;
...@@ -192,12 +191,27 @@ namespace TheMachine ...@@ -192,12 +191,27 @@ namespace TheMachine
this.stateView.TabIndex = 0; this.stateView.TabIndex = 0;
this.stateView.UseCompatibleStateImageBehavior = false; this.stateView.UseCompatibleStateImageBehavior = false;
// //
// listView1
//
this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.listView1.HideSelection = false;
this.listView1.Location = new System.Drawing.Point(8, 52);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.ShowGroups = false;
this.listView1.Size = new System.Drawing.Size(825, 364);
this.listView1.TabIndex = 2;
this.listView1.UseCompatibleStateImageBehavior = false;
//
// cb_EnableBuzzer // cb_EnableBuzzer
// //
this.cb_EnableBuzzer.AutoSize = true; this.cb_EnableBuzzer.AutoSize = true;
this.cb_EnableBuzzer.Location = new System.Drawing.Point(607, 16); this.cb_EnableBuzzer.Location = new System.Drawing.Point(344, 63);
this.cb_EnableBuzzer.Name = "cb_EnableBuzzer"; this.cb_EnableBuzzer.Name = "cb_EnableBuzzer";
this.cb_EnableBuzzer.Size = new System.Drawing.Size(109, 25); this.cb_EnableBuzzer.Size = new System.Drawing.Size(96, 18);
this.cb_EnableBuzzer.TabIndex = 5; this.cb_EnableBuzzer.TabIndex = 5;
this.cb_EnableBuzzer.Text = "使用蜂鸣器"; this.cb_EnableBuzzer.Text = "使用蜂鸣器";
this.cb_EnableBuzzer.UseVisualStyleBackColor = true; this.cb_EnableBuzzer.UseVisualStyleBackColor = true;
...@@ -206,7 +220,7 @@ namespace TheMachine ...@@ -206,7 +220,7 @@ namespace TheMachine
// btn_PauseBuzzer // btn_PauseBuzzer
// //
this.btn_PauseBuzzer.BackColor = System.Drawing.Color.OrangeRed; this.btn_PauseBuzzer.BackColor = System.Drawing.Color.OrangeRed;
this.btn_PauseBuzzer.Location = new System.Drawing.Point(607, 109); this.btn_PauseBuzzer.Location = new System.Drawing.Point(547, 51);
this.btn_PauseBuzzer.Name = "btn_PauseBuzzer"; this.btn_PauseBuzzer.Name = "btn_PauseBuzzer";
this.btn_PauseBuzzer.Size = new System.Drawing.Size(301, 40); this.btn_PauseBuzzer.Size = new System.Drawing.Size(301, 40);
this.btn_PauseBuzzer.TabIndex = 6; this.btn_PauseBuzzer.TabIndex = 6;
...@@ -215,21 +229,6 @@ namespace TheMachine ...@@ -215,21 +229,6 @@ namespace TheMachine
this.btn_PauseBuzzer.Visible = false; this.btn_PauseBuzzer.Visible = false;
this.btn_PauseBuzzer.Click += new System.EventHandler(this.btn_PauseBuzzer_Click); this.btn_PauseBuzzer.Click += new System.EventHandler(this.btn_PauseBuzzer_Click);
// //
// listView1
//
this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.listView1.HideSelection = false;
this.listView1.Location = new System.Drawing.Point(328, 0);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.ShowGroups = false;
this.listView1.Size = new System.Drawing.Size(680, 118);
this.listView1.TabIndex = 2;
this.listView1.UseCompatibleStateImageBehavior = false;
//
// btn_stop // btn_stop
// //
this.btn_stop.Enabled = false; this.btn_stop.Enabled = false;
...@@ -260,8 +259,9 @@ namespace TheMachine ...@@ -260,8 +259,9 @@ namespace TheMachine
this.BackColor = System.Drawing.Color.White; this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(1008, 729); this.ClientSize = new System.Drawing.Size(1008, 729);
this.Controls.Add(this.tabc); this.Controls.Add(this.tabc);
this.Controls.Add(this.listView1);
this.Controls.Add(this.btn_stop); this.Controls.Add(this.btn_stop);
this.Controls.Add(this.btn_PauseBuzzer);
this.Controls.Add(this.cb_EnableBuzzer);
this.Controls.Add(this.btn_run); this.Controls.Add(this.btn_run);
this.Controls.Add(this.menuStrip1); this.Controls.Add(this.menuStrip1);
this.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
...@@ -276,7 +276,6 @@ namespace TheMachine ...@@ -276,7 +276,6 @@ namespace TheMachine
this.tabc.ResumeLayout(false); this.tabc.ResumeLayout(false);
this.tabP1.ResumeLayout(false); this.tabP1.ResumeLayout(false);
this.pnl.ResumeLayout(false); this.pnl.ResumeLayout(false);
this.pnl.PerformLayout();
this.groupBox1.ResumeLayout(false); this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
...@@ -291,11 +290,11 @@ namespace TheMachine ...@@ -291,11 +290,11 @@ namespace TheMachine
private System.Windows.Forms.TabControl tabc; private System.Windows.Forms.TabControl tabc;
private System.Windows.Forms.ToolStripMenuItem 启用调试模式ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 启用调试模式ToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
private System.Windows.Forms.ListView listView1; private DoubleBufferListView listView1;
private System.Windows.Forms.Button btn_stop; private System.Windows.Forms.Button btn_stop;
private System.Windows.Forms.Button btn_run; private System.Windows.Forms.Button btn_run;
private System.Windows.Forms.TabPage tabP1; private System.Windows.Forms.TabPage tabP1;
private System.Windows.Forms.ListView stateView; private DoubleBufferListView stateView;
private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.ToolStripMenuItem 关于ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 关于ToolStripMenuItem;
private System.Windows.Forms.CheckBox cb_EnableBuzzer; private System.Windows.Forms.CheckBox cb_EnableBuzzer;
......
...@@ -62,6 +62,7 @@ namespace TheMachine ...@@ -62,6 +62,7 @@ namespace TheMachine
//LogControl lc = new LogControl(); //LogControl lc = new LogControl();
IOControls ioc = new IOControls(); IOControls ioc = new IOControls();
TrayManagerControl tmc = new TrayManagerControl();
CycleHYControl<HYControl> hy = new CycleHYControl<HYControl>(); CycleHYControl<HYControl> hy = new CycleHYControl<HYControl>();
CycleHYControl<TransplantControl> yz = new CycleHYControl<TransplantControl>(); CycleHYControl<TransplantControl> yz = new CycleHYControl<TransplantControl>();
CycleHYControl<TrayStopControl> ts = new CycleHYControl<TrayStopControl>(); CycleHYControl<TrayStopControl> ts = new CycleHYControl<TrayStopControl>();
...@@ -93,12 +94,16 @@ namespace TheMachine ...@@ -93,12 +94,16 @@ namespace TheMachine
emptycol.Width = 0; emptycol.Width = 0;
ColumnHeader msgcol = new ColumnHeader(); ColumnHeader msgcol = new ColumnHeader();
msgcol.Text = crc.GetString("Form1_tabc_tabP1_Text","信息"); msgcol.Text = crc.GetString("Form1_tabc_tabP1_Text","信息");
msgcol.Width = 530; msgcol.Width = 700;
ColumnHeader timecol = new ColumnHeader(); ColumnHeader timecol = new ColumnHeader();
timecol.Text = crc.GetString("Res0197","时间"); timecol.Text = crc.GetString("Res0197","时间");
timecol.Width = 150; timecol.Width = 100;
ColumnHeader devicecol = new ColumnHeader();
devicecol.Text = "模块";
devicecol.Width = 100;
listView1.Columns.Add(emptycol); listView1.Columns.Add(emptycol);
listView1.Columns.Add(timecol); listView1.Columns.Add(timecol);
listView1.Columns.Add(devicecol);
listView1.Columns.Add(msgcol); listView1.Columns.Add(msgcol);
listView1.ColumnWidthChanging += listView_ColumnWidthChanging; listView1.ColumnWidthChanging += listView_ColumnWidthChanging;
#endregion #endregion
...@@ -139,7 +144,7 @@ namespace TheMachine ...@@ -139,7 +144,7 @@ namespace TheMachine
RobotManage.Init(); RobotManage.Init();
}); });
ListViewItem lvi = new ListViewItem(new string[] { "", DateTime.Now.ToString(), crc.GetString("Res0200","设备加载中,请稍后...") }); ListViewItem lvi = new ListViewItem(new string[] { "", DateTime.Now.ToString(), "Main",crc.GetString("Res0200","设备加载中,请稍后...") });
lvi.ForeColor = Color.DarkGreen; lvi.ForeColor = Color.DarkGreen;
listView1.Items.Add(lvi); listView1.Items.Add(lvi);
//while (!loadtask.IsCompleted) { //while (!loadtask.IsCompleted) {
...@@ -164,6 +169,7 @@ namespace TheMachine ...@@ -164,6 +169,7 @@ namespace TheMachine
const int tabpagecount = 5; const int tabpagecount = 5;
void addTablePage() { void addTablePage() {
AddForm("tab_io","I/O", ioc); AddForm("tab_io","I/O", ioc);
AddForm("tab_tmc","托盘", tmc);
AddForm("tab_sidemove", hy.DeviceName, hy); AddForm("tab_sidemove", hy.DeviceName, hy);
AddForm("tab_transmove", yz.DeviceName, yz); AddForm("tab_transmove", yz.DeviceName, yz);
AddForm("tab_traystop", ts.DeviceName, ts); AddForm("tab_traystop", ts.DeviceName, ts);
...@@ -173,7 +179,7 @@ namespace TheMachine ...@@ -173,7 +179,7 @@ namespace TheMachine
private void T1_Tick(object sender, EventArgs e) private void T1_Tick(object sender, EventArgs e)
{ {
SetState(MoveInfo.List); //SetState(MoveInfo.List);
} }
void SetState(List<MoveInfo> moveInfoList) void SetState(List<MoveInfo> moveInfoList)
{ {
...@@ -239,17 +245,22 @@ namespace TheMachine ...@@ -239,17 +245,22 @@ namespace TheMachine
} }
public delegate void setmsgdelegate(List<Msg> msgs); public delegate void setmsgdelegate(List<Msg> msgs);
private void MainMachine_ProcessMsgEvent(List<Msg> msgs) private void MsgService_ShowMsg(object sender, Dictionary<string, List<Msg>> e)
{ {
if (msgs == null) if (this.InvokeRequired)
{
this.Invoke((EventHandler)delegate
{
MsgService_ShowMsg(sender, e);
});
return; return;
}
try try
{ {
var d = new setmsgdelegate(SetMsg); SetMsg(e);
this.Invoke(d, msgs);
} }
catch(Exception e) { catch(Exception ex) {
LogUtil.info("MainMachine_ProcessMsgEvent:" + e.ToString()); LogUtil.info("MainMachine_ProcessMsgEvent:" + ex.ToString());
} }
} }
...@@ -270,7 +281,7 @@ namespace TheMachine ...@@ -270,7 +281,7 @@ namespace TheMachine
{ {
btn_run.Enabled = true; btn_run.Enabled = true;
//btn_stop.Enabled = true; //btn_stop.Enabled = true;
RobotManage.mainMachine.ProcessMsgEvent += MainMachine_ProcessMsgEvent; MsgService.ShowMsg += MsgService_ShowMsg;
} }
...@@ -278,6 +289,7 @@ namespace TheMachine ...@@ -278,6 +289,7 @@ namespace TheMachine
yz.Init("SISO"); yz.Init("SISO");
ts.Init("RT"); ts.Init("RT");
ioc.Config = RobotManage.Config; ioc.Config = RobotManage.Config;
tmc.Config = RobotManage.Config;
addTablePage(); addTablePage();
var lm = new List<Msg>(); var lm = new List<Msg>();
...@@ -289,7 +301,7 @@ namespace TheMachine ...@@ -289,7 +301,7 @@ namespace TheMachine
m.msgLevel = state ? MsgLevel.info : MsgLevel.warning; m.msgLevel = state ? MsgLevel.info : MsgLevel.warning;
lm.Add(m); lm.Add(m);
} }
SetMsg(lm); SetMsg(new Dictionary<string, List<Msg>>() { { "root",lm} });
//启用调试模式ToolStripMenuItem.Enabled = true; //启用调试模式ToolStripMenuItem.Enabled = true;
//启用调试模式ToolStripMenuItem_Click(启用调试模式ToolStripMenuItem, EventArgs.Empty); //启用调试模式ToolStripMenuItem_Click(启用调试模式ToolStripMenuItem, EventArgs.Empty);
...@@ -303,10 +315,17 @@ namespace TheMachine ...@@ -303,10 +315,17 @@ namespace TheMachine
}); });
} }
void SetMsg(List<Msg> msgs)
void SetMsg(Dictionary<string, List<Msg>> e)
{ {
this.SuspendLayout(); this.SuspendLayout();
listView1.Items.Clear(); listView1.Items.Clear();
foreach (var k in e.Keys)
{
var msgs = e[k];
msgs.Sort((a, b) => msgs.Sort((a, b) =>
{ {
if (a == null) if (a == null)
...@@ -321,10 +340,10 @@ namespace TheMachine ...@@ -321,10 +340,10 @@ namespace TheMachine
}); });
foreach (Msg msg in msgs) foreach (Msg msg in msgs)
{ {
if (string.IsNullOrEmpty(msg.msgtxt) || msg.datetime==null) if (string.IsNullOrEmpty(msg.msgtxt) || msg.datetime == null)
continue; continue;
ListViewItem lvi = new ListViewItem(new string[] { "", msg.datetime.ToString(), msg.msgtxt }); ListViewItem lvi = new ListViewItem(new string[] { "", msg.datetime.ToString("HH:mm:ss"), k, msg.msgtxt });
if (msg.msgLevel == MsgLevel.info) if (msg.msgLevel == MsgLevel.info)
lvi.ForeColor = Color.DarkGreen; lvi.ForeColor = Color.DarkGreen;
else else
...@@ -332,12 +351,14 @@ namespace TheMachine ...@@ -332,12 +351,14 @@ namespace TheMachine
listView1.Items.Add(lvi); listView1.Items.Add(lvi);
if (msg.errInfo == ErrInfo.X09_BoxNotDetect) if (msg.errInfo == ErrInfo.X09_BoxNotDetect)
{ {
}else if (msg.errInfo == ErrInfo.X09_Clear) }
else if (msg.errInfo == ErrInfo.X09_Clear)
{ {
} }
else if (msg.errInfo == ErrInfo.RunBtn) else if (msg.errInfo == ErrInfo.RunBtn)
{ {
Task.Run(()=> { Task.Run(() =>
{
if (!RobotManage.isRunning) if (!RobotManage.isRunning)
btn_run_Click(this, EventArgs.Empty); btn_run_Click(this, EventArgs.Empty);
}); });
...@@ -345,7 +366,8 @@ namespace TheMachine ...@@ -345,7 +366,8 @@ namespace TheMachine
} }
else if (msg.errInfo == ErrInfo.SuddenStop) else if (msg.errInfo == ErrInfo.SuddenStop)
{ {
Task.Run(()=> { Task.Run(() =>
{
if (RobotManage.isRunning) if (RobotManage.isRunning)
//btn_run_Click(this, EventArgs.Empty); //btn_run_Click(this, EventArgs.Empty);
btn_stop_Click(this, EventArgs.Empty); btn_stop_Click(this, EventArgs.Empty);
...@@ -353,6 +375,7 @@ namespace TheMachine ...@@ -353,6 +375,7 @@ namespace TheMachine
} }
} }
}
this.ResumeLayout(true); this.ResumeLayout(true);
} }
bool userpause = false; bool userpause = false;
...@@ -365,13 +388,13 @@ namespace TheMachine ...@@ -365,13 +388,13 @@ namespace TheMachine
if (RobotManage.mainMachine.IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW)) if (RobotManage.mainMachine.IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW))
{ {
RobotManage.mainMachine.Msg.add("急停中,无法启动", MsgLevel.warning); RobotManage.mainMachine.Msg.add("急停中,无法启动", MsgLevel.warning);
MainMachine_ProcessMsgEvent(RobotManage.mainMachine.Msg.get()); RobotManage.mainMachine.Msg.Show();
return; return;
} }
if (RobotManage.mainMachine.IOValue(IO_Type.AutoRun_Single).Equals(IO_VALUE.LOW)) if (RobotManage.mainMachine.IOValue(IO_Type.AutoRun_Single).Equals(IO_VALUE.LOW))
{ {
RobotManage.mainMachine.Msg.add("运行开关没有打开,无法启动", MsgLevel.warning); RobotManage.mainMachine.Msg.add("运行开关没有打开,无法启动", MsgLevel.warning);
MainMachine_ProcessMsgEvent(RobotManage.mainMachine.Msg.get()); RobotManage.mainMachine.Msg.Show();
return; return;
} }
RobotManage.Start(); RobotManage.Start();
...@@ -521,7 +544,8 @@ namespace TheMachine ...@@ -521,7 +544,8 @@ namespace TheMachine
crc.ProcessListItem(menuStrip1.Items, "menuStrip1"); crc.ProcessListItem(menuStrip1.Items, "menuStrip1");
listView1.Columns[1].Text = crc.GetString("Res0197","时间"); listView1.Columns[1].Text = crc.GetString("Res0197","时间");
listView1.Columns[2].Text = crc.GetString("Form1_tabc_tabP1_Text","信息"); listView1.Columns[2].Text = "模块";
listView1.Columns[3].Text = crc.GetString("Form1_tabc_tabP1_Text","信息");
stateView.Columns[1].Text = crc.GetString("Res0198","模块"); stateView.Columns[1].Text = crc.GetString("Res0198","模块");
stateView.Columns[2].Text = crc.GetString("Res0199","步骤"); stateView.Columns[2].Text = crc.GetString("Res0199","步骤");
......
...@@ -147,6 +147,9 @@ ...@@ -147,6 +147,9 @@
<Compile Include="UC\CylinderButton.cs"> <Compile Include="UC\CylinderButton.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
<Compile Include="UC\DoubleBufferListView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UC\StorePosControl.cs"> <Compile Include="UC\StorePosControl.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
......
...@@ -29,18 +29,44 @@ namespace TheMachine ...@@ -29,18 +29,44 @@ namespace TheMachine
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.listView1 = new TheMachine.DoubleBufferListView();
this.SuspendLayout(); this.SuspendLayout();
// //
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// listView1
//
this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listView1.HideSelection = false;
this.listView1.Location = new System.Drawing.Point(3, 34);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(706, 412);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
//
// TrayManagerControl // TrayManagerControl
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.listView1);
this.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Name = "TrayManagerControl"; this.Name = "TrayManagerControl";
this.Size = new System.Drawing.Size(725, 462); this.Size = new System.Drawing.Size(846, 449);
this.Load += new System.EventHandler(this.TrayManagerControl_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
} }
#endregion #endregion
private DoubleBufferListView listView1;
private System.Windows.Forms.Timer timer1;
} }
} }
using System; using DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
...@@ -12,9 +14,70 @@ namespace TheMachine ...@@ -12,9 +14,70 @@ namespace TheMachine
{ {
public partial class TrayManagerControl : UserControl public partial class TrayManagerControl : UserControl
{ {
Robot_Config _Config;
public Robot_Config Config
{
get { return _Config; }
set
{
_Config = value;
Init();
}
}
public TrayManagerControl() public TrayManagerControl()
{ {
InitializeComponent(); InitializeComponent();
} }
private void TrayManagerControl_Load(object sender, EventArgs e)
{
}
void Init() {
#region listview初始化
var ColList = new string[] { "RFID", "上次地址", "更新时间", "托盘类型", "载荷","目的地" };
listView1.View = View.Details;
foreach (var coltxt in ColList)
{
ColumnHeader col1 = new ColumnHeader();
col1.Text = coltxt;
col1.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
listView1.Columns.Add(col1);
}
#endregion
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (!Visible)
return;
var traylist = TrayManager.Traylist.Values.ToList();
foreach (var ti in traylist) {
var timego = (DateTime.Now - ti.LastUpdateTime);
var lasttime = timego.Seconds + "秒前";
if (timego.Minutes > 0)
lasttime = timego.Minutes + "分 " + lasttime;
if (timego.Hours > 0)
lasttime = timego.Hours + "时 " + lasttime;
var traydesc = TrayManager.TrayTypeDesc[ti.TrayType];
var loaddesc = TrayManager.LoadTypeDesc[ti.LoadType];
var lastaddrdesc = TrayManager.AddrDesc[ti.LastAddr];
var toaddrdesc = TrayManager.AddrDesc[ti.DestinationAddr];
var items = new string[] { ti.RFID, lastaddrdesc.ToString(), lasttime, traydesc, loaddesc, toaddrdesc };
var listviewitem = new ListViewItem();
if (timego.TotalSeconds < 10)
listviewitem.BackColor = Color.DarkGreen;
else if (timego.TotalSeconds > 30)
listviewitem.BackColor = Color.DarkGray;
else
listviewitem.BackColor = Color.Black;
listviewitem.UseItemStyleForSubItems = true;
listviewitem.SubItems.AddRange(items);
}
}
} }
} }
...@@ -117,4 +117,7 @@ ...@@ -117,4 +117,7 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root> </root>
\ No newline at end of file \ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TheMachine
{
public class DoubleBufferListView : System.Windows.Forms.ListView
{
public DoubleBufferListView()
{
// 开启双缓冲
this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
// Enable the OnNotifyMessage event so we get a chance to filter out
// Windows messages before they get to the form's WndProc
this.SetStyle(ControlStyles.EnableNotifyMessage, true);
}
protected override void OnNotifyMessage(Message m)
{
//Filter out the WM_ERASEBKGND message
if (m.Msg != 0x14)
{
base.OnNotifyMessage(m);
}
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!