|
@@ -153,10 +153,10 @@ namespace MainForm
|
|
private int test_item_num = 0;//iot 过站数据序号
|
|
private int test_item_num = 0;//iot 过站数据序号
|
|
private string uuid = "";
|
|
private string uuid = "";
|
|
private bool inpass = false;//保存进站测试状态
|
|
private bool inpass = false;//保存进站测试状态
|
|
-
|
|
|
|
- public string _deviceCode="";//装备编码
|
|
|
|
- public string _stationCode="";//工站ID
|
|
|
|
- public string _workstation="";//工位编码
|
|
|
|
|
|
+
|
|
|
|
+ public static XiaoMiParm xiaomiParm=new XiaoMiParm();
|
|
|
|
+ //记录上传附件的信息
|
|
|
|
+ public FileUpload_FileData fileUploadData =new FileUpload_FileData ();
|
|
|
|
|
|
#endregion 变量
|
|
#endregion 变量
|
|
|
|
|
|
@@ -189,8 +189,6 @@ namespace MainForm
|
|
//组建plc对象字典
|
|
//组建plc对象字典
|
|
//plc1Alarm = new ModbusClientHelper(GlobalContext.Machine1Address, GlobalContext.MachinePort);
|
|
//plc1Alarm = new ModbusClientHelper(GlobalContext.Machine1Address, GlobalContext.MachinePort);
|
|
//plc1Alarm = new Inovance_EIP(GlobalContext.PCAddress, GlobalContext.Machine1Address);
|
|
//plc1Alarm = new Inovance_EIP(GlobalContext.PCAddress, GlobalContext.Machine1Address);
|
|
- //上传操作记录
|
|
|
|
- operateToIot("startup","开启");
|
|
|
|
|
|
|
|
if (GlobalContext.IsUsePLC1)
|
|
if (GlobalContext.IsUsePLC1)
|
|
{
|
|
{
|
|
@@ -266,25 +264,6 @@ namespace MainForm
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /*
|
|
|
|
- //plc1Alarm.Connect();
|
|
|
|
- foreach (ModbusClientHelper modbusClient in Funs.Values)
|
|
|
|
- {
|
|
|
|
- if (modbusClient != null)
|
|
|
|
- {
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- modbusClient.Connect();
|
|
|
|
- }
|
|
|
|
- catch (Exception ex)
|
|
|
|
- {
|
|
|
|
- MessageBox.Show($"PLC[{modbusClient.IPAddress}:{modbusClient.Port}]连接失败!失败信息:" + ex.Message,
|
|
|
|
- "PLC连接提示", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
// 采集任务
|
|
// 采集任务
|
|
Task TaskReadAlarm = new Task(ReadAlarmAllPLC); // 线程-获取线体报警数据
|
|
Task TaskReadAlarm = new Task(ReadAlarmAllPLC); // 线程-获取线体报警数据
|
|
List<Task> TaskReadProcess = new List<Task>(); // 线程-触发点位(PLC)的线程
|
|
List<Task> TaskReadProcess = new List<Task>(); // 线程-触发点位(PLC)的线程
|
|
@@ -313,21 +292,6 @@ namespace MainForm
|
|
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- // 开启边线MES(绑定/查询数据)
|
|
|
|
- //int mesRoute = XiaomiMES_RouteCommunication.Init();
|
|
|
|
- //if (mesRoute == 0)
|
|
|
|
- //{
|
|
|
|
- // //picMESStatus.Image = imageListState.Images[1];
|
|
|
|
- // //GlobalContext.MESIsConnect = true;
|
|
|
|
- // AddMessage(LogType.Info, "小米MES边线初始连接成功!");
|
|
|
|
- //}
|
|
|
|
- //else
|
|
|
|
- //{
|
|
|
|
- // //picMESStatus.Image = imageListState.Images[0];
|
|
|
|
- // //GlobalContext.MESIsConnect = false;
|
|
|
|
- // AddMessage(LogType.Info, $"小米MES边线初始连接失败!");
|
|
|
|
- //}
|
|
|
|
-
|
|
|
|
// 开启MES(Http)
|
|
// 开启MES(Http)
|
|
if (GlobalContext.IsUseMES)
|
|
if (GlobalContext.IsUseMES)
|
|
{
|
|
{
|
|
@@ -382,14 +346,14 @@ namespace MainForm
|
|
{
|
|
{
|
|
param.parameter.equipment.deviceCode = GlobalContext.S1_device_code; // 装备编码
|
|
param.parameter.equipment.deviceCode = GlobalContext.S1_device_code; // 装备编码
|
|
param.parameter.equipment.stationCode = GlobalContext.S1_station; // ⼯位Id
|
|
param.parameter.equipment.stationCode = GlobalContext.S1_station; // ⼯位Id
|
|
- _workstation= GlobalContext.S1_work_station;//工站
|
|
|
|
|
|
+ xiaomiParm .workstation= GlobalContext.S1_work_station;//工站
|
|
}
|
|
}
|
|
|
|
|
|
if (GlobalContext.IsUsePLC2)
|
|
if (GlobalContext.IsUsePLC2)
|
|
{
|
|
{
|
|
param.parameter.equipment.deviceCode = GlobalContext.S2_device_code; // 装备编码
|
|
param.parameter.equipment.deviceCode = GlobalContext.S2_device_code; // 装备编码
|
|
param.parameter.equipment.stationCode = GlobalContext.S2_station; // ⼯位Id
|
|
param.parameter.equipment.stationCode = GlobalContext.S2_station; // ⼯位Id
|
|
- _workstation= GlobalContext.S2_work_station;//工站
|
|
|
|
|
|
+ xiaomiParm.workstation = GlobalContext.S2_work_station;//工站
|
|
}
|
|
}
|
|
|
|
|
|
if (GlobalContext.IsUsePLC3)
|
|
if (GlobalContext.IsUsePLC3)
|
|
@@ -402,21 +366,21 @@ namespace MainForm
|
|
{
|
|
{
|
|
param.parameter.equipment.deviceCode = GlobalContext.s4_device_code; // 装备编码
|
|
param.parameter.equipment.deviceCode = GlobalContext.s4_device_code; // 装备编码
|
|
param.parameter.equipment.stationCode = GlobalContext.s4_station; // ⼯位Id
|
|
param.parameter.equipment.stationCode = GlobalContext.s4_station; // ⼯位Id
|
|
- _workstation= GlobalContext.s4_work_station;//工站
|
|
|
|
|
|
+ xiaomiParm.workstation = GlobalContext.s4_work_station;//工站
|
|
}
|
|
}
|
|
|
|
|
|
if (GlobalContext.IsUsePLC5)
|
|
if (GlobalContext.IsUsePLC5)
|
|
{
|
|
{
|
|
param.parameter.equipment.deviceCode = GlobalContext.s5_device_code; // 装备编码
|
|
param.parameter.equipment.deviceCode = GlobalContext.s5_device_code; // 装备编码
|
|
param.parameter.equipment.stationCode = GlobalContext.s5_station; // ⼯位Id
|
|
param.parameter.equipment.stationCode = GlobalContext.s5_station; // ⼯位Id
|
|
- _workstation= GlobalContext.s5_work_station;//工站
|
|
|
|
|
|
+ xiaomiParm.workstation = GlobalContext.s5_work_station;//工站
|
|
}
|
|
}
|
|
|
|
|
|
if (GlobalContext.IsUsePLC6)
|
|
if (GlobalContext.IsUsePLC6)
|
|
{
|
|
{
|
|
param.parameter.equipment.deviceCode = GlobalContext.s6_device_code; // 装备编码
|
|
param.parameter.equipment.deviceCode = GlobalContext.s6_device_code; // 装备编码
|
|
param.parameter.equipment.stationCode = GlobalContext.s6_station; // ⼯位Id
|
|
param.parameter.equipment.stationCode = GlobalContext.s6_station; // ⼯位Id
|
|
- _workstation= GlobalContext.s6_work_station;//工站
|
|
|
|
|
|
+ xiaomiParm.workstation = GlobalContext.s6_work_station;//工站
|
|
}
|
|
}
|
|
|
|
|
|
if (GlobalContext.IsUsePLC7)
|
|
if (GlobalContext.IsUsePLC7)
|
|
@@ -429,14 +393,14 @@ namespace MainForm
|
|
{
|
|
{
|
|
param.parameter.equipment.deviceCode = GlobalContext.s8_device_code; // 装备编码
|
|
param.parameter.equipment.deviceCode = GlobalContext.s8_device_code; // 装备编码
|
|
param.parameter.equipment.stationCode = GlobalContext.s8_station; // ⼯位Id
|
|
param.parameter.equipment.stationCode = GlobalContext.s8_station; // ⼯位Id
|
|
- _workstation= GlobalContext.s8_work_station;//工站
|
|
|
|
|
|
+ xiaomiParm.workstation = GlobalContext.s8_work_station;//工站
|
|
}
|
|
}
|
|
|
|
|
|
if (GlobalContext.IsUsePLC9)
|
|
if (GlobalContext.IsUsePLC9)
|
|
{
|
|
{
|
|
param.parameter.equipment.deviceCode = GlobalContext.s9_device_code; // 装备编码
|
|
param.parameter.equipment.deviceCode = GlobalContext.s9_device_code; // 装备编码
|
|
param.parameter.equipment.stationCode = GlobalContext.s9_station; // ⼯位Id
|
|
param.parameter.equipment.stationCode = GlobalContext.s9_station; // ⼯位Id
|
|
- _workstation= GlobalContext.s9_work_station;//工站
|
|
|
|
|
|
+ xiaomiParm.workstation = GlobalContext.s9_work_station;//工站
|
|
}
|
|
}
|
|
|
|
|
|
param.parameter.equipment.project = GlobalContext.Project_Code;
|
|
param.parameter.equipment.project = GlobalContext.Project_Code;
|
|
@@ -447,8 +411,8 @@ namespace MainForm
|
|
|
|
|
|
XiaomiMqttClient_Extend.ParameterConfig(param);
|
|
XiaomiMqttClient_Extend.ParameterConfig(param);
|
|
//保存全局变量
|
|
//保存全局变量
|
|
- _stationCode = param.parameter.equipment.deviceCode;
|
|
|
|
- _deviceCode = param.parameter.equipment.stationCode;
|
|
|
|
|
|
+ xiaomiParm.stationCode = param.parameter.equipment.deviceCode;
|
|
|
|
+ xiaomiParm.deviceCode = param.parameter.equipment.stationCode;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -544,7 +508,8 @@ namespace MainForm
|
|
state_r.Visible = true;
|
|
state_r.Visible = true;
|
|
lblDeviceStates2.Visible = true;
|
|
lblDeviceStates2.Visible = true;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ //上传操作记录
|
|
|
|
+ operateToIot("startup", "开启");
|
|
AddMessage(LogType.Info, "程序初始化完成");
|
|
AddMessage(LogType.Info, "程序初始化完成");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
@@ -779,7 +744,6 @@ namespace MainForm
|
|
/// 采集到的设备状态
|
|
/// 采集到的设备状态
|
|
/// </summary>
|
|
/// </summary>
|
|
private string _DeviceStates = "未知状态";
|
|
private string _DeviceStates = "未知状态";
|
|
-
|
|
|
|
private string _DeviceStates_Old = "未知状态";
|
|
private string _DeviceStates_Old = "未知状态";
|
|
|
|
|
|
private string _DeviceStates2 = "未知状态";
|
|
private string _DeviceStates2 = "未知状态";
|
|
@@ -1641,9 +1605,9 @@ namespace MainForm
|
|
request.factory_code = GlobalContext.Factory_Code; // ⼯⼚Id
|
|
request.factory_code = GlobalContext.Factory_Code; // ⼯⼚Id
|
|
request.process_section_code = GlobalContext.Process_Section_Code; // ⼯段编码
|
|
request.process_section_code = GlobalContext.Process_Section_Code; // ⼯段编码
|
|
request.line_code = GlobalContext.LineCode; // 线体编码
|
|
request.line_code = GlobalContext.LineCode; // 线体编码
|
|
- request.work_station = _workstation; // ⼯站ID
|
|
|
|
- request.device_code = _deviceCode; // 装备编码
|
|
|
|
- request.station = _stationCode;
|
|
|
|
|
|
+ request.work_station = xiaomiParm.workstation; // ⼯站ID
|
|
|
|
+ request.device_code = xiaomiParm.deviceCode; // 装备编码
|
|
|
|
+ request.station = xiaomiParm.stationCode;
|
|
request.process_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); // 节拍发⽣时间(2022-06-01 14:27:57.283)
|
|
request.process_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); // 节拍发⽣时间(2022-06-01 14:27:57.283)
|
|
request.slot = slot; // 槽位编码
|
|
request.slot = slot; // 槽位编码
|
|
request.sn = sn; // 产品SN
|
|
request.sn = sn; // 产品SN
|
|
@@ -1891,9 +1855,9 @@ namespace MainForm
|
|
request.factory_code = GlobalContext.Factory_Code; // ⼯⼚Id
|
|
request.factory_code = GlobalContext.Factory_Code; // ⼯⼚Id
|
|
request.process_section_code = GlobalContext.Process_Section_Code; // ⼯段编码
|
|
request.process_section_code = GlobalContext.Process_Section_Code; // ⼯段编码
|
|
request.line_code = GlobalContext.LineCode; // 线体编码
|
|
request.line_code = GlobalContext.LineCode; // 线体编码
|
|
- request.work_station = _workstation; // ⼯站ID
|
|
|
|
- request.device_code = _deviceCode; // 装备编码
|
|
|
|
- request.station = _stationCode;
|
|
|
|
|
|
+ request.work_station = xiaomiParm.workstation; // ⼯站ID
|
|
|
|
+ request.device_code = xiaomiParm.deviceCode; // 装备编码
|
|
|
|
+ request.station = xiaomiParm.stationCode;
|
|
request.process_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); // 节拍发⽣时间(2022-06-01 14:27:57.283)
|
|
request.process_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); // 节拍发⽣时间(2022-06-01 14:27:57.283)
|
|
request.slot = slot; // 槽位编码
|
|
request.slot = slot; // 槽位编码
|
|
request.sn = sn; // 产品SN
|
|
request.sn = sn; // 产品SN
|
|
@@ -2278,7 +2242,7 @@ namespace MainForm
|
|
isCollectingFlagRight = false;
|
|
isCollectingFlagRight = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 上传文件
|
|
/// 上传文件
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -2286,12 +2250,22 @@ namespace MainForm
|
|
/// <param name="stationCode">工站编号</param>
|
|
/// <param name="stationCode">工站编号</param>
|
|
/// <param name="stationName">工站名称</param>
|
|
/// <param name="stationName">工站名称</param>
|
|
/// <param name="path">文件路径</param>
|
|
/// <param name="path">文件路径</param>
|
|
- public async Task<(int, string)> SaveDBbyFileInfo(BarcodeSet_t BarcodeSet, string stationCode, string stationName,string path)
|
|
|
|
|
|
+ public async Task<(int, string)> SaveDBbyFileInfo(BarcodeSet_t BarcodeSet, string stationCode, string stationName,int pass,string path, string guid="")
|
|
{
|
|
{
|
|
string sql, filename = "";
|
|
string sql, filename = "";
|
|
- Guid guid;
|
|
|
|
int result = 0;
|
|
int result = 0;
|
|
var formData = new MultipartFormDataContent();
|
|
var formData = new MultipartFormDataContent();
|
|
|
|
+ string msg="";
|
|
|
|
+ string file_category = "IMAGE"; //IMAGE 、TEXT 、UNKNOWN 这里上传图片
|
|
|
|
+ string file_type = "IMAGE";
|
|
|
|
+ string project = GlobalContext.ProgramName;
|
|
|
|
+ string run_mode = GlobalContext.run_mode;
|
|
|
|
+ string product_mode = GlobalContext.product_mode;
|
|
|
|
+ string pass_result = (pass == 1 ? "PASS" : "Fail");
|
|
|
|
+ string device_code = xiaomiParm.deviceCode;
|
|
|
|
+ string sn= BarcodeSet.strProductBarcode;
|
|
|
|
+ string staion_id= xiaomiParm.stationCode;
|
|
|
|
+ string bucket = $"{file_category}/{file_type}/{project}/{product_mode}/{run_mode}/{pass_result}/{device_code}/{sn}/{staion_id}";
|
|
|
|
|
|
// 获取所有图片文件
|
|
// 获取所有图片文件
|
|
List<string> imageFiles = GetAllImageFiles(path);
|
|
List<string> imageFiles = GetAllImageFiles(path);
|
|
@@ -2301,18 +2275,22 @@ namespace MainForm
|
|
{
|
|
{
|
|
foreach (string imageFile in imageFiles)
|
|
foreach (string imageFile in imageFiles)
|
|
{
|
|
{
|
|
- guid = Guid.NewGuid();
|
|
|
|
|
|
+ if (guid=="")
|
|
|
|
+ {
|
|
|
|
+ guid = Guid.NewGuid().ToString();
|
|
|
|
+ }
|
|
filename = Path.GetFileName(imageFile);
|
|
filename = Path.GetFileName(imageFile);
|
|
|
|
+
|
|
sql = string.Format("INSERT INTO [dbo].[DataFiles](stationCode,stationName,CarrierBarcode,ProductBarcode,bucket,fileName,fileContext,uuid,fileUrl,status,submitTime,createTime) " +
|
|
sql = string.Format("INSERT INTO [dbo].[DataFiles](stationCode,stationName,CarrierBarcode,ProductBarcode,bucket,fileName,fileContext,uuid,fileUrl,status,submitTime,createTime) " +
|
|
"VALUES('{0}','{1}','{2}' ,'{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')"
|
|
"VALUES('{0}','{1}','{2}' ,'{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')"
|
|
, stationCode
|
|
, stationCode
|
|
, stationName
|
|
, stationName
|
|
, BarcodeSet.strCarrierBarcode
|
|
, BarcodeSet.strCarrierBarcode
|
|
, BarcodeSet.strProductBarcode
|
|
, BarcodeSet.strProductBarcode
|
|
- , "/mesCommToPC/pic/left"
|
|
|
|
|
|
+ , bucket
|
|
, filename
|
|
, filename
|
|
, ""
|
|
, ""
|
|
- , guid.ToString()
|
|
|
|
|
|
+ , guid
|
|
, ""
|
|
, ""
|
|
, 0
|
|
, 0
|
|
, ""
|
|
, ""
|
|
@@ -2321,9 +2299,6 @@ namespace MainForm
|
|
string ret = SQLHelper_New.ExecuteNonQuery(sql, null);
|
|
string ret = SQLHelper_New.ExecuteNonQuery(sql, null);
|
|
|
|
|
|
FileUpload_X5 fileUpload_X5 = new FileUpload_X5();
|
|
FileUpload_X5 fileUpload_X5 = new FileUpload_X5();
|
|
- string bucket = string.Empty;
|
|
|
|
- //bucket = "IMAGE/IMAGE/N3/debug/online/PASS/M0002PA-0001/P320N000006B/382f55e9-c2bb";
|
|
|
|
- bucket = "/mesCommToPC/pic/left";
|
|
|
|
fileUpload_X5.bucket = bucket;
|
|
fileUpload_X5.bucket = bucket;
|
|
fileUpload_X5.name = filename;
|
|
fileUpload_X5.name = filename;
|
|
fileUpload_X5.uuid = guid.ToString();
|
|
fileUpload_X5.uuid = guid.ToString();
|
|
@@ -2335,41 +2310,32 @@ namespace MainForm
|
|
fileUpload_X5.informMqtt = true;
|
|
fileUpload_X5.informMqtt = true;
|
|
|
|
|
|
FileMqttPayload fileMqttPayload = new FileMqttPayload();
|
|
FileMqttPayload fileMqttPayload = new FileMqttPayload();
|
|
- //fileMqttPayload.factory = "";
|
|
|
|
- //fileMqttPayload.project_name = "";
|
|
|
|
- //fileMqttPayload.product_mode = "";
|
|
|
|
- //fileMqttPayload.line_no = "";
|
|
|
|
- //fileMqttPayload.work_station_no = "";
|
|
|
|
- //fileMqttPayload.equipment_no = "";
|
|
|
|
- //fileMqttPayload.station_no = "";
|
|
|
|
- //fileMqttPayload.file_id = "";
|
|
|
|
- //fileMqttPayload.file_name = "";
|
|
|
|
- //fileMqttPayload.sn = "";
|
|
|
|
|
|
+ fileMqttPayload.factory = GlobalContext.Factory_Code;
|
|
|
|
+ fileMqttPayload.project_name = GlobalContext.Project_Code;
|
|
|
|
+ fileMqttPayload.product_mode = GlobalContext.product_mode;
|
|
|
|
+ fileMqttPayload.line_no = GlobalContext.LineCode;
|
|
|
|
+ fileMqttPayload.work_station_no = xiaomiParm.workstation;
|
|
|
|
+ fileMqttPayload.equipment_no = xiaomiParm.deviceCode;
|
|
|
|
+ fileMqttPayload.station_no = xiaomiParm.stationCode;
|
|
|
|
+ fileMqttPayload.file_id = guid;
|
|
|
|
+ fileMqttPayload.file_name = filename;
|
|
|
|
+ fileMqttPayload.sn = BarcodeSet.strProductBarcode;
|
|
//fileMqttPayload.opt_time = "";
|
|
//fileMqttPayload.opt_time = "";
|
|
//fileMqttPayload.file_type = "";
|
|
//fileMqttPayload.file_type = "";
|
|
//fileMqttPayload.file_category = "";
|
|
//fileMqttPayload.file_category = "";
|
|
//fileMqttPayload.tag = "";
|
|
//fileMqttPayload.tag = "";
|
|
- //fileMqttPayload.pass_station_id = "";
|
|
|
|
-
|
|
|
|
- //FileUpload_X5 fileUpload_X5 = new FileUpload_X5();
|
|
|
|
- //FileMqttPayload fileMqttPayload = new FileMqttPayload();
|
|
|
|
- //fileUpload_X5.bucket = "IMAGE/IMAGE/N3/debug/online/PASS/M0002PA-0001/P320N000006B/382f55e9-c2bb";
|
|
|
|
- //fileUpload_X5.name = "test";
|
|
|
|
- //fileUpload_X5.md5 = "";
|
|
|
|
- //fileUpload_X5.uploadCloud = true;
|
|
|
|
- //fileUpload_X5.informMqtt = true;
|
|
|
|
|
|
+ fileMqttPayload.reference_info.pass_station_id=uuid;
|
|
|
|
|
|
var fileresult = XiaomiMESHttp_UpLoadFile.FileUoladToMes(imageFile, fileUpload_X5, fileMqttPayload);
|
|
var fileresult = XiaomiMESHttp_UpLoadFile.FileUoladToMes(imageFile, fileUpload_X5, fileMqttPayload);
|
|
|
|
+
|
|
if (fileresult.Result.Item1 == 0)
|
|
if (fileresult.Result.Item1 == 0)
|
|
{
|
|
{
|
|
- return (1, fileresult.Result.Item2);
|
|
|
|
|
|
+ sql = string.Format("UPDATE [dbo].[DataFiles] SET status='{0}' WHERE uuid='{1}'", 1, guid);
|
|
|
|
+ string retnew = SQLHelper_New.ExecuteNonQuery(sql, null);
|
|
}
|
|
}
|
|
-
|
|
|
|
- sql = string.Format("UPDATE [dbo].[DataFiles] SET status='{0}' WHERE uuid='{1}'", 1, guid);
|
|
|
|
- string retnew = SQLHelper_New.ExecuteNonQuery(sql, null);
|
|
|
|
- return fileresult.Result;
|
|
|
|
|
|
+ msg = msg + $"{fileresult.Result.Item2}\r\n";
|
|
}
|
|
}
|
|
- return (1, "程序错误!");
|
|
|
|
|
|
+ return (1, msg);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -2581,111 +2547,107 @@ namespace MainForm
|
|
string binaryString = "";
|
|
string binaryString = "";
|
|
bool isNoNewAlarm = false;//是否有新的报警
|
|
bool isNoNewAlarm = false;//是否有新的报警
|
|
|
|
|
|
-
|
|
|
|
- if (FaultData.Length > 0)
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- foreach (var item in FaultData)
|
|
|
|
- {
|
|
|
|
- isNoAlarm = item > 0 ? true : false;
|
|
|
|
- }
|
|
|
|
- if (!FaultData.SequenceEqual(_FaultDatas_Old))
|
|
|
|
- {
|
|
|
|
- isNoNewAlarm = true;
|
|
|
|
- isNeedUpdUI = true;
|
|
|
|
- }
|
|
|
|
- if (FaultData.Length > 0 && isNoAlarm && isNoNewAlarm)
|
|
|
|
- {
|
|
|
|
- //解析报警信息,分析当前报警在字典中的定位
|
|
|
|
- for (int i = 0; i <= FaultData.Length - 1; i++)
|
|
|
|
|
|
+ if (FaultData.Length > 0) {
|
|
|
|
+ foreach (var item in FaultData)
|
|
{
|
|
{
|
|
- var num = 0;
|
|
|
|
- if (FaultData[i] > 0)
|
|
|
|
|
|
+ isNoAlarm = item > 0 ? true : false;
|
|
|
|
+ }
|
|
|
|
+ if (!FaultData.SequenceEqual(_FaultDatas_Old))
|
|
|
|
+ {
|
|
|
|
+ isNoNewAlarm = true;
|
|
|
|
+ isNeedUpdUI = true;
|
|
|
|
+ }
|
|
|
|
+ if (FaultData.Length > 0 && isNoAlarm && isNoNewAlarm)
|
|
|
|
+ {
|
|
|
|
+ //解析报警信息,分析当前报警在字典中的定位
|
|
|
|
+ for (int i = 0; i <= FaultData.Length - 1; i++)
|
|
{
|
|
{
|
|
- //转换二进制
|
|
|
|
- binaryString = Convert.ToString(FaultData[i], 2);
|
|
|
|
- for (int j = binaryString.Length - 1; j >= 0; j--)
|
|
|
|
|
|
+ var num = 0;
|
|
|
|
+ if (FaultData[i] > 0)
|
|
{
|
|
{
|
|
- num++;
|
|
|
|
- char s = binaryString[j];
|
|
|
|
- if (binaryString[j] == '1')
|
|
|
|
|
|
+ //转换二进制
|
|
|
|
+ binaryString = Convert.ToString(FaultData[i], 2);
|
|
|
|
+ for (int j = binaryString.Length - 1; j >= 0; j--)
|
|
{
|
|
{
|
|
- //记录1的位置
|
|
|
|
- AlarmIndexList.Add((i, num - 1));
|
|
|
|
|
|
+ num++;
|
|
|
|
+ char s = binaryString[j];
|
|
|
|
+ if (binaryString[j] == '1')
|
|
|
|
+ {
|
|
|
|
+ //记录1的位置
|
|
|
|
+ AlarmIndexList.Add((i, num - 1));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- // 同步“设备报警信息”到“设备报警临时字典DicAlarms_Cur”
|
|
|
|
- var dicAlarms_Cur_PLC1 = DicAlarms_Cur[GlobalContext.IsUseStationName];
|
|
|
|
- foreach ((int index, int row) in AlarmIndexList)
|
|
|
|
- {
|
|
|
|
- var tempDic = dicAlarms_Cur_PLC1.Where(x => x.group_index == index).ToList();
|
|
|
|
- for (int i = 0; i < tempDic.Count - 1; i++) // 读取
|
|
|
|
|
|
+ // 同步“设备报警信息”到“设备报警临时字典DicAlarms_Cur”
|
|
|
|
+ var dicAlarms_Cur_PLC1 = DicAlarms_Cur[GlobalContext.IsUseStationName];
|
|
|
|
+ foreach ((int index, int row) in AlarmIndexList)
|
|
{
|
|
{
|
|
- //若报警字典第[group_index]个数据,第[i]行与AlarmIndexList中的定位匹配,则添加进对应行的报警数据
|
|
|
|
- if (tempDic[i].group_index == index && i == row)
|
|
|
|
|
|
+ var tempDic = dicAlarms_Cur_PLC1.Where(x => x.group_index == index).ToList();
|
|
|
|
+ for (int i = 0; i < tempDic.Count - 1; i++) // 读取
|
|
{
|
|
{
|
|
- dicAlarms_Cur_PLC1.Where(x => x.group_index == index).ToList()[row].报警数据 = new AlarmData()
|
|
|
|
|
|
+ //若报警字典第[group_index]个数据,第[i]行与AlarmIndexList中的定位匹配,则添加进对应行的报警数据
|
|
|
|
+ if (tempDic[i].group_index == index && i == row)
|
|
{
|
|
{
|
|
- GUID = Guid.NewGuid().ToString(),
|
|
|
|
- LineName = GlobalContext.IsUseStationName, // 工站
|
|
|
|
- PlcStation = tempDic[i].plcName, // 工站全称;[S1]
|
|
|
|
- Type1 = tempDic[i].type1, // 故障层级1
|
|
|
|
- Type2 = tempDic[i].type2, // 故障层级2
|
|
|
|
- Type3 = tempDic[i].type3, // 故障层级3
|
|
|
|
- Type4 = tempDic[i].type4, // 故障层级4
|
|
|
|
- AlarmType = tempDic[i].fault_code, // 报警类型
|
|
|
|
- AlarmDesc = tempDic[i].fault_name, // 报警内容
|
|
|
|
- StartTime = dtNow // 开始时间
|
|
|
|
- };
|
|
|
|
- // 传输到页面
|
|
|
|
- deviceAlarm_Curs.Add(new DeviceAlarm_Cur()
|
|
|
|
- {
|
|
|
|
- 线体名称 = tempDic[i].plcName,
|
|
|
|
- 报警类型 = tempDic[i].fault_code,
|
|
|
|
- 报警内容 = tempDic[i].fault_name,
|
|
|
|
- 开始时间 = dtNow
|
|
|
|
- });
|
|
|
|
- // 新增到数据库
|
|
|
|
- //var data1 = dicAlarms_Cur_PLC1.Where(x => x.group_index == index).ToList()[row].报警数据;
|
|
|
|
- //SaveAlarmDataByDB(stationNameStr, data1, false);
|
|
|
|
- //OnMessage(LogType.Info, $"更新{BodyAlarm}完毕!");
|
|
|
|
|
|
+ dicAlarms_Cur_PLC1.Where(x => x.group_index == index).ToList()[row].报警数据 = new AlarmData()
|
|
|
|
+ {
|
|
|
|
+ GUID = Guid.NewGuid().ToString(),
|
|
|
|
+ LineName = GlobalContext.IsUseStationName, // 工站
|
|
|
|
+ PlcStation = tempDic[i].plcName, // 工站全称;[S1]
|
|
|
|
+ Type1 = tempDic[i].type1, // 故障层级1
|
|
|
|
+ Type2 = tempDic[i].type2, // 故障层级2
|
|
|
|
+ Type3 = tempDic[i].type3, // 故障层级3
|
|
|
|
+ Type4 = tempDic[i].type4, // 故障层级4
|
|
|
|
+ AlarmType = tempDic[i].fault_code, // 报警类型
|
|
|
|
+ AlarmDesc = tempDic[i].fault_name, // 报警内容
|
|
|
|
+ StartTime = dtNow // 开始时间
|
|
|
|
+ };
|
|
|
|
+ // 传输到页面
|
|
|
|
+ deviceAlarm_Curs.Add(new DeviceAlarm_Cur()
|
|
|
|
+ {
|
|
|
|
+ 线体名称 = tempDic[i].plcName,
|
|
|
|
+ 报警类型 = tempDic[i].fault_code,
|
|
|
|
+ 报警内容 = tempDic[i].fault_name,
|
|
|
|
+ 开始时间 = dtNow
|
|
|
|
+ });
|
|
|
|
+ // 新增到数据库
|
|
|
|
+ //var data1 = dicAlarms_Cur_PLC1.Where(x => x.group_index == index).ToList()[row].报警数据;
|
|
|
|
+ //SaveAlarmDataByDB(stationNameStr, data1, false);
|
|
|
|
+ //OnMessage(LogType.Info, $"更新{BodyAlarm}完毕!");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- //筛选含报警数据的字典
|
|
|
|
- var dicAlarms_Cur = dicAlarms_Cur_PLC1.Where(x => x.报警数据 != null).ToList();
|
|
|
|
- if (dicAlarms_Cur.Count > 0)
|
|
|
|
- {
|
|
|
|
- foreach (var item in dicAlarms_Cur)
|
|
|
|
|
|
+ //筛选含报警数据的字典
|
|
|
|
+ var dicAlarms_Cur = dicAlarms_Cur_PLC1.Where(x => x.报警数据 != null).ToList();
|
|
|
|
+ if (dicAlarms_Cur.Count > 0)
|
|
{
|
|
{
|
|
- //上传
|
|
|
|
- SaveAlarmDataByDB(GlobalContext.IsUseStationName, item.报警数据, false);
|
|
|
|
|
|
+ foreach (var item in dicAlarms_Cur)
|
|
|
|
+ {
|
|
|
|
+ //上传
|
|
|
|
+ SaveAlarmDataByDB(GlobalContext.IsUseStationName, item.报警数据, false);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- // 有新报警则更新
|
|
|
|
- if (isNeedUpdUI)
|
|
|
|
- // UI展示 - 展示到设备状态页
|
|
|
|
- await Task.Run(() =>
|
|
|
|
- {
|
|
|
|
- try
|
|
|
|
|
|
+ // 有新报警则更新
|
|
|
|
+ if (isNeedUpdUI)
|
|
|
|
+ // UI展示 - 展示到设备状态页
|
|
|
|
+ await Task.Run(() =>
|
|
{
|
|
{
|
|
- if (Form_Main.formDevAlarm != null && !Form_Main.formDevAlarm.IsDisposed)
|
|
|
|
|
|
+ try
|
|
{
|
|
{
|
|
- Form_Main.formDevAlarm.UpdDeviceAlarm_Cur(deviceAlarm_Curs); // 报警UI 更新
|
|
|
|
- if (Form_Main.formDevAlarm.Visible)
|
|
|
|
- Form_Main.formDevAlarm.UpdDeviceAlarm_History_48H(); // 历史报警UI 更新
|
|
|
|
|
|
+ if (Form_Main.formDevAlarm != null && !Form_Main.formDevAlarm.IsDisposed)
|
|
|
|
+ {
|
|
|
|
+ Form_Main.formDevAlarm.UpdDeviceAlarm_Cur(deviceAlarm_Curs); // 报警UI 更新
|
|
|
|
+ if (Form_Main.formDevAlarm.Visible)
|
|
|
|
+ Form_Main.formDevAlarm.UpdDeviceAlarm_History_48H(); // 历史报警UI 更新
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- catch { }
|
|
|
|
- });
|
|
|
|
- _FaultDatas_Old = FaultData.ToArray();
|
|
|
|
|
|
+ catch { }
|
|
|
|
+ });
|
|
|
|
+ _FaultDatas_Old = FaultData.ToArray();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
//FaultLogRequest request = new FaultLogRequest();
|
|
//FaultLogRequest request = new FaultLogRequest();
|
|
//request.station = mesStation; // 工位
|
|
//request.station = mesStation; // 工位
|
|
//request.fault_name = xmFaultName; // 故障名称(同数据字典中的事件名称)
|
|
//request.fault_name = xmFaultName; // 故障名称(同数据字典中的事件名称)
|
|
@@ -4221,8 +4183,8 @@ namespace MainForm
|
|
{
|
|
{
|
|
ProgressState = true;
|
|
ProgressState = true;
|
|
Task.Run(() => S4出站(plcNo, stationNameStr, stPLC_MesData,
|
|
Task.Run(() => S4出站(plcNo, stationNameStr, stPLC_MesData,
|
|
- tagBaseName + "." + tagMesCommName, stationCode, stationName,
|
|
|
|
- out ProgressState));
|
|
|
|
|
|
+ tagBaseName + "." + tagMesCommName, stationCode, stationName));
|
|
|
|
+ ProgressState = false;
|
|
stPLC_MesData.mesCommFrmPLC.cmd = 0;
|
|
stPLC_MesData.mesCommFrmPLC.cmd = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -4391,12 +4353,12 @@ namespace MainForm
|
|
/// <summary>
|
|
/// <summary>
|
|
/// [S4] 点胶检测设备 - 出站接口
|
|
/// [S4] 点胶检测设备 - 出站接口
|
|
/// </summary>
|
|
/// </summary>
|
|
- private void S4出站(int plcNo, string stationNameStr, OP40_MesData_t stPLC_MesData, string tagMesCommName,
|
|
|
|
- string stationCode, string stationName, out bool ProgressState)
|
|
|
|
|
|
+ private async void S4出站(int plcNo, string stationNameStr, OP40_MesData_t stPLC_MesData, string tagMesCommName,
|
|
|
|
+ string stationCode, string stationName)
|
|
{
|
|
{
|
|
Stopwatch stopwatch1 = new Stopwatch();
|
|
Stopwatch stopwatch1 = new Stopwatch();
|
|
Stopwatch stopwatch2 = new Stopwatch();
|
|
Stopwatch stopwatch2 = new Stopwatch();
|
|
-
|
|
|
|
|
|
+ uuid=Guid.NewGuid().ToString();
|
|
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
@@ -4470,8 +4432,18 @@ namespace MainForm
|
|
{
|
|
{
|
|
AddMessage(LogType.Info, stationNameStr + "_保存加工数据到本地失败");
|
|
AddMessage(LogType.Info, stationNameStr + "_保存加工数据到本地失败");
|
|
}
|
|
}
|
|
-
|
|
|
|
AddMessage(LogType.Info, stationNameStr + "_保存加工数据到本地成功");
|
|
AddMessage(LogType.Info, stationNameStr + "_保存加工数据到本地成功");
|
|
|
|
+
|
|
|
|
+ string[] urlarry = GlobalContext.UpFileUrl.Split(",");
|
|
|
|
+ foreach (var item in urlarry)
|
|
|
|
+ {
|
|
|
|
+ if (!string.IsNullOrEmpty(item))
|
|
|
|
+ {
|
|
|
|
+ fileUploadData.fileData.Clear();
|
|
|
|
+ //上传图片
|
|
|
|
+ await SaveDBbyFileInfo(stPLC_MesData.BarcodeSet, stationCode, stationName, mesResultFrmWeb, item, uuid);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
@@ -4492,7 +4464,6 @@ namespace MainForm
|
|
AddMessage(LogType.Info,
|
|
AddMessage(LogType.Info,
|
|
stationNameStr + "_出站接口;总用时" + stopwatch1.ElapsedMilliseconds + "ms;写入用时" +
|
|
stationNameStr + "_出站接口;总用时" + stopwatch1.ElapsedMilliseconds + "ms;写入用时" +
|
|
stopwatch2.ElapsedMilliseconds + "ms");
|
|
stopwatch2.ElapsedMilliseconds + "ms");
|
|
- ProgressState = false;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|