change-投料时间修改为计算系统运行时长

dev
liuwf 3 months ago
parent b6ca315cc7
commit d988bbfbe7

@ -54,7 +54,7 @@ namespace SlnMesnac.Business
/// <summary>
/// 设备生产管理业务类 -3F
/// </summary>
public class ProdMgmtBusiness: BaseBusiness
public class ProdMgmtBusiness : BaseBusiness
{
public readonly IMesProductPlanService _mesProductPlanService;
@ -64,18 +64,23 @@ namespace SlnMesnac.Business
public readonly IWmsOutStockService _wmsOutStockService;
private readonly ConfigInfoBusiness _configInfoBusiness;
private List<RealPalletTask> _palletTasks;
private ISqlSugarClient sqlSugarClient;
private DebugConfig debugConfig = DebugConfig.Instance;
public ProdMgmtBusiness(ISqlSugarClient _sqlSugarClient,IWmsOutStockService wmsOutStockService,ILogger<ProdMgmtBusiness> logger, AppConfig appConfig, List<PlcAbsractFactory> plcFactories, List<RfidAbsractFactory> rfidFactories, IMesProductPlanService mesProductPlanService, IBasePalletInfoService basePalletInfoService, IBaseRealTaskService baseRealTaskService, List<RealPalletTask> palletTasks,IServiceProvider serviceProvider) : base(logger, appConfig, plcFactories, rfidFactories, serviceProvider)
public ProdMgmtBusiness(ISqlSugarClient _sqlSugarClient, IWmsOutStockService wmsOutStockService, ILogger<ProdMgmtBusiness> logger, AppConfig appConfig, List<PlcAbsractFactory> plcFactories, List<RfidAbsractFactory> rfidFactories, IMesProductPlanService mesProductPlanService, IBasePalletInfoService basePalletInfoService, IBaseRealTaskService baseRealTaskService, List<RealPalletTask> palletTasks, IServiceProvider serviceProvider, ConfigInfoBusiness configInfoBusiness) : base(logger, appConfig, plcFactories, rfidFactories, serviceProvider)
{
sqlSugarClient = _sqlSugarClient;
_wmsOutStockService = wmsOutStockService;
_mesProductPlanService = mesProductPlanService;
_basePalletInfoService = basePalletInfoService;
_baseRealTaskService = baseRealTaskService;
_palletTasks = palletTasks;
_configInfoBusiness =configInfoBusiness;
// testTran();
}
@ -94,7 +99,7 @@ namespace SlnMesnac.Business
//tcpClient.Setup(new TouchSocketConfig().SetRemoteIPHost($"192.168.2.51:3000"));
//tcpClient.Connect();
// byte[] reciveBuffer = await waitClient.SendThenReturnAsync(pMessagePack.m_pData, timeout);
string aaa =await ReadEpcStrByRfidKeyAsync("test");
string aaa = await ReadEpcStrByRfidKeyAsync("test");
// ReadEpcStrByRfidKey("test", out string epcStr);
Console.WriteLine(aaa);
//RefreshMessage($"投料校验RFID标签读取成功标签信息{epcStr}");
@ -203,7 +208,7 @@ namespace SlnMesnac.Business
// string palletCode = GetPalletInfoByTask();
RefreshMessage($"执行计划:{prodPlan.PlanCode};计划数量:{Math.Round(prodPlan.PlanAmount,2)};完成数量:{Math.Round(prodPlan.CompleteAmount,2)};发起叫料申请");
RefreshMessage($"执行计划:{prodPlan.PlanCode};计划数量:{Math.Round(prodPlan.PlanAmount, 2)};完成数量:{Math.Round(prodPlan.CompleteAmount, 2)};发起叫料申请");
//查询下发agv的主键
WmsRawOutstock wmsRaw = _wmsOutStockService.GetProdPlanByPlanCode(prodPlan.PlanCode);
@ -261,7 +266,7 @@ namespace SlnMesnac.Business
localPlan = _baseRealTaskService.GetExeTask();
if (localPlan== null)
if (localPlan == null)
{
RefreshMessage("本地未获取到叫料任务......");
Thread.Sleep(3000);
@ -283,14 +288,14 @@ namespace SlnMesnac.Business
continue;
}
// TODO 时间校验,修改为计算设备运行20分钟
// TODO 投料时间校验
bool timeCheck = JudgeProductTime();
if (!timeCheck)
{
RefreshMessage($"收到物料到位信号,但是距离上次投料不满20min,禁止投料");
Thread.Sleep(1000 * 15);
continue;
}
RefreshMessage($"投料时间校验通过");
// 调用调度接口判断AGV小车是否已经离开到位否则不允许投料
bool positionCheck = JudgeAgvPosition();
@ -345,8 +350,6 @@ namespace SlnMesnac.Business
//}
#endregion
}
catch (Exception e)
{
@ -359,16 +362,21 @@ namespace SlnMesnac.Business
if (prodPlan != null)
{
// 下发翻转信号
plc.writeBoolByAddress(GetPlcAddressByConfigKey("设备投料"),true);
plc.writeBoolByAddress(GetPlcAddressByConfigKey("设备投料"), true);
Thread.Sleep(300);
plc.writeBoolByAddress(GetPlcAddressByConfigKey("设备投料"), false);
debugConfig.LastTime = DateTime.Now.ToString();
#region 清空投料系统运行时间
BaseConfigInfo configInfo = _configInfoBusiness.GetConfigInfos().Where(x => x.ConfigKey == "拆包机系统运行时长").FirstOrDefault();
configInfo.ConfigValue = "0";
_configInfoBusiness.UpdateConfigInfo(configInfo);
#endregion
//在小包2楼绑定托盘时完成计划
// PutInResutlHandle(prodPlan, result);
// 完成本地计划
if(localPlan!= null)
if (localPlan != null)
{
localPlan.Status = 2;
localPlan.UpdateTime = DateTime.Now;
@ -385,7 +393,7 @@ namespace SlnMesnac.Business
/// </summary>
/// <param name="prodPlan"></param>
/// <param name="isRes"></param>
private void PutInResutlHandle(MesProductPlan prodPlan,bool isRes)
private void PutInResutlHandle(MesProductPlan prodPlan, bool isRes)
{
try
{
@ -406,7 +414,8 @@ namespace SlnMesnac.Business
{
RefreshMessage("投料校验失败,人工确认不许投料");
}
}catch(Exception e)
}
catch (Exception e)
{
_logger.LogInformation($"投料结果处理异常:{e.Message}");
}
@ -480,7 +489,7 @@ namespace SlnMesnac.Business
var info = _mesProductPlanService.GetProdPlanByPlanCode(planInfo.PlanCode);
if(info == null)
if (info == null)
{
throw new ArgumentException("更新生产计划异常:根据计划编号获取计划信息为空");
}
@ -510,33 +519,22 @@ namespace SlnMesnac.Business
{
int IntervalMin = int.Parse(GetPlcAddressByConfigKey("投料时间间隔")); // 单位分钟
if (debugConfig.LastTime != "")
{
int systemRunTime = int.Parse(GetPlcAddressByConfigKey("拆包机系统运行时长")); // 单位分钟
DateTime lastTime = DateTime.Parse(debugConfig.LastTime);
TimeSpan timeDifference = DateTime.Now - lastTime;
if (timeDifference.TotalMinutes > IntervalMin)
if (systemRunTime > IntervalMin)
{
return true;
}
else
{
RefreshMessage($"收到物料到位请求投料信号,但是距离上次投料不满20min,禁止投料");
return false;
}
}
else
{
return true;
}
}
catch (Exception ex)
{
_logger.LogError($"距离上次投料时间合格判断异常JudgeProductTime{ex.Message}");
return false;
}
}

@ -284,5 +284,8 @@ namespace SlnMesnac.Business.@base
throw new InvalidOperationException($"根据Key获取PLC地址异常{configKey}:{ex.Message}");
}
}
}
}

