@@ -89,6 +89,8 @@ namespace BPASmartClient.Academy | |||||
Json<LocaMaterial>.Save(); | Json<LocaMaterial>.Save(); | ||||
BPASmartClient.CustomResource.Pages.Model.MessageNotify.GetInstance.LogSave(); | BPASmartClient.CustomResource.Pages.Model.MessageNotify.GetInstance.LogSave(); | ||||
TaskManage.GetInstance.Dispose(); | TaskManage.GetInstance.Dispose(); | ||||
App.Current.Shutdown(); | |||||
Environment.Exit(0); | |||||
//Process.GetCurrentProcess().Kill(); | //Process.GetCurrentProcess().Kill(); | ||||
} | } | ||||
@@ -176,10 +178,10 @@ namespace BPASmartClient.Academy | |||||
}); | }); | ||||
DeviceMonitor.Add(new SubMenumodel() | DeviceMonitor.Add(new SubMenumodel() | ||||
{ | { | ||||
SubMenuName = "设备", | |||||
SubMenuName = "数据曲线", | |||||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | ||||
AssemblyName = "BPASmartClient.Academy", | AssemblyName = "BPASmartClient.Academy", | ||||
ToggleWindowPath = "View.Device" | |||||
ToggleWindowPath = "View.DeviceChartView" | |||||
}); | }); | ||||
MenuManage.GetInstance.menuModels.Add(new MenuModel() | MenuManage.GetInstance.menuModels.Add(new MenuModel() | ||||
{ | { | ||||
@@ -2,10 +2,11 @@ | |||||
<PropertyGroup> | <PropertyGroup> | ||||
<OutputType>WinExe</OutputType> | <OutputType>WinExe</OutputType> | ||||
<TargetFramework>net6.0-windows</TargetFramework> | |||||
<TargetFramework>net6.0-windows7.0</TargetFramework> | |||||
<Nullable>enable</Nullable> | <Nullable>enable</Nullable> | ||||
<ImplicitUsings>enable</ImplicitUsings> | <ImplicitUsings>enable</ImplicitUsings> | ||||
<UseWPF>true</UseWPF> | <UseWPF>true</UseWPF> | ||||
<ApplicationIcon>hbl.ico</ApplicationIcon> | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -18,7 +18,7 @@ namespace BPASmartClient.Academy.Model | |||||
set { _id = value;OnPropertyChanged(); } | set { _id = value;OnPropertyChanged(); } | ||||
} | } | ||||
private string _name; | |||||
private string _name=""; | |||||
public string Name | public string Name | ||||
{ | { | ||||
@@ -48,5 +48,13 @@ namespace BPASmartClient.Academy.Model | |||||
get { return _pipeH_3; } | get { return _pipeH_3; } | ||||
set { _pipeH_3 = value; OnPropertyChanged(); } | set { _pipeH_3 = value; OnPropertyChanged(); } | ||||
} | } | ||||
private PipeLineStatus _pipeH_4 = new PipeLineStatus(); | |||||
public PipeLineStatus PipeH_4 | |||||
{ | |||||
get { return _pipeH_4; } | |||||
set { _pipeH_4 = value; OnPropertyChanged(); } | |||||
} | |||||
} | } | ||||
} | } |
@@ -9,45 +9,45 @@ namespace BPASmartClient.Academy.Model | |||||
{ | { | ||||
public class SaveData:NotifyBase | public class SaveData:NotifyBase | ||||
{ | { | ||||
public string Id { get; set; } | |||||
public string Id { get; set; } = ""; | |||||
public string Name { get; set; } | public string Name { get; set; } | ||||
public DateTime Date { get; set; } | public DateTime Date { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// M101 速度曲线 | /// M101 速度曲线 | ||||
/// </summary> | /// </summary> | ||||
public double M101_Speed { get; set; } | |||||
public int M101_Speed { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// M102 速度曲线 | /// M102 速度曲线 | ||||
/// </summary> | /// </summary> | ||||
public double M102_Speed { get; set; } | |||||
/// <summary> | |||||
/// M102 速度曲线 | |||||
/// </summary> | |||||
public double M103_Speed { get; set; } | |||||
public int M102_Speed { get; set; } | |||||
///// <summary> | |||||
///// M102 速度曲线 | |||||
///// </summary> | |||||
//public int M103_Speed { get; set; } | |||||
/// <summary> | |||||
/// 比例阀开度曲线 | |||||
/// </summary> | |||||
public double OpenValve { get; set; } | |||||
///// <summary> | |||||
///// 比例阀开度曲线 | |||||
///// </summary> | |||||
//public double OpenValve { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 反应釜温度 | /// 反应釜温度 | ||||
/// </summary> | /// </summary> | ||||
public double TempWok { get; set; } | |||||
public int TempWok { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 配料罐温度 | /// 配料罐温度 | ||||
/// </summary> | /// </summary> | ||||
public double TempMaterial { get; set; } | |||||
public int TempMaterial { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 反应釜排气温度 | /// 反应釜排气温度 | ||||
/// </summary> | /// </summary> | ||||
public double TempVent { get; set; } | |||||
/// <summary> | |||||
/// 反应釜压力 | |||||
/// </summary> | |||||
public double PressureWok { get; set; } | |||||
public int TempVent { get; set; } | |||||
///// <summary> | |||||
///// 反应釜压力 | |||||
///// </summary> | |||||
//public double PressureWok { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 反应釜重量 | /// 反应釜重量 | ||||
/// </summary> | /// </summary> | ||||
public double WeightWok { get; set; } | |||||
public float WeightWok { get; set; } | |||||
} | } | ||||
} | } |
@@ -13,6 +13,8 @@ using System.Data; | |||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using static Org.BouncyCastle.Asn1.Cmp.Challenge; | |||||
using Org.BouncyCastle.Asn1.Crmf; | |||||
namespace BPASmartClient.Academy.Model | namespace BPASmartClient.Academy.Model | ||||
{ | { | ||||
@@ -26,6 +28,7 @@ namespace BPASmartClient.Academy.Model | |||||
//public SiemensHelper siemens { get; set; } = new SiemensHelper(); | //public SiemensHelper siemens { get; set; } = new SiemensHelper(); | ||||
public ICommSiemens siemens; | public ICommSiemens siemens; | ||||
public DeviceCtrl deviceCtrl { get; set; } = new DeviceCtrl(); | public DeviceCtrl deviceCtrl { get; set; } = new DeviceCtrl(); | ||||
public Action<bool> connect { get; set; } | |||||
public ConcurrentDictionary<string,string> AlarmInfo { get; set; }= new ConcurrentDictionary<string, string>(); | public ConcurrentDictionary<string,string> AlarmInfo { get; set; }= new ConcurrentDictionary<string, string>(); | ||||
public bool IsConnected { get; set; } = false; | public bool IsConnected { get; set; } = false; | ||||
bool heart = false; | bool heart = false; | ||||
@@ -42,6 +45,10 @@ namespace BPASmartClient.Academy.Model | |||||
{ | { | ||||
siemens = o.Content; | siemens = o.Content; | ||||
IsConnected = true; | IsConnected = true; | ||||
connect?.Invoke(true); | |||||
}).OnFailure(o => | |||||
{ | |||||
IsConnected = false; | |||||
}); | }); | ||||
} | } | ||||
}); | }); | ||||
@@ -56,11 +63,16 @@ namespace BPASmartClient.Academy.Model | |||||
ThreadManage.GetInstance.StartLong(() => | ThreadManage.GetInstance.StartLong(() => | ||||
{ | { | ||||
Heartbeat(); | Heartbeat(); | ||||
connect?.Invoke(IsConnected); | |||||
}, "心跳监听"); | }, "心跳监听"); | ||||
ThreadManage.GetInstance.StartLong(() => | ThreadManage.GetInstance.StartLong(() => | ||||
{ | { | ||||
ChartDataRead(); | ChartDataRead(); | ||||
}, "曲线数据"); | }, "曲线数据"); | ||||
ThreadManage.GetInstance.StartLong(() => | |||||
{ | |||||
AlarmRead(); | |||||
}, "报警监控"); | |||||
} | } | ||||
public void AlarmInfoGet() | public void AlarmInfoGet() | ||||
{ | { | ||||
@@ -85,6 +97,10 @@ namespace BPASmartClient.Academy.Model | |||||
{ | { | ||||
siemens.Read<bool>(o).OnSuccess(p => | siemens.Read<bool>(o).OnSuccess(p => | ||||
{ | { | ||||
if (o== "DB1.DBX2004.4"&&p.Content) | |||||
{ | |||||
IsConnected = false; | |||||
} | |||||
if (p.Content) | if (p.Content) | ||||
{ | { | ||||
App.Current.Dispatcher.Invoke(() => | App.Current.Dispatcher.Invoke(() => | ||||
@@ -96,7 +112,7 @@ namespace BPASmartClient.Academy.Model | |||||
}); | }); | ||||
} | } | ||||
Thread.Sleep(2000); | |||||
} | } | ||||
public void ReadStatus() | public void ReadStatus() | ||||
{ | { | ||||
@@ -189,109 +205,126 @@ namespace BPASmartClient.Academy.Model | |||||
} | } | ||||
public void PipeDetect() | public void PipeDetect() | ||||
{ | { | ||||
//阀门3-4连接 | |||||
if (deviceCtrl.VX102||deviceCtrl.VX103) | if (deviceCtrl.VX102||deviceCtrl.VX103) | ||||
{ | { | ||||
DeviceMotionViewModel.PipeLine.PipeH_1.Fill = true; | DeviceMotionViewModel.PipeLine.PipeH_1.Fill = true; | ||||
DeviceMotionViewModel.PipeLine.PipeH_1.Direction = 1; | |||||
DeviceMotionViewModel.PipeLine.PipeH_1.Direction = 2; | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
DeviceMotionViewModel.PipeLine.PipeH_1.Fill = false; | DeviceMotionViewModel.PipeLine.PipeH_1.Fill = false; | ||||
DeviceMotionViewModel.PipeLine.PipeH_1.Direction = 0; | DeviceMotionViewModel.PipeLine.PipeH_1.Direction = 0; | ||||
} | } | ||||
if (deviceCtrl.VX107||deviceCtrl.VX110) | |||||
{ | |||||
DeviceMotionViewModel.PipeLine.PipeH_2.Fill = true; | |||||
DeviceMotionViewModel.PipeLine.PipeH_2.Direction = 1; | |||||
} | |||||
else | |||||
//阀门10-11连接 | |||||
if (!deviceCtrl.VX110 && !deviceCtrl.VX109) | |||||
{ | { | ||||
DeviceMotionViewModel.PipeLine.PipeH_2.Fill = false; | DeviceMotionViewModel.PipeLine.PipeH_2.Fill = false; | ||||
DeviceMotionViewModel.PipeLine.PipeH_2.Direction = 0; | DeviceMotionViewModel.PipeLine.PipeH_2.Direction = 0; | ||||
} | } | ||||
if (deviceCtrl.VX108||deviceCtrl.VX109) | |||||
else | |||||
{ | { | ||||
DeviceMotionViewModel.PipeLine.PipeH_3.Fill = true; | |||||
DeviceMotionViewModel.PipeLine.PipeH_3.Direction = 1; | |||||
if (deviceCtrl.VX109) | |||||
{ | |||||
DeviceMotionViewModel.PipeLine.PipeH_2.Fill = true; | |||||
DeviceMotionViewModel.PipeLine.PipeH_2.Direction = 1; | |||||
} | |||||
if (deviceCtrl.VX110) | |||||
{ | |||||
DeviceMotionViewModel.PipeLine.PipeH_2.Fill = true; | |||||
DeviceMotionViewModel.PipeLine.PipeH_2.Direction = 2; | |||||
} | |||||
} | } | ||||
else | |||||
//阀门9-12连接 | |||||
if (!deviceCtrl.VX108 && !deviceCtrl.VX111) | |||||
{ | { | ||||
DeviceMotionViewModel.PipeLine.PipeH_3.Fill = false; | DeviceMotionViewModel.PipeLine.PipeH_3.Fill = false; | ||||
DeviceMotionViewModel.PipeLine.PipeH_3.Direction = 0; | DeviceMotionViewModel.PipeLine.PipeH_3.Direction = 0; | ||||
} | } | ||||
else | |||||
{ | |||||
if (deviceCtrl.VX108) | |||||
{ | |||||
DeviceMotionViewModel.PipeLine.PipeH_3.Fill = true; | |||||
DeviceMotionViewModel.PipeLine.PipeH_3.Direction = 1; | |||||
} | |||||
if (deviceCtrl.VX111) | |||||
{ | |||||
DeviceMotionViewModel.PipeLine.PipeH_3.Fill = true; | |||||
DeviceMotionViewModel.PipeLine.PipeH_3.Direction = 2; | |||||
} | |||||
} | |||||
//阀门13-14连接 | |||||
if (deviceCtrl.VX112 || deviceCtrl.VX113) | |||||
{ | |||||
DeviceMotionViewModel.PipeLine.PipeH_4.Fill = true; | |||||
DeviceMotionViewModel.PipeLine.PipeH_4.Direction = 1; | |||||
} | |||||
else | |||||
{ | |||||
DeviceMotionViewModel.PipeLine.PipeH_4.Fill = false; | |||||
DeviceMotionViewModel.PipeLine.PipeH_4.Direction = 0; | |||||
} | |||||
} | } | ||||
public void ChartDataRead() | public void ChartDataRead() | ||||
{ | { | ||||
if (siemens!=null) | |||||
//DateTime date = DateTime.Now; | |||||
//Random random = new Random(); | |||||
//SaveData saveData = new SaveData() | |||||
//{ | |||||
// Id = id, | |||||
// Name = dataFeedback.Name, | |||||
// Date = DateTime.Now, | |||||
// M101_Speed = random.Next(0, 2000), | |||||
// M102_Speed = random.Next(0, 2000), | |||||
// M103_Speed = random.Next(0, 2000), | |||||
// OpenValve = random.Next(0, 5), | |||||
// TempWok = random.Next(-10, 150), | |||||
// TempMaterial = random.Next(-10, 150), | |||||
// TempVent = random.Next(-10, 150), | |||||
// PressureWok = random.NextDouble(), | |||||
// WeightWok = random.Next(0, 50), | |||||
//}; | |||||
//Sqlite.GetInstance.AddData(saveData); | |||||
//DataView(dataFeedback.M101_Speed, new DataValue() { DateTime = date, Value = saveData.M101_Speed }); | |||||
//DataView(dataFeedback.M102_Speed, new DataValue() { DateTime = date, Value = saveData.M102_Speed }); | |||||
//DataView(dataFeedback.M103_Speed, new DataValue() { DateTime = date, Value = saveData.M103_Speed }); | |||||
//DataView(dataFeedback.TempWok, new DataValue() { DateTime = date, Value = saveData.TempWok }); | |||||
//DataView(dataFeedback.TempMaterial, new DataValue() { DateTime = date, Value = saveData.TempMaterial }); | |||||
//DataView(dataFeedback.TempVent, new DataValue() { DateTime = date, Value = saveData.TempVent }); | |||||
//DataView(dataFeedback.OpenValve, new DataValue() { DateTime = date, Value = saveData.OpenValve }); | |||||
//DataView(dataFeedback.PressureWok, new DataValue() { DateTime = date, Value = saveData.PressureWok }); | |||||
//DataView(dataFeedback.WeightWok, new DataValue() { DateTime = date, Value = saveData.WeightWok }); | |||||
if (siemens != null && id != "") | |||||
{ | { | ||||
SaveData saveData = new SaveData() | SaveData saveData = new SaveData() | ||||
{ | { | ||||
Id = id, | |||||
Id = Simens_PLC.GetInstance.id, | |||||
Name = dataFeedback.Name, | Name = dataFeedback.Name, | ||||
Date = DateTime.Now, | Date = DateTime.Now, | ||||
M101_Speed = siemens.Read<double>("DB1.DBD2006").Content, | |||||
M102_Speed = siemens.Read<double>("DB1.DBD2010").Content, | |||||
M103_Speed = siemens.Read<double>("DB1.DBD2014").Content, | |||||
OpenValve = siemens.Read<double>("DB1.DBD2018").Content, | |||||
TempWok = siemens.Read<double>("DB1.DBD2022").Content, | |||||
TempMaterial = siemens.Read<double>("DB1.DBD2026").Content, | |||||
TempVent = siemens.Read<double>("DB1.DBD2030").Content, | |||||
PressureWok = siemens.Read<double>("DB1.DBD2034").Content, | |||||
WeightWok = siemens.Read<double>("DB1.DBD2038").Content, | |||||
M101_Speed = siemens.Read<int>("DB1.DBD2006").Content, | |||||
M102_Speed = siemens.Read<int>("DB1.DBD2010").Content, | |||||
TempWok = siemens.Read<int>("DB1.DBD2022").Content, | |||||
TempMaterial = siemens.Read<int>("DB1.DBD2026").Content, | |||||
TempVent = siemens.Read<int>("DB1.DBD2030").Content, | |||||
WeightWok = siemens.Read<float>("DB1.DBD2018").Content, | |||||
}; | }; | ||||
if (id != "") | |||||
{ | |||||
DataView(dataFeedback.M101_Speed, new DataValue() { DateTime = saveData.Date, Value = saveData.M101_Speed }); | |||||
DataView(dataFeedback.M102_Speed, new DataValue() { DateTime = saveData.Date, Value = saveData.M102_Speed }); | |||||
DataView(dataFeedback.M103_Speed, new DataValue() { DateTime = saveData.Date, Value = saveData.M103_Speed }); | |||||
DataView(dataFeedback.OpenValve, new DataValue() { DateTime = saveData.Date, Value = saveData.OpenValve }); | |||||
DataView(dataFeedback.TempWok, new DataValue() { DateTime = saveData.Date, Value = saveData.TempWok }); | |||||
DataView(dataFeedback.TempMaterial, new DataValue() { DateTime = saveData.Date, Value = saveData.TempMaterial }); | |||||
DataView(dataFeedback.TempVent, new DataValue() { DateTime = saveData.Date, Value = saveData.TempVent }); | |||||
DataView(dataFeedback.PressureWok, new DataValue() { DateTime = saveData.Date, Value = saveData.PressureWok }); | |||||
DataView(dataFeedback.WeightWok, new DataValue() { DateTime = saveData.Date, Value = saveData.WeightWok }); | |||||
} | |||||
else | |||||
{ | |||||
//DateTime date = DateTime.Now; | |||||
//Random random = new Random(); | |||||
//SaveData saveData = new SaveData() | |||||
//{ | |||||
// Id = id, | |||||
// Name = dataFeedback.Name, | |||||
// Date = DateTime.Now, | |||||
// M101_Speed = random.Next(0, 2000), | |||||
// M102_Speed = random.Next(0, 2000), | |||||
// M103_Speed = random.Next(0, 2000), | |||||
// OpenValve = random.Next(0, 5), | |||||
// TempWok = random.Next(-10, 150), | |||||
// TempMaterial = random.Next(-10, 150), | |||||
// TempVent = random.Next(-10, 150), | |||||
// PressureWok = random.NextDouble(), | |||||
// WeightWok = random.Next(0, 50), | |||||
//}; | |||||
//Sqlite.GetInstance.saveDatas.Add(saveData); | |||||
//DataView(dataFeedback.M101_Speed, new DataValue() { DateTime = date, Value = saveData.M101_Speed }); | |||||
//DataView(dataFeedback.M102_Speed, new DataValue() { DateTime = date, Value = saveData.M102_Speed }); | |||||
//DataView(dataFeedback.M103_Speed, new DataValue() { DateTime = date, Value = saveData.M103_Speed }); | |||||
//DataView(dataFeedback.TempWok, new DataValue() { DateTime = date, Value = saveData.TempWok }); | |||||
//DataView(dataFeedback.TempMaterial, new DataValue() { DateTime = date, Value = saveData.TempMaterial }); | |||||
//DataView(dataFeedback.TempVent, new DataValue() { DateTime = date, Value = saveData.TempVent }); | |||||
//DataView(dataFeedback.OpenValve, new DataValue() { DateTime = date, Value = saveData.OpenValve }); | |||||
//DataView(dataFeedback.PressureWok, new DataValue() { DateTime = date, Value = saveData.PressureWok }); | |||||
//DataView(dataFeedback.WeightWok, new DataValue() { DateTime = date, Value = saveData.WeightWok }); | |||||
} | |||||
Sqlite.GetInstance.AddData(saveData); | |||||
DataView(dataFeedback.M101_Speed, new DataValue() { DateTime = saveData.Date, Value = saveData.M101_Speed }); | |||||
DataView(dataFeedback.M102_Speed, new DataValue() { DateTime = saveData.Date, Value = saveData.M102_Speed }); | |||||
DataView(dataFeedback.TempWok, new DataValue() { DateTime = saveData.Date, Value = saveData.TempWok }); | |||||
DataView(dataFeedback.TempMaterial, new DataValue() { DateTime = saveData.Date, Value = saveData.TempMaterial }); | |||||
DataView(dataFeedback.TempVent, new DataValue() { DateTime = saveData.Date, Value = saveData.TempVent }); | |||||
DataView(dataFeedback.WeightWok, new DataValue() { DateTime = saveData.Date, Value = saveData.WeightWok }); | |||||
} | } | ||||
Thread.Sleep(1000); | Thread.Sleep(1000); | ||||
} | } | ||||
public void DataView<T>(ChartValues<T> values, T value) | public void DataView<T>(ChartValues<T> values, T value) | ||||
{ | { | ||||
if (values.Count >= 100) | |||||
if (values.Count >= 20) | |||||
{ | { | ||||
values.RemoveAt(0); | values.RemoveAt(0); | ||||
values.Add(value); | values.Add(value); | ||||
@@ -303,76 +336,18 @@ namespace BPASmartClient.Academy.Model | |||||
} | } | ||||
public void Heartbeat() | public void Heartbeat() | ||||
{ | { | ||||
if (IsConnected) | |||||
if (!heart && siemens != null) | |||||
{ | { | ||||
GetInstance.Connect(); | |||||
} | |||||
if (!heart&&siemens!=null) | |||||
{ | |||||
siemens.Write<bool>("DB1.DBX1003.7", true).OnFailure(o => | |||||
siemens.Write<bool>("DB1.DBX1003.7", true).OnFailure(o => | |||||
{ | { | ||||
IsConnected = false; | IsConnected = false; | ||||
}).OnSuccess(o => | |||||
GetInstance.Connect(); | |||||
}).OnSuccess(o => | |||||
{ | { | ||||
IsConnected=true; | |||||
IsConnected = true; | |||||
}); | }); | ||||
} | } | ||||
//if (deviceCtrl.M101) | |||||
//{ | |||||
// deviceCtrl.M101 = false; | |||||
//} | |||||
//else | |||||
//{ | |||||
// deviceCtrl.M101 = true; | |||||
//} | |||||
//if (deviceCtrl.VX100) | |||||
//{ | |||||
// deviceCtrl.VX100 = false; | |||||
//} | |||||
//else | |||||
//{ | |||||
// deviceCtrl.VX100 = true; | |||||
//} | |||||
//if (deviceCtrl.M102) | |||||
//{ | |||||
// deviceCtrl.M102 = false; | |||||
//} | |||||
//else | |||||
//{ | |||||
// deviceCtrl.M102 = true; | |||||
//} | |||||
//if (deviceCtrl.VX101) | |||||
//{ | |||||
// deviceCtrl.VX101 = false; | |||||
//} | |||||
//else | |||||
//{ | |||||
// deviceCtrl.VX101 = true; | |||||
//} | |||||
//if (deviceCtrl.VX102) | |||||
//{ | |||||
// deviceCtrl.VX102= false; | |||||
// deviceCtrl.VX104 = false; | |||||
// deviceCtrl.VX105 = false; | |||||
// deviceCtrl.VX106 = false; | |||||
// deviceCtrl.VX109 = false; | |||||
//} | |||||
//else | |||||
//{ | |||||
// deviceCtrl.VX102 = true; | |||||
// deviceCtrl.VX104 = true; | |||||
// deviceCtrl.VX105 = true; | |||||
// deviceCtrl.VX106 = true; | |||||
// deviceCtrl.VX109 = true; | |||||
//} | |||||
//PipeDetect(); | |||||
Thread.Sleep(3000); | Thread.Sleep(3000); | ||||
} | } | ||||
@@ -14,7 +14,7 @@ namespace BPASmartClient.Academy.Model | |||||
public static Sqlite GetInstance { get; set; } = instance ??= new Sqlite(); | public static Sqlite GetInstance { get; set; } = instance ??= new Sqlite(); | ||||
private Sqlite() { } | private Sqlite() { } | ||||
public List<SaveData> saveDatas { get; set; } = new List<SaveData>(); | public List<SaveData> saveDatas { get; set; } = new List<SaveData>(); | ||||
static string path | |||||
static string path | |||||
{ | { | ||||
get | get | ||||
{ | { | ||||
@@ -22,12 +22,12 @@ namespace BPASmartClient.Academy.Model | |||||
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AccessFile\\DB\\data.db"); | return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AccessFile\\DB\\data.db"); | ||||
} | } | ||||
} | } | ||||
public SqlSugarScope Db = new SqlSugarScope(new ConnectionConfig() | |||||
public SqlSugarScope Db = new SqlSugarScope(new ConnectionConfig() | |||||
{ | { | ||||
ConnectionString = $"Data Source = {path}", | ConnectionString = $"Data Source = {path}", | ||||
DbType = DbType.Sqlite, | DbType = DbType.Sqlite, | ||||
IsAutoCloseConnection = true, | IsAutoCloseConnection = true, | ||||
}); | }); | ||||
public void Init() | public void Init() | ||||
@@ -50,7 +50,7 @@ namespace BPASmartClient.Academy.Model | |||||
throw; | throw; | ||||
} | } | ||||
} | } | ||||
public bool AddData(SaveData dfb) | |||||
public bool AddData(SaveData dfb) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
@@ -61,6 +61,17 @@ namespace BPASmartClient.Academy.Model | |||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
public List<SaveData> SelectId(string id) | |||||
{ | |||||
try | |||||
{ | |||||
return Db.Queryable<SaveData>().Where(o => o.Id == id).ToList(); | |||||
} | |||||
catch (Exception) | |||||
{ | |||||
return null; | |||||
} | |||||
} | |||||
public List<String> SelectAllName() | public List<String> SelectAllName() | ||||
{ | { | ||||
return Db.Queryable<SaveData>() | return Db.Queryable<SaveData>() | ||||
@@ -0,0 +1,331 @@ | |||||
<UserControl | |||||
x:Class="BPASmartClient.Academy.View.DeviceChartView" | |||||
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:local="clr-namespace:BPASmartClient.Academy.View" | |||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:oxy="http://oxyplot.org/wpf" | |||||
xmlns:vm="clr-namespace:BPASmartClient.Academy.ViewModel" | |||||
d:DesignHeight="450" | |||||
d:DesignWidth="800" | |||||
mc:Ignorable="d"> | |||||
<UserControl.DataContext> | |||||
<vm:DeviceChartViewModel /> | |||||
</UserControl.DataContext> | |||||
<Grid> | |||||
<UniformGrid x:Name="ooo" | |||||
Grid.Row="1" | |||||
Rows="2" | |||||
Columns="2"> | |||||
<StackPanel Orientation="Vertical"> | |||||
<lvc:CartesianChart | |||||
x:Name="ppp" | |||||
Height="270" | |||||
HorizontalAlignment="Stretch" | |||||
VerticalAlignment="Top" | |||||
AnimationsSpeed="0:0:1" | |||||
DataTooltip="{x:Null}" | |||||
Hoverable="False" | |||||
MouseDoubleClick="DataView_CLick" | |||||
ToolTip="温度曲线"> | |||||
<lvc:CartesianChart.Series> | |||||
<lvc:LineSeries | |||||
Fill="Transparent" | |||||
LineSmoothness="1" | |||||
PointGeometry="{x:Null}" | |||||
Stroke="Red" | |||||
StrokeThickness="2" | |||||
Values="{Binding DataFeedback.TempWok}" /> | |||||
<lvc:LineSeries | |||||
Fill="Transparent" | |||||
LineSmoothness="1" | |||||
PointGeometry="{x:Null}" | |||||
Stroke="Blue" | |||||
StrokeThickness="2" | |||||
Values="{Binding DataFeedback.TempMaterial}" /> | |||||
<lvc:LineSeries | |||||
Fill="Transparent" | |||||
LineSmoothness="1" | |||||
PointGeometry="{x:Null}" | |||||
Stroke="Green" | |||||
StrokeThickness="2" | |||||
Values="{Binding DataFeedback.TempVent}" /> | |||||
</lvc:CartesianChart.Series> | |||||
<lvc:CartesianChart.AxisY> | |||||
<lvc:Axis > | |||||
<lvc:Axis.Separator> | |||||
<lvc:Separator IsEnabled="False" /> | |||||
</lvc:Axis.Separator> | |||||
</lvc:Axis> | |||||
</lvc:CartesianChart.AxisY> | |||||
<lvc:CartesianChart.AxisX> | |||||
<lvc:Axis | |||||
LabelFormatter="{Binding DateTimeFormatter}" | |||||
Unit="{Binding AxisUnit}"> | |||||
<lvc:Axis.Separator> | |||||
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" /> | |||||
</lvc:Axis.Separator> | |||||
</lvc:Axis> | |||||
</lvc:CartesianChart.AxisX> | |||||
</lvc:CartesianChart> | |||||
<StackPanel Margin="0,10,0,0" Orientation="Horizontal"> | |||||
<TextBlock Foreground="White" Text="温度曲线/℃" /> | |||||
<Rectangle | |||||
Width="20" | |||||
Height="2" | |||||
Margin="10,0,0,2" | |||||
Fill="Blue" /> | |||||
<TextBlock Foreground="White" Text="物料罐温度" /> | |||||
<Rectangle | |||||
Width="20" | |||||
Height="2" | |||||
Margin="10,0,0,2" | |||||
Fill="Red" /> | |||||
<TextBlock Foreground="White" Text="反应釜温度" /> | |||||
<Rectangle | |||||
Width="20" | |||||
Height="2" | |||||
Margin="10,0,0,2" | |||||
Fill="Green" /> | |||||
<TextBlock Foreground="White" Text="排气温度" /> | |||||
</StackPanel> | |||||
</StackPanel> | |||||
<StackPanel Margin="20,0,0,0" Orientation="Vertical"> | |||||
<lvc:CartesianChart | |||||
Height="270" | |||||
HorizontalAlignment="Stretch" | |||||
VerticalAlignment="Top" | |||||
AnimationsSpeed="0:0:1" | |||||
DataTooltip="{x:Null}" | |||||
Hoverable="False" | |||||
MouseDoubleClick="DataView_CLick" | |||||
ToolTip="转速曲线"> | |||||
<lvc:CartesianChart.Series> | |||||
<lvc:LineSeries | |||||
Fill="Transparent" | |||||
LineSmoothness="1" | |||||
PointGeometry="{x:Null}" | |||||
Stroke="#F44F15" | |||||
StrokeThickness="2" | |||||
Values="{Binding DataFeedback.M101_Speed}" /> | |||||
<lvc:LineSeries | |||||
Fill="Transparent" | |||||
LineSmoothness="1" | |||||
PointGeometry="{x:Null}" | |||||
Stroke="#423FFD" | |||||
StrokeThickness="2" | |||||
Values="{Binding DataFeedback.M102_Speed}" /> | |||||
</lvc:CartesianChart.Series> | |||||
<lvc:CartesianChart.AxisY> | |||||
<lvc:Axis> | |||||
<lvc:Axis.Separator> | |||||
<lvc:Separator IsEnabled="False" /> | |||||
</lvc:Axis.Separator> | |||||
</lvc:Axis> | |||||
</lvc:CartesianChart.AxisY> | |||||
<lvc:CartesianChart.AxisX> | |||||
<lvc:Axis | |||||
LabelFormatter="{Binding DateTimeFormatter}" | |||||
Unit="{Binding AxisUnit}"> | |||||
<lvc:Axis.Separator> | |||||
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" /> | |||||
</lvc:Axis.Separator> | |||||
</lvc:Axis> | |||||
</lvc:CartesianChart.AxisX> | |||||
</lvc:CartesianChart> | |||||
<StackPanel Margin="0,10,0,0" Orientation="Horizontal"> | |||||
<TextBlock Foreground="White" Text="转速曲线/rpm" /> | |||||
<Rectangle | |||||
Width="20" | |||||
Height="2" | |||||
Margin="10,0,0,2" | |||||
Fill="#423FFD" /> | |||||
<TextBlock Foreground="White" Text="物料罐转速" /> | |||||
<Rectangle | |||||
Width="20" | |||||
Height="2" | |||||
Margin="10,0,0,2" | |||||
Fill="#F44F15" /> | |||||
<TextBlock Foreground="White" Text="反应釜转速" /> | |||||
</StackPanel> | |||||
</StackPanel> | |||||
<!--<StackPanel Orientation="Vertical"> | |||||
<lvc:CartesianChart | |||||
Height="270" | |||||
HorizontalAlignment="Stretch" | |||||
VerticalAlignment="Top" | |||||
AnimationsSpeed="0:0:1" | |||||
DataTooltip="{x:Null}" | |||||
Hoverable="False" | |||||
MouseDoubleClick="DataView_CLick" | |||||
ToolTip="比例阀开度曲线"> | |||||
<lvc:CartesianChart.Series> | |||||
<lvc:LineSeries | |||||
Fill="Transparent" | |||||
LineSmoothness="1" | |||||
PointGeometry="{x:Null}" | |||||
Stroke="White" | |||||
StrokeThickness="2" | |||||
Values="{Binding DataFeedback.OpenValve}" /> | |||||
</lvc:CartesianChart.Series> | |||||
<lvc:CartesianChart.AxisY> | |||||
<lvc:Axis> | |||||
<lvc:Axis.Separator> | |||||
<lvc:Separator IsEnabled="False" /> | |||||
</lvc:Axis.Separator> | |||||
</lvc:Axis> | |||||
</lvc:CartesianChart.AxisY> | |||||
<lvc:CartesianChart.AxisX> | |||||
<lvc:Axis | |||||
LabelFormatter="{Binding DateTimeFormatter}" | |||||
Unit="{Binding AxisUnit}"> | |||||
<lvc:Axis.Separator> | |||||
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" /> | |||||
</lvc:Axis.Separator> | |||||
</lvc:Axis> | |||||
</lvc:CartesianChart.AxisX> | |||||
</lvc:CartesianChart> | |||||
<StackPanel Margin="0,10,0,0" Orientation="Horizontal"> | |||||
<TextBlock Foreground="White" Text="比例阀开度曲线" /> | |||||
<Rectangle | |||||
Width="20" | |||||
Height="2" | |||||
Margin="20,0,0,2" | |||||
Fill="White" /> | |||||
<TextBlock Foreground="White" Text="比例阀开度" /> | |||||
</StackPanel> | |||||
</StackPanel>--> | |||||
<!--<StackPanel Orientation="Vertical"> | |||||
<lvc:CartesianChart | |||||
Height="270" | |||||
HorizontalAlignment="Stretch" | |||||
VerticalAlignment="Top" | |||||
AnimationsSpeed="0:0:1" | |||||
DataTooltip="{x:Null}" | |||||
Hoverable="False" | |||||
MouseDoubleClick="DataView_CLick" | |||||
ToolTip="压力曲线"> | |||||
<lvc:CartesianChart.Series> | |||||
<lvc:LineSeries | |||||
Fill="Transparent" | |||||
LineSmoothness="1" | |||||
PointGeometry="{x:Null}" | |||||
Stroke="#F1C74B" | |||||
StrokeThickness="2" | |||||
Values="{Binding DataFeedback.PressureWok}" /> | |||||
</lvc:CartesianChart.Series> | |||||
<lvc:CartesianChart.AxisY> | |||||
<lvc:Axis | |||||
LabelFormatter="{Binding doubleFormatter}" | |||||
MaxValue="1.0" | |||||
MinValue="0"> | |||||
<lvc:Axis.Separator> | |||||
<lvc:Separator IsEnabled="False" /> | |||||
</lvc:Axis.Separator> | |||||
</lvc:Axis> | |||||
</lvc:CartesianChart.AxisY> | |||||
<lvc:CartesianChart.AxisX> | |||||
<lvc:Axis | |||||
LabelFormatter="{Binding DateTimeFormatter}" | |||||
Unit="{Binding AxisUnit}"> | |||||
<lvc:Axis.Separator> | |||||
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" /> | |||||
</lvc:Axis.Separator> | |||||
</lvc:Axis> | |||||
</lvc:CartesianChart.AxisX> | |||||
</lvc:CartesianChart> | |||||
<StackPanel Margin="0,10,0,0" Orientation="Horizontal"> | |||||
<TextBlock Foreground="White" Text="压力曲线/Mpa" /> | |||||
<Rectangle | |||||
Width="20" | |||||
Height="2" | |||||
Margin="20,0,0,2" | |||||
Fill="#F1C74B" /> | |||||
<TextBlock Foreground="White" Text="反应釜压力" /> | |||||
</StackPanel> | |||||
</StackPanel>--> | |||||
<StackPanel Margin="0,20,0,0" Orientation="Vertical"> | |||||
<lvc:CartesianChart | |||||
Height="270" | |||||
HorizontalAlignment="Stretch" | |||||
VerticalAlignment="Top" | |||||
AnimationsSpeed="0:0:1" | |||||
DataTooltip="{x:Null}" | |||||
Hoverable="False" | |||||
MouseDoubleClick="DataView_CLick" | |||||
ToolTip="重量曲线"> | |||||
<lvc:CartesianChart.Series> | |||||
<lvc:LineSeries | |||||
Fill="Transparent" | |||||
LineSmoothness="1" | |||||
PointGeometry="{x:Null}" | |||||
Stroke="Purple" | |||||
StrokeThickness="2" | |||||
Values="{Binding DataFeedback.WeightWok}" /> | |||||
</lvc:CartesianChart.Series> | |||||
<lvc:CartesianChart.AxisY> | |||||
<lvc:Axis> | |||||
<lvc:Axis.Separator> | |||||
<lvc:Separator IsEnabled="False" /> | |||||
</lvc:Axis.Separator> | |||||
</lvc:Axis> | |||||
</lvc:CartesianChart.AxisY> | |||||
<lvc:CartesianChart.AxisX> | |||||
<lvc:Axis | |||||
LabelFormatter="{Binding DateTimeFormatter}" | |||||
Unit="{Binding AxisUnit}"> | |||||
<lvc:Axis.Separator> | |||||
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" /> | |||||
</lvc:Axis.Separator> | |||||
</lvc:Axis> | |||||
</lvc:CartesianChart.AxisX> | |||||
</lvc:CartesianChart> | |||||
<StackPanel Margin="0,10,0,0" Orientation="Horizontal"> | |||||
<TextBlock Foreground="White" Text="重量曲线/kg" /> | |||||
<Rectangle | |||||
Width="20" | |||||
Height="2" | |||||
Margin="20,0,0,2" | |||||
Fill="Purple" /> | |||||
<TextBlock Foreground="White" Text="反应釜重量" /> | |||||
</StackPanel> | |||||
</StackPanel> | |||||
</UniformGrid> | |||||
<Grid | |||||
x:Name="chartGrid" | |||||
HorizontalAlignment="Stretch" | |||||
VerticalAlignment="Stretch" | |||||
Background="White" | |||||
Visibility="Collapsed"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="200" /> | |||||
</Grid.ColumnDefinitions> | |||||
<oxy:PlotView | |||||
x:Name="chartView" | |||||
Margin="5" | |||||
Background="Transparent" | |||||
Foreground="Black" | |||||
PanCursor="Hand" /> | |||||
<Button | |||||
Grid.Column="1" | |||||
Width="120" | |||||
Height=" 40" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Click="Button_Click" | |||||
Content="退出" /> | |||||
</Grid> | |||||
</Grid> | |||||
</UserControl> |
@@ -0,0 +1,178 @@ | |||||
using LiveCharts.Definitions.Charts; | |||||
using LiveCharts.Wpf; | |||||
using OxyPlot.Axes; | |||||
using OxyPlot; | |||||
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 ThingsGateway.Foundation.Core; | |||||
namespace BPASmartClient.Academy.View | |||||
{ | |||||
/// <summary> | |||||
/// DeviceChartView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class DeviceChartView : UserControl | |||||
{ | |||||
public DeviceChartView() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
public PlotModel plotModel { get; set; } = new PlotModel(); | |||||
private void DataView_CLick(object sender, MouseButtonEventArgs e) | |||||
{ | |||||
ooo.Visibility = Visibility.Collapsed; | |||||
double min = DateTimeAxis.ToDouble(System.DateTime.Now.AddMinutes(-10)); | |||||
double max = DateTimeAxis.ToDouble(System.DateTime.Now); | |||||
double maxrange = max - min; | |||||
CartesianChart liveCharts = sender as CartesianChart; | |||||
switch (liveCharts.ToolTip) | |||||
{ | |||||
case "温度曲线": | |||||
plotModel.Series.Clear(); | |||||
plotModel = new PlotModel() { Title = "温度曲线" }; | |||||
chartGrid.Visibility = Visibility.Visible; | |||||
OxyPlot.Series.LineSeries line = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "反应釜温度", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2 }; | |||||
OxyPlot.Series.LineSeries line_1 = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "反应釜排气温度", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2 }; | |||||
OxyPlot.Series.LineSeries line_2 = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "配料罐温度", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2 }; | |||||
List<DataPoint> twValues = new List<DataPoint>(); | |||||
List<DataPoint> tvValues = new List<DataPoint>(); | |||||
List<DataPoint> tmValues = new List<DataPoint>(); | |||||
Sqlite.GetInstance.SelectId(Simens_PLC.GetInstance.id).ForEach(t => | |||||
{ | |||||
twValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.TempWok)); | |||||
tvValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.TempVent)); | |||||
tmValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.TempMaterial)); | |||||
}); | |||||
line.Points.AddRange(twValues); | |||||
line_1.Points.AddRange(tvValues); | |||||
line_2.Points.AddRange(tmValues); | |||||
if (!(plotModel.Axes.Count > 0)) | |||||
{ | |||||
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max }); | |||||
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "温度/℃", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2")}); | |||||
} | |||||
plotModel.Series.Add(line); | |||||
plotModel.Series.Add(line_1); | |||||
plotModel.Series.Add(line_2); | |||||
plotModel.InvalidatePlot(true);//重新加载曲线 | |||||
chartView.Model = plotModel; | |||||
break; | |||||
case "转速曲线": | |||||
plotModel.Series.Clear(); | |||||
plotModel = new PlotModel() { Title = "转速曲线" }; | |||||
chartGrid.Visibility = Visibility.Visible; | |||||
OxyPlot.Series.LineSeries line_3 = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "反应釜转速", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2 }; | |||||
OxyPlot.Series.LineSeries line_4 = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "配料罐转速", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2 }; | |||||
List<DataPoint> m101 = new List<DataPoint>(); | |||||
List<DataPoint> m102 = new List<DataPoint>(); | |||||
Sqlite.GetInstance.SelectId(Simens_PLC.GetInstance.id).ForEach(t => | |||||
{ | |||||
m101.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.M101_Speed)); | |||||
m102.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.M102_Speed)); | |||||
}); | |||||
line_3.Points.AddRange(m101); | |||||
line_4.Points.AddRange(m102); | |||||
if (!(plotModel.Axes.Count > 0)) | |||||
{ | |||||
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max}); | |||||
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "转速/rpm", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") }); | |||||
} | |||||
plotModel.Series.Add(line_3); | |||||
plotModel.Series.Add(line_4); | |||||
plotModel.InvalidatePlot(true);//重新加载曲线 | |||||
chartView.Model = plotModel; | |||||
break; | |||||
//case "比例阀开度曲线": | |||||
// plotModel.Series.Clear(); | |||||
// plotModel = new PlotModel() { Title = "比例阀开度曲线" }; | |||||
// chartGrid.Visibility = Visibility.Visible; | |||||
// List<DataPoint> open = new List<DataPoint>(); | |||||
// Sqlite.GetInstance.SelectId(Simens_PLC.GetInstance.id).ForEach(t => | |||||
// { | |||||
// open.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.OpenValve)); | |||||
// }); | |||||
// line.Points.AddRange(open); | |||||
// if (!(plotModel.Axes.Count > 0)) | |||||
// { | |||||
// plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max, MaximumRange = maxrange }); | |||||
// plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "比例阀开度/挡", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), IsZoomEnabled = false }); | |||||
// } | |||||
// plotModel.Series.Add(line); | |||||
// plotModel.InvalidatePlot(true);//重新加载曲线 | |||||
// chartView.Model = plotModel; | |||||
// break; | |||||
//case "压力曲线": | |||||
// plotModel.Series.Clear(); | |||||
// plotModel = new PlotModel() { Title = "反应釜压力曲线" }; | |||||
// chartGrid.Visibility = Visibility.Visible; | |||||
// List<DataPoint> pressure = new List<DataPoint>(); | |||||
// Sqlite.GetInstance.SelectId(Simens_PLC.GetInstance.id).ForEach(t => | |||||
// { | |||||
// pressure.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.PressureWok)); | |||||
// }); | |||||
// line.Points.AddRange(pressure); | |||||
// if (!(plotModel.Axes.Count > 0)) | |||||
// { | |||||
// plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max, MaximumRange = maxrange }); | |||||
// plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "反应釜压力/Mpa", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), IsZoomEnabled = false }); | |||||
// } | |||||
// plotModel.Series.Add(line); | |||||
// plotModel.InvalidatePlot(true);//重新加载曲线 | |||||
// chartView.Model = plotModel; | |||||
// break; | |||||
case "重量曲线": | |||||
plotModel.Series.Clear(); | |||||
plotModel = new PlotModel() { Title = "反应釜重量曲线" }; | |||||
chartGrid.Visibility = Visibility.Visible; | |||||
List<DataPoint> ww = new List<DataPoint>(); | |||||
OxyPlot.Series.LineSeries line_5 = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "配料罐转速", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2 }; | |||||
Sqlite.GetInstance.SelectId(Simens_PLC.GetInstance.id).ForEach(t => | |||||
{ | |||||
ww.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.WeightWok)); | |||||
}); | |||||
line_5.Points.AddRange(ww); | |||||
if (!(plotModel.Axes.Count > 0)) | |||||
{ | |||||
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max }); | |||||
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "反应釜重量/kg", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2")}); | |||||
} | |||||
plotModel.Series.Add(line_5); | |||||
plotModel.InvalidatePlot(true);//重新加载曲线 | |||||
chartView.Model = plotModel; | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
} | |||||
private void Button_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
chartGrid.Visibility = Visibility.Collapsed; | |||||
ooo.Visibility = Visibility.Visible; | |||||
plotModel.Axes.Clear(); | |||||
plotModel.Series.Clear(); | |||||
plotModel.InvalidatePlot(true); | |||||
chartView.Model = plotModel; | |||||
} | |||||
} | |||||
} |
@@ -1,4 +1,6 @@ | |||||
using BPASmartClient.Academy.Model; | using BPASmartClient.Academy.Model; | ||||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||||
using BPASmartClient.CustomResource.UserControls; | |||||
using LiveCharts; | using LiveCharts; | ||||
using LiveCharts.Wpf; | using LiveCharts.Wpf; | ||||
using Newtonsoft.Json.Linq; | using Newtonsoft.Json.Linq; | ||||
@@ -20,6 +22,7 @@ using System.Windows.Media; | |||||
using System.Windows.Media.Imaging; | using System.Windows.Media.Imaging; | ||||
using System.Windows.Navigation; | using System.Windows.Navigation; | ||||
using System.Windows.Shapes; | using System.Windows.Shapes; | ||||
using static System.Net.Mime.MediaTypeNames; | |||||
namespace BPASmartClient.Academy.View | namespace BPASmartClient.Academy.View | ||||
{ | { | ||||
@@ -31,40 +34,36 @@ namespace BPASmartClient.Academy.View | |||||
public DeviceMotionView() | public DeviceMotionView() | ||||
{ | { | ||||
InitializeComponent(); | InitializeComponent(); | ||||
this.DataContext = DeviceMotionViewModel.GetInstance; | |||||
this.Loaded += DeviceMotionView_Loaded; | |||||
} | } | ||||
private void Start_Click(object sender, RoutedEventArgs e) | |||||
private void DeviceMotionView_Loaded(object sender, RoutedEventArgs e) | |||||
{ | { | ||||
if (recipeName.Text!=""&& Simens_PLC.GetInstance.IsConnected) | |||||
Simens_PLC.GetInstance.connect = o => | |||||
{ | { | ||||
switch (start_check.Content.ToString()) | |||||
App.Current.Dispatcher.Invoke(() => | |||||
{ | { | ||||
case "系统启动": | |||||
start_check.IsChecked = true; | |||||
DataFeedback dataFeedback = new DataFeedback(); | |||||
dataFeedback.Name = recipeName.Text; | |||||
Simens_PLC.GetInstance.id = dataFeedback.Id; | |||||
Simens_PLC.GetInstance.dataFeedback = dataFeedback; | |||||
Sqlite.GetInstance.saveDatas.Clear(); | |||||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.0", true); | |||||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.1", true); | |||||
start_check.Content = "系统停止"; | |||||
break; | |||||
case "系统停止": | |||||
start_check.IsChecked = false; | |||||
Simens_PLC.GetInstance.id = ""; | |||||
start_check.Content = "系统启动"; | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
MessageNotify.GetInstance.ShowDialog("请输入名称后,再开始测试!!", DialogType.Information); | |||||
start_check.IsChecked = false; | |||||
} | |||||
if (o) | |||||
{ | |||||
ooo.Opacity = 1; | |||||
ooo.IsHitTestVisible = true; | |||||
state.Visibility = Visibility.Collapsed; | |||||
} | |||||
else | |||||
{ | |||||
ooo.Opacity = 0.5; | |||||
ooo.IsHitTestVisible = false; | |||||
state.Text = "设 备 未 连 接"; | |||||
state.Visibility = Visibility.Visible; | |||||
state.Foreground = Brushes.Red; | |||||
} | |||||
}); | |||||
}; | |||||
} | } | ||||
private string tempName = "配料罐升温"; | private string tempName = "配料罐升温"; | ||||
private void auto_click(object sender, RoutedEventArgs e) | private void auto_click(object sender, RoutedEventArgs e) | ||||
{ | { | ||||
@@ -73,9 +72,21 @@ namespace BPASmartClient.Academy.View | |||||
{ | { | ||||
case "反应釜升温": | case "反应釜升温": | ||||
tempName = "反应釜升温"; | tempName = "反应釜升温"; | ||||
wokTemp.Visibility = Visibility.Collapsed; | |||||
setTemp.Visibility = Visibility.Visible; | |||||
caliTemp.Visibility = Visibility.Collapsed; | |||||
break; | break; | ||||
case "配料罐升温": | case "配料罐升温": | ||||
tempName = "配料罐升温"; | tempName = "配料罐升温"; | ||||
wokTemp.Visibility = Visibility.Visible; | |||||
setTemp.Visibility = Visibility.Collapsed; | |||||
caliTemp.Visibility = Visibility.Collapsed; | |||||
break; | |||||
case "温度校准": | |||||
tempName = "温度校准"; | |||||
wokTemp.Visibility = Visibility.Collapsed; | |||||
setTemp.Visibility = Visibility.Collapsed; | |||||
caliTemp.Visibility = Visibility.Visible; | |||||
break; | break; | ||||
default: | default: | ||||
break; | break; | ||||
@@ -84,200 +95,162 @@ namespace BPASmartClient.Academy.View | |||||
private void Open_Click(object sender, RoutedEventArgs e) | private void Open_Click(object sender, RoutedEventArgs e) | ||||
{ | { | ||||
RadioButton radioButton = sender as RadioButton; | |||||
int bit = Convert.ToInt32(radioButton.Tag.ToString()); | |||||
if (bit < 8) | |||||
if (Simens_PLC.GetInstance.IsConnected) | |||||
{ | { | ||||
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1000.{bit}", true); | |||||
} | |||||
else | |||||
{ | |||||
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1001.{bit - 8}", true); | |||||
RadioButton radioButton = sender as RadioButton; | |||||
int bit = Convert.ToInt32(radioButton.Tag.ToString()); | |||||
if (bit < 8) | |||||
{ | |||||
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1000.{bit}", true); | |||||
} | |||||
else if (bit < 16) | |||||
{ | |||||
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1001.{bit - 8}", true); | |||||
} | |||||
else | |||||
{ | |||||
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1002.{bit - 16}", true); | |||||
} | |||||
} | } | ||||
} | } | ||||
private void Close_Click(object sender, RoutedEventArgs e) | private void Close_Click(object sender, RoutedEventArgs e) | ||||
{ | { | ||||
RadioButton radioButton = sender as RadioButton; | |||||
int bit = Convert.ToInt32(radioButton.Tag.ToString()); | |||||
if (bit < 8) | |||||
if (Simens_PLC.GetInstance.IsConnected) | |||||
{ | { | ||||
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1000.{bit}", false); | |||||
} | |||||
else | |||||
{ | |||||
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1001.{bit - 8}", false); | |||||
RadioButton radioButton = sender as RadioButton; | |||||
int bit = Convert.ToInt32(radioButton.Tag.ToString()); | |||||
if (bit < 8) | |||||
{ | |||||
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1000.{bit}", false); | |||||
} | |||||
else if (bit < 16) | |||||
{ | |||||
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1001.{bit - 8}", false); | |||||
} | |||||
else | |||||
{ | |||||
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1002.{bit - 16}", false); | |||||
} | |||||
} | } | ||||
} | } | ||||
public PlotModel plotModel { get; set; } = new PlotModel(); | |||||
private void DataView_CLick(object sender, MouseButtonEventArgs e) | |||||
private void TempSet_CLick(object sender, RoutedEventArgs e) | |||||
{ | { | ||||
ooo.Visibility = Visibility.Collapsed; | |||||
double min = DateTimeAxis.ToDouble(System.DateTime.Now.AddMinutes(-10)); | |||||
double max = DateTimeAxis.ToDouble(System.DateTime.Now); | |||||
double maxrange = max - min; | |||||
CartesianChart liveCharts = sender as CartesianChart; | |||||
OxyPlot.Series.LineSeries line = new OxyPlot.Series.LineSeries() { Title = "反应釜温度",MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2 }; | |||||
OxyPlot.Series.LineSeries line_1 = new OxyPlot.Series.LineSeries() { Title = "反应釜排气温度", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2 }; | |||||
OxyPlot.Series.LineSeries line_2 = new OxyPlot.Series.LineSeries() { Title = "配料罐温度", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2 }; | |||||
switch (liveCharts.ToolTip) | |||||
bool suc; | |||||
switch (tempName) | |||||
{ | { | ||||
case "温度曲线": | |||||
plotModel.Series.Clear(); | |||||
plotModel = new PlotModel() { Title = "温度曲线"}; | |||||
chartGrid.Visibility = Visibility.Visible; | |||||
List<DataPoint> twValues = new List<DataPoint>(); | |||||
List<DataPoint> tvValues = new List<DataPoint>(); | |||||
List<DataPoint> tmValues = new List<DataPoint>(); | |||||
Sqlite.GetInstance.saveDatas.ForEach(t => | |||||
case "反应釜升温": | |||||
int tempValue; | |||||
suc = int.TryParse(temp.Text.ToString(), out tempValue); | |||||
if (suc) | |||||
{ | { | ||||
twValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date),t.TempWok)); | |||||
tvValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.TempVent)); | |||||
tmValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.TempMaterial)); | |||||
}); | |||||
line.Points.AddRange(twValues); | |||||
line_1.Points.AddRange(tvValues); | |||||
line_2.Points.AddRange(tmValues); | |||||
if (!(plotModel.Axes.Count>0)) | |||||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.7", true); | |||||
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1020", tempValue); | |||||
} | |||||
else | |||||
{ | { | ||||
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间",StringFormat= "hh:mm:ss" , Minimum = min,Maximum = max,MaximumRange=maxrange }); | |||||
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "温度/℃", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"),IsZoomEnabled = false,IsPanEnabled = false}); | |||||
App.Current.Dispatcher.Invoke(() => | |||||
{ | |||||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查温度输入是否正确", 1, 1); | |||||
}); | |||||
} | } | ||||
plotModel.Series.Add(line); | |||||
plotModel.Series.Add(line_1); | |||||
plotModel.Series.Add(line_2); | |||||
plotModel.InvalidatePlot(true);//重新加载曲线 | |||||
chartView.Model = plotModel; | |||||
break; | break; | ||||
case "转速曲线": | |||||
plotModel.Series.Clear(); | |||||
plotModel = new PlotModel() { Title = "转速曲线"}; | |||||
chartGrid.Visibility = Visibility.Visible; | |||||
List<DataPoint> m101 = new List<DataPoint>(); | |||||
List<DataPoint> m102 = new List<DataPoint>(); | |||||
List<DataPoint> m103 = new List<DataPoint>(); | |||||
Sqlite.GetInstance.saveDatas.ForEach(t => | |||||
case "配料罐升温": | |||||
suc = int.TryParse(temp_1.Text.ToString(), out tempValue); | |||||
int time; | |||||
suc = int.TryParse(time_1.Text.ToString(), out time); | |||||
if (suc) | |||||
{ | { | ||||
m101.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.M101_Speed)); | |||||
m102.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.M102_Speed)); | |||||
m103.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.M103_Speed)); | |||||
}); | |||||
line.Points.AddRange(m101); | |||||
line_1.Points.AddRange(m102); | |||||
line_2.Points.AddRange(m103); | |||||
if (!(plotModel.Axes.Count > 0)) | |||||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.6", true); | |||||
Simens_PLC.GetInstance.siemens.Write<ushort>("DB1.DBD100", (ushort)(time*10)); | |||||
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1016", tempValue); | |||||
} | |||||
else | |||||
{ | { | ||||
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max, MaximumRange = maxrange }); | |||||
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "转速/rpm", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), IsZoomEnabled = false }); | |||||
App.Current.Dispatcher.Invoke(() => | |||||
{ | |||||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查温度输入是否正确", 1, 1); | |||||
}); | |||||
} | } | ||||
plotModel.Series.Add(line); | |||||
plotModel.Series.Add(line_1); | |||||
plotModel.Series.Add(line_2); | |||||
plotModel.InvalidatePlot(true);//重新加载曲线 | |||||
chartView.Model = plotModel; | |||||
break; | break; | ||||
case "比例阀开度曲线": | |||||
plotModel.Series.Clear(); | |||||
plotModel = new PlotModel() { Title = "比例阀开度曲线" }; | |||||
chartGrid.Visibility = Visibility.Visible; | |||||
List<DataPoint> open = new List<DataPoint>(); | |||||
Sqlite.GetInstance.saveDatas.ForEach(t => | |||||
case "温度校准": | |||||
bool val = true; | |||||
int value; | |||||
suc = int.TryParse(tempvent.Text.ToString(),out value); | |||||
if (suc) | |||||
{ | { | ||||
open.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.OpenValve)); | |||||
}); | |||||
line.Points.AddRange(open); | |||||
if (!(plotModel.Axes.Count > 0)) | |||||
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1024", value).OnFailure(o => | |||||
{ | |||||
val = false; | |||||
App.Current.Dispatcher.Invoke(() => | |||||
{ | |||||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "反应釜排气温度写入失败", 1, 1); | |||||
}); | |||||
}); | |||||
} | |||||
else | |||||
{ | { | ||||
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max, MaximumRange = maxrange }); | |||||
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "比例阀开度/挡", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), IsZoomEnabled = false }); | |||||
App.Current.Dispatcher.Invoke(() => | |||||
{ | |||||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查排气温度校准输入", 1, 1); | |||||
}); | |||||
} | } | ||||
plotModel.Series.Add(line); | |||||
plotModel.InvalidatePlot(true);//重新加载曲线 | |||||
chartView.Model = plotModel; | |||||
break; | |||||
case "压力曲线": | |||||
plotModel.Series.Clear(); | |||||
plotModel = new PlotModel() { Title = "反应釜压力曲线" }; | |||||
chartGrid.Visibility = Visibility.Visible; | |||||
List<DataPoint> pressure = new List<DataPoint>(); | |||||
Sqlite.GetInstance.saveDatas.ForEach(t => | |||||
suc = int.TryParse(tempmaterial.Text.ToString(), out value); | |||||
if (suc) | |||||
{ | { | ||||
pressure.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.PressureWok)); | |||||
}); | |||||
line.Points.AddRange(pressure); | |||||
if (!(plotModel.Axes.Count > 0)) | |||||
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1028", value).OnFailure(o => | |||||
{ | |||||
val = false; | |||||
App.Current.Dispatcher.Invoke(() => | |||||
{ | |||||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "配料罐温度写入失败", 1, 1); | |||||
}); | |||||
}); | |||||
} | |||||
else | |||||
{ | { | ||||
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max, MaximumRange = maxrange }); | |||||
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "反应釜压力/Mpa", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), IsZoomEnabled = false }); | |||||
App.Current.Dispatcher.Invoke(() => | |||||
{ | |||||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查配料罐温度校准输入", 1, 1); | |||||
}); | |||||
} | } | ||||
plotModel.Series.Add(line); | |||||
plotModel.InvalidatePlot(true);//重新加载曲线 | |||||
chartView.Model = plotModel; | |||||
break; | |||||
case "重量曲线": | |||||
plotModel.Series.Clear(); | |||||
plotModel = new PlotModel() { Title = "反应釜重量曲线" }; | |||||
chartGrid.Visibility = Visibility.Visible; | |||||
List<DataPoint> ww = new List<DataPoint>(); | |||||
Sqlite.GetInstance.saveDatas.ForEach(t => | |||||
suc = int.TryParse(tempwok.Text.ToString(), out value); | |||||
if (suc) | |||||
{ | { | ||||
ww.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.WeightWok)); | |||||
}); | |||||
line.Points.AddRange(ww); | |||||
if (!(plotModel.Axes.Count > 0)) | |||||
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1032", value).OnFailure(o => | |||||
{ | |||||
val = false; | |||||
App.Current.Dispatcher.Invoke(() => | |||||
{ | |||||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "反应釜温度写入失败", 1, 1); | |||||
}); | |||||
}); | |||||
} | |||||
else | |||||
{ | { | ||||
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max, MaximumRange = maxrange }); | |||||
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "反应釜重量/kg", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), IsZoomEnabled = false }); | |||||
App.Current.Dispatcher.Invoke(() => | |||||
{ | |||||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查反应釜温度校准输入", 1, 1); | |||||
}); | |||||
} | |||||
if (val) | |||||
{ | |||||
App.Current.Dispatcher.Invoke(() => | |||||
{ | |||||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Info, App.MainWindow, "成功", "校准完成", 1, 1); | |||||
}); | |||||
} | } | ||||
plotModel.Series.Add(line); | |||||
plotModel.InvalidatePlot(true);//重新加载曲线 | |||||
chartView.Model = plotModel; | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
} | |||||
private void Button_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
chartGrid.Visibility = Visibility.Collapsed; | |||||
ooo.Visibility= Visibility.Visible; | |||||
chartView.Model = null; | |||||
} | |||||
private void TempSet_CLick(object sender, RoutedEventArgs e) | |||||
{ | |||||
Simens_PLC.GetInstance.siemens.Read<int>("DB1.DBD2006").OnSuccess(o => | |||||
{ | |||||
}); | |||||
int tempValue; | |||||
if (temp.Text!=null&&temp.Text.ToString()!="") | |||||
{ | |||||
tempValue = Convert.ToInt32(temp.Text.ToString()); | |||||
} | |||||
else | |||||
{ | |||||
tempValue = 0; | |||||
} | |||||
switch (tempName) | |||||
{ | |||||
case "反应釜升温": | |||||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.7", true); | |||||
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1020", tempValue); | |||||
break; | |||||
case "配料罐升温": | |||||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.6", true); | |||||
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1016", tempValue); | |||||
break; | break; | ||||
default: | default: | ||||
break; | break; | ||||
@@ -0,0 +1,38 @@ | |||||
using BPASmartClient.Academy.Model; | |||||
using LiveCharts; | |||||
using LiveCharts.Configurations; | |||||
using LiveCharts.Wpf; | |||||
using OxyPlot.Axes; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.Academy.ViewModel | |||||
{ | |||||
public class DeviceChartViewModel : NotifyBase | |||||
{ | |||||
public DeviceChartViewModel() | |||||
{ | |||||
DataFeedback = new DataFeedback(); | |||||
var mapper = Mappers.Xy<DataValue>() | |||||
.X(model => model.DateTime.Ticks) | |||||
.Y(model => model.Value); | |||||
Charting.For<DataValue>(mapper); | |||||
DataFeedback = Simens_PLC.GetInstance.dataFeedback; | |||||
} | |||||
private DataFeedback dataFeedback; | |||||
public DataFeedback DataFeedback { get { return dataFeedback; } set { dataFeedback = value; OnPropertyChanged(); } } | |||||
public Func<double, string> DateTimeFormatter { get; set; } = value => value>0 ? new DateTime((long)value).ToString("HH:mm:ss"):new DateTime((long)DateTime.Now.Ticks).ToString("HH:mm:ss"); | |||||
public Func<double, string> doubleFormatter { get; set; } = value => value.ToString("F2"); | |||||
public double AxisStep { get; set; } = TimeSpan.FromSeconds(2).Ticks; | |||||
public double AxisUnit { get; set; } = TimeSpan.TicksPerSecond; | |||||
} | |||||
} |
@@ -14,68 +14,76 @@ namespace BPASmartClient.Academy.ViewModel | |||||
{ | { | ||||
public class DeviceMotionViewModel : NotifyBase | public class DeviceMotionViewModel : NotifyBase | ||||
{ | { | ||||
private static DeviceMotionViewModel Instance; | |||||
public static DeviceMotionViewModel GetInstance { get; set; } = Instance??=new DeviceMotionViewModel(); | |||||
public DeviceMotionViewModel() | public DeviceMotionViewModel() | ||||
{ | { | ||||
var mapper = Mappers.Xy<DataValue>() | |||||
.X(model => model.DateTime.Ticks) | |||||
.Y(model => model.Value); | |||||
Charting.For<DataValue>(mapper); | |||||
DateTimeFormatter = value => new DateTime((long)value).ToString("mm:ss"); | |||||
doubleFormatter = value=> value.ToString("F2"); | |||||
AxisStep = TimeSpan.FromSeconds(2).Ticks; | |||||
AxisUnit = TimeSpan.TicksPerSecond; | |||||
ThreadManage.GetInstance.StartLong(() => { SetAxisLimits(DateTime.Now); }, "时间显示"); | |||||
Start = new BPARelayCommand(() => | |||||
{ | |||||
if (Name!= "" && Simens_PLC.GetInstance.IsConnected) | |||||
{ | |||||
switch (Content) | |||||
{ | |||||
case "系统启动": | |||||
IsChecked = true; | |||||
DataFeedback dataFeedback = new DataFeedback(); | |||||
dataFeedback.Name = Name; | |||||
Simens_PLC.GetInstance.id = Guid.NewGuid().ToString(); | |||||
Simens_PLC.GetInstance.dataFeedback = dataFeedback; | |||||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.0", true); | |||||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.1", true); | |||||
Content = "系统停止"; | |||||
break; | |||||
case "系统停止": | |||||
IsChecked = false; | |||||
Simens_PLC.GetInstance.id = ""; | |||||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.0", false); | |||||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.1", false); | |||||
Content = "系统启动"; | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
if (!Simens_PLC.GetInstance.IsConnected) | |||||
{ | |||||
MessageNotify.GetInstance.ShowDialog("设备未连接成功,请稍后重试", DialogType.Information); | |||||
} | |||||
else | |||||
{ | |||||
MessageNotify.GetInstance.ShowDialog("请输入名称后,再开始测试!!", DialogType.Information); | |||||
} | |||||
IsChecked = false; | |||||
} | |||||
}); | |||||
} | } | ||||
public static PipeLineMode PipeLine { get; set; } = new PipeLineMode(); | public static PipeLineMode PipeLine { get; set; } = new PipeLineMode(); | ||||
private DataFeedback dataFeedback = Simens_PLC.GetInstance.dataFeedback; | |||||
public DataFeedback DataFeedback { get { return dataFeedback; } set { dataFeedback = value;OnPropertyChanged(); } } | |||||
public Func<double, string> DateTimeFormatter { get; set; } | |||||
public Func<double, string> doubleFormatter { get; set; } | |||||
public double AxisStep { get; set; } | |||||
public double AxisUnit { get; set; } | |||||
private double _axisMax; | |||||
public double AxisMax | |||||
private string _name = ""; | |||||
public string Name | |||||
{ | { | ||||
get { return _axisMax; } | |||||
set | |||||
{ | |||||
_axisMax = value; | |||||
OnPropertyChanged("AxisMax"); | |||||
} | |||||
get { return _name; } | |||||
set { _name = value; OnPropertyChanged(); } | |||||
} | } | ||||
private double _axisMin = DateTime.Now.Ticks; | |||||
public double AxisMin | |||||
private string _content = "系统启动"; | |||||
public string Content | |||||
{ | { | ||||
get { return _axisMin; } | |||||
set | |||||
{ | |||||
_axisMin = value; | |||||
OnPropertyChanged("AxisMin"); | |||||
} | |||||
get { return _content; } | |||||
set { _content = value; OnPropertyChanged(); } | |||||
} | } | ||||
private void SetAxisLimits(DateTime now) | |||||
{ | |||||
if (Simens_PLC.GetInstance.id != "") | |||||
{ | |||||
if (DataFeedback.TempWok.Count > 0) | |||||
{ | |||||
AxisMax = now.Ticks + TimeSpan.FromSeconds(3).Ticks; | |||||
AxisMin = now.Ticks - TimeSpan.FromSeconds(8).Ticks; | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
AxisMax = now.Ticks + TimeSpan.FromSeconds(3).Ticks; | |||||
AxisMin = now.Ticks - TimeSpan.FromSeconds(8).Ticks; | |||||
} | |||||
Thread.Sleep(1000); | |||||
private bool _isChecked = false; | |||||
public bool IsChecked | |||||
{ | |||||
get { return _isChecked; } | |||||
set { _isChecked = value; OnPropertyChanged(); } | |||||
} | } | ||||
public BPARelayCommand Start { get; set; } | |||||
private DeviceCtrl _deviceStatus = Simens_PLC.GetInstance.deviceCtrl; | private DeviceCtrl _deviceStatus = Simens_PLC.GetInstance.deviceCtrl; | ||||
@@ -96,4 +104,5 @@ namespace BPASmartClient.Academy.ViewModel | |||||
public double Value { get { return _value; } set { _value = value; OnPropertyChanged(); } } | public double Value { get { return _value; } set { _value = value; OnPropertyChanged(); } } | ||||
} | } | ||||
} | } |