Bläddra i källkod

冲突解决

样式分支
pry 2 år sedan
förälder
incheckning
286061b9ca
62 ändrade filer med 4335 tillägg och 8 borttagningar
  1. +88
    -3
      BPASmartClient.AGV/AGVHelper.cs
  2. +0
    -1
      BPASmartClient.CustomResource/RecDictionarys/BeveledRadioButtonStyle.xaml
  3. +1
    -0
      BPASmartClient.CustomResource/UserControls/DateTimeUI.xaml.cs
  4. +1
    -1
      BPASmartClient.Helper/RTrig.cs
  5. +4
    -0
      BPASmartClient.Helper/ThreadManage.cs
  6. +72
    -1
      BPASmartClient.Modbus/ModbusTcp.cs
  7. +1
    -1
      DosingSystem/View/MainWindow.xaml
  8. +1
    -1
      DosingSystem/View/NewRecipeView.xaml
  9. +36
    -0
      FryPot_DosingSystem/App.xaml
  10. +17
    -0
      FryPot_DosingSystem/App.xaml.cs
  11. +10
    -0
      FryPot_DosingSystem/AssemblyInfo.cs
  12. +106
    -0
      FryPot_DosingSystem/Control/DeviceOperate.cs
  13. +869
    -0
      FryPot_DosingSystem/Control/DosingLogicControl.cs
  14. +410
    -0
      FryPot_DosingSystem/Control/GlobalVariable.cs
  15. +15
    -0
      FryPot_DosingSystem/Control/MaterialInfo.cs
  16. +30
    -0
      FryPot_DosingSystem/FryPot_DosingSystem.csproj
  17. +37
    -0
      FryPot_DosingSystem/Helper/PasswordBoxHelper.cs
  18. +22
    -0
      FryPot_DosingSystem/Model/ActionMenu.cs
  19. +24
    -0
      FryPot_DosingSystem/Model/DeviceInfo.cs
  20. +15
    -0
      FryPot_DosingSystem/Model/DeviceManage.cs
  21. +13
    -0
      FryPot_DosingSystem/Model/Global.cs
  22. +30
    -0
      FryPot_DosingSystem/Model/LogModel.cs
  23. +48
    -0
      FryPot_DosingSystem/Model/LoginInfoConfig.cs
  24. +35
    -0
      FryPot_DosingSystem/Model/MaterialType.cs
  25. +14
    -0
      FryPot_DosingSystem/Model/PlcVariableModel.cs
  26. +17
    -0
      FryPot_DosingSystem/Model/RecipeManage.cs
  27. +32
    -0
      FryPot_DosingSystem/Model/RecipeModel.cs
  28. +28
    -0
      FryPot_DosingSystem/Model/UserManage.cs
  29. +187
    -0
      FryPot_DosingSystem/View/AdministratorLoginView.xaml
  30. +95
    -0
      FryPot_DosingSystem/View/AdministratorLoginView.xaml.cs
  31. +185
    -0
      FryPot_DosingSystem/View/AdministratorPasswordChangeView.xaml
  32. +85
    -0
      FryPot_DosingSystem/View/AdministratorPasswordChangeView.xaml.cs
  33. +12
    -0
      FryPot_DosingSystem/View/AlarmInfoView.xaml
  34. +28
    -0
      FryPot_DosingSystem/View/AlarmInfoView.xaml.cs
  35. +72
    -0
      FryPot_DosingSystem/View/DeviceListVIew.xaml
  36. +28
    -0
      FryPot_DosingSystem/View/DeviceListVIew.xaml.cs
  37. +12
    -0
      FryPot_DosingSystem/View/EditRecipeView.xaml
  38. +28
    -0
      FryPot_DosingSystem/View/EditRecipeView.xaml.cs
  39. +12
    -0
      FryPot_DosingSystem/View/HardWareStatusView.xaml
  40. +28
    -0
      FryPot_DosingSystem/View/HardWareStatusView.xaml.cs
  41. +54
    -0
      FryPot_DosingSystem/View/LogView.xaml
  42. +30
    -0
      FryPot_DosingSystem/View/LogView.xaml.cs
  43. +260
    -0
      FryPot_DosingSystem/View/MainWindow.xaml
  44. +64
    -0
      FryPot_DosingSystem/View/MainWindow.xaml.cs
  45. +113
    -0
      FryPot_DosingSystem/View/NewRecipeView.xaml
  46. +36
    -0
      FryPot_DosingSystem/View/NewRecipeView.xaml.cs
  47. +82
    -0
      FryPot_DosingSystem/View/RecipeSendDownView.xaml
  48. +28
    -0
      FryPot_DosingSystem/View/RecipeSendDownView.xaml.cs
  49. +127
    -0
      FryPot_DosingSystem/View/RecipeSetView.xaml
  50. +30
    -0
      FryPot_DosingSystem/View/RecipeSetView.xaml.cs
  51. +172
    -0
      FryPot_DosingSystem/ViewModel/AdministratorLoginViewModel.cs
  52. +13
    -0
      FryPot_DosingSystem/ViewModel/AdministratorPasswordChangeViewModel.cs
  53. +61
    -0
      FryPot_DosingSystem/ViewModel/DeviceListViewModel.cs
  54. +76
    -0
      FryPot_DosingSystem/ViewModel/LogViewModel.cs
  55. +173
    -0
      FryPot_DosingSystem/ViewModel/MainViewModel.cs
  56. +98
    -0
      FryPot_DosingSystem/ViewModel/NewRecipeViewModel.cs
  57. +65
    -0
      FryPot_DosingSystem/ViewModel/RecipeSetDownViewModel.cs
  58. +80
    -0
      FryPot_DosingSystem/ViewModel/RecipeSetViewModel.cs
  59. Binär
     
  60. +1
    -0
      LoginUp.hbl
  61. +23
    -0
      SmartClient.sln
  62. +1
    -0
      up.hbl

