修改监控部分功能
This commit is contained in:
@@ -7,14 +7,12 @@ using SamplePre.Common;
|
||||
using SamplePre.Communication.Communication;
|
||||
using SamplePre.Models;
|
||||
using SamplePre.Models.Ext;
|
||||
using SamplePre.Models.Models;
|
||||
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;
|
||||
@@ -45,7 +43,13 @@ namespace SamplePreSystem.UI.ViewModel.Monitor
|
||||
CommunicationBll communicationBll = new CommunicationBll();
|
||||
|
||||
SOPManagerBll sopManagerBll = new SOPManagerBll();
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// u错误队列
|
||||
/// </summary>
|
||||
ConcurrentQueueExt<FaultInfo> errQueue = new SamplePre.Common.ConcurrentQueueExt<FaultInfo>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 所有动作
|
||||
@@ -58,144 +62,39 @@ namespace SamplePreSystem.UI.ViewModel.Monitor
|
||||
//所有动作
|
||||
sys_Actions = actionMangerBll.QuerySysAction();
|
||||
|
||||
GetSampleData();
|
||||
//获取所有样本信息
|
||||
GetSampleData();
|
||||
|
||||
//获取当前SOP所有动作列表
|
||||
GetCurrentSopByID(CurrentSop.id);
|
||||
|
||||
//计算进度百分比
|
||||
CalculationProgress(CurrentSop.id);
|
||||
|
||||
//初始化功能单元
|
||||
InitWorkUnits();
|
||||
InitWorkUnits();
|
||||
|
||||
///启动数据监控线程
|
||||
UpdateMonitorData();
|
||||
|
||||
Test();
|
||||
//错误信息处理
|
||||
ErrInfoDo();
|
||||
|
||||
|
||||
//获取当前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;
|
||||
#region PLC 通信状态监控
|
||||
|
||||
//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 = "";
|
||||
public string txtState = "PLC通信异常!";
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 样品列表
|
||||
|
||||
/// <summary>
|
||||
/// 当前百分比
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
public double currentPercent = 40;
|
||||
|
||||
/// <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_input> _sampleExecList = new List<sample_input>();
|
||||
|
||||
|
||||
public List<sample_input> SampleExecList
|
||||
{
|
||||
get { return _sampleExecList; }
|
||||
set {
|
||||
|
||||
SetProperty(ref _sampleExecList, value);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private string _sopExecData;
|
||||
|
||||
public string SopExecData
|
||||
{
|
||||
get { return _sopExecData; }
|
||||
set {
|
||||
|
||||
SetProperty(ref _sopExecData, value);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public List<sample_input> sampleExecList = new List<sample_input>();
|
||||
|
||||
/// <summary>
|
||||
/// 获取样本信息
|
||||
@@ -209,31 +108,138 @@ namespace SamplePreSystem.UI.ViewModel.Monitor
|
||||
|
||||
//设置当前SOP——ID
|
||||
string standrad_id = samples.FirstOrDefault()?.standrad_id;
|
||||
string standrad_name = samples.FirstOrDefault()?.standrad;
|
||||
if (!string.IsNullOrEmpty(standrad_id))
|
||||
{
|
||||
if(standrad_id.Contains(","))
|
||||
if (standrad_id.Contains(","))
|
||||
{
|
||||
CurrentSopID = standrad_id.Split(",")[0];
|
||||
CurrentSop.id = standrad_id.Split(",")[0];
|
||||
CurrentSop.standard_name = standrad_name.Split(",")[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentSopID = standrad_id;
|
||||
CurrentSop.id = standrad_id;
|
||||
CurrentSop.standard_name = standrad_name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 当前sop的动作列表
|
||||
|
||||
/// <summary>
|
||||
/// sop动作执行信息
|
||||
/// </summary>
|
||||
private List<SopExecInfo> sopExecInfo = new List<SopExecInfo>();
|
||||
|
||||
public List<SopExecInfo> SopExecInfo
|
||||
{
|
||||
get { return sopExecInfo; }
|
||||
set { sopExecInfo = value; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 当前SOP动作
|
||||
/// </summary>
|
||||
public List<sys_standard_action_ext> CurrentstandardActionList = new List<sys_standard_action_ext>();
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前SOP所有动作列表
|
||||
/// </summary>
|
||||
/// <param name="sopID"></param>
|
||||
public void GetCurrentSopByID(string sopID)
|
||||
{
|
||||
CurrentstandardActionList = sopManagerBll.QueryStandardActionByStandardId(sopID)?.OrderBy(p => p.process_no).ToList(); ;
|
||||
|
||||
SopExecInfo.Clear();
|
||||
int index = 1;
|
||||
foreach (var item in CurrentstandardActionList)
|
||||
{
|
||||
if (index == CurrentstandardActionList.Count)
|
||||
{
|
||||
SopExecInfo.Add(new SopExecInfo()
|
||||
{
|
||||
sapmleName = this.currentSop.standard_name,
|
||||
actionName = item.action_name,
|
||||
starDate = DateTime.Now,
|
||||
endDate = DateTime.Now,
|
||||
state = "进行中",
|
||||
doIngShow = true
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
SopExecInfo.Add(new SopExecInfo()
|
||||
{
|
||||
sapmleName = this.currentSop.standard_name,
|
||||
actionName = item.action_name,
|
||||
starDate = DateTime.Now,
|
||||
endDate = DateTime.Now,
|
||||
state = "完成",
|
||||
doIngShow = false
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region sop执行进度
|
||||
|
||||
/// <summary>
|
||||
/// 当前SOP
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
public sys_standard currentSop = new sys_standard();
|
||||
|
||||
/// <summary>
|
||||
/// 当前SOP进度
|
||||
/// </summary>
|
||||
|
||||
[ObservableProperty]
|
||||
public CurrentSopProgress sopProgress = new CurrentSopProgress();
|
||||
|
||||
/// <summary>
|
||||
/// 计算SOP进度百分比
|
||||
/// </summary>
|
||||
/// <param name="actionID"></param>
|
||||
public void CalculationProgress(string SopId)
|
||||
{
|
||||
SopProgress.sopName = this.CurrentSop.standard_name;
|
||||
SopProgress.sampleName = "xxxxx";
|
||||
SopProgress.actionName = CurrentstandardActionList.FirstOrDefault()?.action_name;
|
||||
SopProgress.CurrentPercent = 40;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 功能单元
|
||||
|
||||
|
||||
private List<WorkUnit> _workUnits = new List<WorkUnit>();
|
||||
|
||||
public List<WorkUnit> WorkUnits
|
||||
{
|
||||
get { return _workUnits; }
|
||||
set {
|
||||
|
||||
set
|
||||
{
|
||||
|
||||
SetProperty(ref _workUnits, value);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +248,7 @@ namespace SamplePreSystem.UI.ViewModel.Monitor
|
||||
/// </summary>
|
||||
public void InitWorkUnits()
|
||||
{
|
||||
|
||||
|
||||
var list = SystemConst.dictDatas.Where(p => p.class_id == 2).ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
@@ -250,27 +256,61 @@ namespace SamplePreSystem.UI.ViewModel.Monitor
|
||||
|
||||
var icon = GetIconKind(item.id);
|
||||
|
||||
WorkUnits.Add(new WorkUnit() { actionName= "无", state = 0, StateName = "未连通", unitCode = item.id, unitName = item.data_type ,imgPath = imgPath,packIconKind = icon });
|
||||
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
|
||||
public PackIconKind GetIconKind(string code)
|
||||
{
|
||||
get { return faultInfos; }
|
||||
set {
|
||||
switch (code)
|
||||
{
|
||||
case "300":
|
||||
return PackIconKind.RobotIndustrialOutline;//Resources.机器人1;
|
||||
|
||||
SetProperty(ref faultInfos, value);
|
||||
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新监控数据
|
||||
/// </summary>
|
||||
@@ -296,10 +336,22 @@ namespace SamplePreSystem.UI.ViewModel.Monitor
|
||||
//刷新功能岛
|
||||
UpdateWorkUnit(data1);
|
||||
|
||||
|
||||
|
||||
//刷新样品列表
|
||||
GetSampleData();
|
||||
|
||||
//跟新plc通信状态
|
||||
if(SystemConst.MasterPLC.IsConnected)
|
||||
{
|
||||
TxtState = "PLC通信正常";
|
||||
}
|
||||
else
|
||||
{
|
||||
TxtState = "PLC通信异常!";
|
||||
this.errQueue.Enqueue(new FaultInfo() { FaultName = "PLC通信异常!", FaultDesc = "请检查PLC是否正常!", FaultDate = DateTime.Now });
|
||||
}
|
||||
|
||||
|
||||
await Task.Delay(3000);
|
||||
}
|
||||
|
||||
@@ -325,7 +377,7 @@ namespace SamplePreSystem.UI.ViewModel.Monitor
|
||||
if (data1 != null && data1.Length > 0)
|
||||
{
|
||||
|
||||
foreach(var workUnit in WorkUnits)
|
||||
foreach (var workUnit in WorkUnits)
|
||||
{
|
||||
var unit_actions = sys_Actions.Where(p => p.action_unit == workUnit.unitCode).ToList();
|
||||
foreach (var action in unit_actions)
|
||||
@@ -333,13 +385,7 @@ namespace SamplePreSystem.UI.ViewModel.Monitor
|
||||
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)
|
||||
{ //发生改变再修改
|
||||
@@ -349,7 +395,7 @@ namespace SamplePreSystem.UI.ViewModel.Monitor
|
||||
workUnit.StateName = SetStateData(state);
|
||||
workUnit.RunColor = WorkUnit.GetStateColor(state);
|
||||
workUnit.actionName = state < 2 ? "无" : action.action_name;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -360,77 +406,30 @@ namespace SamplePreSystem.UI.ViewModel.Monitor
|
||||
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);
|
||||
//Application.Current?.Dispatcher.BeginInvoke(new Action(() => {
|
||||
// FaultInfos.Add(new FaultInfo { FaultName = workUnit.unitName + " - 未连通", FaultType = FaultType.Warning });
|
||||
//}), DispatcherPriority.Normal);
|
||||
|
||||
|
||||
errQueue.Enqueue(new FaultInfo { FaultName = workUnit.unitName + " - 未连通", FaultDate = DateTime.Now, FaultType = FaultType.Warning });
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -467,52 +466,58 @@ namespace SamplePreSystem.UI.ViewModel.Monitor
|
||||
return "未连接";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
#region 处理故障信息
|
||||
|
||||
/// <summary>
|
||||
/// 更新sop执行信息
|
||||
/// 故障信息
|
||||
/// </summary>
|
||||
/// <param name="receiveData"></param>
|
||||
public void UpdateSopExecInfo(string receiveData)
|
||||
private ObservableCollection<FaultInfo> faultInfos = new ObservableCollection<FaultInfo>();
|
||||
|
||||
public ObservableCollection<FaultInfo> FaultInfos
|
||||
{
|
||||
SopExecData += receiveData + "\r\n";
|
||||
get { return faultInfos; }
|
||||
set
|
||||
{
|
||||
|
||||
SetProperty(ref faultInfos, value);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// sop执行信息
|
||||
/// </summary>
|
||||
private List<SopExecInfo> sopExecInfo = new List<SopExecInfo>();
|
||||
|
||||
public List<SopExecInfo> SopExecInfo
|
||||
public void ErrInfoDo()
|
||||
{
|
||||
get { return sopExecInfo; }
|
||||
set { sopExecInfo = value; }
|
||||
Task.Run(() => {
|
||||
|
||||
while (true)
|
||||
{
|
||||
var errInfo = this.errQueue.GetOne();
|
||||
if(errInfo != null)
|
||||
{
|
||||
Application.Current?.Dispatcher.Invoke(() =>
|
||||
{
|
||||
FaultInfos.Add(errInfo);
|
||||
});
|
||||
}
|
||||
|
||||
Task.Delay(1000).Wait();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 打开详情窗口
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user