You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AUCMA_SCADA/Aucma.Core.DoorFoam/ViewModels/FoamMachinesPageViewModel.cs

676 lines
21 KiB
C#

using Admin.Core.Common;
using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Model.ViewModels;
using Admin.Core.Service;
using Admin.Core.Tasks;
using Aucma.Core.DoorFoam.Business;
using Aucma.Core.DoorFoam.Models;
using CommunityToolkit.Mvvm.ComponentModel;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Aucma.Core.DoorFoam.ViewModels
{
public partial class FoamMachinesPageViewModel : ObservableObject
{
IBoxLastShotRecordServices _boxLastShotRecordServices;
public FoamMachinesPageViewModel()
{
CollectionFoamMachine.RefreshLastShotDataDelegateEvent += RefreshData;
CollectionFoamMachine.RefreshGunDataDelegateEvent += RefreshGunData;
CollectionFoamMachine.RefreshSystemDataDelegateEvent += RefreshSystemData;
_boxLastShotRecordServices = App.ServiceProvider.GetService<IBoxLastShotRecordServices>();
LoadData();
//Task.WaitAll(LoadData());
}
#region 刷新系统参数---系统1系统2
/// <summary>
/// 系统1系统2数据刷新
/// </summary>
public void RefreshSystemData(Dictionary<string, FoamMachinesModel> keys)
{
foreach (KeyValuePair<string, FoamMachinesModel> kvp in keys)
{
if (kvp.Key.Equals("1"))
{
RefreshSystem1(kvp.Value);
}
else if (kvp.Key.Equals("2"))
{
RefreshSystem2(kvp.Value);
}
}
}
/// <summary>
/// 刷新系统1
/// </summary>
/// <param name="record"></param>
public void RefreshSystem1(FoamMachinesModel record)
{
PolInputPressure1 = record.POL_LP;
IsoInputPressure1 = record.ISO_LP;
PolOutputPressure1 = record.POL_HP;
IsoOutputPressure1 = record.ISO_HP;
PolFlow1 = record.POL_Vol;
IsoFlow1 = record.ISO_Vol;
PoleTmperature1 = record.POL_Temp;
IsoTemperature1 = record.ISO_Temp;
PolMaterialLevel1 = record.POL_Level;
IsoMaterialLevel1 = record.ISO_Level;
Pressure1 = record.Hydr_Press;
Temperature1 = record.Hydr_Temp;
}
/// <summary>
/// 刷新系统2
/// </summary>
/// <param name="record"></param>
public void RefreshSystem2(FoamMachinesModel record)
{
PolInputPressure2 = record.POL_LP;
IsoInputPressure2 = record.ISO_LP;
PolOutputPressure2 = record.POL_HP;
IsoOutputPressure2 = record.ISO_HP;
PolFlow2 = record.POL_Vol;
IsoFlow2 = record.ISO_Vol;
PoleTmperature2 = record.POL_Temp;
IsoTemperature2 = record.ISO_Temp;
PolMaterialLevel2 = record.POL_Level;
IsoMaterialLevel2 = record.ISO_Level;
Pressure2 = record.Hydr_Press;
Temperature2 = record.Hydr_Temp;
}
#endregion
#region 刷新每一枪数据
/// <summary>
/// A1,B1,A2,B2枪数据刷新
/// </summary>
public void RefreshGunData(Dictionary<string, BoxLastShotRecord> keys)
{
foreach (KeyValuePair<string, BoxLastShotRecord> kvp in keys)
{
if (kvp.Key.Equals("A1"))
{
RefreshA1(kvp.Value);
}
else if (kvp.Key.Equals("B1"))
{
RefreshB1(kvp.Value);
}
else if (kvp.Key.Equals("A2"))
{
RefreshA2(kvp.Value);
}
else if (kvp.Key.Equals("B2"))
{
RefreshB2(kvp.Value);
}
}
}
/// <summary>
/// 刷新A1数据
/// </summary>
/// <param name="record"></param>
public void RefreshA1(BoxLastShotRecord record)
{
POLPressure1a = record.PolHp;
POLTemperature1a = record.PolTemp;
ISOPressure1a = record.IsoHp;
ISOTemperature1a = record.IsoTemp;
}
/// <summary>
/// 刷新B1数据
/// </summary>
/// <param name="record"></param>
public void RefreshB1(BoxLastShotRecord record)
{
POLPressure1b = record.PolHp;
POLTemperature1b = record.PolTemp;
ISOPressure1b = record.IsoHp;
ISOTemperature1b = record.IsoTemp;
}
/// <summary>
/// 刷新A2数据
/// </summary>
/// <param name="record"></param>
public void RefreshA2(BoxLastShotRecord record)
{
POLPressure2a = record.PolHp;
POLTemperature2a = record.PolTemp;
ISOPressure2a = record.IsoHp;
ISOTemperature2a = record.IsoTemp;
}
/// <summary>
/// 刷新B2数据
/// </summary>
/// <param name="record"></param>
public void RefreshB2(BoxLastShotRecord record)
{
POLPressure2b = record.PolHp;
POLTemperature2b = record.PolTemp;
ISOPressure2b = record.IsoHp;
ISOTemperature2b = record.IsoTemp;
}
#endregion
/// <summary>
/// datagrid刷新
/// </summary>
/// <param name="record"></param>
public void RefreshData(BoxLastShotRecord record)
{
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
{
string system = string.Empty;
if (record.System == "1")
{
system = "1系统";
// PolFlow1 = record.POLInjecFlowRate;
// IsoFlow1 = record.ISOInjecFlowRate;
// PoleTmperature1 = record.POLInjecTemperatureOfGunHead;
// IsoTemperature1 = record.ISOInjecTemperatureOfGunHead;
}
if (record.System == "2") { system = "2系统"; }
LastShotRecordModel model = new LastShotRecordModel();
model.No = LastShotRecordDataGrid.Count + 1;
model.System = system;
model.GunHead = record.GunCode;
// StationNumber = record.StationNumber,
model.IsoInjectionpressure = record.PolHp;
model.IsoInjectionpressure = record.IsoHp;
model.PolInjectiontemperature = record.PolTemp;
model.IsoInjectiontemperature = record.IsoTemp;
model.PolInjectionpressure = record.PolHp;
model.StationNumber = record.PourNu;
model.LastTime = record.CreateTime;
model.Createtime = record.CreateTime;
LastShotRecordDataGrid.Insert(0, model);
}));
}
#region 加载DataGrid数据
private async Task LoadData()
{
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
{
LastShotRecordDataGrid.Clear();
int i = 1;
var list = await _boxLastShotRecordServices.QueryAsync();
if (list == null) return;
list.OrderByDescending(d => d.CreateTime).Take(30);
foreach (var item in list)
{
string system = string.Empty;
if (item.System == "1") { system = "1系统"; }
if (item.System == "2") { system = "2系统"; }
LastShotRecordModel model = new LastShotRecordModel();
if (LastShotRecordDataGrid.Count() == 0)
{
model.No = 1;
}
else
{
model.No = LastShotRecordDataGrid.Count() + 1;
}
model.No = i;
model.System = system;
model.GunHead = item.GunCode;
model.PolInjectionpressure = item.PolHp;
model.IsoInjectionpressure = item.IsoHp;
model.PolInjectiontemperature = item.PolTemp;
model.IsoInjectiontemperature = item.IsoTemp;
model.LastTime = item.CreateTime;
model.Createtime = item.CreateTime;
model.StationNumber = item.PourNu;
LastShotRecordDataGrid.Insert(0, model);
}
}));
}
#endregion
#region 初始化datagrid
private ObservableCollection<LastShotRecordModel> _lastShotRecordDataGrid = new ObservableCollection<LastShotRecordModel>();
public ObservableCollection<LastShotRecordModel> LastShotRecordDataGrid
{
get { return _lastShotRecordDataGrid; }
set
{
_lastShotRecordDataGrid = value;
OnPropertyChanged();//属性通知
}
}
#endregion
#region 1系统属性
/// <summary>
/// POL输入压力
/// </summary>
private string _PolInputPressure = "0.00";
public string PolInputPressure1
{
get => _PolInputPressure;
set => SetProperty(ref _PolInputPressure, value);
}
/// <summary>
/// ISO输入压力
/// </summary>
private string _IsoInputPressure = "0.00";
public string IsoInputPressure1
{
get => _IsoInputPressure;
set => SetProperty(ref _IsoInputPressure, value);
}
/// <summary>
/// POL输出压力
/// </summary>
private string _polOutputPressure = "0.0";
public string PolOutputPressure1
{
get => _polOutputPressure;
set => SetProperty(ref _polOutputPressure, value);
}
/// <summary>
/// ISO输出压力
/// </summary>
private string _isoOutputPressure1 = "0.0";
public string IsoOutputPressure1
{
get => _isoOutputPressure1;
set => SetProperty(ref _isoOutputPressure1, value);
}
/// <summary>
/// Pol流量
/// </summary>
private string _Polflow1 = "0";
public string PolFlow1
{
get => _Polflow1;
set => SetProperty(ref _Polflow1, value);
}
/// <summary>
/// Iso流量
/// </summary>
private string _isoflow1 = "0";
public string IsoFlow1
{
get => _isoflow1;
set => SetProperty(ref _isoflow1, value);
}
/// <summary>
/// Pol温度
/// </summary>
private string _PoleTmperature = "0";
public string PoleTmperature1
{
get => _PoleTmperature;
set => SetProperty(ref _PoleTmperature, value);
}
/// <summary>
/// Iso温度
/// </summary>
private string _isoTemperature = "0";
public string IsoTemperature1
{
get => _isoTemperature;
set => SetProperty(ref _isoTemperature, value);
}
/// <summary>
/// 料位
/// </summary>
private string _PolMaterialLevel1 = "0";
public string PolMaterialLevel1
{
get => _PolMaterialLevel1;
set => SetProperty(ref _PolMaterialLevel1, value);
}
/// <summary>
/// Iso温度
/// </summary>
private string _IsoMaterialLevel1 = "0";
public string IsoMaterialLevel1
{
get => _IsoMaterialLevel1;
set => SetProperty(ref _IsoMaterialLevel1, value);
}
/// <summary>
/// 压力
/// </summary>
private string _pressure1 = "0.00";
public string Pressure1
{
get => _pressure1;
set => SetProperty(ref _pressure1, value);
}
/// <summary>
/// 温度
/// </summary>
private string _temperature1 = "0.00";
public string Temperature1
{
get => _temperature1;
set => SetProperty(ref _temperature1, value);
}
/// <summary>
/// A枪状态
/// </summary>
//private string _status1a;
//public string Status1a
//{
// get => _status1a;
// set => SetProperty(ref _status1a, value);
//}
/// <summary>
/// pol压力
/// </summary>
private string _POLPressure1a = "0.00";
public string POLPressure1a
{
get => _POLPressure1a;
set => SetProperty(ref _POLPressure1a, value);
}
/// <summary>
/// A枪POL温度
/// </summary>
private string _POLTemperature1a = "0.00";
public string POLTemperature1a
{
get => _POLTemperature1a;
set => SetProperty(ref _POLTemperature1a, value);
}
/// <summary>
/// iso压力
/// </summary>
private string _ISOPressure1a = "0.00";
public string ISOPressure1a
{
get => _ISOPressure1a;
set => SetProperty(ref _ISOPressure1a, value);
}
/// <summary>
/// iso温度
/// </summary>
private string _ISOTemperature1a = "0.0";
public string ISOTemperature1a
{
get => _ISOTemperature1a;
set => SetProperty(ref _ISOTemperature1a, value);
}
/// <summary>
/// B枪状态
/// </summary>
//private string _status1b;
//public string Status1b
//{
// get => _status1b;
// set => SetProperty(ref _status1b, value);
//}
/// <summary>
/// B枪pol压力
/// </summary>
private string _POLPressure1b = "0.00";
public string POLPressure1b
{
get => _POLPressure1b;
set => SetProperty(ref _POLPressure1b, value);
}
/// <summary>
/// B枪POL温度
/// </summary>
private string _POLTemperature1b = "0.00";
public string POLTemperature1b
{
get => _POLTemperature1b;
set => SetProperty(ref _POLTemperature1b, value);
}
/// <summary>
/// B枪iso压力
/// </summary>
private string _ISOPressure1b = "0.00";
public string ISOPressure1b
{
get => _ISOPressure1b;
set => SetProperty(ref _ISOPressure1b, value);
}
/// <summary>
/// B枪iso温度
/// </summary>
private string _ISOTemperature1b = "0.0";
public string ISOTemperature1b
{
get => _ISOTemperature1b;
set => SetProperty(ref _ISOTemperature1b, value);
}
#endregion
#region 2系统属性
/// <summary>
/// POL输入压力
/// </summary>
private string _PolInputPressure2 = "0.00";
public string PolInputPressure2
{
get => _PolInputPressure2;
set => SetProperty(ref _PolInputPressure2, value);
}
/// <summary>
/// ISO输入压力
/// </summary>
private string _IsoInputPressure2 = "0.00";
public string IsoInputPressure2
{
get => _IsoInputPressure2;
set => SetProperty(ref _IsoInputPressure2, value);
}
/// <summary>
/// POL输出压力
/// </summary>
private string _polOutputPressure2 = "0.00";
public string PolOutputPressure2
{
get => _polOutputPressure2;
set => SetProperty(ref _polOutputPressure2, value);
}
/// <summary>
/// ISO输出压力
/// </summary>
private string _isoOutputPressure2 = "0.00";
public string IsoOutputPressure2
{
get => _isoOutputPressure2;
set => SetProperty(ref _isoOutputPressure2, value);
}
/// <summary>
/// Pol流量
/// </summary>
private string _Polflow2 = "0";
public string PolFlow2
{
get => _Polflow2;
set => SetProperty(ref _Polflow2, value);
}
/// <summary>
/// Iso流量
/// </summary>
private string _isoflow2 = "0";
public string IsoFlow2
{
get => _isoflow2;
set => SetProperty(ref _isoflow2, value);
}
/// <summary>
/// Pol温度
/// </summary>
private string _PoleTmperature2 = "0";
public string PoleTmperature2
{
get => _PoleTmperature2;
set => SetProperty(ref _PoleTmperature2, value);
}
/// <summary>
/// Iso温度
/// </summary>
private string _isoTemperature2 = "0";
public string IsoTemperature2
{
get => _isoTemperature2;
set => SetProperty(ref _isoTemperature2, value);
}
/// <summary>
/// 料位
/// </summary>
private string _PolMaterialLevel2 = "0";
public string PolMaterialLevel2
{
get => _PolMaterialLevel2;
set => SetProperty(ref _PolMaterialLevel2, value);
}
/// <summary>
/// Iso温度
/// </summary>
private string _IsoMaterialLevel2 = "0";
public string IsoMaterialLevel2
{
get => _IsoMaterialLevel2;
set => SetProperty(ref _IsoMaterialLevel2, value);
}
/// <summary>
/// 压力
/// </summary>
private string _pressure2 = "0.00";
public string Pressure2
{
get => _pressure2;
set => SetProperty(ref _pressure2, value);
}
/// <summary>
/// 温度
/// </summary>
private string _temperature2 = "0.00";
public string Temperature2
{
get => _temperature2;
set => SetProperty(ref _temperature2, value);
}
/// <summary>
/// A枪POL压力
/// </summary>
private string _POLPressure2a = "0.00";
public string POLPressure2a
{
get => _POLPressure2a;
set => SetProperty(ref _POLPressure2a, value);
}
/// <summary>
/// A枪POL温度
/// </summary>
private string _POLTemperature2a = "0.00";
public string POLTemperature2a
{
get => _POLTemperature2a;
set => SetProperty(ref _POLTemperature2a, value);
}
/// <summary>
/// iso压力
/// </summary>
private string _ISOPressure2a = "0.00";
public string ISOPressure2a
{
get => _ISOPressure2a;
set => SetProperty(ref _ISOPressure2a, value);
}
/// <summary>
/// iso温度
/// </summary>
private string _ISOTemperature2a = "0.0";
public string ISOTemperature2a
{
get => _ISOTemperature2a;
set => SetProperty(ref _ISOTemperature2a, value);
}
/// <summary>
/// B枪状态
/// </summary>
//private string _status2b;
//public string Status2b
//{
// get => _status2b;
// set => SetProperty(ref _status2b, value);
//}
/// <summary>
/// B枪pol压力
/// </summary>
private string _POLPressure2b = "0.00";
public string POLPressure2b
{
get => _POLPressure2b;
set => SetProperty(ref _POLPressure2b, value);
}
/// <summary>
/// B枪POL温度
/// </summary>
private string _POLTemperature2b = "0.00";
public string POLTemperature2b
{
get => _POLTemperature2b;
set => SetProperty(ref _POLTemperature2b, value);
}
/// <summary>
/// B枪iso压力
/// </summary>
private string _ISOPressure2b = "0.00";
public string ISOPressure2b
{
get => _ISOPressure2b;
set => SetProperty(ref _ISOPressure2b, value);
}
/// <summary>
/// B枪iso温度
/// </summary>
private string _ISOTemperature2b = "0.0";
public string ISOTemperature2b
{
get => _ISOTemperature2b;
set => SetProperty(ref _ISOTemperature2b, value);
}
#endregion
}
}