diff --git a/SlnMesnac.Business/base/BaseBusiness.cs b/SlnMesnac.Business/base/BaseBusiness.cs
index 48133f3..d1552bd 100644
--- a/SlnMesnac.Business/base/BaseBusiness.cs
+++ b/SlnMesnac.Business/base/BaseBusiness.cs
@@ -279,7 +279,8 @@ namespace SlnMesnac.Business.@base
throw new ArgumentNullException("根据Key获取PLC地址异常:配置集合为空");
}
- return baseConfigInfos.Where(x => x.ConfigKey == configKey).First().ConfigValue;
+ var result = baseConfigInfos.Where(x => x.ConfigKey == configKey).First().ConfigValue;
+ return result;
}
catch (Exception ex)
{
diff --git a/SlnMesnac.Config/DebugConfig.cs b/SlnMesnac.Config/DebugConfig.cs
index 20637bb..39c3fcc 100644
--- a/SlnMesnac.Config/DebugConfig.cs
+++ b/SlnMesnac.Config/DebugConfig.cs
@@ -27,14 +27,61 @@ namespace SlnMesnac.Config
}
///
- ///上次投料时间
+ ///缓存区重量
///
- public string LastTime
+ public string BufferWeight
{
- get { return iniHelper.IniReadValue("system", "LastTime"); }
- set { iniHelper.IniWriteValue("system", "LastTime", value); }
+ get { return iniHelper.IniReadValue("system", "BufferWeight"); }
+ set { iniHelper.IniWriteValue("system", "BufferWeight", value); }
}
+ ///
+ ///系统当前使用配方模版
+ ///
+ public string RecipeName
+ {
+ get { return iniHelper.IniReadValue("system", "RecipeName"); }
+ set { iniHelper.IniWriteValue("system", "RecipeName", value); }
+ }
+
+
+ ///
+ ///配方运行模式
+ ///
+ public string RecipeMode
+ {
+ get { return iniHelper.IniReadValue("system", "RecipeMode"); }
+ set { iniHelper.IniWriteValue("system", "RecipeMode", value); }
+ }
+
+ ///
+ ///拆包机螺旋--烘干机螺旋切换间隔(单位:ms)
+ ///
+ public string UnpackToHotTime
+ {
+ get { return iniHelper.IniReadValue("system", "UnpackToHotTime"); }
+ set { iniHelper.IniWriteValue("system", "UnpackToHotTime", value); }
+ }
+
+ ///
+ ///烘干机螺旋--螺旋1切换间隔(单位:ms)
+ ///
+ public string HotToSpiralTime
+ {
+ get { return iniHelper.IniReadValue("system", "HotToSpiralTime"); }
+ set { iniHelper.IniWriteValue("system", "HotToSpiralTime", value); }
+ }
+
+ ///
+ ///#螺旋1--螺旋2切换间隔(单位:ms)
+ ///
+ public string SpiralTwoTime
+ {
+ get { return iniHelper.IniReadValue("system", "SpiralTwoTime"); }
+ set { iniHelper.IniWriteValue("system", "SpiralTwoTime", value); }
+ }
+
+
///
///喷码机IP
///
diff --git a/SlnMesnac.Model/domain/RecipeManage.cs b/SlnMesnac.Model/domain/RecipeManage.cs
index e9c3317..22e025a 100644
--- a/SlnMesnac.Model/domain/RecipeManage.cs
+++ b/SlnMesnac.Model/domain/RecipeManage.cs
@@ -34,49 +34,49 @@ namespace SlnMesnac.Model.domain
public class RecipeManage
{
///
- /// 配方Id
+ /// 配方Id频率
///
[SugarColumn(ColumnName = "obj_id", IsPrimaryKey = true, IsIdentity = true)]
public int ObjId { get; set; }
///
- /// 配方Key
+ /// 配方Key频率
///
[SugarColumn(ColumnName = "recipe_key")]
public int RecipeKey { get; set; }
///
- /// 配方名称
+ /// 配方名称频率
///
[SugarColumn(ColumnName = "recipe_name")]
public string RecipeName { get; set; }
///
- /// 拆包机螺旋1
+ /// 拆包机螺旋1频率
///
[SugarColumn(ColumnName = "unpack_spiral1")]
public int UnpackSpiral1 { get; set; }
///
- /// 拆包机螺旋2
+ /// 拆包机螺旋2频率
///
[SugarColumn(ColumnName = "unpack_spiral2")]
public int UnpackSpiral2 { get; set; }
///
- /// 烘干机螺旋
+ /// 烘干机螺旋频率
///
[SugarColumn(ColumnName = "dryer_spiral")]
public int DryerSpiral { get; set; }
///
- /// 螺旋机螺旋1
+ /// 螺旋机螺旋1频率
///
[SugarColumn(ColumnName = "spiral1")]
public int Spiral1 { get; set; }
///
- /// 螺旋机螺旋2
+ /// 螺旋机螺旋2频率
///
[SugarColumn(ColumnName = "spiral2")]
public int Spiral2 { get; set; }
diff --git a/SlnMesnac.WPF/Model/PLCMachineModel.cs b/SlnMesnac.WPF/Model/PLCMachineModel.cs
index 0115a79..68d53d8 100644
--- a/SlnMesnac.WPF/Model/PLCMachineModel.cs
+++ b/SlnMesnac.WPF/Model/PLCMachineModel.cs
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace SlnMesnac.WPF.Model
{
///
- /// 烘干机采集参数
+ /// 采集实体参数
///
public class PLCMachineModel
{
diff --git a/SlnMesnac.WPF/Model/RecipeManageCache.cs b/SlnMesnac.WPF/Model/RecipeManageCache.cs
index 972d406..fb558a7 100644
--- a/SlnMesnac.WPF/Model/RecipeManageCache.cs
+++ b/SlnMesnac.WPF/Model/RecipeManageCache.cs
@@ -1,11 +1,13 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
+using SlnMesnac.Config;
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service;
using SlnMesnac.WPF;
using SlnMesnac.WPF.Page;
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Text;
#region << 版 本 注 释 >>
@@ -50,9 +52,86 @@ namespace SlnMesnac.WPF.Model
#region 变量定义
private readonly ILogger _logger;
-
+ private DebugConfig config = DebugConfig.Instance;
private readonly IBaseRecipeManageService? baseRecipeManageService;
- public List recipeManageList = null;
+
+ ///
+ /// 所有配方列表
+ ///
+ public List recipeManageList = null;
+
+
+ ///
+ /// 当前正在使用配方
+ ///
+ public RecipeManage useRecipeManage
+ {
+ get
+ {
+ if (recipeManageList != null)
+ {
+ return recipeManageList.FirstOrDefault(x => x.RecipeName == config.RecipeName);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ }
+
+
+ ///
+ /// 当前监测重量
+ ///
+ public double BufferWeight {
+ get { return double.Parse(config.BufferWeight); }
+ set { config.BufferWeight = value.ToString(); }
+ }
+ ///
+ /// 当前使用模版名称
+ ///
+ public string RecipeName
+ {
+ get { return config.RecipeName; }
+ set { config.RecipeName = value; }
+ }
+ ///
+ /// 当前使用模式
+ ///
+ public string RecipeMode
+ {
+ get { return config.RecipeMode; }
+ set { config.RecipeMode = value; }
+ }
+
+ ///
+ /// 拆包机螺旋--烘干机螺旋切换间隔(单位:ms)
+ ///
+ public string UnpackToHotTime
+ {
+ get { return config.UnpackToHotTime; }
+ set { config.UnpackToHotTime = value; }
+ }
+
+ ///
+ /// 烘干机螺旋--螺旋1切换间隔(单位:ms)
+ ///
+ public string HotToSpiralTime
+ {
+ get { return config.HotToSpiralTime; }
+ set { config.HotToSpiralTime = value; }
+ }
+
+ ///
+ /// 螺旋1--螺旋2切换间隔(单位:ms)
+ ///
+ public string SpiralTwoTime
+ {
+ get { return config.SpiralTwoTime; }
+ set { config.SpiralTwoTime = value; }
+ }
+
#endregion
diff --git a/SlnMesnac.WPF/Page/DevMonitorPage.xaml b/SlnMesnac.WPF/Page/DevMonitorPage.xaml
index 4bae408..ef42ce6 100644
--- a/SlnMesnac.WPF/Page/DevMonitorPage.xaml
+++ b/SlnMesnac.WPF/Page/DevMonitorPage.xaml
@@ -6,7 +6,8 @@
xmlns:local="clr-namespace:SlnMesnac.WPF.Page"
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent">
-
+
+
@@ -151,13 +152,13 @@
-->
-
+
-
+ -->
@@ -275,8 +276,8 @@
-
-
+
@@ -393,11 +394,11 @@
-
-
+
+
diff --git a/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs b/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs
index 9c55913..1c0a719 100644
--- a/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs
+++ b/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs
@@ -5,6 +5,7 @@ using SlnMesnac.Business;
using SlnMesnac.Business.@base;
using SlnMesnac.Model.domain;
using SlnMesnac.Plc;
+using SlnMesnac.WPF.Model;
using SlnMesnac.WPF.ViewModel;
using System;
using System.Collections.Generic;
@@ -38,9 +39,13 @@ namespace SlnMesnac.WPF.Page
private readonly ILogger _logger;
System.Timers.Timer systemRunTimer = new System.Timers.Timer(1000 * 60);
+ //系统频率配方
+ private RecipeManageCache recipeManageCache = RecipeManageCache.Instance;
+
public DevMonitorPage()
{
+ RecipeModeSetWindow.ManualChangeRecipeEvent += ManualChangeRecipe;
_logger = App.ServiceProvider.GetService>();
_configInfoBusiness = App.ServiceProvider.GetService();
@@ -50,33 +55,31 @@ namespace SlnMesnac.WPF.Page
InitializeComponent();
this.DataContext = new DevMonitorViewModel();
Init();
-
-
StartMachineLisening();
+ StartAdjustRecipe();
}
- private void Init()
- {
+ private void Init()
+ {
systemRunTimer.Elapsed += new System.Timers.ElapsedEventHandler(CalculateSystemRunTime);
systemRunTimer.AutoReset = true;
systemRunTimer.Enabled = true;
systemRunTimer.Start();
-
-
List configInfos = _configInfoBusiness.GetConfigInfos();
- // UnpackSet1Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机翻转机频率设定值").FirstOrDefault().ConfigValue;
- // UnpackSet2Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机滚筒筛频率设定值").FirstOrDefault().ConfigValue;
- UnpackSet3Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机螺旋1频率设定值").FirstOrDefault().ConfigValue;
- UnpackSet4Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机螺旋2频率设定值").FirstOrDefault().ConfigValue;
- // UnpackSet5Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机废袋机频率设定值").FirstOrDefault().ConfigValue;
BagsAmountTxt.Text = configInfos.Where(x => x.ConfigKey == "包装袋余量").FirstOrDefault().ConfigValue;
- Speed1Txt.Text = configInfos.Where(x => x.ConfigKey == "螺旋1速度设定值").FirstOrDefault().ConfigValue;
- Speed2Txt.Text = configInfos.Where(x => x.ConfigKey == "螺旋2速度设定值").FirstOrDefault().ConfigValue;
- HotSpiralSpeedTxt.Text = configInfos.Where(x => x.ConfigKey == "烘干机螺旋频率设定值").FirstOrDefault().ConfigValue;
+ // UnpackSet1Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机翻转机频率设定值").FirstOrDefault().ConfigValue;
+ // UnpackSet2Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机滚筒筛频率设定值").FirstOrDefault().ConfigValue;
+ //UnpackSet3Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机螺旋1频率设定值").FirstOrDefault().ConfigValue;
+ //UnpackSet4Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机螺旋2频率设定值").FirstOrDefault().ConfigValue;
+ // UnpackSet5Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机废袋机频率设定值").FirstOrDefault().ConfigValue;
+
+ //Speed1Txt.Text = configInfos.Where(x => x.ConfigKey == "螺旋1速度设定值").FirstOrDefault().ConfigValue;
+ //Speed2Txt.Text = configInfos.Where(x => x.ConfigKey == "螺旋2速度设定值").FirstOrDefault().ConfigValue;
+ // HotSpiralSpeedTxt.Text = configInfos.Where(x => x.ConfigKey == "烘干机螺旋频率设定值").FirstOrDefault().ConfigValue;
//HotTempTxt.Text = configInfos.Where(x => x.ConfigKey == "烘干机温度设定值").FirstOrDefault().ConfigValue;
}
@@ -95,8 +98,7 @@ namespace SlnMesnac.WPF.Page
bool unPackStatus1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机系统运行状态"));
if (unPackStatus1)
{
-
- BaseConfigInfo configInfo = _configInfoBusiness.GetConfigInfos().Where(x => x.ConfigKey == "拆包机系统运行时长").FirstOrDefault();
+ BaseConfigInfo configInfo = _configInfoBusiness.GetConfigInfos().Where(x => x.ConfigKey == "系统运行时长").FirstOrDefault();
configInfo.ConfigValue += 1;
_configInfoBusiness.UpdateConfigInfo(configInfo);
}
@@ -126,10 +128,10 @@ namespace SlnMesnac.WPF.Page
RefreshHot();
RefreshUnPack();
- App.Current.Dispatcher.BeginInvoke((Action)(() =>
- {
- BagsAmountTxt.Text = _configInfoBusiness.GetConfigInfos().FirstOrDefault(x => x.ConfigKey == "包装袋余量").ConfigValue;
- }));
+ App.Current.Dispatcher.BeginInvoke((Action)(() =>
+ {
+ BagsAmountTxt.Text = _configInfoBusiness.GetConfigInfos().FirstOrDefault(x => x.ConfigKey == "包装袋余量").ConfigValue;
+ }));
}
else
{
@@ -146,6 +148,220 @@ namespace SlnMesnac.WPF.Page
});
}
+ #region 监测缓存区重量,动态调整配方频率
+ ///
+ /// 开始启动监测缓存区重量,动态调整配方频率
+ ///
+ private void StartAdjustRecipe()
+ {
+ Task.Run(() =>
+ {
+ Thread.Sleep(1000 * 10);
+ while (true)
+ {
+ try
+ {
+ float cacheWeigh = plc.readFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("缓存区重量"));
+ recipeManageCache.BufferWeight = cacheWeigh;
+ if (recipeManageCache.RecipeMode == "自动模式")
+ {
+ bool unPackStatus1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机系统运行状态"));
+ bool signal2 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1状态"));
+ bool signal3 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2状态"));
+ int signal1_1 = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋状态"));
+
+ if (signal1_1 == 1 && signal2 && signal3 && unPackStatus1) // 1.设备都已经启动
+ {
+ // 1.判断缓存区重量是否满足配方要求
+ RecipeManage targetRecipe = null;
+ int result = JudgeCacheWeighIsOk(cacheWeigh, out targetRecipe);
+ switch (result)
+ {
+ case -1:
+ // TODO添加报警记录推送
+ break;
+ case 0: break;
+
+ case 1:
+ // 高切低
+ HighToLowSpeed(targetRecipe);
+ break;
+ case 2:
+ // 低切高
+ LowToHighSpeed(targetRecipe);
+ break;
+ default: break;
+ }
+
+
+ }
+ }
+ Thread.Sleep(1000 * 10);
+
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError($"监测缓存区重量,动态调整配方频率StartAdjustRecipe异常:{ex.Message}");
+ }
+ }
+ });
+ }
+
+ ///
+ /// 判断缓存区重量是否满足配方要求
+ ///
+ /// -1,重量未匹配到目标配方,报警
+ /// 0,无需更改配方
+ /// 1,从高速模版切换到低速模版
+ /// 2,从低速模版切换到高速模版
+ private int JudgeCacheWeighIsOk(float weight,out RecipeManage targetRecipe)
+ {
+ int result = -1;
+ targetRecipe = null;
+ try
+ {
+ foreach (var item in recipeManageCache.recipeManageList)
+ {
+ if (item.LowWeight <= weight && weight < item.HightWeight)
+ {
+ // 找到重量对应的配方
+ if (recipeManageCache.useRecipeManage == item)
+ {
+ // 不需要更改配方
+ result = 0;
+ }
+ else if (recipeManageCache.useRecipeManage.LowWeight < item.LowWeight)
+ {
+ //重量变大 从高速模版切换到低速模版
+ result = 1;
+ targetRecipe = item;
+ }
+ else if (recipeManageCache.useRecipeManage.LowWeight > item.LowWeight)
+ {
+ //重量变小 从低速模版切换到高速模版
+ result = 2;
+ targetRecipe = item;
+ }
+ }
+ }
+
+ return result;
+ }catch (Exception ex)
+ {
+ _logger.LogError("JudgeCacheWeighIsOk异常:" + ex.Message);
+ return result;
+ }
+ }
+
+ ///
+ /// 螺旋配方从高速切到低速:从前往后:拆包机、烘干、螺旋1,螺旋2
+ ///
+ private bool HighToLowSpeed(RecipeManage targetRecipe)
+ {
+
+ try
+ {
+ plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋1频率设定"), targetRecipe.UnpackSpiral1);
+ plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋2频率设定"), targetRecipe.UnpackSpiral2);
+ Thread.Sleep(int.Parse(recipeManageCache.UnpackToHotTime));
+ plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋频率设定"), targetRecipe.DryerSpiral);
+ Thread.Sleep(int.Parse(recipeManageCache.HotToSpiralTime));
+ plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设置"), targetRecipe.Spiral1);
+ Thread.Sleep(int.Parse(recipeManageCache.SpiralTwoTime));
+ plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设置"), targetRecipe.Spiral2);
+ //更新配方缓存里的当前使用模版
+ recipeManageCache.RecipeName = targetRecipe.RecipeName;
+ return true;
+ }catch (Exception ex)
+ {
+ _logger.LogError("HighToLowSpeed异常:" + ex.Message);
+ return false;
+ }
+ }
+
+
+ ///
+ /// 螺旋配方从低速切到高速:从后往前:螺旋2、螺旋1、烘干、拆包机
+ ///
+ private bool LowToHighSpeed(RecipeManage targetRecipe)
+ {
+
+ try
+ {
+ plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设置"), targetRecipe.Spiral2);
+ Thread.Sleep(int.Parse(recipeManageCache.SpiralTwoTime));
+ plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设置"), targetRecipe.Spiral1);
+ Thread.Sleep(int.Parse(recipeManageCache.HotToSpiralTime));
+ plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋频率设定"), targetRecipe.DryerSpiral);
+ Thread.Sleep(int.Parse(recipeManageCache.UnpackToHotTime));
+ plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋1频率设定"), targetRecipe.UnpackSpiral1);
+ plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋2频率设定"), targetRecipe.UnpackSpiral2);
+ //更新配方缓存里的当前使用模版
+ recipeManageCache.RecipeName = targetRecipe.RecipeName;
+ return true;
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError("LowToHighSpeed异常:" + ex.Message);
+ return false;
+ }
+ }
+
+
+ private async Task ManualChangeRecipe(RecipeManage targetRecipet)
+ {
+ bool unPackStatus1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机系统运行状态"));
+ bool signal2 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1状态"));
+ bool signal3 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2状态"));
+ int signal1_1 = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋状态"));
+
+ if (signal1_1 == 1 && signal2 && signal3 && unPackStatus1) // 1.设备都已经启动
+ {
+ if(recipeManageCache.useRecipeManage.RecipeName == targetRecipet.RecipeName)
+ {
+ recipeManageCache.RecipeMode = "手动模式";
+ return true;
+ }else if (recipeManageCache.useRecipeManage.LowWeight < targetRecipet.LowWeight)
+ {//高速切低速
+ bool result = await Task.Run(() =>
+ {
+ return HighToLowSpeed(targetRecipet);
+ });
+ if (result)
+ {
+ recipeManageCache.RecipeMode = "手动模式";
+ }
+ return result;
+ }
+ else if (recipeManageCache.useRecipeManage.LowWeight > targetRecipet.LowWeight)
+ {
+ bool result = await Task.Run(() =>
+ {
+ return LowToHighSpeed(targetRecipet);
+ });
+ if (result)
+ {
+ recipeManageCache.RecipeMode = "手动模式";
+ }
+ return result;
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ #endregion
+
+
+
+
#region 设备启动、停止
///
@@ -168,11 +384,13 @@ namespace SlnMesnac.WPF.Page
///
private void StartButton_Click(object sender, RoutedEventArgs e)
{
+
var result = MessageBox.Show("是否确认启动?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
if (result == MessageBoxResult.Yes)
{
try
{
+
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES允许远程")) == false)
{
MessageBox.Show("拆包机MES允许远程,未切换远程");
@@ -234,11 +452,14 @@ namespace SlnMesnac.WPF.Page
}
});
-
}
catch (Exception ex)
{
- _logger.LogError($"一键启动:{ex.Message}");
+ _logger.LogError($"一键启动异常:{ex.Message}");
+ }
+ finally
+ {
+
}
}
@@ -357,11 +578,11 @@ namespace SlnMesnac.WPF.Page
SendPulseSignal("拆包机远程启动");
//频率设定
- // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机翻转机频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机翻转机频率设定值")));
- // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机滚筒筛频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机滚筒筛频率设定值")));
- plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋1频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋1频率设定值")));
- plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋2频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋2频率设定值")));
- // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机废袋机频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机废袋机频率设定值")));
+ // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机翻转机频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机翻转机频率设定值")));
+ // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机滚筒筛频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机滚筒筛频率设定值")));
+ plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋1频率设定"), recipeManageCache.useRecipeManage.UnpackSpiral1);
+ plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋2频率设定"), recipeManageCache.useRecipeManage.UnpackSpiral2);
+ // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机废袋机频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机废袋机频率设定值")));
});
@@ -648,9 +869,9 @@ namespace SlnMesnac.WPF.Page
}
else
{
- int value2 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设定值"));
+
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), true);
- plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设置"), value2);
+ plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设置"), recipeManageCache.useRecipeManage.Spiral2);
Thread.Sleep(MachineSleep);
result = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"));
}
@@ -678,7 +899,7 @@ namespace SlnMesnac.WPF.Page
return false;
}
#region 启动磁选机 / 前提:check螺旋2启动及速度是否达标
- int value2 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设定值")) * 100;
+ int value2 = recipeManageCache.useRecipeManage.Spiral2;
bool startFlag = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"));
int speed2 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度反馈"));
if (!startFlag)
@@ -686,7 +907,7 @@ namespace SlnMesnac.WPF.Page
MessageBox.Show($"前提条件螺旋2未成功启动,请检查后重新启动");
return false;
}
- if (speed2 < value2 * 0.8)
+ if (speed2 < value2 * 100 * 0.8)
{
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), false);
MessageBox.Show($"前提条件螺旋2速度{speed2}未达到设定值{value2}的下限阈值80%,请检查后重新启动");
@@ -736,9 +957,9 @@ namespace SlnMesnac.WPF.Page
return false;
}
- int value1 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设定值"));
+
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"), true);
- plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设置"), value1);
+ plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设置"), recipeManageCache.useRecipeManage.Spiral1);
Thread.Sleep(MachineSleep);
result = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"));
@@ -761,7 +982,7 @@ namespace SlnMesnac.WPF.Page
bool result = false;
try
{
- int value1 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设定值"));
+ int value1 = recipeManageCache.useRecipeManage.Spiral1;
bool startFlag = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"));
int speed1 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度反馈"));
if (!startFlag)
@@ -777,7 +998,7 @@ namespace SlnMesnac.WPF.Page
}
int value = int.Parse(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋频率设定值"));
SendPulseSignal("烘干机螺旋启动");
- plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋频率设定"), value1);
+ plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋频率设定"), recipeManageCache.useRecipeManage.DryerSpiral);
Thread.Sleep(MachineSleep / 2);
return true;
}
@@ -816,7 +1037,6 @@ namespace SlnMesnac.WPF.Page
return result;
}
-
///
/// 烘干机燃烧启动/前提:check:烘干机风机启动
///
@@ -868,11 +1088,11 @@ namespace SlnMesnac.WPF.Page
SendPulseSignal("拆包机远程启动");
//频率设定
- // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机翻转机频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机翻转机频率设定值")));
- // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机滚筒筛频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机滚筒筛频率设定值")));
- plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋1频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋1频率设定值")));
- plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋2频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋2频率设定值")));
- // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机废袋机频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机废袋机频率设定值")));
+ // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机翻转机频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机翻转机频率设定值")));
+ // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机滚筒筛频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机滚筒筛频率设定值")));
+ plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋1频率设定"), recipeManageCache.useRecipeManage.UnpackSpiral1);
+ plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋2频率设定"), recipeManageCache.useRecipeManage.UnpackSpiral2);
+ // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机废袋机频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机废袋机频率设定值")));
Thread.Sleep(MachineSleep);
@@ -977,8 +1197,6 @@ namespace SlnMesnac.WPF.Page
}
-
-
///
/// 螺旋机参数监控
///
@@ -1141,159 +1359,165 @@ namespace SlnMesnac.WPF.Page
MessageBox.Show(message);
}
- ///
- /// 螺旋速度设定
- ///
- ///
- ///
- private void SpiralSpeed_Click(object sender, RoutedEventArgs e)
+
+ private void AmountChangeButton_Click(object sender, RoutedEventArgs e)
{
+ BagsAmountSetWindow window = new BagsAmountSetWindow();
+ window.ShowDialog();
+ }
- try
- {
- bool isValidSpeed1 = int.TryParse(Speed1Txt.Text, out int speed1);
- bool isValidSpeed2 = int.TryParse(Speed2Txt.Text, out int speed2);
- // 校验输入的整数是否在0到50之间且大于0
- if (isValidSpeed1 && isValidSpeed2 && speed1 > 0 && speed1 <= 50 && speed2 > 0 && speed2 <= 50)
- {
- if (speed1 > speed2)
- {
- MessageBox.Show("螺旋1速度不能大于螺旋2速度");
- return;
- }
- var result = MessageBox.Show("是否确认更改?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
- if (result == MessageBoxResult.Yes)
- {
- List configInfos = _configInfoBusiness.GetConfigInfos();
- 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);
+ #region 设备管理界面螺旋频率设定--暂未启用
- configInfo1.ConfigValue = Speed1Txt.Text;
- configInfo2.ConfigValue = Speed2Txt.Text;
- _configInfoBusiness.UpdateConfigInfo(configInfo1);
- _configInfoBusiness.UpdateConfigInfo(configInfo2);
- }
- }
- else
- {
- MessageBox.Show("请输入0到50之间的正整数!");
- }
+ /////
+ ///// 螺旋速度设定
+ /////
+ /////
+ /////
+ //private void SpiralSpeed_Click(object sender, RoutedEventArgs e)
+ //{
- }
- catch (Exception ex)
- {
- _logger.LogError(ex.Message);
- }
- }
+ // try
+ // {
+ // bool isValidSpeed1 = int.TryParse(Speed1Txt.Text, out int speed1);
+ // bool isValidSpeed2 = int.TryParse(Speed2Txt.Text, out int speed2);
+ // // 校验输入的整数是否在0到50之间且大于0
+ // if (isValidSpeed1 && isValidSpeed2 && speed1 > 0 && speed1 <= 50 && speed2 > 0 && speed2 <= 50)
+ // {
+ // if (speed1 > speed2)
+ // {
+ // MessageBox.Show("螺旋1速度不能大于螺旋2速度");
+ // return;
+ // }
+ // var result = MessageBox.Show("是否确认更改?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
+ // if (result == MessageBoxResult.Yes)
+ // {
+ // List configInfos = _configInfoBusiness.GetConfigInfos();
+ // BaseConfigInfo configInfo1 = configInfos.Where(x => x.ConfigKey == "螺旋1速度设定值").FirstOrDefault();
+ // BaseConfigInfo configInfo2 = configInfos.Where(x => x.ConfigKey == "螺旋2速度设定值").FirstOrDefault();
- ///
- /// 烘干机螺旋频率设定
- ///
- ///
- ///
- private void HotSpiralSpeedSet_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- bool isValidSpeed1 = int.TryParse(HotSpiralSpeedTxt.Text, out int speed1);
+ // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设置"), speed1);
+ // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设置"), speed2);
- // 校验输入的整数是否在0到50之间且大于0
- if (isValidSpeed1 && speed1 > 0 && speed1 <= 50)
- {
- var result = MessageBox.Show("是否确认更改?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
- if (result == MessageBoxResult.Yes)
- {
- List configInfos = _configInfoBusiness.GetConfigInfos();
- BaseConfigInfo configInfo = configInfos.Where(x => x.ConfigKey == "烘干机螺旋频率设定值").FirstOrDefault();
+ // configInfo1.ConfigValue = Speed1Txt.Text;
+ // configInfo2.ConfigValue = Speed2Txt.Text;
+ // _configInfoBusiness.UpdateConfigInfo(configInfo1);
+ // _configInfoBusiness.UpdateConfigInfo(configInfo2);
+ // }
+ // }
+ // else
+ // {
+ // MessageBox.Show("请输入0到50之间的正整数!");
+ // }
- plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋频率设定"), speed1);
+ // }
+ // catch (Exception ex)
+ // {
+ // _logger.LogError(ex.Message);
+ // }
+ //}
- configInfo.ConfigValue = HotSpiralSpeedTxt.Text;
- _configInfoBusiness.UpdateConfigInfo(configInfo);
+ /////
+ ///// 烘干机螺旋频率设定
+ /////
+ /////
+ /////
+ //private void HotSpiralSpeedSet_Click(object sender, RoutedEventArgs e)
+ //{
+ // try
+ // {
+ // bool isValidSpeed1 = int.TryParse(HotSpiralSpeedTxt.Text, out int speed1);
- }
- }
- else
- {
- MessageBox.Show("请输入0到50之间的正整数!");
- }
+ // // 校验输入的整数是否在0到50之间且大于0
+ // if (isValidSpeed1 && speed1 > 0 && speed1 <= 50)
+ // {
+ // var result = MessageBox.Show("是否确认更改?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
+ // if (result == MessageBoxResult.Yes)
+ // {
+ // List configInfos = _configInfoBusiness.GetConfigInfos();
+ // BaseConfigInfo configInfo = configInfos.Where(x => x.ConfigKey == "烘干机螺旋频率设定值").FirstOrDefault();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex.Message);
- }
- }
+ // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋频率设定"), speed1);
- private void UnpackSetButton_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- // bool isValidSpeed1 = int.TryParse(UnpackSet1Txt.Text, out int speed1) && speed1 >= 0 && speed1 <= 50;
- // bool isValidSpeed2 = int.TryParse(UnpackSet2Txt.Text, out int speed2) && speed2 >= 0 && speed2 <= 50;
- bool isValidSpeed3 = int.TryParse(UnpackSet3Txt.Text, out int speed3) && speed3 >= 0 && speed3 <= 50;
- bool isValidSpeed4 = int.TryParse(UnpackSet4Txt.Text, out int speed4) && speed4 >= 0 && speed4 <= 50;
- // bool isValidSpeed5 = int.TryParse(UnpackSet5Txt.Text, out int speed5) && speed5 >= 0 && speed5 <= 50;
+ // configInfo.ConfigValue = HotSpiralSpeedTxt.Text;
+ // _configInfoBusiness.UpdateConfigInfo(configInfo);
- if ( isValidSpeed3 && isValidSpeed4 )
- {
+ // }
+ // }
+ // else
+ // {
+ // MessageBox.Show("请输入0到50之间的正整数!");
+ // }
- var result = MessageBox.Show("是否确认更改?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
- if (result == MessageBoxResult.Yes)
- {
+ // }
+ // catch (Exception ex)
+ // {
+ // _logger.LogError(ex.Message);
+ // }
+ //}
+ //private void UnpackSetButton_Click(object sender, RoutedEventArgs e)
+ //{
+ // try
+ // {
+ // // bool isValidSpeed1 = int.TryParse(UnpackSet1Txt.Text, out int speed1) && speed1 >= 0 && speed1 <= 50;
+ // // bool isValidSpeed2 = int.TryParse(UnpackSet2Txt.Text, out int speed2) && speed2 >= 0 && speed2 <= 50;
+ // bool isValidSpeed3 = int.TryParse(UnpackSet3Txt.Text, out int speed3) && speed3 >= 0 && speed3 <= 50;
+ // bool isValidSpeed4 = int.TryParse(UnpackSet4Txt.Text, out int speed4) && speed4 >= 0 && speed4 <= 50;
+ // // bool isValidSpeed5 = int.TryParse(UnpackSet5Txt.Text, out int speed5) && speed5 >= 0 && speed5 <= 50;
- //频率设定
- // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机翻转机频率设定"), speed1);
- // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机滚筒筛频率设定"), speed2);
- plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋1频率设定"), speed3);
- plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋2频率设定"), speed4);
- // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机废袋机频率设定"), speed5);
-
- List configInfos = _configInfoBusiness.GetConfigInfos();
- // BaseConfigInfo configInfo1 = configInfos.Where(x => x.ConfigKey == "拆包机翻转机频率设定值").FirstOrDefault();
- // BaseConfigInfo configInfo2 = configInfos.Where(x => x.ConfigKey == "拆包机滚筒筛频率设定值").FirstOrDefault();
- BaseConfigInfo configInfo3 = configInfos.Where(x => x.ConfigKey == "拆包机螺旋1频率设定值").FirstOrDefault();
- BaseConfigInfo configInfo4 = configInfos.Where(x => x.ConfigKey == "拆包机螺旋2频率设定值").FirstOrDefault();
- // BaseConfigInfo configInfo5 = configInfos.Where(x => x.ConfigKey == "拆包机废袋机频率设定值").FirstOrDefault();
- // configInfo1.ConfigValue = UnpackSet1Txt.Text;
- // configInfo2.ConfigValue = UnpackSet2Txt.Text;
- configInfo3.ConfigValue = UnpackSet3Txt.Text;
- configInfo4.ConfigValue = UnpackSet4Txt.Text;
- // configInfo5.ConfigValue = UnpackSet5Txt.Text;
- // _configInfoBusiness.UpdateConfigInfo(configInfo1);
- // _configInfoBusiness.UpdateConfigInfo(configInfo2);
- _configInfoBusiness.UpdateConfigInfo(configInfo3);
- _configInfoBusiness.UpdateConfigInfo(configInfo4);
- // _configInfoBusiness.UpdateConfigInfo(configInfo5);
- }
- }
- else
- {
- MessageBox.Show("请输入0到50之间的正整数!");
- }
- }
- catch (Exception ex)
- {
- _logger.LogError(ex.Message);
- }
+ // if ( isValidSpeed3 && isValidSpeed4 )
+ // {
+ // var result = MessageBox.Show("是否确认更改?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
+ // if (result == MessageBoxResult.Yes)
+ // {
- }
- private void AmountChangeButton_Click(object sender, RoutedEventArgs e)
- {
- BagsAmountSetWindow window = new BagsAmountSetWindow();
- window.ShowDialog();
- }
+ // //频率设定
+ // // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机翻转机频率设定"), speed1);
+ // // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机滚筒筛频率设定"), speed2);
+ // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋1频率设定"), speed3);
+ // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋2频率设定"), speed4);
+ // // plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机废袋机频率设定"), speed5);
+
+ // List configInfos = _configInfoBusiness.GetConfigInfos();
+ // // BaseConfigInfo configInfo1 = configInfos.Where(x => x.ConfigKey == "拆包机翻转机频率设定值").FirstOrDefault();
+ // // BaseConfigInfo configInfo2 = configInfos.Where(x => x.ConfigKey == "拆包机滚筒筛频率设定值").FirstOrDefault();
+ // BaseConfigInfo configInfo3 = configInfos.Where(x => x.ConfigKey == "拆包机螺旋1频率设定值").FirstOrDefault();
+ // BaseConfigInfo configInfo4 = configInfos.Where(x => x.ConfigKey == "拆包机螺旋2频率设定值").FirstOrDefault();
+ // // BaseConfigInfo configInfo5 = configInfos.Where(x => x.ConfigKey == "拆包机废袋机频率设定值").FirstOrDefault();
+ // // configInfo1.ConfigValue = UnpackSet1Txt.Text;
+ // // configInfo2.ConfigValue = UnpackSet2Txt.Text;
+ // configInfo3.ConfigValue = UnpackSet3Txt.Text;
+ // configInfo4.ConfigValue = UnpackSet4Txt.Text;
+ // // configInfo5.ConfigValue = UnpackSet5Txt.Text;
+ // // _configInfoBusiness.UpdateConfigInfo(configInfo1);
+ // // _configInfoBusiness.UpdateConfigInfo(configInfo2);
+ // _configInfoBusiness.UpdateConfigInfo(configInfo3);
+ // _configInfoBusiness.UpdateConfigInfo(configInfo4);
+ // // _configInfoBusiness.UpdateConfigInfo(configInfo5);
+ // }
+ // }
+ // else
+ // {
+ // MessageBox.Show("请输入0到50之间的正整数!");
+ // }
+
+ // }
+ // catch (Exception ex)
+ // {
+ // _logger.LogError(ex.Message);
+ // }
+
+
+ //}
+
///
/// 烘干机温度设定
@@ -1334,5 +1558,9 @@ namespace SlnMesnac.WPF.Page
// _logger.LogError(ex.Message);
// }
//}
+ #endregion
+
+
+
}
}
diff --git a/SlnMesnac.WPF/Page/RecipeManagePage.xaml b/SlnMesnac.WPF/Page/RecipeManagePage.xaml
index c119733..79582fa 100644
--- a/SlnMesnac.WPF/Page/RecipeManagePage.xaml
+++ b/SlnMesnac.WPF/Page/RecipeManagePage.xaml
@@ -7,7 +7,6 @@
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent">
-
@@ -15,30 +14,87 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
@@ -53,7 +109,7 @@
-
+
@@ -72,7 +128,7 @@
-->
-
+
diff --git a/SlnMesnac.WPF/Page/RecipeManagePage.xaml.cs b/SlnMesnac.WPF/Page/RecipeManagePage.xaml.cs
index a09f84e..228d656 100644
--- a/SlnMesnac.WPF/Page/RecipeManagePage.xaml.cs
+++ b/SlnMesnac.WPF/Page/RecipeManagePage.xaml.cs
@@ -5,6 +5,7 @@ using SlnMesnac.Business;
using SlnMesnac.Business.@base;
using SlnMesnac.Model.domain;
using SlnMesnac.Plc;
+using SlnMesnac.WPF.Model;
using SlnMesnac.WPF.ViewModel;
using System;
using System.Collections.Generic;
@@ -32,22 +33,114 @@ namespace SlnMesnac.WPF.Page
public partial class RecipeManagePage : UserControl
{
private BaseBusiness baseBusiness = null;
-
-
-
-
-
-
+ private RecipeManageCache recipeManageCache = RecipeManageCache.Instance;
public RecipeManagePage()
{
-
InitializeComponent();
this.DataContext = new RecipeManageViewModel();
+ InitWeightInfo();
+ }
+
+ ///
+ /// 加载重量及时间
+ ///
+ private void InitWeightInfo()
+ {
+ highSpeed1.Text = recipeManageCache.recipeManageList.FirstOrDefault(x => x.RecipeName == "高速配方").LowWeight.ToString();
+ highSpeed2.Text = recipeManageCache.recipeManageList.FirstOrDefault(x => x.RecipeName == "高速配方").HightWeight.ToString();
+
+ midiumSpeed1.Text = recipeManageCache.recipeManageList.FirstOrDefault(x => x.RecipeName == "中速配方").LowWeight.ToString();
+ midiumSpeed2.Text = recipeManageCache.recipeManageList.FirstOrDefault(x => x.RecipeName == "中速配方").HightWeight.ToString();
+
+ lowSpeed1.Text = recipeManageCache.recipeManageList.FirstOrDefault(x => x.RecipeName == "低速配方").LowWeight.ToString();
+ lowSpeed2.Text = recipeManageCache.recipeManageList.FirstOrDefault(x => x.RecipeName == "低速配方").HightWeight.ToString();
+ UnpackToHotTime.Text = recipeManageCache.UnpackToHotTime;
+ HotToSpiralTime.Text = recipeManageCache.HotToSpiralTime;
+ SpiralTwoTime.Text = recipeManageCache.SpiralTwoTime;
+ }
+
+ private void updateWeight_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ // 创建变量来存储转换后的整数值
+ int highSpeed1Value, highSpeed2Value;
+ int midiumSpeed1Value, midiumSpeed2Value;
+ int lowSpeed1Value, lowSpeed2Value;
+ // 从文本框中获取文本并尝试转换为整数
+ if (int.TryParse(highSpeed1.Text, out highSpeed1Value) &&
+ int.TryParse(highSpeed2.Text, out highSpeed2Value) &&
+ int.TryParse(midiumSpeed1.Text, out midiumSpeed1Value) &&
+ int.TryParse(midiumSpeed2.Text, out midiumSpeed2Value) &&
+ int.TryParse(lowSpeed1.Text, out lowSpeed1Value) &&
+ int.TryParse(lowSpeed2.Text, out lowSpeed2Value))
+ {
+ // 校验是否所有的整数值都大于0
+ if (highSpeed1Value >= 0 && highSpeed2Value >= 0 &&
+ midiumSpeed1Value >= 0 && midiumSpeed2Value >= 0 &&
+ lowSpeed1Value >= 0 && lowSpeed2Value >= 0)
+ {
+ RecipeManage highRecipe = recipeManageCache.recipeManageList.FirstOrDefault(x => x.RecipeName == "高速配方");
+ RecipeManage midiumRecipe = recipeManageCache.recipeManageList.FirstOrDefault(x => x.RecipeName == "中速配方");
+ RecipeManage lowRecipe = recipeManageCache.recipeManageList.FirstOrDefault(x => x.RecipeName == "低速配方");
+ highRecipe.LowWeight = highSpeed1Value;
+ highRecipe.HightWeight = highSpeed2Value;
+ recipeManageCache.UpdateRecipeManage(highRecipe);
+ midiumRecipe.LowWeight = midiumSpeed1Value;
+ midiumRecipe.HightWeight = midiumSpeed2Value;
+ recipeManageCache.UpdateRecipeManage(midiumRecipe);
+ midiumRecipe.LowWeight = midiumSpeed1Value;
+ lowRecipe.LowWeight = lowSpeed1Value;
+ lowRecipe.HightWeight = lowSpeed2Value;
+ recipeManageCache.UpdateRecipeManage(lowRecipe);
+ MessageBox.Show("更新成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ else
+ {
+ MessageBox.Show("所有的重量值必须大于等于0", "输入错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+ else
+ {
+ // 转换失败,提示用户
+ MessageBox.Show("请确保所有输入值都是有效的整数", "输入错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }catch (Exception ex)
+ {
+ Console.WriteLine(ex.Message);
+ }
}
+ private void updateSpiralTime_Click(object sender, RoutedEventArgs e)
+ {
+
+ int unpackToHotTimeValue;
+ int hotToSpiralTimeValue;
+ int spiralTwoTimeValue;
+
+
+ bool unpackToHotTimeValid = int.TryParse(UnpackToHotTime.Text, out unpackToHotTimeValue);
+ bool hotToSpiralTimeValid = int.TryParse(HotToSpiralTime.Text, out hotToSpiralTimeValue);
+ bool spiralTwoTimeValid = int.TryParse(SpiralTwoTime.Text, out spiralTwoTimeValue);
+
+
+ if (unpackToHotTimeValid && hotToSpiralTimeValid && spiralTwoTimeValid &&
+ unpackToHotTimeValue >= 0 && hotToSpiralTimeValue >= 0 && spiralTwoTimeValue >= 0)
+ {
+ recipeManageCache.UnpackToHotTime = UnpackToHotTime.Text;
+ recipeManageCache.HotToSpiralTime = HotToSpiralTime.Text;
+ recipeManageCache.SpiralTwoTime = SpiralTwoTime.Text;
+ MessageBox.Show("更新成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ else
+ {
+
+ MessageBox.Show("请输入有效的正整数值(大于等于0)", "输入错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
}
}
diff --git a/SlnMesnac.WPF/Page/Window/RecipeManageSetWindow.xaml b/SlnMesnac.WPF/Page/Window/RecipeManageSetWindow.xaml
index 5508c04..84c6322 100644
--- a/SlnMesnac.WPF/Page/Window/RecipeManageSetWindow.xaml
+++ b/SlnMesnac.WPF/Page/Window/RecipeManageSetWindow.xaml
@@ -5,8 +5,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SlnMesnac.WPF.Page"
mc:Ignorable="d"
- Title="配方设置" Height="550" Width="600" WindowStartupLocation="CenterScreen" Topmost="True" Background="Blue">
-
+ Title="配方设置" Height="550" Width="600" WindowStartupLocation="CenterScreen" Topmost="True" Background="#73B0F5">
+
diff --git a/SlnMesnac.WPF/Page/Window/RecipeModeSetWindow.xaml b/SlnMesnac.WPF/Page/Window/RecipeModeSetWindow.xaml
new file mode 100644
index 0000000..2a9d061
--- /dev/null
+++ b/SlnMesnac.WPF/Page/Window/RecipeModeSetWindow.xaml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SlnMesnac.WPF/Page/Window/RecipeModeSetWindow.xaml.cs b/SlnMesnac.WPF/Page/Window/RecipeModeSetWindow.xaml.cs
new file mode 100644
index 0000000..c0e1c58
--- /dev/null
+++ b/SlnMesnac.WPF/Page/Window/RecipeModeSetWindow.xaml.cs
@@ -0,0 +1,73 @@
+using Microsoft.Extensions.DependencyInjection;
+using Quartz.Util;
+using SlnMesnac.Business;
+using SlnMesnac.Model.domain;
+using SlnMesnac.WPF.Model;
+using SlnMesnac.WPF.ViewModel;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace SlnMesnac.WPF.Page
+{
+ ///
+ ///
+ ///
+ public partial class RecipeModeSetWindow : Window
+ {
+ private RecipeManageCache recipeManageCache = RecipeManageCache.Instance;
+
+
+ ///
+ /// 手动修改配方
+ ///
+ public delegate Task ManualChangeRecipe(RecipeManage targetRecipe);
+ public static event ManualChangeRecipe? ManualChangeRecipeEvent;
+
+
+ public RecipeModeSetWindow()
+ {
+ InitializeComponent();
+ }
+
+
+ private async void ChangeRecipeButton_Click(object sender, RoutedEventArgs e)
+ {
+ var button = sender as Button;
+ if (button != null)
+ {
+ var tag = button.Tag as string;
+ var result = MessageBox.Show($"是否确认切换为手动模式---{tag},系统当前{recipeManageCache.RecipeMode}---{recipeManageCache.RecipeName}", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
+ if(result == MessageBoxResult.Yes)
+ {
+ // 调用委托在设备监控界面发送PLC频率
+ this.Close();
+ bool? changeResult = await ManualChangeRecipeEvent?.Invoke(recipeManageCache.recipeManageList.FirstOrDefault(x=>x.RecipeName==tag));
+ //if(changeResult.HasValue && changeResult.Value)
+ //{
+ // // MessageBox.Show("配方切换成功");
+ // recipeManageCache.RecipeMode = "手动模式";
+
+ //}
+ //else
+ //{
+ // MessageBox.Show("配方切换失败");
+ //}
+ //MessageBox.Show("配方切换成功");
+
+ }
+
+ }
+ }
+ }
+}
diff --git a/SlnMesnac.WPF/SlnMesnac.WPF.csproj b/SlnMesnac.WPF/SlnMesnac.WPF.csproj
index 9672321..b4d33a6 100644
--- a/SlnMesnac.WPF/SlnMesnac.WPF.csproj
+++ b/SlnMesnac.WPF/SlnMesnac.WPF.csproj
@@ -48,6 +48,9 @@
+
+ Code
+
Code
diff --git a/SlnMesnac.WPF/Templates/style/resourceStyle.xaml b/SlnMesnac.WPF/Templates/style/resourceStyle.xaml
index 0f7369e..81a57b6 100644
--- a/SlnMesnac.WPF/Templates/style/resourceStyle.xaml
+++ b/SlnMesnac.WPF/Templates/style/resourceStyle.xaml
@@ -137,6 +137,12 @@
+
+
+
+
+
+
diff --git a/SlnMesnac.WPF/ViewModel/RecipeManageViewModel.cs b/SlnMesnac.WPF/ViewModel/RecipeManageViewModel.cs
index feb5afe..6d62a13 100644
--- a/SlnMesnac.WPF/ViewModel/RecipeManageViewModel.cs
+++ b/SlnMesnac.WPF/ViewModel/RecipeManageViewModel.cs
@@ -1,6 +1,7 @@
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
using SlnMesnac.Business;
using SlnMesnac.Business.@base;
using SlnMesnac.Model.domain;
@@ -16,6 +17,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using System.Timers;
using System.Windows;
#region << 版 本 注 释 >>
@@ -53,20 +55,51 @@ namespace SlnMesnac.WPF.ViewModel
private RecipeManageCache recipeManageCache = RecipeManageCache.Instance;
+ private System.Timers.Timer refreshWeightTimer = new System.Timers.Timer(1000 * 5);
+
+ private readonly ILogger _logger;
///
- /// 修改配方
+ /// 修改配方按钮
///
public RelayCommand UpdateRecipeCommand { get; set; }
+ ///
+ /// 手自动模式切换按钮
+ ///
+ public RelayCommand ModeChangeCommand { get; set; }
+
+
+
+
public RecipeManageViewModel()
{
+ _logger = App.ServiceProvider.GetService>();
+
baseBusiness = App.ServiceProvider.GetService();
UpdateRecipeCommand = new RelayCommand(obj => UpdateRecipe(obj));
+ ModeChangeCommand = new RelayCommand(obj => ModeChange(obj));
RrfreshDataGrid();
+
+ refreshWeightTimer.Elapsed += new System.Timers.ElapsedEventHandler(RefreshWeight);
+ refreshWeightTimer.AutoReset = true;
+ refreshWeightTimer.Enabled = true;
+ refreshWeightTimer.Start();
+
+
}
- public void RrfreshDataGrid()
+ private void RefreshWeight(object? sender, ElapsedEventArgs e)
{
+ BufferWeight = recipeManageCache.BufferWeight.ToString("F2");
+ RecipeName = recipeManageCache.RecipeName;
+ RecipeMode = recipeManageCache.RecipeMode;
+ }
+
+ public void RrfreshDataGrid()
+ {
+ BufferWeight = recipeManageCache.BufferWeight.ToString("F2");
+ RecipeName = recipeManageCache.RecipeName;
+ RecipeMode = recipeManageCache.RecipeMode;
List list = recipeManageCache.recipeManageList;
if (list != null && list.Count > 0)
{
@@ -90,17 +123,79 @@ namespace SlnMesnac.WPF.ViewModel
set { recipeDataGrid = value; RaisePropertyChanged(() => RecipeDataGrid); }
}
+
+ //缓存区重量
+ private string bufferWeight = string.Empty;
+ public string BufferWeight
+ {
+ get { return bufferWeight; }
+ set { bufferWeight = value; RaisePropertyChanged(() => BufferWeight); }
+ }
+
+ //当前配方
+ private string recipeName = string.Empty;
+ public string RecipeName
+ {
+ get { return recipeName; }
+ set { recipeName = value; RaisePropertyChanged(() => RecipeName); }
+ }
+
+ //运行模式
+ private string recipeMode = string.Empty;
+ public string RecipeMode
+ {
+ get { return recipeMode; }
+ set { recipeMode = value; RaisePropertyChanged(() => RecipeMode); }
+ }
+
#endregion
+ ///
+ /// 更新配方
+ ///
+ ///
public void UpdateRecipe(int RecipeKey)
{
RecipeManageSetWindow window = new RecipeManageSetWindow(RecipeKey);
window.ShowDialog();
RrfreshDataGrid();
+ }
+ ///
+ /// 模式切换
+ ///
+ ///
+ public void ModeChange(string param)
+ {
+ try
+ {
+ //切换自动模式
+ if ("auto".Equals(param))
+ {
+ var result = MessageBox.Show("是否确认切换自动模式?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
+ if (result == MessageBoxResult.Yes)
+ {
+ recipeManageCache.RecipeMode = "自动模式";
+ RecipeMode = "自动模式";
+ }
+ }
+ else if ("manual".Equals(param))
+ {
+ RecipeModeSetWindow window = new RecipeModeSetWindow();
+ window.ShowDialog();
+ }
+ RecipeName = recipeManageCache.RecipeName;
+ RecipeMode = recipeManageCache.RecipeMode;
+
+ }catch (Exception ex)
+ {
+ _logger.LogError("ModeChange异常:" + ex.Message);
+ }
}
+
+
}
}