add-添加配方管理界面,待完善

dev
liuwf 5 months ago
parent 28ba808d9c
commit f7cb19a23c

@ -69,6 +69,8 @@ namespace SlnMesnac.Business.@base
private List<RealBarCodeTask> barCodeTasks;
private List<BaseConfigInfo> baseConfigInfos;
#endregion
@ -90,7 +92,7 @@ namespace SlnMesnac.Business.@base
using (var scope = _serviceProvider.CreateScope())
{
baseConfigInfos = scope.ServiceProvider.GetRequiredService<List<BaseConfigInfo>>();
palletTasks = scope.ServiceProvider.GetRequiredService<List<RealPalletTask>>();
barCodeTasks = scope.ServiceProvider.GetRequiredService<List<RealBarCodeTask>>();

@ -0,0 +1,96 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Model.domain
* ca1b0f85-e7a8-4e1b-ab98-07a7aa31c8f5
*
* WenJY
* wenjy@mesnac.com
* 2024-04-08 16:43:07
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Model.domain
{
/// <summary>
/// 配方管理实体类
/// </summary>
[SugarTable("recipe_manage"), TenantAttribute("local")]
public class RecipeManage
{
/// <summary>
/// 配方Id
/// </summary>
[SugarColumn(ColumnName = "obj_id", IsPrimaryKey = true, IsIdentity = true)]
public int ObjId { get; set; }
/// <summary>
/// 配方Key
/// </summary>
[SugarColumn(ColumnName = "recipe_key")]
public int RecipeKey { get; set; }
/// <summary>
/// 配方名称
/// </summary>
[SugarColumn(ColumnName = "recipe_name")]
public string RecipeName { get; set; }
/// <summary>
/// 拆包机螺旋1
/// </summary>
[SugarColumn(ColumnName = "unpack_spiral1")]
public int UnpackSpiral1 { get; set; }
/// <summary>
/// 拆包机螺旋2
/// </summary>
[SugarColumn(ColumnName = "unpack_spiral2")]
public int UnpackSpiral2 { get; set; }
/// <summary>
/// 烘干机螺旋
/// </summary>
[SugarColumn(ColumnName = "dryer_spiral")]
public int DryerSpiral { get; set; }
/// <summary>
/// 螺旋机螺旋1
/// </summary>
[SugarColumn(ColumnName = "spiral1")]
public int Spiral1 { get; set; }
/// <summary>
/// 螺旋机螺旋2
/// </summary>
[SugarColumn(ColumnName = "spiral2")]
public int Spiral2 { get; set; }
/// <summary>
/// 配方区间最低重量包含kg
/// </summary>
[SugarColumn(ColumnName = "low_weight")]
public int LowWeight { get; set; }
/// <summary>
/// 配方区间最高重量不包含kg
/// </summary>
[SugarColumn(ColumnName = "hight_weight")]
public int HightWeight { get; set; }
}
}

@ -0,0 +1,16 @@
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service.@base;
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Repository.service
{
public interface IBaseRecipeManageService : IBaseService<RecipeManage>
{
void UpdateRecipeManage(RecipeManage recipeManage);
public List<RecipeManage> GetRecipeManageList();
}
}

@ -0,0 +1,58 @@
using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service.@base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Repository.service.Impl
* 50d84911-9088-4fd3-b85a-151411028afc
*
* WenJY
* wenjy@mesnac.com
* 2024-04-08 16:47:57
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Repository.service.Impl
{
public class BaseRecipeManageServiceImpl : BaseServiceImpl<RecipeManage>, IBaseRecipeManageService
{
private readonly IServiceProvider _serviceProvider;
public BaseRecipeManageServiceImpl(Repository<RecipeManage> rep,IServiceProvider serviceProvider) : base(rep)
{
_serviceProvider = serviceProvider;
}
public void UpdateRecipeManage(RecipeManage recipeManage)
{
bool isRes = base._rep.Update(recipeManage);
}
public List<RecipeManage> GetRecipeManageList()
{
return base._rep.GetList();
}
}
}

@ -0,0 +1,85 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service;
using SlnMesnac.WPF;
using SlnMesnac.WPF.Page;
using System;
using System.Collections.Generic;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Model.dto
* 96940a51-66a8-4593-b68d-e4d7fdb16c9b
*
* WenJY
* wenjy@mesnac.com
* 2024-04-12 11:07:33
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.WPF.Model
{
/// <summary>
/// 配方管理封装对象
/// </summary>
public class RecipeManageCache
{
#region 单例实现
private static readonly RecipeManageCache lazy = new RecipeManageCache();
public static RecipeManageCache Instance
{
get
{
return lazy;
}
}
#endregion
#region 变量定义
private readonly ILogger<RecipeManageCache> _logger;
private readonly IBaseRecipeManageService? baseRecipeManageService;
public List<RecipeManage> recipeManageList = null;
#endregion
public RecipeManageCache()
{
baseRecipeManageService = App.ServiceProvider.GetService<IBaseRecipeManageService>();
recipeManageList = baseRecipeManageService.GetRecipeManageList();
}
/// <summary>
/// 更新配方
/// </summary>
/// <param name="recipeManage"></param>
public void UpdateRecipeManage(RecipeManage recipeManage)
{
try
{
baseRecipeManageService.UpdateRecipeManage(recipeManage);
//刷新缓存
recipeManageList = baseRecipeManageService.GetRecipeManageList();
}
catch (Exception ex)
{
_logger.LogError($"UpdateRecipeManage异常:{ex.Message}");
}
}
}
}

@ -147,16 +147,16 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Horizontal" >
<TextBlock Text="翻转机:" FontSize="20" VerticalAlignment="Center" Margin="5,0,0,0" Foreground="White"/>
<!--<TextBlock Text="翻转机:" FontSize="20" VerticalAlignment="Center" Margin="5,0,0,0" Foreground="White"/>
<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"/>
<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"/>
<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"/>
<!--<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>

@ -68,14 +68,14 @@ namespace SlnMesnac.WPF.Page
List<BaseConfigInfo> configInfos = _configInfoBusiness.GetConfigInfos();
UnpackSet1Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机翻转机频率设定值").FirstOrDefault().ConfigValue;
UnpackSet2Txt.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;
// 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;
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;
@ -357,11 +357,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("拆包机翻转机频率设定"), 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("拆包机废袋机频率设定值")));
});
@ -648,7 +648,7 @@ namespace SlnMesnac.WPF.Page
}
else
{
int value2 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度值"));
int value2 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设定值"));
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), true);
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设置"), value2);
Thread.Sleep(MachineSleep);
@ -678,7 +678,7 @@ namespace SlnMesnac.WPF.Page
return false;
}
#region 启动磁选机 / 前提:check螺旋2启动及速度是否达标
int value2 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度值")) * 100;
int value2 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设定值")) * 100;
bool startFlag = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"));
int speed2 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度反馈"));
if (!startFlag)
@ -736,7 +736,7 @@ namespace SlnMesnac.WPF.Page
return false;
}
int value1 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度值"));
int value1 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设定值"));
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"), true);
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设置"), value1);
Thread.Sleep(MachineSleep);
@ -761,7 +761,7 @@ namespace SlnMesnac.WPF.Page
bool result = false;
try
{
int value1 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度值"));
int value1 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设定值"));
bool startFlag = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"));
int speed1 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度反馈"));
if (!startFlag)
@ -868,11 +868,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("拆包机翻转机频率设定"), 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("拆包机废袋机频率设定值")));
Thread.Sleep(MachineSleep);
@ -998,8 +998,8 @@ namespace SlnMesnac.WPF.Page
double speed2 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度反馈")) / 100;
// 螺旋速度预设值
int speed1Set = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度值"));
int speed2Set = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度值"));
int speed1Set = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设定值"));
int speed2Set = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设定值"));
await App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
@ -1166,8 +1166,8 @@ namespace SlnMesnac.WPF.Page
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();
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);
@ -1235,14 +1235,14 @@ namespace SlnMesnac.WPF.Page
{
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 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;
// bool isValidSpeed5 = int.TryParse(UnpackSet5Txt.Text, out int speed5) && speed5 >= 0 && speed5 <= 50;
if (isValidSpeed1 && isValidSpeed2 && isValidSpeed3 && isValidSpeed4 && isValidSpeed5)
if ( isValidSpeed3 && isValidSpeed4 )
{
var result = MessageBox.Show("是否确认更改?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
@ -1251,28 +1251,28 @@ namespace SlnMesnac.WPF.Page
//频率设定
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机翻转机频率设定"), speed1);
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机滚筒筛频率设定"), speed2);
// 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);
// 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 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;
// 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);
// configInfo5.ConfigValue = UnpackSet5Txt.Text;
// _configInfoBusiness.UpdateConfigInfo(configInfo1);
// _configInfoBusiness.UpdateConfigInfo(configInfo2);
_configInfoBusiness.UpdateConfigInfo(configInfo3);
_configInfoBusiness.UpdateConfigInfo(configInfo4);
_configInfoBusiness.UpdateConfigInfo(configInfo5);
// _configInfoBusiness.UpdateConfigInfo(configInfo5);
}
}
else

@ -6,11 +6,75 @@
xmlns:local="clr-namespace:SlnMesnac.WPF.Page"
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent">
<Grid >
<TextBlock Text="qqqqqqq" FontSize="50" Foreground="White" />
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="4*"/>
<RowDefinition Height="3.5*"/>
</Grid.RowDefinitions>
<Border Grid.Row="2" BorderThickness="1" BorderBrush="Green">
<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"/>
</Grid>
<Grid Grid.Row="1">
<DataGrid Grid.Row="0" ItemsSource="{Binding RecipeDataGrid}" Background="Transparent" BorderThickness="1,0,1,1" BorderBrush="Green"
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"/>
<DataGridTextColumn Binding="{Binding RecipeName}" Header="配方名称" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding UnpackSpiral1}" Header="拆包机螺旋1频率" Width="1.5*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding UnpackSpiral2}" Header="拆包机螺旋2频率" Width="1.5*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding DryerSpiral}" Header="烘干机螺旋频率" Width="1.5*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Spiral1}" Header="螺旋机螺旋1频率" Width="1.5*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Spiral2}" Header="螺旋机螺旋2频率" Width="1.5*" IsReadOnly="True"/>
<DataGridTemplateColumn Header="操作" Width="2*">
<DataGridTemplateColumn.CellTemplate>
<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>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
<!--<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>-->
<!--<Button Grid.Row="0" Grid.Column="0" Style="{StaticResource BUTTON_AGREE}" Content="低速模版修改" FontSize="25" Background="Green" Width="180" Height="50" Margin="0,0,0,0" />
<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>

