浏览代码

180项目更新

样式分支
taoye 2 年前
父节点
当前提交
baa4236c82
共有 59 个文件被更改,包括 3466 次插入7 次删除
  1. +0
    -1
      BPASmartClient.CustomResource/RecDictionarys/BeveledRadioButtonStyle.xaml
  2. +1
    -0
      BPASmartClient.CustomResource/UserControls/DateTimeUI.xaml.cs
  3. +72
    -1
      BPASmartClient.Modbus/ModbusTcp.cs
  4. +0
    -2
      DosingSystem/Model/DeviceInquire.cs
  5. +1
    -1
      DosingSystem/View/MainWindow.xaml
  6. +1
    -1
      DosingSystem/View/NewRecipeView.xaml
  7. +36
    -0
      FryPot_DosingSystem/App.xaml
  8. +17
    -0
      FryPot_DosingSystem/App.xaml.cs
  9. +10
    -0
      FryPot_DosingSystem/AssemblyInfo.cs
  10. +106
    -0
      FryPot_DosingSystem/Control/DeviceOperate.cs
  11. +162
    -0
      FryPot_DosingSystem/Control/DosingLogicControl.cs
  12. +386
    -0
      FryPot_DosingSystem/Control/GlobalVariable.cs
  13. +29
    -0
      FryPot_DosingSystem/FryPot_DosingSystem.csproj
  14. +37
    -0
      FryPot_DosingSystem/Helper/PasswordBoxHelper.cs
  15. +22
    -0
      FryPot_DosingSystem/Model/ActionMenu.cs
  16. +24
    -0
      FryPot_DosingSystem/Model/DeviceInfo.cs
  17. +15
    -0
      FryPot_DosingSystem/Model/DeviceManage.cs
  18. +13
    -0
      FryPot_DosingSystem/Model/Global.cs
  19. +30
    -0
      FryPot_DosingSystem/Model/LogModel.cs
  20. +48
    -0
      FryPot_DosingSystem/Model/LoginInfoConfig.cs
  21. +35
    -0
      FryPot_DosingSystem/Model/MaterialType.cs
  22. +14
    -0
      FryPot_DosingSystem/Model/PlcVariableModel.cs
  23. +17
    -0
      FryPot_DosingSystem/Model/RecipeManage.cs
  24. +32
    -0
      FryPot_DosingSystem/Model/RecipeModel.cs
  25. +28
    -0
      FryPot_DosingSystem/Model/UserManage.cs
  26. +187
    -0
      FryPot_DosingSystem/View/AdministratorLoginView.xaml
  27. +95
    -0
      FryPot_DosingSystem/View/AdministratorLoginView.xaml.cs
  28. +185
    -0
      FryPot_DosingSystem/View/AdministratorPasswordChangeView.xaml
  29. +85
    -0
      FryPot_DosingSystem/View/AdministratorPasswordChangeView.xaml.cs
  30. +12
    -0
      FryPot_DosingSystem/View/AlarmInfoView.xaml
  31. +28
    -0
      FryPot_DosingSystem/View/AlarmInfoView.xaml.cs
  32. +72
    -0
      FryPot_DosingSystem/View/DeviceListVIew.xaml
  33. +28
    -0
      FryPot_DosingSystem/View/DeviceListVIew.xaml.cs
  34. +12
    -0
      FryPot_DosingSystem/View/EditRecipeView.xaml
  35. +28
    -0
      FryPot_DosingSystem/View/EditRecipeView.xaml.cs
  36. +12
    -0
      FryPot_DosingSystem/View/HardWareStatusView.xaml
  37. +28
    -0
      FryPot_DosingSystem/View/HardWareStatusView.xaml.cs
  38. +54
    -0
      FryPot_DosingSystem/View/LogView.xaml
  39. +30
    -0
      FryPot_DosingSystem/View/LogView.xaml.cs
  40. +255
    -0
      FryPot_DosingSystem/View/MainWindow.xaml
  41. +64
    -0
      FryPot_DosingSystem/View/MainWindow.xaml.cs
  42. +113
    -0
      FryPot_DosingSystem/View/NewRecipeView.xaml
  43. +36
    -0
      FryPot_DosingSystem/View/NewRecipeView.xaml.cs
  44. +82
    -0
      FryPot_DosingSystem/View/RecipeSendDownView.xaml
  45. +28
    -0
      FryPot_DosingSystem/View/RecipeSendDownView.xaml.cs
  46. +127
    -0
      FryPot_DosingSystem/View/RecipeSetView.xaml
  47. +30
    -0
      FryPot_DosingSystem/View/RecipeSetView.xaml.cs
  48. +172
    -0
      FryPot_DosingSystem/ViewModel/AdministratorLoginViewModel.cs
  49. +13
    -0
      FryPot_DosingSystem/ViewModel/AdministratorPasswordChangeViewModel.cs
  50. +61
    -0
      FryPot_DosingSystem/ViewModel/DeviceListViewModel.cs
  51. +76
    -0
      FryPot_DosingSystem/ViewModel/LogViewModel.cs
  52. +151
    -0
      FryPot_DosingSystem/ViewModel/MainViewModel.cs
  53. +98
    -0
      FryPot_DosingSystem/ViewModel/NewRecipeViewModel.cs
  54. +62
    -0
      FryPot_DosingSystem/ViewModel/RecipeSetDownViewModel.cs
  55. +80
    -0
      FryPot_DosingSystem/ViewModel/RecipeSetViewModel.cs
  56. 二进制
     
  57. +1
    -0
      LoginUp.hbl
  58. +24
    -1
      SmartClient.sln
  59. +1
    -0
      up.hbl

+ 0
- 1
BPASmartClient.CustomResource/RecDictionarys/BeveledRadioButtonStyle.xaml 查看文件

@@ -215,5 +215,4 @@
</Setter>
</Style>
<!--#endregion-->

</ResourceDictionary>

+ 1
- 0
BPASmartClient.CustomResource/UserControls/DateTimeUI.xaml.cs 查看文件

@@ -21,6 +21,7 @@ namespace BPASmartClient.CustomResource.UserControls
/// </summary>
public partial class DateTimeUI : UserControl
{

public DateTimeUI()
{
InitializeComponent();


+ 72
- 1
BPASmartClient.Modbus/ModbusTcp.cs 查看文件

@@ -130,7 +130,7 @@ namespace BPASmartClient.Modbus
}
return -1;
}
private void ExceptionHandling(Exception ex)
{
if (ex.InnerException is SocketException)
@@ -174,7 +174,78 @@ namespace BPASmartClient.Modbus
}
return default(object);
}
#region 180项目调用
public int GetAddress(string address, string target)
{
if (address == null) return -1;
if (address.Length > 0)
{
if (address.ToUpper().Contains("D") && address.Length == 5)
{
try
{
string head = (Convert.ToInt32(address.Substring(1, 1)) - 1).ToString();
string tail = address.Substring(2, 3);
address = head + tail;
}
catch (Exception)
{
//打印日志
return -1;
}
}

}
return -1;
}
public object Read(string address, ushort len, string target, byte slaveAddress = 1)
{
if (address == null || tcpClient == null) return default(object);
ushort startAddress = (ushort)GetAddress(address, target);
CommandType commandType = CommandType.HoldingRegisters;
try
{
if (address.ToUpper().Contains("D"))
{
commandType = CommandType.HoldingRegisters;
return master.ReadHoldingRegisters(slaveAddress, startAddress, len);
}

}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx($"读取地址:【{address}:= {startAddress}】,读取类型:【{commandType.ToString()}】出错,{ex.ToString()}");
ExceptionHandling(ex);
}
return default(object);
}

public void Write<T>(string address, T value, string target, byte slaveAddress = 1)
{
if (address == null || tcpClient == null) return;
ushort startAddress = (ushort)GetAddress(address,target);
CommandType commandType = CommandType.Coils;
try
{
if (address.ToUpper().Contains("D"))
{
commandType = CommandType.HoldingRegisters;
if (value is ushort ushortValue)
{
master.WriteSingleRegister(slaveAddress, startAddress, ushortValue);
}
}
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx($"写入地址:【{address}:= {startAddress}】,写入类型:【{commandType.ToString()}】出错,{ex.ToString()}");
ExceptionHandling(ex);
}
}
#endregion
public void Write<T>(string address, T value, byte slaveAddress = 1)
{
if (address == null || tcpClient == null) return;


+ 0
- 2
DosingSystem/Model/DeviceInquire.cs 查看文件

@@ -51,8 +51,6 @@ namespace DosingSystem.Model

private void IpAddressLines()
{


for (int i = 1; i <= 255; i++)
{
if (!InvalidIP.Contains($"{IPSegment}{i}"))


+ 1
- 1
DosingSystem/View/MainWindow.xaml 查看文件

@@ -238,7 +238,7 @@
</Grid>

<!--#region 底部窗体栏-->
<ContentControl
<ContentControl
x:Name="contentRegion"
Grid.Row="1"
Content="{Binding MyWindow}" />


+ 1
- 1
DosingSystem/View/NewRecipeView.xaml 查看文件

@@ -116,7 +116,7 @@
Height="30"
Margin="0,0,7,0"
Command="{Binding AddCommand}"
Content="添加原料" />
Content="添加原料" Cursor="Hand" />

<Button
Width="80"


+ 36
- 0
FryPot_DosingSystem/App.xaml 查看文件

@@ -0,0 +1,36 @@
<Application x:Class="FryPot_DosingSystem.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FryPot_DosingSystem" xmlns:con="clr-namespace:System.Drawing;assembly=netstandard"
xmlns:con1="clr-namespace:BPASmartClient.CustomResource.Converters;assembly=BPASmartClient.CustomResource"
StartupUri="View/MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>

<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecCheckBox.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecTitleBarButton.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/GlobalStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecComboBox.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecIcoButtonStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecToggleButton.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/BeveledRadioButtonStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/DatePickeerDictionary.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecButtonStyle.xaml" />

<ResourceDictionary>
<con:ColorConverter x:Key="ColorConverter" />
<con1:TextConverter x:Key="TextConverter" />
<con1:VisibleTypeConverter x:Key="VisibleTypeConverter" />
<con1:StatusConverter x:Key="StatusConverter" />
</ResourceDictionary>

<ResourceDictionary>
<ImageBrush x:Key="hbl" ImageSource="/BPASmartClient.CustomResource;component/Image/HBL.png" />
<ImageBrush x:Key="dbxt" ImageSource="/BPASmartClient.CustomResource;component/Image/顶部线条.png" />
</ResourceDictionary>

</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

+ 17
- 0
FryPot_DosingSystem/App.xaml.cs 查看文件

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace FryPot_DosingSystem
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

+ 10
- 0
FryPot_DosingSystem/AssemblyInfo.cs 查看文件

@@ -0,0 +1,10 @@
using System.Windows;

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

+ 106
- 0
FryPot_DosingSystem/Control/DeviceOperate.cs 查看文件

@@ -0,0 +1,106 @@
using BPASmartClient.Helper;
using BPASmartClient.Message;
using BPASmartClient.Modbus;
using FryPot_DosingSystem.Model;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.Control
{
internal class DeviceOperate
{
private static DeviceOperate _instance;
public static DeviceOperate GetInstance=>_instance ??= new DeviceOperate();
ModbusTcp modbus = new ModbusTcp();
private string Ip { get; set; }
private string Port { get; set; }
private bool Connected { get; set; }

private string DeviceName { get; set; }

public ConcurrentDictionary<string, object> Data { get; set; } = new ConcurrentDictionary<string, object>();
public ObservableCollection<PlcVariableModel> Variables { get; set; }=new ObservableCollection<PlcVariableModel>();
public DeviceOperate()
{
Init();
Connect();
ReadData();
}
public void Init()
{
if (Variables.Count > 0)
{
Variables.Clear();
}
Variables.Add(new PlcVariableModel() { Address = "D2001", Length = 8 });//1号线体滚筒工位号
Variables.Add(new PlcVariableModel() { Address = "D2011", Length = 8 });//2号线体滚筒工位号
Variables.Add(new PlcVariableModel() { Address = "D2021", Length = 8 });//3号线体滚筒工位号
Variables.Add(new PlcVariableModel() { Address = "D2031", Length = 9 });//输送线出料状态
Variables.Add(new PlcVariableModel() { Address = "D2040", Length = 5 });//炒锅1-5进料滚筒运行
Variables.Add(new PlcVariableModel() { Address = "D2045", Length = 5 });//炒锅1-5进料到位信号
Variables.Add(new PlcVariableModel() { Address = "D2050", Length = 5 });//炒锅1-5空桶到位信号
Variables.Add(new PlcVariableModel() { Address = "D2055", Length = 5 });//炒锅1-5空桶呼叫AGV
Variables.Add(new PlcVariableModel() { Address = "D2060", Length = 5 });//炒锅1空桶洗桶呼叫AGV
Variables.Add(new PlcVariableModel() { Address = "D2065", Length = 5 });//炒锅1-5空桶滚筒运行
Variables.Add(new PlcVariableModel() { Address = "D2070", Length = 5 });//炒锅1-5滚筒故障信号
Variables.Add(new PlcVariableModel() { Address = "D2075", Length = 1 });//洗桶进桶滚筒运行信号
Variables.Add(new PlcVariableModel() { Address = "D2076", Length = 1 });//洗桶出桶呼叫AGV
Variables.Add(new PlcVariableModel() { Address = "D2077", Length = 1 });// 洗桶出桶滚筒运行信号
Variables.Add(new PlcVariableModel() { Address = "D2078", Length = 3 });//1-3滚筒线体配方完成信号
}
public void Connect()
{
Json<DeviceManage>.Read();
DeviceManage devices = Json<DeviceManage>.Data;
if (devices != null)
{
if (devices.Devices.Count > 0)
{
Ip = devices.Devices[0].Ip;
Port = devices.Devices[0].Port;
DeviceName = devices.Devices[0].DeviceName;
Task.Run(() => { modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); });
}
}
}
public void ReadData()
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
Connected = modbus.Connected;
while (Connected)
{
foreach (var item in Variables)
{
var res = modbus.Read(item.Address, item.Length, "180项目");
if (Data.ContainsKey(item.Address))
{
Data[item.Address] = res;
}
else
{
Data.TryAdd(item.Address, res);
}
}
Thread.Sleep(500);
}
Thread.Sleep(1000);
}),$"设备【{DeviceName}】PLC实时数据读取线程");
}
public void WritePlcData(string address,ushort value)
{
modbus.Write(address, value,"180项目");
}
public ConcurrentDictionary<string, object> GetAllData()
{
return Data;
}
}
}

