Commit 3768325d LN

1

1 个父辈 eda8bcfe
......@@ -37,6 +37,10 @@ namespace OnlineStore.Common
[MyConfigComment("屏蔽出入库时料叉检测")]
public static MyConfig<bool> Device_Disable_INOUT_FixtureCheck = false;
[MyConfigComment("二维码扫码超时毫秒")]
public static MyConfig<int> Device_RfidServer_Port = 30001;
[MyConfigComment("管理员密码")]
public static MyConfig<string> User_AdminPassword = "123456";
[MyConfigComment("启用管理员密码")]
......@@ -61,6 +65,7 @@ namespace OnlineStore.Common
public static MyConfig<int> CameraScan_CodeTimeOut = 3000;
public static MyConfig<bool> Runtime_IsInStore;
public static MyConfig<string> Runtime_PosID;
public static MyConfig<string> Runtime_WareCode;
......
......@@ -73,10 +73,11 @@ namespace OnlineStore.Common
}
public static string Post(string url, string paramData, int timeOut = 10000)
{
return Post(url, paramData, Encoding.UTF8, timeOut);
bool IsTimeOut = false;
return Post(url, paramData, Encoding.UTF8, timeOut, out IsTimeOut);
}
public static string Post(string url, string paramData, Encoding encoding, int timeOut = 10000)
public static string Post(string url, string paramData, Encoding encoding, int timeOut ,out bool IsTimeOut )
{
string result = "";
......@@ -86,7 +87,7 @@ namespace OnlineStore.Common
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback((sender, certificate, chain, errors) => { return true; });
}
IsTimeOut = false;
try
{
using (var wc = new MyWebClient(timeOut))
......@@ -101,6 +102,11 @@ namespace OnlineStore.Common
result = wc.UploadString(url, "POST", paramData);
}
//LogUtil.info(result);
}
catch (WebException ex)
{
IsTimeOut = true;
LogUtil.error("POST [" + url + "] WebException :" + ex.ToString() );
}
catch (Exception e)
{
......
......@@ -36,6 +36,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\SharedDLL\Asa.Camera.VisionLib.dll</HintPath>
</Reference>
<Reference Include="Asa.RFID">
<HintPath>..\..\DoubleLineClient_3D\dll\Asa.RFID.dll</HintPath>
</Reference>
<Reference Include="CodeLibrary, Version=1.0.8485.20895, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\SharedDLL\CodeLibrary.dll</HintPath>
......@@ -64,6 +67,7 @@
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
......@@ -76,23 +80,24 @@
<Compile Include="DeviceLibrary\AcSerialBean.cs" />
<Compile Include="DeviceLibrary\Camera.cs" />
<Compile Include="DeviceLibrary\CylinderManger.cs" />
<Compile Include="DeviceLibrary\HttpServer.cs" />
<Compile Include="DeviceLibrary\IOMonitor.cs" />
<Compile Include="DeviceLibrary\I_SafetyDevice.cs" />
<Compile Include="DeviceLibrary\LiftMonitor.cs" />
<Compile Include="DeviceLibrary\LineRunMonitor.cs" />
<Compile Include="DeviceLibrary\C8WeightSensor.cs" />
<Compile Include="DeviceLibrary\OKLEController.cs" />
<Compile Include="DeviceLibrary\ReelParam.cs" />
<Compile Include="DeviceLibrary\RFIDManager.cs" />
<Compile Include="DeviceLibrary\ServerCommunication.cs" />
<Compile Include="DeviceLibrary\AxisBean.cs" />
<Compile Include="theMachine\BoxTransport.cs" />
<Compile Include="theMachine\ReelTransport.cs" />
<Compile Include="theMachine\Common.cs" />
<Compile Include="theMachine\InReelBean.cs" />
<Compile Include="theMachine\JobList.cs" />
<Compile Include="theMachine\LabelParam.cs" />
<Compile Include="theMachine\MainMachine _BtnProcess.cs" />
<Compile Include="theMachine\MainMachine _Common.cs" />
<Compile Include="theMachine\MainMachine _AutoInOutTest.cs" />
<Compile Include="theMachine\MainMachine_Store.cs" />
<Compile Include="theMachine\MainMachine_PutReel.cs" />
<Compile Include="theMachine\MainMachine _IOMonitor.cs" />
<Compile Include="theMachine\MainMachine _LedProcess.cs" />
<Compile Include="theMachine\MainMachine.cs" />
......@@ -100,6 +105,7 @@
<Compile Include="theMachine\MoveStep.cs" />
<Compile Include="DeviceLibrary\AlarmBuzzer.cs" />
<Compile Include="DeviceLibrary\CodeManager.cs" />
<Compile Include="theMachine\OutShelfBean.cs" />
<Compile Include="theMachine\RobotManage.cs" />
<Compile Include="theMachine\IRobot.cs" />
<Compile Include="DeviceLibrary\IAxisManager.cs" />
......
......@@ -371,6 +371,16 @@ namespace DeviceLibrary
}
return message;
}
public static string ProcessCode(List<CodeInfo> codeInfos)
{
string codeStr = "";
foreach(CodeInfo code in codeInfos)
{
codeStr += ReplaceCode(code.CodeStr)+"#";
}
return codeStr;
}
public static bool HasChinese(string str)
{
return Regex.IsMatch(str, @"[\u4e00-\u9fa5]");
......
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Script.Serialization;
namespace DeviceLibrary
{
public class HttpServer
{
public HttpServer()
{
}
private static string Addr_updateDeviceAlarmMsg = "/rest/api/qisda/device/updateDeviceAlarmMsg";
private static string Addr_ShelfFinish = "/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.debug("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||result.data==null)
{
LogUtil.error("getShelfEmptySlot,rfids[" + rfids + "]结果:code=" + result.code + ",msg=" + result.msg);
}
else
{
foreach(string key in result.data.Keys)
{
int v =Convert.ToInt32( result.data[key].ToString());
map.Add(key, v);
}
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";
public static string updateDeviceAlarmMsg(List<AlarmMsg> msgList)
{
string msg = "";
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
string msgListStr = JsonHelper.SerializeObject(msgList);
paramMap.Add("deviceAlarmList", msgListStr);
string server = GetAddr(Addr_updateDeviceAlarmMsg, paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "", 2000);
LogUtil.debug("updateDeviceAlarmMsg " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
ResultData data = JsonHelper.DeserializeJsonToObject<ResultData>(resultStr);
if (data == null)
{
return msg = " updateDeviceAlarmMsg 没有收到服务器反馈";
}
else if (data.code.Equals(0).Equals(false))
{
return msg = " updateDeviceAlarmMsg 【" + server + "】【" + resultStr + "】" + data.msg;
}
return "";
}
catch (Exception ex)
{
LogUtil.error(" updateDeviceAlarmMsg Error: " + ex.ToString());
}
return msg;
}
public static string GetAddr(string addr, Dictionary<string, string> paramsMap)
{
string server = ConfigAppSettings.GetValue(Setting_Init.Device_Server_Address);
if (server.EndsWith("/"))
{
server = server.Substring(0, server.Length - 1);
}
string path = server + addr.Trim() + "?";
foreach (string paramName in paramsMap.Keys)
{
string par = System.Web.HttpUtility.UrlEncode(paramsMap[paramName], System.Text.Encoding.UTF8);
path += paramName + "=" + par + "&";
}
path = path.Substring(0, path.Length - 1);
return path;
}
public static ShelfTaskInfo ShelfFinish(string rfid, string barcode = "", string rfidLoc = "", string robotIndex = "1")
{
ShelfTaskInfo task = new ShelfTaskInfo();
task.rfid = rfid;
DateTime startTime = DateTime.Now;
try
{
string api = Addr_ShelfFinish;
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 = httpAddr + api + "?barcode=" + barcode + "&rfid=" + rfid + "&rfidLoc=" + rfidLoc + "&robotIndex=" + robotIndex;
string url = GetAddr(api, paramMap);
LogUtil.debug("http :URL:" + url);
string json = HttpHelper.Post(url, "", 10000);
if (barcode != "")
{
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 task;
//行 2234: [2021 - 04 - 07 15:09:31,412][9]INFO - http :URL:
//http://192.168.100.14/myproject/rest/api/qisda/device/putShelfFinished?barcode=640253A*34005600000309*QG00006*5000*23C4&rfid=F103&rfidLoc=8&robotIndex=1 :
//Response:{"code":0,"msg":"ok","data":{"smallTask":"0","cutPackageTask":"0","packageTask":"0","bigTask":"0","smallEmpty":"0","bigEmpty":"5","packageEmpty":"0","rfid":"F103","usedRfidList":"F106,F105,F103","barcode":"640253A*34005600000309*QG00006*5000*23C4","cutTask":"0"}} 耗时[00:00:00.1]
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.error("http" + api + ": " + 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("http" + api + ": data=null");
return task;
}
if (dict.TryGetValue("bigEmpty", out value))
int.TryParse(value.ToString(), out task.bigEmpty);
if (dict.TryGetValue("smallEmpty", out value))
int.TryParse(value.ToString(), out task.smallEmpty);
if (dict.TryGetValue("usedRfidList", out value))
task.usedRfidList = value.ToString();
}
catch (Exception ex)
{
LogUtil.error("http error : " + ex.ToString());
}
return task;
}
public static TrayInfo GetLocation(string barcode, string currRFID, out string msg)
{
//getLocation这个接口传入barcode和rfid列表会分配料架
TrayInfo tray = new TrayInfo();
msg = "";
try
{
//string api = "getLocation" + "?barcode=" + barcode + "&rfid=" + currRFID;
//string url = httpAddr + api;
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("barcode", barcode);
paramMap.Add("rfid", currRFID);
string url = GetAddr(Addr_getLocation, paramMap);
string logName = "http :URL:" + url;
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(url, "", 5000);
LogUtil.info(logName + ": Response:" + resultStr + ",耗时【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】");
ResultData data = JsonHelper.DeserializeJsonToObject<ResultData>(resultStr);
if (data == null || data.code != 0)
{
tray = TrayInfo.newNgTray(barcode, data.msg);
return tray;
}
tray = JsonHelper.DeserializeJsonToObject<TrayInfo>(data.data.ToString());
if (tray == null || tray.rfid == "" || tray.shelfP == 0)
{
tray = TrayInfo.newNgTray(barcode, "获取位置失败");
return tray;
}
}
catch (Exception ex)
{
LogUtil.error("http error : " + ex.ToString());
}
//tray.robotNum = robot;
return tray;
}
}
public class TrayInfo
{
//Response:{"code":0,"msg":"ok","data":{"w":"7","realRfid":"","h":"8","rfid":"1-2F","usedRfidList":"F102","rfidLoc":"11","barcode":"985022*35030377*0822*3000*08220350"}}
/// <summary>
/// 料架位置,1-31
/// </summary>
public int shelfP = 0;
/// <summary>
/// 虚拟料架号
/// </summary>
public string rfid = "";
/// <summary>
/// 真实料架号
/// </summary>
public string realRFID = "";
/// <summary>
/// 条码信息
/// </summary>
public string barcode = "";
/// <summary>
/// 已使用的真实料架号
/// </summary>
public string usedRfidList = "";
public int plateW = 7;
public int plageH = 8;
public bool ngReel = false;
public string ngMsg = "";
public string ToStr()
{
if (ngReel)
{
return "NGReel: [" + barcode + "] [" + ngMsg + "] [" + updateTime.ToLongTimeString() + "]";
}
else
{
return " [" + barcode + "] [" + shelfP + "] [" + rfid + "] [" + realRFID + "] [" + usedRfidList + "] [" + updateTime.ToLongTimeString() + "]";
}
}
public DateTime updateTime = DateTime.Now;
public TrayInfo()
{
}
public static TrayInfo newNgTray(string barcode, string ngMsg)
{
TrayInfo tray = new TrayInfo();
tray.ngMsg = ngMsg;
tray.ngReel = true;
tray.barcode = barcode;
return tray;
}
}
public class ShelfTaskInfo
{
public string rfid = "";
public int bigEmpty = -1;
public int smallEmpty = -1;
//public int packageEmpty = -1;
public string usedRfidList = "";
public bool IsValid()
{
if (bigEmpty != -1 && smallEmpty != -1)
{
return true;
}
return false;
}
public string ToStr()
{
return " " + rfid + "剩余位置: 小料=" + smallEmpty + ",大料=" + bigEmpty + ",已使用料架=" + usedRfidList + " ";
}
}
public class AllTaskInfo
{
public int smallTask = -1;
public int bigTask = -1;
//public int packageTask = -1;
public string ToStr()
{
return " 剩余任务: 小料=" + smallTask + ",大料=" + bigTask + " ";
}
public bool IsValid()
{
if (smallTask != -1 && bigTask != -1)
{
return true;
}
return false;
}
}
public class AlarmMsg
{
//>>>name : 异常位置名称
public string name = "";
//>>>msgKey : 异常信息唯一标识
public string msgKey = "";
//>>>msgValue : 异常信息
public string msgValue = "";
/// <summary>
/// 异常信息
/// </summary>
/// <param name="name">异常位置名称</param>
/// <param name="key">异常信息唯一标识</param>
/// <param name="value">异常信息</param>
public AlarmMsg(string name, string key, string value)
{
this.name = name;
this.msgKey = key;
this.msgValue = value;
}
}
//public class ResultData
//{
// public int code { get; set; }
// public string msg { get; set; }
// public object data { get; set; }
//}
}

using Asa.RFID;
using OnlineStore.Common;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OnlineStore.DeviceLibrary
{
public class RFIDManager
{
private static ReadAll readAll = new ReadAll("TheRFID");
private static bool IsOpen = false;
private static ConcurrentDictionary<string, string> LastRfidMap = new ConcurrentDictionary<string, string>();
public static void Open()
{
if (IsOpen)
{
return;
}
try
{
int port = Setting_Init.Device_RfidServer_Port;
if (port <= 0)
{
port = 13000;
}
LogUtil.info("RFID Server Open,port=" + port);
readAll.Start(port);
IsOpen = true;
}
catch (Exception ex)
{
LogUtil.error("Open 出错:" + ex.ToString());
}
}
private static void ReadAll_Log(string ip, string log)
{
LogUtil.LOGGER.Info("RFID : [" + ip + "] " + log);
}
public static RFIDData ReadRFID(string ip, bool isClear = false)
{
try
{
if (String.IsNullOrEmpty(ip).Equals(false))
{
if (isClear)
{
readAll.Clear(ip);
}
Thread.Sleep(1000);
string outValue = readAll.Read(ip);
if (outValue.Equals("000"))
{
// LogUtil.error("ReadRFID[" + ip + "]=" + outValue);
}
RFIDData data = new RFIDData(outValue);
return data;
}
}
catch (Exception ex)
{
LogUtil.error("ReadRFID[" + ip + "] [" + isClear + "] 出错:" + ex.ToString());
}
return new RFIDData();
}
public static void Close()
{
try
{
if (readAll != null)
{
readAll.Stop();
}
}
catch (Exception ex)
{
LogUtil.error("关闭RFID出错:" + ex.ToString());
}
}
}
public class RFIDData
{
public string StrData = "";
public RFIDData(string data="00")
{
if (String.IsNullOrEmpty(data))
{
data = "00";
}
this.StrData = data;
}
public string NumStr()
{
return StrData;
}
internal static bool IsRealRfid(string shelfRfid)
{
//判断料架号是否是真实的料架号
//混合料架用F
if (shelfRfid.StartsWith("F"))
//if (shelfRfid.StartsWith("C") || shelfRfid.StartsWith("D"))
{
int num = -1;
try
{
num = Convert.ToInt32(shelfRfid.Substring(1, shelfRfid.Length - 1));
}
catch (Exception ex)
{
}
if (num > 0)
{
return true;
}
}
return false;
}
}
}
......@@ -10,21 +10,32 @@ using System.Threading.Tasks;
[Serializable]
public class ReelParam
{
/// <summary>
/// 创建新出入库信息
/// </summary>
/// <param name="wareNo">二维码内容</param>
/// <param name="platew">宽度</param>
/// <param name="plateh">高度</param>
/// <param name="IsNg">是否是入库NG料</param>
/// <param name="ngMsg">NG消息</param>
public ReelParam(string wareNo = "", int platew = 0, int plateh = 0, bool _IsNg = false, string ngMsg = "")
///// <summary>
///// 创建新出入库信息
///// </summary>
///// <param name="wareNo">二维码内容</param>
///// <param name="platew">宽度</param>
///// <param name="plateh">高度</param>
///// <param name="IsNg">是否是入库NG料</param>
///// <param name="ngMsg">NG消息</param>
//public ReelParam(string wareNo = "", int platew = 0, int plateh = 0, bool _IsNg = false, string ngMsg = "")
//{
// WareCode = wareNo;
// PlateW = platew;
// PlateH = plateh;
// IsNg = _IsNg;
// NgMsg = ngMsg;
// codeInfos = new List<CodeInfo>();
//}
public ReelParam(string wareNo = "", int platew = 0, int plateh = 0,string startPos="",string pos="", bool _IsNg = false, string ngMsg = "")
{
WareCode = wareNo;
PlateW = platew;
PlateH = plateh;
IsNg = _IsNg;
NgMsg = ngMsg;
this.StartPos = startPos;
this.TargetPos = TargetPos;
codeInfos = new List<CodeInfo>();
}
/// <summary>
......@@ -32,9 +43,13 @@ public class ReelParam
/// </summary>
public string WareCode { get; set; }
/// <summary>
/// 取料位置
/// </summary>
public string StartPos { get; set; }
/// <summary>
/// 库位号
/// </summary>
public string PosID { get; set; }
public string TargetPos { get; set; }
public string bitmapfilename = "";
public List<CodeInfo> codeInfos { get; set; }
/// <summary>
......@@ -108,7 +123,7 @@ public class ReelParam
else
{
return $":[{PosID}][{WareCode}][{RFID}][{PlateW}x{PlateH}]";
return $":[{TargetPos}][{WareCode}][{RFID}][{PlateW}x{PlateH}]";
}
}
bool islog = false;
......
......@@ -645,13 +645,12 @@ namespace DeviceLibrary
}
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 Dictionary<string, Object> data { get; set; }
}
/// <summary>
///1=设备联机(正常就绪)(入库后,BOX恢复原始状态)(出库后,移载装置恢复原始状态),
......
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class InReelBean
{
//设备名称
public string Name;
//料盘检测信号
public string Reel_Check = "Reel_Check";
MoveInfo MoveInfo;
public string ErrMsgTxt = "";
//private string LastCode;
private List<CodeLibrary.CodeInfo> LastCode;
public TrayInfo CurrTray = null;
public string PosName;
public InReelBean(string name )
{
this.Name = name;
this.PosName = name;
MoveInfo = new MoveInfo(name, false);
#region 初始化IO
string ioStr = name + "_";
Reel_Check = ioStr + Reel_Check;
#endregion
}
public void Reset()
{
MoveInfo.NewMove(MoveStep.Wait);
MoveInfo.log("执行重置,清理当前条码:"+LastCode);
LastCode = new List<CodeLibrary.CodeInfo>();
ErrMsgTxt = "";
}
public bool ReelReady()
{
if (MoveInfo.MoveStep.Equals(MoveStep.IN05_ReelReady))
{
return true;
}
return false;
}
public void ReelLeave()
{
MoveInfo.NewMove(MoveStep.Wait);
MoveInfo.log("料盘已离开:执行重置,清理当前条码:" + LastCode);
LastCode = new List<CodeLibrary.CodeInfo> ();
ErrMsgTxt = "";
}
bool pause = false;
public void Pause()
{
pause = true;
}
public void Resume()
{
pause = false;
}
private Stopwatch reelCheckWatch = new Stopwatch();
public bool Process()
{
if (pause)
return false;
if (RobotManage.mainMachine.CheckWait(MoveInfo))
{
return false;
}
switch (MoveInfo.MoveStep)
{
case MoveStep.Wait:
//判断定位气缸是否下降到位
if (IOManager.IOValue(Reel_Check).Equals(IO_VALUE.HIGH))
{
if (RobotManage.checkWatch(reelCheckWatch, 1000, true))
{
//默认是进来的料架
MoveInfo.NewMove(MoveStep.IN01_WaitCheck);
MoveInfo.log("检测到料盘信号");
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(Reel_Check, IO_VALUE.HIGH));
ErrMsgTxt = "";
}
}
else
{
reelCheckWatch.Reset();
}
break;
case MoveStep.IN01_WaitCheck:
IN02_ScanCode();
break;
case MoveStep.IN02_ScanCode:
if (ScanCodeTask == null || ScanCodeTask.IsCompleted)
{
MoveInfo.NewMove(MoveStep.IN03_GetPos);
MoveInfo.log("获取库位号");
}
else if (MoveInfo.IsTimeOut(60))
{
ErrMsgTxt = MoveInfo.Name + "[" + MoveInfo.MoveStep + "] 扫码执行结束超时 [" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
}
break;
case MoveStep.IN03_GetPos:
if (GetPosTask == null || GetPosTask.IsCompleted)
{
MoveInfo.NewMove(MoveStep.IN05_ReelReady);
MoveInfo.log("料盘已准备好,等待取料");
}
else if (MoveInfo.IsTimeOut(60))
{
ErrMsgTxt = MoveInfo.Name + "[" + MoveInfo.MoveStep + "] 获取库位号超时 [" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
}
break;
case MoveStep.IN05_ReelReady:
break;
default:
MoveInfo.log($" 未找到对应步骤:{MoveInfo.MoveStep}");
return true;
}
return false;
}
private Task ScanCodeTask = null;
private Task GetPosTask = null;
private void IN02_ScanCode()
{
try
{
MoveInfo.NewMove(MoveStep.IN02_ScanCode);
MoveInfo.log("开始扫码");
ScanCodeTask = Task.Factory.StartNew(delegate
{
string[] cameraName=Setting_Init.CameraScan_IN_2;
if (Name.Contains("1"))
{
cameraName = Setting_Init.CameraScan_IN_1;
}
LastCode= CodeManager.CameraScan(cameraName.ToList());
MoveInfo.log("扫码完成:");
});
}
catch (Exception ex)
{
LogUtil.error("IN02_ScanCode 扫码出错:", ex);
}
}
private void IN03_GetPos()
{
try
{
MoveInfo.NewMove(MoveStep.IN03_GetPos);
string codestr = CodeManager.ProcessCode(LastCode);
if (LastCode.Count <= 0 || codestr.Equals(""))
{
CurrTray = TrayInfo.newNgTray(codestr, "扫码失败");
MoveInfo.log("未扫到条码,直接NG ");
}
else
{
MoveInfo.log("获取库位号: " + codestr);
GetPosTask = Task.Factory.StartNew(delegate
{
while (MoveInfo.MoveStep.Equals(MoveStep.IN03_GetPos))
{
string shelfRfid = RobotManage.mainMachine.getReadyShelf();
if (String.IsNullOrEmpty(shelfRfid))
{
//无可用料架
ErrMsgTxt = $"{Name}:{codestr}暂无可用料架";
MoveInfo.errlog("获取库位号: " + ErrMsgTxt + ",等待3秒后重新获取");
Thread.Sleep(3000);
}
else
{
ClearWarnMsg("暂无可用料架");
//获取库位号
string outMsg = "";
CurrTray = HttpServer.GetLocation(codestr, shelfRfid, out outMsg);
//需要取放料,且料架已准备好
if (outMsg.Equals(""))
{
ClearWarnMsg("getLocation");
MoveInfo.log("获取位置成功:" + CurrTray.ToStr());
}
else
{
ErrMsgTxt = " getLocation " + outMsg;
}
break;
}
}
});
}
}
catch (Exception ex)
{
LogUtil.error("IN03_GetPos 扫码出错:", ex);
}
}
private void ClearWarnMsg(string v)
{
if (ErrMsgTxt.Contains(v))
{
ErrMsgTxt = "";
}
}
bool movelock = false;
internal void Lock()
{
movelock = true;
}
internal void Unlock()
{
movelock = false;
}
}
}
......@@ -12,102 +12,6 @@ using System.Threading.Tasks;
namespace DeviceLibrary
{
//[Serializable]
//public class ReelParam
//{
// /// <summary>
// /// 创建新出入库信息
// /// </summary>
// /// <param name="wareNo">二维码内容</param>
// /// <param name="platew">宽度</param>
// /// <param name="plateh">高度</param>
// /// <param name="IsNg">是否是入库NG料</param>
// /// <param name="ngMsg">NG消息</param>
// public ReelParam(string wareNo = "", int platew = 0, int plateh = 0, bool _IsNg = false, string ngMsg = "")
// {
// WareCode = wareNo;
// PlateW = platew;
// PlateH = plateh;
// IsNg = _IsNg;
// NgMsg = ngMsg;
// }
// /// <summary>
// /// 物品二维码信息
// /// </summary>
// public string WareCode { get; set; }
// /// <summary>
// /// 库位号
// /// </summary>
// public string PosID { get; set; }
// public string bitmapfilename = "";
// public List<CodeInfo> codeInfos { get; set; }
// /// <summary>
// /// 料盘高度
// /// </summary>
// public int PlateH { get; set; }
// /// <summary>
// /// 料盘宽度
// /// </summary>
// public int PlateW { get; set; }
// /// <summary>
// /// 是否是入料NG料
// /// </summary>
// public bool IsNg = false;
// /// <summary>
// /// 入料NG消息
// /// </summary>
// public string NgMsg = "";
// /// <summary>
// /// 物料编码
// /// </summary>
// public string PN { get; set; }
// /// <summary>
// /// 数量
// /// </summary>
// public int QTY { get; set; } = 0;
// /// <summary>
// /// 厂家代码
// /// </summary>
// public string FC { get; set; }
// /// <summary>
// /// 唯一序列号
// /// </summary>
// public string RI { get; set; }
// /// <summary>
// /// 批次号
// /// </summary>
// public string Batch { get; set; }
// public bool ReelOnFixture { get; internal set; } = false;
// public int HeightPos = 0;
// public ReelParam clone()
// {
// ReelParam dstobject;
// using (MemoryStream mStream = new MemoryStream())
// {
// BinaryFormatter bf = new BinaryFormatter();
// bf.Serialize(mStream, this);
// mStream.Seek(0, SeekOrigin.Begin);//指定当前流的位置为流的开头。
// dstobject = (ReelParam)bf.Deserialize(mStream);
// mStream.Close();
// }
// return dstobject;
// }
// public string ToStr()
// {
// if (IsNg)
// {
// return crc.GetString(L.in_store_ng,"入库NG")+ $":{NgMsg}[{WareCode}]";
// }
// else
// {
// return crc.GetString(L.posnum, "库位号") + $":[{PosID}][{WareCode}] ";
// }
// }
//}
[Serializable]
class BoxStorePosition {
......
......@@ -121,7 +121,7 @@ namespace DeviceLibrary
var ac = RobotManage.allPositionMap.Values.ToArray()[CurrentPosIndex];
var reel = new ReelParam("auto", ac.BagWidth, ac.BagHigh);
if (!boxTransport.Start(new BoxStorePosition(Config, ac, reel), new BoxStorePosition(Config, ac, reel), StoreMoveType.InStore))
if (!boxTransport.Start(new BoxStorePosition(Config, ac, reel), new BoxStorePosition(Config, ac, reel), StoreMoveType.PutReel))
{
AIOTMoveInfo.log($"料仓周转启动失败");
AutoInOutTest = false;
......@@ -177,7 +177,7 @@ namespace DeviceLibrary
AIOTMoveInfo.log($"开始转运料盘第二盘");
ac = RobotManage.allPositionMap.Values.ToArray()[CurrentPosIndex - 1];
reel = new ReelParam("auto", ac.BagWidth, ac.BagHigh);
if (!boxTransport.Start(new BoxStorePosition(Config, ac, reel), new BoxStorePosition(Config, ac, reel), StoreMoveType.InStore))
if (!boxTransport.Start(new BoxStorePosition(Config, ac, reel), new BoxStorePosition(Config, ac, reel), StoreMoveType.PutReel))
{
AIOTMoveInfo.log($"料仓周转启动失败");
AutoInOutTest = false;
......@@ -224,7 +224,7 @@ namespace DeviceLibrary
}
var ac2 = RobotManage.allPositionMap.Values.ToArray()[CurrentPosIndex - 2];
reel = new ReelParam("auto", ac2.BagWidth, ac2.BagHigh);
if (!boxTransport.Start(new BoxStorePosition(Config, ac1, reel), new BoxStorePosition(Config, ac2, reel), StoreMoveType.InStore))
if (!boxTransport.Start(new BoxStorePosition(Config, ac1, reel), new BoxStorePosition(Config, ac2, reel), StoreMoveType.PutReel))
{
AIOTMoveInfo.log($"料仓周转启动失败");
AutoInOutTest = false;
......
......@@ -76,5 +76,15 @@ namespace DeviceLibrary
LogUtil.info("按下启动按钮");
ProcessMsgEvent?.Invoke(Msg.get());
}
private void LeftNgDoorOpen()
{
clearNgPos("NG_1");
}
private void RightNgDoorOpen()
{
clearNgPos("NG_7");
}
}
}
......@@ -35,9 +35,7 @@ namespace DeviceLibrary
public MoveInfo ResetMoveInfo;
/// <summary>
/// 右侧移动信息
/// </summary>
public MoveInfo StoreMoveInfo;
public MoveInfo AIOTMoveInfo;
......@@ -55,7 +53,7 @@ namespace DeviceLibrary
public event Action<string, StoreMoveType, bool> InOutEndProcessEvent;
public ServerCommunication ServerCM;
string CID = ServerCommunication.CID;
//string CID = ServerCommunication.CID;
/// <summary>
/// 开始运行的时间
/// </summary>
......@@ -66,8 +64,13 @@ namespace DeviceLibrary
/// </summary>
public bool isInSuddenDown = false;
public List<InReelBean> inReelBeans = new List<InReelBean>();
public Dictionary<string, OutShelfBean> outShelfBeans = new Dictionary<string, OutShelfBean>();
public Dictionary<string, ReelParam> NgPosMap = new Dictionary<string, ReelParam>();
public MainMachine(Robot_Config _config) {
Config = _config;
crc.LanguageChangeEvent += Crc_LanguageChangeEvent;
......@@ -77,8 +80,8 @@ namespace DeviceLibrary
AIOTMoveInfo = new MoveInfo("移库测试");
ServerCM = new ServerCommunication();
ServerCM.InStoreEvent += ServerCM_InStoreEvent1;
ServerCM.OutStoreEvent += ServerCM_OutStoreEvent;
//ServerCM.InStoreEvent += ServerCM_InStoreEvent1;
//ServerCM.OutStoreEvent += ServerCM_OutStoreEvent;
#region 初始化led
RunningLed = new Led(Config.DOList[IO_Type.Run_Led].GetIOAddr(),LedColor.green);
StandbyLed = new Led(Config.DOList[IO_Type.Standby_Led].GetIOAddr(), LedColor.yellow);
......@@ -105,44 +108,30 @@ namespace DeviceLibrary
IOMonitor.RegisterIO(IO_Type.Reset_BTN, Config, IO_VALUE.HIGH, Reset_BTN, 2500,100);
IOMonitor.RegisterIO(IO_Type.Reset_BTN, Config, IO_VALUE.HIGH, HomeReset_BTN, 2500, 3000);
LedProcessInit();
}
private void ServerCM_OutStoreEvent(JobInfo jobInfo)
{
AddOutStoreTask(jobInfo.WareNum, jobInfo.PosId, jobInfo.plateW, jobInfo.plateH);
}
//NG门打开又关闭后,需要清空NG库位信息
IOMonitor.RegisterIO(IO_Type.Left_NGDoor_Close_Check, Config,IO_VALUE.LOW, LeftNgDoorOpen, 2500, 500);
IOMonitor.RegisterIO(IO_Type.Right_NGDoor_Close_Check, Config, IO_VALUE.LOW, RightNgDoorOpen, 2500, 500);
private bool ServerCM_InStoreEvent1(JobInfo jobInfo, bool ng, string msg)
{
if (ng)
for(int i = 0; i < 2; i++)
{
StoreMoveInfo.MoveParam.IsNg = true;
StoreMoveInfo.MoveParam.NgMsg = msg;
StoreMoveInfo.NextMoveStep(MoveStep.Wait);
StoreMoveInfo.WaitList.Add(WaitResultInfo.WaitMsg(msg, MsgLevel.alarm));
StoreMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
return true;
InReelBean inReel = new InReelBean("IN_"+i);
inReelBeans.Add(inReel);
}
else
{
return StartInStore(jobInfo, StoreMoveInfo);
}
}
public bool StartInStore(JobInfo jobInfo, MoveInfo moveInfo)
{
if (moveInfo.MoveStep == MoveStep.InWaitServerCallback)
for (int i = 0; i < 5; i++)
{
moveInfo.MoveParam.WareCode = jobInfo.WareNum;
moveInfo.MoveParam.PosID = jobInfo.PosId;
moveInfo.MoveParam.PlateH = jobInfo.plateH;
moveInfo.MoveParam.PlateW = jobInfo.plateW;
moveInfo.NextMoveStep(MoveStep.StoreIn01);
moveInfo.log($"料盘等待入库:{moveInfo.MoveParam.ToStr()}");
return true;
OutShelfBean outShelf = new OutShelfBean("U" + i);
outShelfBeans.Add(outShelf.Name, outShelf);
}
return false;
LedProcessInit();
}
//private void ServerCM_OutStoreEvent(JobInfo jobInfo)
//{
// AddOutStoreTask(jobInfo.WareNum, jobInfo.PosId, jobInfo.plateW, jobInfo.plateH);
//}
private void Crc_LanguageChangeEvent(object sender, EventArgs e)
{
......@@ -203,6 +192,16 @@ namespace DeviceLibrary
AutoInOutTestProcess();
else
StoreProcess();
foreach(InReelBean bean in inReelBeans)
{
bean.Process();
}
foreach (OutShelfBean bean in outShelfBeans.Values)
{
bean.Process();
}
}
else if (runStatus == RunStatus.HomeReset)
{
......@@ -278,6 +277,14 @@ namespace DeviceLibrary
ResetMoveInfo.NewMove(MoveStep.H01_HomeReset);
ResetMoveInfo.log("开始回原");
ResetMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
foreach (InReelBean bean in inReelBeans)
{
bean.Reset();
}
foreach (OutShelfBean bean in outShelfBeans.Values)
{
bean.Reset();
}
}
//强制回原
bool forceHome=true;
......@@ -295,7 +302,7 @@ namespace DeviceLibrary
break;
case MoveStep.H02_HomeReset_01:
ResetMoveInfo.NextMoveStep(MoveStep.H02_HomeReset);
ResetMoveInfo.log("进出轴,批量轴回原,料串检测杆退回避让端");
ResetMoveInfo.log("进出轴 回原 ");
InOut_Axis.HomeMove(ResetMoveInfo, forceHome);
break;
case MoveStep.H02_HomeReset:
......@@ -332,43 +339,43 @@ namespace DeviceLibrary
var TrayCheck_Fixture = IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH);
if (TrayCheck_Fixture)
{
ResetMoveInfo.log($"回原时检测到又滞留物料:TrayCheck_Fixture={TrayCheck_Fixture}");
StoreMoveInfo.MoveParam.PosID = Setting_Init.Runtime_PosID;
StoreMoveInfo.MoveParam.PlateH = Setting_Init.Runtime_PlateH;
StoreMoveInfo.MoveParam.PlateW = Setting_Init.Runtime_PlateW;
StoreMoveInfo.MoveParam.WareCode = Setting_Init.Runtime_WareCode;
StoreMoveInfo.MoveParam.IsNg = Setting_Init.Runtime_IsNg;
StoreMoveInfo.MoveParam.NgMsg = Setting_Init.Runtime_NgMsg;
if (Setting_Init.Runtime_IsInStore)
{
ResetMoveInfo.log("入库物料:" + StoreMoveInfo.MoveParam.ToStr());
if (TrayCheck_Fixture)
StoreMoveInfo.MoveParam.ReelOnFixture = true;
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn02);
}
else if (TrayCheck_Fixture)
{
ResetMoveInfo.log("出库物料在料叉上:" + StoreMoveInfo.MoveParam.ToStr());
StoreMoveInfo.MoveParam.ReelOnFixture = true;
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut10);
}
else
{
ResetMoveInfo.log("出库物料在门口:" + StoreMoveInfo.MoveParam.ToStr());
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut_WaitMT);
}
//ResetMoveInfo.log($"回原时检测到又滞留物料:TrayCheck_Fixture={TrayCheck_Fixture}");
//StoreMoveInfo.MoveParam.TargetPos = Setting_Init.Runtime_PosID;
//StoreMoveInfo.MoveParam.PlateH = Setting_Init.Runtime_PlateH;
//StoreMoveInfo.MoveParam.PlateW = Setting_Init.Runtime_PlateW;
//StoreMoveInfo.MoveParam.WareCode = Setting_Init.Runtime_WareCode;
//StoreMoveInfo.MoveParam.IsNg = Setting_Init.Runtime_IsNg;
//StoreMoveInfo.MoveParam.NgMsg = Setting_Init.Runtime_NgMsg;
//if (Setting_Init.Runtime_IsInStore)
//{
// ResetMoveInfo.log("入库物料:" + StoreMoveInfo.MoveParam.ToStr());
// if (TrayCheck_Fixture)
// StoreMoveInfo.MoveParam.ReelOnFixture = true;
// StoreMoveInfo.NextMoveStep(MoveStep.StoreIn02);
//}
//else if (TrayCheck_Fixture)
//{
// ResetMoveInfo.log("出库物料在料叉上:" + StoreMoveInfo.MoveParam.ToStr());
// StoreMoveInfo.MoveParam.ReelOnFixture = true;
// StoreMoveInfo.NextMoveStep(MoveStep.StoreOut10);
//}
//else
//{
// ResetMoveInfo.log("出库物料在门口:" + StoreMoveInfo.MoveParam.ToStr());
// StoreMoveInfo.NextMoveStep(MoveStep.StoreOut_WaitMT);
//}
}
else if (!string.IsNullOrEmpty(Setting_Init.Runtime_PlateInFix.Val)) {
var ac = CSVPositionReader<ACStorePosition>.GetPositon(StoreMoveInfo.MoveParam.PosID);
var dc = CSVPositionReader<ACStorePosition>.GetPositon(Setting_Init.Runtime_PlateInFix);
boxTransport.Start(new BoxStorePosition(Config, dc, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, ac, StoreMoveInfo.MoveParam), StoreMoveType.InStore, true);
ResetMoveInfo.log($"开始转运料盘:{Setting_Init.Runtime_PlateInFix}=>{StoreMoveInfo.MoveParam.PosID}");
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut11);
}
else
//else if (!string.IsNullOrEmpty(Setting_Init.Runtime_PlateInFix.Val)) {
// var ac = CSVPositionReader<ACStorePosition>.GetPositon(StoreMoveInfo.MoveParam.TargetPos);
// var dc = CSVPositionReader<ACStorePosition>.GetPositon(Setting_Init.Runtime_PlateInFix);
// boxTransport.Start(new BoxStorePosition(Config, dc, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, ac, StoreMoveInfo.MoveParam), StoreMoveType.InStore, true);
// ResetMoveInfo.log($"开始转运料盘:{Setting_Init.Runtime_PlateInFix}=>{StoreMoveInfo.MoveParam.TargetPos}");
// StoreMoveInfo.NextMoveStep(MoveStep.StoreOut11);
//}
//else
{
StoreMoveInfo.NewMove(MoveStep.Wait);
}
......@@ -548,5 +555,131 @@ namespace DeviceLibrary
boxTransport.IgnoreX09 = true;
LogUtil.info("按下X09忽略");
}
private void clearNgPos(string ngType)
{
List<string> allPosList = CSVPositionReader<ACStorePosition>.getPositionKeyList();
List<string> leftNgPos = (from m in allPosList where m.StartsWith(ngType) select m).ToList();
if (leftNgPos.Count > 0)
{
foreach (string pos in leftNgPos)
{
if (NgPosMap.ContainsKey(pos))
{
ReelParam reelParam = NgPosMap[pos];
LogUtil.info($"NG门打开,清理NG库位[{pos}]的物料信息:{reelParam.ToStr()}");
}
}
}
}
private string getNextNgPos(int size = 7)
{
string ngType = "NG_" + size;
List<string> allPosList = CSVPositionReader<ACStorePosition>.getPositionKeyList();
List<string> leftNgPos = (from m in allPosList where m.StartsWith(ngType) select m).ToList();
if (leftNgPos.Count > 0)
{
foreach (string pos in leftNgPos)
{
if (!NgPosMap.ContainsKey(pos))
{
LogUtil.info($"获取下一个{size}寸盘的NG库位号: {pos}");
return pos;
}
}
}
return "";
}
private void UpdateNgPos(string ngPos,ReelParam reelParam)
{
if (NgPosMap.ContainsKey(ngPos))
{
ReelParam reel = NgPosMap[ngPos];
NgPosMap.Remove(ngPos);
}
NgPosMap.Add(ngPos, reelParam);
LogUtil.info($"更新NG库位[{ngPos}]的物料信息:{reelParam.ToStr()}");
}
public string getReadyShelf(string split= ",")
{
string rfid = "";
foreach(OutShelfBean bean in outShelfBeans.Values)
{
if (bean.ShelfValid())
{
rfid += bean.currShelfRfid;
}
}
return rfid;
}
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 = getReadyShelf();
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());
}
}
internal string GetShelfPosId(TrayInfo tray)
{
string str = "";
if (tray != null)
{
foreach (OutShelfBean obj in outShelfBeans.Values)
{
if (obj.IsRightShelf(tray, out str))
{
obj.StartPutReel();
LogUtil.info(Name + " " + tray.ToStr() + " 使用料架:" + str + ",更改料架为忙碌状态");
break;
}
}
}
return str;
}
}
}
\ No newline at end of file
using CodeLibrary;
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
namespace DeviceLibrary
{
partial class MainMachine
{
private bool canStartMove()
{
if (!boxTransport.IgnoreX09 && IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH))
{
if (!boxTransport.IgnoreX09 && IOMonitor.IODebound(IO_Type.TrayCheck_Fixture, Config, IO_VALUE.HIGH, 5000))
{
Msg.add(crc.GetString("Res0152", "收到出库任务,但料叉上有料,无法启动,请检查"), MsgLevel.alarm, ErrInfo.X09_BoxNotDetect);
return false;
}
else
{
Msg.add(crc.GetString("Res0152", "收到出库任务,但料叉上有料,无法启动,请检查"), MsgLevel.warning);
return false;
}
}
return true;
}
void StoreProcess()
{
if (CheckWait(StoreMoveInfo))
return;
//常规上料扫码流程
switch (StoreMoveInfo.MoveStep)
{
case MoveStep.Wait:
foreach (InReelBean inReel in inReelBeans)
{
if (inReel.ReelReady())
{
TrayInfo tray = inReel.CurrTray;
//取料
if (tray.ngReel)
{
//NG门关上再放料
if (IOManager.IOValue(IO_Type.Left_NGDoor_Close_Check).Equals(IO_VALUE.HIGH) && IOManager.IOValue(IO_Type.Right_NGDoor_Close_Check).Equals(IO_VALUE.HIGH))
{
string ngPos = getNextNgPos();
if (ngPos == "")
{
//暂无NG空位
}
else
{
//送料到NG
StoreMoveInfo.NewMove(MoveStep.PutReel01_Ready);
StoreMoveInfo.MoveParam = new ReelParam(tray.barcode, tray.plateW, tray.plageH, inReel.PosName, ngPos, tray.ngReel, tray.ngMsg);
StoreMoveInfo.log("准备放料:" + StoreMoveInfo.MoveParam.ToStr());
break;
}
}
}
else
{
//获取料架
string pos = GetShelfPosId(tray);
}
}
}
break;
// //放料,准备放料
// PutReel01_Ready,
////放料:开始移库
//PutReel02_StartM,
////放料:等待取料完成
//PutReel03_GetReelEnd,
////放料:等待放料完成
//PutReel04_PutReelEnd,
////放料:放料全部结束
//PutReel05_End,
case MoveStep.PutReel01_Ready:
ACStorePosition startP = CSVPositionReader<ACStorePosition>.GetPositon(StoreMoveInfo.MoveParam.StartPos);
ACStorePosition targetP = CSVPositionReader<ACStorePosition>.GetPositon(StoreMoveInfo.MoveParam.TargetPos);
bool result = boxTransport.Start(new BoxStorePosition(Config, startP, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, targetP, StoreMoveInfo.MoveParam), StoreMoveType.PutReel, true);
if (result)
{
StoreMoveInfo.NewMove(MoveStep.PutReel02_StartM);
StoreMoveInfo.log("开始放料:" + StoreMoveInfo.MoveParam.ToStr());
}
break;
case MoveStep.PutReel02_StartM:
if (boxTransport.IsTakedReel)
{
StoreMoveInfo.NewMove(MoveStep.PutReel03_GetReelEnd);
StoreMoveInfo.log("取料完成:" + StoreMoveInfo.MoveParam.ToStr());
}
break;
case MoveStep.PutReel03_GetReelEnd:
if (boxTransport.IsPutOnOut|| boxTransport.IsComplateOrFree)
{
StoreMoveInfo.NewMove(MoveStep.PutReel04_PutReelEnd);
StoreMoveInfo.log("放料完成:" + StoreMoveInfo.MoveParam.ToStr());
//TODO 通知服务器
}
break;
case MoveStep.PutReel04_PutReelEnd:
if (boxTransport.IsComplateOrFree)
{
StoreMoveInfo.NewMove(MoveStep.PutReel05_End);
StoreMoveInfo.log("放料结束:" + StoreMoveInfo.MoveParam.ToStr());
}
break;
case MoveStep.PutReel05_End:
StoreMoveInfo.EndMove();
break;
default:
StoreMoveInfo.log($"未找到对应步骤:{StoreMoveInfo.MoveStep}");
break;
}
}
string StoreState()
{
string state = crc.GetString("Res0162", "空闲中");
if (StoreMoveInfo.MoveStep == MoveStep.PutReel01_Ready)
{
state = crc.GetString("Res0072","准备放料") + ":[]->[" + StoreMoveInfo.MoveParam.TargetPos+"]";
}
else if (StoreMoveInfo.MoveStep >= MoveStep.PutReel03_GetReelEnd)
{
state = crc.GetString("Res0163", "取料中") + ":" + StoreMoveInfo.MoveParam.TargetPos;
}
else if (StoreMoveInfo.MoveStep >= MoveStep.PutReel05_End)
{
state = crc.GetString("Res0164", "放料中") + ":" + StoreMoveInfo.MoveParam.TargetPos;
}
return state;
}
}
}
\ No newline at end of file
using CodeLibrary;
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
partial class MainMachine
{
public bool IsInStoreReady
{
get => IOValue(IO_Type.IN_1_Reel_Check).Equals(IO_VALUE.HIGH)
|| StoreMoveInfo.MoveStep == MoveStep.Wait || StoreMoveInfo.MoveStep == MoveStep.InWaitServerCallback;
}
StoreJobList OutStoreJobList = new StoreJobList("");
public void AddOutStoreTask(string warecode, string posId, int plateW, int plateH)
{
JobInfo jobInfo = new JobInfo(warecode, posId, plateW, plateH);
OutStoreJobList.Enqueue(jobInfo);
LogUtil.info($"添加出库任务队列: {posId},当前任务数量: {OutStoreJobList.Count}");
}
void StoreProcess()
{
if (CheckWait(StoreMoveInfo))
return;
//常规上料扫码流程
switch (StoreMoveInfo.MoveStep)
{
case MoveStep.Wait:
//判断有没有出库任务, 需要入库空闲, 出口空闲
if (OutStoreJobList.Count > 0 && boxTransport.IsComplateOrFree)
{
if (!boxTransport.IgnoreX09 && IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH))
{
if (!boxTransport.IgnoreX09 && IOMonitor.IODebound(IO_Type.TrayCheck_Fixture, Config, IO_VALUE.HIGH, 5000))
{
Msg.add(crc.GetString("Res0152", "收到出库任务,但料叉上有料,无法启动,请检查"), MsgLevel.alarm, ErrInfo.X09_BoxNotDetect);
}
else
Msg.add(crc.GetString("Res0152", "收到出库任务,但料叉上有料,无法启动,请检查"), MsgLevel.warning);
return;
}
else
boxTransport.IgnoreX09 = false;
if (OutStoreJobList.Dequeue(out JobInfo jobInfo))
{
StoreMoveInfo.NewMove(MoveStep.StoreOut10);
StoreMoveInfo.MoveParam.WareCode = jobInfo.WareNum;
StoreMoveInfo.MoveParam.PosID = jobInfo.PosId;
StoreMoveInfo.MoveParam.PlateH = jobInfo.plateH;
StoreMoveInfo.MoveParam.PlateW = jobInfo.plateW;
StoreMoveInfo.MoveParam.IsNg = jobInfo.isNG;
StoreMoveInfo.MoveParam.NgMsg = jobInfo.NgMsg;
Setting_Init.Runtime_IsInStore = false;
Setting_Init.Runtime_PosID = StoreMoveInfo.MoveParam.PosID;
Setting_Init.Runtime_PlateH = StoreMoveInfo.MoveParam.PlateH;
Setting_Init.Runtime_PlateW = StoreMoveInfo.MoveParam.PlateW;
Setting_Init.Runtime_WareCode = StoreMoveInfo.MoveParam.WareCode;
Setting_Init.Runtime_IsNg = StoreMoveInfo.MoveParam.IsNg;
Setting_Init.Runtime_NgMsg = StoreMoveInfo.MoveParam.NgMsg;
StoreMoveInfo.log($"开始出库任务:" + jobInfo.ToStr());
ServerCM.storeStatus = StoreStatus.OutStoreExecute;
return;
}
}
break;
case MoveStep.InWaitServerCallback:
if (StoreMoveInfo.IsTimeOut(10))
{
StoreMoveInfo.log("入口料盘,获取库位失败");
StoreMoveInfo.MoveParam.IsNg = true;
StoreMoveInfo.MoveParam.NgMsg = $"[{CID}]" + crc.GetString("Res0018","无信息物料");
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut_WaitMT);
}
break;
case MoveStep.StoreIn01:
if (!ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.InStoreExecute))
{
Msg.add(crc.GetString("Res0156", "服务器连接异常"), MsgLevel.warning);
return;
}
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn02);
break;
case MoveStep.StoreIn02:
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn03);
var ac = CSVPositionReader<ACStorePosition>.GetPositon(StoreMoveInfo.MoveParam.PosID);
if (ac == null)
{
StoreMoveInfo.log($"找不到库位:" + StoreMoveInfo.MoveParam.PosID);
}
boxTransport.Start(new BoxStorePosition(Config, ac, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, ac, StoreMoveInfo.MoveParam), StoreMoveType.InStore, true);
StoreMoveInfo.log($"开始转运料盘");
break;
case MoveStep.StoreIn03:
if (boxTransport.IsTakedReel)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn04);
StoreMoveInfo.log($"料盘已取走");
}
else
{
Msg.add(crc.GetString("Res0154", "单料口等待料盘离开."), MsgLevel.info);
}
break;
case MoveStep.StoreIn04:
if (boxTransport.IsPutOnOut)
{
if (!ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.InStoreEnd))
{
StoreMoveInfo.CanWhileCount--;
///Msg.add(crc.GetString("Res0156", "服务器连接异常"), MsgLevel.warning);
if (StoreMoveInfo.CanWhileCount>0)
return;
StoreMoveInfo.log($"服务器连接异常");
}
StoreMoveInfo.log($"料盘已到达目的地");
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn05);
}
else
{
Msg.add(crc.GetString("Res0157", "等待料盘送到指定位置."), MsgLevel.info);
}
break;
case MoveStep.StoreIn05:
if (boxTransport.IsComplateOrFree)
{
StoreMoveInfo.log($"料盘已到达目的地");
if (!ServerCM.tryposQuery(StoreMoveInfo.MoveParam.PosID,""))
{
StoreMoveInfo.log($"无法确认入库成功NG处理");
JobInfo jobInfo = new JobInfo(StoreMoveInfo.MoveParam.WareCode, StoreMoveInfo.MoveParam.PosID, StoreMoveInfo.MoveParam.PlateW, StoreMoveInfo.MoveParam.PlateH);
jobInfo.isNG=true;
jobInfo.NgMsg= "Inbound confirmation failed.";
OutStoreJobList.Enqueue(jobInfo);
}
StoreMoveInfo.EndMove();
OutStoreJobList.ClearLastPosid(StoreMoveInfo.MoveParam.PosID);
}
break;
default:
StoreMoveInfo.log($"未找到对应步骤:{StoreMoveInfo.MoveStep}");
break;
}
}
string StoreState()
{
string state = crc.GetString("Res0162", "空闲中");
if (StoreMoveInfo.MoveStep == MoveStep.WaitInStore)
{
state = crc.GetString("Res0072","等待入库物料") + ":" + StoreMoveInfo.MoveParam.PosID;
}
else if (StoreMoveInfo.MoveStep >= MoveStep.StoreOut10)
{
state = crc.GetString("Res0163", "出库中") + ":" + StoreMoveInfo.MoveParam.PosID;
}
else if (StoreMoveInfo.MoveStep >= MoveStep.StoreIn01)
{
state = crc.GetString("Res0164", "入库中") + ":" + StoreMoveInfo.MoveParam.PosID;
}
return state;
}
}
}
\ No newline at end of file
......@@ -113,7 +113,7 @@ namespace DeviceLibrary
}
string lastmsg = "";
public void log(string msg) {
msg = $"[{Name}][{moveStep}][{MoveParam.PosID}-{MoveParam.WareCode}]{msg}";
msg = $"[{Name}][{moveStep}][{MoveParam.TargetPos}-{MoveParam.WareCode}]{msg}";
if (String.Compare(lastmsg,msg, StringComparison.Ordinal)!=0)
{
......@@ -381,11 +381,11 @@ namespace DeviceLibrary
/// <summary>
/// 入库
/// </summary>
InStore = 1,
PutReel = 1,
/// <summary>
/// 出库
/// </summary>
OutStore = 2,
OutStore=2,
/// <summary>
/// 原点返回
/// </summary>
......@@ -393,14 +393,6 @@ namespace DeviceLibrary
/// <summary>
/// 重置
/// </summary>
StoreReset = 4,
///// <summary>
///// 移栽装置的停止,需要先远点返回,然后停止
///// </summary>
//StopMove=5,
///// <summary>
///// 移栽检测托盘
///// </summary>
//CheckFixture=6,
StoreReset = 4,
}
}
\ No newline at end of file
......@@ -113,7 +113,16 @@ namespace DeviceLibrary
Out11,
OutReset,
//放料,准备放料
PutReel01_Ready,
//放料:开始移库
PutReel02_StartM,
//放料:等待取料完成
PutReel03_GetReelEnd,
//放料:等待放料完成
PutReel04_PutReelEnd,
//放料:放料全部结束
PutReel05_End,
StoreIn01, //入库
......@@ -160,7 +169,61 @@ namespace DeviceLibrary
StoreTS16,
StoreTS17,
StoreTS_WaitOutProcess,
StoreTS_Continue
StoreTS_Continue,
//复位:定位气缸下降
SR01_LocationDown,
//出料口:AGV检测到小车
S01_AgvDetect,
//电机正传
S02_LineFRun,
//料架到位
//S03_Shelf_Front_Check,
//等待1秒后停止电机正传,
S04_WaitTime,
//定位气缸上升,
S05_LocationUp,
//读取RFID,
S06_ReadRFID,
//料架准备好,可放料,
S10_ShelfReady,
//放料中
S11_PutReel,
//料架需要离开
S21_ShelfNeedLeave,
//呼叫agv拉料
S22_WaitAGV,
//agv到位
S23_AgvDetect,
//定位气缸下降
S24_LocationDown,
//电机反转
S25_LineRRun,
//等待前端料格检测 On变OFF
S26_ShelfBackHigh,
//等待前端料格检测 On变OFF
S27_ShelfBackLow,
//电机反转延时2秒OFF
S28_WaitTime,
//料盘:等待信号检测
IN01_WaitCheck,
//料盘:扫码
IN02_ScanCode,
//料盘:获取库位号
IN03_GetPos,
//料盘:料盘已准备好,等待取料
IN05_ReelReady,
//料盘:料盘已拿走
IN06_ReelLeave,
}
......
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class OutShelfBean
{
public string Name;
//agv小车检测
public string Agv_Detect = "Agv_Detect";
//出料口前端料格检测
public string Shelf_Front_Check = "Shelf_Front_Check";
//出料口后端料格检测
public string Shelf_Back_Check = "Shelf_Back_Check";
//出料口定位上升端
public string Location_Up = "Location_Up";
//出料口定位下降端,
public string Location_Down = "Location_Down";
//电机正传
public static string Moto_Fwd = "Moto_Fwd";
//电机反转
public static string Moto_Rwd = "Moto_Rwd";
MoveInfo MoveInfo;
public string ErrMsgTxt = "";
private MainMachine mainMachine;
/// <summary>
/// 出料口定位气缸,high=up,low=down
/// </summary>
private CylinderManger locationCylinder;
public string currShelfRfid;
public TrayInfo CurrShelf;
public OutShelfBean(string name )
{
this.Name = name;
MoveInfo = new MoveInfo(name, false);
#region 初始化IO
string ioStr = name + "_";
Agv_Detect = ioStr + Agv_Detect;
Shelf_Front_Check = ioStr + Shelf_Front_Check;
Shelf_Back_Check = ioStr + Shelf_Back_Check;
Location_Up = ioStr + Location_Up;
Location_Down = ioStr + Location_Down;
Moto_Fwd = ioStr + Moto_Fwd;
Moto_Rwd = ioStr + Moto_Rwd;
locationCylinder = new CylinderManger(name + "出料口定位", Location_Up, Location_Down);
#endregion
}
public void Reset()
{
MoveInfo.NewMove(MoveStep.SR01_LocationDown);
MoveInfo.log("执行重置,定位气缸下降");
locationCylinder.ToLow(MoveInfo);
ErrMsgTxt = "";
pause = false;
}
private StoreMoveType storeMoveType = StoreMoveType.None;
bool PreMove = false;
public bool ShelfValid()
{
//料架是否有效可放料
if (currShelfRfid != "")
{
if (MoveInfo.MoveStep.Equals(MoveStep.S10_ShelfReady)||MoveInfo.MoveStep.Equals(MoveStep.S11_PutReel))
{
return true;
}
}
return false;
}
public bool ShelfReady()
{
if (MoveInfo.MoveStep.Equals(MoveStep.S10_ShelfReady))
{
return true;
}
return false;
}
public bool StartPutReel()
{
if (ShelfReady())
{
MoveInfo.NewMove(MoveStep.S11_PutReel);
MoveInfo.log("开始放料");
return true;
}
return false;
}
bool pause = false;
public void Pause()
{
pause = true;
}
public void Resume()
{
pause = false;
}
private void LineFRun(MoveInfo move = null)
{
lineMove(IO_VALUE.LOW, IO_VALUE.HIGH, move);
}
private void LineRRun(MoveInfo move = null)
{
lineMove(IO_VALUE.HIGH, IO_VALUE.LOW, move);
}
private void LineStopRun(MoveInfo move = null)
{
lineMove(IO_VALUE.LOW, IO_VALUE.LOW, move);
}
private void lineMove(IO_VALUE rValue,IO_VALUE fValue,MoveInfo move)
{
IOManager.IOMove(Moto_Rwd, rValue);
IOManager.IOMove(Moto_Fwd, fValue);
if (move != null)
{
move.WaitList.Add(WaitResultInfo.WaitIO(Moto_Fwd, fValue));
move.WaitList.Add(WaitResultInfo.WaitIO(Moto_Rwd, rValue));
}
}
public bool Process()
{
if (pause)
return false;
if (mainMachine.CheckWait(MoveInfo))
return false;
switch (MoveInfo.MoveStep)
{
case MoveStep.Wait:
//判断定位气缸是否下降到位
if (locationCylinder.IsLow())
{
if (IOManager.IOValue(Shelf_Front_Check).Equals(IO_VALUE.HIGH) || IOManager.IOValue(Shelf_Back_Check).Equals(IO_VALUE.HIGH))
{
//默认是进来的料架
MoveInfo.NewMove(MoveStep.S02_LineFRun);
MoveInfo.log("检测到料架信号,电机正传");
LineFRun();
//等待后端料格检测
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(Shelf_Front_Check, IO_VALUE.HIGH));
}
else if (IOManager.IOValue(Agv_Detect).Equals(IO_VALUE.HIGH))
{
//小车已到位
//默认是进来的料架
MoveInfo.NewMove(MoveStep.S02_LineFRun);
MoveInfo.log("检测到AGV小车,电机正传");
LineFRun();
//等待后端料格检测
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(Shelf_Front_Check, IO_VALUE.HIGH));
}
}
break;
case MoveStep.SR01_LocationDown:
MoveInfo.NewMove(MoveStep.Wait);
MoveInfo.log("复位完成");
break;
case MoveStep.S02_LineFRun:
MoveInfo.NewMove(MoveStep.S04_WaitTime);
MoveInfo.log("检测到料架前端信号,再转动1秒钟");
LineFRun();
//等待后端料格检测
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(Shelf_Front_Check, IO_VALUE.HIGH));
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
break;
case MoveStep.S04_WaitTime:
MoveInfo.NewMove(MoveStep.S05_LocationUp);
MoveInfo.log("电机停止,定位气缸上升");
LineStopRun();
locationCylinder.ToHigh(MoveInfo);
break;
case MoveStep.S05_LocationUp:
MoveInfo.NextMoveStep(MoveStep.S06_ReadRFID);
MoveInfo.log("读取RFID");
MoveInfo.NextMoveStep(MoveStep.S10_ShelfReady);
break;
case MoveStep.S10_ShelfReady:
break;
case MoveStep.S11_PutReel:
break;
case MoveStep.S21_ShelfNeedLeave:
//呼叫AGV小车
break;
case MoveStep.S22_WaitAGV:
//呼叫agv拉料
break;
case MoveStep.S23_AgvDetect:
MoveInfo.NextMoveStep(MoveStep.S24_LocationDown);
MoveInfo.log("定位气缸下降");
locationCylinder.ToLow(MoveInfo);
break;
case MoveStep.S24_LocationDown:
MoveInfo.NextMoveStep(MoveStep.S25_LineRRun);
MoveInfo.log("电机反转");
LineRRun();
break;
case MoveStep.S25_LineRRun:
MoveInfo.NextMoveStep(MoveStep.S26_ShelfBackHigh);
MoveInfo.log("等待后端检测信号亮");
LineRRun();
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(Shelf_Back_Check, IO_VALUE.HIGH));
break;
case MoveStep.S26_ShelfBackHigh:
MoveInfo.NextMoveStep(MoveStep.S27_ShelfBackLow);
MoveInfo.log("等待后端检测信号灭");
LineRRun();
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(Shelf_Back_Check, IO_VALUE.LOW));
break;
case MoveStep.S27_ShelfBackLow:
MoveInfo.NextMoveStep(MoveStep.S28_WaitTime);
MoveInfo.log("继续转动2秒");
LineRRun();
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(Shelf_Back_Check, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
break;
case MoveStep.S28_WaitTime:
MoveInfo.NextMoveStep(MoveStep.Wait);
MoveInfo.log("料架已离开");
LineStopRun();
break;
default:
MoveInfo.log($"{storeMoveType}:未找到对应步骤:{MoveInfo.MoveStep}");
return true;
}
return false;
}
bool movelock = false;
internal void Lock()
{
movelock = true;
}
internal void Unlock()
{
movelock = false;
}
public bool IsDis()
{
return false;
}
internal bool IsRightShelf(TrayInfo CurrTray, out string ShelfPosId)
{
ShelfPosId = "";
if (IsDis())
{
return false;
}
if (ShelfValid())
{
if (CurrShelf.realRFID.Equals(CurrTray.realRFID))
{
if (String.IsNullOrEmpty(CurrShelf.rfid))
{
CurrShelf.rfid = CurrTray.rfid;
LogUtil.info(Name + "增加虚拟料架号绑定:" + CurrShelf.ToStr());
}
ShelfPosId = Name + CurrTray.shelfP;
return true;
}
else if (String.IsNullOrEmpty(CurrTray.realRFID))
{
if ((!CurrShelf.rfid.Equals("")) && CurrShelf.rfid.Equals(CurrTray.rfid))
{
CurrTray.realRFID = CurrShelf.realRFID;
ShelfPosId = Name + CurrTray.shelfP;
return true;
}
if (!String.IsNullOrEmpty(CurrTray.usedRfidList))
{
string[] array = CurrTray.usedRfidList.Split(',');
//若料架已使用过,直接返回false
if (array.Contains(CurrShelf.realRFID))
{
return false;
}
}
if (CurrShelf.rfid.Equals(""))
{
CurrShelf.rfid = CurrTray.rfid;
CurrTray.realRFID = CurrShelf.realRFID;
LogUtil.info(Name + "增加虚拟料架号绑定:" + CurrShelf.ToStr());
ShelfPosId = Name + CurrTray.shelfP;
return true;
}
}
}
return false;
}
}
}
......@@ -76,7 +76,7 @@ namespace DeviceLibrary
To = to.clone();
MoveInfo.NewMove(MoveStep.StoreTS10);
MoveInfo.log($"{storeMoveType}:开始运输料盘,直接到:{to.posid}");
MoveInfo.MoveParam.PosID = $"NA=>{To.posid}";
MoveInfo.MoveParam.TargetPos = $"NA=>{To.posid}";
}
else
{
......@@ -87,7 +87,7 @@ namespace DeviceLibrary
MoveInfo.NewMove(MoveStep.StoreTS01);
MoveInfo.log($"{storeMoveType}:开始运输料盘,从:{from.posid},到:{to.posid}");
MoveInfo.MoveParam.PosID = $"{From.posid}=>{To.posid}";
MoveInfo.MoveParam.TargetPos = $"{From.posid}=>{To.posid}";
MoveInfo.MoveParam.ReelOnFixture = From.Reel.ReelOnFixture;
}
if (To.posid == BoxStorePosition.ngdoor)
......@@ -252,7 +252,7 @@ namespace DeviceLibrary
IgnoreX09 = false;
MoveInfo.NextMoveStep(MoveStep.StoreTS16);
MoveInfo.log($"{storeMoveType}:安全检查");
InOutEndProcess(StoreMoveType.InStore, To.posid);
InOutEndProcess(StoreMoveType.PutReel, To.posid);
}
break;
case MoveStep.StoreTS16:
......
......@@ -3,6 +3,7 @@ using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
......@@ -166,6 +167,23 @@ namespace DeviceLibrary
else
LogUtil.info("用户取消忽略安全光栅");
}
public static bool checkWatch(Stopwatch watch, int targetMs, bool isStop = true)
{
if (!watch.IsRunning)
{
watch.Restart();
return false;
}
else if (watch.ElapsedMilliseconds >= targetMs)
{
if (isStop)
{
watch.Stop();
}
return true;
}
return false;
}
}
public enum StoreType {
......
......@@ -54,7 +54,7 @@ DO,0,出料口2电机反转,U2_Moto_Rwd,8,HC,Y08,,,,,,,,,,
DO,0,出料口3电机正转,U3_Moto_Fwd,9,HC,Y09,,,,,,,,,,
DO,0,出料口3电机反转,U3_Moto_Rwd,10,HC,Y10,,,,,,,,,,
DO,0,出料口4电机正转,U4_Moto_Fwd,11,HC,Y11,,,,,,,,,,
DO,0,出料口4电机反转,U5_Moto_Rwd,12,HC,Y12,,,,,,,,,,
DO,0,出料口4电机反转,U4_Moto_Rwd,12,HC,Y12,,,,,,,,,,
DO,0,出料口1定位上升,U1_Location_Up,13,HC,Y13,,,,,,,,,,
DO,0,出料口1定位下降,U1_Location_Down,14,HC,Y14,,,,,,,,,,
DO,0,出料口2定位上升,U2_Location_Up,15,HC,Y15,,,,,,,,,,
......
......@@ -7,7 +7,7 @@ using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
public class StorePostionBase
{
{
/// <summary>
/// 位置
/// </summary>
......
......@@ -196,9 +196,9 @@ namespace OnlineStore.LoadCSVLibrary
/// </summary>
public static string U4_Moto_Fwd = "U4_Moto_Fwd";
/// <summary>
/// DO,0,出料口4电机反转,U5_Moto_Rwd,12,HC,Y12,,,,,,,,,,
/// DO,0,出料口4电机反转,U4_Moto_Rwd,12,HC,Y12,,,,,,,,,,
/// </summary>
public static string U5_Moto_Rwd = "U5_Moto_Rwd";
public static string U4_Moto_Rwd = "U4_Moto_Rwd";
}
public enum IO_VALUE
......
......@@ -35,49 +35,58 @@ namespace TheMachine
this.btn_stop = new System.Windows.Forms.Button();
this.cylinderButton7 = new TheMachine.CylinderButton();
this.ioControl1 = new TheMachine.IOControl();
this.btnLocationStop = new System.Windows.Forms.Button();
this.btnDown = new System.Windows.Forms.Button();
this.btnUp = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// cb_motolist
//
this.cb_motolist.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cb_motolist.Font = new System.Drawing.Font("新宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.cb_motolist.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.cb_motolist.FormattingEnabled = true;
this.cb_motolist.Location = new System.Drawing.Point(565, 230);
this.cb_motolist.Name = "cb_motolist";
this.cb_motolist.Size = new System.Drawing.Size(224, 24);
this.cb_motolist.Size = new System.Drawing.Size(267, 29);
this.cb_motolist.TabIndex = 2;
//
// btn_fwd
//
this.btn_fwd.BackColor = System.Drawing.Color.White;
this.btn_fwd.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_fwd.Location = new System.Drawing.Point(566, 260);
this.btn_fwd.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btn_fwd.Location = new System.Drawing.Point(566, 272);
this.btn_fwd.Name = "btn_fwd";
this.btn_fwd.Size = new System.Drawing.Size(67, 33);
this.btn_fwd.Size = new System.Drawing.Size(126, 33);
this.btn_fwd.TabIndex = 3;
this.btn_fwd.Text = "正转";
this.btn_fwd.UseVisualStyleBackColor = true;
this.btn_fwd.Text = "电机正转";
this.btn_fwd.UseVisualStyleBackColor = false;
this.btn_fwd.Click += new System.EventHandler(this.btn_fwd_Click);
//
// btn_rwd
//
this.btn_rwd.BackColor = System.Drawing.Color.White;
this.btn_rwd.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_rwd.Location = new System.Drawing.Point(644, 260);
this.btn_rwd.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btn_rwd.Location = new System.Drawing.Point(566, 311);
this.btn_rwd.Name = "btn_rwd";
this.btn_rwd.Size = new System.Drawing.Size(67, 33);
this.btn_rwd.Size = new System.Drawing.Size(126, 33);
this.btn_rwd.TabIndex = 3;
this.btn_rwd.Text = "反转";
this.btn_rwd.UseVisualStyleBackColor = true;
this.btn_rwd.Text = "电机反转";
this.btn_rwd.UseVisualStyleBackColor = false;
this.btn_rwd.Click += new System.EventHandler(this.btn_rwd_Click);
//
// btn_stop
//
this.btn_stop.BackColor = System.Drawing.Color.White;
this.btn_stop.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_stop.Location = new System.Drawing.Point(722, 260);
this.btn_stop.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btn_stop.Location = new System.Drawing.Point(566, 350);
this.btn_stop.Name = "btn_stop";
this.btn_stop.Size = new System.Drawing.Size(67, 33);
this.btn_stop.Size = new System.Drawing.Size(126, 33);
this.btn_stop.TabIndex = 3;
this.btn_stop.Text = "停止";
this.btn_stop.UseVisualStyleBackColor = true;
this.btn_stop.Text = "电机停止";
this.btn_stop.UseVisualStyleBackColor = false;
this.btn_stop.Click += new System.EventHandler(this.btn_stop_Click);
//
// cylinderButton7
......@@ -106,9 +115,51 @@ namespace TheMachine
this.ioControl1.Tag = "not";
this.ioControl1.Load += new System.EventHandler(this.ioControl1_Load);
//
// btnLocationStop
//
this.btnLocationStop.BackColor = System.Drawing.Color.White;
this.btnLocationStop.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnLocationStop.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnLocationStop.Location = new System.Drawing.Point(706, 350);
this.btnLocationStop.Name = "btnLocationStop";
this.btnLocationStop.Size = new System.Drawing.Size(126, 33);
this.btnLocationStop.TabIndex = 4;
this.btnLocationStop.Text = "定位停止";
this.btnLocationStop.UseVisualStyleBackColor = false;
this.btnLocationStop.Click += new System.EventHandler(this.btnLocationStop_Click);
//
// btnDown
//
this.btnDown.BackColor = System.Drawing.Color.White;
this.btnDown.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnDown.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnDown.Location = new System.Drawing.Point(706, 311);
this.btnDown.Name = "btnDown";
this.btnDown.Size = new System.Drawing.Size(126, 33);
this.btnDown.TabIndex = 5;
this.btnDown.Text = "定位下降";
this.btnDown.UseVisualStyleBackColor = false;
this.btnDown.Click += new System.EventHandler(this.btnDown_Click);
//
// btnUp
//
this.btnUp.BackColor = System.Drawing.Color.White;
this.btnUp.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnUp.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnUp.Location = new System.Drawing.Point(706, 272);
this.btnUp.Name = "btnUp";
this.btnUp.Size = new System.Drawing.Size(126, 33);
this.btnUp.TabIndex = 6;
this.btnUp.Text = "定位上升";
this.btnUp.UseVisualStyleBackColor = false;
this.btnUp.Click += new System.EventHandler(this.btnUp_Click);
//
// IOControls
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Controls.Add(this.btnLocationStop);
this.Controls.Add(this.btnDown);
this.Controls.Add(this.btnUp);
this.Controls.Add(this.btn_stop);
this.Controls.Add(this.btn_rwd);
this.Controls.Add(this.btn_fwd);
......@@ -130,5 +181,8 @@ namespace TheMachine
private System.Windows.Forms.Button btn_fwd;
private System.Windows.Forms.Button btn_rwd;
private System.Windows.Forms.Button btn_stop;
private System.Windows.Forms.Button btnLocationStop;
private System.Windows.Forms.Button btnDown;
private System.Windows.Forms.Button btnUp;
}
}
......@@ -34,8 +34,8 @@ namespace TheMachine
private void ioControl1_Load(object sender, EventArgs e)
{
for (int i = 1;i<=5; i++)
cb_motolist.Items.Add(new KeyValuePair<string, string>($"出料口{i}电机正转", i.ToString()));
for (int i = 1;i<=4; i++)
cb_motolist.Items.Add(new KeyValuePair<string, string>($"出料口_U{i}", i.ToString()));
cb_motolist.SelectedIndex = 0;
}
......@@ -69,5 +69,30 @@ namespace TheMachine
LogUtil.info($"手动点击 U{u.Value} 电机停止");
}
private void btnUp_Click(object sender, EventArgs e)
{
var u = (KeyValuePair<string, string>)cb_motolist.SelectedItem;
IOManager.IOMove($"U{u.Value}_Location_Up", IO_VALUE.HIGH);
IOManager.IOMove($"U{u.Value}_Location_Down", IO_VALUE.LOW);
LogUtil.info($"手动点击 U{u.Value} 定位上升");
}
private void btnDown_Click(object sender, EventArgs e)
{
var u = (KeyValuePair<string, string>)cb_motolist.SelectedItem;
IOManager.IOMove($"U{u.Value}_Location_Down", IO_VALUE.HIGH);
IOManager.IOMove($"U{u.Value}_Location_Up", IO_VALUE.LOW);
LogUtil.info($"手动点击 U{u.Value} 定位下降");
}
private void btnLocationStop_Click(object sender, EventArgs e)
{
var u = (KeyValuePair<string, string>)cb_motolist.SelectedItem;
IOManager.IOMove($"U{u.Value}_Location_Up", IO_VALUE.LOW);
IOManager.IOMove($"U{u.Value}_Location_Down", IO_VALUE.LOW);
LogUtil.info($"手动点击 U{u.Value} 定位停止");
}
}
}
......@@ -49,7 +49,7 @@ namespace TheMachine
{
InitializeComponent();
Setting_Init.Device_DisableUpdownProtect=false;
positionConfigFile = Path.Combine(appPath, "StoreConfig\\linePositions.csv");
positionConfigFile = Path.Combine(appPath, "config\\Magzine.csv");
}
public void Init()
......@@ -75,7 +75,7 @@ namespace TheMachine
//LogUtil.info($"出入库完成状态:{arg2},库位:{arg1}");
int InStoreCheck = 0;
int OutStoreCheck = 0;
if (arg2 == StoreMoveType.InStore)
if (arg2 == StoreMoveType.PutReel)
InStoreCheck = 1;
else if (arg2 == StoreMoveType.OutStore)
OutStoreCheck = 1;
......@@ -209,14 +209,20 @@ namespace TheMachine
{
currentRowIndex = 0;
currentColIndex++;
string headerText = crc.GetString("Res0090", "其他取放料口");
lastAB = ab;
string[] posArray = posname.Split('_');
if (posArray.Length >= 2)
{
headerText = posArray[0];
}
//if (posname.StartsWith("L"))
//{
// dataGridView1.Columns[currentColIndex].HeaderText = crc.GetString(memo, memo) + "(" + posname.Substring(0, 2) + ")";
//}
//else
{
dataGridView1.Columns[currentColIndex].HeaderText = crc.GetString("Res0090", "其他取放料口");
dataGridView1.Columns[currentColIndex].HeaderText = headerText;
}
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!