240705
This commit is contained in:
@@ -57,7 +57,7 @@ namespace CapMachine.Wpf
|
||||
|
||||
////注册设备服务
|
||||
//containerRegistry.RegisterSingleton<MachineDataService>();
|
||||
containerRegistry.RegisterSingleton<PlcRtDataService>();
|
||||
containerRegistry.RegisterSingleton<MachineRtDataService>();
|
||||
|
||||
//注册AutoMapper 将IAutoMapperProvider注入IOC容器,并对外提供IMapper注入类型。
|
||||
containerRegistry.RegisterSingleton<IMapperProvider, MapperConfig>();
|
||||
@@ -140,7 +140,7 @@ namespace CapMachine.Wpf
|
||||
var appVersionService = ContainerLocator.Container.Resolve<IFreeSql>();
|
||||
//var appVersionService1 = ContainerLocator.Container.Resolve<MachineDataService>();
|
||||
//var appVersionService2 = ContainerLocator.Container.Resolve<ILogService>();
|
||||
var appVersionService3 = ContainerLocator.Container.Resolve<PlcRtDataService>();
|
||||
var appVersionService3 = ContainerLocator.Container.Resolve<MachineRtDataService>();
|
||||
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
@@ -15,11 +15,13 @@
|
||||
<PackageReference Include="HslCommunication" Version="11.7.0" />
|
||||
<PackageReference Include="MaterialDesignColors" Version="2.1.4" />
|
||||
<PackageReference Include="MaterialDesignThemes" Version="4.9.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" />
|
||||
<PackageReference Include="NLog" Version="5.2.8" />
|
||||
<PackageReference Include="Prism.DryIoc" Version="8.1.97" />
|
||||
<PackageReference Include="Syncfusion.Licensing" Version="24.2.7" />
|
||||
<PackageReference Include="Syncfusion.SfGrid.WPF" Version="24.2.7" />
|
||||
<PackageReference Include="System.Collections.Concurrent" Version="4.3.0" />
|
||||
<PackageReference Include="System.ComponentModel.Composition" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
30
CapMachine.Wpf/Models/RecordInfo.cs
Normal file
30
CapMachine.Wpf/Models/RecordInfo.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 记录的信息
|
||||
/// 曲线缓存用
|
||||
/// </summary>
|
||||
public class RecordInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 工况
|
||||
/// </summary>
|
||||
public string? WorkCondition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 温度
|
||||
/// </summary>
|
||||
public double Temp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
}
|
||||
}
|
||||
13
CapMachine.Wpf/PrismEvent/ChartActionType.cs
Normal file
13
CapMachine.Wpf/PrismEvent/ChartActionType.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.PrismEvent
|
||||
{
|
||||
public enum ChartActionType:byte
|
||||
{
|
||||
ReLoadChart=1,
|
||||
}
|
||||
}
|
||||
19
CapMachine.Wpf/PrismEvent/ChartRtActionEvent.cs
Normal file
19
CapMachine.Wpf/PrismEvent/ChartRtActionEvent.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using CapMachine.Wpf.Models;
|
||||
using Prism.Events;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.PrismEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Chart图表操作的动作事件
|
||||
/// </summary>
|
||||
public class ChartRtActionEvent : PubSubEvent<ChartActionType>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
238
CapMachine.Wpf/Services/MachineRtDataService.cs
Normal file
238
CapMachine.Wpf/Services/MachineRtDataService.cs
Normal file
@@ -0,0 +1,238 @@
|
||||
using AutoMapper.Internal;
|
||||
using CapMachine.Wpf.Models;
|
||||
using CapMachine.Wpf.PrismEvent;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Prism.Events;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 机器实时数据服务
|
||||
/// </summary>
|
||||
public class MachineRtDataService : BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 事件聚合器
|
||||
/// </summary>
|
||||
private IEventAggregator _EventAggregator { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ScanTask扫描Task
|
||||
/// </summary>
|
||||
static Task ScanTask { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 仪表数据集合
|
||||
/// </summary>
|
||||
public List<MeterRtDataModel> ListMeterRtData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 扫描线程使能
|
||||
/// </summary>
|
||||
public bool ThreadEnable { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 历史数据
|
||||
/// </summary>
|
||||
public List<RecordInfo> HistoryData = new List<RecordInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
/// <param name="eventAggregator"></param>
|
||||
public MachineRtDataService(IEventAggregator eventAggregator)
|
||||
{
|
||||
//ConcurrentDictionary<DateTime, RecordInfo> keyValuePairs = new ConcurrentDictionary<DateTime, RecordInfo>();
|
||||
|
||||
|
||||
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
//第一次计时
|
||||
stopwatch.Start(); //启动Stopwatch
|
||||
|
||||
for (var i = 0; i < 10000000; i++)
|
||||
{
|
||||
keyValuePairs.TryAdd(DateTime.UtcNow, new RecordInfo()
|
||||
{
|
||||
CreateTime = DateTime.UtcNow,
|
||||
WorkCondition = "dadf",
|
||||
Temp = 23.3
|
||||
});
|
||||
//keyValuePairs.Add(new RecordInfo()
|
||||
//{
|
||||
// CreateTime = DateTime.UtcNow,
|
||||
// WorkCondition = "dadf",
|
||||
// Temp = 23.3
|
||||
//});
|
||||
}
|
||||
|
||||
stopwatch.Stop(); //停止Stopwatch
|
||||
Console.WriteLine("Add Elapsed output runTime:{0}", stopwatch.Elapsed.ToString());
|
||||
|
||||
//事件服务
|
||||
_EventAggregator = eventAggregator;
|
||||
|
||||
//实例化集合
|
||||
ListMeterRtData = new List<MeterRtDataModel>()
|
||||
{
|
||||
new MeterRtDataModel(){
|
||||
MeterName = "EVA风量",
|
||||
RtUIControlTitle="EVA风量" + Environment.NewLine + "m³/h",
|
||||
RtUIControlTitleIndex="Title5",
|
||||
Station = 1,
|
||||
RtAddressPV = "101",
|
||||
RtAddressMV = "105",
|
||||
RtMVUIControlIndex="MV5",
|
||||
RtSVUIControlIndex="SV5",
|
||||
RtPVUIControlIndex="PV5",
|
||||
MaxValue=500,
|
||||
MinValue=0,
|
||||
Accuracy=1,
|
||||
Unit="m³/h",
|
||||
MeterEnableStatePLCAddress="V30.3",
|
||||
},
|
||||
new MeterRtDataModel(){//目前是DB表
|
||||
MeterName = "中间轴转速",//原来中间轴转速,先全部改为电机转速-开发过程中某个时刻中间轴转速改为电机转速
|
||||
RtUIControlTitle="中间轴转速" + Environment.NewLine + "(r/min)",
|
||||
RtUIControlTitleIndex="Title3",
|
||||
Station = 2,
|
||||
RtAddressPV = "101",
|
||||
RtAddressMV = "105",
|
||||
RtMVUIControlIndex="MV3",
|
||||
RtSVUIControlIndex="SV3",
|
||||
RtPVUIControlIndex="PV3",
|
||||
MaxValue=4000,
|
||||
MinValue=0,
|
||||
Accuracy=0,
|
||||
Unit="(r/min)",
|
||||
MeterEnableStatePLCAddress="",
|
||||
},
|
||||
new MeterRtDataModel(){
|
||||
MeterName = "加热电力",//加热电力
|
||||
RtUIControlTitle="加热电力" + Environment.NewLine + "(KW)",
|
||||
RtUIControlTitleIndex="Title7",
|
||||
Station = 3,
|
||||
RtAddressPV = "101",
|
||||
RtAddressMV = "105",
|
||||
RtMVUIControlIndex="MV7",
|
||||
RtSVUIControlIndex="SV7",
|
||||
RtPVUIControlIndex="PV7",
|
||||
MaxValue=30,
|
||||
MinValue=0,
|
||||
Accuracy=2,
|
||||
Unit="(KW)",
|
||||
MeterEnableStatePLCAddress="V30.4",
|
||||
},
|
||||
new MeterRtDataModel(){
|
||||
MeterName = "加湿电力",
|
||||
RtUIControlTitle="加湿电力" + Environment.NewLine + "(KW)",
|
||||
RtUIControlTitleIndex="Title8",
|
||||
Station = 4,
|
||||
RtAddressPV = "101",
|
||||
RtAddressMV = "105",
|
||||
RtMVUIControlIndex="MV8",
|
||||
RtSVUIControlIndex="SV8",
|
||||
RtPVUIControlIndex="PV8",
|
||||
MaxValue=18,
|
||||
MinValue=0,
|
||||
Accuracy=2,
|
||||
Unit="(KW)",
|
||||
MeterEnableStatePLCAddress="V30.5",
|
||||
},
|
||||
new MeterRtDataModel(){//目前是DB表
|
||||
MeterName = "EMPCV电流",//EMPCV电力
|
||||
RtUIControlTitle="EMPCV电流" + Environment.NewLine + "(A)",
|
||||
RtUIControlTitleIndex="Title9",
|
||||
Station = 5,
|
||||
RtAddressPV = "101",
|
||||
RtAddressMV = "105",
|
||||
RtMVUIControlIndex="MV9",
|
||||
RtSVUIControlIndex="SV9",
|
||||
RtPVUIControlIndex="PV9",
|
||||
MaxValue=1,
|
||||
MinValue=0,
|
||||
Accuracy=2,
|
||||
Unit="(A)",
|
||||
MeterEnableStatePLCAddress="V30.6",
|
||||
},
|
||||
new MeterRtDataModel(){
|
||||
MeterName = "INJ压力",
|
||||
RtUIControlTitle="INJ压力" + Environment.NewLine + "(MPa)",
|
||||
RtUIControlTitleIndex="Title10",
|
||||
Station = 6,
|
||||
RtAddressPV = "101",
|
||||
RtAddressMV = "105",
|
||||
RtMVUIControlIndex="MV10",
|
||||
RtSVUIControlIndex="SV10",
|
||||
RtPVUIControlIndex="PV10",
|
||||
MaxValue=5,
|
||||
MinValue=0,
|
||||
Accuracy=3,
|
||||
Unit="(MPa)",
|
||||
MeterEnableStatePLCAddress="V30.7",
|
||||
},
|
||||
new MeterRtDataModel(){
|
||||
MeterName = "冷媒流量",
|
||||
RtUIControlTitle="冷媒流量" + Environment.NewLine + "(kg/h)",
|
||||
RtUIControlTitleIndex="Title11",
|
||||
Station = 7,
|
||||
RtAddressPV = "101",
|
||||
RtAddressMV = "105",
|
||||
RtMVUIControlIndex="MV11",
|
||||
RtSVUIControlIndex="SV11",
|
||||
RtPVUIControlIndex="PV11",
|
||||
MaxValue=500,
|
||||
MinValue=0,
|
||||
Accuracy=1,
|
||||
Unit="(kg/h)",
|
||||
MeterEnableStatePLCAddress="V31.0",
|
||||
},
|
||||
};
|
||||
|
||||
PubRtDataStart();
|
||||
}
|
||||
|
||||
private Random random = new Random();
|
||||
|
||||
/// <summary>
|
||||
///发布实时数据
|
||||
/// </summary>
|
||||
private void PubRtDataStart()
|
||||
{
|
||||
ScanTask = Task.Run(async () =>
|
||||
{
|
||||
while (ThreadEnable)
|
||||
{
|
||||
try
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
_EventAggregator.GetEvent<ChartRtEvent>().Publish(new List<Models.ChartRtValue>()
|
||||
{
|
||||
new Models.ChartRtValue(){Name="室温0",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="室温1",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="室温2",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="室温3",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="室温4",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="室温5",Value=random.NextDouble()*100,Unit="℃"},
|
||||
});
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var dd = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
using CapMachine.Wpf.PrismEvent;
|
||||
using Prism.Events;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.Services
|
||||
{
|
||||
public class PlcRtDataService:BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 事件聚合器
|
||||
/// </summary>
|
||||
private IEventAggregator _EventAggregator { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ScanTask扫描Task
|
||||
/// </summary>
|
||||
static Task ScanTask { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 扫描线程使能
|
||||
/// </summary>
|
||||
public bool ThreadEnable { get; set; } = true;
|
||||
|
||||
public PlcRtDataService(IEventAggregator eventAggregator)
|
||||
{
|
||||
//事件服务
|
||||
_EventAggregator = eventAggregator;
|
||||
|
||||
|
||||
PubRtDataStart();
|
||||
}
|
||||
|
||||
private Random random = new Random();
|
||||
|
||||
/// <summary>
|
||||
///发布实时数据
|
||||
/// </summary>
|
||||
private void PubRtDataStart()
|
||||
{
|
||||
ScanTask = Task.Run(async () =>
|
||||
{
|
||||
while (ThreadEnable)
|
||||
{
|
||||
try
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
_EventAggregator.GetEvent<ChartRtEvent>().Publish(new List<Models.ChartRtValue>()
|
||||
{
|
||||
new Models.ChartRtValue(){Name="室温0",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="室温1",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="室温2",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="室温3",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="室温4",Value=random.NextDouble()*100,Unit="℃"},
|
||||
new Models.ChartRtValue(){Name="室温5",Value=random.NextDouble()*100,Unit="℃"},
|
||||
});
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var dd = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using CapMachine.Core;
|
||||
using CapMachine.Model;
|
||||
using CapMachine.Wpf.Models;
|
||||
using CapMachine.Wpf.Services;
|
||||
using ImTools;
|
||||
using Prism.Commands;
|
||||
using Prism.Services.Dialogs;
|
||||
@@ -17,36 +18,12 @@ namespace CapMachine.Wpf.ViewModels
|
||||
{
|
||||
public class DialogChartRtConfigViewModel : DialogViewModel
|
||||
{
|
||||
public DialogChartRtConfigViewModel(IFreeSql freeSql, IMapper mapper)
|
||||
public DialogChartRtConfigViewModel(IFreeSql freeSql, IMapper mapper, MachineRtDataService machineRtDataService)
|
||||
{
|
||||
this.Title = "曲线编辑";
|
||||
|
||||
//加载曲线数据源
|
||||
ChartSrcDataListViewItems = new ObservableCollection<ChartSrcData>();
|
||||
ChartSrcDataListViewItems.Add(new ChartSrcData()
|
||||
{
|
||||
Index = 1,
|
||||
Name = "温度",
|
||||
Selected = true
|
||||
});
|
||||
ChartSrcDataListViewItems.Add(new ChartSrcData()
|
||||
{
|
||||
Index = 2,
|
||||
Name = "压力",
|
||||
Selected = true
|
||||
});
|
||||
ChartSrcDataListViewItems.Add(new ChartSrcData()
|
||||
{
|
||||
Index = 3,
|
||||
Name = "湿度",
|
||||
Selected = false
|
||||
});
|
||||
ChartSrcDataListViewItems.Add(new ChartSrcData()
|
||||
{
|
||||
Index = 4,
|
||||
Name = "过冷度",
|
||||
Selected = false
|
||||
});
|
||||
|
||||
ChartYAxisDataListViewItems = new ObservableCollection<ChartYAxisDto>()
|
||||
{
|
||||
@@ -74,8 +51,8 @@ namespace CapMachine.Wpf.ViewModels
|
||||
};
|
||||
FreeSql = freeSql;
|
||||
this.Mapper = mapper;
|
||||
|
||||
RefreshChartSourceData();
|
||||
MachineRtDataService = machineRtDataService;
|
||||
LoadChartSourceData();
|
||||
RefreshChartSelectedData();
|
||||
RefreshChartYAxisData();
|
||||
}
|
||||
@@ -84,11 +61,36 @@ namespace CapMachine.Wpf.ViewModels
|
||||
/// FreeSql
|
||||
/// </summary>
|
||||
public IFreeSql FreeSql { get; }
|
||||
|
||||
/// <summary>
|
||||
/// AutoMap映射
|
||||
/// </summary>
|
||||
public IMapper Mapper { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据服务
|
||||
/// </summary>
|
||||
public MachineRtDataService MachineRtDataService { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加载ChartSourceData
|
||||
/// </summary>
|
||||
private void LoadChartSourceData()
|
||||
{
|
||||
foreach (var item in MachineRtDataService.ListMeterRtData)
|
||||
{
|
||||
ChartSrcDataListViewItems.Add(new ChartSrcData()
|
||||
{
|
||||
Index=1,
|
||||
Name=item.MeterName,
|
||||
Selected=false,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加载数据
|
||||
/// </summary>
|
||||
@@ -98,6 +100,7 @@ namespace CapMachine.Wpf.ViewModels
|
||||
//Mapper.Map<List<ChartSelectDto>>(data);
|
||||
//ChartSelectDataListViewItems = new ObservableCollection<ChartSelectDto>(Mapper.Map<List<ChartSelectDto>>(data));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -112,6 +115,18 @@ namespace CapMachine.Wpf.ViewModels
|
||||
ChartSelectDataListViewItems.Add(Mapper.Map<ChartSelectDto>(item));
|
||||
}
|
||||
|
||||
//选中后源数据状态被选中
|
||||
foreach (var item in ChartSelectedData)
|
||||
{
|
||||
var data = ChartSrcDataListViewItems.FindFirst(a => a.Name == item.Name);
|
||||
if (data != null)
|
||||
{
|
||||
//选中
|
||||
data.Selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//SelectedChartSelectData = null;
|
||||
|
||||
//Mapper.Map<List<ChartSelectDto>>(data);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using CapMachine.Core;
|
||||
using CapMachine.Wpf.PrismEvent;
|
||||
using Prism.Commands;
|
||||
using Prism.Events;
|
||||
using Prism.Services.Dialogs;
|
||||
using SharpDX.Direct3D9;
|
||||
using System;
|
||||
@@ -12,10 +14,11 @@ namespace CapMachine.Wpf.ViewModels
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
public RealTimeChartViewModel(IDialogService dialogService, IFreeSql freeSql)
|
||||
public RealTimeChartViewModel(IDialogService dialogService, IFreeSql freeSql, IEventAggregator eventAggregator)
|
||||
{
|
||||
DialogService = dialogService;
|
||||
FreeSql = freeSql;
|
||||
EventAggregator = eventAggregator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -28,6 +31,11 @@ namespace CapMachine.Wpf.ViewModels
|
||||
/// </summary>
|
||||
public IFreeSql FreeSql { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 事件聚合器
|
||||
/// </summary>
|
||||
public IEventAggregator EventAggregator { get; }
|
||||
|
||||
private DelegateCommand _ChartConfigCmd;
|
||||
/// <summary>
|
||||
/// 编辑曲线数据
|
||||
@@ -60,8 +68,8 @@ namespace CapMachine.Wpf.ViewModels
|
||||
{
|
||||
//程序名称
|
||||
var ReturnValue = par.Parameters.GetValue<string>("Name");
|
||||
|
||||
|
||||
//返回数据,刷新Chart
|
||||
EventAggregator.GetEvent<ChartRtActionEvent>().Publish(ChartActionType.ReLoadChart);
|
||||
}
|
||||
else if (par.Result == ButtonResult.Cancel)
|
||||
{
|
||||
@@ -72,7 +80,7 @@ namespace CapMachine.Wpf.ViewModels
|
||||
});
|
||||
}
|
||||
|
||||
//#region 曲线配置
|
||||
#region 曲线配置
|
||||
|
||||
//private LightningChart _LightningChartInstance;
|
||||
///// <summary>
|
||||
@@ -127,6 +135,6 @@ namespace CapMachine.Wpf.ViewModels
|
||||
//}
|
||||
|
||||
|
||||
//#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using Arction.Wpf.Charting.SeriesXY;
|
||||
using Arction.Wpf.Charting.Views.ViewXY;
|
||||
using CapMachine.Wpf.Models;
|
||||
using CapMachine.Wpf.PrismEvent;
|
||||
using CapMachine.Wpf.Services;
|
||||
using CapMachine.Wpf.ViewModels;
|
||||
using NLog;
|
||||
using Prism.Events;
|
||||
@@ -26,14 +27,19 @@ namespace CapMachine.Wpf.Views
|
||||
static System.Timers.Timer CurTimer { get; set; }
|
||||
|
||||
private IEventAggregator _EventAggregator { get; set; }
|
||||
public MachineRtDataService MachineRtDataService { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 曲线配置
|
||||
/// </summary>
|
||||
public ChartConfig ChartConfigInfo { get; set; }
|
||||
|
||||
|
||||
public RealTimeChartView(IEventAggregator eventAggregator)
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
/// <param name="eventAggregator"></param>
|
||||
/// <param name="machineRtDataService"></param>
|
||||
public RealTimeChartView(IEventAggregator eventAggregator, MachineRtDataService machineRtDataService)
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
@@ -44,7 +50,10 @@ namespace CapMachine.Wpf.Views
|
||||
|
||||
//事件服务
|
||||
_EventAggregator = eventAggregator;
|
||||
MachineRtDataService = machineRtDataService;
|
||||
|
||||
_EventAggregator.GetEvent<ChartRtEvent>().Subscribe(GetChartRtEvent);
|
||||
_EventAggregator.GetEvent<ChartRtActionEvent>().Subscribe(ReLoadData);
|
||||
|
||||
var CreateAxisY = new AxisY();
|
||||
CreateAxisY.Title.Text = Name;
|
||||
@@ -56,6 +65,17 @@ namespace CapMachine.Wpf.Views
|
||||
ListChartRtSeries.Add(new ChartRtSeries(CreateAxisY, lightningChart1, "室温0"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重新加载数据
|
||||
/// 更新曲线和Y轴设置
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void ReLoadData(ChartActionType type)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取曲线的实时值
|
||||
|
||||
Reference in New Issue
Block a user