+ 162
- 0
FryPot_DosingSystem/Control/DosingLogicControl.cs 查看文件

@@ -0,0 +1,162 @@
using BPASmartClient.Helper;
using FryPot_DosingSystem.Model;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.Control
{
internal class DosingLogicControl
{
public static DosingLogicControl _instance;
public static DosingLogicControl GetInstance=>_instance ??= new DosingLogicControl();
public ConcurrentDictionary<string,object> PlcReadData=new ConcurrentDictionary<string, object>();
public DosingLogicControl()
{
IniteTask();
}
/// <summary>
/// 实时获取plc数据
/// </summary>
public void ReadPlcData()
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
GetAddressData("D2001", new Action<ushort[]>((data) =>
{
GlobalVariable.rollerLineOne.StationOne = data[0];
GlobalVariable.rollerLineOne.StationTwo = data[1];
GlobalVariable.rollerLineOne.StationThree = data[2];
GlobalVariable.rollerLineOne.StationFour = data[3];
GlobalVariable.rollerLineOne.StationFive = data[4];
GlobalVariable.rollerLineOne.StationSix = data[5];
GlobalVariable.rollerLineOne.StationSeven = data[6];
GlobalVariable.rollerLineOne.StationEight = data[7];
}));
GetAddressData("D2011", new Action<ushort[]>((data) =>
{
GlobalVariable.rollerLineTwo.StationOne = data[0];
GlobalVariable.rollerLineTwo.StationTwo = data[1];
GlobalVariable.rollerLineTwo.StationThree = data[2];
GlobalVariable.rollerLineTwo.StationFour = data[3];
GlobalVariable.rollerLineTwo.StationFive = data[4];
GlobalVariable.rollerLineTwo.StationSix = data[5];
GlobalVariable.rollerLineTwo.StationSeven = data[6];
GlobalVariable.rollerLineTwo.StationEight = data[7];
}));
GetAddressData("D2021", new Action<ushort[]>((data) =>
{
GlobalVariable.rollerLineThree.StationOne = data[0];
GlobalVariable.rollerLineThree.StationTwo = data[1];
GlobalVariable.rollerLineThree.StationThree = data[2];
GlobalVariable.rollerLineThree.StationFour = data[3];
GlobalVariable.rollerLineThree.StationFive = data[4];
GlobalVariable.rollerLineThree.StationSix = data[5];
GlobalVariable.rollerLineThree.StationSeven = data[6];
GlobalVariable.rollerLineThree.StationEight = data[7];
}));
GetAddressData("D2040", new Action<ushort[]>((data) =>
{
GlobalVariable.fryPotOne.InputMaterialRollerRunningSingle = data[0];
GlobalVariable.fryPotTwo.InputMaterialRollerRunningSingle = data[1];
GlobalVariable.fryPotThree.InputMaterialRollerRunningSingle = data[2];
GlobalVariable.fryPotFour.InputMaterialRollerRunningSingle = data[3];
GlobalVariable.fryPotFive.InputMaterialRollerRunningSingle= data[4];
}));
GetAddressData("D2045", new Action<ushort[]>((data) =>
{
GlobalVariable.fryPotOne.InputMaterialArrivedSingle = data[0];
GlobalVariable.fryPotTwo.InputMaterialArrivedSingle = data[1];
GlobalVariable.fryPotThree.InputMaterialArrivedSingle = data[2];
GlobalVariable.fryPotFour.InputMaterialArrivedSingle = data[3];
GlobalVariable.fryPotFive.InputMaterialArrivedSingle = data[4];
}));
GetAddressData("D2050", new Action<ushort[]>((data) =>
{
GlobalVariable.fryPotOne.EmptyBarrelArrivedSingle = data[0];
GlobalVariable.fryPotTwo.EmptyBarrelArrivedSingle = data[1];
GlobalVariable.fryPotThree.EmptyBarrelArrivedSingle = data[2];
GlobalVariable.fryPotFour.EmptyBarrelArrivedSingle = data[3];
GlobalVariable.fryPotFive.EmptyBarrelArrivedSingle = data[4];
}));
GetAddressData("D2065", new Action<ushort[]>((data) =>
{
GlobalVariable.fryPotOne.EmptyBarrelRollerRunningSingle = data[0];
GlobalVariable.fryPotTwo.EmptyBarrelRollerRunningSingle = data[1];
GlobalVariable.fryPotThree.EmptyBarrelRollerRunningSingle = data[2];
GlobalVariable.fryPotFour.EmptyBarrelRollerRunningSingle = data[3];
GlobalVariable.fryPotFive.EmptyBarrelRollerRunningSingle = data[4];
}));
GetAddressData("D2070", new Action<ushort[]>((data) =>
{
GlobalVariable.fryPotOne.RollerTroubleSingle = data[0];
GlobalVariable.fryPotTwo.RollerTroubleSingle = data[1];
GlobalVariable.fryPotThree.RollerTroubleSingle = data[2];
GlobalVariable.fryPotFour.RollerTroubleSingle = data[3];
GlobalVariable.fryPotFive.RollerTroubleSingle = data[4];
}));
GetAddressData("D2078",new Action<ushort[]>(data => {
GlobalVariable.rollerLineOne.RecipeCompleteSingle = data[0];
GlobalVariable.rollerLineTwo.RecipeCompleteSingle = data[1];
GlobalVariable.rollerLineThree.RecipeCompleteSingle = data[2];
}));
GetAddressData("D2075",new Action<ushort[]>(data => {
GlobalVariable.CleadBarrelEnterSingle = data[0];
}));
GetAddressData("D2077", new Action<ushort[]>(data => {

GlobalVariable.CleadBarrelExitSingle = data[0];
}));
Thread.Sleep(10);
}), "MainViewReadPlcData");
}

/// <summary>
/// 返回指定地址指定长度的数据
/// </summary>
/// <param name="address"></param>
/// <returns></returns>
public void GetAddressData(string address, Action<ushort[]> action)
{
PlcReadData= DeviceOperate.GetInstance.GetAllData();
if (PlcReadData.ContainsKey(address))
{
action((ushort[])(PlcReadData[address]));
}
}
/// <summary>
/// 写Plc数据
/// </summary>
/// <param name="address"></param>
/// <param name="Value"></param>
public void WritePlcData(string address, ushort Value)
{
DeviceOperate.GetInstance.WritePlcData(address, Value);
}
/// <summary>
/// 初始化任务
/// </summary>
public void IniteTask()
{
ThreadManage.GetInstance().StartLong(new Action(() => {

MainTask();
}),"启动主任务循环",true);
}
/// <summary>
/// 开启主任务
/// </summary>
public void MainTask()
{
}
}
}

+ 386
- 0
FryPot_DosingSystem/Control/GlobalVariable.cs 查看文件

