|
@@ -11,7 +11,6 @@ using SIMDP.Project.MES;
|
|
|
using Newtonsoft.Json;
|
|
|
using static SIMDP.Project.STORAGE_BIND_L_TOOL;
|
|
|
|
|
|
-
|
|
|
namespace SIMDP.Project
|
|
|
{
|
|
|
/// <summary>
|
|
@@ -21,19 +20,24 @@ namespace SIMDP.Project
|
|
|
{
|
|
|
#region 设备空间
|
|
|
|
|
|
+ private string plcname = "小压溃PLC";
|
|
|
+
|
|
|
private const string lshelfWorkStaion = "YK1001";
|
|
|
+
|
|
|
private const int line = 3;
|
|
|
|
|
|
//系统参数、用户参数
|
|
|
private string workStaion = "";
|
|
|
+
|
|
|
private string fixedScannerIp = "";
|
|
|
+
|
|
|
private int fixedScannerPort = 0;
|
|
|
|
|
|
//当前呼叫状态、L工装盘号和WMS信息状态
|
|
|
- private const string redis_largeLoading = "PLC1LargeLoading";
|
|
|
- private const string redis_largeBlanking = "PLC1LargeBlanking";
|
|
|
- private const string redis_smallLoading = "PLC1SmallLoading";
|
|
|
- private const string redis_lshelfBlanking = "PLC1LShelfBlanking";
|
|
|
+ private const string redis_largeLoading = "{plcname}LargeLoading";
|
|
|
+ private const string redis_largeBlanking = "{plcname}LargeBlanking";
|
|
|
+ private const string redis_smallLoading = "{plcname}SmallLoading";
|
|
|
+ private const string redis_lshelfBlanking = "{plcname}LShelfBlanking";
|
|
|
|
|
|
private const string lbl_lshelfbarcode = "lbl_lshelfbarcodel1";//当前盘号
|
|
|
private const string lbl_serialnum = "lbl_serialnum1";//流水
|
|
@@ -50,11 +54,10 @@ namespace SIMDP.Project
|
|
|
|
|
|
//记录actionTimer()执行次数,到达阈值后触发一次自动呼叫逻辑
|
|
|
private int actionCount = 0;
|
|
|
- private const int threshold = 10;
|
|
|
+
|
|
|
+ private const int threshold = 5;
|
|
|
+
|
|
|
private bool pcHeartBeat = false;
|
|
|
- //记录AutoCallingTask()执行次数,到达阈值后触发一次大托盘下料逻辑
|
|
|
- private int autoCallCount = 0;
|
|
|
- private const int threshold2 = 2;
|
|
|
|
|
|
public PLC1()
|
|
|
{
|
|
@@ -68,7 +71,6 @@ namespace SIMDP.Project
|
|
|
|
|
|
public override void actionTimer()
|
|
|
{
|
|
|
- //LogHelper.log.Info("PLC1【actionTimer()开始Log】");
|
|
|
try
|
|
|
{
|
|
|
pcHeartBeat = !pcHeartBeat;
|
|
@@ -92,28 +94,22 @@ namespace SIMDP.Project
|
|
|
p.proc.Invoke(this, new object[] { value });
|
|
|
}
|
|
|
}
|
|
|
- //LogHelper.log.Info("PLC1【foreach执行完毕 】");
|
|
|
- redis.Publish<string>(SysEnvironment.OpcDataChannel, "");
|
|
|
-
|
|
|
+ redis.Publish(SysEnvironment.OpcDataChannel, "");
|
|
|
|
|
|
++actionCount;
|
|
|
if (actionCount > threshold)
|
|
|
{
|
|
|
actionCount = 0;
|
|
|
- //执行自动呼叫逻辑
|
|
|
- //LogHelper.log.Info("AutoCallingTask() CALLED");
|
|
|
AutoCallingTask();
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
isConnect = false;
|
|
|
- LogHelper.log.Error($"PLC1 通信异常,即将重连:{ex.Message}");
|
|
|
+ LogHelper.log.Error($"{plcname} 通信异常,即将重连:{ex.Message}");
|
|
|
}
|
|
|
- //LogHelper.log.Info("PLC1【actionTimer()结束Log】");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public override void actionConnected()
|
|
|
{
|
|
|
Write("辅助压机左侧读取请求处理完成", true);
|
|
@@ -131,64 +127,31 @@ namespace SIMDP.Project
|
|
|
Read("小托盘下料请求", out bool bvalue2); redis.SetString(lbl_sensorstate2, bvalue2);
|
|
|
Read("L型工装上料请求", out bool bvalue5); redis.SetString(lbl_sensorstateLUP, bvalue5);
|
|
|
|
|
|
- if (SysEnvironment.allowProduce == true)
|
|
|
- {
|
|
|
- //small and large loading
|
|
|
- string smallRecord = redis.GetString(redis_smallLoading);
|
|
|
- string largeRecord = redis.GetString(redis_largeLoading);
|
|
|
- bool smallCalled = string.IsNullOrEmpty(smallRecord);
|
|
|
- bool largeCalled = string.IsNullOrEmpty(largeRecord);
|
|
|
- //if (bvalue1 && !smallCalled && smallRecord.StartsWith("False")) 小托盘单独上料();
|
|
|
- //if (bvalue3 && !largeCalled && largeRecord.StartsWith("False")) 大托盘单独上料();
|
|
|
- if (bvalue1 && bvalue3 && largeCalled && smallCalled) 大小托盘同时上料();
|
|
|
-
|
|
|
- //large blanking
|
|
|
- if (!bvalue4)
|
|
|
- {
|
|
|
- redis.SetString(redis_largeBlanking, "");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ++autoCallCount;
|
|
|
- if (autoCallCount > threshold2)
|
|
|
- {
|
|
|
- autoCallCount = 0;
|
|
|
-
|
|
|
- string largeDown= redis.GetString(redis_largeBlanking);
|
|
|
- if (string.IsNullOrEmpty(largeDown))
|
|
|
- {
|
|
|
- LogHelper.log.Info("大托盘下料() CALLED");
|
|
|
- 大托盘下料();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ //small and large loading
|
|
|
+ string smallRecord = redis.GetString(redis_smallLoading);
|
|
|
+ string largeRecord = redis.GetString(redis_largeLoading);
|
|
|
+ bool smallCalled = string.IsNullOrEmpty(smallRecord);
|
|
|
+ bool largeCalled = string.IsNullOrEmpty(largeRecord);
|
|
|
|
|
|
- //lshelf loading
|
|
|
- if (bvalue5) redis.SetString(redis_lshelfBlanking, "");
|
|
|
+ if (bvalue1 && bvalue3 && largeCalled && smallCalled) 大小托盘同时上料();
|
|
|
|
|
|
- //shelf blanking
|
|
|
- if (bvalue6)
|
|
|
- {
|
|
|
- if (!SysEnvironment.NeedAutoIM_Warehousing) return;
|
|
|
+ //large blanking
|
|
|
+ if (!bvalue4)
|
|
|
+ {
|
|
|
+ redis.SetString(redis_largeBlanking, "");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(redis.GetString(redis_largeBlanking))) 大托盘下料();
|
|
|
+ }
|
|
|
|
|
|
- string sBlankingRecord = redis.GetString(redis_lshelfBlanking);
|
|
|
- if (string.IsNullOrEmpty(sBlankingRecord) || sBlankingRecord.StartsWith("False"))
|
|
|
- {
|
|
|
- int ires = L型工装下料请求(out string errorMsg);
|
|
|
- //添加下料报警弹窗
|
|
|
- if (ires != 1)
|
|
|
- {
|
|
|
- redis.SetString(redis_lshelfBlanking, errorMsg);
|
|
|
- //不是所有的都需要弹窗,MES接口异常时弹
|
|
|
- if (ires == 5)
|
|
|
- {
|
|
|
- BLLFactory<BlSystemNotice>.Instance.PublishSysMessage("自动下料异常", 2, errorMsg);
|
|
|
- }
|
|
|
- }
|
|
|
- redis.SetString(lbl_matchresult, ires);
|
|
|
+ //lshelf loading
|
|
|
+ if (bvalue5) redis.SetString(redis_lshelfBlanking, "");
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
+ //shelf blanking
|
|
|
+ if (bvalue6)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(redis.GetString(redis_lshelfBlanking))) L型工装下料请求();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -232,11 +195,11 @@ namespace SIMDP.Project
|
|
|
bool res1 = ExternalInterface.TrayLoadingTransfer(workStaion, model.LargeBarcode, model.WorkCode, out string sreturn);
|
|
|
redis.SetString(redis_largeLoading, $"{res1};{model.LargeBarcode};{sreturn}");
|
|
|
if (res1) model.LargeState = 2;
|
|
|
-
|
|
|
+
|
|
|
bool res2 = ExternalInterface.TrayLoadingTransfer(workStaion, model.SmallBarcode, model.WorkCode, out string smallreturn);
|
|
|
redis.SetString(redis_smallLoading, $"{res2};{model.SmallBarcode};{smallreturn}");
|
|
|
if (res2) model.SmallState = 4;
|
|
|
-
|
|
|
+
|
|
|
BLLFactory<BlProductTask>.Instance.Update(model, model.ID);
|
|
|
|
|
|
if (!res1 || !res2) Write("上位机报警", 1);
|
|
@@ -255,7 +218,7 @@ namespace SIMDP.Project
|
|
|
if (string.IsNullOrEmpty(sworkcode))
|
|
|
{
|
|
|
redis.SetString(redis_largeBlanking, $"False;大托盘下料异常:无法获取托盘 {sbarcode} 绑定的对应工单号!");
|
|
|
- LogHelper.log.Error($"PLC1 大托盘下料异常:无法获取托盘 {sbarcode} 绑定的对应工单号!");
|
|
|
+ LogHelper.log.Error($"{plcname} 大托盘下料异常:无法获取托盘 {sbarcode} 绑定的对应工单号!");
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -267,48 +230,39 @@ namespace SIMDP.Project
|
|
|
}
|
|
|
redis.SetString(redis_largeBlanking, $"{res01};{sreturn};{sflag};{sbarcode}");
|
|
|
|
|
|
- if(!res01) Write("上位机报警", 2);
|
|
|
+ if (!res01) Write("上位机报警", 2);
|
|
|
}
|
|
|
|
|
|
- public int L型工装下料请求(out string errorMsg)
|
|
|
+ public void L型工装下料请求()
|
|
|
{
|
|
|
- errorMsg = "";
|
|
|
+ string errorMsg = "";
|
|
|
|
|
|
try
|
|
|
{
|
|
|
string lShelfBarcode = redis.GetString(lbl_lshelfbarcode);
|
|
|
- if (string.IsNullOrEmpty(lShelfBarcode))
|
|
|
- lShelfBarcode = GenRandomLShelfBarcode();
|
|
|
+ if (string.IsNullOrEmpty(lShelfBarcode)) lShelfBarcode = GenRandomLShelfBarcode();
|
|
|
Write("L型工装下料请求处理结果", 0);
|
|
|
|
|
|
//1 读取并记录流水号
|
|
|
Read("L工装下料流水号一", out short serialnum1);
|
|
|
redis.SetString(lbl_serialnum, serialnum1.ToString());
|
|
|
- LogHelper.log.Info($"PLC1 L型工装下料请求(): serialnum1 = {serialnum1} ");
|
|
|
if (serialnum1 == 0)
|
|
|
{
|
|
|
- LogHelper.log.Error($"PLC1 L型工装下料请求(): 流水号为0,返回结果2");
|
|
|
- errorMsg = "False;L工装下料流水号为0,无法解析该工件";
|
|
|
- return 2;
|
|
|
+ LogHelper.log.Error($"{plcname} 下料流水为0!");
|
|
|
+ errorMsg = "False;流水号异常,找不到工件";
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
//2 查找需求单号
|
|
|
bool bFindReqCode = BLLFactory<BlProductTask>.Instance.FindRequirementCode(serialnum1, out string requirecode1, out string mcode1);
|
|
|
- //if (string.IsNullOrEmpty(requirecode1))
|
|
|
- //{
|
|
|
- // //触发下料阻断
|
|
|
- // LogHelper.log.Error($"PLC1 L型工装下料请求(): 需求单为空、触发下料阻断 流水号{serialnum1}");
|
|
|
- // errorMsg = "";
|
|
|
- // return 1;
|
|
|
- //}
|
|
|
if (!bFindReqCode)
|
|
|
{
|
|
|
- LogHelper.log.Error($"PLC1 L型工装下料请求(): serialnum1 = {serialnum1},查找需求单失败,返回结果3");
|
|
|
- errorMsg = "False;单独下料工件需求单查找失败!";
|
|
|
- return 3;
|
|
|
+ LogHelper.log.Error($"{plcname} 下料流水号= {serialnum1},找不到需求单!");
|
|
|
+ errorMsg = $"False;查找工件{serialnum1}需求单失败";
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
- //3 信息入库WMS
|
|
|
+ //3 WMS入库
|
|
|
if (string.IsNullOrEmpty(redis.GetString(redis_wmsmsg)) || !redis.GetString(redis_wmsmsg).StartsWith("True;" + serialnum1.ToString()))
|
|
|
{
|
|
|
WMS_inpara inPara = new WMS_inpara();
|
|
@@ -323,30 +277,28 @@ namespace SIMDP.Project
|
|
|
inPara.LS_GOODS_INFO.Add(good1);
|
|
|
|
|
|
bool bSendWMS = ExternalInterface.GenWMSStorage(inPara, out string sWMSReturn);
|
|
|
- int iwhileCount = 0;
|
|
|
- while (iwhileCount < 10 && !bSendWMS && sWMSReturn.Contains("已经有库存"))//换个L工装号重录
|
|
|
+ while (sWMSReturn.Contains("已经有库存"))
|
|
|
{
|
|
|
inPara.STOCK_BARCODE = GenRandomLShelfBarcode();
|
|
|
bSendWMS = ExternalInterface.GenWMSStorage(inPara, out sWMSReturn);
|
|
|
- ++iwhileCount;
|
|
|
+ if (bSendWMS) break;
|
|
|
}
|
|
|
+
|
|
|
redis.SetString(lbl_lshelfbarcode, lShelfBarcode);
|
|
|
redis.SetString(redis_wmsmsg, $"{bSendWMS};{serialnum1};{sWMSReturn}");
|
|
|
|
|
|
if (!bSendWMS)
|
|
|
{
|
|
|
- // LogHelper.log.Error($"PLC1 L型工装下料请求(): 导入WMS库存失败,返回6!");
|
|
|
- errorMsg = "False;信息导入WMS失败!请查看录入WMS结果";
|
|
|
-
|
|
|
+ errorMsg = "False;WMS入库接口失败";
|
|
|
Write("上位机报警", 3);
|
|
|
- return 6;
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//4 物料入库请求转发MES
|
|
|
int iwhileCountMES = 0;
|
|
|
bool bCallMES = ExternalInterface.LShelfTransfer(lshelfWorkStaion, lShelfBarcode, out string emptyBarcode, out string sMESReturn);
|
|
|
- while (iwhileCountMES < 2 && !bCallMES)
|
|
|
+ while (iwhileCountMES < 3 && !bCallMES)
|
|
|
{
|
|
|
bCallMES = ExternalInterface.LShelfTransfer(lshelfWorkStaion, lShelfBarcode, out emptyBarcode, out sMESReturn);
|
|
|
++iwhileCountMES;
|
|
@@ -354,33 +306,28 @@ namespace SIMDP.Project
|
|
|
redis.SetString(redis_lshelfBlanking, $"{bCallMES};{lShelfBarcode};{sMESReturn};{emptyBarcode}");
|
|
|
if (!bCallMES)
|
|
|
{
|
|
|
- LogHelper.log.Error($"PLC1 L型工装下料请求(): 呼叫MES转运L工装下料失败次数过多,返回结果5");
|
|
|
+ LogHelper.log.Error($"{plcname} L型工装下料请求(): 呼叫MES转运L工装下料失败次数过多,返回结果5");
|
|
|
errorMsg = "False;呼叫MES进行L工装转运接口失败";
|
|
|
|
|
|
Write("上位机报警", 4);
|
|
|
- return 5;
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
+ errorMsg = $"True;";
|
|
|
+
|
|
|
ProductDataUpload(serialnum1);
|
|
|
- return 1;
|
|
|
+ return;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- LogHelper.log.Error($"PLC1 L型工装下料请求() 【异常】:{ex.Message}");
|
|
|
+ LogHelper.log.Error($"{plcname} L型工装下料请求() 【异常】:{ex.Message}");
|
|
|
errorMsg = $"False;{ex.Message}";
|
|
|
- return 9;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ redis.SetString(lbl_matchresult, errorMsg);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 生成随机的L工装号 例如:LXG123456
|
|
|
- /// </summary>
|
|
|
- /// <returns></returns>
|
|
|
- private string GenRandomLShelfBarcode()
|
|
|
- {
|
|
|
- Random rd = new Random();
|
|
|
- int i = rd.Next(0, 999999);
|
|
|
- return "LXG" + i.ToString().PadLeft(6, '0');
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
@@ -398,13 +345,13 @@ namespace SIMDP.Project
|
|
|
roboticToMesInterfaceImplService.Url = "http://172.30.156.163:8080/uma-unimax-web/ws/robotic?wsdl";
|
|
|
string sresult = roboticToMesInterfaceImplService.receivingDocData(JsonConvert.SerializeObject(inPara).Replace("\\u0000", ""));
|
|
|
CraftMsg.outPara outPara = JsonConvert.DeserializeObject<CraftMsg.outPara>(sresult);
|
|
|
- LogHelper.log.Debug($"PLC1 : inPara = {JsonConvert.SerializeObject(inPara)}, outPara = {sresult}");
|
|
|
+ LogHelper.log.Debug($"{plcname} : inPara = {JsonConvert.SerializeObject(inPara)}, outPara = {sresult}");
|
|
|
if (outPara.ResultType == "S") return true;
|
|
|
else return false;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- LogHelper.log.Error($"PLC1 CraftParaUpload(): ex = {ex.Message}");
|
|
|
+ LogHelper.log.Error($"{plcname} CraftParaUpload(): ex = {ex.Message}");
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
@@ -419,14 +366,14 @@ namespace SIMDP.Project
|
|
|
try
|
|
|
{
|
|
|
ProduceMsg.inPara inPara = new ProduceMsg.inPara();
|
|
|
- MoProductData moProductData = BLLFactory<BlProductData>.Instance.FindbySerialNum(serialNum);
|
|
|
+ MoProductData moProductData = BLLFactory<BlProductData>.Instance.FindbySerialNum(serialNum);
|
|
|
if (moProductData == null)
|
|
|
{
|
|
|
- LogHelper.log.Error($"PLC1 ProductDataUpload():无法根据流水码找到生产数据,serialNum= {serialNum}");
|
|
|
+ LogHelper.log.Error($"{plcname} ProductDataUpload():无法根据流水码找到生产数据,serialNum= {serialNum}");
|
|
|
return false;
|
|
|
}
|
|
|
ProdataSet data = new ProdataSet(moProductData.RuleId);
|
|
|
-
|
|
|
+
|
|
|
data.LoadData(moProductData);
|
|
|
inPara.orderCode = data.dict["备注"];
|
|
|
inPara.workCode = data.dict["流转卡号"];
|
|
@@ -440,21 +387,23 @@ namespace SIMDP.Project
|
|
|
roboticToMesInterfaceImplService.Url = "http://172.30.156.163:8080/uma-unimax-web/ws/robotic?wsdl";
|
|
|
string sresult = roboticToMesInterfaceImplService.receivingProductionData(JsonConvert.SerializeObject(inPara).Replace("\\u0000", ""));
|
|
|
ProduceMsg.outPara outPara = JsonConvert.DeserializeObject<ProduceMsg.outPara>(sresult);
|
|
|
- //LogHelper.log.Debug($"PLC1 : inPara = {JsonConvert.SerializeObject(inPara)}, outPara = {sresult}");
|
|
|
+ //LogHelper.log.Debug($"{plcname} : inPara = {JsonConvert.SerializeObject(inPara)}, outPara = {sresult}");
|
|
|
if (outPara.ResultType == "S") return true;
|
|
|
else return false;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- LogHelper.log.Error($"PLC1 ProductDataUpload(): ex = {ex.Message}");
|
|
|
+ LogHelper.log.Error($"{plcname} ProductDataUpload(): ex = {ex.Message}");
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private const string workCellCode1001Up = "SCADA.YK1001.AGVup";
|
|
|
+
|
|
|
private const string workCellCode1002Up = "SCADA.YK1002.AGVup";
|
|
|
+
|
|
|
private const string workCellTypeL_Up = "L_UP";
|
|
|
+
|
|
|
public void UpdateMES_AGVSign(string workCellCode, string type, int state)
|
|
|
{
|
|
|
int result = 0;
|
|
@@ -470,12 +419,12 @@ namespace SIMDP.Project
|
|
|
result = cmd.ExecuteNonQuery();
|
|
|
con.Close();
|
|
|
}
|
|
|
- //LogHelper.log.Debug($"PLC1 : 写入MES数据库数量:{result}");
|
|
|
+ //LogHelper.log.Debug($"{plcname} : 写入MES数据库数量:{result}");
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- LogHelper.log.Debug($"PLC1 UpdateMES_AGVSign(): 状态写入MES数据库发生异常{ex.Message}");
|
|
|
+ LogHelper.log.Debug($"{plcname} UpdateMES_AGVSign(): 状态写入MES数据库发生异常{ex.Message}");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -485,16 +434,15 @@ namespace SIMDP.Project
|
|
|
|
|
|
public void 大托盘到位请求(object value)
|
|
|
{
|
|
|
-
|
|
|
bool signal = Convert.ToBoolean(value);
|
|
|
- LogHelper.log.Info($"PLC1 : signal = {signal}");
|
|
|
+ LogHelper.log.Info($"{plcname} : signal = {signal}");
|
|
|
if (!signal)
|
|
|
{
|
|
|
Write("大托盘到位请求处理完成", false);
|
|
|
return;
|
|
|
}
|
|
|
- //1 清除呼叫记录、PLC接收地址、处理结果
|
|
|
- //redis.SetString(redis_largeLoading, "");
|
|
|
+
|
|
|
+ //1 复位信号
|
|
|
LargeArriveWrite(null, false);
|
|
|
Write("大托盘到位处理结果", 0);
|
|
|
|
|
@@ -507,40 +455,40 @@ namespace SIMDP.Project
|
|
|
{
|
|
|
Write("大托盘到位处理结果", 2);
|
|
|
Write("大托盘到位请求处理完成", true);
|
|
|
- LogHelper.log.Error($"PLC1 : 扫码失败,返回结果2");
|
|
|
+ LogHelper.log.Error($"{plcname} : 扫码失败,返回结果2");
|
|
|
|
|
|
Write("上位机报警", 11);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- catch
|
|
|
+ catch
|
|
|
{
|
|
|
Write("大托盘到位处理结果", 2);
|
|
|
Write("大托盘到位请求处理完成", true);
|
|
|
- LogHelper.log.Error($"PLC1 : 扫码枪通信异常");
|
|
|
+ LogHelper.log.Error($"{plcname} : 扫码枪通信异常");
|
|
|
|
|
|
Write("上位机报警", 11);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//3 解析托盘号
|
|
|
MoProductTask model = BLLFactory<BlProductTask>.Instance.LargeTrayArrive(sbarcode, line);
|
|
|
if (model == null)
|
|
|
{
|
|
|
Write("大托盘到位处理结果", 3);
|
|
|
Write("大托盘到位请求处理完成", true);
|
|
|
- LogHelper.log.Error($"PLC1 : 无法根据托盘号查找到可执行任务,返回结果3");
|
|
|
+ LogHelper.log.Error($"{plcname} : 无法根据托盘号查找到可执行任务,返回结果3");
|
|
|
|
|
|
Write("上位机报警", 11);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//校验盘号再清任务状态
|
|
|
- if (redis_largeLoading.Contains(model.LargeBarcode))
|
|
|
+ if (redis_largeLoading.Contains(sbarcode))
|
|
|
redis.SetString(redis_largeLoading, "");
|
|
|
|
|
|
//4 写入PLC
|
|
|
- LogHelper.log.Info($"PLC1 :解析托盘 {sbarcode}成功,程序号 = {model.PlcProgramCode}");
|
|
|
+ LogHelper.log.Info($"{plcname} :解析托盘 {sbarcode}成功,程序号 = {model.PlcProgramCode}");
|
|
|
|
|
|
LargeArriveWrite(model);
|
|
|
Write("大托盘到位处理结果", 1);
|
|
@@ -554,9 +502,9 @@ namespace SIMDP.Project
|
|
|
data.dict["成品码"] = model.FinalNum;
|
|
|
data.model.Batchid = model.WorkCode;//流转卡号
|
|
|
data.model.SerialNum = model.SerialNum;//流水号
|
|
|
- data.model.RuleTime = DateTime.Now;//更新的时间r
|
|
|
+ data.model.RuleTime = DateTime.Now;//更新的时间
|
|
|
bool bSave = BLLFactory<BlProductData>.Instance.Insert(data.toModel());
|
|
|
- LogHelper.log.Info($"PLC1 : 工单{model.WorkCode} 物料到达{bSave}");
|
|
|
+ LogHelper.log.Info($"{plcname} : 工单{model.WorkCode} 物料到达{bSave}");
|
|
|
|
|
|
//6 反馈完成 更新task状态
|
|
|
Write("大托盘到位请求处理完成", true);
|
|
@@ -591,7 +539,7 @@ namespace SIMDP.Project
|
|
|
public void 小托盘到位请求(object value)
|
|
|
{
|
|
|
bool signal = Convert.ToBoolean(value);
|
|
|
- LogHelper.log.Info($"PLC1 : signal = {signal}");
|
|
|
+ LogHelper.log.Info($"{plcname} : signal = {signal}");
|
|
|
if (!signal)
|
|
|
{
|
|
|
Write("小托盘到位请求处理完成", false);
|
|
@@ -606,7 +554,7 @@ namespace SIMDP.Project
|
|
|
public void 辅助压机左侧读取请求(object value)
|
|
|
{
|
|
|
bool signal = Convert.ToBoolean(value);
|
|
|
- LogHelper.log.Info($"PLC1: signal = {signal}");
|
|
|
+ LogHelper.log.Info($"{plcname}: signal = {signal}");
|
|
|
if (!signal)
|
|
|
{
|
|
|
Write("辅助压机左侧读取请求处理完成", false);
|
|
@@ -635,7 +583,7 @@ namespace SIMDP.Project
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- LogHelper.log.Error($"PLC1 辅助压机左侧数据存储失败,无法找到当前工件流水号 {serialNum}");
|
|
|
+ LogHelper.log.Error($"{plcname} 辅助压机左侧数据存储失败,无法找到当前工件流水号 {serialNum}");
|
|
|
//报警信号!
|
|
|
Write("上位机报警", 12);
|
|
|
}
|
|
@@ -646,7 +594,7 @@ namespace SIMDP.Project
|
|
|
public void 辅助压机右侧读取请求(object value)
|
|
|
{
|
|
|
bool signal = Convert.ToBoolean(value);
|
|
|
- LogHelper.log.Info($"PLC1: signal = {signal}");
|
|
|
+ LogHelper.log.Info($"{plcname}: signal = {signal}");
|
|
|
if (!signal)
|
|
|
{
|
|
|
Write("辅助压机右侧读取请求处理完成", false);
|
|
@@ -675,7 +623,7 @@ namespace SIMDP.Project
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- LogHelper.log.Error($"PLC1 辅助压机右侧数据存储失败,无法找到当前工件流水号 {serialNum}");
|
|
|
+ LogHelper.log.Error($"{plcname} 辅助压机右侧数据存储失败,无法找到当前工件流水号 {serialNum}");
|
|
|
//报警信号!
|
|
|
Write("上位机报警", 12);
|
|
|
}
|
|
@@ -683,39 +631,39 @@ namespace SIMDP.Project
|
|
|
Write("辅助压机右侧读取请求处理完成", true);
|
|
|
}
|
|
|
|
|
|
- public void 工艺看板一到位请求(object value)
|
|
|
- {
|
|
|
- bool signal = Convert.ToBoolean(value);
|
|
|
- LogHelper.log.Debug($"PLC1 : signal = {signal} ");
|
|
|
+ //public void 工艺看板一到位请求(object value)
|
|
|
+ //{
|
|
|
+ // bool signal = Convert.ToBoolean(value);
|
|
|
+ // LogHelper.log.Debug($"{plcname} : signal = {signal} ");
|
|
|
|
|
|
- if (!signal) return;
|
|
|
+ // if (!signal) return;
|
|
|
|
|
|
- //1 读取流水号
|
|
|
+ // //1 读取流水号
|
|
|
|
|
|
- //2 根据流水号查找订单 调出M码
|
|
|
+ // //2 根据流水号查找订单 调出M码
|
|
|
|
|
|
- //3 给MES写值:看板位置、M码
|
|
|
+ // //3 给MES写值:看板位置、M码
|
|
|
|
|
|
- //4 反馈完成
|
|
|
- }
|
|
|
+ // //4 反馈完成
|
|
|
+ //}
|
|
|
|
|
|
- public void L型工装上料请求(object value)
|
|
|
- {
|
|
|
- bool signal = Convert.ToBoolean(value);
|
|
|
+ //public void L型工装上料请求(object value)
|
|
|
+ //{
|
|
|
+ // bool signal = Convert.ToBoolean(value);
|
|
|
|
|
|
- UpdateMES_AGVSign(workCellCode1001Up, workCellTypeL_Up, Convert.ToInt32(signal));
|
|
|
- UpdateMES_AGVSign(workCellCode1002Up, workCellTypeL_Up, Convert.ToInt32(signal));
|
|
|
- }
|
|
|
+ // UpdateMES_AGVSign(workCellCode1001Up, workCellTypeL_Up, Convert.ToInt32(signal));
|
|
|
+ // UpdateMES_AGVSign(workCellCode1002Up, workCellTypeL_Up, Convert.ToInt32(signal));
|
|
|
+ //}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 模拟调试
|
|
|
//public class TestRunner
|
|
|
//{
|
|
|
- // public PLC1 plc1;
|
|
|
- // public TestRunner(PLC1 parent)
|
|
|
+ // public {plcname} {plcname};
|
|
|
+ // public TestRunner({plcname} parent)
|
|
|
// {
|
|
|
- // plc1 = parent;
|
|
|
+ // {plcname} = parent;
|
|
|
// }
|
|
|
// public PLC5 plc5 = (PLC5)PlcHelper.deviceList.Find(e => ((PlcMXComponent)e).actLogicalStationNumber == 5);//读取小压溃压机实例
|
|
|
|
|
@@ -725,39 +673,39 @@ namespace SIMDP.Project
|
|
|
// Task.Run(() =>
|
|
|
// {
|
|
|
// //上料
|
|
|
- // plc1.Write("大小托盘扫码请求", true);
|
|
|
+ // {plcname}.Write("大小托盘扫码请求", true);
|
|
|
// ReadUntil("大托盘扫码结果", true);
|
|
|
// ReadUntil("大托盘扫码完成", true);
|
|
|
// ReadUntil("小托盘扫码结果", true);
|
|
|
// ReadUntil("小托盘扫码完成", true);
|
|
|
// ReadUntil("大小托盘配对结果", true);
|
|
|
|
|
|
- // plc1.Read("产品型号", out string producttype);
|
|
|
- // plc1.Read("视觉颜色", out string color);
|
|
|
- // plc1.Read("上料流水号", out string serialnum);
|
|
|
- // plc1.Write("大小托盘扫码请求", false);
|
|
|
+ // {plcname}.Read("产品型号", out string producttype);
|
|
|
+ // {plcname}.Read("视觉颜色", out string color);
|
|
|
+ // {plcname}.Read("上料流水号", out string serialnum);
|
|
|
+ // {plcname}.Write("大小托盘扫码请求", false);
|
|
|
|
|
|
// // ts.Cancel();// 如出现此句,则下面抛出异常跳出
|
|
|
// try
|
|
|
// {
|
|
|
// ts.Token.ThrowIfCancellationRequested();
|
|
|
// //辅助压机1次
|
|
|
- // plc1.Write("辅助压机读取流水号", serialnum);
|
|
|
- // plc1.Write("辅助压机数值", 50);
|
|
|
- // plc1.Write("辅助压机读取次数", false);//第一次
|
|
|
- // plc1.Write("辅助压机读取请求", true);
|
|
|
+ // {plcname}.Write("辅助压机读取流水号", serialnum);
|
|
|
+ // {plcname}.Write("辅助压机数值", 50);
|
|
|
+ // {plcname}.Write("辅助压机读取次数", false);//第一次
|
|
|
+ // {plcname}.Write("辅助压机读取请求", true);
|
|
|
// ReadUntil("辅助压机读取结果", true);
|
|
|
// ReadUntil("辅助压机读取完成", true);
|
|
|
- // plc1.Write("辅助压机读取请求", false);
|
|
|
+ // {plcname}.Write("辅助压机读取请求", false);
|
|
|
// Thread.Sleep(3000);
|
|
|
// //辅助压机2次
|
|
|
- // plc1.Write("辅助压机读取流水号", serialnum);
|
|
|
- // plc1.Write("辅助压机数值", 51);
|
|
|
- // plc1.Write("辅助压机读取次数", true);//第二次
|
|
|
- // plc1.Write("辅助压机读取请求", true);
|
|
|
+ // {plcname}.Write("辅助压机读取流水号", serialnum);
|
|
|
+ // {plcname}.Write("辅助压机数值", 51);
|
|
|
+ // {plcname}.Write("辅助压机读取次数", true);//第二次
|
|
|
+ // {plcname}.Write("辅助压机读取请求", true);
|
|
|
// ReadUntil("辅助压机读取结果", true);
|
|
|
// ReadUntil("辅助压机读取完成", true);
|
|
|
- // plc1.Write("辅助压机读取请求", false);
|
|
|
+ // {plcname}.Write("辅助压机读取请求", false);
|
|
|
// //主压机
|
|
|
// plc5.Write("主压机读取流水号", serialnum);
|
|
|
// plc5.Write("主压机数值", 60);
|
|
@@ -766,11 +714,11 @@ namespace SIMDP.Project
|
|
|
// ReadPLC5Until("主压机读取完成", true);
|
|
|
// plc5.Write("主压机读取请求", false);
|
|
|
// //打标
|
|
|
- // plc1.Write("打标流水号", serialnum);
|
|
|
- // plc1.Write("打标请求", true);
|
|
|
+ // {plcname}.Write("打标流水号", serialnum);
|
|
|
+ // {plcname}.Write("打标请求", true);
|
|
|
// ReadUntil("打标结果", true);
|
|
|
// ReadUntil("打标完成", true);
|
|
|
- // plc1.Write("打标请求", false);
|
|
|
+ // {plcname}.Write("打标请求", false);
|
|
|
|
|
|
// }
|
|
|
// catch { }
|
|
@@ -782,7 +730,7 @@ namespace SIMDP.Project
|
|
|
// {
|
|
|
// while (true)
|
|
|
// {
|
|
|
- // plc1.Read(pointName, out bool value);
|
|
|
+ // {plcname}.Read(pointName, out bool value);
|
|
|
// if (value == target) break;
|
|
|
// else Thread.Sleep(1000);
|
|
|
// }
|