add-添加配方动态变化

dev
liuwf 7 months ago
parent f7cb19a23c
commit ab610c56bb

@ -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)
{

@ -27,14 +27,61 @@ namespace SlnMesnac.Config
}
/// <summary>
///上次投料时间
///缓存区重量
/// </summary>
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); }
}
/// <summary>
///系统当前使用配方模版
/// </summary>
public string RecipeName
{
get { return iniHelper.IniReadValue("system", "RecipeName"); }
set { iniHelper.IniWriteValue("system", "RecipeName", value); }
}
/// <summary>
///配方运行模式
/// </summary>
public string RecipeMode
{
get { return iniHelper.IniReadValue("system", "RecipeMode"); }
set { iniHelper.IniWriteValue("system", "RecipeMode", value); }
}
/// <summary>
///拆包机螺旋--烘干机螺旋切换间隔(单位:ms)
/// </summary>
public string UnpackToHotTime
{
get { return iniHelper.IniReadValue("system", "UnpackToHotTime"); }
set { iniHelper.IniWriteValue("system", "UnpackToHotTime", value); }
}
/// <summary>
///烘干机螺旋--螺旋1切换间隔(单位:ms)
/// </summary>
public string HotToSpiralTime
{
get { return iniHelper.IniReadValue("system", "HotToSpiralTime"); }
set { iniHelper.IniWriteValue("system", "HotToSpiralTime", value); }
}
/// <summary>
///#螺旋1--螺旋2切换间隔(单位:ms)
/// </summary>
public string SpiralTwoTime
{
get { return iniHelper.IniReadValue("system", "SpiralTwoTime"); }
set { iniHelper.IniWriteValue("system", "SpiralTwoTime", value); }
}
/// <summary>
///喷码机IP
/// </summary>

