change - 优化前端刷新,优化配方写入

master
SoulStar 1 month ago
parent 07c15adc14
commit feae78a61f

@ -96,15 +96,16 @@ namespace HighWayIot.Plc.PlcHelper
Array.Copy(bytes4, 0, bytes, (393 - 290) * 2, bytes4.Length); Array.Copy(bytes4, 0, bytes, (393 - 290) * 2, bytes4.Length);
Array.Copy(bytes5, 0, bytes, (394 - 290) * 2, bytes5.Length); Array.Copy(bytes5, 0, bytes, (394 - 290) * 2, bytes5.Length);
Array.Copy(bytes6, 0, bytes, (398 - 290) * 2, bytes6.Length); Array.Copy(bytes6, 0, bytes, (398 - 290) * 2, bytes6.Length);
Array.Copy(sideBytes, 0, bytes, (409 - 290) * 2, sideBytes.Length);
if (!PlcConnect.PlcWriteBytes2("D290", bytes).IsSuccess) if (!PlcConnect.PlcWriteBytes2("D290", bytes).IsSuccess)
{ {
return false; return false;
} }
if (!PlcConnect.PlcWriteBytes2("D409", sideBytes).IsSuccess) //if (!PlcConnect.PlcWriteBytes2("D409", sideBytes).IsSuccess)
{ //{
return false; // return false;
} //}
return true; return true;
} }

