71 lines
2.1 KiB
C#
71 lines
2.1 KiB
C#
using CapMachine.Wpf.Models;
|
||
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
|
||
{
|
||
/// <summary>
|
||
/// 系统
|
||
/// </summary>
|
||
public class SysRunService : BindableBase
|
||
{
|
||
public SysRunService(IEventAggregator eventAggregator,ConfigService configService,CanDriveService canDriveService,LinDriveService linDriveService)
|
||
{
|
||
// 创建一个定时器,设置间隔时间为2000毫秒(即2秒)
|
||
CurTimer = new System.Timers.Timer(5000);
|
||
CurTimer.AutoReset = true;
|
||
// 设置Elapsed事件处理程序
|
||
CurTimer.Elapsed += CurTimer_Elapsed;
|
||
// 启动定时器
|
||
CurTimer.Start();
|
||
|
||
EventAggregator = eventAggregator;
|
||
ConfigService = configService;
|
||
CanDriveService = canDriveService;
|
||
LinDriveService = linDriveService;
|
||
MachineRunState1 = new MachineRunState("M1", EventAggregator, ConfigService,canDriveService,linDriveService);
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 设备运行状态
|
||
/// </summary>
|
||
public MachineRunState MachineRunState1 { get; set; }
|
||
|
||
|
||
private void CurTimer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e)
|
||
{
|
||
CurDateTime = DateTime.Now;
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 定时器
|
||
/// </summary>
|
||
private System.Timers.Timer CurTimer { get; set; }
|
||
|
||
private DateTime _CurDateTime;
|
||
/// <summary>
|
||
/// 当前时间信息
|
||
/// </summary>
|
||
public DateTime CurDateTime
|
||
{
|
||
get { return _CurDateTime; }
|
||
set { _CurDateTime = value; RaisePropertyChanged(); }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 时间发布器
|
||
/// </summary>
|
||
public IEventAggregator EventAggregator { get; }
|
||
public ConfigService ConfigService { get; }
|
||
public CanDriveService CanDriveService { get; }
|
||
public LinDriveService LinDriveService { get; }
|
||
}
|
||
}
|