@ -34,49 +34,49 @@ namespace SlnMesnac.Model.domain
public class RecipeManage
{
/// <summary>
/// 配方Id
/// 配方Id频率
/// </summary>
[SugarColumn(ColumnName = "obj_id", IsPrimaryKey = true, IsIdentity = true)]
public int ObjId { get; set; }
/// <summary>
/// 配方Key
/// 配方Key频率
/// </summary>
[SugarColumn(ColumnName = "recipe_key")]
public int RecipeKey { get; set; }
/// <summary>
/// 配方名称
/// 配方名称频率
/// </summary>
[SugarColumn(ColumnName = "recipe_name")]
public string RecipeName { get; set; }
/// <summary>
/// 拆包机螺旋1
/// 拆包机螺旋1频率
/// </summary>
[SugarColumn(ColumnName = "unpack_spiral1")]
public int UnpackSpiral1 { get; set; }
/// <summary>
/// 拆包机螺旋2
/// 拆包机螺旋2频率
/// </summary>
[SugarColumn(ColumnName = "unpack_spiral2")]
public int UnpackSpiral2 { get; set; }
/// <summary>
/// 烘干机螺旋
/// 烘干机螺旋频率
/// </summary>
[SugarColumn(ColumnName = "dryer_spiral")]
public int DryerSpiral { get; set; }
/// <summary>
/// 螺旋机螺旋1
/// 螺旋机螺旋1频率
/// </summary>
[SugarColumn(ColumnName = "spiral1")]
public int Spiral1 { get; set; }
/// <summary>
/// 螺旋机螺旋2
/// 螺旋机螺旋2频率
/// </summary>
[SugarColumn(ColumnName = "spiral2")]
public int Spiral2 { get; set; }

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace SlnMesnac.WPF.Model
{
/// <summary>
/// 烘干机采集参数
/// 采集实体参数
/// </summary>
public class PLCMachineModel
{

@ -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<RecipeManageCache> _logger;
private DebugConfig config = DebugConfig.Instance;
private readonly IBaseRecipeManageService? baseRecipeManageService;
public List<RecipeManage> recipeManageList = null;
/// <summary>
/// 所有配方列表
/// </summary>
public List<RecipeManage> recipeManageList = null;
/// <summary>
/// 当前正在使用配方
/// </summary>
public RecipeManage useRecipeManage
{
get
{
if (recipeManageList != null)
{
return recipeManageList.FirstOrDefault(x => x.RecipeName == config.RecipeName);
}
else
{
return null;
}
}
}
/// <summary>
/// 当前监测重量
/// </summary>
public double BufferWeight {
get { return double.Parse(config.BufferWeight); }
set { config.BufferWeight = value.ToString(); }
}
/// <summary>
/// 当前使用模版名称
/// </summary>
public string RecipeName
{
get { return config.RecipeName; }
set { config.RecipeName = value; }
}
/// <summary>
/// 当前使用模式
/// </summary>
public string RecipeMode
{
get { return config.RecipeMode; }
set { config.RecipeMode = value; }
}
/// <summary>
/// 拆包机螺旋--烘干机螺旋切换间隔(单位:ms)
/// </summary>
public string UnpackToHotTime
{
get { return config.UnpackToHotTime; }
set { config.UnpackToHotTime = value; }
}
/// <summary>
/// 烘干机螺旋--螺旋1切换间隔(单位:ms)
/// </summary>
public string HotToSpiralTime
{
get { return config.HotToSpiralTime; }
set { config.HotToSpiralTime = value; }
}
/// <summary>
/// 螺旋1--螺旋2切换间隔(单位:ms)
/// </summary>
public string SpiralTwoTime
{
get { return config.SpiralTwoTime; }
set { config.SpiralTwoTime = value; }
}
#endregion

@ -6,7 +6,8 @@
xmlns:local="clr-namespace:SlnMesnac.WPF.Page"
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent">
<Grid >
<Grid.RowDefinitions>
@ -151,13 +152,13 @@
<TextBox x:Name="UnpackSet1Txt" Text="0.00" Width="70" Height="35" FontSize="20" VerticalAlignment="Center" Margin="10,0,0,0" Foreground="White"/>
<TextBlock Text="滚筒筛:" FontSize="20" VerticalAlignment="Center" Margin="5,0,5,0" Foreground="White"/>
<TextBox x:Name="UnpackSet2Txt" Text="0.00" Width="70" Height="35" FontSize="20" VerticalAlignment="Center" Margin="0,0,10,0" Foreground="White"/>-->
<TextBlock Text="螺旋1:" FontSize="20" VerticalAlignment="Center" Margin="5,0,5,0" Foreground="White"/>
<!--<TextBlock Text="螺旋1:" FontSize="20" VerticalAlignment="Center" Margin="5,0,5,0" Foreground="White"/>
<TextBox x:Name="UnpackSet3Txt" Text="0.00" Width="70" Height="35" FontSize="20" VerticalAlignment="Center" Margin="0,0,10,0" Foreground="White"/>
<TextBlock Text="螺旋2:" FontSize="20" VerticalAlignment="Center" Margin="5,0,5,0" Foreground="White"/>
<TextBox x:Name="UnpackSet4Txt" Text="0.00" Width="70" Height="35" FontSize="20" VerticalAlignment="Center" Margin="0,0,10,0" Foreground="White"/>
<!--<TextBlock Text="滚筒筛:" FontSize="20" VerticalAlignment="Center" Margin="5,0,5,0" Foreground="White"/>
<TextBox x:Name="UnpackSet5Txt" Text="0.00" Width="70" Height="35" FontSize="20" VerticalAlignment="Center" Margin="0,0,10,0" Foreground="White"/>-->
<Button x:Name="UnpackSetButton" Content="频率设定(0-50HZ)" FontSize="20" Width="170" Height="40" VerticalAlignment="Center" Margin="0,0,0,0" Background="Blue" Click="UnpackSetButton_Click" />
--><!--<TextBlock Text="滚筒筛:" FontSize="20" VerticalAlignment="Center" Margin="5,0,5,0" Foreground="White"/>
<TextBox x:Name="UnpackSet5Txt" Text="0.00" Width="70" Height="35" FontSize="20" VerticalAlignment="Center" Margin="0,0,10,0" Foreground="White"/>--><!--
<Button x:Name="UnpackSetButton" Content="频率设定(0-50HZ)" FontSize="20" Width="170" Height="40" VerticalAlignment="Center" Margin="0,0,0,0" Background="Blue" Click="UnpackSetButton_Click" />-->
</StackPanel>
<StackPanel Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Horizontal" >
@ -275,8 +276,8 @@
</Grid>
<StackPanel Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Horizontal" >
<TextBox x:Name="HotSpiralSpeedTxt" Width="70" Height="35" FontSize="20" VerticalAlignment="Center" Margin="30,0,10,0" Foreground="White"/>
<Button x:Name="HotSpiralSpeedSet" Content="螺旋频率设定" FontSize="20" Width="150" Height="40" VerticalAlignment="Center" Margin="0,0,20,0" Background="Blue" Click="HotSpiralSpeedSet_Click" />
<!--<TextBox x:Name="HotSpiralSpeedTxt" Width="70" Height="35" FontSize="20" VerticalAlignment="Center" Margin="30,0,10,0" Foreground="White"/>
<Button x:Name="HotSpiralSpeedSet" Content="螺旋频率设定" FontSize="20" Width="150" Height="40" VerticalAlignment="Center" Margin="0,0,20,0" Background="Blue" Click="HotSpiralSpeedSet_Click" />-->
<Button x:Name="StartDryerSpiralButton" Content="螺旋启动" FontSize="20" Background="LimeGreen" Width="120" Height="40" Margin="0 0 20 0" Click="StartDryerSpiralButton_Click"/>
<Button x:Name="StartDryerFanButton" Content="风机启动" FontSize="20" Background="LimeGreen" Width="90" Height="40" Margin="0 0 20 0" Click="StartDryerFanButton_Click"/>
<Button x:Name="StartDryerHotButton" Content="燃烧启动" FontSize="20" Background="LimeGreen" Width="90" Height="40" Margin="0 0 20 0" Click="StartDryerHotButton_Click"/>
@ -393,11 +394,11 @@
</StackPanel>
</Grid>
<StackPanel Grid.Row="2" VerticalAlignment="Top" Orientation="Horizontal" >
<TextBox x:Name="Speed1Txt" Text="0.00" Width="70" Height="35" FontSize="20" VerticalAlignment="Center" Margin="10,0,0,0" Foreground="White"/>
<StackPanel Grid.Row="2" VerticalAlignment="Top" Orientation="Horizontal" HorizontalAlignment="Center">
<!--<TextBox x:Name="Speed1Txt" Text="0.00" Width="70" Height="35" FontSize="20" VerticalAlignment="Center" Margin="10,0,0,0" Foreground="White"/>
<TextBlock Text="/" FontSize="20" VerticalAlignment="Center" Margin="5,0,5,0" Foreground="White"/>
<TextBox x:Name="Speed2Txt" Text="0.00" Width="70" Height="35" FontSize="20" VerticalAlignment="Center" Margin="0,0,10,0" Foreground="White"/>
<Button x:Name="SpiralSpeed" Content="螺旋1/2频率设定(0-50HZ)" FontSize="20" Width="250" Height="40" VerticalAlignment="Center" Margin="0,0,20,0" Background="Blue" Click="SpiralSpeed_Click" />
<Button x:Name="SpiralSpeed" Content="螺旋1/2频率设定(0-50HZ)" FontSize="20" Width="250" Height="40" VerticalAlignment="Center" Margin="0,0,20,0" Background="Blue" Click="SpiralSpeed_Click" />-->
<Button x:Name="StartSpiral1Button" Content="螺旋1启动" FontSize="20" Background="LimeGreen" Width="100" Height="40" Margin="30 0 10 0" Click="StartSpiral1Button_Click"/>
<Button x:Name="StartSpiral2Button" Content="螺旋2启动" FontSize="20" Background="LimeGreen" Width="100" Height="40" Margin="0 0 10 0" Click="StartSpiral2Button_Click"/>

@ -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<DevMonitorPage> _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<ILogger<DevMonitorPage>>();
_configInfoBusiness = App.ServiceProvider.GetService<ConfigInfoBusiness>();
@ -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<BaseConfigInfo> 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 监测缓存区重量,动态调整配方频率
/// <summary>
/// 开始启动监测缓存区重量,动态调整配方频率
/// </summary>
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}");
}
}
});
}
/// <summary>
/// 判断缓存区重量是否满足配方要求
/// </summary>
/// <returns>-1,重量未匹配到目标配方,报警</returns>
/// <returns>0,无需更改配方</returns>
/// <returns>1,从高速模版切换到低速模版</returns>
/// <returns>2,从低速模版切换到高速模版</returns>
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;
}
}
/// <summary>
/// 螺旋配方从高速切到低速从前往后拆包机、烘干、螺旋1螺旋2
/// </summary>
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;
}
}
/// <summary>
/// 螺旋配方从低速切到高速从后往前螺旋2、螺旋1、烘干、拆包机
/// </summary>
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<bool> 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 设备启动、停止
/// <summary>
@ -168,11 +384,13 @@ namespace SlnMesnac.WPF.Page
/// <param name="e"></param>
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;
}
/// <summary>
/// 烘干机燃烧启动/前提check:烘干机风机启动
/// </summary>
@ -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
}
/// <summary>
/// 螺旋机参数监控
/// </summary>
@ -1141,159 +1359,165 @@ namespace SlnMesnac.WPF.Page
MessageBox.Show(message);
}
/// <summary>
/// 螺旋速度设定
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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<BaseConfigInfo> 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之间的正整数");
}
///// <summary>
///// 螺旋速度设定
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//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<BaseConfigInfo> configInfos = _configInfoBusiness.GetConfigInfos();
// BaseConfigInfo configInfo1 = configInfos.Where(x => x.ConfigKey == "螺旋1速度设定值").FirstOrDefault();
// BaseConfigInfo configInfo2 = configInfos.Where(x => x.ConfigKey == "螺旋2速度设定值").FirstOrDefault();
/// <summary>
/// 烘干机螺旋频率设定
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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<BaseConfigInfo> 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);
///// <summary>
///// 烘干机螺旋频率设定
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//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<BaseConfigInfo> 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<BaseConfigInfo> 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<BaseConfigInfo> 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);
// }
//}
/// <summary>
/// 烘干机温度设定
@ -1334,5 +1558,9 @@ namespace SlnMesnac.WPF.Page
// _logger.LogError(ex.Message);
// }
//}
#endregion
}
}

