添加项目文件。
This commit is contained in:
63
CapMachine.Wpf/Services/NavigationMenuService.cs
Normal file
63
CapMachine.Wpf/Services/NavigationMenuService.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using CapMachine.Core.IService;
|
||||
using CapMachine.Wpf.Models;
|
||||
using Prism.Mvvm;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace CapMachine.Wpf.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 导航服务
|
||||
/// </summary>
|
||||
public class NavigationMenuService : BindableBase, INavigationMenuService
|
||||
{
|
||||
public NavigationMenuService()
|
||||
{
|
||||
MenuItems = new ObservableCollection<NavigationItem>();
|
||||
}
|
||||
|
||||
private ObservableCollection<NavigationItem> menuItems;
|
||||
|
||||
public ObservableCollection<NavigationItem> MenuItems
|
||||
{
|
||||
get { return menuItems; }
|
||||
set { menuItems = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
MenuItems.Clear();
|
||||
MenuItems.Add(new NavigationItem("", "全部", "", new ObservableCollection<NavigationItem>()
|
||||
{
|
||||
new NavigationItem("","模板匹配","",new ObservableCollection<NavigationItem>()
|
||||
{
|
||||
new NavigationItem("ShapeCirclePlus","轮廓匹配",""),
|
||||
new NavigationItem("ShapeOutline","形状匹配",""),
|
||||
new NavigationItem("Clouds", "相似性匹配",""),
|
||||
new NavigationItem("ShapeOvalPlus","形变匹配",""),
|
||||
}),
|
||||
new NavigationItem("", "比较测量","",new ObservableCollection<NavigationItem>()
|
||||
{
|
||||
new NavigationItem("Circle","卡尺找圆",""),
|
||||
new NavigationItem("Palette","颜色检测",""),
|
||||
new NavigationItem("Ruler", "几何测量",""),
|
||||
}),
|
||||
new NavigationItem("","字符识别","",new ObservableCollection<NavigationItem>()
|
||||
{
|
||||
new NavigationItem("FormatColorText", "字符识别",""),
|
||||
new NavigationItem("Barcode", "一维码识别",""),
|
||||
new NavigationItem("Qrcode", "二维码识别",""),
|
||||
}),
|
||||
new NavigationItem("","缺陷检测","",new ObservableCollection<NavigationItem>()
|
||||
{
|
||||
new NavigationItem("Crop", "差分模型",""),
|
||||
new NavigationItem("CropRotate", "形变模型",""),
|
||||
})
|
||||
}));
|
||||
MenuItems.Add(new NavigationItem("", "工艺过程", "MonitorView"));
|
||||
MenuItems.Add(new NavigationItem("", "工艺参数", "ProConfigView"));
|
||||
MenuItems.Add(new NavigationItem("", "工艺曲线", "RealTimeChartView"));
|
||||
MenuItems.Add(new NavigationItem("", "动作日志", "ActionLogView"));
|
||||
MenuItems.Add(new NavigationItem("", "用户管理", "UserView"));
|
||||
}
|
||||
}
|
||||
}
|
||||
74
CapMachine.Wpf/Services/PlcRtDataService.cs
Normal file
74
CapMachine.Wpf/Services/PlcRtDataService.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user