+ 88
- 3
BPASmartClient.AGV/AGVHelper.cs Visa fil

@@ -52,9 +52,94 @@ namespace BPASmartClient.AGV
request.Abort();
}
return retString;//返回响应报文


}
/// <summary>
/// AGV去1号线体装桶
/// </summary>
/// <returns></returns>
public string AgvToLineOneLoadRoller()
{
string url = "";
string head = "";
string body = "";
return HttpRequest(url,head,body);
}
/// <summary>
/// AGV去2号线体装桶
/// </summary>
/// <returns></returns>
public string AgvToLineTwoLoadRoller()
{
string url = "";
string head = "";
string body = "";
return HttpRequest(url, head, body);
}
/// <summary>
/// AGV去3号线体装桶
/// </summary>
/// <returns></returns>
public string AgvToLineThreeLoadRoller()
{
string url = "";
string head = "";
string body = "";
return HttpRequest(url, head, body);
}
/// <summary>
/// AGV离开炒锅1
/// </summary>
/// <returns></returns>
public string AgvLeaveFryPotOne()
{
string url = "";
string head = "";
string body = "";
return HttpRequest(url, head, body);
}
/// <summary>
/// AGV离开炒锅2
/// </summary>
/// <returns></returns>
public string AgvLeaveFryPotTwo()
{
string url = "";
string head = "";
string body = "";
return HttpRequest(url, head, body);
}
/// <summary>
/// AGV离开炒锅3
/// </summary>
/// <returns></returns>
public string AgvLeaveFryPotThree()
{
string url = "";
string head = "";
string body = "";
return HttpRequest(url, head, body);
}
/// <summary>
/// AGV离开炒锅4
/// </summary>
/// <returns></returns>
public string AgvLeaveFryPotFour()
{
string url = "";
string head = "";
string body = "";
return HttpRequest(url, head, body);
}
/// <summary>
/// AGV离开炒锅5
/// </summary>
/// <returns></returns>
public string AgvLeaveFryPotFive()
{
string url = "";
string head = "";
string body = "";
return HttpRequest(url, head, body);
}
}
}

+ 0
- 1
BPASmartClient.CustomResource/RecDictionarys/BeveledRadioButtonStyle.xaml Visa fil

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

</ResourceDictionary>

+ 1
- 0
BPASmartClient.CustomResource/UserControls/DateTimeUI.xaml.cs Visa fil

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

public DateTimeUI()
{
InitializeComponent();


+ 1
- 1
BPASmartClient.Helper/RTrig.cs Visa fil

@@ -15,7 +15,7 @@ namespace BPASmartClient.Helper
private volatile static ConcurrentDictionary<string, RTrig> _Instance;
public static RTrig GetInstance(string name)
{
if (_Instance == null) _Instance = new ConcurrentDictionary<string, RTrig>();
if (_Instance == null) _Instance = new ConcurrentDictionary<string, RTrig>();
if (!_Instance.ContainsKey(name)) _Instance.TryAdd(name, new RTrig());
return _Instance[name];
}


+ 4
- 0
BPASmartClient.Helper/ThreadManage.cs Visa fil

@@ -32,6 +32,10 @@ namespace BPASmartClient.Helper
if (CancellationTokenSources.ContainsKey(guid + key))
{
CancellationTokenSources[guid + key]?.Cancel();
if (key.Equals("MainTask"))
{
ActionManage.GetInstance.Send("FryPotDosingMainTaskExit");
}
ActionManage.GetInstance.Register(ExitCallback, guid + key);
}
else


+ 72
- 1
BPASmartClient.Modbus/ModbusTcp.cs Visa fil

@@ -145,7 +145,7 @@ namespace BPASmartClient.Modbus
}
return -1;
}
private void ExceptionHandling(Exception ex)
{
if (ex.InnerException is SocketException)
@@ -189,7 +189,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;


+ 1
- 1
DosingSystem/View/MainWindow.xaml Visa fil

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

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


+ 1
- 1
DosingSystem/View/NewRecipeView.xaml Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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;
}
}
}

+ 869
- 0
FryPot_DosingSystem/Control/DosingLogicControl.cs Visa fil

@@ -0,0 +1,869 @@
using BPASmartClient.AGV;
using BPASmartClient.Helper;
using BPASmartClient.Message;
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>();
/// <summary>
/// 配方队列
/// </summary>
public ConcurrentQueue<NewRecipeModel> RecipeQuene = new ConcurrentQueue<NewRecipeModel>();
/// <summary>
/// 进料原料队列
/// </summary>
public ConcurrentQueue<MaterialInfo> InputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
/// <summary>
/// 出料原料队列
/// </summary>
public ConcurrentQueue<MaterialInfo> OutputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
/// <summary>
/// 全局变量对象声明
/// </summary>
GlobalVariable globalVar;

#region 上位机内部变量
int lineAlarm = 0;//线体故障信号 1:无故障 -1:故障
int FryPotAlarm = 0;//炒锅滚筒故障信号 1:无故障 -1:故障
int ReicpeNum = 0;//记录接收到的配方数
#endregion
#region agv临时变量
bool agvArriveLine = false;//agv是否到达线体装料位置
bool agvArriveFryPot = false;//agv是否到达炒锅送料位置
bool agvFryPotEmptyRollerArrive = false;//agv是否拿到炒锅空桶
#endregion
public DosingLogicControl()
{
globalVar = new GlobalVariable();
ActionManage.GetInstance.Register(new Action<object>(RecipeDataParse), "RecipeSetDown");
ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.Clear(); }), "ClearRecipes");
ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 1; }), "StartPlcInite");
ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 0; }), "EndPlcInite");
ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitMainTask = true; }), "FryPotDosingMainTaskExit");
ResetProgram();
ReadPlcData();
IniteTask();
}
/// <summary>
/// 主任务重启
/// </summary>
private void ResetProgram()
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (RTrig.GetInstance("ResetProgram").Start(globalVar.PlcInite == 1))//判断是否初始化 一初始化就重启主任务
{
MessageLog.GetInstance.Show("主任务正在重启");
ThreadManage.GetInstance().StopTask("MainTask", new Action(() =>
{
ThreadManage.GetInstance().StopTask("MainViewReadPlcData", new Action(() =>
{
globalVar = null;
globalVar = new GlobalVariable();
ReicpeNum = 0;
ActionManage.GetInstance.CancelRegister("RecipeSetDown");
ActionManage.GetInstance.Register(new Action<object>(RecipeDataParse), "RecipeSetDown");
ActionManage.GetInstance.Send("ClearRecipes");
ReadPlcData();
IniteTask();
MessageLog.GetInstance.Show("主任务重启完成");
}));
}));
}