@ -7,7 +7,6 @@
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent">
<Grid >
<Grid.RowDefinitions>
@ -15,30 +14,87 @@
<RowDefinition Height="4*"/>
<RowDefinition Height="3.5*"/>
</Grid.RowDefinitions>
<Border Grid.Row="2" BorderThickness="1" BorderBrush="Green">
<Border Grid.Row="0" BorderBrush="CadetBlue" BorderThickness="0.6" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.0*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock Text="缓存区重量:" FontSize="32" Foreground="White" />
<TextBox Text="{Binding BufferWeight}" FontSize="32" Foreground="White" IsReadOnly="True"/>
</StackPanel>
<StackPanel Grid.Column="1" VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock Text="当前配方:" FontSize="32" Foreground="White" />
<TextBox Text="{Binding RecipeName}" FontSize="32" Foreground="White" IsReadOnly="True"/>
</StackPanel>
<StackPanel Grid.Column="2" VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock Text="运行模式:" FontSize="32" Foreground="White" />
<TextBox Text="{Binding RecipeMode}" FontSize="32" Foreground="White" IsReadOnly="True"/>
</StackPanel>
<StackPanel Grid.Column="3" VerticalAlignment="Center" Orientation="Horizontal">
<Button Command="{Binding ModeChangeCommand}" CommandParameter="auto" Style="{StaticResource BUTTON_AGREE}" Content="自动切换" FontSize="32" Background="ForestGreen" Width="200" Height="70" Margin="0 0 0 0" />
<Button Command="{Binding ModeChangeCommand}" CommandParameter="manual" Style="{StaticResource BUTTON_AGREE}" Content="手动切换" FontSize="32" Background="#C4D134" Width="200" Height="70" Margin="50 0 0 0" />
</StackPanel>
</Grid >
</Border>
<Border Grid.Row="1" BorderBrush="CadetBlue" BorderThickness="0.6" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" VerticalAlignment="Center" Orientation="Horizontal">
<TextBox x:Name="highSpeed1" FontSize="22" Width="120" Foreground="White" />
<TextBlock Text="=&lt;高速模版重量&lt;" FontSize="22" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBox x:Name="highSpeed2" FontSize="22" Width="120" Foreground="White" />
<TextBox x:Name="midiumSpeed1" FontSize="22" Width="120" Foreground="White" Margin="80 0 0 0" />
<TextBlock Text="=&lt;中速模版重量&lt;" FontSize="22" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBox x:Name="midiumSpeed2" FontSize="22" Width="120" Foreground="White" />
<TextBox x:Name="lowSpeed1" FontSize="22" Width="120" Foreground="White" Margin="80 0 0 0" />
<TextBlock Text="=&lt;低速模版重量&lt;" FontSize="22" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBox x:Name="lowSpeed2" FontSize="22" Width="120" Foreground="White" />
<Button x:Name="updateWeight" Style="{StaticResource BUTTON_AGREE}" Content="修改重量" FontSize="22" Background="ForestGreen" Width="200" Margin="50 0 0 0" Click="updateWeight_Click" />
</StackPanel>
<StackPanel Grid.Row="1" VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock Text="拆包机螺旋--烘干机螺旋切换间隔(单位:ms)" FontSize="22" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBox x:Name="UnpackToHotTime" FontSize="22" Width="120" Foreground="White" />
<TextBlock Text="烘干机螺旋--螺旋1切换间隔(单位:ms)" FontSize="22" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="50 0 0 0"/>
<TextBox x:Name="HotToSpiralTime" FontSize="22" Width="120" Foreground="White" />
<TextBlock Text="螺旋1--螺旋2切换间隔(单位:ms)" FontSize="22" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="50 0 0 0"/>
<TextBox x:Name="SpiralTwoTime" FontSize="22" Width="120" Foreground="White" />
<Button x:Name="updateSpiralTime" Style="{StaticResource BUTTON_AGREE}" Content="修改时间" FontSize="22" Background="ForestGreen" Width="200" Margin="50 0 0 0" Click="updateSpiralTime_Click" />
</StackPanel>
</Grid>
</Border>
<Border Grid.Row="2" BorderBrush="CadetBlue" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="0.8*"/>
<RowDefinition Height="6*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<TextBlock Text="配方管理" FontSize="30" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Text="配方管理" FontSize="30" FontWeight="Bold" Foreground="#0288d1" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<Grid Grid.Row="1">
<DataGrid Grid.Row="0" ItemsSource="{Binding RecipeDataGrid}" Background="Transparent" BorderThickness="1,0,1,1" BorderBrush="Green"
<DataGrid Grid.Row="0" ItemsSource="{Binding RecipeDataGrid}" Background="Transparent"
FontSize="22" ColumnHeaderHeight="55"
RowHeight="60" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden" CanUserAddRows="False" HorizontalAlignment="Center"
Foreground="#FFFFFF" >
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Setter Property="BorderBrush" Value="#FFDDDDDD"/>
<Setter Property="BorderThickness" Value="0,0.5,0,0.5"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Margin" Value="0,0,0,0"/>
</Style>
</DataGrid.RowStyle>
<!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding RecipeKey}" Header="配方编号" Width="*" IsReadOnly="True"/>
@ -53,7 +109,7 @@
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Content="修改" Style="{StaticResource BUTTON_AGREE}" CommandParameter="{Binding RecipeKey}" Background="#007DFA" Foreground="White" Margin="10,0,0,0" Height="45" BorderBrush="DeepSkyBlue" BorderThickness="0" Width="85" Command="{Binding DataContext.UpdateRecipeCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid }}"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
@ -72,7 +128,7 @@
<Button Grid.Row="0" Grid.Column="1" Style="{StaticResource BUTTON_AGREE}" Content="中速模版修改" FontSize="25" Background="Green" Width="180" Height="50" Margin="0,0,0,0" />
<Button Grid.Row="0" Grid.Column="2" Style="{StaticResource BUTTON_AGREE}" Content="高速模版修改" FontSize="25" Background="Green" Width="180" Height="50" Margin="0,0,0,0" />-->
</Grid>
</Border>
</Grid>