@@ -0,0 +1,386 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.Control
{
/// <summary>
/// plc变量
/// </summary>
internal static class GlobalVariable
{
/// <summary>
/// 滚筒线1
/// </summary>
public static RollerLineOne rollerLineOne = new RollerLineOne();
/// <summary>
/// 滚筒线2
/// </summary>
public static RollerLineTwo rollerLineTwo = new RollerLineTwo();
/// <summary>
/// 滚筒线3
/// </summary>
public static RollerLineThree rollerLineThree = new RollerLineThree();
/// <summary>
/// 炒锅1
/// </summary>
public static FryPotOne fryPotOne= new FryPotOne();
/// <summary>
/// 炒锅2
/// </summary>
public static FryPotTwo fryPotTwo= new FryPotTwo();
/// <summary>
/// 炒锅3
/// </summary>
public static FryPotThree fryPotThree= new FryPotThree();
/// <summary>
/// 炒锅4
/// </summary>
public static FryPotFour fryPotFour= new FryPotFour();
/// <summary>
/// 炒锅5
/// </summary>
public static FryPotFive fryPotFive= new FryPotFive();
/// <summary>
/// 洗桶进桶滚筒运行信号
/// </summary>
public static ushort CleadBarrelEnterSingle { get; set; }
/// <summary>
/// 洗桶出桶滚筒运行信号
/// </summary>
public static ushort CleadBarrelExitSingle { get; set; }

}
/// <summary>
/// 滚筒线1相关变量
/// </summary>
public class RollerLineOne
{
/// <summary>
/// 工位号1
/// </summary>
public ushort StationOne { get; set; }
/// <summary>
/// 工位号2
/// </summary>
public ushort StationTwo { get; set; }
/// <summary>
/// 工位号3
/// </summary>
public ushort StationThree { get; set; }
/// <summary>
/// 工位号4
/// </summary>
public ushort StationFour { get; set; }
/// <summary>
/// 工位号5
/// </summary>
public ushort StationFive { get; set; }
/// <summary>
/// 工位号6
/// </summary>
public ushort StationSix { get; set; }
/// <summary>
/// 工位号7
/// </summary>
public ushort StationSeven { get; set; }
/// <summary>
/// 工位号8
/// </summary>
public ushort StationEight { get; set; }
/// <summary>
/// 输送出料滚筒运行信号
/// </summary>
public ushort OutMaterialingSingle { get; set; }
/// <summary>
/// 输送出料滚筒运行故障信号
/// </summary>
public ushort OutMaterialingTroubleSingle { get; set; }
/// <summary>
/// 当前线体配方完成信号
/// </summary>
public ushort RecipeCompleteSingle { get; set; }
}
/// <summary>
/// 滚筒线2相关变量
/// </summary>
public class RollerLineTwo
{
/// <summary>
/// 工位号1
/// </summary>
public ushort StationOne { get; set; }
/// <summary>
/// 工位号2
/// </summary>
public ushort StationTwo { get; set; }
/// <summary>
/// 工位号3
/// </summary>
public ushort StationThree { get; set; }
/// <summary>
/// 工位号4
/// </summary>
public ushort StationFour { get; set; }
/// <summary>
/// 工位号5
/// </summary>
public ushort StationFive { get; set; }
/// <summary>
/// 工位号6
/// </summary>
public ushort StationSix { get; set; }
/// <summary>
/// 工位号7
/// </summary>
public ushort StationSeven { get; set; }
/// <summary>
/// 工位号8
/// </summary>
public ushort StationEight { get; set; }
/// <summary>
/// 输送出料滚筒运行信号
/// </summary>
public ushort OutMaterialingSingle { get; set; }
/// <summary>
/// 输送出料滚筒运行故障信号
/// </summary>
public ushort OutMaterialingTroubleSingle { get; set; }
/// <summary>
/// 当前线体配方完成信号
/// </summary>
public ushort RecipeCompleteSingle { get; set; }
}
/// <summary>
/// 滚筒线3相关变量
/// </summary>
public class RollerLineThree
{
/// <summary>
/// 工位号1
/// </summary>
public ushort StationOne { get; set; }
/// <summary>
/// 工位号2
/// </summary>
public ushort StationTwo { get; set; }
/// <summary>
/// 工位号3
/// </summary>
public ushort StationThree { get; set; }
/// <summary>
/// 工位号4
/// </summary>
public ushort StationFour { get; set; }
/// <summary>
/// 工位号5
/// </summary>
public ushort StationFive { get; set; }
/// <summary>
/// 工位号6
/// </summary>
public ushort StationSix { get; set; }
/// <summary>
/// 工位号7
/// </summary>
public ushort StationSeven { get; set; }
/// <summary>
/// 工位号8
/// </summary>
public ushort StationEight { get; set; }
/// <summary>
/// 输送出料滚筒运行信号
/// </summary>
public ushort OutMaterialingSingle { get; set; }
/// <summary>
/// 输送出料滚筒运行故障信号
/// </summary>
public ushort OutMaterialingTroubleSingle { get; set; }
/// <summary>
/// 当前线体配方完成信号
/// </summary>
public ushort RecipeCompleteSingle { get; set; }
}
/// <summary>
/// 滚筒线4相关变量
/// </summary>
public class RollerLineFour
{
/// <summary>
/// 工位号1
/// </summary>
public ushort StationOne { get; set; }
/// <summary>
/// 工位号2
/// </summary>
public ushort StationTwo { get; set; }
/// <summary>
/// 工位号3
/// </summary>
public ushort StationThree { get; set; }
/// <summary>
/// 工位号4
/// </summary>
public ushort StationFour { get; set; }
/// <summary>
/// 工位号5
/// </summary>
public ushort StationFive { get; set; }
/// <summary>
/// 工位号6
/// </summary>
public ushort StationSix { get; set; }
/// <summary>
/// 工位号7
/// </summary>
public ushort StationSeven { get; set; }
/// <summary>
/// 工位号8
/// </summary>
public ushort StationEight { get; set; }
/// <summary>
/// 输送出料滚筒运行信号
/// </summary>
public ushort OutMaterialingSingle { get; set; }
/// <summary>
/// 输送出料滚筒运行故障信号
/// </summary>
public ushort OutMaterialingTroubleSingle { get; set; }
/// <summary>
/// 当前线体配方完成信号
/// </summary>
public ushort RecipeCompleteSingle { get; set; }
}
/// <summary>
/// 炒锅1相关变量
/// </summary>
public class FryPotOne
{
/// <summary>
/// 进料滚筒运行信号
/// </summary>
public ushort InputMaterialRollerRunningSingle { get; set; }
/// <summary>
/// 进料到位信号
/// </summary>
public ushort InputMaterialArrivedSingle { get; set; }
/// <summary>
/// 空桶到位信号
/// </summary>
public ushort EmptyBarrelArrivedSingle { get; set; }
/// <summary>
/// 空桶滚筒运行信号
/// </summary>
public ushort EmptyBarrelRollerRunningSingle { get; set; }
/// <summary>
/// 滚筒故障信号
/// </summary>
public ushort RollerTroubleSingle { get; set; }
}
/// <summary>
/// 炒锅2相关变量
/// </summary>
public class FryPotTwo
{
/// <summary>
/// 进料滚筒运行信号
/// </summary>
public ushort InputMaterialRollerRunningSingle { get; set; }
/// <summary>
/// 进料到位信号
/// </summary>
public ushort InputMaterialArrivedSingle { get; set; }
/// <summary>
/// 空桶到位信号
/// </summary>
public ushort EmptyBarrelArrivedSingle { get; set; }
/// <summary>
/// 空桶滚筒运行信号
/// </summary>
public ushort EmptyBarrelRollerRunningSingle { get; set; }
/// <summary>
/// 滚筒故障信号
/// </summary>
public ushort RollerTroubleSingle { get; set; }
}
/// <summary>
/// 炒锅3相关变量
/// </summary>
public class FryPotThree
{
/// <summary>
/// 进料滚筒运行信号
/// </summary>
public ushort InputMaterialRollerRunningSingle { get; set; }
/// <summary>
/// 进料到位信号
/// </summary>
public ushort InputMaterialArrivedSingle { get; set; }
/// <summary>
/// 空桶到位信号
/// </summary>
public ushort EmptyBarrelArrivedSingle { get; set; }
/// <summary>
/// 空桶滚筒运行信号
/// </summary>
public ushort EmptyBarrelRollerRunningSingle { get; set; }
/// <summary>
/// 滚筒故障信号
/// </summary>
public ushort RollerTroubleSingle { get; set; }
}
/// <summary>
/// 炒锅4相关变量
/// </summary>
public class FryPotFour
{
/// <summary>
/// 进料滚筒运行信号
/// </summary>
public ushort InputMaterialRollerRunningSingle { get; set; }
/// <summary>
/// 进料到位信号
/// </summary>
public ushort InputMaterialArrivedSingle { get; set; }
/// <summary>
/// 空桶到位信号
/// </summary>
public ushort EmptyBarrelArrivedSingle { get; set; }
/// <summary>
/// 空桶滚筒运行信号
/// </summary>
public ushort EmptyBarrelRollerRunningSingle { get; set; }
/// <summary>
/// 滚筒故障信号
/// </summary>
public ushort RollerTroubleSingle { get; set; }
}
/// <summary>
/// 炒锅5相关变量
/// </summary>
public class FryPotFive
{
/// <summary>
/// 进料滚筒运行信号
/// </summary>
public ushort InputMaterialRollerRunningSingle { get; set; }
/// <summary>
/// 进料到位信号
/// </summary>
public ushort InputMaterialArrivedSingle { get; set; }
/// <summary>
/// 空桶到位信号
/// </summary>
public ushort EmptyBarrelArrivedSingle { get; set; }
/// <summary>
/// 空桶滚筒运行信号
/// </summary>
public ushort EmptyBarrelRollerRunningSingle { get; set; }
/// <summary>
/// 滚筒故障信号
/// </summary>
public ushort RollerTroubleSingle { get; set; }
}
}

+ 29
- 0
FryPot_DosingSystem/FryPot_DosingSystem.csproj 查看文件

@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>

<ItemGroup>
<None Remove="hbl.ico" />
</ItemGroup>

<ItemGroup>
<Content Include="hbl.ico" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
<PackageReference Include="NModbus" Version="3.0.72" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" />
<ProjectReference Include="..\BPASmartClient.Helper\BPASmartClient.Helper.csproj" />
<ProjectReference Include="..\BPASmartClient.Modbus\BPASmartClient.Modbus.csproj" />
</ItemGroup>

</Project>

+ 37
- 0
FryPot_DosingSystem/Helper/PasswordBoxHelper.cs 查看文件

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace FryPot_DosingSystem.Helper
{
public class PasswordBoxHelper
{
public static string GetPasswordContent(DependencyObject obj) => (string)obj.GetValue(PasswordContentProperty);

public static void SetPasswordContent(DependencyObject obj, string value) => obj.SetValue(PasswordContentProperty, value);

public static readonly DependencyProperty PasswordContentProperty =
DependencyProperty.RegisterAttached("PasswordContent", typeof(string), typeof(PasswordBoxHelper),
new PropertyMetadata(string.Empty, OnPasswordContentPropertyChanged));

private static void OnPasswordContentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var box = d as PasswordBox;
box.PasswordChanged -= OnPasswordChanged;
var password = (string)e.NewValue;
if (box != null && box.Password != password)
box.Password = password;
box.PasswordChanged += OnPasswordChanged;
}

private static void OnPasswordChanged(object sender, RoutedEventArgs e)
{
var box = sender as PasswordBox;
SetPasswordContent(box, box.Password);
}
}
}

+ 22
- 0
FryPot_DosingSystem/Model/ActionMenu.cs 查看文件

@@ -0,0 +1,22 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.Model
{
public class ActionMenu:ObservableObject
{
private string commandParmeter;
public string CommandParameter { get { return commandParmeter; }set { commandParmeter = value; OnPropertyChanged(); } }

private string menuName;
public string MenuName { get { return menuName; } set { menuName = value;OnPropertyChanged(); } }

private Authority[] authority;
public Authority[] Authority { get { return authority; } set { authority = value; OnPropertyChanged(); } }
}
}

+ 24
- 0
FryPot_DosingSystem/Model/DeviceInfo.cs 查看文件

@@ -0,0 +1,24 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.Model
{
internal class DeviceInfo : ObservableObject
{
private string _deviceNum;
public string DeviceNum { get { return _deviceNum; }set { _deviceNum = value;OnPropertyChanged(); } }

private string _deviceName;
public string DeviceName { get { return _deviceName; } set { _deviceName = value; OnPropertyChanged(); } }

private string _ip;
public string Ip { get { return _ip; } set { _ip = value; OnPropertyChanged(); } }

private string _port;
public string Port { get { return _port; } set { _port = value; OnPropertyChanged(); } }
}
}

+ 15
- 0
FryPot_DosingSystem/Model/DeviceManage.cs 查看文件

@@ -0,0 +1,15 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.Model
{
internal class DeviceManage:ObservableObject
{
public ObservableCollection<DeviceInfo> Devices { get; set; } = new ObservableCollection<DeviceInfo>();
}
}

+ 13
- 0
FryPot_DosingSystem/Model/Global.cs 查看文件

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.Model
{
internal class Global
{
public static UserManage userManager { get; set; } = new UserManage();
}
}

+ 30
- 0
FryPot_DosingSystem/Model/LogModel.cs 查看文件

@@ -0,0 +1,30 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;