@ -15,7 +15,7 @@
</Grid.RowDefinitions>
<Border Grid.Row="0" BorderBrush="White" BorderThickness="0.4" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
<Grid >
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal" >
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal" >
<!--<Ellipse x:Name="StatusLight" Width="50" Height="50" Fill="Green"/>
<Label Content="系统运行状态:" Foreground="White" FontSize="40" Margin="0 0 10 0"/>
<TextBox Text="正在进料" Width="200" Foreground="White" FontSize="40"/>-->

@ -12,6 +12,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
@ -36,7 +37,7 @@ namespace SlnMesnac.WPF.Page
int MachineSleep = 1000;
private readonly ILogger<DevMonitorPage> _logger;
System.Timers.Timer systemRunTimer = new System.Timers.Timer(1000 * 60);
public DevMonitorPage()
{
@ -56,6 +57,15 @@ namespace SlnMesnac.WPF.Page
private void Init()
{
systemRunTimer.Elapsed += new System.Timers.ElapsedEventHandler(CalculateSystemRunTime);
systemRunTimer.AutoReset = true;
systemRunTimer.Enabled = true;
systemRunTimer.Start();
List<BaseConfigInfo> configInfos = _configInfoBusiness.GetConfigInfos();
UnpackSet1Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机翻转机频率设定值").FirstOrDefault().ConfigValue;
@ -70,6 +80,33 @@ namespace SlnMesnac.WPF.Page
//HotTempTxt.Text = configInfos.Where(x => x.ConfigKey == "烘干机温度设定值").FirstOrDefault().ConfigValue;
}
/// <summary>
/// 计算系统投料后运行时长
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CalculateSystemRunTime(object? sender, ElapsedEventArgs e)
{
try
{
if (plc != null)
{
bool unPackStatus1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机系统运行状态"));
if (unPackStatus1)
{
BaseConfigInfo configInfo = _configInfoBusiness.GetConfigInfos().Where(x => x.ConfigKey == "拆包机系统运行时长").FirstOrDefault();
configInfo.ConfigValue += 1;
_configInfoBusiness.UpdateConfigInfo(configInfo);
}
}
}
catch (Exception ex)
{
_logger.LogError($"计算系统运行时长异常:{ex.Message}");
}
}
/// <summary>
/// 设备参数监听
/// </summary>
@ -95,7 +132,7 @@ namespace SlnMesnac.WPF.Page
Thread.Sleep(1000 * 30);
}
}
catch(Exception ex)
catch (Exception ex)
{
_logger.LogError($"设备参数监听StartMachineLisening()异常:{ex.Message}");
}
@ -727,7 +764,7 @@ namespace SlnMesnac.WPF.Page
MessageBox.Show($"烘干机螺旋启动失败:前提条件螺旋1未成功启动,请检查后重新启动");
return false;
}
if (speed1 < value1 *100 * 0.8)
if (speed1 < value1 * 100 * 0.8)
{
// plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), false);
MessageBox.Show($"烘干机螺旋启动失败:前提条件螺旋1速度{speed1}未达到设定值{value1}的下限阈值80%,请检查后重新启动");
@ -952,8 +989,8 @@ namespace SlnMesnac.WPF.Page
bool signal4 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1变频器状态"));
bool signal5 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2变频器状态"));
double speed1 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度反馈"))/100;
double speed2 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度反馈"))/100;
double speed1 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度反馈")) / 100;
double speed2 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度反馈")) / 100;
// 螺旋速度预设值
int speed1Set = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度值"));
@ -995,7 +1032,7 @@ namespace SlnMesnac.WPF.Page
try
{
int signal1_1 = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋状态"));
int signal2_1= plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机风机状态"));
int signal2_1 = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机风机状态"));
int signal3_1 = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机燃烧机状态"));
@ -1017,7 +1054,7 @@ namespace SlnMesnac.WPF.Page
await App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
HotSignal1_1.Fill = signal1_1==1 ? Brushes.Green : Brushes.Red;
HotSignal1_1.Fill = signal1_1 == 1 ? Brushes.Green : Brushes.Red;
HotSignal1_1_Value.Text = ChangeHotStatus(signal1_1);
HotSignal2_1.Fill = signal2_1 == 1 ? Brushes.Green : Brushes.Red;
HotSignal2_1_Value.Text = ChangeHotStatus(signal2_1);
@ -1127,8 +1164,8 @@ namespace SlnMesnac.WPF.Page
BaseConfigInfo configInfo1 = configInfos.Where(x => x.ConfigKey == "螺旋1速度值").FirstOrDefault();
BaseConfigInfo configInfo2 = configInfos.Where(x => x.ConfigKey == "螺旋2速度值").FirstOrDefault();
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设置"), speed1 );
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设置"), speed2 );
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设置"), speed1);
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设置"), speed2);
configInfo1.ConfigValue = Speed1Txt.Text;
configInfo2.ConfigValue = Speed2Txt.Text;
@ -1141,7 +1178,8 @@ namespace SlnMesnac.WPF.Page
MessageBox.Show("请输入0到50之间的正整数");
}
}catch(Exception ex)
}
catch (Exception ex)
{
_logger.LogError(ex.Message);
}
@ -1160,7 +1198,7 @@ namespace SlnMesnac.WPF.Page
bool isValidSpeed1 = int.TryParse(HotSpiralSpeedTxt.Text, out int speed1);
// 校验输入的整数是否在0到50之间且大于0
if (isValidSpeed1&& speed1 > 0 && speed1 <= 50)
if (isValidSpeed1 && speed1 > 0 && speed1 <= 50)
{
var result = MessageBox.Show("是否确认更改?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
if (result == MessageBoxResult.Yes)

Loading…
Cancel
Save