@ -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();
}
/// <summary>
/// 加载重量及时间
/// </summary>
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);
}
}
}
}

@ -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">
<Border Margin="5" Background="LightGoldenrodYellow" CornerRadius="10">
Title="配方设置" Height="550" Width="600" WindowStartupLocation="CenterScreen" Topmost="True" Background="#73B0F5">
<Border Margin="5" Background="Transparent" CornerRadius="10">
<Border.Effect>
<DropShadowEffect Color="LightGoldenrodYellow" ShadowDepth="0" BlurRadius="5" Opacity="0.3" Direction="0"></DropShadowEffect>
</Border.Effect>

@ -0,0 +1,32 @@
<Window x:Class="SlnMesnac.WPF.Page.RecipeModeSetWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SlnMesnac.WPF.Page"
mc:Ignorable="d"
Title="模式设置" Height="300" Width="700" WindowStartupLocation="CenterScreen" Topmost="True" Background="#73B0F5">
<Border Margin="5" Background="Transparent" CornerRadius="10">
<Border.Effect>
<DropShadowEffect Color="LightGoldenrodYellow" ShadowDepth="0" BlurRadius="5" Opacity="0.3" Direction="0"></DropShadowEffect>
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="手动切换配方选择" FontSize="26" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="10,0">
<Button Content="低速配方" FontSize="20" Style="{StaticResource BUTTON_AGREE}" Width="150" Height="50" Background="#41CF77" BorderBrush="#FF36B5C1" Margin="0,0,30,0" Click="ChangeRecipeButton_Click" Tag="低速配方" />
<Button Content="中速配方" FontSize="20" Style="{StaticResource BUTTON_AGREE}" Width="150" Height="50" Background="#41CF77" BorderBrush="#FF36B5C1" Margin="0,0,30,0" Click="ChangeRecipeButton_Click" Tag="中速配方" />
<Button Content="高速配方" FontSize="20" Style="{StaticResource BUTTON_AGREE}" Width="150" Height="50" Background="#41CF77" BorderBrush="#FF36B5C1" Margin="0,0,30,0" Click="ChangeRecipeButton_Click" Tag="高速配方" />
</StackPanel>
</Grid>
</Border>
</Window>

