Commit 61f4e58c 刘韬

1

1 个父辈 8ea5ab94
......@@ -64,10 +64,13 @@ namespace OnlineStore.Common
public static MyConfig<int> URRobot_CI_ListenPort = 31;
[MyConfigComment("VJ点料机串口端口号")]
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>
/// 摄像机名称
......
......@@ -110,6 +110,7 @@
<Compile Include="DeviceLibrary\RobotMoveHelper.cs" />
<Compile Include="DeviceLibrary\ServerCommunication.cs" />
<Compile Include="DeviceLibrary\AxisBean.cs" />
<Compile Include="DeviceLibrary\ShareFolderWatcher.cs" />
<Compile Include="DeviceLibrary\VJCounter.cs" />
<Compile Include="theMachine\Common.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
private static StopBits stopBits = StopBits.One; //停止位
private static SerialPort _serialPort = null;
public static string newline="\n";
static string comPortName;
public static bool Connect(string _comport, out string msg) {
public static bool Connect(string _comport,int _baudRate, out string msg) {
msg = "";
try
{
try
{
if (_serialPort != null && _serialPort.IsOpen)
{
_serialPort.Close();
_serialPort.Dispose();
_serialPort = null;
}
}catch (Exception ex)
{
LogUtil.error($"VJCounter: "+ex);
}
comPortName = _comport;
baudRate = _baudRate;
_serialPort = new SerialPort(comPortName, baudRate, parity, dataBits, stopBits);
//_serialPort.RtsEnable = true; //自动请求
//_serialPort.ReadTimeout = 100;//超时
_serialPort.Open();
LogUtil.info("VJCounter: 串口连接成功");
LogUtil.info($"VJCounter: 串口连接成功 comPortName:{comPortName},baudRate:{baudRate}");
return true;
}catch (Exception ex)
{
......@@ -40,19 +55,20 @@ namespace DeviceLibrary
{
if (_serialPort == null)
{
return Connect(comPortName,out _);
return Connect(comPortName,baudRate,out _);
}
else if (!_serialPort.IsOpen)
{
_serialPort = null;
return Connect(comPortName, out _);
return Connect(comPortName, baudRate, out _);
}
else
return true;
}
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.BaseStream.Flush();
LogUtil.info("VJCounter: 串口发送:"+ barcode);
}
}
......
......@@ -252,9 +252,9 @@ namespace DeviceLibrary
//}
//LastProcessErrorTimes++;
Msg.add($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}", MsgLevel.warning);
//RTStoreStatus = RTStoreStatus.InStoreError;
//ServerCM.storeStatus = StoreStatus.InStoreFaild;
RTStoreStatus = RTStoreStatus.Offline;
TerminalError = false;
//ServerCM.storeStatus = StoreStatus.None;
}
else if (ti.StatusCode < 10000)
......@@ -296,32 +296,35 @@ namespace DeviceLibrary
310234,Error clamping on opening (234)
*/
//统计剩余容量
string capacity = "";
for (int i = 0; i < ti.Slots.Count; i++)
if (ti != null)
{
var sn = ti.Slots[i].Slotname;
int w = 0;
int h = 0;
if (sn.StartsWith("s15"))
{
w = 15;
int.TryParse(sn.Substring(3), out h);
}
else if (sn.StartsWith("s13"))
{
w = 13;
int.TryParse(sn.Substring(3), out h);
}
else if (sn.StartsWith("s7"))
string capacity = "";
for (int i = 0; i < ti.Slots.Count; i++)
{
w = 7;
int.TryParse(sn.Substring(2), out h);
var sn = ti.Slots[i].Slotname;
int w = 0;
int h = 0;
if (sn.StartsWith("s15"))
{
w = 15;
int.TryParse(sn.Substring(3), out h);
}
else if (sn.StartsWith("s13"))
{
w = 13;
int.TryParse(sn.Substring(3), out h);
}
else if (sn.StartsWith("s7"))
{
w = 7;
int.TryParse(sn.Substring(2), out h);
}
//boxStatus.data.Add("capacity", "7X8=1000;7X12=345;13X32=100;");
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}";
}
//boxStatus.data.Add("capacity", "7X8=1000;7X12=345;13X32=100;");
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}";
ServerCM.capacity = capacity;
}
ServerCM.capacity = capacity;
}
catch (Exception ex)
{
......
......@@ -60,6 +60,7 @@ namespace DeviceLibrary
TrayManager.Init(DeviceGroup);
MI.Init(Config, DeviceGroup, out m);
CI.Init(Config, DeviceGroup, out m);
msg += m;
#region 初始化led
RunningLed = new Led(Config.DOList["root"][IO_Type.Run_Led].GetIOAddr(), LedColor.green);
......@@ -163,6 +164,7 @@ namespace DeviceLibrary
TransplantMove.DeviceList.Values.ToList().ForEach(s => s.Stop());
TrayStop.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);
ResetEvent.Set();
Alarm(AlarmType.None);
......@@ -183,6 +185,7 @@ namespace DeviceLibrary
TransplantMove.DeviceList.Values.ToList().ForEach(s => s.Start());
TrayStop.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
public static URRobotControl Robot_CI;
public static VStoreCollection VStoreCollection;
public static ShareFolderWatcher folderWatcher;
public static void Init() {
string msg = "";
try
......@@ -60,6 +61,14 @@ namespace DeviceLibrary
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 MI2PostionFile = "config\\MI2Postion.csv";
string CIPostionFile = "config\\CIPostion.csv";
......@@ -93,7 +102,7 @@ namespace DeviceLibrary
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;
msg += crc.GetString("Res0111.43f91cee","VJ点料机连接失败") + "\n";
LogUtil.error(msg + "," + msgs);
......@@ -103,6 +112,7 @@ namespace DeviceLibrary
DeviceRunControl.AddDevice("TransplantMove", TransplantMove.DeviceList.Values.ToList<IDevice>());
//DeviceRunControl.AddDevice("TrayStop", TrayStop.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 }); });
if (G.simulate)
......
......@@ -95,7 +95,7 @@ namespace DeviceLibrary
static void SaveTrayInfo() {
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");
}
......@@ -235,7 +235,7 @@ namespace DeviceLibrary
else {
SetTrayLoadInfo(device.CurrrentRFID, requestLoadInfo);
}
LogUtil.info("释放设备:"+device.GroupName);
LogUtil.info("释放设备:"+device.GroupName+","+ device.CurrrentRFID);
device.TrayRelease();
}
}
......@@ -287,7 +287,7 @@ namespace DeviceLibrary
public static bool IsNeedProcessNG(RemoteLoad remoteLoad)
{
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;
}
......@@ -347,9 +347,12 @@ namespace DeviceLibrary
public string RFID { get => _rfid; set {
try
{
var ss = Enum.GetNames(typeof(TrayTypeE));
TrayType = (TrayTypeE)Enum.Parse(typeof(TrayTypeE), ss.ToList().Find(s => value.StartsWith(s)));
_rfid = value;
if (value != null)
{
var ss = Enum.GetNames(typeof(TrayTypeE));
TrayType = (TrayTypeE)Enum.Parse(typeof(TrayTypeE), ss.ToList().Find(s => value.StartsWith(s)));
_rfid = value;
}
}
catch (Exception ex) {
LogUtil.error($"获取RFID的类型时出错:{value}");
......
......@@ -149,7 +149,7 @@ namespace DeviceLibrary
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);
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的情况判断
if ((GroupName == "AMH-MI1" || GroupName == "AMH-MI2") && trayInfo.TrayType == TrayTypeE.MTP1)
{
......@@ -245,15 +245,17 @@ namespace DeviceLibrary
MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
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];
if (!device.ManualCount)
{
MoveInfo.log($"点料机当前不可用,NG处理");
RequestLoadInfo RequestLoadInfo = new RequestLoadInfo();
RequestLoadInfo.LoadParam = trayInfo.TrayParam.clone();
RequestLoadInfo.LoadParam.IsNg=true;
RequestLoadInfo.LoadParam.NgMsg="XRay not enable";
RequestLoadInfo.LoadParam.IsNg = true;
RequestLoadInfo.LoadParam.NgMsg = "XRay not enable";
RequestLoadInfo.DeviceGroupName = "AMH-MI2";
RequestLoadInfo.TrayType = trayInfo.TrayType.ToString();
RequestLoadInfo.IsEmpty = false;
......@@ -262,11 +264,24 @@ namespace DeviceLibrary
MoveInfo.NextMoveStep(MoveStep.TrayStop_03);
return;
}
else
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
{
MoveInfo.NextMoveStep(MoveStep.TrayStop_07);
//device.StartOutStore();
}
}
else if (trayInfo.DestinationAddr == DeviceGroup.addr_1 && trayInfo.HasLoad)
{
MoveInfo.log("开始处理入料");
//抵达了一个有物料的托盘等待处理
if (!device.HasJob(trayInfo.TrayParam))
MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
else
......@@ -275,6 +290,10 @@ namespace DeviceLibrary
device.StartInStore(trayInfo.TrayParam);
}
}
else
MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
return;
}
#endregion
if (stop && !trayInfo.HasLoad && IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.LOW))
......
......@@ -163,6 +163,7 @@
this.lblAlarmcode.Tag = "not";
this.lblAlarmcode.Text = "ErrCode:160";
this.lblAlarmcode.Visible = false;
this.lblAlarmcode.Click += new System.EventHandler(this.lblAlarmcode_Click);
//
// label4
//
......
......@@ -445,5 +445,11 @@ namespace DeviceLibrary
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
using ConfigHelper;
using Newtonsoft.Json;
using OnlineStore;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Text;
......@@ -34,9 +36,26 @@ namespace RemoteSheardObject
{"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)
{
//料盘空出后直接结束任务
......@@ -49,7 +68,7 @@ namespace RemoteSheardObject
{
{"barcode", barcode}
};
return !string.IsNullOrEmpty(SubmitPostData("/service/store/robotBox/emptyOut", postData));
return !string.IsNullOrEmpty(SubmitPostData("/service/store/robotBox/emptyOut", postData, out _));
}
/// <summary>
/// 获取正在进行的任务数量
......@@ -67,7 +86,7 @@ namespace RemoteSheardObject
taskdata["tray"] = 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)
return taskdata;
......@@ -107,7 +126,7 @@ namespace RemoteSheardObject
{
{"barcode", barcode},
};
var result = SubmitPostData( "/service/store/robotBox/getSize", postData);
var result = SubmitPostData( "/service/store/robotBox/getSize", postData, out _);
if (result != null)
return JsonConvert.DeserializeObject<T>(result);
else
......@@ -147,7 +166,7 @@ namespace RemoteSheardObject
{"ngPos",ngPos.ToString() }
};
string url = "/rest/micron/device/clearNgPos";
var resultStr = SubmitPostData(url, postData);
var resultStr = SubmitPostData(url, postData, out _);
}
/// <summary>
/// 上传自定义数据
......@@ -162,7 +181,7 @@ namespace RemoteSheardObject
{"value",value }
};
string url = "/rest/micron/device/updateData";
var resultStr = SubmitPostData(url, postData);
var resultStr = SubmitPostData(url, postData, out _);
}
/// <summary>
/// 上传自定义数据
......@@ -176,7 +195,7 @@ namespace RemoteSheardObject
{"key",key}
};
string url = "/rest/micron/device/getData";
var resultStr = SubmitPostData(url, postData);
var resultStr = SubmitPostData(url, postData, out _);
var r= JsonConvert.DeserializeObject<ResultData2>(resultStr);
if (!string.IsNullOrWhiteSpace(r.data)) {
return r.data;
......@@ -201,8 +220,9 @@ namespace RemoteSheardObject
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);
//创建WebClient对象
using (var client = new WebClient())
......@@ -226,6 +246,7 @@ namespace RemoteSheardObject
if (postDataString.Length>0)
postDataString.Length--;
msg += postDataString;
//将POST请求参数转换为字节数组
byte[] bytes = Encoding.UTF8.GetBytes(postDataString.ToString());
......@@ -240,8 +261,10 @@ namespace RemoteSheardObject
{
// 捕获任何网络异常,并输出错误信息
//Console.WriteLine(crc.GetString("Res0071","提交POST请求时发生错误:") + ex.Message);
msg += "\r\n提交POST请求时发生错误:"+ex.Message;
// 请求失败,返回false
Debug.WriteLine(url);
Debug.WriteLine(ex);
return "";
}
}
......@@ -259,7 +282,11 @@ namespace RemoteSheardObject
var barcode = reelParam.WareCode;
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
{
......@@ -271,7 +298,7 @@ namespace RemoteSheardObject
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");
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";
emptyPosForPutin result = JsonConvert.DeserializeObject<emptyPosForPutin>(data);
......
......@@ -260,6 +260,7 @@
</EmbeddedResource>
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="IOControls.resx">
<DependentUpon>IOControls.cs</DependentUpon>
......
......@@ -123,6 +123,9 @@ namespace TheMachine
reelid = ti.TrayParam?.WareCode;
var items = new string[] {lastaddrdesc.ToString(), lasttime, traydesc, loaddesc, toaddrdesc, reelid };
if (string.IsNullOrEmpty(ti.RFID))
continue;
if (listView1.Items.ContainsKey(ti.RFID))
{
while (listView1.Items[ti.RFID].SubItems.Count > 1)
......@@ -189,7 +192,8 @@ namespace TheMachine
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("Res0023","目的地") + ": " + listView1.SelectedItems[0].SubItems[4].Text;
txt += "\r\n"+"Code" + ": " + listView1.SelectedItems[0].SubItems[6].Text;
if (listView1.SelectedItems[0].SubItems.Count>6)
txt += "\r\n"+"Code" + ": " + listView1.SelectedItems[0].SubItems[6].Text;
if (ti.HasLoad && ti.TrayParam.IsNg) {
txt += "\r\n" + "NgMsg" + ": " + ti.TrayParam.NgMsg;
}
......
......@@ -35,12 +35,21 @@
this.label_barcode = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
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();
//
// label_status
//
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.Size = new System.Drawing.Size(41, 12);
this.label_status.TabIndex = 0;
......@@ -48,11 +57,12 @@
//
// 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.Size = new System.Drawing.Size(135, 23);
this.btn_start.TabIndex = 1;
this.btn_start.Text = "开始点料";
this.btn_start.Text = "Start count";
this.btn_start.UseVisualStyleBackColor = true;
this.btn_start.Click += new System.EventHandler(this.btn_start_Click);
//
......@@ -62,7 +72,7 @@
this.txt_barcode.Name = "txt_barcode";
this.txt_barcode.Size = new System.Drawing.Size(337, 21);
this.txt_barcode.TabIndex = 2;
this.txt_barcode.Text = "P123456#S123456789#0#182+EA";
this.txt_barcode.Text = "12345|123456789";
//
// label_barcode
//
......@@ -82,25 +92,143 @@
// cb_manualcount
//
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.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.Text = "手动拦截点料";
this.cb_manualcount.Text = "Manual operation";
this.cb_manualcount.UseVisualStyleBackColor = true;
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
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
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.txt_barcode);
this.Controls.Add(this.btn_start);
this.Controls.Add(this.label_barcode);
this.Controls.Add(this.label_watchstatus);
this.Controls.Add(this.label_status);
this.Name = "CIDebugControl";
this.Size = new System.Drawing.Size(517, 310);
this.Size = new System.Drawing.Size(693, 359);
this.ResumeLayout(false);
this.PerformLayout();
......@@ -114,5 +242,14 @@
private System.Windows.Forms.Label label_barcode;
private System.Windows.Forms.Timer timer1;
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;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using ConfigHelper;
namespace TheMachine.device
{
......@@ -20,6 +21,51 @@ namespace TheMachine.device
public CIDebugControl()
{
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)
......@@ -36,19 +82,27 @@ namespace TheMachine.device
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)
{
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 (VJCounter.CheckConnect())
{
VJCounter.SendBarcode(txt_barcode.Text.Trim());
Thread.Sleep(500);
TrayStop.DeviceList["CI"].IOMove(IO_Type.CI_Start, IO_VALUE.HIGH, 1000);
LogUtil.info("手动点击开始点料");
TrayStop.DeviceList["CI"].IOMove(IO_Type.CI_Start, IO_VALUE.HIGH, 500);
LogUtil.info("CID:手动点击开始点料");
}
else {
MessageBox.Show(crc.GetString("Res0117.c9f109fe","未成功连接VJ点料机"));
......@@ -64,5 +118,45 @@ namespace TheMachine.device
{
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
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!