namespace FryPot_DosingSystem.Model
{
internal class LogModel:ObservableObject
{
private string _logTime;
public string LogTime { get { return _logTime; } set { _logTime = value; OnPropertyChanged(); } }

private string _logType;
public string LogType { get { return _logType; } set { _logType = value; OnPropertyChanged(); } }

private string _logMessage;
public string LogMessage { get { return _logMessage; } set { _logMessage = value; OnPropertyChanged(); } }

private Brush _foreColor;
public Brush ForeColor { get { return _foreColor; } set { _foreColor = value; OnPropertyChanged(); } }
public LogModel()
{
ForeColor = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#21bb2e"));
LogTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
}
}

+ 48
- 0
FryPot_DosingSystem/Model/LoginInfoConfig.cs 查看文件

@@ -0,0 +1,48 @@
using BPA.Message;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.Model
{
internal class LoginInfoConfig
{
private volatile static LoginInfoConfig _Instance;
public static LoginInfoConfig GetInstance => _Instance ?? (_Instance = new LoginInfoConfig());
private LoginInfoConfig() { }


public void Init()
{
if (File.Exists("LoginUp.hbl"))
{
var result = JsonConvert.DeserializeObject<UserManage>(File.ReadAllText("LoginUp.hbl").AESDecrypt());
if (result == null || (result != null && result.userInfos.Count <= 0))//无用户登陆相关信息
{
}
else
{
Global.userManager = result;
}
}
else
{
AddData();
}
}

private void AddData()
{
Global.userManager.userInfos.Add(new UserInfo() { Authority = Authority.管理员, UserName = "admin", Password = "123456",UserId="123" });
//Global.userManager.userInfos.Add(new UserInfo() { Authority = Authority.操作员, UserName = "czy", Password = "123456" });
//Global.userManager.userInfos.Add(new UserInfo() { Authority = Authority.观察员, UserName = "gcy", Password = "123456" });
//Global.userManager.userInfos.Add(new UserInfo() { Authority = Authority.技术员, UserName = "jsy", Password = "123456" });
File.WriteAllText("LoginUp.hbl", JsonConvert.SerializeObject(Global.userManager).AESEncrypt());
}
}
}

+ 35
- 0
FryPot_DosingSystem/Model/MaterialType.cs 查看文件

@@ -0,0 +1,35 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.Model
{
internal class MaterialType:ObservableObject
{
/// <summary>
/// 原料名称
/// </summary>
private string _materialName;
public string MaterialName { get { return _materialName; } set { _materialName = value; OnPropertyChanged(); } }
/// <summary>
/// 原料编码
/// </summary>
private string _materialCode;
public string MaterialCode { get { return _materialCode; } set { _materialCode = value; OnPropertyChanged(); } }
/// <summary>
/// 原料重量
/// </summary>
private string _materialWeight;
public string MaterialWeight { get { return _materialWeight; }set { _materialWeight = value;OnPropertyChanged(); } }
/// <summary>
/// 原料对应桶位置
/// </summary>
private string _materialLoc;
public string MaterialLoc { get { return _materialLoc; } set { _materialLoc = value; OnPropertyChanged(); } }

}
}

+ 14
- 0
FryPot_DosingSystem/Model/PlcVariableModel.cs 查看文件

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.Model
{
internal class PlcVariableModel
{
public string Address { get; set; }
public ushort Length { get; set;}
}
}

+ 17
- 0
FryPot_DosingSystem/Model/RecipeManage.cs 查看文件

@@ -0,0 +1,17 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.Model
{
internal class RecipeManage:ObservableObject
{
//private static RecipeManage _Instance;
//public static RecipeManage GetInstance=>_Instance ?? (_Instance = new RecipeManage());
public ObservableCollection<NewRecipeModel> Recipes { get; set; }=new ObservableCollection<NewRecipeModel>();
}
}

+ 32
- 0
FryPot_DosingSystem/Model/RecipeModel.cs 查看文件

@@ -0,0 +1,32 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.Model
{
internal class NewRecipeModel:ObservableObject
{
/// <summary>
/// 配方唯一ID
/// </summary>
private string _recipeId;
public string RecipeId { get { return _recipeId; }set { _recipeId = value; OnPropertyChanged(); } }
/// <summary>
/// 配方名称
/// </summary>
private string _recipeName;
public string RecipeName { get { return _recipeName; } set { _recipeName = value;OnPropertyChanged(); } }

/// <summary>
/// 配发下发状况信息
/// </summary>
private string _recipeSetInfo;
public string RecipeSetInfo { get { return _recipeSetInfo; } set { _recipeSetInfo = value; OnPropertyChanged(); } }

public ObservableCollection<MaterialType> materialCollection { get; set; } = new ObservableCollection<MaterialType>();
}
}

+ 28
- 0
FryPot_DosingSystem/Model/UserManage.cs 查看文件

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.Model
{
internal class UserManage
{
public List<UserInfo> userInfos { get; set; } = new List<UserInfo>();
}
public class UserInfo
{
public Authority Authority { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public string UserId { get; set; }
}

public enum Authority
{
管理员 = 1,
操作员 = 2,
观察员 = 3,
技术员 = 4
}
}

+ 187
- 0
FryPot_DosingSystem/View/AdministratorLoginView.xaml 查看文件

@@ -0,0 +1,187 @@
<UserControl x:Class="FryPot_DosingSystem.View.AdministratorLoginView"
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:vm="clr-namespace:FryPot_DosingSystem.ViewModel"
xmlns:helper="clr-namespace:FryPot_DosingSystem.Helper"
xmlns:uc="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
mc:Ignorable="d"
Height="450" Width="800"
Loaded="UserControl_Loaded">
<UserControl.DataContext>
<vm:AdministratorLoginViewModel></vm:AdministratorLoginViewModel>
</UserControl.DataContext>
<UserControl.Resources>
<Style x:Key="TxLogin" TargetType="TextBlock">
<Setter Property="FontSize" Value="20" />
<Setter Property="Foreground" Value="#ddd" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</UserControl.Resources>
<Grid>
<!--<Grid.ColumnDefinitions>
<ColumnDefinition Width="7*" />
<ColumnDefinition Width="10*" />
</Grid.ColumnDefinitions>-->
<!--<Grid.RowDefinitions>
<RowDefinition Height="5*" />
<RowDefinition Height="5*" />
<RowDefinition Height="5*" />
<RowDefinition Height="4*" />
<RowDefinition Height="8*" />
<RowDefinition Height="20*" />
</Grid.RowDefinitions>-->

<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<!--#region 登录-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.7*"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock
HorizontalAlignment="Right"
VerticalAlignment="Center"
Foreground="#feffff"
Style="{StaticResource TxLogin}"
Text="权限:" />
<ComboBox
Grid.Column="1"
Width="230"
HorizontalAlignment="Left"
VerticalAlignment="Center"
BorderBrush="#FF074B92"
BorderThickness="1"
FontFamily="楷体"
FontSize="20"
Foreground="#FF2AB2E7"
IsEditable="False"
ItemsSource="{Binding permission}"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding SelectText}" />

<TextBlock
Grid.Row="1"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Foreground="#feffff"
Style="{StaticResource TxLogin}"
Text="账号:" />
<TextBox
x:Name="tbx_admin"
Grid.Row="1"
Grid.Column="1"
Width="230"
Height="28"
HorizontalAlignment="Left"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Top"
Background="Transparent"
BorderBrush="White"
BorderThickness="0,0,0,1"
FontSize="20"
Foreground="#F8F8FF"
GotFocus="tbx_admin_GotFocus"
Text="{Binding Admin, Mode=TwoWay}" />


<TextBlock
Grid.Row="2"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Foreground="#feffff"
Style="{StaticResource TxLogin}"
Text="密码:" />
<PasswordBox
x:Name="password"
Grid.Row="2"
Grid.Column="1"
Width="230"
HorizontalAlignment="Left"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Top"
helper:PasswordBoxHelper.PasswordContent="{Binding Password, Mode=TwoWay}"
Background="Transparent"
BorderBrush="White"
BorderThickness="0,0,0,1"
CaretBrush="White"
FontSize="16"
Foreground="#F8F8FF"
GotFocus="password_GotFocus" />
<TextBlock
Grid.Row="3"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="楷体"
FontSize="16"
Foreground="#FFE2415C"
Text="{Binding ErrorMessage}"
TextWrapping="Wrap" />
<StackPanel Grid.Row="4" Grid.ColumnSpan="2" Orientation="Horizontal">
<Button
Margin="280,0,0,0"
Width="120"
Height="40"
VerticalAlignment="Center"
Background="Transparent"
BorderBrush="#ff19b7ec"
BorderThickness="2"
Command="{Binding AdminLoginCommand}"
Content="登 录"
FontSize="28"
Foreground="#9934F7F7"
IsDefault="True" />
<Button
Margin="30,0,0,0"
Width="120"
Height="40"
VerticalAlignment="Center"
Background="Transparent"
BorderBrush="#ff19b7ec"
BorderThickness="2"
Content="{Binding RegistOrChange}"
FontSize="28"
Foreground="#9934F7F7"
IsDefault="True"
Command="{Binding RegistCommand}"
CommandParameter="{Binding RegistOrChange}"/>

</StackPanel>

</Grid>
<!--#endregion-->

<!--#region 密码修改-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
</Grid>
<!--#endregion-->
<uc:UserKeyBoard
x:Name="myKeyboard"
Grid.Row="5"
Grid.ColumnSpan="2"
Margin="100,10,100,50"
Focusable="False" />
</Grid>
</UserControl>

+ 95
- 0
FryPot_DosingSystem/View/AdministratorLoginView.xaml.cs 查看文件

@@ -0,0 +1,95 @@
using BPASmartClient.Helper;
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;
using static BPASmartClient.CustomResource.UserControls.UserKeyBoard;

namespace FryPot_DosingSystem.View
{
/// <summary>
/// AdministratorLoginView.xaml 的交互逻辑
/// </summary>
public partial class AdministratorLoginView : UserControl
{
public AdministratorLoginView()
{
InitializeComponent();
}


private void MyKeyDown_Password(object _key)
{
EKeyitem key = EKeyitem.A;
if (_key.GetType() == typeof(EKeyitem)) key = (EKeyitem)_key;
switch (key)
{
case EKeyitem.DEL:
if (password.Password.Length > 0)
{
password.Password = password.Password.Substring(0, password.Password.Length - 1);
}
break;
case EKeyitem.AC:
password.Password = string.Empty;
break;
case EKeyitem.OK:
break;
default:
password.Password += _key.ToString();
break;
}

}
private void tbx_admin_GotFocus(object sender, RoutedEventArgs e)
{
myKeyboard.MyKeyDown = MyKeyDown_Admin;
}

private void password_GotFocus(object sender, RoutedEventArgs e)
{
myKeyboard.MyKeyDown = MyKeyDown_Password;
}

private void MyKeyDown_Admin(object _key)
{
EKeyitem key = EKeyitem.A;
if (_key.GetType() == typeof(EKeyitem)) key = (EKeyitem)_key;
switch (key)
{
case EKeyitem.DEL:
if (tbx_admin.Text.Length > 0)
{
tbx_admin.Text = tbx_admin.Text.Substring(0, tbx_admin.Text.Length - 1);
}
break;
case EKeyitem.AC:
tbx_admin.Text = string.Empty;
break;
case EKeyitem.OK:
break;
default:
tbx_admin.Text += _key.ToString();
break;
}
this.tbx_admin.Focus();
}

private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
this.tbx_admin.Focus();
}
}
}

+ 185
- 0
FryPot_DosingSystem/View/AdministratorPasswordChangeView.xaml 查看文件

@@ -0,0 +1,185 @@
<UserControl x:Class="FryPot_DosingSystem.View.AdministratorPasswordChangeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:helper="clr-namespace:FryPot_DosingSystem.Helper"
xmlns:uc="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:local="clr-namespace:FryPot_DosingSystem.View"
xmlns:vm="clr-namespace:FryPot_DosingSystem.ViewModel"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.DataContext>
<vm:AdministratorPasswordChangeViewModel/>
</UserControl.DataContext>
<UserControl.Resources>
<Style x:Key="TxLogin" TargetType="TextBlock">
<Setter Property="FontSize" Value="20" />
<Setter Property="Foreground" Value="#ddd" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</UserControl.Resources>
<Grid>
<!--<Grid.ColumnDefinitions>
<ColumnDefinition Width="7*" />
<ColumnDefinition Width="10*" />
</Grid.ColumnDefinitions>-->
<!--<Grid.RowDefinitions>
<RowDefinition Height="5*" />
<RowDefinition Height="5*" />
<RowDefinition Height="5*" />
<RowDefinition Height="4*" />
<RowDefinition Height="8*" />
<RowDefinition Height="20*" />
</Grid.RowDefinitions>-->

<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<!--#region 登录-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.7*"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock
HorizontalAlignment="Right"
VerticalAlignment="Center"
Foreground="#feffff"
Style="{StaticResource TxLogin}"
Text="权限:" />
<ComboBox
Grid.Column="1"
Width="230"
HorizontalAlignment="Left"
VerticalAlignment="Center"
BorderBrush="#FF074B92"
BorderThickness="1"
FontFamily="楷体"
FontSize="20"
Foreground="#FF2AB2E7"
IsEditable="False"
ItemsSource="{Binding permission}"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding SelectText}" />

<TextBlock
Grid.Row="1"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Foreground="#feffff"
Style="{StaticResource TxLogin}"
Text="账号:" />
<TextBox
x:Name="tbx_admin"
Grid.Row="1"
Grid.Column="1"
Width="230"
Height="28"
HorizontalAlignment="Left"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Top"
Background="Transparent"
BorderBrush="White"
BorderThickness="0,0,0,1"
FontSize="20"
Foreground="#F8F8FF"
GotFocus="tbx_admin_GotFocus"
Text="{Binding Admin, Mode=TwoWay}" />


<TextBlock
Grid.Row="2"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Foreground="#feffff"
Style="{StaticResource TxLogin}"
Text="密码:" />
<PasswordBox
x:Name="password"
Grid.Row="2"
Grid.Column="1"
Width="230"
HorizontalAlignment="Left"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Top"
helper:PasswordBoxHelper.PasswordContent="{Binding Password, Mode=TwoWay}"
Background="Transparent"
BorderBrush="White"
BorderThickness="0,0,0,1"
CaretBrush="White"
FontSize="16"
Foreground="#F8F8FF"
GotFocus="password_GotFocus" />
<TextBlock
Grid.Row="3"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="楷体"
FontSize="16"
Foreground="#FFE2415C"
Text="{Binding ErrorMessage}"
TextWrapping="Wrap" />
<StackPanel Grid.Row="4" Grid.ColumnSpan="2" Orientation="Horizontal">
<Button
Margin="280,0,0,0"
Width="120"
Height="40"
VerticalAlignment="Center"
Background="Transparent"
BorderBrush="#ff19b7ec"
BorderThickness="2"
Command="{Binding AdminLoginCommand}"
Content="登 录"
FontSize="28"
Foreground="#9934F7F7"
IsDefault="True" />
<Button
Margin="30,0,0,0"
Width="120"
Height="40"
VerticalAlignment="Center"
Background="Transparent"
BorderBrush="#ff19b7ec"
BorderThickness="2"
Content="修改"
FontSize="28"
Foreground="#9934F7F7"
IsDefault="True"
Command="{Binding RegistCommand}"/>

</StackPanel>

</Grid>
<!--#endregion-->

<!--#region 密码修改-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
</Grid>
<!--#endregion-->
<uc:UserKeyBoard
x:Name="myKeyboard"
Grid.Row="5"
Grid.ColumnSpan="2"
Margin="100,10,100,50"
Focusable="False" />
</Grid>
</UserControl>

+ 85
- 0
FryPot_DosingSystem/View/AdministratorPasswordChangeView.xaml.cs 查看文件

