|
@@ -48,6 +48,8 @@ using System.Reflection;
|
|
|
using static MainForm.ClassFile.XiaomiAPI_MES.XiaomiMESHttp_StationOutbound.XmMES_StationOutRequest_Body;
|
|
|
using FaFrameUI;
|
|
|
using System.Security.Policy;
|
|
|
+using static MainForm.ClassFile.XiaomiClass.MesHelper;
|
|
|
+using static MainForm.ClassFile.XiaomiAPI_MES.XiaomiMESHttp_StationOutbound.XmMES_StationOutRequest_Body;
|
|
|
|
|
|
/*
|
|
|
* 注:本源码对外提供,所以有些地方使用中文命名方法及变量
|
|
@@ -1472,6 +1474,8 @@ namespace MainForm
|
|
|
XiaomiMqttClient_Extend.ParameterConfig(param);
|
|
|
}
|
|
|
|
|
|
+ private bool OpenDailogFalg = true;//是否开启扫码弹窗标识
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// float[]转为string
|
|
|
/// </summary>
|
|
@@ -1630,7 +1634,97 @@ namespace MainForm
|
|
|
|
|
|
return compensationDict;
|
|
|
}
|
|
|
+ public int PCBStationOutData(BarcodeSet_t Barcode,IoT_DataSet_t iotData)
|
|
|
+ {
|
|
|
+ int res = 0;
|
|
|
+ string jsonstr1 = "";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ XmMES_StationOutRequest_Body outRequest_Body = new XmMES_StationOutRequest_Body();
|
|
|
+ outRequest_Body.machineId = GlobalContext.S5_MachineId; // 装备id(可配置)
|
|
|
+ outRequest_Body.stationId = GlobalContext.S5_station; // ⼯位ID(可配置)
|
|
|
+ outRequest_Body.clientMac = GlobalContext.MacStr; // 客⼾端本机MAC地址,格式:XX-XX-XX-XX-XX-XX
|
|
|
+ outRequest_Body.clientTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); // 客⼾端请求时间,格式yyyy-MM-dd HH:mm:ss.fff
|
|
|
+ outRequest_Body.unitSn = Barcode.strPCBBarcode; // 产品SN
|
|
|
+ int a1Result = (int)iotData.testStatus;
|
|
|
+ //bool pass = a1Result == 1;
|
|
|
+ //outRequest_Body.state = pass ? "PASS" : "FAIL"; ; // 出站条件 PASS或FAIL
|
|
|
+ outRequest_Body.state = "PASS";
|
|
|
+ outRequest_Body.userId = GlobalContext.MESUserId; // ⽤⼾ID
|
|
|
+ outRequest_Body.factoryId = GlobalContext.Factory_Code; // ⼯⼚id
|
|
|
+ XmStationOut_KeyMaterial keyMaterial = new XmStationOut_KeyMaterial();
|
|
|
+ keyMaterial.bindSort = 1;
|
|
|
+ keyMaterial.materialSn = Barcode.strProductBarcode;
|
|
|
+ outRequest_Body.unitData.keyMaterial.Add(keyMaterial); // 产品码
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ jsonstr1 = JsonConvert.SerializeObject(outRequest_Body);
|
|
|
+
|
|
|
+ XmMES_StationOutResponse response = new XmMES_StationOutResponse();
|
|
|
+
|
|
|
+ response = XiaomiMESHttp_StationOutbound.StationOut(outRequest_Body);
|
|
|
+
|
|
|
+ if (response != null && response.header.code == "200")
|
|
|
+ {
|
|
|
+ res = 1;
|
|
|
+ AddMessage(LogType.Info, "上传PCB出站数据到MES服务器---成功!请求信息:" + jsonstr1 + ",返回信息:" + JsonConvert.SerializeObject(response.body));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ res = 0;
|
|
|
+ AddMessage(LogType.Error, "上传PCB出站数据到MES服务器---失败!错误信息:"+ response.header.desc + ",请求信息:" + jsonstr1 + ",返回信息:" + JsonConvert.SerializeObject(response.body));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ res = 0;
|
|
|
+ AddMessage(LogType.Info, "上传PCB出站数据到MES服务器---失败!请求信息:" + jsonstr1 + ",返回信息:" + e.Message);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int PCBStationInData(BarcodeSet_t Barcode, IoT_DataSet_t iotData)
|
|
|
+ {
|
|
|
+ int res = 0;
|
|
|
+ string json_Body = "";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ XmMES_StationInRequest_Body inRequest_Body = new XmMES_StationInRequest_Body();
|
|
|
+ inRequest_Body.machineId = GlobalContext.S5_MachineId; // 装备ID(可配置)
|
|
|
+ inRequest_Body.stationId = GlobalContext.S5_station; // ⼯位ID(可配置)
|
|
|
+ inRequest_Body.clientMac = GlobalContext.MacStr; // 客⼾端本机MAC地址,格式:XX-XX-XX-XX-XX-XX
|
|
|
+ inRequest_Body.clientTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); // 客⼾端请求时间,格式yyyy-MM-dd HH:mm:ss.fff
|
|
|
+ inRequest_Body.unitSn = Barcode.strPCBBarcode; // 产品SN
|
|
|
+ inRequest_Body.userId = GlobalContext.MESUserId; // 用户ID;
|
|
|
+ inRequest_Body.factoryId = GlobalContext.Factory_Code; // 工厂ID;
|
|
|
+
|
|
|
+ json_Body = JsonConvert.SerializeObject(inRequest_Body);
|
|
|
+ var response = XiaomiMESHttp_StationInbound.StationIn(inRequest_Body);
|
|
|
|
|
|
+ string resultJson = JsonConvert.SerializeObject(response);
|
|
|
+
|
|
|
+ if (response != null && response.header.code == "200")
|
|
|
+ {
|
|
|
+ res = 1;
|
|
|
+ AddMessage(LogType.Info, "上传PCB进站数据到MES服务器---成功!请求信息:" + json_Body + ",返回信息:" + JsonConvert.SerializeObject(response.body));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ res = 0;
|
|
|
+ AddMessage(LogType.Error, "上传PCB进站数据到MES服务器---失败!错误信息:" + response.header.desc + ",请求信息:" + json_Body + ",返回信息:" + JsonConvert.SerializeObject(response.body));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ res = 0;
|
|
|
+ AddMessage(LogType.Info, "上传PCB进站数据到MES服务器---失败!请求信息:" + json_Body + ",返回信息:" + e.Message);
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 调用进站接口并保存进站数据
|
|
@@ -5162,7 +5256,7 @@ namespace MainForm
|
|
|
#endregion
|
|
|
|
|
|
#region S5
|
|
|
-
|
|
|
+ private static bool isPCBStation = false;//控制PCB是否进出站的标识
|
|
|
/// <summary>
|
|
|
/// [S5] 点胶检测设备
|
|
|
/// </summary>
|
|
@@ -5178,6 +5272,10 @@ namespace MainForm
|
|
|
string tagiotComnName = "iotData";
|
|
|
string tagBarsetName = "BarcodeSet";
|
|
|
|
|
|
+ string pcbBarcode = "";
|
|
|
+ string pcbBarcodeOld = "";
|
|
|
+
|
|
|
+ OP50_MesData_t stPLC_MesData; //PLC的MES数据
|
|
|
string CarrierBarcode = "";
|
|
|
|
|
|
// 触发信号字典
|
|
@@ -5223,6 +5321,24 @@ namespace MainForm
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ #region PCB出站
|
|
|
+ //stPLC_MesData.BarcodeSet.strPCBBarcode = "A1507V000239";
|
|
|
+ pcbBarcode = stPLC_MesData.BarcodeSet.strPCBBarcode;
|
|
|
+ if (pcbBarcode!= pcbBarcodeOld)
|
|
|
+ {
|
|
|
+ isPCBStation = true;
|
|
|
+ }
|
|
|
+ if (isPCBStation)
|
|
|
+ {
|
|
|
+ var r = S5_PCB进出站(stPLC_MesData, plcNo, stationNameStr, tagBaseName, tagMesCommName);
|
|
|
+ if (r > 0)
|
|
|
+ {
|
|
|
+ isPCBStation = false;
|
|
|
+ pcbBarcodeOld = pcbBarcode;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //stPLC_MesData.BarcodeSet.strCarrierBarcode = "A123456";
|
|
|
+ #endregion
|
|
|
//richTextBox1.AppendText("\n" + "读取成功");
|
|
|
int xmDeviceStateInt = stPLC_MesData.iotData.machineState;
|
|
|
xmDeviceStateData.left = (xmDeviceStateInt < 0 || xmDeviceStateInt > 7)
|
|
@@ -5252,9 +5368,8 @@ namespace MainForm
|
|
|
{
|
|
|
uuid = Guid.NewGuid().ToString(); //创建贯穿进出站的uuid
|
|
|
ProgressState = true;
|
|
|
- Task.Run(() => S5进站(plcNo, stationNameStr, stPLC_MesData,
|
|
|
- tagBaseName + "." + tagMesCommName, tagBaseName + "." + tagBarsetName,
|
|
|
- out ProgressState));
|
|
|
+ isPCBStation = true;//开启PCB进出站
|
|
|
+ Task.Run(() => S5进站(plcNo, stationNameStr, stPLC_MesData, tagBaseName + "." + tagMesCommName, tagBaseName + "." + tagBarsetName, out ProgressState));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -5439,7 +5554,7 @@ namespace MainForm
|
|
|
}
|
|
|
|
|
|
sn = strProductBarcode;
|
|
|
- AddMessage(LogType.Info, $"载具码:{strCarrierBarcode};产品码:{sn};PCB码:{pcbBarcode}");
|
|
|
+ AddMessage(LogType.Info, $"载具码:{strCarrierBarcode};产品码:{sn}");
|
|
|
|
|
|
// 产品SN(物料码)校验
|
|
|
List<TestItem> item = new List<TestItem>();
|
|
@@ -5503,16 +5618,18 @@ namespace MainForm
|
|
|
string equipmentCode = GlobalContext.LineCode + "-" + stationCode; // 设备编号
|
|
|
string processItem = stationName; // 测试项目
|
|
|
string plcDate_YMD = DateTime.Now.ToString("yyyyMMdd");
|
|
|
- string supplierCode = ""; // 供应商代码
|
|
|
- string workorder_code = GlobalContext.WorkOrderCode; // 工单号
|
|
|
- string batch_num = GlobalContext.BatchNumber; // 批次号
|
|
|
- string mtltmrk = GlobalContext.Mtltmrk; // 产品型号
|
|
|
- string sn = (string)stPLC_MesData.BarcodeSet.strProductBarcode; // 产品条码;
|
|
|
- string PartBarcode = (string)stPLC_MesData.BarcodeSet.strPartBarcode; // 产品条码;
|
|
|
- string CarrierBarcode = (string)stPLC_MesData.BarcodeSet.strCarrierBarcode; // 载具条码;
|
|
|
- string MachineId = GlobalContext.S5_MachineId; // 装备id(可配置) // ZS
|
|
|
- string StationId = GlobalContext.S5_StationId; // ⼯位ID(可配置) // ZS
|
|
|
- int a1Result = (int)stPLC_MesData.iotData.testStatus; // 产品结果
|
|
|
+ string supplierCode = ""; // 供应商代码
|
|
|
+ string workorder_code = GlobalContext.WorkOrderCode; // 工单号
|
|
|
+ string batch_num = GlobalContext.BatchNumber; // 批次号
|
|
|
+ string mtltmrk = GlobalContext.Mtltmrk; // 产品型号
|
|
|
+ string sn = (string)stPLC_MesData.BarcodeSet.strProductBarcode; // 产品条码;
|
|
|
+ string PartBarcode = (string)stPLC_MesData.BarcodeSet.strPartBarcode; // 产品条码;
|
|
|
+ string CarrierBarcode = (string)stPLC_MesData.BarcodeSet.strCarrierBarcode; // 载具条码;
|
|
|
+ string pcbBarcode = (string)stPLC_MesData.BarcodeSet.strPCBBarcode;
|
|
|
+
|
|
|
+ string MachineId = GlobalContext.S5_MachineId; // 装备id(可配置) // ZS
|
|
|
+ string StationId = GlobalContext.S5_StationId; // ⼯位ID(可配置) // ZS
|
|
|
+ int a1Result = (int)stPLC_MesData.iotData.testStatus; // 产品结果
|
|
|
bool pass = a1Result == 1;
|
|
|
|
|
|
//根据载具码获取产品码
|
|
@@ -5526,7 +5643,14 @@ namespace MainForm
|
|
|
}
|
|
|
|
|
|
sn = strProductBarcode;
|
|
|
- AddMessage(LogType.Info, $"载具码:{CarrierBarcode};产品码:{sn}");
|
|
|
+ //数据库绑定载具和PCB
|
|
|
+ ResponseMessage message = new ResponseMessage();
|
|
|
+ message = SQLHelper.PCBCarrierBind(CarrierBarcode, pcbBarcode);
|
|
|
+ if (message.result == false)
|
|
|
+ {
|
|
|
+ AddMessage(LogType.Error, stationNameStr + "_载具码与产品码绑定失败,错误:" + message.text);
|
|
|
+ }
|
|
|
+ AddMessage(LogType.Info, $"载具码:{CarrierBarcode};产品码:{sn};PCB码:{pcbBarcode}");
|
|
|
|
|
|
List<TestItem> items = new List<TestItem>();
|
|
|
items.Add(new TestItem()
|
|
@@ -5586,7 +5710,7 @@ namespace MainForm
|
|
|
AddMessage(LogType.Info, stationNameStr + "_出站结束");
|
|
|
|
|
|
//保存PLC返回MES数据到本地
|
|
|
- ResponseMessage message = new ResponseMessage();
|
|
|
+ //ResponseMessage message = new ResponseMessage();
|
|
|
message = SQLHelper.InsertOp50Data(CarrierBarcode, sn, stPLC_MesData.mesData.nIsAddPCBAsmOK,
|
|
|
stPLC_MesData.mesData.nHaveAddPCB, stPLC_MesData.mesData.fForceAddPCB,
|
|
|
stPLC_MesData.mesData.nRemainCount, "");
|
|
@@ -5628,7 +5752,61 @@ namespace MainForm
|
|
|
stopwatch2.ElapsedMilliseconds + "ms");
|
|
|
ProgressState = false;
|
|
|
}
|
|
|
+ private int S5_PCB进出站(OP50_MesData_t stPLC_MesData,int plcNo,string stationNameStr,string tagBaseName,string tagMesCommName) {
|
|
|
+ string PCBBarcode = stPLC_MesData.BarcodeSet.strPCBBarcode.Replace("\r", "");
|
|
|
+ stPLC_MesData.BarcodeSet.strPCBBarcode = PCBBarcode;//特殊字符处理
|
|
|
+ if (PCBBarcode != "ERROR" && !string.IsNullOrEmpty(PCBBarcode))
|
|
|
+ {
|
|
|
+ string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(stPLC_MesData.BarcodeSet.strCarrierBarcode);
|
|
|
+
|
|
|
+ stPLC_MesData.BarcodeSet.strProductBarcode = strProductBarcode;
|
|
|
+ CommandFromPLC resultToPlC = new CommandFromPLC();
|
|
|
+ resultToPlC.cmd = 0;
|
|
|
+ resultToPlC.cmdParam = 0; //指令参数
|
|
|
+
|
|
|
+ if (GlobalContext.IsSendStationIn)
|
|
|
+ {
|
|
|
+ #region 出站
|
|
|
+ int res1 = PCBStationInData(stPLC_MesData.BarcodeSet, stPLC_MesData.iotData);
|
|
|
+ if (res1 == 1)
|
|
|
+ {
|
|
|
+ resultToPlC.cmdResult = 2;//OK
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagBaseName + "." + tagMesCommName, 1, resultToPlC);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ resultToPlC.cmdResult = 120;
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagBaseName + "." + tagMesCommName, 1, resultToPlC);
|
|
|
+ return 2;
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 出站
|
|
|
+ int res2 = PCBStationOutData(stPLC_MesData.BarcodeSet, stPLC_MesData.iotData);
|
|
|
+ if (res2 == 1)
|
|
|
+ {
|
|
|
+ resultToPlC.cmdResult = 2;//OK
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagBaseName + "." + tagMesCommName, 1, resultToPlC);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ resultToPlC.cmdResult = 120;
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagBaseName + "." + tagMesCommName, 1, resultToPlC);
|
|
|
+ return 2;
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return 2;
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
private void S5节拍接口(int plcNo, string stationNameStr, string tagMesCommName, string CarrierBarcode,
|
|
|
IoT_DataSet_t iot_data)
|
|
|
{
|
|
@@ -6924,9 +7102,8 @@ namespace MainForm
|
|
|
{
|
|
|
StationId = GlobalContext.S7_StationId_2;
|
|
|
}
|
|
|
-
|
|
|
- int a1Result = (int)stPLC_MesData.iotData.testStatus; // 产品结果
|
|
|
- a1Result = 1;
|
|
|
+ int a1Result = (int)stPLC_MesData.iotData.testStatus; // 产品结果
|
|
|
+ //a1Result = 1;
|
|
|
bool pass = a1Result == 1;
|
|
|
//根据载具码获取产品码
|
|
|
string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(CarrierBarcode);
|