Commit 61f4e58c 刘韬

1

1 个父辈 8ea5ab94
...@@ -64,10 +64,13 @@ namespace OnlineStore.Common ...@@ -64,10 +64,13 @@ namespace OnlineStore.Common
public static MyConfig<int> URRobot_CI_ListenPort = 31; public static MyConfig<int> URRobot_CI_ListenPort = 31;
[MyConfigComment("VJ点料机串口端口号")] [MyConfigComment("VJ点料机串口端口号")]
public static MyConfig<string> VJCounter_COMPORT = "COM5"; public static MyConfig<string> VJCounter_COMPORT = "COM5";
[MyConfigComment("VJ点料机串口比特率")]
public static MyConfig<int> VJCounter_BaudRate = 115200;
[MyConfigComment("VJ点料机数据共享路径")]
public static MyConfig<string> Device_VJCounterFolder = "\\\\XQUIKII-3679\\Sample Log Directory";
/// <summary> /// <summary>
/// 摄像机名称 /// 摄像机名称
......
...@@ -110,6 +110,7 @@ ...@@ -110,6 +110,7 @@
<Compile Include="DeviceLibrary\RobotMoveHelper.cs" /> <Compile Include="DeviceLibrary\RobotMoveHelper.cs" />
<Compile Include="DeviceLibrary\ServerCommunication.cs" /> <Compile Include="DeviceLibrary\ServerCommunication.cs" />
<Compile Include="DeviceLibrary\AxisBean.cs" /> <Compile Include="DeviceLibrary\AxisBean.cs" />
<Compile Include="DeviceLibrary\ShareFolderWatcher.cs" />
<Compile Include="DeviceLibrary\VJCounter.cs" /> <Compile Include="DeviceLibrary\VJCounter.cs" />
<Compile Include="theMachine\Common.cs" /> <Compile Include="theMachine\Common.cs" />
<Compile Include="theMachine\JobList.cs" /> <Compile Include="theMachine\JobList.cs" />
......
using HalconDotNet;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
public class ShareFolderWatcher : IDisposable
{
Thread thread;
bool run = false;
string backupfolder = "\\image\\VJBackup";
public string FolderName;
public ShareFolderWatcher(string foldername)
{
FolderName = foldername;
Directory.CreateDirectory(backupfolder);
LogUtil.info("[ShareFolderWatcher] " + "set:" + foldername);
}
public bool Start(out string errmsg)
{
errmsg = "";
try
{
if (!Directory.Exists(FolderName))
{
errmsg = $"Directory not exists:{FolderName}";
LogUtil.error("[ShareFolderWatcher] " + errmsg);
return false;
}
}
catch (Exception ex)
{
errmsg = ex.ToString();
LogUtil.error("[ShareFolderWatcher] " + errmsg);
return false;
}
thread = new Thread(new ThreadStart(Watcher));
thread.Start();
LogUtil.error("[ShareFolderWatcher] 文件监听启动成功");
return true;
}
DateTime lastUpdateTime = DateTime.MinValue;
Dictionary<string, int> CountList = new Dictionary<string, int>();
public DateTime LastUpdateTime { get => lastUpdateTime; }
public int LastQty = 0;
public string LastSN = "";
void Watcher()
{
run = true;
while (run)
{
Thread.Sleep(1000);
try
{
DirectoryInfo directoryInfo = new DirectoryInfo(FolderName);
var fis = directoryInfo.GetFiles("*.csv").Where(x => x.LastWriteTime > lastUpdateTime).ToList();
fis.Sort((a, b) => b.LastWriteTime.CompareTo(a.LastWriteTime));
if (fis.Count > 0)
lastUpdateTime = fis[0].LastWriteTime;
else
continue;
lock (CountList)
{
foreach (var fi in fis)
{
var file = fi.FullName;
var localfile = Path.Combine(backupfolder, Path.GetFileName(file));
File.Copy(file, localfile, true);
try
{
File.Delete(file);
}
catch (Exception ex) {
LogUtil.error("[ShareFolderWatcher] " + ex.ToString());
}
var ft = File.ReadAllLines(localfile);
if (ft.Length >= 2 && !string.IsNullOrWhiteSpace(ft[1]))
{
var datas = ft[1].Split(',');
if (datas.Length == 3 && int.TryParse(datas[2], out int qty))
{
LogUtil.info($"读取到VJ点料结果:{datas[1]},{qty}");
if (!CountList.ContainsKey(datas[1]))
CountList.Add(datas[1], qty);
else
CountList[datas[1]] = qty;
LastQty = qty;
LastSN = datas[1];
}
}
}
}
}
catch (Exception ex)
{
LogUtil.error("[ShareFolderWatcher] " + ex.ToString());
}
}
}
public bool GetQty(string barcode, out int qty)
{
if (barcode.Count(c => c == '#') == 3)
{
barcode = barcode.Split('#')[1].Substring(1);
}
lock (CountList)
{
if (CountList.TryGetValue(barcode, out qty))
{
CountList.Remove(barcode);
return true;
}
}
qty = 0;
return false;
}
public void Dispose()
{
run = false;
}
}
...@@ -16,17 +16,32 @@ namespace DeviceLibrary ...@@ -16,17 +16,32 @@ namespace DeviceLibrary
private static StopBits stopBits = StopBits.One; //停止位 private static StopBits stopBits = StopBits.One; //停止位
private static SerialPort _serialPort = null; private static SerialPort _serialPort = null;
public static string newline="\n";
static string comPortName; static string comPortName;
public static bool Connect(string _comport, out string msg) { public static bool Connect(string _comport,int _baudRate, out string msg) {
msg = ""; msg = "";
try try
{ {
try
{
if (_serialPort != null && _serialPort.IsOpen)
{
_serialPort.Close();
_serialPort.Dispose();
_serialPort = null;
}
}catch (Exception ex)
{
LogUtil.error($"VJCounter: "+ex);
}
comPortName = _comport; comPortName = _comport;
baudRate = _baudRate;
_serialPort = new SerialPort(comPortName, baudRate, parity, dataBits, stopBits); _serialPort = new SerialPort(comPortName, baudRate, parity, dataBits, stopBits);
//_serialPort.RtsEnable = true; //自动请求 //_serialPort.RtsEnable = true; //自动请求
//_serialPort.ReadTimeout = 100;//超时 //_serialPort.ReadTimeout = 100;//超时
_serialPort.Open(); _serialPort.Open();
LogUtil.info("VJCounter: 串口连接成功"); LogUtil.info($"VJCounter: 串口连接成功 comPortName:{comPortName},baudRate:{baudRate}");
return true; return true;
}catch (Exception ex) }catch (Exception ex)
{ {
...@@ -40,19 +55,20 @@ namespace DeviceLibrary ...@@ -40,19 +55,20 @@ namespace DeviceLibrary
{ {
if (_serialPort == null) if (_serialPort == null)
{ {
return Connect(comPortName,out _); return Connect(comPortName,baudRate,out _);
} }
else if (!_serialPort.IsOpen) else if (!_serialPort.IsOpen)
{ {
_serialPort = null; _serialPort = null;
return Connect(comPortName, out _); return Connect(comPortName, baudRate, out _);
} }
else else
return true; return true;
} }
public static void SendBarcode(string barcode) { public static void SendBarcode(string barcode) {
var b = Encoding.ASCII.GetBytes(barcode + "\n"); var b = Encoding.ASCII.GetBytes(barcode);
_serialPort.Write(b, 0, b.Length); _serialPort.Write(b, 0, b.Length);
_serialPort.BaseStream.Flush();
LogUtil.info("VJCounter: 串口发送:"+ barcode); LogUtil.info("VJCounter: 串口发送:"+ barcode);
} }
} }
......
...@@ -252,9 +252,9 @@ namespace DeviceLibrary ...@@ -252,9 +252,9 @@ namespace DeviceLibrary
//} //}
//LastProcessErrorTimes++; //LastProcessErrorTimes++;
Msg.add($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}", MsgLevel.warning); Msg.add($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}", MsgLevel.warning);
//RTStoreStatus = RTStoreStatus.InStoreError; RTStoreStatus = RTStoreStatus.Offline;
//ServerCM.storeStatus = StoreStatus.InStoreFaild; TerminalError = false;
//ServerCM.storeStatus = StoreStatus.None;
} }
else if (ti.StatusCode < 10000) else if (ti.StatusCode < 10000)
...@@ -296,6 +296,8 @@ namespace DeviceLibrary ...@@ -296,6 +296,8 @@ namespace DeviceLibrary
310234,Error clamping on opening (234) 310234,Error clamping on opening (234)
*/ */
//统计剩余容量 //统计剩余容量
if (ti != null)
{
string capacity = ""; string capacity = "";
for (int i = 0; i < ti.Slots.Count; i++) for (int i = 0; i < ti.Slots.Count; i++)
{ {
...@@ -318,11 +320,12 @@ namespace DeviceLibrary ...@@ -318,11 +320,12 @@ namespace DeviceLibrary
int.TryParse(sn.Substring(2), out h); int.TryParse(sn.Substring(2), out h);
} }
//boxStatus.data.Add("capacity", "7X8=1000;7X12=345;13X32=100;"); //boxStatus.data.Add("capacity", "7X8=1000;7X12=345;13X32=100;");
capacity += $"{w}X{h}={ti.Slots[i].Slots_free- ti.Slots[i].Slots_used};"; capacity += $"{w}X{h}={ti.Slots[i].Slots_free - ti.Slots[i].Slots_used};";
SlotsInfo[$"{w}X{h}"] = $"{ti.Slots[i].Slots_used}/{ti.Slots[i].Slots_free}"; SlotsInfo[$"{w}X{h}"] = $"{ti.Slots[i].Slots_used}/{ti.Slots[i].Slots_free}";
} }
ServerCM.capacity = capacity; ServerCM.capacity = capacity;
} }
}
catch (Exception ex) catch (Exception ex)
{ {
ServerCM.storeStatus = StoreStatus.None; ServerCM.storeStatus = StoreStatus.None;
......
...@@ -60,6 +60,7 @@ namespace DeviceLibrary ...@@ -60,6 +60,7 @@ namespace DeviceLibrary
TrayManager.Init(DeviceGroup); TrayManager.Init(DeviceGroup);
MI.Init(Config, DeviceGroup, out m); MI.Init(Config, DeviceGroup, out m);
CI.Init(Config, DeviceGroup, out m);
msg += m; msg += m;
#region 初始化led #region 初始化led
RunningLed = new Led(Config.DOList["root"][IO_Type.Run_Led].GetIOAddr(), LedColor.green); RunningLed = new Led(Config.DOList["root"][IO_Type.Run_Led].GetIOAddr(), LedColor.green);
...@@ -163,6 +164,7 @@ namespace DeviceLibrary ...@@ -163,6 +164,7 @@ namespace DeviceLibrary
TransplantMove.DeviceList.Values.ToList().ForEach(s => s.Stop()); TransplantMove.DeviceList.Values.ToList().ForEach(s => s.Stop());
TrayStop.DeviceList.Values.ToList().ForEach(s => s.Stop()); TrayStop.DeviceList.Values.ToList().ForEach(s => s.Stop());
MI.DeviceList.Values.ToList().ForEach(s => s.Stop()); MI.DeviceList.Values.ToList().ForEach(s => s.Stop());
CI.DeviceList.Values.ToList().ForEach(s => s.Stop());
IOMove(IO_Type.Line_Run, IO_VALUE.LOW); IOMove(IO_Type.Line_Run, IO_VALUE.LOW);
ResetEvent.Set(); ResetEvent.Set();
Alarm(AlarmType.None); Alarm(AlarmType.None);
...@@ -183,6 +185,7 @@ namespace DeviceLibrary ...@@ -183,6 +185,7 @@ namespace DeviceLibrary
TransplantMove.DeviceList.Values.ToList().ForEach(s => s.Start()); TransplantMove.DeviceList.Values.ToList().ForEach(s => s.Start());
TrayStop.DeviceList.Values.ToList().ForEach(s => s.Start()); TrayStop.DeviceList.Values.ToList().ForEach(s => s.Start());
MI.DeviceList.Values.ToList().ForEach(s => s.Start()); MI.DeviceList.Values.ToList().ForEach(s => s.Start());
CI.DeviceList.Values.ToList().ForEach(s => s.Start());
} }
......
...@@ -40,6 +40,7 @@ namespace DeviceLibrary ...@@ -40,6 +40,7 @@ namespace DeviceLibrary
public static URRobotControl Robot_CI; public static URRobotControl Robot_CI;
public static VStoreCollection VStoreCollection; public static VStoreCollection VStoreCollection;
public static ShareFolderWatcher folderWatcher;
public static void Init() { public static void Init() {
string msg = ""; string msg = "";
try try
...@@ -60,6 +61,14 @@ namespace DeviceLibrary ...@@ -60,6 +61,14 @@ namespace DeviceLibrary
msg += crc.GetString("Res0180", "找不到库位配置文件") + "\n"; msg += crc.GetString("Res0180", "找不到库位配置文件") + "\n";
} }
folderWatcher = new ShareFolderWatcher(Setting_Init.Device_VJCounterFolder);
if (!folderWatcher.Start(out string errmsg))
{
IsLoadOk = false;
msg += errmsg + "\n";
LogUtil.error("ShareFolderWatcher:"+errmsg);
}
string MI1PostionFile = "config\\MI1Postion.csv"; string MI1PostionFile = "config\\MI1Postion.csv";
string MI2PostionFile = "config\\MI2Postion.csv"; string MI2PostionFile = "config\\MI2Postion.csv";
string CIPostionFile = "config\\CIPostion.csv"; string CIPostionFile = "config\\CIPostion.csv";
...@@ -93,7 +102,7 @@ namespace DeviceLibrary ...@@ -93,7 +102,7 @@ namespace DeviceLibrary
msg += crc.GetString("Res0181", "IO板卡初始化失败") + "\n"; msg += crc.GetString("Res0181", "IO板卡初始化失败") + "\n";
} }
if (!VJCounter.Connect(Setting_Init.VJCounter_COMPORT, out string msgs)) { if (!VJCounter.Connect(Setting_Init.VJCounter_COMPORT, Setting_Init.VJCounter_BaudRate, out string msgs)) {
IsLoadOk = false; IsLoadOk = false;
msg += crc.GetString("Res0111.43f91cee","VJ点料机连接失败") + "\n"; msg += crc.GetString("Res0111.43f91cee","VJ点料机连接失败") + "\n";
LogUtil.error(msg + "," + msgs); LogUtil.error(msg + "," + msgs);
...@@ -103,6 +112,7 @@ namespace DeviceLibrary ...@@ -103,6 +112,7 @@ namespace DeviceLibrary
DeviceRunControl.AddDevice("TransplantMove", TransplantMove.DeviceList.Values.ToList<IDevice>()); DeviceRunControl.AddDevice("TransplantMove", TransplantMove.DeviceList.Values.ToList<IDevice>());
//DeviceRunControl.AddDevice("TrayStop", TrayStop.DeviceList.Values.ToList<IDevice>()); //DeviceRunControl.AddDevice("TrayStop", TrayStop.DeviceList.Values.ToList<IDevice>());
DeviceRunControl.AddDevice("MI", MI.DeviceList.Values.ToList<IDevice>()); DeviceRunControl.AddDevice("MI", MI.DeviceList.Values.ToList<IDevice>());
DeviceRunControl.AddDevice("CI", CI.DeviceList.Values.ToList<IDevice>());
TrayStop.DeviceList.Values.ToList<IDevice>().ForEach(device => { DeviceRunControl.AddDevice(device.GroupName, new List<IDevice>() { device }); }); TrayStop.DeviceList.Values.ToList<IDevice>().ForEach(device => { DeviceRunControl.AddDevice(device.GroupName, new List<IDevice>() { device }); });
if (G.simulate) if (G.simulate)
......
...@@ -95,7 +95,7 @@ namespace DeviceLibrary ...@@ -95,7 +95,7 @@ namespace DeviceLibrary
static void SaveTrayInfo() { static void SaveTrayInfo() {
try try
{ {
var TL = Traylist.Where(t => t.Value.DestinationAddr >= 0).ToDictionary(a => a.Key, a => a.Value); var TL = Traylist.Where(t => t.Value.RFID!=null && t.Value.DestinationAddr >= 0).ToDictionary(a => a.Key, a => a.Value);
ConfigHelper.Config.FileSave(JsonConvert.SerializeObject(TL), "Config\\TrayList.temp~"); ConfigHelper.Config.FileSave(JsonConvert.SerializeObject(TL), "Config\\TrayList.temp~");
ConfigHelper.Config.FileSave(JsonConvert.SerializeObject(TL), "Config\\TrayList.temp"); ConfigHelper.Config.FileSave(JsonConvert.SerializeObject(TL), "Config\\TrayList.temp");
} }
...@@ -235,7 +235,7 @@ namespace DeviceLibrary ...@@ -235,7 +235,7 @@ namespace DeviceLibrary
else { else {
SetTrayLoadInfo(device.CurrrentRFID, requestLoadInfo); SetTrayLoadInfo(device.CurrrentRFID, requestLoadInfo);
} }
LogUtil.info("释放设备:"+device.GroupName); LogUtil.info("释放设备:"+device.GroupName+","+ device.CurrrentRFID);
device.TrayRelease(); device.TrayRelease();
} }
} }
...@@ -287,7 +287,7 @@ namespace DeviceLibrary ...@@ -287,7 +287,7 @@ namespace DeviceLibrary
public static bool IsNeedProcessNG(RemoteLoad remoteLoad) public static bool IsNeedProcessNG(RemoteLoad remoteLoad)
{ {
var requestLoadInfo = remoteLoad.RequestLoadInfo; var requestLoadInfo = remoteLoad.RequestLoadInfo;
var xx = TrayManager.Traylist.Values.ToList().Where(t => t.HasLoad && t.LoadType == requestLoadInfo.GetTrayType && t.DestinationAddr==3 && (t.LastAddr >= 20 || t.LastAddr <= 3)); var xx = TrayManager.Traylist.Values.ToList().Where(t =>t.RFID!=null && t.HasLoad && t.LoadType == requestLoadInfo.GetTrayType && t.DestinationAddr==3 && (t.LastAddr >= 20 || t.LastAddr <= 3));
return xx.Count() > 0; return xx.Count() > 0;
} }
...@@ -347,10 +347,13 @@ namespace DeviceLibrary ...@@ -347,10 +347,13 @@ namespace DeviceLibrary
public string RFID { get => _rfid; set { public string RFID { get => _rfid; set {
try try
{ {
if (value != null)
{
var ss = Enum.GetNames(typeof(TrayTypeE)); var ss = Enum.GetNames(typeof(TrayTypeE));
TrayType = (TrayTypeE)Enum.Parse(typeof(TrayTypeE), ss.ToList().Find(s => value.StartsWith(s))); TrayType = (TrayTypeE)Enum.Parse(typeof(TrayTypeE), ss.ToList().Find(s => value.StartsWith(s)));
_rfid = value; _rfid = value;
} }
}
catch (Exception ex) { catch (Exception ex) {
LogUtil.error($"获取RFID的类型时出错:{value}"); LogUtil.error($"获取RFID的类型时出错:{value}");
} }
......
...@@ -149,7 +149,7 @@ namespace DeviceLibrary ...@@ -149,7 +149,7 @@ namespace DeviceLibrary
CurrrentRFID = Common.RfidFilter(data); CurrrentRFID = Common.RfidFilter(data);
TrayManager.Process(MoveInfo, CurrrentRFID, DeviceGroup.addr_1, IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.HIGH)?1:0, out TrayInfo trayInfo); TrayManager.Process(MoveInfo, CurrrentRFID, DeviceGroup.addr_1, IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.HIGH)?1:0, out TrayInfo trayInfo);
var stop = TrayManager.TryGetTrayRequest(GroupName, CurrrentRFID, out _); var stop = TrayManager.TryGetTrayRequest(GroupName, CurrrentRFID, out _);
MoveInfo.log($"CurrrentRFID:{CurrrentRFID},HasLoad:{trayInfo.HasLoad},MI_Reel_Check:{IOValue(IO_Type.MI_Reel_Check)},NeedStop:{stop}"); MoveInfo.log($"CurrrentRFID:{CurrrentRFID},HasLoad:{trayInfo.HasLoad},MI_Reel_Check:{IOValue(IO_Type.MI_Reel_Check)},NeedStop:{stop},GroupName:{GroupName},TrayType:{trayInfo.TrayType}");
#region MI1,Mi2的情况判断 #region MI1,Mi2的情况判断
if ((GroupName == "AMH-MI1" || GroupName == "AMH-MI2") && trayInfo.TrayType == TrayTypeE.MTP1) if ((GroupName == "AMH-MI1" || GroupName == "AMH-MI2") && trayInfo.TrayType == TrayTypeE.MTP1)
{ {
...@@ -245,15 +245,17 @@ namespace DeviceLibrary ...@@ -245,15 +245,17 @@ namespace DeviceLibrary
MoveInfo.NextMoveStep(MoveStep.TrayStop_04); MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
return; return;
} }
else if (GroupName == "CI" && trayInfo.TrayType == TrayTypeE.MTP1) { else if (GroupName == "CI" && trayInfo.TrayType == TrayTypeE.MTP1)
{
MoveInfo.log($"在CI设备:{trayInfo.DestinationAddr}=={DeviceGroup.addr_1}");
var device = CI.DeviceList[GroupName]; var device = CI.DeviceList[GroupName];
if (!device.ManualCount) if (!device.ManualCount)
{ {
MoveInfo.log($"点料机当前不可用,NG处理"); MoveInfo.log($"点料机当前不可用,NG处理");
RequestLoadInfo RequestLoadInfo = new RequestLoadInfo(); RequestLoadInfo RequestLoadInfo = new RequestLoadInfo();
RequestLoadInfo.LoadParam = trayInfo.TrayParam.clone(); RequestLoadInfo.LoadParam = trayInfo.TrayParam.clone();
RequestLoadInfo.LoadParam.IsNg=true; RequestLoadInfo.LoadParam.IsNg = true;
RequestLoadInfo.LoadParam.NgMsg="XRay not enable"; RequestLoadInfo.LoadParam.NgMsg = "XRay not enable";
RequestLoadInfo.DeviceGroupName = "AMH-MI2"; RequestLoadInfo.DeviceGroupName = "AMH-MI2";
RequestLoadInfo.TrayType = trayInfo.TrayType.ToString(); RequestLoadInfo.TrayType = trayInfo.TrayType.ToString();
RequestLoadInfo.IsEmpty = false; RequestLoadInfo.IsEmpty = false;
...@@ -262,11 +264,24 @@ namespace DeviceLibrary ...@@ -262,11 +264,24 @@ namespace DeviceLibrary
MoveInfo.NextMoveStep(MoveStep.TrayStop_03); MoveInfo.NextMoveStep(MoveStep.TrayStop_03);
return; return;
} }
if (!trayInfo.HasLoad && IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.LOW))
{
MoveInfo.log("开始处理出料");
MoveInfo.NextMoveStep(MoveStep.TrayStop_07);
//请求的空托盘到达时
if (!device.HasJob(null))
MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
else else
{ {
MoveInfo.NextMoveStep(MoveStep.TrayStop_07); MoveInfo.NextMoveStep(MoveStep.TrayStop_07);
//device.StartOutStore();
}
}
else if (trayInfo.DestinationAddr == DeviceGroup.addr_1 && trayInfo.HasLoad)
{
MoveInfo.log("开始处理入料");
//抵达了一个有物料的托盘等待处理 //抵达了一个有物料的托盘等待处理
if (!device.HasJob(trayInfo.TrayParam)) if (!device.HasJob(trayInfo.TrayParam))
MoveInfo.NextMoveStep(MoveStep.TrayStop_04); MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
else else
...@@ -275,6 +290,10 @@ namespace DeviceLibrary ...@@ -275,6 +290,10 @@ namespace DeviceLibrary
device.StartInStore(trayInfo.TrayParam); device.StartInStore(trayInfo.TrayParam);
} }
} }
else
MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
return;
} }
#endregion #endregion
if (stop && !trayInfo.HasLoad && IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.LOW)) if (stop && !trayInfo.HasLoad && IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.LOW))
......
...@@ -163,6 +163,7 @@ ...@@ -163,6 +163,7 @@
this.lblAlarmcode.Tag = "not"; this.lblAlarmcode.Tag = "not";
this.lblAlarmcode.Text = "ErrCode:160"; this.lblAlarmcode.Text = "ErrCode:160";
this.lblAlarmcode.Visible = false; this.lblAlarmcode.Visible = false;
this.lblAlarmcode.Click += new System.EventHandler(this.lblAlarmcode_Click);
// //
// label4 // label4
// //
......
...@@ -445,5 +445,11 @@ namespace DeviceLibrary ...@@ -445,5 +445,11 @@ namespace DeviceLibrary
lbl.BackColor = this.BackColor; lbl.BackColor = this.BackColor;
} }
} }
private void lblAlarmcode_Click(object sender, EventArgs e)
{
MessageBox.Show(string.Join(",", HuichuanLibrary.HCBoardManager.GetAxisErrorDetail(currentAxis.Config.GetAxisValue())));
}
} }
} }
\ No newline at end of file \ No newline at end of file
using ConfigHelper; using ConfigHelper;
using Newtonsoft.Json; using Newtonsoft.Json;
using OnlineStore; using OnlineStore;
using OnlineStore.Common;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Text; using System.Text;
...@@ -34,9 +36,26 @@ namespace RemoteSheardObject ...@@ -34,9 +36,26 @@ namespace RemoteSheardObject
{"locInfo", locInfo} {"locInfo", locInfo}
}; };
return !string.IsNullOrEmpty(SubmitPostData("/service/store/robotBox/updateLocInfo", postData)); return !string.IsNullOrEmpty(SubmitPostData("/service/store/robotBox/updateLocInfo", postData, out _));
} }
public static bool UpdateReelQty(string barcode, int qty)
{
if (barcode.Count(c => c == '#') == 3)
{
barcode = barcode.Split('#')[1].Substring(1);
}
var postData = new Dictionary<string, string>()
{
{"barcode", barcode},
{"qty", qty.ToString()}
};
var data = SubmitPostData("/rest/micron/device/updateReelQty", postData, out string msg);
LogUtil.info("UpdateReelQty:"+data);
if (string.IsNullOrEmpty(data))
LogUtil.info("UpdateReelQty:" + msg);
return !string.IsNullOrEmpty(data);
}
public static bool emptyOut(string barcode) public static bool emptyOut(string barcode)
{ {
//料盘空出后直接结束任务 //料盘空出后直接结束任务
...@@ -49,7 +68,7 @@ namespace RemoteSheardObject ...@@ -49,7 +68,7 @@ namespace RemoteSheardObject
{ {
{"barcode", barcode} {"barcode", barcode}
}; };
return !string.IsNullOrEmpty(SubmitPostData("/service/store/robotBox/emptyOut", postData)); return !string.IsNullOrEmpty(SubmitPostData("/service/store/robotBox/emptyOut", postData, out _));
} }
/// <summary> /// <summary>
/// 获取正在进行的任务数量 /// 获取正在进行的任务数量
...@@ -67,7 +86,7 @@ namespace RemoteSheardObject ...@@ -67,7 +86,7 @@ namespace RemoteSheardObject
taskdata["tray"] = 0; taskdata["tray"] = 0;
taskdata["reel"] = 0; taskdata["reel"] = 0;
var result= JsonConvert.DeserializeObject<ResultData>(SubmitPostData("/rest/micron/device/getTaskCount", postData)); var result= JsonConvert.DeserializeObject<ResultData>(SubmitPostData("/rest/micron/device/getTaskCount", postData, out _));
if (result==null || result.code != 0) if (result==null || result.code != 0)
return taskdata; return taskdata;
...@@ -107,7 +126,7 @@ namespace RemoteSheardObject ...@@ -107,7 +126,7 @@ namespace RemoteSheardObject
{ {
{"barcode", barcode}, {"barcode", barcode},
}; };
var result = SubmitPostData( "/service/store/robotBox/getSize", postData); var result = SubmitPostData( "/service/store/robotBox/getSize", postData, out _);
if (result != null) if (result != null)
return JsonConvert.DeserializeObject<T>(result); return JsonConvert.DeserializeObject<T>(result);
else else
...@@ -147,7 +166,7 @@ namespace RemoteSheardObject ...@@ -147,7 +166,7 @@ namespace RemoteSheardObject
{"ngPos",ngPos.ToString() } {"ngPos",ngPos.ToString() }
}; };
string url = "/rest/micron/device/clearNgPos"; string url = "/rest/micron/device/clearNgPos";
var resultStr = SubmitPostData(url, postData); var resultStr = SubmitPostData(url, postData, out _);
} }
/// <summary> /// <summary>
/// 上传自定义数据 /// 上传自定义数据
...@@ -162,7 +181,7 @@ namespace RemoteSheardObject ...@@ -162,7 +181,7 @@ namespace RemoteSheardObject
{"value",value } {"value",value }
}; };
string url = "/rest/micron/device/updateData"; string url = "/rest/micron/device/updateData";
var resultStr = SubmitPostData(url, postData); var resultStr = SubmitPostData(url, postData, out _);
} }
/// <summary> /// <summary>
/// 上传自定义数据 /// 上传自定义数据
...@@ -176,7 +195,7 @@ namespace RemoteSheardObject ...@@ -176,7 +195,7 @@ namespace RemoteSheardObject
{"key",key} {"key",key}
}; };
string url = "/rest/micron/device/getData"; string url = "/rest/micron/device/getData";
var resultStr = SubmitPostData(url, postData); var resultStr = SubmitPostData(url, postData, out _);
var r= JsonConvert.DeserializeObject<ResultData2>(resultStr); var r= JsonConvert.DeserializeObject<ResultData2>(resultStr);
if (!string.IsNullOrWhiteSpace(r.data)) { if (!string.IsNullOrWhiteSpace(r.data)) {
return r.data; return r.data;
...@@ -201,8 +220,9 @@ namespace RemoteSheardObject ...@@ -201,8 +220,9 @@ namespace RemoteSheardObject
public Dictionary<string, object> data { get; set; } public Dictionary<string, object> data { get; set; }
} }
public static string SubmitPostData(string url, Dictionary<string, string> postData) public static string SubmitPostData(string url, Dictionary<string, string> postData,out string msg)
{ {
msg = "";
url = CombineUrl(Config.Get("Device_Server_Address"), url); url = CombineUrl(Config.Get("Device_Server_Address"), url);
//创建WebClient对象 //创建WebClient对象
using (var client = new WebClient()) using (var client = new WebClient())
...@@ -226,6 +246,7 @@ namespace RemoteSheardObject ...@@ -226,6 +246,7 @@ namespace RemoteSheardObject
if (postDataString.Length>0) if (postDataString.Length>0)
postDataString.Length--; postDataString.Length--;
msg += postDataString;
//将POST请求参数转换为字节数组 //将POST请求参数转换为字节数组
byte[] bytes = Encoding.UTF8.GetBytes(postDataString.ToString()); byte[] bytes = Encoding.UTF8.GetBytes(postDataString.ToString());
...@@ -240,8 +261,10 @@ namespace RemoteSheardObject ...@@ -240,8 +261,10 @@ namespace RemoteSheardObject
{ {
// 捕获任何网络异常,并输出错误信息 // 捕获任何网络异常,并输出错误信息
//Console.WriteLine(crc.GetString("Res0071","提交POST请求时发生错误:") + ex.Message); //Console.WriteLine(crc.GetString("Res0071","提交POST请求时发生错误:") + ex.Message);
msg += "\r\n提交POST请求时发生错误:"+ex.Message;
// 请求失败,返回false // 请求失败,返回false
Debug.WriteLine(url);
Debug.WriteLine(ex);
return ""; return "";
} }
} }
...@@ -259,7 +282,11 @@ namespace RemoteSheardObject ...@@ -259,7 +282,11 @@ namespace RemoteSheardObject
var barcode = reelParam.WareCode; var barcode = reelParam.WareCode;
if (barcode.Count(c => c == '#') == 3) if (barcode.Count(c => c == '#') == 3)
{ {
barcode = barcode.Split('#')[1].Substring(1); var bs = barcode.Split('#');
reelParam.RI = bs[1].Substring(1);
reelParam.PN = bs[0].Substring(1);
reelParam.DC = bs[2];
barcode = bs[1].Substring(1);
} }
try try
{ {
...@@ -271,7 +298,7 @@ namespace RemoteSheardObject ...@@ -271,7 +298,7 @@ namespace RemoteSheardObject
else //不包含 AMH-SBDH3-1 else //不包含 AMH-SBDH3-1
nameValue.Add("cids", "AMH-SBDH3-1,AMH-SBDH3-2,AMH-SBSH1,AMH-SBSH2,AMH-SBDH2-1,AMH-SBDH2-2,AMH-SBDH1-1,AMH-SBDH1-2,003040,003048,003039,003043,003035,003036,003041,003042"); nameValue.Add("cids", "AMH-SBDH3-1,AMH-SBDH3-2,AMH-SBSH1,AMH-SBSH2,AMH-SBDH2-1,AMH-SBDH2-2,AMH-SBDH1-1,AMH-SBDH1-2,003040,003048,003039,003043,003035,003036,003041,003042");
var data = SubmitPostData("/service/store/robotBox/renewPosForPutin", nameValue); var data = SubmitPostData("/service/store/robotBox/renewPosForPutin", nameValue, out _);
msg += "Regetposid code: " + reelParam.WareCode + ",preCid: " + reelParam.cid + ",cids:" + nameValue["cids"] + ",Result: " + data + "\r\n"; msg += "Regetposid code: " + reelParam.WareCode + ",preCid: " + reelParam.cid + ",cids:" + nameValue["cids"] + ",Result: " + data + "\r\n";
emptyPosForPutin result = JsonConvert.DeserializeObject<emptyPosForPutin>(data); emptyPosForPutin result = JsonConvert.DeserializeObject<emptyPosForPutin>(data);
......
...@@ -260,6 +260,7 @@ ...@@ -260,6 +260,7 @@
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Form1.resx"> <EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>Form1.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="IOControls.resx"> <EmbeddedResource Include="IOControls.resx">
<DependentUpon>IOControls.cs</DependentUpon> <DependentUpon>IOControls.cs</DependentUpon>
......
...@@ -123,6 +123,9 @@ namespace TheMachine ...@@ -123,6 +123,9 @@ namespace TheMachine
reelid = ti.TrayParam?.WareCode; reelid = ti.TrayParam?.WareCode;
var items = new string[] {lastaddrdesc.ToString(), lasttime, traydesc, loaddesc, toaddrdesc, reelid }; var items = new string[] {lastaddrdesc.ToString(), lasttime, traydesc, loaddesc, toaddrdesc, reelid };
if (string.IsNullOrEmpty(ti.RFID))
continue;
if (listView1.Items.ContainsKey(ti.RFID)) if (listView1.Items.ContainsKey(ti.RFID))
{ {
while (listView1.Items[ti.RFID].SubItems.Count > 1) while (listView1.Items[ti.RFID].SubItems.Count > 1)
...@@ -189,6 +192,7 @@ namespace TheMachine ...@@ -189,6 +192,7 @@ namespace TheMachine
txt += "\r\n"+crc.GetString("Res0021","托盘类型") + ": " + listView1.SelectedItems[0].SubItems[2].Text; txt += "\r\n"+crc.GetString("Res0021","托盘类型") + ": " + listView1.SelectedItems[0].SubItems[2].Text;
txt += "\r\n"+crc.GetString("Res0055","物料") + ": " + listView1.SelectedItems[0].SubItems[3].Text; txt += "\r\n"+crc.GetString("Res0055","物料") + ": " + listView1.SelectedItems[0].SubItems[3].Text;
txt += "\r\n"+crc.GetString("Res0023","目的地") + ": " + listView1.SelectedItems[0].SubItems[4].Text; txt += "\r\n"+crc.GetString("Res0023","目的地") + ": " + listView1.SelectedItems[0].SubItems[4].Text;
if (listView1.SelectedItems[0].SubItems.Count>6)
txt += "\r\n"+"Code" + ": " + listView1.SelectedItems[0].SubItems[6].Text; txt += "\r\n"+"Code" + ": " + listView1.SelectedItems[0].SubItems[6].Text;
if (ti.HasLoad && ti.TrayParam.IsNg) { if (ti.HasLoad && ti.TrayParam.IsNg) {
txt += "\r\n" + "NgMsg" + ": " + ti.TrayParam.NgMsg; txt += "\r\n" + "NgMsg" + ": " + ti.TrayParam.NgMsg;
......
...@@ -35,12 +35,21 @@ ...@@ -35,12 +35,21 @@
this.label_barcode = new System.Windows.Forms.Label(); this.label_barcode = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components); this.timer1 = new System.Windows.Forms.Timer(this.components);
this.cb_manualcount = new System.Windows.Forms.CheckBox(); this.cb_manualcount = new System.Windows.Forms.CheckBox();
this.btn_finishcount = new System.Windows.Forms.Button();
this.label_watchstatus = new System.Windows.Forms.Label();
this.btn_manualsend = new System.Windows.Forms.Button();
this.cb_com = new System.Windows.Forms.ComboBox();
this.cb_bitrate = new System.Windows.Forms.ComboBox();
this.btn_reopen = new System.Windows.Forms.Button();
this.button_start = new System.Windows.Forms.Button();
this.cb_enter = new System.Windows.Forms.CheckBox();
this.cb_newline = new System.Windows.Forms.CheckBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// label_status // label_status
// //
this.label_status.AutoSize = true; this.label_status.AutoSize = true;
this.label_status.Location = new System.Drawing.Point(60, 128); this.label_status.Location = new System.Drawing.Point(60, 143);
this.label_status.Name = "label_status"; this.label_status.Name = "label_status";
this.label_status.Size = new System.Drawing.Size(41, 12); this.label_status.Size = new System.Drawing.Size(41, 12);
this.label_status.TabIndex = 0; this.label_status.TabIndex = 0;
...@@ -48,11 +57,12 @@ ...@@ -48,11 +57,12 @@
// //
// btn_start // btn_start
// //
this.btn_start.Location = new System.Drawing.Point(325, 128); this.btn_start.Enabled = false;
this.btn_start.Location = new System.Drawing.Point(305, 143);
this.btn_start.Name = "btn_start"; this.btn_start.Name = "btn_start";
this.btn_start.Size = new System.Drawing.Size(135, 23); this.btn_start.Size = new System.Drawing.Size(135, 23);
this.btn_start.TabIndex = 1; this.btn_start.TabIndex = 1;
this.btn_start.Text = "开始点料"; this.btn_start.Text = "Start count";
this.btn_start.UseVisualStyleBackColor = true; this.btn_start.UseVisualStyleBackColor = true;
this.btn_start.Click += new System.EventHandler(this.btn_start_Click); this.btn_start.Click += new System.EventHandler(this.btn_start_Click);
// //
...@@ -62,7 +72,7 @@ ...@@ -62,7 +72,7 @@
this.txt_barcode.Name = "txt_barcode"; this.txt_barcode.Name = "txt_barcode";
this.txt_barcode.Size = new System.Drawing.Size(337, 21); this.txt_barcode.Size = new System.Drawing.Size(337, 21);
this.txt_barcode.TabIndex = 2; this.txt_barcode.TabIndex = 2;
this.txt_barcode.Text = "P123456#S123456789#0#182+EA"; this.txt_barcode.Text = "12345|123456789";
// //
// label_barcode // label_barcode
// //
...@@ -82,25 +92,143 @@ ...@@ -82,25 +92,143 @@
// cb_manualcount // cb_manualcount
// //
this.cb_manualcount.AutoSize = true; this.cb_manualcount.AutoSize = true;
this.cb_manualcount.Checked = true;
this.cb_manualcount.CheckState = System.Windows.Forms.CheckState.Checked;
this.cb_manualcount.Location = new System.Drawing.Point(32, 27); this.cb_manualcount.Location = new System.Drawing.Point(32, 27);
this.cb_manualcount.Name = "cb_manualcount"; this.cb_manualcount.Name = "cb_manualcount";
this.cb_manualcount.Size = new System.Drawing.Size(96, 16); this.cb_manualcount.Size = new System.Drawing.Size(120, 16);
this.cb_manualcount.TabIndex = 3; this.cb_manualcount.TabIndex = 3;
this.cb_manualcount.Text = "手动拦截点料"; this.cb_manualcount.Text = "Manual operation";
this.cb_manualcount.UseVisualStyleBackColor = true; this.cb_manualcount.UseVisualStyleBackColor = true;
this.cb_manualcount.CheckedChanged += new System.EventHandler(this.cb_manualcount_CheckedChanged); this.cb_manualcount.CheckedChanged += new System.EventHandler(this.cb_manualcount_CheckedChanged);
// //
// btn_finishcount
//
this.btn_finishcount.Enabled = false;
this.btn_finishcount.Location = new System.Drawing.Point(305, 221);
this.btn_finishcount.Name = "btn_finishcount";
this.btn_finishcount.Size = new System.Drawing.Size(135, 23);
this.btn_finishcount.TabIndex = 4;
this.btn_finishcount.Text = "Finish count";
this.btn_finishcount.UseVisualStyleBackColor = true;
this.btn_finishcount.Click += new System.EventHandler(this.btn_finishcount_Click);
//
// label_watchstatus
//
this.label_watchstatus.AutoSize = true;
this.label_watchstatus.Location = new System.Drawing.Point(60, 284);
this.label_watchstatus.Name = "label_watchstatus";
this.label_watchstatus.Size = new System.Drawing.Size(41, 12);
this.label_watchstatus.TabIndex = 0;
this.label_watchstatus.Text = "label1";
//
// btn_manualsend
//
this.btn_manualsend.Location = new System.Drawing.Point(486, 74);
this.btn_manualsend.Name = "btn_manualsend";
this.btn_manualsend.Size = new System.Drawing.Size(132, 23);
this.btn_manualsend.TabIndex = 5;
this.btn_manualsend.Text = "Send manually";
this.btn_manualsend.UseVisualStyleBackColor = true;
this.btn_manualsend.Click += new System.EventHandler(this.btn_manualsend_Click);
//
// cb_com
//
this.cb_com.FormattingEnabled = true;
this.cb_com.Items.AddRange(new object[] {
"COM1",
"COM2",
"COM3",
"COM4",
"COM5",
"COM6",
"COM7",
"COM8",
"COM9",
"COM10"});
this.cb_com.Location = new System.Drawing.Point(224, 25);
this.cb_com.Name = "cb_com";
this.cb_com.Size = new System.Drawing.Size(101, 20);
this.cb_com.TabIndex = 6;
//
// cb_bitrate
//
this.cb_bitrate.FormattingEnabled = true;
this.cb_bitrate.Items.AddRange(new object[] {
"115200",
"9600",
"4800"});
this.cb_bitrate.Location = new System.Drawing.Point(331, 25);
this.cb_bitrate.Name = "cb_bitrate";
this.cb_bitrate.Size = new System.Drawing.Size(121, 20);
this.cb_bitrate.TabIndex = 6;
//
// btn_reopen
//
this.btn_reopen.Location = new System.Drawing.Point(469, 23);
this.btn_reopen.Name = "btn_reopen";
this.btn_reopen.Size = new System.Drawing.Size(75, 23);
this.btn_reopen.TabIndex = 7;
this.btn_reopen.Text = "Apply";
this.btn_reopen.UseVisualStyleBackColor = true;
this.btn_reopen.Click += new System.EventHandler(this.btn_reopen_Click);
//
// button_start
//
this.button_start.Location = new System.Drawing.Point(486, 104);
this.button_start.Name = "button_start";
this.button_start.Size = new System.Drawing.Size(132, 23);
this.button_start.TabIndex = 8;
this.button_start.Text = "Start button";
this.button_start.UseVisualStyleBackColor = true;
this.button_start.Click += new System.EventHandler(this.button_start_Click);
//
// cb_enter
//
this.cb_enter.AutoSize = true;
this.cb_enter.Location = new System.Drawing.Point(360, 54);
this.cb_enter.Name = "cb_enter";
this.cb_enter.Size = new System.Drawing.Size(36, 16);
this.cb_enter.TabIndex = 9;
this.cb_enter.Tag = "not";
this.cb_enter.Text = "\\r";
this.cb_enter.UseVisualStyleBackColor = true;
this.cb_enter.CheckedChanged += new System.EventHandler(this.cb_enter_CheckedChanged);
//
// cb_newline
//
this.cb_newline.AutoSize = true;
this.cb_newline.Checked = true;
this.cb_newline.CheckState = System.Windows.Forms.CheckState.Checked;
this.cb_newline.Location = new System.Drawing.Point(424, 54);
this.cb_newline.Name = "cb_newline";
this.cb_newline.Size = new System.Drawing.Size(36, 16);
this.cb_newline.TabIndex = 9;
this.cb_newline.Tag = "not";
this.cb_newline.Text = "\\n";
this.cb_newline.UseVisualStyleBackColor = true;
this.cb_newline.CheckedChanged += new System.EventHandler(this.cb_enter_CheckedChanged);
//
// CIDebugControl // CIDebugControl
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.cb_newline);
this.Controls.Add(this.cb_enter);
this.Controls.Add(this.button_start);
this.Controls.Add(this.btn_reopen);
this.Controls.Add(this.cb_bitrate);
this.Controls.Add(this.cb_com);
this.Controls.Add(this.btn_manualsend);
this.Controls.Add(this.btn_finishcount);
this.Controls.Add(this.cb_manualcount); this.Controls.Add(this.cb_manualcount);
this.Controls.Add(this.txt_barcode); this.Controls.Add(this.txt_barcode);
this.Controls.Add(this.btn_start); this.Controls.Add(this.btn_start);
this.Controls.Add(this.label_barcode); this.Controls.Add(this.label_barcode);
this.Controls.Add(this.label_watchstatus);
this.Controls.Add(this.label_status); this.Controls.Add(this.label_status);
this.Name = "CIDebugControl"; this.Name = "CIDebugControl";
this.Size = new System.Drawing.Size(517, 310); this.Size = new System.Drawing.Size(693, 359);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
...@@ -114,5 +242,14 @@ ...@@ -114,5 +242,14 @@
private System.Windows.Forms.Label label_barcode; private System.Windows.Forms.Label label_barcode;
private System.Windows.Forms.Timer timer1; private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.CheckBox cb_manualcount; private System.Windows.Forms.CheckBox cb_manualcount;
private System.Windows.Forms.Button btn_finishcount;
private System.Windows.Forms.Label label_watchstatus;
private System.Windows.Forms.Button btn_manualsend;
private System.Windows.Forms.ComboBox cb_com;
private System.Windows.Forms.ComboBox cb_bitrate;
private System.Windows.Forms.Button btn_reopen;
private System.Windows.Forms.Button button_start;
private System.Windows.Forms.CheckBox cb_enter;
private System.Windows.Forms.CheckBox cb_newline;
} }
} }
...@@ -12,6 +12,7 @@ using System.Text; ...@@ -12,6 +12,7 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using ConfigHelper;
namespace TheMachine.device namespace TheMachine.device
{ {
...@@ -20,6 +21,51 @@ namespace TheMachine.device ...@@ -20,6 +21,51 @@ namespace TheMachine.device
public CIDebugControl() public CIDebugControl()
{ {
InitializeComponent(); InitializeComponent();
RobotManage.LoadFinishEvent += RobotManage_LoadFinishEvent;
Config.PropertyBind(Setting_Init.VJCounter_COMPORT.Key, cb_com, "SelectedItem", "SelectedIndexChanged");
Config.PropertyBind(Setting_Init.VJCounter_BaudRate.Key, cb_bitrate, "SelectedItem", "SelectedIndexChanged");
}
private void RobotManage_LoadFinishEvent(bool state, string msg)
{
if (!TrayStop.DeviceList.ContainsKey("CI"))
return;
CI.DeviceList["CI"].ReelReady += CIDebugControl_ReelReady;
CI.DeviceList["CI"].XRayStep += CIDebugControl_XRayStep;
CI.DeviceList["CI"].ManualCount = cb_manualcount.Checked;
}
XRayStepE currentstep= XRayStepE.Finish;
private void CIDebugControl_XRayStep(object sender, XRayStepE e)
{
currentstep = e;
LogUtil.info("CID:CI测试界面接受到步骤:" + e);
this.Invoke((EventHandler)delegate
{
switch (e)
{
case XRayStepE.WaitMTtoVJ:
btn_start.Enabled = true;
break;
case XRayStepE.Counting:
btn_start.Enabled = false;
break;
case XRayStepE.WaitVJtoMT:
btn_finishcount.Enabled = true;
break;
case XRayStepE.Finish:
btn_finishcount.Enabled = false;
btn_start.Enabled = false;
break;
}
});
}
private void CIDebugControl_ReelReady(object sender, string e)
{
this.Invoke((EventHandler)delegate {
LogUtil.info("CID:CI测试界面接受到条码:" + e);
txt_barcode.Text = e;
});
} }
private void timer1_Tick(object sender, EventArgs e) private void timer1_Tick(object sender, EventArgs e)
...@@ -36,19 +82,27 @@ namespace TheMachine.device ...@@ -36,19 +82,27 @@ namespace TheMachine.device
status = "Counting"; status = "Counting";
} }
label_status.Text = status; label_status.Text = status+", "+ currentstep;
label_watchstatus.Text = $"Last SN:{RobotManage.folderWatcher.LastSN}, QTY:{RobotManage.folderWatcher.LastQty}, " + RobotManage.folderWatcher.LastUpdateTime.ToString();
} }
private void btn_start_Click(object sender, EventArgs e) private void btn_start_Click(object sender, EventArgs e)
{ {
if (CI.DeviceList["CI"].MoveInfo.MoveStep == MoveStep.MI_01)
CI.DeviceList["CI"].MoveInfo.NextMoveStep(MoveStep.MI_02);
else
MessageBox.Show("没有准备点料的托盘");
return;
if (TrayStop.DeviceList["CI"].IOValue(IO_Type.CI_Count_Finished).Equals(IO_VALUE.HIGH)) if (TrayStop.DeviceList["CI"].IOValue(IO_Type.CI_Count_Finished).Equals(IO_VALUE.HIGH))
{ {
if (VJCounter.CheckConnect()) if (VJCounter.CheckConnect())
{ {
VJCounter.SendBarcode(txt_barcode.Text.Trim()); VJCounter.SendBarcode(txt_barcode.Text.Trim());
Thread.Sleep(500); Thread.Sleep(500);
TrayStop.DeviceList["CI"].IOMove(IO_Type.CI_Start, IO_VALUE.HIGH, 1000); TrayStop.DeviceList["CI"].IOMove(IO_Type.CI_Start, IO_VALUE.HIGH, 500);
LogUtil.info("手动点击开始点料"); LogUtil.info("CID:手动点击开始点料");
} }
else { else {
MessageBox.Show(crc.GetString("Res0117.c9f109fe","未成功连接VJ点料机")); MessageBox.Show(crc.GetString("Res0117.c9f109fe","未成功连接VJ点料机"));
...@@ -64,5 +118,45 @@ namespace TheMachine.device ...@@ -64,5 +118,45 @@ namespace TheMachine.device
{ {
CI.DeviceList["CI"].ManualCount = cb_manualcount.Checked; CI.DeviceList["CI"].ManualCount = cb_manualcount.Checked;
} }
private void btn_finishcount_Click(object sender, EventArgs e)
{
LogUtil.info("CID:用户确认放料完成");
CI.DeviceList["CI"].StartOutStore();
}
private void btn_manualsend_Click(object sender, EventArgs e)
{
LogUtil.info("CID:手动点击SendBarcode");
var bc = txt_barcode.Text.Trim() + VJCounter.newline;
VJCounter.SendBarcode(bc);
MessageBox.Show("send: \"" + bc.Replace("\r","\\r").Replace("\n","\\n")+"\"");
}
private void btn_reopen_Click(object sender, EventArgs e)
{
if (!VJCounter.Connect(Setting_Init.VJCounter_COMPORT, Setting_Init.VJCounter_BaudRate, out string msgs))
{
MessageBox.Show(msgs);
}
}
private void button_start_Click(object sender, EventArgs e)
{
LogUtil.info("CID:手动点击startbtn");
TrayStop.DeviceList["CI"].IOMove(IO_Type.CI_Start, IO_VALUE.HIGH, 500);
}
private void cb_enter_CheckedChanged(object sender, EventArgs e)
{
string newline = "";
if (cb_enter.Checked)
newline += "\r";
if (cb_newline.Checked)
newline += "\n";
VJCounter.newline=newline;
}
} }
} }
\ No newline at end of file \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!