Thread.Sleep(10);
}), "ResetProgram");
}
/// <summary>
/// 实时获取plc数据
/// </summary>
public void ReadPlcData()
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
GetAddressData("D2001", new Action<ushort[]>((data) =>
{
globalVar.rollerLineOne.StationOne = data[0];
globalVar.rollerLineOne.StationTwo = data[1];
globalVar.rollerLineOne.StationThree = data[2];
globalVar.rollerLineOne.StationFour = data[3];
globalVar.rollerLineOne.StationFive = data[4];
globalVar.rollerLineOne.StationSix = data[5];
globalVar.rollerLineOne.StationSeven = data[6];
globalVar.rollerLineOne.StationEight = data[7];
}));
GetAddressData("D2011", new Action<ushort[]>((data) =>
{
globalVar.rollerLineTwo.StationOne = data[0];
globalVar.rollerLineTwo.StationTwo = data[1];
globalVar.rollerLineTwo.StationThree = data[2];
globalVar.rollerLineTwo.StationFour = data[3];
globalVar.rollerLineTwo.StationFive = data[4];
globalVar.rollerLineTwo.StationSix = data[5];
globalVar.rollerLineTwo.StationSeven = data[6];
globalVar.rollerLineTwo.StationEight = data[7];
}));
GetAddressData("D2021", new Action<ushort[]>((data) =>
{
globalVar.rollerLineThree.StationOne = data[0];
globalVar.rollerLineThree.StationTwo = data[1];
globalVar.rollerLineThree.StationThree = data[2];
globalVar.rollerLineThree.StationFour = data[3];
globalVar.rollerLineThree.StationFive = data[4];
globalVar.rollerLineThree.StationSix = data[5];
globalVar.rollerLineThree.StationSeven = data[6];
globalVar.rollerLineThree.StationEight = data[7];
}));
GetAddressData("D2040", new Action<ushort[]>((data) =>
{
globalVar.fryPotOne.InputMaterialRollerRunningSingle = data[0];
globalVar.fryPotTwo.InputMaterialRollerRunningSingle = data[1];
globalVar.fryPotThree.InputMaterialRollerRunningSingle = data[2];
globalVar.fryPotFour.InputMaterialRollerRunningSingle = data[3];
globalVar.fryPotFive.InputMaterialRollerRunningSingle = data[4];
}));
GetAddressData("D2045", new Action<ushort[]>((data) =>
{
globalVar.fryPotOne.InputMaterialArrivedSingle = data[0];
globalVar.fryPotTwo.InputMaterialArrivedSingle = data[1];
globalVar.fryPotThree.InputMaterialArrivedSingle = data[2];
globalVar.fryPotFour.InputMaterialArrivedSingle = data[3];
globalVar.fryPotFive.InputMaterialArrivedSingle = data[4];
}));
GetAddressData("D2050", new Action<ushort[]>((data) =>
{
globalVar.fryPotOne.EmptyBarrelArrivedSingle = data[0];
globalVar.fryPotTwo.EmptyBarrelArrivedSingle = data[1];
globalVar.fryPotThree.EmptyBarrelArrivedSingle = data[2];
globalVar.fryPotFour.EmptyBarrelArrivedSingle = data[3];
globalVar.fryPotFive.EmptyBarrelArrivedSingle = data[4];
}));
GetAddressData("D2065", new Action<ushort[]>((data) =>
{
globalVar.fryPotOne.EmptyBarrelRollerRunningSingle = data[0];
globalVar.fryPotTwo.EmptyBarrelRollerRunningSingle = data[1];
globalVar.fryPotThree.EmptyBarrelRollerRunningSingle = data[2];
globalVar.fryPotFour.EmptyBarrelRollerRunningSingle = data[3];
globalVar.fryPotFive.EmptyBarrelRollerRunningSingle = data[4];
}));
GetAddressData("D2070", new Action<ushort[]>((data) =>
{
globalVar.fryPotOne.RollerTroubleSingle = data[0];
globalVar.fryPotTwo.RollerTroubleSingle = data[1];
globalVar.fryPotThree.RollerTroubleSingle = data[2];
globalVar.fryPotFour.RollerTroubleSingle = data[3];
globalVar.fryPotFive.RollerTroubleSingle = data[4];
}));
GetAddressData("D2078", new Action<ushort[]>(data =>
{
globalVar.rollerLineOne.RecipeCompleteSingle = data[0];
globalVar.rollerLineTwo.RecipeCompleteSingle = data[1];
globalVar.rollerLineThree.RecipeCompleteSingle = data[2];
}));
GetAddressData("D2075", new Action<ushort[]>(data =>
{

globalVar.CleadBarrelEnterSingle = data[0];
}));
GetAddressData("D2077", new Action<ushort[]>(data =>
{

globalVar.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();
}), "MainTask");
}
/// <summary>
/// 配方数据接收
/// </summary>
public void RecipeDataParse(object obj)
{
if (obj != null && obj is NewRecipeModel recipe)
{
RecipeQuene.Enqueue(recipe);
ReicpeNum++;
MessageLog.GetInstance.Show($"接收到{ReicpeNum}个配方");
}

}
/// <summary>
/// 开启主任务
/// </summary>
public void MainTask()
{
RecipeDataToPlc();
AgvLoadRoller();
FryPotInputMaterial();
FryPotOutputMaterial();
}
/// <summary>
/// 数据下发PLC
/// </summary>
public void RecipeDataToPlc()
{
if (RecipeQuene.Count > 0 && OutputMaterialQuene.Count == 0 && InputMaterialQuene.Count == 0)//后续添加其它限制条件
{

if (RecipeQuene.TryDequeue(out NewRecipeModel result))
{
MessageLog.GetInstance.Show($"开始制作【{result.RecipeName}】 配方");
for (int i = 0; i < result.materialCollection.Count; i++) //遍历单个配方中所有物料
{
//将配方中原料加入新的队列
InputMaterialQuene.Enqueue(new MaterialInfo()
{
materialType = result.materialCollection[i],
materialId = result.RecipeId
});
ushort n = result.materialCollection[i].MaterialLoc;
switch (n / 100)
{
case 1:
case 4: RollerOneDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight); break;//1号滚筒线桶号以及重量数据下发
case 2:
case 5: RollerTwoDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight); break;//2号滚筒线桶号以及重量数据下发
case 3: RollerThreeDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight); break;//3号滚筒线桶号以及重量数据下发
}
}
switch (result.materialCollection[0].MaterialLoc / 100)
{
case 1:
DeviceOperate.GetInstance.WritePlcData("D1009", (ushort)result.materialCollection.Count); break;//发送1号滚筒线工序数据
case 2:
DeviceOperate.GetInstance.WritePlcData("D1026", (ushort)result.materialCollection.Count); break;//发送2号滚筒线工序数据
case 3:
DeviceOperate.GetInstance.WritePlcData("D1043", (ushort)result.materialCollection.Count); break;//发送3号滚筒线工序数据
}
}
}

}
/// <summary>
/// AGV到配方对应线体装桶以及出料到炒锅
/// </summary>
public void AgvLoadRoller()
{
lineAlarm = 0;
if (InputMaterialQuene.Count > 0)
{
switch (InputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
{
case 1:
case 4: AgvToLineOneLoadRoller(); AgvFromLineOneToFryPot(); break;//AGV到1号线体装桶
case 2:
case 5: AgvToLineTwoLoadRoller(); AgvFromLineTwoToFryPot(); break;//AGV到2号线体装桶
case 3: AgvToLineThreeLoadRoller(); AgvFromLineThreeToFryPot(); break;//AGV到3号线体装桶
}
}

}
/// <summary>
/// AGV从炒锅送料位置到倒料过程处理
/// </summary>
public void FryPotInputMaterial()
{
if (OutputMaterialQuene.Count > 0 && !globalVar.InOrOutputLock)
{
while (!agvArriveFryPot)//等待agv到达炒锅位置
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
AgvArriveFryPotSingleSetDown();
FryPotRollerTroubleCheck();
if (FryPotAlarm == 1)//炒锅滚筒无故障
{
//炒锅滚筒进料运行到位处理
FryPotInputMaterialRollerOperate();
globalVar.InOrOutputLock = true;
}
else
{
//MessageLog.GetInstance.ShowEx($"警告:炒锅{OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100}滚筒故障!!!");
}
}

}
/// <summary>
/// 炒锅出桶
/// </summary>
public void FryPotOutputMaterial()
{
if (OutputMaterialQuene.Count > 0 && globalVar.InOrOutputLock)
{
while (!agvArriveFryPot)//等待agv到达炒锅位置
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
AgvArriveFryPotOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号
FryPotRollerTroubleCheck();
if (FryPotAlarm == 1)//无故障
{
FryPotOutEmpetyRollerOperate();
if (OutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料
{
while (!agvFryPotEmptyRollerArrive)//等待AGV拿到出桶空桶
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
//AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅
globalVar.AllowAgvToLineLoadRoller = true;
globalVar.InOrOutputLock = false;
}
}
else//有故障
{

}
}
}
/// <summary>
/// 炒锅滚筒进料运行到位处理
/// </summary>
public void FryPotInputMaterialRollerOperate()
{
switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
{
case 1:
while (globalVar.fryPotOne.InputMaterialArrivedSingle == 0 || globalVar.fryPotOne.InputMaterialRollerRunningSingle == 0)
{
Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.Show($"炒锅【1】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
case 2:
while (globalVar.fryPotTwo.InputMaterialArrivedSingle == 0 || globalVar.fryPotTwo.InputMaterialRollerRunningSingle == 0)
{
Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.Show($"炒锅【2】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
case 3:
while (globalVar.fryPotThree.InputMaterialArrivedSingle == 0 || globalVar.fryPotThree.InputMaterialRollerRunningSingle == 0)
{
Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.Show($"炒锅【3】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
case 4:
while (globalVar.fryPotFour.InputMaterialArrivedSingle == 0 || globalVar.fryPotFour.InputMaterialRollerRunningSingle == 0)
{
Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.Show($"炒锅【4】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
case 5:
while (globalVar.fryPotFive.InputMaterialArrivedSingle == 0 || globalVar.fryPotFive.InputMaterialRollerRunningSingle == 0)
{
Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.Show($"炒锅【5】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
}

}
/// <summary>
/// 炒锅滚筒空桶出桶处理
/// </summary>
public void FryPotOutEmpetyRollerOperate()
{
switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
{
case 1: while (globalVar.fryPotOne.EmptyBarrelArrivedSingle == 0 || globalVar.fryPotOne.EmptyBarrelRollerRunningSingle == 0) { Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
} MessageLog.GetInstance.Show($"炒锅【1】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break;
case 2: while (globalVar.fryPotTwo.EmptyBarrelArrivedSingle == 0 || globalVar.fryPotTwo.EmptyBarrelRollerRunningSingle == 0) { Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
} MessageLog.GetInstance.Show($"炒锅【2】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break;
case 3: while (globalVar.fryPotThree.EmptyBarrelArrivedSingle == 0 || globalVar.fryPotThree.EmptyBarrelRollerRunningSingle == 0) { Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
} MessageLog.GetInstance.Show($"炒锅【3】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break;
case 4: while (globalVar.fryPotFour.EmptyBarrelArrivedSingle == 0 || globalVar.fryPotFour.EmptyBarrelRollerRunningSingle == 0) { Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
} MessageLog.GetInstance.Show($"炒锅【4】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break;
case 5: while (globalVar.fryPotFive.EmptyBarrelArrivedSingle == 0 || globalVar.fryPotFive.EmptyBarrelRollerRunningSingle == 0) { Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
} MessageLog.GetInstance.Show($"炒锅【5】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break;

}
}
/// <summary>
/// 发送agv送料就位信号至PLC(线体到炒锅)
/// </summary>
public void AgvArriveFryPotSingleSetDown()
{
switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
{
case 1: DeviceOperate.GetInstance.WritePlcData("D1055", 1); break;//agv到炒锅1送料就位信号
case 2: DeviceOperate.GetInstance.WritePlcData("D1056", 1); break;//agv到炒锅2送料就位信号
case 3: DeviceOperate.GetInstance.WritePlcData("D1057", 1); break;//agv到炒锅3送料就位信号
case 4: DeviceOperate.GetInstance.WritePlcData("D1058", 1); break;//agv到炒锅4送料就位信号
case 5: DeviceOperate.GetInstance.WritePlcData("D1059", 1); break;//agv到炒锅5送料就位信号
}
}
/// <summary>
/// 发送agv回桶就位信号至PLC
/// </summary>
public void AgvArriveFryPotOutEmptyRollerSingleSetDown()
{
switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
{
case 1: DeviceOperate.GetInstance.WritePlcData("D1060", 1); break;//agv到炒锅1送料就位信号
case 2: DeviceOperate.GetInstance.WritePlcData("D1061", 1); break;//agv到炒锅2送料就位信号
case 3: DeviceOperate.GetInstance.WritePlcData("D1062", 1); break;//agv到炒锅3送料就位信号
case 4: DeviceOperate.GetInstance.WritePlcData("D1063", 1); break;//agv到炒锅4送料就位信号
case 5: DeviceOperate.GetInstance.WritePlcData("D1064", 1); break;//agv到炒锅5送料就位信号
}
}
/// <summary>
/// 处理agv从线体1到送料到炒锅的条件
/// </summary>
/// <param name="lineAlarm"></param>
public void AgvFromLineOneToFryPot()
{
erp: if (lineAlarm == 1)//无故障
{
while (!agvArriveLine)//等待AGV到线体装料位置
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
agvArriveLine = false;
AgvArriveLineSingelSetDown();
if (InputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
{
while (!(globalVar.rollerLineOne.StationEight == materialInfo.materialType.MaterialLoc))//等待线体工号位8存放对应原料桶号
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
OutputMaterialQuene.Enqueue(materialInfo);
//原料到位,agv到位,agv运料到炒锅
}

}
else//有故障
{
while (lineAlarm == -1)
{
Thread.Sleep(50);
if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.Show("线体【1】滚筒故障解除,继续运行");
lineAlarm = 1;
goto erp;
}
}
/// <summary>
/// 处理agv从线体2到送料到炒锅的条件
/// </summary>
/// <param name="lineAlarm"></param>
public void AgvFromLineTwoToFryPot()
{
erp: if (lineAlarm == 1)//无故障
{
while (!agvArriveLine)//等待AGV到线体装料位置
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
agvArriveLine = false;
AgvArriveLineSingelSetDown();
if (InputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
{
while (!(globalVar.rollerLineTwo.StationEight == materialInfo.materialType.MaterialLoc))//等待线体工号位8存放对应原料桶号
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
OutputMaterialQuene.Enqueue(materialInfo);
//原料到位,agv到位,agv运料到炒锅
}

}
else//有故障
{
while (lineAlarm == -1)
{
Thread.Sleep(50);
if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.Show("线体【2】滚筒故障解除,继续运行");
lineAlarm = 1;
goto erp;
}
}
/// <summary>
/// 处理agv从线体3到送料到炒锅的条件
/// </summary>
/// <param name="lineAlarm"></param>
public void AgvFromLineThreeToFryPot()
{
erp: if (lineAlarm == 1)//无故障
{
while (!agvArriveLine)//等待AGV到线体装料位置
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
agvArriveLine = false;
AgvArriveLineSingelSetDown();
if (InputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
{
while (!(globalVar.rollerLineThree.StationEight == materialInfo.materialType.MaterialLoc))//等待线体工号位8存放对应原料桶号
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
OutputMaterialQuene.Enqueue(materialInfo);
//原料到位,agv到位,agv运料到炒锅
}

}
else//有故障
{
while (lineAlarm == -1)
{
Thread.Sleep(50);
if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.Show("线体【3】滚筒故障解除,继续运行");
lineAlarm = 1;
goto erp;
}
}
public void AgvToLineOneLoadRoller()
{
if (globalVar.rollerLineOne.OutMaterialingTroubleSingle == 0)//输送线无故障
{
if (InputMaterialQuene.Count > 0)
{
while (!globalVar.AllowAgvToLineLoadRoller || globalVar.rollerLineOne.OutMaterialingSingle == 0)
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
AGVHelper.GetInstance.AgvToLineOneLoadRoller();
MessageLog.GetInstance.Show("AGV去1号线体");
globalVar.AllowAgvToLineLoadRoller = false;
}
}
else
{
MessageLog.GetInstance.ShowEx("警告:滚筒输送线体【1】故障!!!");
lineAlarm = -1;
}
lineAlarm = 1;
}
public void AgvToLineTwoLoadRoller()
{
if (globalVar.rollerLineTwo.OutMaterialingTroubleSingle == 0)//输送线无故障
{
if (InputMaterialQuene.Count > 0)
{
while (!globalVar.AllowAgvToLineLoadRoller || globalVar.rollerLineOne.OutMaterialingSingle == 0) //后续考虑是否用while
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
AGVHelper.GetInstance.AgvToLineTwoLoadRoller();
MessageLog.GetInstance.Show("AGV去2号线体");
globalVar.AllowAgvToLineLoadRoller = false;
}

}
else
{
MessageLog.GetInstance.ShowEx("警告:滚筒输送线体【2】故障!!!");
lineAlarm = -1;
}
lineAlarm = 1;
}
public void AgvToLineThreeLoadRoller()
{
if (globalVar.rollerLineThree.OutMaterialingTroubleSingle == 0)//输送线无故障
{
if (InputMaterialQuene.Count > 0)
{
while (!globalVar.AllowAgvToLineLoadRoller || globalVar.rollerLineOne.OutMaterialingSingle == 0) //后续考虑是否用while
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
AGVHelper.GetInstance.AgvToLineThreeLoadRoller();
MessageLog.GetInstance.Show("AGV去3号线体");
globalVar.AllowAgvToLineLoadRoller = false;
}

}
else
{
MessageLog.GetInstance.ShowEx("警告:滚筒输送线体【3】故障!!!");
lineAlarm = -1;
}
lineAlarm = 1;
}
/// <summary>
/// 1号线体数据下发
/// </summary>
/// <param name="count"></param>
/// <param name="materialLoc"></param>
/// <param name="materialWeight"></param>
public void RollerOneDataWrite(int count, ushort materialLoc, ushort materialWeight)
{
switch (count)
{
case 0:
DeviceOperate.GetInstance.WritePlcData("D1001", materialLoc);//桶1位置
DeviceOperate.GetInstance.WritePlcData("D1010", materialWeight);//桶2重量
break;
case 1:
DeviceOperate.GetInstance.WritePlcData("D1002", materialLoc);//桶2位置
DeviceOperate.GetInstance.WritePlcData("D1011", materialWeight);//桶2重量
break;
case 2:
DeviceOperate.GetInstance.WritePlcData("D1003", materialLoc);//桶3位置
DeviceOperate.GetInstance.WritePlcData("D1012", materialWeight);//桶3重量
break;
case 3:
DeviceOperate.GetInstance.WritePlcData("D1004", materialLoc);//桶4位置
DeviceOperate.GetInstance.WritePlcData("D1013", materialWeight);//桶4重量
break;
case 4:
DeviceOperate.GetInstance.WritePlcData("D1005", materialLoc);//桶5位置
DeviceOperate.GetInstance.WritePlcData("D1014", materialWeight);//桶5重量
break;
case 5:
DeviceOperate.GetInstance.WritePlcData("D1006", materialLoc);//桶6位置
DeviceOperate.GetInstance.WritePlcData("D1015", materialWeight);//桶6重量
break;
case 6:
DeviceOperate.GetInstance.WritePlcData("D1007", materialLoc);//桶7位置
DeviceOperate.GetInstance.WritePlcData("D1016", materialWeight);//桶7重量
break;
case 7:
DeviceOperate.GetInstance.WritePlcData("D1008", materialLoc);//桶8位置
DeviceOperate.GetInstance.WritePlcData("D1017", materialWeight);//桶8重量
break;

}
}
/// <summary>
/// 2号线体数据下发
/// </summary>
/// <param name="count"></param>
/// <param name="materialLoc"></param>
/// <param name="materialWeight"></param>
public void RollerTwoDataWrite(int count, ushort materialLoc, ushort materialWeight)
{
switch (count)
{
case 0:
DeviceOperate.GetInstance.WritePlcData("D1018", materialLoc);//桶1位置
DeviceOperate.GetInstance.WritePlcData("D1027", materialWeight);//桶2重量
break;
case 1:
DeviceOperate.GetInstance.WritePlcData("D1019", materialLoc);//桶2位置
DeviceOperate.GetInstance.WritePlcData("D1028", materialWeight);//桶2重量
break;
case 2:
DeviceOperate.GetInstance.WritePlcData("D1020", materialLoc);//桶3位置
DeviceOperate.GetInstance.WritePlcData("D1029", materialWeight);//桶3重量
break;
case 3:
DeviceOperate.GetInstance.WritePlcData("D1021", materialLoc);//桶4位置
DeviceOperate.GetInstance.WritePlcData("D1030", materialWeight);//桶4重量
break;
case 4:
DeviceOperate.GetInstance.WritePlcData("D1022", materialLoc);//桶5位置
DeviceOperate.GetInstance.WritePlcData("D1031", materialWeight);//桶5重量
break;
case 5:
DeviceOperate.GetInstance.WritePlcData("D1023", materialLoc);//桶6位置
DeviceOperate.GetInstance.WritePlcData("D1032", materialWeight);//桶6重量
break;
case 6:
DeviceOperate.GetInstance.WritePlcData("D1024", materialLoc);//桶7位置
DeviceOperate.GetInstance.WritePlcData("D1033", materialWeight);//桶7重量
break;
case 7:
DeviceOperate.GetInstance.WritePlcData("D1025", materialLoc);//桶8位置
DeviceOperate.GetInstance.WritePlcData("D1034", materialWeight);//桶8重量
break;

}
}
/// <summary>
/// 3号线体数据下发
/// </summary>
/// <param name="count"></param>
/// <param name="materialLoc"></param>
/// <param name="materialWeight"></param>
public void RollerThreeDataWrite(int count, ushort materialLoc, ushort materialWeight)
{
switch (count)
{
case 0:
DeviceOperate.GetInstance.WritePlcData("D1035", materialLoc);//桶1位置
DeviceOperate.GetInstance.WritePlcData("D1044", materialWeight);//桶2重量
break;
case 1:
DeviceOperate.GetInstance.WritePlcData("D1036", materialLoc);//桶2位置
DeviceOperate.GetInstance.WritePlcData("D1045", materialWeight);//桶2重量
break;
case 2:
DeviceOperate.GetInstance.WritePlcData("D1037", materialLoc);//桶3位置
DeviceOperate.GetInstance.WritePlcData("D1046", materialWeight);//桶3重量
break;
case 3:
DeviceOperate.GetInstance.WritePlcData("D1038", materialLoc);//桶4位置
DeviceOperate.GetInstance.WritePlcData("D1047", materialWeight);//桶4重量
break;
case 4:
DeviceOperate.GetInstance.WritePlcData("D1039", materialLoc);//桶5位置
DeviceOperate.GetInstance.WritePlcData("D1048", materialWeight);//桶5重量
break;
case 5:
DeviceOperate.GetInstance.WritePlcData("D1040", materialLoc);//桶6位置
DeviceOperate.GetInstance.WritePlcData("D1049", materialWeight);//桶6重量
break;
case 6:
DeviceOperate.GetInstance.WritePlcData("D1041", materialLoc);//桶7位置
DeviceOperate.GetInstance.WritePlcData("D1050", materialWeight);//桶7重量
break;
case 7:
DeviceOperate.GetInstance.WritePlcData("D1042", materialLoc);//桶8位置
DeviceOperate.GetInstance.WritePlcData("D1051", materialWeight);//桶8重量
break;

}

}
/// <summary>
/// AGV进料就位信号下发至PLC
/// </summary>
public void AgvArriveLineSingelSetDown()
{
switch (InputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
{
case 1:
case 4: DeviceOperate.GetInstance.WritePlcData("D1052", 1); break;//AGV进料就位信号1
case 2:
case 5: DeviceOperate.GetInstance.WritePlcData("D1053", 1); break;//AGV进料就位信号2
case 3: DeviceOperate.GetInstance.WritePlcData("D1054", 1); break;//AGV进料就位信号3
}

}
/// <summary>
/// 炒锅滚筒信号检测
/// </summary>
public void FryPotRollerTroubleCheck()
{
FryPotAlarm = 0;
switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
{
case 1:
if (globalVar.fryPotOne.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowEx("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotOne.RollerTroubleSingle == 1)
{
Thread.Sleep(50); if (globalVar.ExitMainTask)
return;
}
FryPotAlarm = 1; break;
case 2:
if (globalVar.fryPotTwo.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowEx("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotTwo.RollerTroubleSingle == 1)
{
Thread.Sleep(50); if (globalVar.ExitMainTask)
return;
}
FryPotAlarm = 1; break;
case 3:
if (globalVar.fryPotThree.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowEx("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotThree.RollerTroubleSingle == 1)
{
Thread.Sleep(50); if (globalVar.ExitMainTask)
return;
}
FryPotAlarm = 1; break;
case 4:
if (globalVar.fryPotFour.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowEx("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotFour.RollerTroubleSingle == 1)
{
Thread.Sleep(50); if (globalVar.ExitMainTask)
return;
}
FryPotAlarm = 1; break;
case 5:
if (globalVar.fryPotFive.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowEx("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotFive.RollerTroubleSingle == 1)
{
Thread.Sleep(50); if (globalVar.ExitMainTask)
return;
}
FryPotAlarm = 1; break;

}
}

}
}

+ 410
- 0
FryPot_DosingSystem/Control/GlobalVariable.cs Visa fil

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

namespace FryPot_DosingSystem.Control
{
/// <summary>
/// plc变量
/// </summary>
internal class GlobalVariable
{
/// <summary>
/// 滚筒线1
/// </summary>
public RollerLineOne rollerLineOne = new RollerLineOne();
/// <summary>
/// 滚筒线2
/// </summary>
public RollerLineTwo rollerLineTwo = new RollerLineTwo();
/// <summary>
/// 滚筒线3
/// </summary>
public RollerLineThree rollerLineThree = new RollerLineThree();
/// <summary>
/// 炒锅1
/// </summary>
public FryPotOne fryPotOne= new FryPotOne();
/// <summary>
/// 炒锅2
/// </summary>
public FryPotTwo fryPotTwo= new FryPotTwo();
/// <summary>
/// 炒锅3
/// </summary>
public FryPotThree fryPotThree= new FryPotThree();
/// <summary>
/// 炒锅4
/// </summary>
public FryPotFour fryPotFour= new FryPotFour();
/// <summary>
/// 炒锅5
/// </summary>
public FryPotFive fryPotFive= new FryPotFive();
/// <summary>
/// 洗桶进桶滚筒运行信号
/// </summary>
public ushort CleadBarrelEnterSingle { get; set; }
/// <summary>
/// 洗桶出桶滚筒运行信号
/// </summary>
public ushort CleadBarrelExitSingle { get; set; }
/// <summary>
/// PLC初始化状态
/// </summary>
public ushort PlcInite { get; set; }
#region 上位机内部逻辑条件
/// <summary>
/// 退出主任务循环
/// </summary>
public bool ExitMainTask { get; set; }
/// <summary>
/// 允许AGV去线体装桶条件
/// </summary>
public bool AllowAgvToLineLoadRoller { get; set; } = true;
/// <summary>
/// 配方唯一ID
/// </summary>
public string RecipeId { get; set; }
/// <summary>
/// 进桶出桶互锁
/// </summary>
public bool InOrOutputLock { get; set; }
#endregion

}
/// <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; }
}
}

+ 15
- 0
FryPot_DosingSystem/Control/MaterialInfo.cs Visa fil

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

namespace FryPot_DosingSystem.Control
{
internal class MaterialInfo
{
public MaterialType materialType { get; set;}
public string materialId { get; set; }//原料所属配方的唯一ID
}
}

+ 30
- 0
FryPot_DosingSystem/FryPot_DosingSystem.csproj Visa fil

@@ -0,0 +1,30 @@
<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.AGV\BPASmartClient.AGV.csproj" />
<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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 ushort _materialWeight;
public ushort MaterialWeight { get { return _materialWeight; }set { _materialWeight = value;OnPropertyChanged(); } }
/// <summary>
/// 原料对应桶位置
/// </summary>
private ushort _materialLoc;
public ushort MaterialLoc { get { return _materialLoc; } set { _materialLoc = value; OnPropertyChanged(); } }

}
}

+ 14
- 0
FryPot_DosingSystem/Model/PlcVariableModel.cs Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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;
}
}
}

+ 260
- 0
FryPot_DosingSystem/View/MainWindow.xaml Visa fil

@@ -0,0 +1,260 @@
<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}" />
<CheckBox
Margin="5,0,5,0"
Content="设备初始化"
IsChecked="{Binding Status}"
/>
</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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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 Visa fil

@@ -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);
}));
});
}
}
}

+ 173
- 0
FryPot_DosingSystem/ViewModel/MainViewModel.cs Visa fil

@@ -0,0 +1,173 @@

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 bool _status;
/// <summary>
/// 设备初始化状态
/// </summary>
public bool Status
{
get { return _status; }
set
{
if (value)
{
ActionManage.GetInstance.Send("StartPlcInite");
}
else
{
ActionManage.GetInstance.Send("EndPlcInite");
}
_status = 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 Visa fil

@@ -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");
}
});
}
}
}

+ 65
- 0
FryPot_DosingSystem/ViewModel/RecipeSetDownViewModel.cs Visa fil

@@ -0,0 +1,65 @@
using BPASmartClient.Helper;
using BPASmartClient.Message;
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)
{
ActionManage.GetInstance.Send("RecipeSetDown",recipeModel);
recipeModel.RecipeSetInfo = "下发成功";
}
}
}

+ 80
- 0
FryPot_DosingSystem/ViewModel/RecipeSetViewModel.cs Visa fil

@@ -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();//保存配方
}
}
});
}
}
}

Binär
Visa fil


+ 1
- 0
LoginUp.hbl Visa fil

@@ -0,0 +1 @@
deac37237d550f2bb590b1d004aab120f4401e4504fd380cf9afa150f1f019d624ce5842ec9c5a8b2120413b2d623477a5b1c93800f28232dfcce895649de806a90a33c6aa3e437981381bb5e28745b8c5a9df97b8b94372d1b9dcac16580901

+ 23
- 0
SmartClient.sln Visa fil

@@ -102,6 +102,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.AGV", "BPASm
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkT_Show", "BPASmartClient.MorkT_Show\BPASmartClient.MorkT_Show.csproj", "{3653724D-3683-4722-B978-EB88DD4AE5DB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FryPot_DosingSystem", "FryPot_DosingSystem\FryPot_DosingSystem.csproj", "{D638DFA2-D160-4D32-912F-385BC04A9382}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.ZhuoDian", "BPASmartClient.ZhuoDian\BPASmartClient.ZhuoDian.csproj", "{C5D53928-34F6-4FA0-A8E6-261BAC1A659C}"
EndProject
Global
@@ -938,6 +940,26 @@ Global
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x64.Build.0 = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x86.ActiveCfg = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x86.Build.0 = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|ARM.ActiveCfg = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|ARM.Build.0 = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|ARM64.Build.0 = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|x64.ActiveCfg = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|x64.Build.0 = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|x86.ActiveCfg = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|x86.Build.0 = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|Any CPU.Build.0 = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|ARM.ActiveCfg = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|ARM.Build.0 = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|ARM64.ActiveCfg = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|ARM64.Build.0 = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|x64.ActiveCfg = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|x64.Build.0 = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|x86.ActiveCfg = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|x86.Build.0 = Release|Any CPU
{C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Debug|ARM.ActiveCfg = Debug|Any CPU
@@ -1004,6 +1026,7 @@ Global
{724087A3-E7E7-4494-B844-414FF5CD1D40} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F}
{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625}
{3653724D-3683-4722-B978-EB88DD4AE5DB} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F}
{D638DFA2-D160-4D32-912F-385BC04A9382} = {8712125E-14CD-4E1B-A1CE-4BDE03805942}
{C5D53928-34F6-4FA0-A8E6-261BAC1A659C} = {8712125E-14CD-4E1B-A1CE-4BDE03805942}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution


+ 1
- 0
up.hbl Visa fil

@@ -0,0 +1 @@
deac37237d550f2bb590b1d004aab120481999a41282f0d8eed6fa9049bb2b58cf766ac542f7a79f9082f942d0190d731890e60eebc260ec3b9e76773b3e4e83443ee7e834210c4de2f560a9b4a6dffbc2a95b696b61aa07653dc4afdd31b551dc9f238426fc95486e3cf08d9387518bf125481cbfd4003d593f7f0c83167badfca9e6b0e585bf724542d50252bd672d2650e1146dd47b395b9b5d22b4fba4e75f528e15f91b5eb98112d2b1a3d5b1e1305cd1a1086a71336213e2a7cf83b262e36d4f33428a80c089f2f1ed81695a6c2d431dd7aaf64d71262dd132539e26900ebb7a6d1cc5923550c6612fdfee2a0a

Laddar…
Avbryt
Spara