|
@@ -38,6 +38,7 @@ using System.Numerics;
|
|
|
using MathNet.Numerics.RootFinding;
|
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Tab;
|
|
|
using static MainForm.ClassFile.XiaomiClass.MesHelper;
|
|
|
+using static MainForm.ClassFile.XiaomiAPI_MES.XiaomiMESHttp_StationOutbound.XmMES_StationOutRequest_Body;
|
|
|
|
|
|
/*
|
|
|
* 注:本源码对外提供,所以有些地方使用中文命名方法及变量
|
|
@@ -1081,6 +1082,7 @@ namespace MainForm
|
|
|
private static bool isCollectingFlagLeft;
|
|
|
private static bool isCollectingFlagRight;
|
|
|
private bool OpenDailogFalg = true;//是否开启扫码弹窗标识
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// float[]转为string
|
|
|
/// </summary>
|
|
@@ -1247,10 +1249,17 @@ namespace MainForm
|
|
|
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
|
|
|
+ //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);
|
|
|
|
|
@@ -1280,6 +1289,45 @@ namespace MainForm
|
|
|
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>
|
|
|
/// 调用进站接口并保存进站数据
|
|
|
/// </summary>
|
|
@@ -3174,6 +3222,7 @@ namespace MainForm
|
|
|
#endregion
|
|
|
|
|
|
#region S5
|
|
|
+ private static bool isPCBStation = false;//控制PCB是否进出站的标识
|
|
|
/// <summary>
|
|
|
/// [S5] 点胶检测设备
|
|
|
/// </summary>
|
|
@@ -3188,6 +3237,9 @@ namespace MainForm
|
|
|
string tagAgvCommName = "agvCommFrmPC";
|
|
|
string tagBarsetName = "BarcodeSet";
|
|
|
|
|
|
+ string pcbBarcode = "";
|
|
|
+ string pcbBarcodeOld = "";
|
|
|
+
|
|
|
OP50_MesData_t stPLC_MesData; //PLC的MES数据
|
|
|
(int, string) result;
|
|
|
|
|
@@ -3217,8 +3269,22 @@ namespace MainForm
|
|
|
else
|
|
|
{
|
|
|
#region PCB出站
|
|
|
- //stPLC_MesData.BarcodeSet.strPCBBarcode = "A1507V000243";
|
|
|
- S5_PCB出站(stPLC_MesData, plcNo, stationNameStr, tagBaseName,tagMesCommName);
|
|
|
+ //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
|
|
|
}
|
|
|
#endregion 一次性读取所有数据
|
|
@@ -3234,6 +3300,7 @@ namespace MainForm
|
|
|
if (!ProgressState)
|
|
|
{
|
|
|
ProgressState = true;
|
|
|
+ isPCBStation = true;//开启PCB进出站
|
|
|
Task.Run(() => S5进站(plcNo, stationNameStr, stPLC_MesData, tagBaseName + "." + tagMesCommName, tagBaseName + "." + tagBarsetName, out ProgressState));
|
|
|
}
|
|
|
}
|
|
@@ -3317,8 +3384,6 @@ namespace MainForm
|
|
|
string MachineId = GlobalContext.S5_MachineId; // 装备ID(可配置)
|
|
|
string StationId = GlobalContext.S5_StationId; // 工位ID(可配置)
|
|
|
string strCarrierBarcode = (string)stPLC_MesData.BarcodeSet.strCarrierBarcode; // 载具条码
|
|
|
-
|
|
|
-
|
|
|
//载具码验证产品码 //载具码验证产品码
|
|
|
string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(strCarrierBarcode);
|
|
|
|
|
@@ -3402,6 +3467,13 @@ namespace MainForm
|
|
|
AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
|
|
|
}
|
|
|
sn = strProductBarcode;
|
|
|
+ //数据库绑定载具和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>();
|
|
@@ -3434,7 +3506,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, "");
|
|
|
if (message.result == false)
|
|
@@ -3469,28 +3541,58 @@ namespace MainForm
|
|
|
AddMessage(LogType.Info, stationNameStr + "_出站接口;总用时" + stopwatch1.ElapsedMilliseconds + "ms;写入用时" + stopwatch2.ElapsedMilliseconds + "ms");
|
|
|
ProgressState = false;
|
|
|
}
|
|
|
-
|
|
|
- private void S5_PCB出站(OP50_MesData_t stPLC_MesData,int plcNo,string stationNameStr,string tagBaseName,string tagMesCommName) {
|
|
|
- if (stPLC_MesData.BarcodeSet.strPCBBarcode.Replace("\r", "") != "ERROR")
|
|
|
+ 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))
|
|
|
{
|
|
|
- int res = PCBStationOutData(stPLC_MesData.BarcodeSet, stPLC_MesData.iotData);
|
|
|
+ string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(stPLC_MesData.BarcodeSet.strCarrierBarcode);
|
|
|
+
|
|
|
+ stPLC_MesData.BarcodeSet.strProductBarcode = strProductBarcode;
|
|
|
CommandFromPLC resultToPlC = new CommandFromPLC();
|
|
|
resultToPlC.cmd = 0;
|
|
|
resultToPlC.cmdParam = 0; //指令参数
|
|
|
- if (res == 1)
|
|
|
+
|
|
|
+ if (GlobalContext.IsSendStationIn)
|
|
|
{
|
|
|
- resultToPlC.cmdResult = 2;
|
|
|
- WriteResultToPlc(plcNo, stationNameStr, tagBaseName + "." + tagMesCommName, 1, resultToPlC);
|
|
|
+ #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
|
|
|
- {
|
|
|
- resultToPlC.cmdResult = 120;
|
|
|
- WriteResultToPlc(plcNo, stationNameStr, tagBaseName + "." + tagMesCommName, 1, resultToPlC);
|
|
|
+ else {
|
|
|
+ return 2;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- return;
|
|
|
+ return 2;
|
|
|
}
|
|
|
|
|
|
}
|