|
@@ -151,7 +151,7 @@ namespace MainForm
|
|
XiaomiDeviceStateData xmDeviceStateData = new XiaomiDeviceStateData();
|
|
XiaomiDeviceStateData xmDeviceStateData = new XiaomiDeviceStateData();
|
|
|
|
|
|
private int test_item_num = 0;//iot 过站数据序号
|
|
private int test_item_num = 0;//iot 过站数据序号
|
|
- private string uuid = "";
|
|
|
|
|
|
+ public static string uuid = "";
|
|
private bool inpass = false;//保存进站测试状态
|
|
private bool inpass = false;//保存进站测试状态
|
|
|
|
|
|
public static XiaoMiParm xiaomiParm=new XiaoMiParm();
|
|
public static XiaoMiParm xiaomiParm=new XiaoMiParm();
|
|
@@ -225,25 +225,25 @@ namespace MainForm
|
|
if (GlobalContext.IsUsePLC6)
|
|
if (GlobalContext.IsUsePLC6)
|
|
{
|
|
{
|
|
GlobalContext.IsUsePLCNow = 6;
|
|
GlobalContext.IsUsePLCNow = 6;
|
|
- GlobalContext.IsUseStationName = "[OP60]组上盖板";
|
|
|
|
|
|
+ GlobalContext.IsUseStationName = "[OP70]组上盖板";
|
|
FunsEip.Add(GlobalContext.IsUsePLCNow, new Inovance_EIP(GlobalContext.PC6Address, GlobalContext.Machine6Address)); //OP60 顶盖装配
|
|
FunsEip.Add(GlobalContext.IsUsePLCNow, new Inovance_EIP(GlobalContext.PC6Address, GlobalContext.Machine6Address)); //OP60 顶盖装配
|
|
}
|
|
}
|
|
if (GlobalContext.IsUsePLC7)
|
|
if (GlobalContext.IsUsePLC7)
|
|
{
|
|
{
|
|
GlobalContext.IsUsePLCNow = 7;
|
|
GlobalContext.IsUsePLCNow = 7;
|
|
- GlobalContext.IsUseStationName = "[OP70]上盖板锁螺丝";
|
|
|
|
|
|
+ GlobalContext.IsUseStationName = "[OP80]上盖板锁螺丝";
|
|
FunsEip.Add(GlobalContext.IsUsePLCNow, new Inovance_EIP(GlobalContext.PC7Address, GlobalContext.Machine7Address)); //OP70 锁螺丝
|
|
FunsEip.Add(GlobalContext.IsUsePLCNow, new Inovance_EIP(GlobalContext.PC7Address, GlobalContext.Machine7Address)); //OP70 锁螺丝
|
|
}
|
|
}
|
|
if (GlobalContext.IsUsePLC8)
|
|
if (GlobalContext.IsUsePLC8)
|
|
{
|
|
{
|
|
GlobalContext.IsUsePLCNow = 8;
|
|
GlobalContext.IsUsePLCNow = 8;
|
|
- GlobalContext.IsUseStationName = "[OP80]NG下料";
|
|
|
|
|
|
+ GlobalContext.IsUseStationName = "[OP90]NG下料";
|
|
FunsEip.Add(GlobalContext.IsUsePLCNow, new Inovance_EIP(GlobalContext.PC8Address, GlobalContext.Machine8Address)); //OP80 3D螺丝高度检测,NG出料站
|
|
FunsEip.Add(GlobalContext.IsUsePLCNow, new Inovance_EIP(GlobalContext.PC8Address, GlobalContext.Machine8Address)); //OP80 3D螺丝高度检测,NG出料站
|
|
}
|
|
}
|
|
if (GlobalContext.IsUsePLC9)
|
|
if (GlobalContext.IsUsePLC9)
|
|
{
|
|
{
|
|
GlobalContext.IsUsePLCNow = 9;
|
|
GlobalContext.IsUsePLCNow = 9;
|
|
- GlobalContext.IsUseStationName = "[OP90]半成品下料";
|
|
|
|
|
|
+ GlobalContext.IsUseStationName = "[OP100]半成品下料";
|
|
FunsEip.Add(GlobalContext.IsUsePLCNow, new Inovance_EIP(GlobalContext.PC9Address, GlobalContext.Machine9Address)); //OP90 下料站
|
|
FunsEip.Add(GlobalContext.IsUsePLCNow, new Inovance_EIP(GlobalContext.PC9Address, GlobalContext.Machine9Address)); //OP90 下料站
|
|
}
|
|
}
|
|
(bool,string)DicResult=InitalDicAlarm(); // 实例化报警字典
|
|
(bool,string)DicResult=InitalDicAlarm(); // 实例化报警字典
|
|
@@ -1340,7 +1340,9 @@ namespace MainForm
|
|
private static bool isCollectingFlagLeft;
|
|
private static bool isCollectingFlagLeft;
|
|
private static bool isCollectingFlagRight;
|
|
private static bool isCollectingFlagRight;
|
|
private bool OpenDailogFalg = true;//是否开启扫码弹窗标识
|
|
private bool OpenDailogFalg = true;//是否开启扫码弹窗标识
|
|
-
|
|
|
|
|
|
+ public static bool isNoStop = false;//是否停止循环
|
|
|
|
+
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// float[]转为string
|
|
/// float[]转为string
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -1568,7 +1570,7 @@ namespace MainForm
|
|
|
|
|
|
mesRet = $"[{response?.header?.code}]{response?.header?.desc}";
|
|
mesRet = $"[{response?.header?.code}]{response?.header?.desc}";
|
|
// 记录失败原因
|
|
// 记录失败原因
|
|
- OnMessage(LogType.Error, $"上传出站数据到MES服务器---失败!正在重新上传!请求参数:{json_Body},接口报错信息:" + mesRet);
|
|
|
|
|
|
+ OnMessage(LogType.Error, $"上传出站数据到MES服务器---失败!正在重新上传!接口报错信息:{mesRet},请求参数:{ json_Body}");
|
|
}
|
|
}
|
|
|
|
|
|
if (response?.header?.code == "200")
|
|
if (response?.header?.code == "200")
|
|
@@ -1576,12 +1578,12 @@ namespace MainForm
|
|
string sql_Upd = stationIn.ToStringUpdateStatusByID(1);
|
|
string sql_Upd = stationIn.ToStringUpdateStatusByID(1);
|
|
string ret_Upd = SQLHelper_New.ExecuteNonQuery(sql_Upd, null);
|
|
string ret_Upd = SQLHelper_New.ExecuteNonQuery(sql_Upd, null);
|
|
result = ret_Upd == "成功" ? 1 : 6;
|
|
result = ret_Upd == "成功" ? 1 : 6;
|
|
- AddMessage(LogType.Info, $"【进站数据 SN {stationIn.Sn}】上传MES服务器---成功,请求参数:{json_Body},返回参数:{resultJson}");
|
|
|
|
|
|
+ AddMessage(LogType.Info, $"【进站数据 SN {stationIn.Sn}】上传MES服务器---成功,返回参数:{resultJson},请求参数:{json_Body}");
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
result = 5;
|
|
result = 5;
|
|
- AddMessage(LogType.Info, $"【进站数据 SN {stationIn.Sn}】上传MES服务器---失败!请求参数:{json_Body},接口报错信息:" + mesRet);
|
|
|
|
|
|
+ AddMessage(LogType.Info, $"【进站数据 SN {stationIn.Sn}】上传MES服务器---失败!接口报错信息: {mesRet},请求参数:{ json_Body}");
|
|
}
|
|
}
|
|
|
|
|
|
string sql_response =
|
|
string sql_response =
|
|
@@ -2703,6 +2705,183 @@ namespace MainForm
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void 通用节拍接口(int plcNo, string stationNameStr, string tagMesCommName, string CarrierBarcode, IoT_DataSet_t iot_data)
|
|
|
|
+ {
|
|
|
|
+ Stopwatch stopwatch1 = new Stopwatch();
|
|
|
|
+ Stopwatch stopwatch2 = new Stopwatch();
|
|
|
|
+
|
|
|
|
+ string resultStr = string.Empty;
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ stopwatch1.Start();
|
|
|
|
+ string oEEType = iot_data.BeatAction.ToString(); // 节拍类型(plc写入)
|
|
|
|
+ string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(CarrierBarcode);//产品SN
|
|
|
|
+
|
|
|
|
+ bool actionBool = Enum.TryParse(oEEType, out XiaomiDeviceOEE deviceOEE);
|
|
|
|
+ if (!actionBool)
|
|
|
|
+ {
|
|
|
|
+ stopwatch2.Start();
|
|
|
|
+ //写入PLC
|
|
|
|
+ IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
+ iotData.machineState = iot_data.machineState;
|
|
|
|
+ iotData.work_type = iot_data.work_type;
|
|
|
|
+ iotData.testStatus = iot_data.testStatus;
|
|
|
|
+ iotData.BeatAction = iot_data.BeatAction;
|
|
|
|
+ iotData.beatReturn = 2; //NG
|
|
|
|
+ iotData.fault_codes = iot_data.fault_codes;
|
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iotData);
|
|
|
|
+ stopwatch2.Stop();
|
|
|
|
+ AddMessage(LogType.Info,
|
|
|
|
+ stationNameStr + $"_节拍接口-- 设备上传了未识别的节拍类型【{oEEType}】请检查;总用时" + stopwatch1.ElapsedMilliseconds +
|
|
|
|
+ "ms;写入用时" + stopwatch2.ElapsedMilliseconds + "ms");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ //作业开始后要有物料和载具信息
|
|
|
|
+ //if (string.IsNullOrEmpty(strProductBarcode) && string.IsNullOrEmpty(CarrierBarcode) &&
|
|
|
|
+ // Convert.ToInt32(oEEType) > 2)
|
|
|
|
+ //{
|
|
|
|
+ // stopwatch2.Start();
|
|
|
|
+ // //写入PLC
|
|
|
|
+ // IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
+ // iotData.machineState = iot_data.machineState;
|
|
|
|
+ // iotData.work_type = iot_data.work_type;
|
|
|
|
+ // iotData.testStatus = iot_data.testStatus;
|
|
|
|
+ // iotData.BeatAction = iot_data.BeatAction;
|
|
|
|
+ // iotData.beatReturn = 2; //NG
|
|
|
|
+ // iotData.fault_codes = iot_data.fault_codes;
|
|
|
|
+ // WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iotData);
|
|
|
|
+ // stopwatch2.Stop();
|
|
|
|
+ // AddMessage_Station(stationNameStr, LogType.Info,
|
|
|
|
+ // stationNameStr + $"_[{CarrierBarcode}][{strProductBarcode}]上传节拍失败!物料码与载具SN不可都为空;总用时" +
|
|
|
|
+ // stopwatch1.ElapsedMilliseconds + "ms;调用Iot用时" + stopwatch2.ElapsedMilliseconds + "ms");
|
|
|
|
+ // return;
|
|
|
|
+ //}
|
|
|
|
+ //else if (Convert.ToInt32(oEEType) > 2 && string.IsNullOrEmpty(strProductBarcode))
|
|
|
|
+ //{
|
|
|
|
+ // stopwatch2.Start();
|
|
|
|
+ // //写入PLC
|
|
|
|
+ // IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
+ // iotData.machineState = iot_data.machineState;
|
|
|
|
+ // iotData.work_type = iot_data.work_type;
|
|
|
|
+ // iotData.testStatus = iot_data.testStatus;
|
|
|
|
+ // iotData.BeatAction = iot_data.BeatAction;
|
|
|
|
+ // iotData.beatReturn = 2; //NG
|
|
|
|
+ // iotData.fault_codes = iot_data.fault_codes;
|
|
|
|
+ // WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iotData);
|
|
|
|
+ // stopwatch2.Stop();
|
|
|
|
+ // AddMessage_Station(stationNameStr, LogType.Info,
|
|
|
|
+ // stationNameStr + $"_[{CarrierBarcode}]上传节拍失败!物料码不可为空;总用时" +
|
|
|
|
+ // stopwatch1.ElapsedMilliseconds + "ms;调用Iot用时" + stopwatch2.ElapsedMilliseconds + "ms");
|
|
|
|
+ // return;
|
|
|
|
+ //}
|
|
|
|
+ //else if (Convert.ToInt32(oEEType) > 2 && string.IsNullOrEmpty(CarrierBarcode))
|
|
|
|
+ //{
|
|
|
|
+ // stopwatch2.Start();
|
|
|
|
+ // //写入PLC
|
|
|
|
+ // IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
+ // iotData.machineState = iot_data.machineState;
|
|
|
|
+ // iotData.work_type = iot_data.work_type;
|
|
|
|
+ // iotData.testStatus = iot_data.testStatus;
|
|
|
|
+ // iotData.BeatAction = iot_data.BeatAction;
|
|
|
|
+ // iotData.beatReturn = 2; //NG
|
|
|
|
+ // iotData.fault_codes = iot_data.fault_codes;
|
|
|
|
+ // WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iotData);
|
|
|
|
+ // stopwatch2.Stop();
|
|
|
|
+ // AddMessage_Station(stationNameStr, LogType.Info,
|
|
|
|
+ // stationNameStr + $"_上传节拍失败!载具码不可为空;总用时" +
|
|
|
|
+ // stopwatch1.ElapsedMilliseconds + "ms;调用Iot用时" + stopwatch2.ElapsedMilliseconds + "ms");
|
|
|
|
+ // return;
|
|
|
|
+ //}
|
|
|
|
+
|
|
|
|
+ short _result = 0;
|
|
|
|
+
|
|
|
|
+ // 上传OEE
|
|
|
|
+ (short, string) result = SaveOEEData(plcNo, stationNameStr, deviceOEE, strProductBarcode, CarrierBarcode);
|
|
|
|
+ _result = result.Item1;
|
|
|
|
+ resultStr = result.Item2;
|
|
|
|
+
|
|
|
|
+ if (_result == 1)
|
|
|
|
+ {
|
|
|
|
+ stopwatch2.Start();
|
|
|
|
+ //写入PLC
|
|
|
|
+ IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
+ iotData.machineState = iot_data.machineState;
|
|
|
|
+ iotData.work_type = iot_data.work_type;
|
|
|
|
+ iotData.testStatus = iot_data.testStatus;
|
|
|
|
+ iotData.BeatAction = iot_data.BeatAction;
|
|
|
|
+ iotData.beatReturn = 1;//OK
|
|
|
|
+ iotData.fault_codes = iot_data.fault_codes;
|
|
|
|
+ (int,string) PLCresult= WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iotData);
|
|
|
|
+ if (PLCresult.Item1 != 0)
|
|
|
|
+ {
|
|
|
|
+ OnMessage(LogType.Info, $"PLC{plcNo}_{stationNameStr} 节拍{iotData.BeatAction}上传IOT成功!上传结果:" + resultStr);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ OnMessage(LogType.Info, $"PLC{plcNo}_{stationNameStr} 节拍{iotData.BeatAction}上传IOT失敗!上传结果:" + resultStr);
|
|
|
|
+ }
|
|
|
|
+ stopwatch2.Stop();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ stopwatch2.Start();
|
|
|
|
+ //写入PLC
|
|
|
|
+ IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
+ iotData.machineState = iot_data.machineState;
|
|
|
|
+ iotData.work_type = iot_data.work_type;
|
|
|
|
+ iotData.testStatus = iot_data.testStatus;
|
|
|
|
+ iotData.BeatAction = iot_data.BeatAction;
|
|
|
|
+ iotData.beatReturn = 2; //NG
|
|
|
|
+ iotData.fault_codes = iot_data.fault_codes;
|
|
|
|
+ (int, string) PLCresult = WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iotData);
|
|
|
|
+ if (PLCresult.Item1 != 0)
|
|
|
|
+ {
|
|
|
|
+ OnMessage(LogType.Info, $"PLC{plcNo}_{stationNameStr} 节拍{iotData.BeatAction}上传IOT成功!上传结果:" + resultStr);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ OnMessage(LogType.Info, $"PLC{plcNo}_{stationNameStr} 节拍{iotData.BeatAction}上传IOT失敗!上传结果:" + resultStr);
|
|
|
|
+ }
|
|
|
|
+ stopwatch2.Stop();
|
|
|
|
+ AddMessage_Station(stationNameStr, LogType.Error,
|
|
|
|
+ $"PLC{plcNo}_{stationNameStr} 节拍接口出错!错误信息:" + resultStr);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+ string str = ex.StackTrace;
|
|
|
|
+ AddMessage_Station(stationNameStr, LogType.Error,
|
|
|
|
+ $"PLC{plcNo}_{stationNameStr} 节拍接口出错!错误信息:" + ex.Message + "异常位置:" +
|
|
|
|
+ str.Substring(str.LastIndexOf("\\") + 1, str.Length - str.LastIndexOf("\\") - 1));
|
|
|
|
+
|
|
|
|
+ // MES_Flag
|
|
|
|
+ stopwatch2.Start();
|
|
|
|
+ //写入PLC
|
|
|
|
+ IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
+ iotData.machineState = iot_data.machineState;
|
|
|
|
+ iotData.work_type = iot_data.work_type;
|
|
|
|
+ iotData.testStatus = iot_data.testStatus;
|
|
|
|
+ iotData.BeatAction = iot_data.BeatAction;
|
|
|
|
+ iotData.beatReturn = 2; //NG
|
|
|
|
+ iotData.fault_codes = iot_data.fault_codes;
|
|
|
|
+ (int, string) PLCresult = WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
|
|
|
|
+ if (PLCresult.Item1 != 0)
|
|
|
|
+ {
|
|
|
|
+ OnMessage(LogType.Info, $"PLC{plcNo}_{stationNameStr} 节拍{iotData.BeatAction}上传IOT成功!上传结果:" + resultStr);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ OnMessage(LogType.Info, $"PLC{plcNo}_{stationNameStr} 节拍{iotData.BeatAction}上传IOT失敗!上传结果:" + resultStr);
|
|
|
|
+ }
|
|
|
|
+ stopwatch2.Stop();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ stopwatch1.Stop();
|
|
|
|
+ AddMessage(LogType.Info,
|
|
|
|
+ stationNameStr + $"_节拍接口-- {resultStr};总用时" + stopwatch1.ElapsedMilliseconds + "ms;写入用时" +
|
|
|
|
+ stopwatch2.ElapsedMilliseconds + "ms");
|
|
|
|
+ }
|
|
|
|
+
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
#region S1
|
|
#region S1
|
|
@@ -3577,9 +3756,7 @@ namespace MainForm
|
|
|
|
|
|
// PLC数据字典 赋值
|
|
// PLC数据字典 赋值
|
|
s3PLCData.Add("a3OEEType_left", 0); // 节拍类型(plc写入)
|
|
s3PLCData.Add("a3OEEType_left", 0); // 节拍类型(plc写入)
|
|
- s3PLCData.Add("a3OEEPartNo_left", ""); // 物料码(物料码还未绑定载具SN时必填)
|
|
|
|
s3PLCData.Add("a3OEEType_right", 0); // 节拍类型(plc写入)
|
|
s3PLCData.Add("a3OEEType_right", 0); // 节拍类型(plc写入)
|
|
- s3PLCData.Add("a3OEEPartNo_right", ""); // 物料码(物料码还未绑定载具SN时必填)
|
|
|
|
|
|
|
|
OP30_MesData_t stPLC_MesData; //PLC的MES数据
|
|
OP30_MesData_t stPLC_MesData; //PLC的MES数据
|
|
(int, string) result;
|
|
(int, string) result;
|
|
@@ -3601,9 +3778,6 @@ namespace MainForm
|
|
stopwatch1.Start();
|
|
stopwatch1.Start();
|
|
stopwatch2.Start();
|
|
stopwatch2.Start();
|
|
|
|
|
|
- stPLC_MesData.Left.BarcodeSet.strCarrierBarcode = "A123456";
|
|
|
|
- stPLC_MesData.Left.iotData.BeatAction = 1;
|
|
|
|
-
|
|
|
|
#region 一次性读取所有数据
|
|
#region 一次性读取所有数据
|
|
|
|
|
|
// 一次性读取所有数据
|
|
// 一次性读取所有数据
|
|
@@ -3771,89 +3945,103 @@ namespace MainForm
|
|
#region 节拍接口
|
|
#region 节拍接口
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- #region 左工位 节拍
|
|
|
|
- int a3OEEType_left = Convert.ToInt32(s3PLCData["a3OEEType_left"]);
|
|
|
|
- int a3OEETypeGOld_left = Convert.ToInt32(s3PLCSignal_Old["a3OEEType_left"]);
|
|
|
|
- //若设备紧急复原后节拍重置
|
|
|
|
- if (a3OEEType_left == 1)
|
|
|
|
- {
|
|
|
|
- a3OEETypeGOld_left = 0;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- if (a3OEEType_left != a3OEETypeGOld_left)
|
|
|
|
|
|
+ #region 左工位 节拍
|
|
|
|
+ if (stPLC_MesData.Left.iotData.BeatAction > 0)
|
|
{
|
|
{
|
|
- stationNameStr = stationNameStr + "_Left";
|
|
|
|
- //节拍需要成双成对,有开始就要有结束,例如有1上料开始就必须有2上料结束
|
|
|
|
- if ((a3OEETypeGOld_left == 1 && a3OEEType_left != 2) || (a3OEETypeGOld_left == 3 && a3OEEType_left != 4)
|
|
|
|
- || (a3OEETypeGOld_left == 5 && a3OEEType_left != 6))
|
|
|
|
|
|
+ stationCode = "[OP31]";
|
|
|
|
+ stationName = "点散热胶装备1";
|
|
|
|
+ stationNameStr = stationCode + stationName;
|
|
|
|
+ int a3OEEType_left = Convert.ToInt32(s3PLCData["a3OEEType_left"]);
|
|
|
|
+ int a3OEETypeGOld_left = Convert.ToInt32(s3PLCSignal_Old["a3OEEType_left"]);
|
|
|
|
+ //若设备紧急复原后节拍重置
|
|
|
|
+ if (a3OEEType_left == 1)
|
|
{
|
|
{
|
|
- //写入PLC
|
|
|
|
- IoT_DataSet_t iotData=new IoT_DataSet_t();
|
|
|
|
- iotData.machineState = stPLC_MesData.Left.iotData.machineState;
|
|
|
|
- iotData.work_type = stPLC_MesData.Left.iotData.work_type;
|
|
|
|
- iotData.testStatus = stPLC_MesData.Left.iotData.testStatus;
|
|
|
|
- iotData.BeatAction = stPLC_MesData.Left.iotData.BeatAction;
|
|
|
|
- iotData.beatReturn = 2; //NG
|
|
|
|
- iotData.fault_codes = stPLC_MesData.Left.iotData.fault_codes;
|
|
|
|
- WriteResultToPlc(plcNo, stationNameStr, tagBaseName + ".Left." + tagiotComnName, 1, iotData);
|
|
|
|
- AddMessage(LogType.Info,
|
|
|
|
- stationNameStr +
|
|
|
|
- $"_节拍接口-- 设备本次上传节拍[{a3OEEType_left}],未上传节拍[{a3OEETypeGOld_left}]的结束信号,请检查;总用时" +
|
|
|
|
- stopwatch1.ElapsedMilliseconds + "ms;写入用时" + stopwatch2.ElapsedMilliseconds +
|
|
|
|
- "ms");
|
|
|
|
- return;
|
|
|
|
|
|
+ a3OEETypeGOld_left = 0;
|
|
}
|
|
}
|
|
- else
|
|
|
|
|
|
+
|
|
|
|
+ if (a3OEEType_left != a3OEETypeGOld_left)
|
|
{
|
|
{
|
|
- Task.Run(() =>
|
|
|
|
- S3节拍接口(plcNo, stationNameStr, tagBaseName + ".Left." + tagiotComnName, stPLC_MesData.Left.BarcodeSet.strCarrierBarcode.ToString(),
|
|
|
|
- stPLC_MesData.Left.iotData)); // MreTasks[4].Set();
|
|
|
|
|
|
+ stationNameStr = stationNameStr + "_Left";
|
|
|
|
+ //节拍需要成双成对,有开始就要有结束,例如有1上料开始就必须有2上料结束
|
|
|
|
+ if ((a3OEETypeGOld_left == 1 && a3OEEType_left != 2) || (a3OEETypeGOld_left == 3 && a3OEEType_left != 4)
|
|
|
|
+ || (a3OEETypeGOld_left == 5 && a3OEEType_left != 6))
|
|
|
|
+ {
|
|
|
|
+ //写入PLC
|
|
|
|
+ IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
+ iotData.machineState = stPLC_MesData.Left.iotData.machineState;
|
|
|
|
+ iotData.work_type = stPLC_MesData.Left.iotData.work_type;
|
|
|
|
+ iotData.testStatus = stPLC_MesData.Left.iotData.testStatus;
|
|
|
|
+ iotData.BeatAction = stPLC_MesData.Left.iotData.BeatAction;
|
|
|
|
+ iotData.beatReturn = 2; //NG
|
|
|
|
+ iotData.fault_codes = stPLC_MesData.Left.iotData.fault_codes;
|
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagBaseName + ".Left." + tagiotComnName, 1, iotData);
|
|
|
|
+ AddMessage(LogType.Info,
|
|
|
|
+ stationNameStr +
|
|
|
|
+ $"_节拍接口-- 设备本次上传节拍[{a3OEEType_left}],未上传节拍[{a3OEETypeGOld_left}]的结束信号,请检查;总用时" +
|
|
|
|
+ stopwatch1.ElapsedMilliseconds + "ms;写入用时" + stopwatch2.ElapsedMilliseconds +
|
|
|
|
+ "ms");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ Task.Run(() =>
|
|
|
|
+ S3节拍接口(plcNo, stationNameStr, tagBaseName + ".Left." + tagiotComnName, stPLC_MesData.Left.BarcodeSet.strCarrierBarcode.ToString(),
|
|
|
|
+ stPLC_MesData.Left.iotData)); // MreTasks[4].Set();
|
|
|
|
+ }
|
|
|
|
+ s3PLCSignal_Old["a3OEEType_left"] = s3PLCData["a3OEEType_left"];
|
|
}
|
|
}
|
|
- s3PLCSignal_Old["a3OEEType_left"] = s3PLCData["a3OEEType_left"];
|
|
|
|
}
|
|
}
|
|
#endregion 左工位 节拍
|
|
#endregion 左工位 节拍
|
|
|
|
|
|
#region 右工位 节拍
|
|
#region 右工位 节拍
|
|
- int a3OEEType_right = Convert.ToInt32(s3PLCData["a3OEEType_right"]);
|
|
|
|
- int a3OEETypeGOld_right = Convert.ToInt32(s3PLCSignal_Old["a3OEEType_right"]);
|
|
|
|
-
|
|
|
|
- //若设备紧急复原后节拍重置
|
|
|
|
- if (a3OEEType_right == 1)
|
|
|
|
|
|
+ if (stPLC_MesData.Right.iotData.BeatAction > 0)
|
|
{
|
|
{
|
|
- a3OEETypeGOld_right = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (a3OEEType_right != a3OEETypeGOld_right)
|
|
|
|
- {
|
|
|
|
- stationNameStr = stationNameStr + "_Right";
|
|
|
|
- //节拍需要成双成对,有开始就要有结束,例如有1上料开始就必须有2上料结束
|
|
|
|
- if ((a3OEETypeGOld_right == 1 && a3OEEType_right != 2) || (a3OEETypeGOld_right == 3 && a3OEEType_right != 4) ||
|
|
|
|
- (a3OEETypeGOld_right == 5 && a3OEEType_right != 6))
|
|
|
|
|
|
+ stationCode = "[OP32]";
|
|
|
|
+ stationName = "点散热胶装备2";
|
|
|
|
+ stationNameStr = stationCode + stationName;
|
|
|
|
+ int a3OEEType_right = Convert.ToInt32(s3PLCData["a3OEEType_right"]);
|
|
|
|
+ int a3OEETypeGOld_right = Convert.ToInt32(s3PLCSignal_Old["a3OEEType_right"]);
|
|
|
|
+
|
|
|
|
+ //若设备紧急复原后节拍重置
|
|
|
|
+ if (a3OEEType_right == 1)
|
|
{
|
|
{
|
|
- //写入PLC
|
|
|
|
- IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
- iotData.machineState = stPLC_MesData.Left.iotData.machineState;
|
|
|
|
- iotData.work_type = stPLC_MesData.Left.iotData.work_type;
|
|
|
|
- iotData.testStatus = stPLC_MesData.Left.iotData.testStatus;
|
|
|
|
- iotData.BeatAction = stPLC_MesData.Left.iotData.BeatAction;
|
|
|
|
- iotData.beatReturn = 2; //NG
|
|
|
|
- iotData.fault_codes = stPLC_MesData.Left.iotData.fault_codes;
|
|
|
|
- WriteResultToPlc(plcNo, stationNameStr, tagBaseName + ".Right." + tagMesCommName, 1, iotData);
|
|
|
|
- AddMessage(LogType.Info,
|
|
|
|
- stationNameStr +
|
|
|
|
- $"_节拍接口-- 设备本次上传节拍[{a3OEEType_right}],未上传节拍[{a3OEETypeGOld_right}]的结束信号,请检查;总用时" +
|
|
|
|
- stopwatch1.ElapsedMilliseconds + "ms;写入用时" + stopwatch2.ElapsedMilliseconds +
|
|
|
|
- "ms");
|
|
|
|
- return;
|
|
|
|
|
|
+ a3OEETypeGOld_right = 0;
|
|
}
|
|
}
|
|
- else
|
|
|
|
|
|
+
|
|
|
|
+ if (a3OEEType_right != a3OEETypeGOld_right)
|
|
{
|
|
{
|
|
- Task.Run(() =>
|
|
|
|
- S3节拍接口(plcNo, stationNameStr, tagBaseName + ".Right." + tagMesCommName, stPLC_MesData.Right.BarcodeSet.strCarrierBarcode,
|
|
|
|
- stPLC_MesData.Left.iotData)); // MreTasks[4].Set();
|
|
|
|
|
|
+ stationNameStr = stationNameStr + "_Right";
|
|
|
|
+ //节拍需要成双成对,有开始就要有结束,例如有1上料开始就必须有2上料结束
|
|
|
|
+ if ((a3OEETypeGOld_right == 1 && a3OEEType_right != 2) || (a3OEETypeGOld_right == 3 && a3OEEType_right != 4) ||
|
|
|
|
+ (a3OEETypeGOld_right == 5 && a3OEEType_right != 6))
|
|
|
|
+ {
|
|
|
|
+ //写入PLC
|
|
|
|
+ IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
+ iotData.machineState = stPLC_MesData.Left.iotData.machineState;
|
|
|
|
+ iotData.work_type = stPLC_MesData.Left.iotData.work_type;
|
|
|
|
+ iotData.testStatus = stPLC_MesData.Left.iotData.testStatus;
|
|
|
|
+ iotData.BeatAction = stPLC_MesData.Left.iotData.BeatAction;
|
|
|
|
+ iotData.beatReturn = 2; //NG
|
|
|
|
+ iotData.fault_codes = stPLC_MesData.Left.iotData.fault_codes;
|
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagBaseName + ".Right." + tagiotComnName, 1, iotData);
|
|
|
|
+ AddMessage(LogType.Info,
|
|
|
|
+ stationNameStr +
|
|
|
|
+ $"_节拍接口-- 设备本次上传节拍[{a3OEEType_right}],未上传节拍[{a3OEETypeGOld_right}]的结束信号,请检查;总用时" +
|
|
|
|
+ stopwatch1.ElapsedMilliseconds + "ms;写入用时" + stopwatch2.ElapsedMilliseconds +
|
|
|
|
+ "ms");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ Task.Run(() =>
|
|
|
|
+ S3节拍接口(plcNo, stationNameStr, tagBaseName + ".Right." + tagiotComnName, stPLC_MesData.Right.BarcodeSet.strCarrierBarcode,
|
|
|
|
+ stPLC_MesData.Left.iotData)); // MreTasks[4].Set();
|
|
|
|
+ }
|
|
|
|
+ s3PLCSignal_Old["a3OEEType_right"] = s3PLCData["a3OEEType_right"];
|
|
}
|
|
}
|
|
- s3PLCSignal_Old["a3OEEType_right"] = s3PLCData["a3OEEType_right"];
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
#endregion 右工位 节拍
|
|
#endregion 右工位 节拍
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
@@ -4677,16 +4865,17 @@ namespace MainForm
|
|
string tagBaseName = "g_OP50_MES"; //标签变量名称
|
|
string tagBaseName = "g_OP50_MES"; //标签变量名称
|
|
string tagMesCommName = "mesCommToPC"; //标签变量名称
|
|
string tagMesCommName = "mesCommToPC"; //标签变量名称
|
|
string tagAgvCommName = "agvCommFrmPC";
|
|
string tagAgvCommName = "agvCommFrmPC";
|
|
|
|
+ string tagiotComnName = "iotData";
|
|
string tagBarsetName = "BarcodeSet";
|
|
string tagBarsetName = "BarcodeSet";
|
|
|
|
|
|
|
|
+ string CarrierBarcode = "";
|
|
|
|
+
|
|
// 触发信号字典
|
|
// 触发信号字典
|
|
//s1PLCSignal_Old.Add("a1OEEPLC_FLAG", 0); // PLC_FLAG 节拍接口
|
|
//s1PLCSignal_Old.Add("a1OEEPLC_FLAG", 0); // PLC_FLAG 节拍接口
|
|
s5PLCSignal_Old.Add("a5OEEType", 0); // 节拍类型(plc写入)
|
|
s5PLCSignal_Old.Add("a5OEEType", 0); // 节拍类型(plc写入)
|
|
|
|
|
|
// PLC数据字典 赋值
|
|
// PLC数据字典 赋值
|
|
s5PLCData.Add("a5OEEType", 0); // 节拍类型(plc写入)
|
|
s5PLCData.Add("a5OEEType", 0); // 节拍类型(plc写入)
|
|
- s5PLCData.Add("a50EEPartNo", ""); // 物料码(物料码还未绑定载具SN时必填)
|
|
|
|
- s5PLCData.Add("a50EEVehicleCode", ""); // 载具SN
|
|
|
|
|
|
|
|
OP50_MesData_t stPLC_MesData; //PLC的MES数据
|
|
OP50_MesData_t stPLC_MesData; //PLC的MES数据
|
|
(int, string) result;
|
|
(int, string) result;
|
|
@@ -4706,9 +4895,14 @@ namespace MainForm
|
|
Stopwatch stopwatch1 = new Stopwatch();
|
|
Stopwatch stopwatch1 = new Stopwatch();
|
|
Stopwatch stopwatch2 = new Stopwatch();
|
|
Stopwatch stopwatch2 = new Stopwatch();
|
|
stopwatch1.Start();
|
|
stopwatch1.Start();
|
|
-
|
|
|
|
stopwatch2.Start();
|
|
stopwatch2.Start();
|
|
|
|
|
|
|
|
+ //测试
|
|
|
|
+ stPLC_MesData.mesCommFrmPLC.cmd = 1;
|
|
|
|
+ stPLC_MesData.BarcodeSet.strCarrierBarcode = "A123456";
|
|
|
|
+ stPLC_MesData.BarcodeSet.strPCBBarcode = "123456";
|
|
|
|
+ stPLC_MesData.iotData.BeatAction = 1;
|
|
|
|
+
|
|
#region 一次性读取所有数据
|
|
#region 一次性读取所有数据
|
|
|
|
|
|
// 一次性读取所有数据
|
|
// 一次性读取所有数据
|
|
@@ -4716,20 +4910,18 @@ namespace MainForm
|
|
.Read_SingleTag<OP50_MesData_t>(tagBaseName, 1, out stPLC_MesData, this); //读取单个结构体数据
|
|
.Read_SingleTag<OP50_MesData_t>(tagBaseName, 1, out stPLC_MesData, this); //读取单个结构体数据
|
|
if (result.Item1 != 0)
|
|
if (result.Item1 != 0)
|
|
{
|
|
{
|
|
- //richTextBox1.AppendText("\n" + strRet);
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- //richTextBox1.AppendText("\n" + "读取成功");
|
|
|
|
//richTextBox1.AppendText("\n" + "读取成功");
|
|
//richTextBox1.AppendText("\n" + "读取成功");
|
|
int xmDeviceStateInt = stPLC_MesData.iotData.machineState;
|
|
int xmDeviceStateInt = stPLC_MesData.iotData.machineState;
|
|
xmDeviceStateData.left = (xmDeviceStateInt < 0 || xmDeviceStateInt > 7)
|
|
xmDeviceStateData.left = (xmDeviceStateInt < 0 || xmDeviceStateInt > 7)
|
|
? XiaomiDeviceState.Unknown
|
|
? XiaomiDeviceState.Unknown
|
|
: (XiaomiDeviceState)xmDeviceStateInt;
|
|
: (XiaomiDeviceState)xmDeviceStateInt;
|
|
|
|
|
|
- s5PLCData["a5OEEPartNo"] = stPLC_MesData.BarcodeSet.strProductBarcode; // 物料码(物料码还未绑定载具SN时必填)
|
|
|
|
- s5PLCData["a5OEEVehicleCode"] = stPLC_MesData.BarcodeSet.strCarrierBarcode; // 载具SN
|
|
|
|
s5PLCData["a5OEEType"] = stPLC_MesData.iotData.BeatAction; // 节拍
|
|
s5PLCData["a5OEEType"] = stPLC_MesData.iotData.BeatAction; // 节拍
|
|
|
|
+ CarrierBarcode=stPLC_MesData.BarcodeSet.strCarrierBarcode.ToString();
|
|
}
|
|
}
|
|
|
|
|
|
#endregion 一次性读取所有数据
|
|
#endregion 一次性读取所有数据
|
|
@@ -4800,39 +4992,56 @@ namespace MainForm
|
|
#region 节拍接口
|
|
#region 节拍接口
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- int a5OEEType = (int)s5PLCData["a5OEEType"];
|
|
|
|
- int a5OEETypeGOld = (int)s5PLCSignal_Old["a5OEEType"];
|
|
|
|
- //若设备紧急复原后节拍重置
|
|
|
|
- if (a5OEEType == 1)
|
|
|
|
- {
|
|
|
|
- a5OEETypeGOld = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (a5OEEType != a5OEETypeGOld)
|
|
|
|
- {
|
|
|
|
- //节拍需要成双成对,有开始就要有结束,例如有1上料开始就必须有2上料结束
|
|
|
|
- if ((a5OEETypeGOld == 1 && a5OEEType != 2) || (a5OEETypeGOld == 3 && a5OEEType != 4) ||
|
|
|
|
- (a5OEETypeGOld == 5 && a5OEEType != 6))
|
|
|
|
|
|
+ if (stPLC_MesData.iotData.BeatAction > 0) {
|
|
|
|
+ int a5OEEType = Convert.ToInt32(s5PLCData["a5OEEType"]);
|
|
|
|
+ int a5OEETypeGOld = Convert.ToInt32(s5PLCSignal_Old["a5OEEType"]);
|
|
|
|
+ //若设备紧急复原后节拍重置
|
|
|
|
+ if (a5OEEType == 1)
|
|
{
|
|
{
|
|
- //写入PLC
|
|
|
|
- stPLC_MesData.iotData.beatReturn = 2; //NG
|
|
|
|
- WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, stPLC_MesData.iotData);
|
|
|
|
- AddMessage(LogType.Info,
|
|
|
|
- stationNameStr +
|
|
|
|
- $"_节拍接口-- 设备本次上传节拍[{a5OEEType}],未上传节拍[{a5OEETypeGOld}]的结束信号,请检查;总用时" +
|
|
|
|
- stopwatch1.ElapsedMilliseconds + "ms;写入用时" + stopwatch2.ElapsedMilliseconds +
|
|
|
|
- "ms");
|
|
|
|
- return;
|
|
|
|
|
|
+ a5OEETypeGOld = 0;
|
|
}
|
|
}
|
|
- else
|
|
|
|
|
|
+
|
|
|
|
+ if (a5OEEType != a5OEETypeGOld)
|
|
{
|
|
{
|
|
- Task.Run(() =>
|
|
|
|
- S5节拍接口(plcNo, stationNameStr, tagBaseName,
|
|
|
|
- stPLC_MesData.iotData)); // MreTasks[4].Set();
|
|
|
|
|
|
+ //如果上位机告诉PLC NG,PLC节拍会直接跳到4
|
|
|
|
+ if (a5OEETypeGOld == 1 && a5OEEType == 4)
|
|
|
|
+ {
|
|
|
|
+ Task.Run(() =>
|
|
|
|
+ 通用节拍接口(plcNo, stationNameStr, tagBaseName + "." + tagiotComnName, CarrierBarcode,
|
|
|
|
+ stPLC_MesData.iotData));
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ //节拍需要成双成对,有开始就要有结束,例如有1上料开始就必须有2上料结束
|
|
|
|
+ if ((a5OEETypeGOld == 1 && a5OEEType != 2) || (a5OEETypeGOld == 3 && a5OEEType != 4) ||
|
|
|
|
+ (a5OEETypeGOld == 5 && a5OEEType != 6))
|
|
|
|
+ {
|
|
|
|
+ //写入PLC
|
|
|
|
+ IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
+ iotData.machineState = stPLC_MesData.iotData.machineState;
|
|
|
|
+ iotData.work_type = stPLC_MesData.iotData.work_type;
|
|
|
|
+ iotData.testStatus = stPLC_MesData.iotData.testStatus;
|
|
|
|
+ iotData.BeatAction = stPLC_MesData.iotData.BeatAction;
|
|
|
|
+ iotData.beatReturn = 2; //NG
|
|
|
|
+ iotData.fault_codes = stPLC_MesData.iotData.fault_codes;
|
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagBaseName + "." + tagiotComnName, 1, iotData);
|
|
|
|
+ AddMessage(LogType.Info,
|
|
|
|
+ stationNameStr +
|
|
|
|
+ $"_节拍接口-- 设备本次上传节拍[{a5OEEType}],未上传节拍[{a5OEETypeGOld}]的结束信号,请检查;总用时" +
|
|
|
|
+ stopwatch1.ElapsedMilliseconds + "ms;写入用时" + stopwatch2.ElapsedMilliseconds +
|
|
|
|
+ "ms");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ Task.Run(() => 通用节拍接口(plcNo, stationNameStr, tagBaseName + "." + tagiotComnName, CarrierBarcode,stPLC_MesData.iotData));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ s5PLCSignal_Old["a5OEEType"] = s5PLCData["a5OEEType"];
|
|
}
|
|
}
|
|
-
|
|
|
|
- s5PLCSignal_Old["a5OEEType"] = s5PLCData["a5OEEType"];
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
@@ -5093,7 +5302,7 @@ namespace MainForm
|
|
ProgressState = false;
|
|
ProgressState = false;
|
|
}
|
|
}
|
|
|
|
|
|
- private void S5节拍接口(int plcNo, string stationNameStr, string tagMesCommName, IoT_DataSet_t iot_data)
|
|
|
|
|
|
+ private void S5节拍接口(int plcNo, string stationNameStr, string tagMesCommName, string CarrierBarcode, IoT_DataSet_t iot_data)
|
|
{
|
|
{
|
|
Stopwatch stopwatch1 = new Stopwatch();
|
|
Stopwatch stopwatch1 = new Stopwatch();
|
|
Stopwatch stopwatch2 = new Stopwatch();
|
|
Stopwatch stopwatch2 = new Stopwatch();
|
|
@@ -5102,19 +5311,22 @@ namespace MainForm
|
|
try
|
|
try
|
|
{
|
|
{
|
|
stopwatch1.Start();
|
|
stopwatch1.Start();
|
|
- string oEEType = ((int)s1PLCData["a5OEEType"]).ToString(); // 节拍类型(plc写入)
|
|
|
|
- string a50EEPartNo = (string)s1PLCData["a50EEPartNo"]; // 物料码
|
|
|
|
- a50EEPartNo = a50EEPartNo.Replace("\0", "");
|
|
|
|
- string a40EEVehicleCode = (string)s1PLCData["a40EEVehicleCode"]; // 载具SN
|
|
|
|
- a40EEVehicleCode = a40EEVehicleCode.Replace("\0", "");
|
|
|
|
|
|
+ string oEEType = iot_data.BeatAction.ToString(); // 节拍类型(plc写入)
|
|
|
|
+ string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(CarrierBarcode);//产品SN
|
|
|
|
|
|
bool actionBool = Enum.TryParse(oEEType, out XiaomiDeviceOEE deviceOEE);
|
|
bool actionBool = Enum.TryParse(oEEType, out XiaomiDeviceOEE deviceOEE);
|
|
if (!actionBool)
|
|
if (!actionBool)
|
|
{
|
|
{
|
|
stopwatch2.Start();
|
|
stopwatch2.Start();
|
|
//写入PLC
|
|
//写入PLC
|
|
- iot_data.beatReturn = 2; //NG
|
|
|
|
- WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
|
|
|
|
|
|
+ IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
+ iotData.machineState = iot_data.machineState;
|
|
|
|
+ iotData.work_type = iot_data.work_type;
|
|
|
|
+ iotData.testStatus = iot_data.testStatus;
|
|
|
|
+ iotData.BeatAction = iot_data.BeatAction;
|
|
|
|
+ iotData.beatReturn = 2; //NG
|
|
|
|
+ iotData.fault_codes = iot_data.fault_codes;
|
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iotData);
|
|
stopwatch2.Stop();
|
|
stopwatch2.Stop();
|
|
AddMessage(LogType.Info,
|
|
AddMessage(LogType.Info,
|
|
stationNameStr + $"_节拍接口-- 设备上传了未识别的节拍类型【{oEEType}】请检查;总用时" + stopwatch1.ElapsedMilliseconds +
|
|
stationNameStr + $"_节拍接口-- 设备上传了未识别的节拍类型【{oEEType}】请检查;总用时" + stopwatch1.ElapsedMilliseconds +
|
|
@@ -5122,48 +5334,66 @@ namespace MainForm
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
//作业开始后要有物料和载具信息
|
|
//作业开始后要有物料和载具信息
|
|
- if (string.IsNullOrEmpty(a50EEPartNo) && string.IsNullOrEmpty(a40EEVehicleCode) &&
|
|
|
|
|
|
+ if (string.IsNullOrEmpty(strProductBarcode) && string.IsNullOrEmpty(CarrierBarcode) &&
|
|
Convert.ToInt32(oEEType) > 2)
|
|
Convert.ToInt32(oEEType) > 2)
|
|
{
|
|
{
|
|
stopwatch2.Start();
|
|
stopwatch2.Start();
|
|
//写入PLC
|
|
//写入PLC
|
|
- iot_data.beatReturn = 2; //NG
|
|
|
|
- WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
|
|
|
|
|
|
+ IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
+ iotData.machineState = iot_data.machineState;
|
|
|
|
+ iotData.work_type = iot_data.work_type;
|
|
|
|
+ iotData.testStatus = iot_data.testStatus;
|
|
|
|
+ iotData.BeatAction = iot_data.BeatAction;
|
|
|
|
+ iotData.beatReturn = 2; //NG
|
|
|
|
+ iotData.fault_codes = iot_data.fault_codes;
|
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iotData);
|
|
stopwatch2.Stop();
|
|
stopwatch2.Stop();
|
|
AddMessage_Station(stationNameStr, LogType.Info,
|
|
AddMessage_Station(stationNameStr, LogType.Info,
|
|
- stationNameStr + $"_[{a40EEVehicleCode}][{a50EEPartNo}]上传节拍失败!物料码与载具SN不可都为空;总用时" +
|
|
|
|
|
|
+ stationNameStr + $"_[{CarrierBarcode}][{strProductBarcode}]上传节拍失败!物料码与载具SN不可都为空;总用时" +
|
|
stopwatch1.ElapsedMilliseconds + "ms;调用Iot用时" + stopwatch2.ElapsedMilliseconds + "ms");
|
|
stopwatch1.ElapsedMilliseconds + "ms;调用Iot用时" + stopwatch2.ElapsedMilliseconds + "ms");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- else if (Convert.ToInt32(oEEType) > 2 && string.IsNullOrEmpty(a50EEPartNo))
|
|
|
|
|
|
+ else if (Convert.ToInt32(oEEType) > 2 && string.IsNullOrEmpty(strProductBarcode))
|
|
{
|
|
{
|
|
stopwatch2.Start();
|
|
stopwatch2.Start();
|
|
//写入PLC
|
|
//写入PLC
|
|
- iot_data.beatReturn = 2; //NG
|
|
|
|
- WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
|
|
|
|
|
|
+ IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
+ iotData.machineState = iot_data.machineState;
|
|
|
|
+ iotData.work_type = iot_data.work_type;
|
|
|
|
+ iotData.testStatus = iot_data.testStatus;
|
|
|
|
+ iotData.BeatAction = iot_data.BeatAction;
|
|
|
|
+ iotData.beatReturn = 2; //NG
|
|
|
|
+ iotData.fault_codes = iot_data.fault_codes;
|
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iotData);
|
|
stopwatch2.Stop();
|
|
stopwatch2.Stop();
|
|
AddMessage_Station(stationNameStr, LogType.Info,
|
|
AddMessage_Station(stationNameStr, LogType.Info,
|
|
- stationNameStr + $"_[{a40EEVehicleCode}][{a50EEPartNo}]上传节拍失败!物料码不可为空;总用时" +
|
|
|
|
|
|
+ stationNameStr + $"_[{CarrierBarcode}]上传节拍失败!物料码不可为空;总用时" +
|
|
stopwatch1.ElapsedMilliseconds + "ms;调用Iot用时" + stopwatch2.ElapsedMilliseconds + "ms");
|
|
stopwatch1.ElapsedMilliseconds + "ms;调用Iot用时" + stopwatch2.ElapsedMilliseconds + "ms");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- else if (Convert.ToInt32(oEEType) > 2 && string.IsNullOrEmpty(a40EEVehicleCode))
|
|
|
|
|
|
+ else if (Convert.ToInt32(oEEType) > 2 && string.IsNullOrEmpty(CarrierBarcode))
|
|
{
|
|
{
|
|
stopwatch2.Start();
|
|
stopwatch2.Start();
|
|
//写入PLC
|
|
//写入PLC
|
|
- iot_data.beatReturn = 2; //NG
|
|
|
|
- WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
|
|
|
|
|
|
+ IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
+ iotData.machineState = iot_data.machineState;
|
|
|
|
+ iotData.work_type = iot_data.work_type;
|
|
|
|
+ iotData.testStatus = iot_data.testStatus;
|
|
|
|
+ iotData.BeatAction = iot_data.BeatAction;
|
|
|
|
+ iotData.beatReturn = 2; //NG
|
|
|
|
+ iotData.fault_codes = iot_data.fault_codes;
|
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iotData);
|
|
stopwatch2.Stop();
|
|
stopwatch2.Stop();
|
|
AddMessage_Station(stationNameStr, LogType.Info,
|
|
AddMessage_Station(stationNameStr, LogType.Info,
|
|
- stationNameStr + $"_[{a40EEVehicleCode}][{a50EEPartNo}]上传节拍失败!载具码不可为空;总用时" +
|
|
|
|
|
|
+ stationNameStr + $"_上传节拍失败!载具码不可为空;总用时" +
|
|
stopwatch1.ElapsedMilliseconds + "ms;调用Iot用时" + stopwatch2.ElapsedMilliseconds + "ms");
|
|
stopwatch1.ElapsedMilliseconds + "ms;调用Iot用时" + stopwatch2.ElapsedMilliseconds + "ms");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
short _result = 0;
|
|
short _result = 0;
|
|
- // 上传OEE
|
|
|
|
- (short, string) result = SaveOEEData(plcNo, stationNameStr, deviceOEE, a50EEPartNo, a40EEVehicleCode);
|
|
|
|
|
|
|
|
|
|
+ // 上传OEE
|
|
|
|
+ (short, string) result = SaveOEEData(plcNo, stationNameStr, deviceOEE, strProductBarcode, CarrierBarcode);
|
|
_result = result.Item1;
|
|
_result = result.Item1;
|
|
resultStr = result.Item2;
|
|
resultStr = result.Item2;
|
|
|
|
|
|
@@ -5171,17 +5401,29 @@ namespace MainForm
|
|
{
|
|
{
|
|
stopwatch2.Start();
|
|
stopwatch2.Start();
|
|
//写入PLC
|
|
//写入PLC
|
|
- iot_data.beatReturn = 1; //OK
|
|
|
|
- WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
|
|
|
|
- OnMessage(LogType.Info, $"PLC{plcNo}_{stationNameStr} 节拍{iot_data.BeatAction}上传IOT成功!上传结果:" + resultStr);
|
|
|
|
|
|
+ IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
+ iotData.machineState = iot_data.machineState;
|
|
|
|
+ iotData.work_type = iot_data.work_type;
|
|
|
|
+ iotData.testStatus = iot_data.testStatus;
|
|
|
|
+ iotData.BeatAction = iot_data.BeatAction;
|
|
|
|
+ iotData.beatReturn = 1;//OK
|
|
|
|
+ iotData.fault_codes = iot_data.fault_codes;
|
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iotData);
|
|
|
|
+ OnMessage(LogType.Info, $"PLC{plcNo}_{stationNameStr} 节拍{iotData.BeatAction}上传IOT成功!上传结果:" + resultStr);
|
|
stopwatch2.Stop();
|
|
stopwatch2.Stop();
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
stopwatch2.Start();
|
|
stopwatch2.Start();
|
|
//写入PLC
|
|
//写入PLC
|
|
- iot_data.beatReturn = 2; //NG
|
|
|
|
- WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
|
|
|
|
|
|
+ IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
+ iotData.machineState = iot_data.machineState;
|
|
|
|
+ iotData.work_type = iot_data.work_type;
|
|
|
|
+ iotData.testStatus = iot_data.testStatus;
|
|
|
|
+ iotData.BeatAction = iot_data.BeatAction;
|
|
|
|
+ iotData.beatReturn = 2; //NG
|
|
|
|
+ iotData.fault_codes = iot_data.fault_codes;
|
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iotData);
|
|
stopwatch2.Stop();
|
|
stopwatch2.Stop();
|
|
AddMessage_Station(stationNameStr, LogType.Error,
|
|
AddMessage_Station(stationNameStr, LogType.Error,
|
|
$"PLC{plcNo}_{stationNameStr} 节拍接口出错!错误信息:" + resultStr);
|
|
$"PLC{plcNo}_{stationNameStr} 节拍接口出错!错误信息:" + resultStr);
|
|
@@ -5198,7 +5440,13 @@ namespace MainForm
|
|
// MES_Flag
|
|
// MES_Flag
|
|
stopwatch2.Start();
|
|
stopwatch2.Start();
|
|
//写入PLC
|
|
//写入PLC
|
|
- iot_data.beatReturn = 2; //NG
|
|
|
|
|
|
+ IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
+ iotData.machineState = iot_data.machineState;
|
|
|
|
+ iotData.work_type = iot_data.work_type;
|
|
|
|
+ iotData.testStatus = iot_data.testStatus;
|
|
|
|
+ iotData.BeatAction = iot_data.BeatAction;
|
|
|
|
+ iotData.beatReturn = 2; //NG
|
|
|
|
+ iotData.fault_codes = iot_data.fault_codes;
|
|
WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
|
|
WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
|
|
stopwatch2.Stop();
|
|
stopwatch2.Stop();
|
|
}
|
|
}
|
|
@@ -5250,7 +5498,12 @@ namespace MainForm
|
|
UpdatePLCMonitor(1, plcNo, 0);
|
|
UpdatePLCMonitor(1, plcNo, 0);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ //弹出扫码框则停止循环
|
|
|
|
+ if (isNoStop)
|
|
|
|
+ {
|
|
|
|
+ Task.Delay(1000);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
if (FunsEip[plcNo].IsConnected) // 检查PLC是否已连接上
|
|
if (FunsEip[plcNo].IsConnected) // 检查PLC是否已连接上
|
|
{
|
|
{
|
|
Stopwatch stopwatch1 = new Stopwatch();
|
|
Stopwatch stopwatch1 = new Stopwatch();
|
|
@@ -5264,13 +5517,16 @@ namespace MainForm
|
|
// 一次性读取所有数据
|
|
// 一次性读取所有数据
|
|
result = FunsEip[plcNo]
|
|
result = FunsEip[plcNo]
|
|
.Read_SingleTag<OP60_MesData_t>(tagBaseName, 1, out stPLC_MesData, this); //读取单个结构体数据
|
|
.Read_SingleTag<OP60_MesData_t>(tagBaseName, 1, out stPLC_MesData, this); //读取单个结构体数据
|
|
|
|
+ //测试
|
|
|
|
+ stPLC_MesData.BarcodeSet.strCarrierBarcode = "A123456";
|
|
|
|
+ stPLC_MesData.mesCommFrmPLC.cmd = 1;
|
|
|
|
+
|
|
if (result.Item1 != 0)
|
|
if (result.Item1 != 0)
|
|
{
|
|
{
|
|
//richTextBox1.AppendText("\n" + strRet);
|
|
//richTextBox1.AppendText("\n" + strRet);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- //richTextBox1.AppendText("\n" + "读取成功");
|
|
|
|
//richTextBox1.AppendText("\n" + "读取成功");
|
|
//richTextBox1.AppendText("\n" + "读取成功");
|
|
int xmDeviceStateInt = stPLC_MesData.iotData.machineState;
|
|
int xmDeviceStateInt = stPLC_MesData.iotData.machineState;
|
|
xmDeviceStateData.left = (xmDeviceStateInt < 0 || xmDeviceStateInt > 7)
|
|
xmDeviceStateData.left = (xmDeviceStateInt < 0 || xmDeviceStateInt > 7)
|
|
@@ -5447,6 +5703,8 @@ namespace MainForm
|
|
//strCarrierBarcode = "N801A-003";
|
|
//strCarrierBarcode = "N801A-003";
|
|
//载具码验证产品码
|
|
//载具码验证产品码
|
|
string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(strCarrierBarcode);
|
|
string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(strCarrierBarcode);
|
|
|
|
+ string strPCBBarcode = SQLHelper.GetPCBBarcodeByCarrierCode(strCarrierBarcode);
|
|
|
|
+
|
|
if (string.IsNullOrEmpty(strProductBarcode))
|
|
if (string.IsNullOrEmpty(strProductBarcode))
|
|
{
|
|
{
|
|
AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
|
|
AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
|
|
@@ -5461,11 +5719,13 @@ namespace MainForm
|
|
{
|
|
{
|
|
dialog._CarrierBarcode = strCarrierBarcode;
|
|
dialog._CarrierBarcode = strCarrierBarcode;
|
|
dialog._ProductBarcode = sn;
|
|
dialog._ProductBarcode = sn;
|
|
|
|
+ dialog._PCBBarcode = strPCBBarcode;
|
|
var rs = dialog.ShowDialog();
|
|
var rs = dialog.ShowDialog();
|
|
if (rs == DialogResult.OK)
|
|
if (rs == DialogResult.OK)
|
|
{
|
|
{
|
|
AddMessage(LogType.Info, $"扫码校验通过,载具码:{strCarrierBarcode};产品码:{sn};产品码:{sn}");
|
|
AddMessage(LogType.Info, $"扫码校验通过,载具码:{strCarrierBarcode};产品码:{sn};产品码:{sn}");
|
|
OpenDailogFalg = false;//关闭扫码
|
|
OpenDailogFalg = false;//关闭扫码
|
|
|
|
+ isNoStop = false;
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
ProgressState = false;
|
|
ProgressState = false;
|
|
@@ -10436,8 +10696,14 @@ namespace MainForm
|
|
{
|
|
{
|
|
stopwatch2.Start();
|
|
stopwatch2.Start();
|
|
//写入PLC
|
|
//写入PLC
|
|
- iot_data.beatReturn = 2; //NG
|
|
|
|
- WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
|
|
|
|
|
|
+ IoT_DataSet_t iotData = new IoT_DataSet_t();
|
|
|
|
+ iotData.machineState = iot_data.machineState;
|
|
|
|
+ iotData.work_type = iot_data.work_type;
|
|
|
|
+ iotData.testStatus = iot_data.testStatus;
|
|
|
|
+ iotData.BeatAction = iot_data.BeatAction;
|
|
|
|
+ iotData.beatReturn = 2; //NG
|
|
|
|
+ iotData.fault_codes = iot_data.fault_codes;
|
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iotData);
|
|
stopwatch2.Stop();
|
|
stopwatch2.Stop();
|
|
AddMessage(LogType.Info,
|
|
AddMessage(LogType.Info,
|
|
stationNameStr + $"_节拍接口-- 设备上传了未识别的节拍类型【{oEEType}】请检查;总用时" + stopwatch1.ElapsedMilliseconds +
|
|
stationNameStr + $"_节拍接口-- 设备上传了未识别的节拍类型【{oEEType}】请检查;总用时" + stopwatch1.ElapsedMilliseconds +
|
|
@@ -10457,7 +10723,7 @@ namespace MainForm
|
|
iotData.BeatAction = iot_data.BeatAction;
|
|
iotData.BeatAction = iot_data.BeatAction;
|
|
iotData.beatReturn = 2; //NG
|
|
iotData.beatReturn = 2; //NG
|
|
iotData.fault_codes = iot_data.fault_codes;
|
|
iotData.fault_codes = iot_data.fault_codes;
|
|
- WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
|
|
|
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iotData);
|
|
stopwatch2.Stop();
|
|
stopwatch2.Stop();
|
|
AddMessage_Station(stationNameStr, LogType.Info,
|
|
AddMessage_Station(stationNameStr, LogType.Info,
|
|
stationNameStr + $"_[{CarrierBarcode}][{strProductBarcode}]上传节拍失败!物料码与载具SN不可都为空;总用时" +
|
|
stationNameStr + $"_[{CarrierBarcode}][{strProductBarcode}]上传节拍失败!物料码与载具SN不可都为空;总用时" +
|
|
@@ -10475,7 +10741,7 @@ namespace MainForm
|
|
iotData.BeatAction = iot_data.BeatAction;
|
|
iotData.BeatAction = iot_data.BeatAction;
|
|
iotData.beatReturn = 2; //NG
|
|
iotData.beatReturn = 2; //NG
|
|
iotData.fault_codes = iot_data.fault_codes;
|
|
iotData.fault_codes = iot_data.fault_codes;
|
|
- WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
|
|
|
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iotData);
|
|
stopwatch2.Stop();
|
|
stopwatch2.Stop();
|
|
AddMessage_Station(stationNameStr, LogType.Info,
|
|
AddMessage_Station(stationNameStr, LogType.Info,
|
|
stationNameStr + $"_[{CarrierBarcode}]上传节拍失败!物料码不可为空;总用时" +
|
|
stationNameStr + $"_[{CarrierBarcode}]上传节拍失败!物料码不可为空;总用时" +
|
|
@@ -10493,7 +10759,7 @@ namespace MainForm
|
|
iotData.BeatAction = iot_data.BeatAction;
|
|
iotData.BeatAction = iot_data.BeatAction;
|
|
iotData.beatReturn = 2; //NG
|
|
iotData.beatReturn = 2; //NG
|
|
iotData.fault_codes = iot_data.fault_codes;
|
|
iotData.fault_codes = iot_data.fault_codes;
|
|
- WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
|
|
|
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iotData);
|
|
stopwatch2.Stop();
|
|
stopwatch2.Stop();
|
|
AddMessage_Station(stationNameStr, LogType.Info,
|
|
AddMessage_Station(stationNameStr, LogType.Info,
|
|
stationNameStr + $"_上传节拍失败!载具码不可为空;总用时" +
|
|
stationNameStr + $"_上传节拍失败!载具码不可为空;总用时" +
|
|
@@ -10519,8 +10785,8 @@ namespace MainForm
|
|
iotData.BeatAction = iot_data.BeatAction;
|
|
iotData.BeatAction = iot_data.BeatAction;
|
|
iotData.beatReturn = 1;//OK
|
|
iotData.beatReturn = 1;//OK
|
|
iotData.fault_codes = iot_data.fault_codes;
|
|
iotData.fault_codes = iot_data.fault_codes;
|
|
- WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
|
|
|
|
- OnMessage(LogType.Info, $"PLC{plcNo}_{stationNameStr} 节拍{iot_data.BeatAction}上传IOT成功!上传结果:" + resultStr);
|
|
|
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iotData);
|
|
|
|
+ OnMessage(LogType.Info, $"PLC{plcNo}_{stationNameStr} 节拍{iotData.BeatAction}上传IOT成功!上传结果:" + resultStr);
|
|
stopwatch2.Stop();
|
|
stopwatch2.Stop();
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -10534,7 +10800,7 @@ namespace MainForm
|
|
iotData.BeatAction = iot_data.BeatAction;
|
|
iotData.BeatAction = iot_data.BeatAction;
|
|
iotData.beatReturn = 2; //NG
|
|
iotData.beatReturn = 2; //NG
|
|
iotData.fault_codes = iot_data.fault_codes;
|
|
iotData.fault_codes = iot_data.fault_codes;
|
|
- WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
|
|
|
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iotData);
|
|
stopwatch2.Stop();
|
|
stopwatch2.Stop();
|
|
AddMessage_Station(stationNameStr, LogType.Error,
|
|
AddMessage_Station(stationNameStr, LogType.Error,
|
|
$"PLC{plcNo}_{stationNameStr} 节拍接口出错!错误信息:" + resultStr);
|
|
$"PLC{plcNo}_{stationNameStr} 节拍接口出错!错误信息:" + resultStr);
|