@@ -0,0 +1,85 @@
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.Navigation;
using System.Windows.Shapes;
using static BPASmartClient.CustomResource.UserControls.UserKeyBoard;

namespace FryPot_DosingSystem.View
{
/// <summary>
/// AdministratorPasswordChangeView.xaml 的交互逻辑
/// </summary>
public partial class AdministratorPasswordChangeView : UserControl
{
public AdministratorPasswordChangeView()
{
InitializeComponent();
}

private void tbx_admin_GotFocus(object sender, RoutedEventArgs e)
{
myKeyboard.MyKeyDown = MyKeyDown_Admin;
}

private void password_GotFocus(object sender, RoutedEventArgs e)
{
myKeyboard.MyKeyDown = MyKeyDown_Password;
}
private void MyKeyDown_Password(object _key)
{
EKeyitem key = EKeyitem.A;
if (_key.GetType() == typeof(EKeyitem)) key = (EKeyitem)_key;
switch (key)
{
case EKeyitem.DEL:
if (password.Password.Length > 0)
{
password.Password = password.Password.Substring(0, password.Password.Length - 1);
}
break;
case EKeyitem.AC:
password.Password = string.Empty;
break;
case EKeyitem.OK:
break;
default:
password.Password += _key.ToString();
break;
}

}
private void MyKeyDown_Admin(object _key)
{
EKeyitem key = EKeyitem.A;
if (_key.GetType() == typeof(EKeyitem)) key = (EKeyitem)_key;
switch (key)
{
case EKeyitem.DEL:
if (tbx_admin.Text.Length > 0)
{
tbx_admin.Text = tbx_admin.Text.Substring(0, tbx_admin.Text.Length - 1);
}
break;
case EKeyitem.AC:
tbx_admin.Text = string.Empty;
break;
case EKeyitem.OK:
break;
default:
tbx_admin.Text += _key.ToString();
break;
}
this.tbx_admin.Focus();
}
}
}

+ 12
- 0
FryPot_DosingSystem/View/AlarmInfoView.xaml 查看文件

@@ -0,0 +1,12 @@
<UserControl x:Class="FryPot_DosingSystem.View.AlarmInfoView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FryPot_DosingSystem.View"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
</Grid>
</UserControl>

+ 28
- 0
FryPot_DosingSystem/View/AlarmInfoView.xaml.cs 查看文件

@@ -0,0 +1,28 @@
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.Navigation;
using System.Windows.Shapes;

namespace FryPot_DosingSystem.View
{
/// <summary>
/// AlarmInfoView.xaml 的交互逻辑
/// </summary>
public partial class AlarmInfoView : UserControl
{
public AlarmInfoView()
{
InitializeComponent();
}
}
}

+ 72
- 0
FryPot_DosingSystem/View/DeviceListVIew.xaml 查看文件

@@ -0,0 +1,72 @@
<UserControl x:Class="FryPot_DosingSystem.View.DeviceListVIew"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="clr-namespace:FryPot_DosingSystem.ViewModel"
xmlns:local="clr-namespace:FryPot_DosingSystem.View"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.DataContext>
<vm:DeviceListViewModel/>
</UserControl.DataContext>
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="20"/>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Width="150" Height="35" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,20,0" Content="添加设备" Command="{Binding AddDeviceCommand}"></Button>
<Button Content="保存设置" Width="150" Height="35" Margin="0,0,20,0" Command="{Binding SaveDeviceConfig}"></Button>
</StackPanel>
<Line Grid.Row="1" X1="0" Y1="10" X2="1300" Y2="10" Stroke="Aqua" StrokeThickness="1"></Line>
<ItemsControl Grid.Row="2" ItemsSource="{Binding devices}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<RadioButton>
<RadioButton.Template>
<ControlTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="设备名称:" Margin="10,10,10,10" FontSize="16" ></TextBlock>
<ComboBox ItemsSource="{Binding DataContext.DeviceName, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" Text="{Binding DeviceName}" Width="150" FontSize="16"></ComboBox>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="ModBus IP:" Margin="10,10,10,10" FontSize="16" VerticalAlignment="Center"></TextBlock>
<TextBox Width="150" FontSize="16" Text="{Binding Ip}" ></TextBox>
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="Port:" FontSize="16" Margin="10,10,10,10"></TextBlock>
<TextBox Width="150" FontSize="16" Text="{Binding Port}"></TextBox>
</StackPanel>
<Button Grid.Column="3" Content="删除" Width="150" Height="30" FontSize="16" Command="{Binding DataContext.DeleteDevice,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}" CommandParameter="{Binding DeviceNum}"></Button>
</Grid>
</ControlTemplate>
</RadioButton.Template>
</RadioButton>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</UserControl>

+ 28
- 0
FryPot_DosingSystem/View/DeviceListVIew.xaml.cs 查看文件

@@ -0,0 +1,28 @@
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.Navigation;
using System.Windows.Shapes;

namespace FryPot_DosingSystem.View
{
/// <summary>
/// DeviceListVIew.xaml 的交互逻辑
/// </summary>
public partial class DeviceListVIew : UserControl
{
public DeviceListVIew()
{
InitializeComponent();
}
}
}

+ 12
- 0
FryPot_DosingSystem/View/EditRecipeView.xaml 查看文件

@@ -0,0 +1,12 @@
<UserControl x:Class="FryPot_DosingSystem.View.EditRecipeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FryPot_DosingSystem.View"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
</Grid>
</UserControl>

+ 28
- 0
FryPot_DosingSystem/View/EditRecipeView.xaml.cs 查看文件

@@ -0,0 +1,28 @@
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.Navigation;
using System.Windows.Shapes;

namespace FryPot_DosingSystem.View
{
/// <summary>
/// EditRecipeView.xaml 的交互逻辑
/// </summary>
public partial class EditRecipeView : UserControl
{
public EditRecipeView()
{
InitializeComponent();
}
}
}

+ 12
- 0
FryPot_DosingSystem/View/HardWareStatusView.xaml 查看文件

@@ -0,0 +1,12 @@
<UserControl x:Class="FryPot_DosingSystem.View.HardWareStatusView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FryPot_DosingSystem.View"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
</Grid>
</UserControl>

+ 28
- 0
FryPot_DosingSystem/View/HardWareStatusView.xaml.cs 查看文件

@@ -0,0 +1,28 @@
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.Navigation;
using System.Windows.Shapes;

namespace FryPot_DosingSystem.View
{
/// <summary>
/// HardWareStatusView.xaml 的交互逻辑
/// </summary>
public partial class HardWareStatusView : UserControl
{
public HardWareStatusView()
{
InitializeComponent();
}
}
}

+ 54
- 0
FryPot_DosingSystem/View/LogView.xaml 查看文件

@@ -0,0 +1,54 @@
<UserControl x:Class="FryPot_DosingSystem.View.LogView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FryPot_DosingSystem.View"
xmlns:vm="clr-namespace:FryPot_DosingSystem.ViewModel"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">

<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml"/>
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition/>
</Grid.RowDefinitions>
<DataGrid Grid.Row="1" ItemsSource="{Binding LogDatas}">
<DataGrid.Columns>
<DataGridTemplateColumn Header="日志时间" Width="300">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding LogTime, UpdateSourceTrigger=PropertyChanged}" Foreground="{Binding ForeColor, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center" FontSize="14"></TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="日志类型" Width="300">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding LogType, UpdateSourceTrigger=PropertyChanged}" Foreground="{Binding ForeColor, UpdateSourceTrigger=PropertyChanged}" FontSize="14" HorizontalAlignment="Center">
</TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="日志信息" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding LogMessage, UpdateSourceTrigger=PropertyChanged}"
Foreground="{Binding ForeColor, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center" FontSize="14"></TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
</UserControl>

+ 30
- 0
FryPot_DosingSystem/View/LogView.xaml.cs 查看文件

@@ -0,0 +1,30 @@
using FryPot_DosingSystem.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.Navigation;
using System.Windows.Shapes;

namespace FryPot_DosingSystem.View
{
/// <summary>
/// LogView.xaml 的交互逻辑
/// </summary>
public partial class LogView : UserControl
{
public LogView()
{
InitializeComponent();
this.DataContext = LogViewModel.GetInstance;
}
}
}

+ 255
- 0
FryPot_DosingSystem/View/MainWindow.xaml 查看文件

@@ -0,0 +1,255 @@
<Window x:Class="FryPot_DosingSystem.View.MainWindow"
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:vm="clr-namespace:FryPot_DosingSystem.ViewModel"
xmlns:local="clr-namespace:FryPot_DosingSystem.View"
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
Title="MainWindow"
Width="1300"
Height="800"
AllowsTransparency="True"
Background="{x:Null}"
Topmost="False"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" />
<ResourceDictionary>
<!--#region ListBox样式-->
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="BorderBrush" Value="{x:Null}" />
<Setter Property="Foreground" Value="White" />
<Setter Property="FontSize" Value="20" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border x:Name="border" CornerRadius="8">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--#endregion-->
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Window.DataContext>
<vm:MainViewModel></vm:MainViewModel>
</Window.DataContext>

<Border x:Name="br" Style="{DynamicResource border主窗体背景}">
<Grid x:Name="grid_main">
<Grid.RowDefinitions>
<RowDefinition Height="60" />
<RowDefinition />
</Grid.RowDefinitions>

<!-- 标题 -->
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Border
Grid.ColumnSpan="2"
Height="52"
VerticalAlignment="Top"
Style="{DynamicResource bordertop矩形}" />
<Border Style="{DynamicResource bordertopL}" />
<Image
Margin="20,0,0,0"
VerticalAlignment="Center"
Style="{DynamicResource imagetop_Title}" />
<Grid Grid.Column="1">

<ListBox
x:Name="lstEnt"
Background="{x:Null}"
BorderBrush="{x:Null}"
ScrollViewer.CanContentScroll="False"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
BorderThickness="0"
ItemContainerStyle="{StaticResource ResourceKey=ListBoxItemStyle1}"
ItemsSource="{Binding DisplayMenus}" Margin="0,0,293,0">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<RadioButton
Command="{Binding DataContext.TogglePag, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}"
CommandParameter="{Binding CommandParameter}"
Content="{Binding MenuName}"
GroupName="all"
Style="{StaticResource MenuRadioButtonStyle}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>

<StackPanel
Grid.Column="4"
Height="50"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Orientation="Horizontal">
<Border Style="{DynamicResource border竖线}" />

<Grid>

<ToggleButton
Name="tb"
Margin="5"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Cursor="Hand"
IsChecked="{Binding UserManagement}"
Style="{DynamicResource StatusBtnStyle网络连接状态}"
ToolTip="用户管理" />

<!-- 当 StaysOpen 设置为 True 时 popup失去焦点的时候不会自动关闭 -->
<Popup
AllowsTransparency="True"
Focusable="False"
IsOpen="{Binding IsChecked, ElementName=tb}"
Placement="Bottom"
PlacementTarget="{Binding ElementName=tb}"
StaysOpen="False">
<Border Background="#081424" ClipToBounds="True">
<Grid Width="100" Margin="0">
<StackPanel Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}">
<Button
Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}"
Margin="0,5,0,1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Command="{Binding PasswordChange}"
Content="密码修改"
Cursor="Hand" />
<Button
Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}"
Margin="0,5,0,1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Command="{Binding Login}"
Content="登录账号"
Cursor="Hand" />
<Button
Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}"
Margin="0,5,0,1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Command="{Binding ExitLogin}"
Content="退出登录"
Cursor="Hand" />
</StackPanel>
</Grid>
</Border>
</Popup>
</Grid>


<Border Style="{DynamicResource border竖线}" />
<ToggleButton
HorizontalAlignment="Center"
VerticalAlignment="Center"
Cursor="Hand"
DataContext="{Binding IsAlarm}"
Style="{DynamicResource StatusBtnStyle告警}"
ToolTip="告警消息" />
<Border Style="{DynamicResource border竖线}" />
<control:DateTimeUI Margin="10,0,10,0" VerticalAlignment="Center" />
<Border Style="{DynamicResource border竖线}" />
<Button
x:Name="ButClose"
Grid.Column="4"
Margin="10,0,20,0"
VerticalAlignment="Center"
Content="退出"
Cursor="Hand"
Style="{DynamicResource CommonBtn_返回}"
ToolTip="退出程序"
/>
</StackPanel>
</Grid>

<!-- 底部窗体 -->
<Grid Grid.Row="1" Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="45" />
<RowDefinition />
</Grid.RowDefinitions>
<!-- 顶部装饰 -->
<Border
Grid.Row="0"
Grid.RowSpan="2"
Style="{DynamicResource border右下}" />

<Border
Grid.Row="0"
Grid.RowSpan="2"
Style="{DynamicResource border左下}" />

