Commit 45422c2b LN

放料bug修改。料架增加获取剩余空位和判断是否离开功能。

1 个父辈 60fa6425
......@@ -846,6 +846,55 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error(Name + "InShelfProcess:" + ex.ToString());
}
}
private DateTime lastEmptyTime = DateTime.Now;
private void ShelfEmptyProcess()
{
//2秒钟获取一次
TimeSpan span = DateTime.Now - lastEmptyTime;
if (span.TotalSeconds < 3)
{
return;
}
try
{
lastEmptyTime = DateTime.Now;
string shelfRfid = ReadyShelf( ",");
if (String.IsNullOrEmpty(shelfRfid))
{
return;
}
Dictionary<string,int> emptyMap= HttpServer.getShelfEmptySlot(shelfRfid);
//需要取放料,且料架已准备好
if (emptyMap!=null)
{
List<int> keys = new List<int>(StationMap.Keys);
foreach (int key in keys)
{
ShelfInfo shelf = StationMap[key].CurrShelf;
if (StationMap[key].IsReady())
{
string realRfid = StationMap[key].CurrShelf.RealShelf;
if(emptyMap.TryGetValue(realRfid,out int emptyP))
{
StationMap[key].CurrShelf.EmptyPos = emptyP;
if (emptyP <= 0)
{
StationMap[key].CheckNeedLeave(true);
}
}
}
}
}
}
catch (Exception ex)
{
LogUtil.error(Name + "ShelfEmptyProcess:" + ex.ToString());
}
}
private void ClearWarnMsg(string str)
{
if (WarnMsg.Contains(str))
......@@ -871,17 +920,17 @@ namespace OnlineStore.DeviceLibrary
}
return str;
}
private string ReadyShelf()
private string ReadyShelf(string spilt=";")
{
string str = "";
foreach (WorkStation shelf in StationMap.Values)
{
if (shelf.IsReady())
{
str += shelf.CurrShelf.RealShelf + ";";
str += shelf.CurrShelf.RealShelf + spilt;
}
}
if (str.EndsWith(";"))
if (str.EndsWith(spilt))
{
str = str.Substring(0, str.Length - 1);
}
......@@ -1075,8 +1124,15 @@ namespace OnlineStore.DeviceLibrary
string posId = "";
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
if (MoveInfo.MoveParam.PosInfo.IsNg)
{
}
else
{
posId = MoveInfo.MoveParam?.PosInfo.BoxPosId;
}
}
StoreSendBean store = lineConn.GetBean((int)ss, (int)storeRunStatus, hasTray, (int)alarmType,posId);
lineConn.SendHeart(store);
}
......
......@@ -207,13 +207,5 @@ namespace OnlineStore.DeviceLibrary
}
public class ResultData
{
//{"code":0,"msg":"ok","data":"7"}
public int code { get; set; }
public string msg { get; set; }
public object data { get; set; }
}
}
......@@ -75,19 +75,14 @@ namespace OnlineStore.DeviceLibrary
//料架准备好可以放料
return false;
}
internal bool CheckNeedLeave(bool IsReset = true )
internal bool CheckNeedLeave(bool IsReset = true)
{
if (IsDis())
{
return false;
}
CurrShelf.TaskInfo = HttpServer.ShelfFinish(CurrShelf.RealShelf);
string log = "";
//判断的当前料架是否无任务
if (CurrShelf.TaskInfo.IsValid())
{
if (CurrShelf.TaskInfo.bigEmpty <= 0 && CurrShelf.TaskInfo.smallEmpty <= 0)
if (CurrShelf.EmptyPos <= 0)
{
CurrShelf.IsNeedLeave = true;
LogUtil.info(Name + " " + CurrShelf.ToStr() + " 没有空位需要离开 ");
......@@ -95,8 +90,7 @@ namespace OnlineStore.DeviceLibrary
{
Reset();
}
return true ;
}
return true;
}
return false;
}
......@@ -781,11 +775,12 @@ namespace OnlineStore.DeviceLibrary
}
public class ShelfInfo
{
public ShelfTaskInfo TaskInfo = null;
//public ShelfTaskInfo TaskInfo = null;
public string RealShelf = "";
public string XNShelf = "";
public bool IsNeedLeave = false;
public bool IsBusy = false;
public int EmptyPos = 100;
public ShelfInfo(string shelfId = "", string xnId = "", bool needLeave = false, bool busy = false)
{
......@@ -793,14 +788,14 @@ namespace OnlineStore.DeviceLibrary
this.XNShelf = xnId;
this.IsNeedLeave = needLeave;
this.IsBusy = busy;
EmptyPos = 100;
}
public string ToStr()
{
string result = "料架:[" + RealShelf + "_" + XNShelf + "]";
if (TaskInfo != null && TaskInfo.IsValid())
{
result += "[空位:大料=" + TaskInfo.bigEmpty + ",小料=" + TaskInfo.smallEmpty + "]";
}
result += "[空位 " + EmptyPos + "]";
if (IsNeedLeave)
{
result += "[需离开]";
......
......@@ -232,13 +232,13 @@ namespace OnlineStore.DeviceLibrary
bean.WaitInStoreList = new List<string>( );
if (DoorPosInfo != null)
{
if (string.IsNullOrEmpty(DoorPosInfo.ShelfPosId))
if (DoorPosInfo.IsNg)
{
bean.WaitInStoreList.Add("NG料");
}
else
{
bean.WaitInStoreList.Add(DoorPosInfo.ShelfPosId);
bean.WaitInStoreList.Add(DoorPosInfo.BoxPosId);
}
}
return bean;
......@@ -266,12 +266,10 @@ namespace OnlineStore.DeviceLibrary
this.SRunStatus = runs;
this.DoorHasTray = doorHasTray;
this.AlarmType = alarmType;
//this.Seq = LineConnect.nextSeq();
//this.WaitInStoreList = new List<string>(LineConnect.WaitInStoreList);
this.Seq = 0;
this.WaitInStoreList = new List<string>();
this.data = new Dictionary<string, string>();
// WaitInStoreList.Add("1#AC1_1_1");
this.CurrPosId = currPosId;
}
public string Cmd = LineConnect.cmd_heart;
......
......@@ -16,11 +16,63 @@ namespace OnlineStore.DeviceLibrary
}
private static string Addr_updateDeviceAlarmMsg = "/rest/api/qisda/device/updateDeviceAlarmMsg";
private static string Addr_ShelfFinish = "/rest/api/qisda/device/putShelfFinished";
private static string Addr_putShelfFinished = "/rest/api/qisda/device/putShelfFinished";
private static string Addr_getLocation = "/rest/api/qisda/device/getLocation";
private static string Addr_getShelfEmptySlot = "/rest/api/dcs/device/getShelfEmptySlot";
/// <summary>
/// rest/api/dcs/device/getShelfEmptySlot
/// 获取当前任务数及料架的剩余空位
/// 参数:rfids 料架rfid列表,逗号分割,未发送rfids只返回当前剩余任务数量
/// </summary>
/// <param name="rfids"></param>
/// <returns></returns>
public static Dictionary<string, int> getShelfEmptySlot(string rfids)
{
Dictionary<string, int> map = new Dictionary<string, int>();
DateTime startTime = DateTime.Now;
try
{
string api = Addr_getShelfEmptySlot;
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("rfids", rfids);
string url = GetAddr(api, paramMap);
LogUtil.debug("http :URL:" + url);
string json = HttpHelper.Post(url, "", 2000);
if (rfids != "")
{
LogUtil.info("http :URL:" + url + " :Response:" + json + " 耗时[" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "]");
}
else
{
LogUtil.debug("http :URL:" + url + " :Response:" + json);
}
if (string.IsNullOrWhiteSpace(json))
{
return map;
}
ResultData result = JsonHelper.DeserializeJsonToObject<ResultData>(json);
if (result.code >= 0 || (!String.IsNullOrEmpty(result.msg))){
LogUtil.error("getShelfEmptySlot,rfids[" + rfids + "]结果:code=" + result.code + ",msg=" + result.msg);
}
else
{
map = (Dictionary<string, int>)(result.data);
return map;
}
}
catch (Exception ex)
{
LogUtil.error("http getShelfEmptySlot error : " + ex.ToString());
}
return map;
}
//private static string Addr_putShelfFinished = "/rest/api/qisda/device/putShelfFinished";
// 取消出库任务地址: /cancelOutTask //参数: barcode
private static string Addr_cancelPutInTask = "/rest/api/qisda/device/cancelOutTask";
//private static string Addr_cancelPutInTask = "/rest/api/qisda/device/cancelOutTask";
public static string updateDeviceAlarmMsg(List<AlarmMsg> msgList)
{
string msg = "";
......@@ -34,7 +86,7 @@ namespace OnlineStore.DeviceLibrary
string resultStr = HttpHelper.Post(server, "", 2000);
LogUtil.debug("updateDeviceAlarmMsg " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
RfidData data = JsonHelper.DeserializeJsonToObject<RfidData>(resultStr);
ResultData data = JsonHelper.DeserializeJsonToObject<ResultData>(resultStr);
if (data == null)
{
......@@ -68,38 +120,7 @@ namespace OnlineStore.DeviceLibrary
path = path.Substring(0, path.Length - 1);
return path;
}
public static string cancelOutTask(string barcode)
{
string msg = "";
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("barcode", barcode);
string server = GetAddr(Addr_cancelPutInTask, paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "");
LogUtil.info("cancelOutTask " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
ResultData data = JsonHelper.DeserializeJsonToObject<ResultData>(resultStr);
if (data == null)
{
return msg = " cancelOutTask【 " + barcode + "】 没有收到服务器反馈";
}
else if (data.code.Equals(0).Equals(false))
{
return msg = " cancelOutTask【 " + barcode + "】 :" + data.msg;
}
return "";
}
catch (Exception ex)
{
LogUtil.error(" cancelOutTask error :" + ex.ToString());
}
return msg;
}
public static ShelfTaskInfo ShelfFinish(string rfid, string barcode = "", string rfidLoc = "", string robotIndex = "1")
......@@ -166,66 +187,7 @@ namespace OnlineStore.DeviceLibrary
return task;
}
public static AllTaskInfo GetATaskInfo(string rfid = "", string barcode = "", string rfidLoc = "", string robotIndex = "")
{
AllTaskInfo task = new AllTaskInfo();
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("barcode", barcode);
paramMap.Add("rfid", rfid);
paramMap.Add("rfidLoc", rfidLoc);
paramMap.Add("robotIndex", robotIndex);
string url = GetAddr(Addr_putShelfFinished, paramMap);
//string url = httpAddr + api + "?barcode=" + barcode + "&rfid=" + rfid + "&rfidLoc=" + rfidLoc + "&robotIndex=" + robotIndex;
string logName = "http :URL:" + url + " , ";
string json = HttpHelper.Post(url, "", 10000);
if (string.IsNullOrWhiteSpace(json)) return task;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> obj = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (!obj.TryGetValue("code", out object value)) return task;
if (value.ToString() != "0")
{
if (obj.TryGetValue("msg", out value))
LogUtil.info(logName + ": " + value.ToString());
return task;
}
if (!obj.TryGetValue("data", out value)) return task;
Dictionary<string, object> dict = (Dictionary<string, object>)value;
if (dict == null)
{
LogUtil.info(logName + ": data=null");
return task;
}
if (dict.TryGetValue("bigTask", out value))
int.TryParse(value.ToString(), out task.bigTask);
if (dict.TryGetValue("smallTask", out value))
int.TryParse(value.ToString(), out task.smallTask);
if (task.bigTask > 0 || task.smallTask > 0)
{
LogUtil.debug(logName + " Response:" + json);
}
else
{
LogUtil.debug(logName + " Response:" + json);
}
}
catch (Exception ex)
{
LogUtil.error("http error : " + ex.ToString());
}
return task;
}
/// <summary>
/// 获取定位机构上的料盘信息
/// </summary>
/// <param name="barcode">条码信息</param>
/// <param name="currRFID">当前工位的RFID</param>
public static TrayInfo GetLocation(string barcode, string currRFID, out string msg)
{
//getLocation这个接口传入barcode和rfid列表会分配料架
......@@ -384,13 +346,21 @@ namespace OnlineStore.DeviceLibrary
this.msgValue = value;
}
}
public class RfidData
public class ResultData
{
//{"code":0,"msg":"ok","data":"7"}
public int code { get; set; }
public string msg { get; set; }
public Dictionary<string, string> data { get; set; }
public object data { get; set; }
}
//public class ResultData
//{
// //{"code":0,"msg":"ok","data":"7"}
// public int code { get; set; }
// public string msg { get; set; }
// public object data { get; set; }
//}
}
......@@ -137,6 +137,7 @@
this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.lblHeartMsg = new System.Windows.Forms.Label();
this.tabControl1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.groupBox2.SuspendLayout();
......@@ -176,6 +177,7 @@
//
// tabPage2
//
this.tabPage2.Controls.Add(this.lblHeartMsg);
this.tabPage2.Controls.Add(this.lblWarnMsg);
this.tabPage2.Controls.Add(this.chbMoveStop);
this.tabPage2.Controls.Add(this.checkBox3);
......@@ -338,7 +340,7 @@
this.logBox.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.logBox.Location = new System.Drawing.Point(4, 297);
this.logBox.Name = "logBox";
this.logBox.Size = new System.Drawing.Size(978, 301);
this.logBox.Size = new System.Drawing.Size(978, 270);
this.logBox.TabIndex = 278;
this.logBox.Text = "";
this.logBox.VisibleChanged += new System.EventHandler(this.logBox_VisibleChanged);
......@@ -364,7 +366,7 @@
this.groupBox2.Controls.Add(this.button6);
this.groupBox2.Controls.Add(this.button3);
this.groupBox2.Controls.Add(this.button5);
this.groupBox2.Location = new System.Drawing.Point(6, 442);
this.groupBox2.Location = new System.Drawing.Point(6, 439);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(972, 78);
this.groupBox2.TabIndex = 276;
......@@ -466,7 +468,7 @@
this.tabPage3.Controls.Add(this.btnAxisOff);
this.tabPage3.Location = new System.Drawing.Point(4, 26);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(988, 602);
this.tabPage3.Size = new System.Drawing.Size(988, 609);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = " 库位调试 ";
this.tabPage3.UseVisualStyleBackColor = true;
......@@ -1525,6 +1527,18 @@
//
this.timer2.Interval = 1000;
//
// lblHeartMsg
//
this.lblHeartMsg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblHeartMsg.AutoSize = true;
this.lblHeartMsg.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblHeartMsg.ForeColor = System.Drawing.Color.Green;
this.lblHeartMsg.Location = new System.Drawing.Point(9, 579);
this.lblHeartMsg.Name = "lblHeartMsg";
this.lblHeartMsg.Size = new System.Drawing.Size(0, 17);
this.lblHeartMsg.TabIndex = 289;
this.lblHeartMsg.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// FrmEquip
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
......@@ -1673,6 +1687,7 @@
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.CheckBox checkBox1;
protected System.Windows.Forms.CheckBox chbMoveStop;
private System.Windows.Forms.Label lblHeartMsg;
}
}
......@@ -162,6 +162,7 @@ namespace OnlineStore.ACSingleStore
{
return;
}
lblHeartMsg.Text = LineConnect.HeartMsg;
if (chbDebug.Checked.Equals(equip.IsDebug).Equals(false))
{
LoadOk = false;
......@@ -620,6 +621,14 @@ namespace OnlineStore.ACSingleStore
string posid = "";
if (equip.MoveInfo.MoveType.Equals(StoreMoveType.None))
{
if (equip.MoveInfo.MoveParam.PosInfo.IsNg)
{
posid = "";
}
else
{
}
posid = equip.MoveInfo.MoveParam?.PosInfo.BoxPosId;
}
StoreSendBean bean = equip.lineConn.GetBean((int)ss, (int)StoreRunStatus.Runing, hasTray, (int)StoreAlarmType.None,posid);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!