@ -32,23 +32,18 @@ namespace SlnMesnac.WPF.Page
public partial class RecipeManagePage : UserControl
{
private BaseBusiness baseBusiness = null;
private readonly ConfigInfoBusiness _configInfoBusiness;
PlcAbsractFactory plc = null;
int MachineSleep = 1000;
private readonly ILogger<DevMonitorPage> _logger;
System.Timers.Timer systemRunTimer = new System.Timers.Timer(1000 * 60);
public RecipeManagePage()
{
_logger = App.ServiceProvider.GetService<ILogger<DevMonitorPage>>();
_configInfoBusiness = App.ServiceProvider.GetService<ConfigInfoBusiness>();
baseBusiness = App.ServiceProvider.GetService<BaseBusiness>();
MachineSleep = Convert.ToInt32(baseBusiness.GetPlcAddressByConfigKey("设备启动间隔"));
plc = baseBusiness.GetPlcByKey("plc");
InitializeComponent();
this.DataContext = new DevMonitorViewModel();
this.DataContext = new RecipeManageViewModel();

@ -0,0 +1,59 @@
<Window x:Class="SlnMesnac.WPF.Page.RecipeManageSetWindow"
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="550" Width="600" WindowStartupLocation="CenterScreen" Topmost="True" Background="Blue">
<Border Margin="5" Background="LightGoldenrodYellow" CornerRadius="10">
<Border.Effect>
<DropShadowEffect Color="LightGoldenrodYellow" ShadowDepth="0" BlurRadius="5" Opacity="0.3" Direction="0"></DropShadowEffect>
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="5*"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="配方修改" FontSize="26" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="拆包机螺旋1频率:" FontSize="20" VerticalAlignment="Center" Width="170" Margin="0,0,20,0" />
<TextBox x:Name="UnpackSpiral1Txt" Width="80" Text="0" FontSize="20" VerticalAlignment="Center" Margin="0,0,20,0" />
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="拆包机螺旋2频率:" FontSize="20" VerticalAlignment="Center" Width="170" Margin="0,0,20,0" />
<TextBox x:Name="UnpackSpiral2Txt" Width="80" Text="0" FontSize="20" VerticalAlignment="Center" Margin="0,0,20,0" />
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="烘干机螺旋频率:" FontSize="20" VerticalAlignment="Center" Width="170" Margin="0,0,20,0" />
<TextBox x:Name="DryerSpiralTxt" Width="80" Text="0" FontSize="20" VerticalAlignment="Center" Margin="0,0,20,0" />
</StackPanel>
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="螺旋机螺旋1频率:" FontSize="20" VerticalAlignment="Center" Width="170" Margin="0,0,20,0" />
<TextBox x:Name="Spiral1Txt" Width="80" Text="0" FontSize="20" VerticalAlignment="Center" Margin="0,0,20,0" />
</StackPanel>
<StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="螺旋机螺旋2频率:" FontSize="20" VerticalAlignment="Center" Width="170" Margin="0,0,20,0" />
<TextBox x:Name="Spiral2Txt" Width="80" Text="0" FontSize="20" VerticalAlignment="Center" Margin="0,0,20,0" />
</StackPanel>
</Grid>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="10,0">
<Button Content="确 认" x:Name="ConfirmButton" FontSize="16" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#FF36B5C1" BorderBrush="#FF36B5C1" Margin="0,0,10,0" Click="ConfirmButton_Click" />
<Button Content="取 消" x:Name="CancelButton" FontSize="16" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#E4B74C" BorderBrush="Blue" Margin="10,0,0,0" Click="CancelButton_Click" />
</StackPanel>
</Grid>
</Border>
</Window>

@ -0,0 +1,94 @@
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 RecipeManageSetWindow : Window
{
private RecipeManageCache recipeManageCache = RecipeManageCache.Instance;
private int recipeKey;
public RecipeManageSetWindow(int key)
{
recipeKey = key;
InitializeComponent();
Init(key);
}
public void Init(int key)
{
RecipeManage recipeManage = recipeManageCache.recipeManageList.FirstOrDefault(x => x.RecipeKey == key);
if (recipeManage != null)
{
UnpackSpiral1Txt.Text = recipeManage.UnpackSpiral1.ToString();
UnpackSpiral2Txt.Text = recipeManage.UnpackSpiral2.ToString();
DryerSpiralTxt.Text = recipeManage.DryerSpiral.ToString();
Spiral1Txt.Text = recipeManage.Spiral1.ToString();
Spiral2Txt.Text = recipeManage.Spiral2.ToString();
}
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void ConfirmButton_Click(object sender, RoutedEventArgs e)
{
if (IsValidInt(UnpackSpiral1Txt.Text, out int unpackSpiral1) &&
IsValidInt(UnpackSpiral2Txt.Text, out int unpackSpiral2) &&
IsValidInt(DryerSpiralTxt.Text, out int dryerSpiral) &&
IsValidInt(Spiral1Txt.Text, out int spiral1) &&
IsValidInt(Spiral2Txt.Text, out int spiral2))
{
RecipeManage recipeManage = recipeManageCache.recipeManageList.FirstOrDefault(x => x.RecipeKey == recipeKey);
if (recipeManage != null)
{
recipeManage.UnpackSpiral1 = unpackSpiral1;
recipeManage.UnpackSpiral2 = unpackSpiral2;
recipeManage.DryerSpiral = dryerSpiral;
recipeManage.Spiral1 = spiral1;
recipeManage.Spiral2 = spiral2;
recipeManageCache.UpdateRecipeManage(recipeManage);
MessageBox.Show("修改成功");
this.Close();
}
}
}
private bool IsValidInt(string value, out int result)
{
bool isValid = int.TryParse(value, out result) && result > 0;
if (!isValid)
{
MessageBox.Show("请输入正整数", $"{value}输入错误", MessageBoxButton.OK, MessageBoxImage.Warning);
}
return isValid;
}
}
}

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

@ -45,7 +45,6 @@ namespace SlnMesnac.WPF
//RFID
services.AddRfidFactorySetup();
}

@ -0,0 +1,106 @@
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Business;
using SlnMesnac.Business.@base;
using SlnMesnac.Model.domain;
using SlnMesnac.Model.dto;
using SlnMesnac.Plc;
using SlnMesnac.Repository.service;
using SlnMesnac.WPF.Model;
using SlnMesnac.WPF.Page;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.WPF.ViewModel
* 14008fcc-0a31-4f1e-bc80-9f9ea84d3de5
*
* WenJY
* wenjy@mesnac.com
* 2024-04-10 16:18:57
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.WPF.ViewModel
{
/// <summary>
/// 设备参数监控
/// </summary>
internal class RecipeManageViewModel : ViewModelBase
{
private BaseBusiness baseBusiness = null;
private PlcAbsractFactory plc = null;
private RecipeManageCache recipeManageCache = RecipeManageCache.Instance;
/// <summary>
/// 修改配方
/// </summary>
public RelayCommand<int> UpdateRecipeCommand { get; set; }
public RecipeManageViewModel()
{
baseBusiness = App.ServiceProvider.GetService<BaseBusiness>();
UpdateRecipeCommand = new RelayCommand<int>(obj => UpdateRecipe(obj));
RrfreshDataGrid();
}
public void RrfreshDataGrid()
{
List<RecipeManage> list = recipeManageCache.recipeManageList;
if (list != null && list.Count > 0)
{
RecipeDataGrid.Clear();
foreach (var item in list)
{
RecipeDataGrid.Add(item);
}
}
}
#region 参数定义
/// <summary>
/// 配方DataGrid
/// </summary>
private ObservableCollection<RecipeManage> recipeDataGrid = new ObservableCollection<RecipeManage>();
public ObservableCollection<RecipeManage> RecipeDataGrid
{
get { return recipeDataGrid; }
set { recipeDataGrid = value; RaisePropertyChanged(() => RecipeDataGrid); }
}
#endregion
public void UpdateRecipe(int RecipeKey)
{
RecipeManageSetWindow window = new RecipeManageSetWindow(RecipeKey);
window.ShowDialog();
RrfreshDataGrid();
}
}
}
Loading…
Cancel
Save