@ -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
{
/// <summary>
///
/// </summary>
public partial class RecipeModeSetWindow : Window
{
private RecipeManageCache recipeManageCache = RecipeManageCache.Instance;
/// <summary>
/// 手动修改配方
/// </summary>
public delegate Task<bool> 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("配方切换成功");
}
}
}
}
}

@ -48,6 +48,9 @@
</ItemGroup>
<ItemGroup>
<Compile Update="Page\Window\RecipeModeSetWindow.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Page\Window\RecipeManageSetWindow.xaml.cs">
<SubType>Code</SubType>
</Compile>

@ -137,6 +137,12 @@
<Label VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Foreground="White" Content="{TemplateBinding Content}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="bdr" Property="Background" Value="LightGray"/>
<Setter TargetName="bdr" Property="BorderBrush" Value="DarkGray"/>
<Setter TargetName="bdr" Property="Opacity" Value="1"/>
<Setter Property="Foreground" Value="DarkGray"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Trigger.EnterActions>
<BeginStoryboard >

@ -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<RecipeManageViewModel> _logger;
/// <summary>
/// 修改配方
/// 修改配方按钮
/// </summary>
public RelayCommand<int> UpdateRecipeCommand { get; set; }
/// <summary>
/// 手自动模式切换按钮
/// </summary>
public RelayCommand<string> ModeChangeCommand { get; set; }
public RecipeManageViewModel()
{
_logger = App.ServiceProvider.GetService<ILogger<RecipeManageViewModel>>();
baseBusiness = App.ServiceProvider.GetService<BaseBusiness>();
UpdateRecipeCommand = new RelayCommand<int>(obj => UpdateRecipe(obj));
ModeChangeCommand = new RelayCommand<string>(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<RecipeManage> 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
/// <summary>
/// 更新配方
/// </summary>
/// <param name="RecipeKey"></param>
public void UpdateRecipe(int RecipeKey)
{
RecipeManageSetWindow window = new RecipeManageSetWindow(RecipeKey);
window.ShowDialog();
RrfreshDataGrid();
}
/// <summary>
/// 模式切换
/// </summary>
/// <param name="RecipeKey"></param>
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);
}
}
}
}

Loading…
Cancel
Save