@ -29,7 +29,7 @@ namespace HighWayIot.Winform.Business
public MonitorDataRefreshBusiness() public MonitorDataRefreshBusiness()
{ {
// 启动定时器每隔1秒刷新一次报表数据 // 启动定时器每隔1秒刷新一次报表数据
refreshTimer = new Timer(RefreshData, null, 0, 1600); refreshTimer = new Timer(RefreshData, null, 0, 2000);
} }
/// <summary> /// <summary>
@ -47,6 +47,7 @@ namespace HighWayIot.Winform.Business
} }
//解析返回的信号数据 //解析返回的信号数据
//RGV小车号
ushort[] rgvNo = new ushort[7]; ushort[] rgvNo = new ushort[7];
//RGV状态信号 //RGV状态信号
ushort[] rgvState = new ushort[7]; ushort[] rgvState = new ushort[7];
@ -90,11 +91,13 @@ namespace HighWayIot.Winform.Business
transferSingal.WriteAlarmSignal(); transferSingal.WriteAlarmSignal();
} }
bool isRefresh = false;
//报表信号获取 //报表信号获取
for (int i = 0; i < 7; i++) for (int i = 0; i < 7; i++)
{ {
rgvNo[i] = PlcConnect.MelsecInstance2.ByteTransform.TransUInt16(signals, (i * 2) + 20);
rgvState[i] = PlcConnect.MelsecInstance2.ByteTransform.TransUInt16(signals, i * 2); rgvState[i] = PlcConnect.MelsecInstance2.ByteTransform.TransUInt16(signals, i * 2);
rgvNo[i] = PlcConnect.MelsecInstance2.ByteTransform.TransUInt16(signals, (i * 2) + 20);
if (i > 2) if (i > 2)
{ {
weights[i - 3] = PlcConnect.MelsecInstance2.ByteTransform.TransSingle(signals, ((i - 3) * 4) + 38); weights[i - 3] = PlcConnect.MelsecInstance2.ByteTransform.TransSingle(signals, ((i - 3) * 4) + 38);
@ -109,7 +112,7 @@ namespace HighWayIot.Winform.Business
// 监控画面信息插入 // 监控画面信息插入
if (MonitorInsert(RecipeSendBusiness.NowRecipeCode, RecipeSendBusiness.NowDeviceNo, rgvNo[0])) if (MonitorInsert(RecipeSendBusiness.NowRecipeCode, RecipeSendBusiness.NowDeviceNo, rgvNo[0]))
{ {
MonitorMainPage.MonitorRefreshAction.Invoke(); isRefresh = true;
} }
transferSingal.WriteStationReportSignal(1); // 复位信号 transferSingal.WriteStationReportSignal(1); // 复位信号
} }
@ -126,7 +129,7 @@ namespace HighWayIot.Winform.Business
entity.BaseEndTime = DateTime.Now; entity.BaseEndTime = DateTime.Now;
if (ZxDailyReportService.Instance.UpdateDailyReportInfo(entity)) if (ZxDailyReportService.Instance.UpdateDailyReportInfo(entity))
{ {
MonitorMainPage.MonitorRefreshAction.Invoke(); isRefresh = true;
} }
transferSingal.WriteStationReportSignal(2); // 复位信号 transferSingal.WriteStationReportSignal(2); // 复位信号
} }
@ -144,9 +147,8 @@ namespace HighWayIot.Winform.Business
entity.MidEndTime = DateTime.Now; entity.MidEndTime = DateTime.Now;
if (ZxDailyReportService.Instance.UpdateDailyReportInfo(entity)) if (ZxDailyReportService.Instance.UpdateDailyReportInfo(entity))
{ {
MonitorMainPage.MonitorRefreshAction.Invoke(); isRefresh = true;
} }
MonitorMainPage.MonitorRefreshAction.Invoke();
transferSingal.WriteStationReportSignal(3); // 复位信号 transferSingal.WriteStationReportSignal(3); // 复位信号
} }
n2: n2:
@ -171,7 +173,7 @@ namespace HighWayIot.Winform.Business
} }
if (ZxDailyReportService.Instance.UpdateDailyReportInfo(entity)) if (ZxDailyReportService.Instance.UpdateDailyReportInfo(entity))
{ {
MonitorMainPage.MonitorRefreshAction.Invoke(); isRefresh = true;
} }
transferSingal.WriteStationReportSignal(i + 1); // 复位信号 transferSingal.WriteStationReportSignal(i + 1); // 复位信号
} }
@ -194,15 +196,20 @@ namespace HighWayIot.Winform.Business
} }
if (ZxDailyReportService.Instance.UpdateDailyReportInfo(entity)) if (ZxDailyReportService.Instance.UpdateDailyReportInfo(entity))
{ {
MonitorMainPage.MonitorRefreshAction.Invoke(); isRefresh = true;
} }
transferSingal.WriteStationReportSignal(7); // 复位信号 transferSingal.WriteStationReportSignal(7); // 复位信号
} }
if (isRefresh == true)
{
MonitorMainPage.MonitorRefreshAction.Invoke();
}
} }
catch (Exception ex) catch (Exception ex)
{ {
Log4net.LogHelper.Instance.Error("报表解析方法出现错误", ex); Log4net.LogHelper.Instance.Error("前端监控报表解析方法出现错误", ex);
} }
} }

@ -136,7 +136,7 @@ namespace HighWayIot.Winform.Business
//MonitorInsert(recipeNo, $"{deviceNo}上模"); //MonitorInsert(recipeNo, $"{deviceNo}上模");
LogHelper.Instance.Info($"配方上传成功,配方号:{recipeNo},模具号:{deviceNo}上模"); LogHelper.Instance.Info($"配方上传成功,配方号:{recipeNo},模具号:{deviceNo}上模");
NowRecipeCode = recipeNo; NowRecipeCode = recipeNo;
NowDeviceNo = deviceNo + "-2"; NowDeviceNo = deviceNo + "-1";
} }
else else
{ {
@ -161,7 +161,7 @@ namespace HighWayIot.Winform.Business
//MonitorInsert(recipeNo, $"{deviceNo}下模"); //MonitorInsert(recipeNo, $"{deviceNo}下模");
LogHelper.Instance.Info($"配方上传成功,配方号:{recipeNo},模具号:{deviceNo}下模"); LogHelper.Instance.Info($"配方上传成功,配方号:{recipeNo},模具号:{deviceNo}下模");
NowRecipeCode = recipeNo; NowRecipeCode = recipeNo;
NowDeviceNo = deviceNo + "-1"; NowDeviceNo = deviceNo + "-2";
} }
else else
{ {

Loading…
Cancel
Save