<Border
Grid.Row="0"
Grid.RowSpan="2"
Style="{DynamicResource border右上}" />

<Border
Grid.Row="0"
Grid.RowSpan="2"
Style="{DynamicResource border左上}" />

<Grid Margin="10">
<Border Width="600" Style="{DynamicResource borderFromTitle}" />

<StackPanel Orientation="Horizontal">
<CheckBox
Margin="5,0,5,0"
Content="开机启动"
IsChecked="{Binding AutoStart}" />
</StackPanel>

<TextBlock
x:Name="Title"
HorizontalAlignment="Center"
VerticalAlignment="Top"
FontSize="16"
Foreground="#feffff"
Text="{Binding WindowTitleName}" />

</Grid>

<!--#region 底部窗体栏-->
<ContentControl
x:Name="contentRegion"
Grid.Row="1"
Content="{Binding MyWindow}"
/>
<!--#endregion-->
</Grid>


</Grid>
</Border>


</Window>

+ 64
- 0
FryPot_DosingSystem/View/MainWindow.xaml.cs 查看文件

@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 FryPot_DosingSystem.View
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
ScrollViewer scrollViewer;
double lastPointX;
double distance;
public MainWindow()
{
InitializeComponent();
Initialize();
}
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonDown(e);
// 获取鼠标相对控件位置 (grid_main为控件Name)
Point position = Mouse.GetPosition(grid_main);
// 如果鼠标位置在控件内,允许拖动
if (e.LeftButton == MouseButtonState.Pressed)
{
if (position.X >= 0 && position.X < grid_main.ActualWidth && position.Y >= 0 && position.Y < grid_main.ActualHeight)
{
this.DragMove();
}

}
}

private void Initialize()
{
this.ButClose.Click += (obj, e) =>
{
MessageBoxResult res = MessageBox.Show("确定关闭上位机软件?", "警告", MessageBoxButton.OKCancel);
if (res == MessageBoxResult.OK)
{
this.Close();
}
};



}

}
}

+ 113
- 0
FryPot_DosingSystem/View/NewRecipeView.xaml 查看文件

@@ -0,0 +1,113 @@
<Window x:Class="FryPot_DosingSystem.View.NewRecipeView"
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:FryPot_DosingSystem.View"
xmlns:vm="clr-namespace:FryPot_DosingSystem.ViewModel"
mc:Ignorable="d"
Title="NewRecipeView" Height="550" Width="800"
WindowStyle="None" WindowStartupLocation="CenterScreen" AllowsTransparency="True">
<Window.DataContext>
<vm:NewRecipeViewModel></vm:NewRecipeViewModel>
</Window.DataContext>
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" />

<ResourceDictionary>
<!--#region ListBox样式-->
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="BorderBrush" Value="{x:Null}" />
<Setter Property="Foreground" Value="White" />
<Setter Property="FontSize" Value="20" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border x:Name="border" CornerRadius="8">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--#endregion-->
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Border Name="br">
<Border.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/bg.png"></ImageBrush>
</Border.Background>
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Text="配方信息" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Aqua" FontSize="25" Margin="0,10"></TextBlock>
<UniformGrid Grid.Row="1" Columns="2">
<StackPanel Orientation="Horizontal">
<TextBlock Text="请输入配方名称:" Foreground="Aqua" FontSize="18" Margin="10,0,5,0" VerticalAlignment="Center"></TextBlock>
<TextBox Text="{Binding RecipeName}" Width="230" Height="30" BorderThickness="1" BorderBrush="Aqua" VerticalAlignment="Center" FontSize="16" ></TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button Content="添加原料" Width="150" Margin="10" Height="30" Cursor="Hand" Command="{Binding AddRecipe}" ></Button>
<Button Content="确认" Height="30" Width="100" Margin="5,10" Command="{Binding Comfirm}"></Button>
<Button Click="Button_Click" Content="取消" Height="30" FontSize="20" Width="100" Margin="8,10" Cursor="Hand"></Button>
</StackPanel>
</UniformGrid>
<ScrollViewer Grid.Row="2">
<ItemsControl ItemsSource="{Binding materials}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<RadioButton>
<RadioButton.Template>
<ControlTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="210"/>

<ColumnDefinition Width="210"></ColumnDefinition>
<ColumnDefinition Width="225"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<ComboBox ItemsSource="{Binding DataContext.materialNames,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" Text="{Binding MaterialName}" Margin="10,0,0,10" Width="190"></ComboBox>
<StackPanel Grid.Column="1" Orientation="Horizontal" >
<TextBox Text="{Binding MaterialLoc}" Width="170" Margin="35,0,0,10" ></TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Column="2">
<TextBox Text="{Binding MaterialWeight}" Width="170" Margin="35,0,0,10" ></TextBox>
<TextBlock VerticalAlignment="Center" Margin="4,0,0,10" Text="g" ></TextBlock>
</StackPanel>
<Button Grid.Column="3"
Content="删除"
Width="94"
Margin="0,0,0,10"
HorizontalAlignment="Right"
Command="{Binding DataContext.RemoveRecipe,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}"
CommandParameter="{Binding MaterialCode}"></Button>
</Grid>
</ControlTemplate>
</RadioButton.Template>
</RadioButton>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Border>
</Window>

+ 36
- 0
FryPot_DosingSystem/View/NewRecipeView.xaml.cs 查看文件

@@ -0,0 +1,36 @@
using BPASmartClient.Helper;
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 FryPot_DosingSystem.View
{
/// <summary>
/// NewRecipeView.xaml 的交互逻辑
/// </summary>
public partial class NewRecipeView : Window
{
public NewRecipeView()
{
InitializeComponent();
this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); };
ActionManage.GetInstance.CancelRegister("CloseNewRecipeView");
ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "CloseNewRecipeView");
}

private void Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

+ 82
- 0
FryPot_DosingSystem/View/RecipeSendDownView.xaml 查看文件

@@ -0,0 +1,82 @@
<UserControl x:Class="FryPot_DosingSystem.View.RecipeSendDownView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FryPot_DosingSystem.View"
xmlns:vm="clr-namespace:FryPot_DosingSystem.ViewModel"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.DataContext>
<vm:RecipeSetDownViewModel/>
</UserControl.DataContext>
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button HorizontalAlignment="Right" VerticalAlignment="Center" Content="配方一键下发" Width="110" Height="30" Margin="0,0,10,0" Cursor="Hand" Command="{Binding AllRecipeSetDownCommand}"></Button>
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding Recipes}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Aqua" BorderThickness="2" CornerRadius="14" Height="120" Margin="5,5">
<RadioButton>
<RadioButton.Template>
<ControlTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="0.01*"></ColumnDefinition>

<ColumnDefinition Width="4*"></ColumnDefinition>
<ColumnDefinition Width="1.2*"/>
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="70"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Text="{Binding RecipeName}" FontSize="35" HorizontalAlignment="Center"></TextBlock>
<Button Grid.Row="1" Width="100" Content="配方下发" Command="{Binding DataContext.RecipeSetDownCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}"
CommandParameter="{Binding RecipeId}" Cursor="Hand"></Button>
</Grid>
<Line StrokeThickness="3" Grid.Column="1" HorizontalAlignment="Left" Stroke="LawnGreen" X1="0" Y1="5" X2="0" Y2="110"></Line>
<Grid Grid.Column="2">
<!--后续添加内容-->
</Grid>
<Grid Grid.Column="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Line StrokeThickness="3" Grid.Column="0" HorizontalAlignment="Left" Stroke="LawnGreen" X1="0" Y1="5" X2="0" Y2="110"></Line>
<TextBlock Grid.Column="1" FontSize="16" Text="{Binding RecipeSetInfo}" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
<!--后续添加内容-->
</Grid>
</Grid>
</ControlTemplate>
</RadioButton.Template>
</RadioButton>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</UserControl>

+ 28
- 0
FryPot_DosingSystem/View/RecipeSendDownView.xaml.cs 查看文件

@@ -0,0 +1,28 @@
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.Navigation;
using System.Windows.Shapes;

namespace FryPot_DosingSystem.View
{
/// <summary>
/// RecipeSendDownView.xaml 的交互逻辑
/// </summary>
public partial class RecipeSendDownView : UserControl
{
public RecipeSendDownView()
{
InitializeComponent();
}
}
}

+ 127
- 0
FryPot_DosingSystem/View/RecipeSetView.xaml 查看文件

@@ -0,0 +1,127 @@
<UserControl x:Class="FryPot_DosingSystem.View.RecipeSetView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FryPot_DosingSystem.View"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:vm="clr-namespace:FryPot_DosingSystem.ViewModel"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.DataContext>
<vm:RecipeSetViewModel></vm:RecipeSetViewModel>
</UserControl.DataContext>
<UserControl.Resources>
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" />
<SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="TitleFontColor" Color="#ddd" />
<SolidColorBrush x:Key="CursorColor" Color="Aqua" />
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="TextBlockForeground" Color="#9934F7F7" />

<Style x:Key="TextBlockStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="楷体" />
<Setter Property="FontSize" Value="16" />
<Setter Property="Background" Value="Transparent" />
<!--<Setter Property="Foreground" Value="{StaticResource FontColor}" />-->
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>

<Style x:Key="buttonStyle" TargetType="Button">
<Setter Property="Background" Value="Transparent" />
<Setter Property="FontSize" Value="16" />
<Setter Property="Foreground" Value="Aqua" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="BorderThickness" Value="0" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Cursor" Value="Hand"></Setter>
</Trigger>
</Style.Triggers>
</Style>

</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<UniformGrid Columns="2">
<Image Source="../hbl.ico" HorizontalAlignment="Left"></Image>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Column="2">
<pry:IcoButton Content="新建配方"
Margin="80,5,15,5"
Width="150"
FontSize="16"
Foreground="Aqua"
IcoText="&#xe626;"
Cursor="Hand"
Style="{StaticResource NewButtonStyle}"
Command="{Binding NewRecipe}">
</pry:IcoButton>
<pry:IcoButton
Content="保存配方" Margin="0,5"
Width="150"
FontSize="16"
Foreground="Aqua"
IcoText="&#xe626;"
Cursor="Hand"
Style="{StaticResource NewButtonStyle}"
Command="{Binding SaveRecipe}">
</pry:IcoButton>

</StackPanel>
</UniformGrid>
<TextBlock Grid.Row="1" Text="配方信息" Foreground="Aquamarine" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" Margin="0,5" ></TextBlock>
<ScrollViewer Grid.Row="2" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding recipeModels}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<RadioButton>
<RadioButton.Template>
<ControlTemplate>
<Grid x:Name="gr">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding RecipeId}" Grid.Column="0" FontSize="16" HorizontalAlignment="Left" VerticalAlignment="Center"
Foreground="Aqua"
Margin="5,0,0,5"></TextBlock>
<TextBlock Text="{Binding RecipeName}" Grid.Column="1" Margin="5,0,0,5"
HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Aqua" FontSize="16"></TextBlock>
<Grid Grid.Column="3">
<Button FontSize="16"
Margin="5,0,0,5" Content="编辑配方" Style="{StaticResource buttonStyle}" Command="{Binding DataContext.EditRecipeCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}"
CommandParameter="{Binding RecipeId}"></Button>
</Grid>
<Grid Grid.Column="4">
<Button Margin="5,0,0,5" FontSize="16" Content="删除配方" Style="{StaticResource buttonStyle}" Command="{Binding DataContext.DeleteRecipeCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" CommandParameter="{Binding RecipeId}">
</Button>
</Grid>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="gr" Property="Background" Value="#3300ccff" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</RadioButton.Template>
</RadioButton>

</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</UserControl>

+ 30
- 0
FryPot_DosingSystem/View/RecipeSetView.xaml.cs 查看文件

@@ -0,0 +1,30 @@
using FryPot_DosingSystem.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.Navigation;
using System.Windows.Shapes;

namespace FryPot_DosingSystem.View
{
/// <summary>
/// RecipeSetView.xaml 的交互逻辑
/// </summary>
public partial class RecipeSetView : UserControl
{
public RecipeSetView()
{
InitializeComponent();
}
}
}

+ 172
- 0
FryPot_DosingSystem/ViewModel/AdministratorLoginViewModel.cs 查看文件

@@ -0,0 +1,172 @@
using BPA.Message;
using BPASmartClient.Helper;
using FryPot_DosingSystem.Model;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using Newtonsoft.Json;
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Windows;

