diff --git a/FryPot_DosingSystem/Control/DosingLogicControl.cs b/FryPot_DosingSystem/Control/DosingLogicControl.cs index 3f7ba180..a9feba2a 100644 --- a/FryPot_DosingSystem/Control/DosingLogicControl.cs +++ b/FryPot_DosingSystem/Control/DosingLogicControl.cs @@ -5,6 +5,7 @@ using BPASmartClient.CustomResource.Pages.Model; using BPASmartClient.Helper; using BPASmartClient.HubHelper; using FryPot_DosingSystem.Model; +using FryPot_DosingSystem.ViewModel; using Newtonsoft.Json; using System; using System.Collections.Concurrent; @@ -14,6 +15,7 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; +using System.Windows.Media; namespace FryPot_DosingSystem.Control { @@ -38,6 +40,10 @@ namespace FryPot_DosingSystem.Control /// 全局变量对象声明 /// GlobalVariable globalVar; + /// + /// 线体状态对象声明 + /// + HardWareStatusViewModel hardWareStatusModel; #region 上位机内部变量 //int lineAlarm = 0;//线体故障信号 1:无故障 -1:故障 @@ -55,6 +61,7 @@ namespace FryPot_DosingSystem.Control public DosingLogicControl() { globalVar = new GlobalVariable(); + hardWareStatusModel = HardWareStatusViewModel.GetInstance; ActionManage.GetInstance.Register(new Action(RecipeDataParse), "RecipeSetDown"); ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.Clear(); }), "ClearRecipes"); ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 1; }), "StartPlcInite"); @@ -66,6 +73,7 @@ namespace FryPot_DosingSystem.Control ReadPlcData(); IniteTask(); } + /// /// AGV上下料上报数据解析 /// @@ -252,11 +260,94 @@ namespace FryPot_DosingSystem.Control globalVar.CleadBarrelExitSingle = data[0]; })); + globalVar.rollerLineOne.OutMaterialingSingle = 1; + globalVar.rollerLineOne.StationOne = 401; + RollerLineStatusDisplay(); Thread.Sleep(10); }), "MainViewReadPlcData"); - + } + /// + /// 滚筒线运行状态显示 + /// + private void RollerLineStatusDisplay() + { + hardWareStatusModel.RollerOneModel.LocOneRollerSerial = globalVar.rollerLineOne.StationOne; + hardWareStatusModel.RollerOneModel.LocTwoRollerSerial = globalVar.rollerLineOne.StationTwo; + hardWareStatusModel.RollerOneModel.LocThreeRollerSerial = globalVar.rollerLineOne.StationThree; + hardWareStatusModel.RollerOneModel.LocFourRollerSerial=globalVar.rollerLineOne.StationFour; + hardWareStatusModel.RollerOneModel.LocFiveRollerSerial=globalVar.rollerLineOne.StationFive; + hardWareStatusModel.RollerOneModel.LocSixRollerSerial = globalVar.rollerLineOne.StationSix; + hardWareStatusModel.RollerOneModel.LocSevenRollerSerial = globalVar.rollerLineOne.StationSeven; + hardWareStatusModel.RollerOneModel.LocEightRollerSerial = globalVar.rollerLineOne.StationEight; + if (globalVar.rollerLineOne.OutMaterialingTroubleSingle == 0) + { + // ActionManage.GetInstance.Send("RedToGray", 1);//无故障 + } + else + { + // ActionManage.GetInstance.Send("ToRed",1);//有故障 + } + if (globalVar.rollerLineOne.OutMaterialingSingle == 1)//运行中 + { + // ActionManage.GetInstance.Send("ToGreen",1); + } + else + { + // ActionManage.GetInstance.Send("GreenToGray",1); //未运行 + } + hardWareStatusModel.RollerTwoModel.LocOneRollerSerial = globalVar.rollerLineTwo.StationOne; + hardWareStatusModel.RollerTwoModel.LocTwoRollerSerial = globalVar.rollerLineTwo.StationTwo; + hardWareStatusModel.RollerTwoModel.LocThreeRollerSerial = globalVar.rollerLineTwo.StationThree; + hardWareStatusModel.RollerTwoModel.LocFourRollerSerial = globalVar.rollerLineTwo.StationFour; + hardWareStatusModel.RollerTwoModel.LocFiveRollerSerial = globalVar.rollerLineTwo.StationFive; + hardWareStatusModel.RollerTwoModel.LocSixRollerSerial = globalVar.rollerLineTwo.StationSix; + hardWareStatusModel.RollerTwoModel.LocSevenRollerSerial = globalVar.rollerLineTwo.StationSeven; + hardWareStatusModel.RollerTwoModel.LocEightRollerSerial = globalVar.rollerLineTwo.StationEight; + if (globalVar.rollerLineTwo.OutMaterialingTroubleSingle == 0) + { + //ActionManage.GetInstance.Send("RedToGray", 2);//无故障 + } + else + { + //ActionManage.GetInstance.Send("ToRed", 2);//有故障 + } + if (globalVar.rollerLineTwo.OutMaterialingSingle == 1)//运行中 + { + + // ActionManage.GetInstance.Send("ToGreen",2); + + } + else + { + // ActionManage.GetInstance.Send("GreenToGray", 2);//未运行 + } + hardWareStatusModel.RollerThreeModel.LocOneRollerSerial = globalVar.rollerLineThree.StationOne; + hardWareStatusModel.RollerThreeModel.LocTwoRollerSerial = globalVar.rollerLineThree.StationTwo; + hardWareStatusModel.RollerThreeModel.LocThreeRollerSerial = globalVar.rollerLineThree.StationThree; + hardWareStatusModel.RollerThreeModel.LocFourRollerSerial = globalVar.rollerLineThree.StationFour; + hardWareStatusModel.RollerThreeModel.LocFiveRollerSerial = globalVar.rollerLineThree.StationFive; + hardWareStatusModel.RollerThreeModel.LocSixRollerSerial = globalVar.rollerLineThree.StationSix; + hardWareStatusModel.RollerThreeModel.LocSevenRollerSerial = globalVar.rollerLineThree.StationSeven; + hardWareStatusModel.RollerThreeModel.LocEightRollerSerial = globalVar.rollerLineThree.StationEight; + if (globalVar.rollerLineThree.OutMaterialingTroubleSingle == 0) + { + // ActionManage.GetInstance.Send("RedToGray", 3);//无故障 + } + else + { + // ActionManage.GetInstance.Send("ToRed", 3);//有故障 + } + if (globalVar.rollerLineThree.OutMaterialingSingle == 1)//运行中 + { + // ActionManage.GetInstance.Send("ToGreen", 3); + } + else + { + //ActionManage.GetInstance.Send("GreenToGray",3);//未运行 + } + } /// /// 返回指定地址指定长度的数据 /// diff --git a/FryPot_DosingSystem/Model/RollerLineBarrelSerialModel.cs b/FryPot_DosingSystem/Model/RollerLineBarrelSerialModel.cs new file mode 100644 index 00000000..a1aa6f0f --- /dev/null +++ b/FryPot_DosingSystem/Model/RollerLineBarrelSerialModel.cs @@ -0,0 +1,44 @@ +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 RollerLineBarrelSerialModel:ObservableObject + { + private int _locOneRollerSerial; + public int LocOneRollerSerial { get { return _locOneRollerSerial; } set { _locOneRollerSerial = value;OnPropertyChanged(); } } + + private int _locTwoRollerSerial; + public int LocTwoRollerSerial { get { return _locTwoRollerSerial; } set { _locTwoRollerSerial = value; OnPropertyChanged(); } } + + private int _locThreeRollerSerial; + public int LocThreeRollerSerial { get { return _locThreeRollerSerial; } set { _locThreeRollerSerial = value; OnPropertyChanged(); } } + + private int _locFourRollerSerial; + public int LocFourRollerSerial { get { return _locFourRollerSerial; } set { _locFourRollerSerial = value; OnPropertyChanged(); } } + + private int _locFiveRollerSerial; + public int LocFiveRollerSerial { get { return _locFiveRollerSerial; } set { _locFiveRollerSerial = value; OnPropertyChanged(); } } + + private int _locSixRollerSerial; + public int LocSixRollerSerial { get { return _locSixRollerSerial; } set { _locSixRollerSerial = value; OnPropertyChanged(); } } + + private int _locSevenRollerSerial; + public int LocSevenRollerSerial { get { return _locSevenRollerSerial; } set { _locSevenRollerSerial = value; OnPropertyChanged(); } } + + private int _locEightRollerSerial; + public int LocEightRollerSerial { get { return _locEightRollerSerial; } set { _locEightRollerSerial = value; OnPropertyChanged(); } } + + //private Brush? _rollerRunState; + //public Brush RollerRunState { get { return _rollerRunState; } set { _rollerRunState = value; OnPropertyChanged(); } } + + + //private Color _rollerAlarmState; + //public Color RollerAlarmState { get { return _rollerAlarmState; } set { _rollerAlarmState = value; OnPropertyChanged(); } } + } +} diff --git a/FryPot_DosingSystem/View/HardWareStatusView.xaml b/FryPot_DosingSystem/View/HardWareStatusView.xaml index 48b2fd23..5365da2d 100644 --- a/FryPot_DosingSystem/View/HardWareStatusView.xaml +++ b/FryPot_DosingSystem/View/HardWareStatusView.xaml @@ -4,9 +4,644 @@ 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"> + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FryPot_DosingSystem/View/HardWareStatusView.xaml.cs b/FryPot_DosingSystem/View/HardWareStatusView.xaml.cs index a90f2f7c..0cab32b3 100644 --- a/FryPot_DosingSystem/View/HardWareStatusView.xaml.cs +++ b/FryPot_DosingSystem/View/HardWareStatusView.xaml.cs @@ -1,4 +1,5 @@ -using System; +using BPASmartClient.Helper; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -23,6 +24,51 @@ namespace FryPot_DosingSystem.View public HardWareStatusView() { InitializeComponent(); + ActionManage.GetInstance.Register(new Action((a) => + { + switch (a) + { + case 1: gsGreen1.Color = Color.FromRgb(130, 232, 139);break; + case 2: gsGreen2.Color = Color.FromRgb(130, 232, 139); break; + case 3: gsGreen3.Color = Color.FromRgb(130, 232, 139); break; + case 4: gsGreen4.Color = Color.FromRgb(130, 232, 139); break; + } + + }), "ToGreen"); + ActionManage.GetInstance.Register(new Action((a) => + { + switch (a) + { + case 1: gsRed1.Color = Color.FromRgb(243, 165, 230); break; + case 2: gsRed2.Color = Color.FromRgb(243, 165, 230); break; + case 3: gsRed3.Color = Color.FromRgb(243, 165, 230); break; + case 4: gsRed4.Color = Color.FromRgb(243, 165, 230); break; + } + + }), "ToRed"); + ActionManage.GetInstance.Register(new Action((a) => + { + switch (a) + { + case 1: gsGreen1.Color = Color.FromRgb(84,84,84); break; + case 2: gsGreen2.Color = Color.FromRgb(84,84,84); break; + case 3: gsGreen3.Color = Color.FromRgb(84,84,84); break; + case 4: gsGreen4.Color = Color.FromRgb(84,84,84); break; + } + + }), "GreenToGray"); + ActionManage.GetInstance.Register(new Action((a) => + { + switch (a) + { + case 1: gsRed1.Color = Color.FromRgb(84,84,84); break; + case 2: gsRed2.Color = Color.FromRgb(84,84,84); break; + case 3: gsRed3.Color = Color.FromRgb(84,84,84); break; + case 4: gsRed4.Color = Color.FromRgb(84,84,84); break; + } + + }), "RedToGray"); + } } } diff --git a/FryPot_DosingSystem/ViewModel/HardWareStatusViewModel.cs b/FryPot_DosingSystem/ViewModel/HardWareStatusViewModel.cs new file mode 100644 index 00000000..fe70994a --- /dev/null +++ b/FryPot_DosingSystem/ViewModel/HardWareStatusViewModel.cs @@ -0,0 +1,48 @@ +using BPASmartClient.Helper; +using FryPot_DosingSystem.Model; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FryPot_DosingSystem.ViewModel +{ + internal class HardWareStatusViewModel:ObservableObject + { + private static HardWareStatusViewModel _instance; + public static HardWareStatusViewModel GetInstance=>_instance??=new HardWareStatusViewModel(); + public HardWareStatusViewModel() + { + RollerOneModel = new RollerLineBarrelSerialModel(); + RollerTwoModel = new RollerLineBarrelSerialModel(); + RollerThreeModel = new RollerLineBarrelSerialModel(); + + } + /// + /// 线体1 工位->桶号 + /// + private RollerLineBarrelSerialModel _rollerOneModel; + public RollerLineBarrelSerialModel RollerOneModel { get { return _rollerOneModel; }set { _rollerOneModel = value;OnPropertyChanged(); } } + + + /// + /// 线体2 工位->桶号 + /// + private RollerLineBarrelSerialModel _rollerTwoModel; + public RollerLineBarrelSerialModel RollerTwoModel { get { return _rollerTwoModel; } set { _rollerTwoModel = value; OnPropertyChanged(); } } + + /// + /// 线体3 工位->桶号 + /// + private RollerLineBarrelSerialModel _rollerThreeModel; + public RollerLineBarrelSerialModel RollerThreeModel { get { return _rollerThreeModel; } set { _rollerThreeModel = value; OnPropertyChanged(); } } + /// + /// 线体4 工位->桶号s + /// + private RollerLineBarrelSerialModel _rollerFourModel; + public RollerLineBarrelSerialModel RollerFourModel { get { return _rollerFourModel; } set { _rollerFourModel = value; OnPropertyChanged(); } } + } +}