添加项目文件。
This commit is contained in:
57
SamplePreSystem.UI/ViewModel/Monitor/FaultInfo.cs
Normal file
57
SamplePreSystem.UI/ViewModel/Monitor/FaultInfo.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
//using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace SamplePreSystem.UI.ViewModel.Monitor
|
||||
{
|
||||
/// <summary>
|
||||
/// 监控故障信息实体
|
||||
/// </summary>
|
||||
public class FaultInfo :INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public string FaultName { get; set; } // 故障名称
|
||||
|
||||
public string FaultDesc { get; set; } // 故障描述
|
||||
public FaultType FaultType { get; set; } // 故障类型
|
||||
|
||||
private Brush runColor = Brushes.Orange;
|
||||
|
||||
|
||||
|
||||
public Brush RunColor
|
||||
{
|
||||
get { return runColor; }
|
||||
set
|
||||
{
|
||||
runColor = value;
|
||||
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 定义故障类型枚举
|
||||
public enum FaultType
|
||||
{
|
||||
Warning = 0, // 警告
|
||||
Error = 1, // 错误
|
||||
Critical = 2, // 严重错误
|
||||
Run = 3 // 严重错误
|
||||
}
|
||||
}
|
||||
549
SamplePreSystem.UI/ViewModel/Monitor/MonitorViewModel.cs
Normal file
549
SamplePreSystem.UI/ViewModel/Monitor/MonitorViewModel.cs
Normal file
@@ -0,0 +1,549 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Models.Const;
|
||||
using Models.Models;
|
||||
using SamplePre.Common;
|
||||
using SamplePre.Communication.Communication;
|
||||
using SamplePre.Models;
|
||||
using SamplePre.Models.Ext;
|
||||
using SamplePre.ProcessBll.BLL;
|
||||
using SamplePre.ProcessBll.SampleSequence;
|
||||
using SamplePre.UIWpf.MonitorManager.chirld;
|
||||
using SamplePre.UIWpf.SampleManager.chirld;
|
||||
using SamplePreSystem.UI.Views.MonitorManager;
|
||||
|
||||
|
||||
//using SamplePre.UIWpf.Properties;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using static MaterialDesignThemes.Wpf.Theme.ToolBar;
|
||||
|
||||
namespace SamplePreSystem.UI.ViewModel.Monitor
|
||||
{
|
||||
public partial class MonitorViewModel: ObservableObject
|
||||
{
|
||||
|
||||
SampleSequenceBll sampleSequenceBll = new SampleSequenceBll();
|
||||
|
||||
ActionMangerBll actionMangerBll = new ActionMangerBll();
|
||||
|
||||
MonitorBll monitorBll = new MonitorBll();
|
||||
|
||||
CommunicationBll communicationBll = new CommunicationBll();
|
||||
|
||||
SOPManagerBll sopManagerBll = new SOPManagerBll();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 所有动作
|
||||
/// </summary>
|
||||
List<sys_action_ext> sys_Actions = new List<sys_action_ext>();
|
||||
|
||||
|
||||
public MonitorViewModel()
|
||||
{
|
||||
//所有动作
|
||||
sys_Actions = actionMangerBll.QuerySysAction();
|
||||
|
||||
GetSampleData();
|
||||
|
||||
//初始化功能单元
|
||||
InitWorkUnits();
|
||||
|
||||
///启动数据监控线程
|
||||
UpdateMonitorData();
|
||||
|
||||
Test();
|
||||
|
||||
|
||||
//获取当前SOP所有动作列表
|
||||
GetCurrentSopByID(this.CurrentSopID);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前SOP所有动作列表
|
||||
/// </summary>
|
||||
/// <param name="sopID"></param>
|
||||
public void GetCurrentSopByID(string sopID)
|
||||
{
|
||||
CurrentstandardActionList = sopManagerBll.QueryStandardActionByStandardId(sopID)?.OrderBy(p => p.process_no).ToList(); ;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算进度百分比
|
||||
/// </summary>
|
||||
/// <param name="actionID"></param>
|
||||
public void CalculationProgress(string actionID)
|
||||
{
|
||||
if (CurrentstandardActionList.Count <= 0) return;
|
||||
|
||||
var item = CurrentstandardActionList.Where(p => p.process_id == actionID && p.ExecFinishFlag == false).FirstOrDefault();
|
||||
if (item != null)
|
||||
{
|
||||
item.ExecFinishFlag = true;
|
||||
|
||||
int finishcount = CurrentstandardActionList.Count(p => p.ExecFinishFlag == true);
|
||||
int totalcount = CurrentstandardActionList.Count;
|
||||
|
||||
double percent = (float)finishcount / totalcount;
|
||||
|
||||
CurrentPercent = Math.Round(percent * 100,0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前SOP_ID
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
public string currentSopID = "";
|
||||
|
||||
/// <summary>
|
||||
/// 当前百分比
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
public double currentPercent = 10;
|
||||
|
||||
/// <summary>
|
||||
/// 当前SOP动作
|
||||
/// </summary>
|
||||
public List<sys_standard_action_ext> CurrentstandardActionList = new List<sys_standard_action_ext>();
|
||||
|
||||
public void Test()
|
||||
{
|
||||
SopExecInfo.Add(new SopExecInfo()
|
||||
{
|
||||
sapmleName = "DCM固相萃取",
|
||||
actionName = "加液",
|
||||
starDate = DateTime.Now,
|
||||
endDate = DateTime.Now,
|
||||
state = "完成",
|
||||
doIngShow = false
|
||||
|
||||
});
|
||||
SopExecInfo.Add(new SopExecInfo()
|
||||
{
|
||||
sapmleName = "DCM固相萃取",
|
||||
actionName = "加液",
|
||||
starDate = DateTime.Now,
|
||||
endDate = DateTime.Now,
|
||||
state = "完成",
|
||||
doIngShow = false
|
||||
});
|
||||
SopExecInfo.Add(new SopExecInfo()
|
||||
{
|
||||
sapmleName = "DCM固相萃取",
|
||||
actionName = "加液",
|
||||
starDate = DateTime.Now,
|
||||
endDate = DateTime.Now,
|
||||
state = "完成",
|
||||
doIngShow = false
|
||||
|
||||
});
|
||||
SopExecInfo.Add(new SopExecInfo()
|
||||
{
|
||||
sapmleName = "DCM固相萃取",
|
||||
actionName = "离心",
|
||||
starDate = DateTime.Now,
|
||||
endDate = DateTime.Now,
|
||||
state = "执行",
|
||||
doIngShow = true
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
private List<sample_exec_detail_ext> _sampleExecList = new List<sample_exec_detail_ext>();
|
||||
|
||||
|
||||
public List<sample_exec_detail_ext> SampleExecList
|
||||
{
|
||||
get { return _sampleExecList; }
|
||||
set {
|
||||
|
||||
SetProperty(ref _sampleExecList, value);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private string _sopExecData;
|
||||
|
||||
public string SopExecData
|
||||
{
|
||||
get { return _sopExecData; }
|
||||
set {
|
||||
|
||||
SetProperty(ref _sopExecData, value);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取样本信息
|
||||
/// </summary>
|
||||
/// <param name="standID"></param>
|
||||
private void GetSampleData()
|
||||
{
|
||||
|
||||
List<sample_exec_detail_ext> samples = sampleSequenceBll.GetSampleExecDetails();
|
||||
SampleExecList = samples;
|
||||
|
||||
//设置当前SOP——ID
|
||||
string standrad_id = samples.FirstOrDefault()?.standrad_id;
|
||||
if (!string.IsNullOrEmpty(standrad_id))
|
||||
{
|
||||
if(standrad_id.Contains(","))
|
||||
{
|
||||
CurrentSopID = standrad_id.Split(",")[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentSopID = standrad_id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private List<WorkUnit> _workUnits = new List<WorkUnit>();
|
||||
|
||||
public List<WorkUnit> WorkUnits
|
||||
{
|
||||
get { return _workUnits; }
|
||||
set {
|
||||
|
||||
SetProperty(ref _workUnits, value);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化功能岛
|
||||
/// </summary>
|
||||
public void InitWorkUnits()
|
||||
{
|
||||
|
||||
var list = SystemConst.dictDatas.Where(p => p.class_id == 2).ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
string imgPath = GetIcon(item.id);
|
||||
|
||||
var icon = GetIconKind(item.id);
|
||||
|
||||
WorkUnits.Add(new WorkUnit() { actionName= "无", state = 0, StateName = "未连通", unitCode = item.id, unitName = item.data_type ,imgPath = imgPath,packIconKind = icon });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 故障信息
|
||||
/// </summary>
|
||||
private ObservableCollection<FaultInfo> faultInfos = new ObservableCollection<FaultInfo>();
|
||||
|
||||
public ObservableCollection<FaultInfo> FaultInfos
|
||||
{
|
||||
get { return faultInfos; }
|
||||
set {
|
||||
|
||||
SetProperty(ref faultInfos, value);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新监控数据
|
||||
/// </summary>
|
||||
public void UpdateMonitorData()
|
||||
{
|
||||
//if (tileGroup2.Items.Count <= 0) return;
|
||||
|
||||
Task.Factory.StartNew(async () => {
|
||||
|
||||
try
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
//ushort[] data1 = SystemConst.MasterPLC.ReadArraysShort(100, 1000, 1000);
|
||||
ushort[] data1 = communicationBll.ReadSateData(100, 1000, 1000);
|
||||
|
||||
//跨线程
|
||||
Application.Current?.Dispatcher.Invoke(() =>
|
||||
{
|
||||
FaultInfos.Clear();
|
||||
});
|
||||
|
||||
//刷新功能岛
|
||||
UpdateWorkUnit(data1);
|
||||
|
||||
|
||||
//刷新样品列表
|
||||
GetSampleData();
|
||||
|
||||
await Task.Delay(3000);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
LoggerHelper.Logger.Error("更新监控数据异常退出:" + ex.Message + ex.StackTrace);
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新功能岛信息
|
||||
/// </summary>
|
||||
/// <param name="data1"></param>
|
||||
public void UpdateWorkUnit(ushort[] data1)
|
||||
{
|
||||
//WorkUnits
|
||||
if (data1 != null && data1.Length > 0)
|
||||
{
|
||||
|
||||
foreach(var workUnit in WorkUnits)
|
||||
{
|
||||
var unit_actions = sys_Actions.Where(p => p.action_unit == workUnit.unitCode).ToList();
|
||||
foreach (var action in unit_actions)
|
||||
{
|
||||
int plcCode = int.Parse(action.plc_type);
|
||||
ushort state = data1[plcCode];//动作的状态码
|
||||
|
||||
//UCFunUnit uCFunUnit = this.dictUnits[unitCode];
|
||||
if(state >= 2)
|
||||
{
|
||||
//处理sop执行状态,计算执行百分比
|
||||
CalculationProgress(action.id);
|
||||
|
||||
}
|
||||
|
||||
if (state >= workUnit.state || state == 2)
|
||||
{ //发生改变再修改
|
||||
if (workUnit.state != state || workUnit.actionName != action.action_name)
|
||||
{
|
||||
workUnit.state = state;
|
||||
workUnit.StateName = SetStateData(state);
|
||||
workUnit.RunColor = WorkUnit.GetStateColor(state);
|
||||
workUnit.actionName = state < 2 ? "无" : action.action_name;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//如果动作一样,状态发生变化,就要修改
|
||||
if (workUnit.state != state && workUnit.actionName == action.action_name)
|
||||
{
|
||||
workUnit.state = state;
|
||||
workUnit.StateName = SetStateData(state);
|
||||
workUnit.RunColor = WorkUnit.GetStateColor(state);
|
||||
workUnit.actionName = state < 2 ? "无" : action.action_name;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//添加故障信息
|
||||
if (workUnit.state == 0)
|
||||
{
|
||||
Application.Current?.Dispatcher.BeginInvoke(new Action(() => {
|
||||
FaultInfos.Add(new FaultInfo { FaultName = workUnit.unitName + " - 未连通", FaultType = FaultType.Warning });
|
||||
}), DispatcherPriority.Normal);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public string GetIcon(string code)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case "300":
|
||||
return "/Assets/机器人1.png";//Resources.机器人1;
|
||||
|
||||
case "301":
|
||||
return "/Assets/分液1.png";//Resources.分液1;
|
||||
|
||||
case "302":
|
||||
return "/Assets/离心机1.png";//Resources.离心机1;
|
||||
|
||||
case "303":
|
||||
return "/Assets/氮吹1.png";
|
||||
|
||||
case "304":
|
||||
return "/Assets/固相萃取1.png";//Resources.固相萃取1;
|
||||
|
||||
default:
|
||||
return "/Assets/机器人1.png";//Resources.机器人1;
|
||||
}
|
||||
}
|
||||
|
||||
public PackIconKind GetIconKind(string code)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case "300":
|
||||
return PackIconKind.RobotIndustrialOutline;//Resources.机器人1;
|
||||
|
||||
case "301":
|
||||
return PackIconKind.TestTube;//Resources.分液1;
|
||||
|
||||
case "302":
|
||||
return PackIconKind.GoogleCirclesCommunities;//Resources.离心机1;
|
||||
|
||||
case "303":
|
||||
return PackIconKind.GoogleCirclesGroup;
|
||||
|
||||
case "304":
|
||||
return PackIconKind.InboxMultiple;//Resources.固相萃取1;
|
||||
|
||||
default:
|
||||
return PackIconKind.ThermometerWater; //Resources.机器人1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public string SetStateData(int state)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
if (state == 0)
|
||||
{
|
||||
return "未连接";
|
||||
|
||||
|
||||
}
|
||||
if (state == 1)
|
||||
{
|
||||
return "待机";
|
||||
}
|
||||
else if (state == 2)
|
||||
{
|
||||
return "运行";
|
||||
|
||||
|
||||
}
|
||||
else if (state == 3)
|
||||
{
|
||||
return "完成";
|
||||
}
|
||||
|
||||
|
||||
return "未连接";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggerHelper.Logger.Error(ex.Message + ex.StackTrace);
|
||||
return "未连接";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
SocketClient client;
|
||||
/// <summary>
|
||||
/// 启动socket
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task StarClientAsync()
|
||||
{
|
||||
client = new SocketClient();
|
||||
|
||||
//回调函数
|
||||
client.ReceiveMsgAction = UpdateSopExecInfo;
|
||||
|
||||
await client.StartClientAsync();
|
||||
}
|
||||
|
||||
public void SendSocketTest(string msg)
|
||||
{
|
||||
client.SendMsgAsync(msg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新sop执行信息
|
||||
/// </summary>
|
||||
/// <param name="receiveData"></param>
|
||||
public void UpdateSopExecInfo(string receiveData)
|
||||
{
|
||||
SopExecData += receiveData + "\r\n";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// sop执行信息
|
||||
/// </summary>
|
||||
private List<SopExecInfo> sopExecInfo = new List<SopExecInfo>();
|
||||
|
||||
public List<SopExecInfo> SopExecInfo
|
||||
{
|
||||
get { return sopExecInfo; }
|
||||
set { sopExecInfo = value; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 打开详情窗口
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
public void HLinkDetailClick(string unitName)
|
||||
{
|
||||
|
||||
var param = unitName;
|
||||
var item = SystemConst.dictDatas.Where(p => p.data_type == param.ToString() && p.class_id == 2).FirstOrDefault();
|
||||
if (item != null)
|
||||
{
|
||||
UnitDetailWindow frm = new UnitDetailWindow(item.id);
|
||||
frm.ShowDialog();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开明细进度窗口
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
public void MouseDoubleDetailWindow()
|
||||
{
|
||||
SampleDetailWindow frm = new SampleDetailWindow();
|
||||
frm.ShowDialog();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
110
SamplePreSystem.UI/ViewModel/Monitor/UnitDetailViewModel.cs
Normal file
110
SamplePreSystem.UI/ViewModel/Monitor/UnitDetailViewModel.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using SamplePre.Models;
|
||||
using SamplePre.ProcessBll.BLL;
|
||||
using SamplePre.ProcessBll.SampleSequence;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SamplePreSystem.UI.ViewModel.Monitor
|
||||
{
|
||||
public class UnitDetailViewModel : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
MonitorBll monitorBll = new MonitorBll();
|
||||
|
||||
CommunicationBll communicationBll = new CommunicationBll();
|
||||
|
||||
ActionMangerBll actionMangerBll = new ActionMangerBll();
|
||||
|
||||
string unitID;
|
||||
public UnitDetailViewModel(string _unitID)
|
||||
{
|
||||
unitID = _unitID;
|
||||
|
||||
ShowActionInfo();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 动作状态信息
|
||||
/// </summary>
|
||||
private ObservableCollection<FaultInfo> faultInfos = new ObservableCollection<FaultInfo>();
|
||||
|
||||
public ObservableCollection<FaultInfo> FaultInfos
|
||||
{
|
||||
get { return faultInfos; }
|
||||
set
|
||||
{
|
||||
faultInfos = value;
|
||||
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置异常数据显示
|
||||
/// </summary>
|
||||
public void ShowActionInfo()
|
||||
{
|
||||
//读取下位机状态
|
||||
ushort[] data1 = communicationBll.ReadSateData(100, 1000, 1000);
|
||||
if (data1 == null || data1.Length <= 0) return;
|
||||
|
||||
//查询该单元中的动作
|
||||
var sys_Actions = actionMangerBll.QuerySysAction();
|
||||
sys_Actions = sys_Actions.Where(p => p.action_unit == unitID).ToList();
|
||||
|
||||
|
||||
|
||||
foreach (var sys_action in sys_Actions)
|
||||
{
|
||||
|
||||
if (data1 != null && data1.Length > 0)
|
||||
{
|
||||
int state = data1[int.Parse(sys_action.plc_type)];
|
||||
//state = 2;
|
||||
if (state == 0)
|
||||
{
|
||||
FaultInfos.Add(new FaultInfo() { FaultName = sys_action.action_name, FaultDesc = "未连通", RunColor = WorkUnit.GetStateColor(state) });
|
||||
}
|
||||
if (state == 1)
|
||||
{
|
||||
FaultInfos.Add(new FaultInfo() { FaultName = sys_action.action_name, FaultDesc = "待机", RunColor = WorkUnit.GetStateColor(state) });
|
||||
}
|
||||
if (state == 2)
|
||||
{
|
||||
FaultInfos.Add(new FaultInfo() { FaultName = sys_action.action_name, FaultDesc = "运行", RunColor = WorkUnit.GetStateColor(state) });
|
||||
}
|
||||
if (state == 3)
|
||||
{
|
||||
FaultInfos.Add(new FaultInfo() { FaultName = sys_action.action_name, FaultDesc = "完成", RunColor = WorkUnit.GetStateColor(state) });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FaultInfos.Add(new FaultInfo() { FaultName = sys_action.action_name, FaultDesc = "待机", RunColor = WorkUnit.GetStateColor(0) });
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
149
SamplePreSystem.UI/ViewModel/Monitor/WorkUnit.cs
Normal file
149
SamplePreSystem.UI/ViewModel/Monitor/WorkUnit.cs
Normal file
@@ -0,0 +1,149 @@
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using SamplePre.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace SamplePreSystem.UI.ViewModel.Monitor
|
||||
{
|
||||
public class WorkUnit : INotifyPropertyChanged
|
||||
{
|
||||
|
||||
private int _state;
|
||||
|
||||
public int state
|
||||
{
|
||||
get { return _state; }
|
||||
set { _state = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private string _stateName;
|
||||
|
||||
public string StateName
|
||||
{
|
||||
get { return _stateName; }
|
||||
set { _stateName = value;
|
||||
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private string _actionName;
|
||||
|
||||
public string actionName
|
||||
{
|
||||
get { return _actionName; }
|
||||
set { _actionName = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private string _unitName;
|
||||
|
||||
public string unitName
|
||||
{
|
||||
get { return _unitName; }
|
||||
set { _unitName = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private string _unitCode;
|
||||
|
||||
public string unitCode
|
||||
{
|
||||
get { return _unitCode; }
|
||||
set { _unitCode = value;
|
||||
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string imgPath { get; set; }
|
||||
|
||||
public PackIconKind packIconKind { get; set; }
|
||||
|
||||
private Brush runColor = Brushes.Orange ;
|
||||
|
||||
public Brush RunColor
|
||||
{
|
||||
get { return runColor; }
|
||||
set { runColor = value;
|
||||
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取运行状态的颜色
|
||||
/// </summary>
|
||||
/// <param name="state"></param>
|
||||
/// <returns></returns>
|
||||
public static Brush GetStateColor(int state)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
if (state == 0)
|
||||
{
|
||||
return Brushes.Red;
|
||||
|
||||
|
||||
}
|
||||
if (state == 1)
|
||||
{
|
||||
return Brushes.Orange;
|
||||
}
|
||||
else if (state == 2)
|
||||
{
|
||||
return Brushes.LightGreen;
|
||||
|
||||
|
||||
}
|
||||
else if (state == 3)
|
||||
{
|
||||
return Brushes.Green;
|
||||
}
|
||||
|
||||
|
||||
return Brushes.Orange;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggerHelper.Logger.Error(ex.Message + ex.StackTrace);
|
||||
return Brushes.Orange;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user