namespace FryPot_DosingSystem.ViewModel
{
public class AdministratorLoginViewModel : ObservableObject
{
/// <summary>
/// 按钮内容修改:注册/修改
/// </summary>
private string _registOrChange;
public string RegistOrChange { get { return _registOrChange; } set { _registOrChange = value; OnPropertyChanged(); } }
public string Admin { get { return _admin; } set { _admin = value; OnPropertyChanged(); } }
private string _admin;

public string Password { get { return _password; } set { _password = value; OnPropertyChanged(); } }
private string _password;

public string ErrorMessage { get { return _errorMessage; } set { _errorMessage = value; OnPropertyChanged(); } }
private string _errorMessage;

public string SelectText { get { return _mSelectText; } set { _mSelectText = value; OnPropertyChanged(); } }
private string _mSelectText;

private UserInfo _userInfo;
public UserInfo UserInfo { get { return _userInfo; }set { _userInfo = value;OnPropertyChanged(); } }

private string _account;
public string Account { get { return _account; } set { _account = value;OnPropertyChanged(); } }

private string _txtpassword;
public string Txtpassword { get { return _txtpassword; } set { _txtpassword = value; OnPropertyChanged(); } }

public RelayCommand AdminLoginCommand { get; set; }
public RelayCommand RegistCommand { get; set; }

public ObservableCollection<string> permission { get; set; } = new ObservableCollection<string>();

public AdministratorLoginViewModel()
{
permission.Add("管理员");
permission.Add("操作员");
permission.Add("观察员");
permission.Add("技术员");
SelectText = permission[0];
var content = ActionManage.GetInstance.SendResult("ContentUpdate");
if (content != null && content is string strContent)
{
RegistOrChange = strContent;
}
var loginInfo = ActionManage.GetInstance.SendResult("LoginInfo");
if (loginInfo != null && loginInfo is UserInfo LoginInfo)
{
UserInfo = LoginInfo;
if (UserInfo != null)
{
switch (UserInfo.Authority)
{
case Authority.管理员: SelectText = permission[0]; break;
case Authority.操作员: SelectText = permission[1]; break;
case Authority.观察员: SelectText = permission[2]; break;
case Authority.技术员: SelectText = permission[3]; break;
}
Account = UserInfo.UserName;
Txtpassword = UserInfo.Password;
}
}
RegistCommand = new RelayCommand(() =>
{
if (RegistOrChange != null)
{
if (RegistOrChange == "注册")
{
if (Admin == null || Admin == string.Empty || Password == null || Password == string.Empty)
{
ErrorMessage = "注册信息不能为空!!!";
}
else
{
ep:
string guid=Guid.NewGuid().ToString();//用户唯一ID
var resultManage = JsonConvert.DeserializeObject<UserManage>(File.ReadAllText("LoginUp.hbl").AESDecrypt());
if (resultManage != null && resultManage is UserManage manage)
{
int a= manage.userInfos.FindIndex(p => p.UserId == guid);
if (a == -1)
{
switch (SelectText)
{
case "管理员": Global.userManager.userInfos.Add(new UserInfo() { Authority = Authority.管理员, UserName = Admin, Password = Password,UserId=guid }); break;
case "技术员": Global.userManager.userInfos.Add(new UserInfo() { Authority = Authority.技术员, UserName = Admin, Password = Password,UserId = guid }); break;
case "操作员": Global.userManager.userInfos.Add(new UserInfo() { Authority = Authority.操作员, UserName = Admin, Password = Password, UserId = guid }); break;
case "观察员": Global.userManager.userInfos.Add(new UserInfo() { Authority = Authority.观察员, UserName = Admin, Password = Password, UserId = guid }); break;
}
File.WriteAllText("LoginUp.hbl", JsonConvert.SerializeObject(Global.userManager).AESEncrypt());
var result = JsonConvert.DeserializeObject<UserManage>(File.ReadAllText("LoginUp.hbl").AESDecrypt());
Global.userManager = result;
ErrorMessage = "注册成功";
}
else
{
goto ep;
}
}
}
}
if (RegistOrChange == "修改")
{
//执行密码修改操作
try
{
if (UserInfo != null)
{
UserInfo info = Global.userManager.userInfos.Find(p => p.UserId == UserInfo.UserId);
if (info != null)
{
switch (SelectText)
{
case "管理员": info.Authority = Authority.管理员; info.UserName = Admin; info.Password = Password; break;
case "技术员": info.Authority = Authority.技术员; info.UserName = Admin; info.Password = Password; break;
case "操作员": info.Authority = Authority.操作员; info.UserName = Admin; info.Password = Password; break;
case "观察员": info.Authority = Authority.观察员; info.UserName = Admin; info.Password = Password; break;
}
File.WriteAllText("LoginUp.hbl", JsonConvert.SerializeObject(Global.userManager).AESEncrypt());
var result = JsonConvert.DeserializeObject<UserManage>(File.ReadAllText("LoginUp.hbl").AESDecrypt());
Global.userManager = result;
ErrorMessage = "修改成功";
}
else
{
ErrorMessage = "修改失败";
}
}
else
{
ErrorMessage = "修改失败";
}
}
catch (Exception)
{
ErrorMessage = "修改失败";
}
}
}
});
AdminLoginCommand = new RelayCommand(() =>
{
var rest = ActionManage.GetInstance.SendResult("LoginDosingSystem", $"{Admin}-={Password}-={SelectText}");
if (rest != null && rest is string str)
{
Account = String.Empty;
Txtpassword = String.Empty;
ErrorMessage = str;

}
});

}
}
}

+ 13
- 0
FryPot_DosingSystem/ViewModel/AdministratorPasswordChangeViewModel.cs 查看文件

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.ViewModel
{
internal class AdministratorPasswordChangeViewModel
{

}
}

+ 61
- 0
FryPot_DosingSystem/ViewModel/DeviceListViewModel.cs 查看文件

@@ -0,0 +1,61 @@
using BPASmartClient.Helper;
using FryPot_DosingSystem.Model;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.ViewModel
{
internal class DeviceListViewModel : ObservableObject
{
public ObservableCollection<string> DeviceName { get; set; } = new ObservableCollection<string>();
public ObservableCollection<DeviceInfo> devices { get; set; } = new ObservableCollection<DeviceInfo>();
public RelayCommand AddDeviceCommand { get; set; }
public RelayCommand SaveDeviceConfig { get; set; }
public RelayCommand<string> DeleteDevice { get; set; }
public DeviceListViewModel()
{
Json<DeviceManage>.Read();
devices = Json<DeviceManage>.Data.Devices;
DeviceName.Add("滚筒输送线");
DeviceName.Add("炒锅1");
DeviceName.Add("炒锅2");
DeviceName.Add("炒锅3");
DeviceName.Add("炒锅4");
DeviceName.Add("炒锅5");
AddDeviceCommand = new RelayCommand(() =>
{
erp:
string guid = Guid.NewGuid().ToString();
DeviceInfo info = devices.FirstOrDefault(p => p.DeviceNum == guid);
if (info == null)
{
devices.Add(new DeviceInfo() { DeviceNum = guid });
}
else
{
goto erp;
}
});
DeleteDevice = new RelayCommand<string>((str) =>
{
DeviceInfo device = devices.FirstOrDefault(p => p.DeviceNum == str);
if (device != null)
{
devices.Remove(device);
}
});
SaveDeviceConfig = new RelayCommand(() =>
{
Json<DeviceManage>.Data.Devices = devices;
Json<DeviceManage>.Save();
});
}

}
}

+ 76
- 0
FryPot_DosingSystem/ViewModel/LogViewModel.cs 查看文件

@@ -0,0 +1,76 @@
using BPASmartClient.Message;
using FryPot_DosingSystem.Model;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;

namespace FryPot_DosingSystem.ViewModel
{
internal class LogViewModel:ObservableObject
{
public static LogViewModel _instance;
public static LogViewModel GetInstance=>_instance?? (_instance = new LogViewModel());
private string _logTime;
public string LogTime { get { return _logTime; } set { _logTime = value; OnPropertyChanged(); } }

private string _logType;
public string LogType { get { return _logType; } set { _logType = value; OnPropertyChanged(); } }

private string _logMessage;
public string LogMessage { get { return _logMessage; } set { _logMessage = value; OnPropertyChanged(); } }

private Brush _foreColor;
public Brush ForeColor { get { return _foreColor; } set { _foreColor = value; OnPropertyChanged(); } }

public ObservableCollection<LogModel> LogDatas { get; set; } = new ObservableCollection<LogModel>();

public LogViewModel()
{
Inite();
}
public void Inite()
{
//一般日志 MessageLog.GetInstance.Show("");
MessageLog.GetInstance.InfoNotify = new Action<string>((s) =>
{
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
{
LogModel logModel = new LogModel { LogMessage= s, LogType = "一般日志" };
LogDatas.Add(logModel);
}));
});
//设备日志 MessageLog.GetInstance.DeviceProcessLogShow(id,message)
MessageLog.GetInstance.DeviceProcessLogNotify = new Action<string, string>((id, s) =>
{
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
{
LogModel logModel = new LogModel { LogMessage = s, LogType = "设备日志" };
LogDatas.Add(logModel);
}));
});
//设备告警日志 MessageLog.GetInstance.AddDeviceAlarmLogShow(id,message)
MessageLog.GetInstance.DeviceAlarmLogNotify = new Action<string, string>((id, s) =>
{
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
{
LogModel logModel = new LogModel { LogMessage = id, LogType = "报警日志" };
LogDatas.Add(logModel);
}));
});
//错误日志MessageLog.GetInstance.ShowEx(message)
MessageLog.GetInstance.ExInfoNotify = new Action<string>((s) =>
{
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
{
LogModel logModel = new LogModel { LogMessage = s, LogType = "错误日志" };
LogDatas.Add(logModel);
}));
});
}
}
}

+ 151
- 0
FryPot_DosingSystem/ViewModel/MainViewModel.cs 查看文件

@@ -0,0 +1,151 @@

using BPASmartClient.Helper;
using FryPot_DosingSystem.Control;
using FryPot_DosingSystem.Model;
using FryPot_DosingSystem.View;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;

namespace FryPot_DosingSystem.ViewModel
{
internal class MainViewModel : ObservableObject
{
public ObservableCollection<ActionMenu> menus { get; set; } = new ObservableCollection<ActionMenu>();

public RelayCommand Login { get; set; }
public RelayCommand PasswordChange { get; set; }

public RelayCommand ExitLogin { get; set; }
public RelayCommand<object> TogglePag { get; set; }
public bool UserManagement { get { return _mUserManagement; } set { _mUserManagement = value; OnPropertyChanged(); } }
private bool _mUserManagement;
/// <summary>
/// 当前登陆信息
/// </summary>
private UserInfo _currentLoginAccount;
public UserInfo CurrentLoginAccount { get { return _currentLoginAccount; } set { _currentLoginAccount = value;OnPropertyChanged(); } }
/// <summary>
/// 不同权限显示不同菜单
/// </summary>
public ObservableCollection<ActionMenu> DisplayMenus { get; set; } = new ObservableCollection<ActionMenu>();
public FrameworkElement MyWindow { get { return _mMyWindow; } set { _mMyWindow = value; OnPropertyChanged(); } }
private FrameworkElement _mMyWindow;

public string WindowTitleName { get { return _mWindowTitleName; } set { _mWindowTitleName = value; OnPropertyChanged(); } }
private string _mWindowTitleName;
/// <summary>
/// 开机自启
/// </summary>
public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } }

private Authority authority;
public Authority Authority
{
get { return authority; }
set
{
var res = menus.Where(p => Array.FindIndex(p.Authority, au => au == value) >= 0).ToList();
if (res != null && res.Count > 0)
{
DisplayMenus.Clear();
res.ForEach(p => DisplayMenus.Add(p));
DoNavChanged(res[0].CommandParameter);
}
authority = value;
}
}
public MainViewModel()
{
LogViewModel model= LogViewModel.GetInstance;
DeviceOperate deviceOperate=DeviceOperate.GetInstance;//开启实时PLC数据读取
DosingLogicControl logigControl = DosingLogicControl.GetInstance;//开启逻辑控制任务程序
TogglePag = new RelayCommand<object>(DoNavChanged);
Login = new RelayCommand(() =>
{
ActionManage.GetInstance.CancelRegister("ContentUpdate");
ActionManage.GetInstance.Register(new Func<object>(() => { return "注册"; }), "ContentUpdate");
DoNavChanged("AdministratorLoginView.用户登陆");
UserManagement = false;
});
PasswordChange = new RelayCommand(() =>
{
ActionManage.GetInstance.CancelRegister("ContentUpdate");
ActionManage.GetInstance.Register(new Func<object>(() => { return "修改"; }), "ContentUpdate");
ActionManage.GetInstance.CancelRegister("LoginInfo");
ActionManage.GetInstance.Register(new Func<object>(() => { return CurrentLoginAccount; }), "LoginInfo");
DoNavChanged("AdministratorLoginView.密码修改");
UserManagement = false;
});
ExitLogin = new RelayCommand(() =>
{
//DoNavChanged("LoginView.退出登录");
CurrentLoginAccount = null;
Authority = Authority.观察员;
UserManagement = false;
});
LoginInfoConfig.GetInstance.Init();//用户数据初始化
LoginRegister();
MenusDefaultInit();
Authority = Authority.管理员;
}

private void MenusDefaultInit()
{
menus.Add(new ActionMenu() { MenuName = "配方设置", CommandParameter = "RecipeSetView.配方设置", Authority = new Authority[] { Authority.管理员, Authority.技术员 } });
menus.Add(new ActionMenu() { MenuName = "配方下发", CommandParameter = "RecipeSendDownView.配方下发", Authority = new Authority[] { Authority.管理员, Authority.技术员, Authority.操作员 } });
menus.Add(new ActionMenu() { MenuName = "设备列表", CommandParameter = "DeviceListVIew.设备列表", Authority = new Authority[] { Authority.管理员, Authority.技术员, Authority.操作员, Authority.观察员 } });
menus.Add(new ActionMenu() { MenuName = "状态监测", CommandParameter = "HardWareStatusView.状态监测", Authority = new Authority[] { Authority.管理员, Authority.技术员, Authority.操作员, Authority.观察员 } });
menus.Add(new ActionMenu() { MenuName = "日志信息", CommandParameter = "LogView.日志信息", Authority = new Authority[] { Authority.管理员, Authority.技术员, Authority.操作员, Authority.观察员 } });
menus.Add(new ActionMenu() { MenuName = "报警记录", CommandParameter = "", Authority = new Authority[] { Authority.管理员, Authority.技术员, Authority.操作员, Authority.观察员 } });
}

public void DoNavChanged(object obj)
{
if (obj != null && obj is string stobj)
{
var strs = stobj.Split('.');
if (strs != null && strs.Length == 2)
{
Type type = Type.GetType($"FryPot_DosingSystem.View.{strs[0]}");
var res = type?.GetConstructor(System.Type.EmptyTypes)?.Invoke(null);
if (res != null && res is FrameworkElement fe) MyWindow = fe;
WindowTitleName = strs[1];
}
}
}
/// <summary>
/// 登陆验证
/// </summary>
private void LoginRegister()
{
ActionManage.GetInstance.Register(new Func<object, object>((o) =>
{
if (o != null && o is string str)
{
var strs = str.Split("-=");
if (strs != null && strs.Length == 3)
{
var us = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == strs[0] && p.Password == strs[1]&& strs[2] == p.Authority.ToString());
if (us != null)
{
Authority = us.Authority;
CurrentLoginAccount = us;//记录当前登陆信息
return string.Empty;
}
}
}
return "用户名或密码错误";
}), "LoginDosingSystem");
}
}
}

+ 98
- 0
FryPot_DosingSystem/ViewModel/NewRecipeViewModel.cs 查看文件

@@ -0,0 +1,98 @@
using BPASmartClient.Helper;
using FryPot_DosingSystem.Model;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.ViewModel
{
internal class NewRecipeViewModel : ObservableObject
{
/// <summary>
/// 配方唯一编码,用于编辑配方
/// </summary>
public string recipeId { get; set; }
/// <summary>
/// 配料名称
/// </summary>
private string _recipeName;
public string RecipeName { get { return _recipeName; } set { _recipeName = value; OnPropertyChanged(); } }

public ObservableCollection<MaterialType> materials { get; set; } = new ObservableCollection<MaterialType>();

public ObservableCollection<string> materialNames { get; set; } = new ObservableCollection<string>() { "肉","葱","蒜"};

public RelayCommand AddRecipe { get; set; }
public RelayCommand<string> RemoveRecipe { get; set; }
public RelayCommand Comfirm { get; set; }
public NewRecipeViewModel()
{
ActionManage.GetInstance.Register(new Action<object>(Id => {
if (Id != null && Id is string strId)
{
var res = Json<RecipeManage>.Data.Recipes.FirstOrDefault(p => p.RecipeId == strId);
if (res != null && res is NewRecipeModel rom)
{
RecipeName = rom.RecipeName;
foreach (var item in rom.materialCollection)
{
materials.Add(item);
}
recipeId = strId;
}
}
}),"EditRecipe");
AddRecipe = new RelayCommand(() =>
{
pr:
string materialCode = Guid.NewGuid().ToString();//原料唯一ID ,后期需要根据实际要求更改
var res = materials.FirstOrDefault(p => p.MaterialCode == materialCode);
if (res == null)
{
materials.Add(new MaterialType() { MaterialCode = materialCode });
}
else
{
goto pr;
}
});
RemoveRecipe = new RelayCommand<string>(code =>
{
var res = materials.FirstOrDefault(m => m.MaterialCode == code);
if (res != null)
materials.Remove(res);
});
Comfirm = new RelayCommand(() =>
{
var bom = Json<RecipeManage>.Data.Recipes.FirstOrDefault(p => p.RecipeId == recipeId);
if (bom == null)//新配方
{
prop: string recipeID = Guid.NewGuid().ToString();//配方唯一ID,后期根据实际要求更改
var res = Json<RecipeManage>.Data.Recipes.FirstOrDefault(p => p.RecipeId == recipeID);
if (res == null)
{
Json<RecipeManage>.Data.Recipes.Add(new NewRecipeModel { RecipeId = recipeID, RecipeName = RecipeName, materialCollection = materials });//配方添加

}
else
{
goto prop;
}
ActionManage.GetInstance.Send("CloseNewRecipeView");
}
else //已有配方,用于编辑
{
bom.materialCollection= materials;
bom.RecipeName = RecipeName;
ActionManage.GetInstance.Send("CloseNewRecipeView");
}
});
}
}
}

+ 62
- 0
FryPot_DosingSystem/ViewModel/RecipeSetDownViewModel.cs 查看文件

@@ -0,0 +1,62 @@
using BPASmartClient.Helper;
using FryPot_DosingSystem.Model;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.ViewModel
{
internal class RecipeSetDownViewModel : ObservableObject
{

/// <summary>
/// 配方下发
/// </summary>
public RelayCommand<object> RecipeSetDownCommand { get; set; }
/// <summary>
/// 配方一键下发
/// </summary>
public RelayCommand AllRecipeSetDownCommand { get; set; }
public ObservableCollection<NewRecipeModel> Recipes { get; set; } = new ObservableCollection<NewRecipeModel>();
public RecipeSetDownViewModel()
{
Json<RecipeManage>.Read();
Recipes = Json<RecipeManage>.Data.Recipes;
RecipeSetDownCommand = new RelayCommand<object>((Id) =>
{
if (Id != null && Id is string strId)
{
var res = Recipes.FirstOrDefault(p => p.RecipeId == strId);
if (res != null)
{
RecipeSetDown(res);
}
}
});
AllRecipeSetDownCommand = new RelayCommand(() =>
{
if (Recipes!=null)
{
foreach (var recipeModel in Recipes)
{
RecipeSetDown(recipeModel);
}
}

});
}
/// <summary>
/// 数据下发方法
/// </summary>
public void RecipeSetDown(NewRecipeModel recipeModel)
{
recipeModel.RecipeSetInfo = "下发成功";
}
}
}

+ 80
- 0
FryPot_DosingSystem/ViewModel/RecipeSetViewModel.cs 查看文件

@@ -0,0 +1,80 @@
using BPASmartClient.Helper;
using BPASmartClient.Message;
using FryPot_DosingSystem.Model;
using FryPot_DosingSystem.View;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.ViewModel
{
internal class RecipeSetViewModel : ObservableObject
{
///// <summary>
///// 配方编号
///// </summary>
//private int _serialNumber;
//public int SerialNumber { get { return _serialNumber; } set { _serialNumber = value;OnPropertyChanged(); } }
///// <summary>
///// 配方名称
///// </summary>
//private string _recipeName;
//public string RecipeName { get { return _recipeName; } set { _recipeName = value; OnPropertyChanged(); } }

public ObservableCollection<NewRecipeModel> recipeModels { get; set; } = new ObservableCollection<NewRecipeModel>();

public Action NewRecipe { get; set; }

public Action SaveRecipe { get; set; }
/// <summary>
/// 编辑配方
/// </summary>
public RelayCommand<object> EditRecipeCommand { get; set; }
/// <summary>
/// 删除配方
/// </summary>
public RelayCommand<object> DeleteRecipeCommand { get; set; }

public RecipeSetViewModel()
{
Json<RecipeManage>.Read();
recipeModels = Json<RecipeManage>.Data.Recipes;
NewRecipe = new Action(() =>
{
NewRecipeView nrv = new NewRecipeView();
nrv.ShowDialog();
MessageLog.GetInstance.Show("新建配方");
});
SaveRecipe = new Action(() => {
Json<RecipeManage>.Save();
});
EditRecipeCommand = new RelayCommand<object>((Id) =>
{
if (Id != null)
{
ActionManage.GetInstance.CancelRegister("EditRecipe");
NewRecipeView nrv = new NewRecipeView();
ActionManage.GetInstance.Send("EditRecipe", Id);
nrv.ShowDialog();
}
});
DeleteRecipeCommand = new RelayCommand<object>((Id) =>
{
if (Id != null && Id is String strId)
{
var res= recipeModels.FirstOrDefault(p => p.RecipeId == strId);
if (res != null && res is NewRecipeModel nes)
{
recipeModels.Remove(res);//删除配方
Json<RecipeManage>.Save();//保存配方
}
}
});
}
}
}

二进制
查看文件


+ 1
- 0
LoginUp.hbl 查看文件

@@ -0,0 +1 @@
deac37237d550f2bb590b1d004aab120f4401e4504fd380cf9afa150f1f019d624ce5842ec9c5a8b2120413b2d623477a5b1c93800f28232dfcce895649de806a90a33c6aa3e437981381bb5e28745b8c5a9df97b8b94372d1b9dcac16580901

+ 24
- 1
SmartClient.sln 查看文件

@@ -98,7 +98,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DosingSystem", "DosingSyste
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkTJuicer", "BPASmartClient.MorkTJuicer\BPASmartClient.MorkTJuicer.csproj", "{724087A3-E7E7-4494-B844-414FF5CD1D40}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.AGV", "BPASmartClient.AGV\BPASmartClient.AGV.csproj", "{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.AGV", "BPASmartClient.AGV\BPASmartClient.AGV.csproj", "{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FryPot_DosingSystem", "FryPot_DosingSystem\FryPot_DosingSystem.csproj", "{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -914,6 +916,26 @@ Global
{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}.Release|x64.Build.0 = Release|Any CPU
{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}.Release|x86.ActiveCfg = Release|Any CPU
{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}.Release|x86.Build.0 = Release|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Debug|ARM.ActiveCfg = Debug|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Debug|ARM.Build.0 = Debug|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Debug|ARM64.Build.0 = Debug|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Debug|x64.ActiveCfg = Debug|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Debug|x64.Build.0 = Debug|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Debug|x86.ActiveCfg = Debug|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Debug|x86.Build.0 = Debug|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Release|Any CPU.Build.0 = Release|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Release|ARM.ActiveCfg = Release|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Release|ARM.Build.0 = Release|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Release|ARM64.ActiveCfg = Release|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Release|ARM64.Build.0 = Release|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Release|x64.ActiveCfg = Release|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Release|x64.Build.0 = Release|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Release|x86.ActiveCfg = Release|Any CPU
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -959,6 +981,7 @@ Global
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB} = {8712125E-14CD-4E1B-A1CE-4BDE03805942}
{724087A3-E7E7-4494-B844-414FF5CD1D40} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F}
{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625}
{BF0BCA66-BAE3-4293-9C3A-51537AB8580E} = {8712125E-14CD-4E1B-A1CE-4BDE03805942}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC}


+ 1
- 0
up.hbl 查看文件

@@ -0,0 +1 @@
deac37237d550f2bb590b1d004aab120481999a41282f0d8eed6fa9049bb2b58cf766ac542f7a79f9082f942d0190d731890e60eebc260ec3b9e76773b3e4e83443ee7e834210c4de2f560a9b4a6dffbc2a95b696b61aa07653dc4afdd31b551dc9f238426fc95486e3cf08d9387518bf125481cbfd4003d593f7f0c83167badfca9e6b0e585bf724542d50252bd672d2650e1146dd47b395b9b5d22b4fba4e75f528e15f91b5eb98112d2b1a3d5b1e1305cd1a1086a71336213e2a7cf83b262e36d4f33428a80c089f2f1ed81695a6c2d431dd7aaf64d71262dd132539e26900ebb7a6d1cc5923550c6612fdfee2a0a

正在加载...
取消
保存