using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Reflection; using System.Runtime.Serialization; using System.Text; using System.Windows.Input; using Aitex.Core.UI.MVVM; namespace Aitex.Core.Common.DeviceData { [DataContract] [Serializable] public class AITStatisticsData : INotifyPropertyChanged, IDeviceData { public event PropertyChangedEventHandler PropertyChanged; public void InvokePropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } public void InvokePropertyChanged() { PropertyInfo[] ps = this.GetType().GetProperties(); foreach (PropertyInfo p in ps) { InvokePropertyChanged(p.Name); if (p.PropertyType == typeof(ICommand)) { DelegateCommand cmd = p.GetValue(this, null) as DelegateCommand; if (cmd != null) cmd.RaiseCanExecuteChanged(); } } FieldInfo[] fi = this.GetType().GetFields(); foreach (FieldInfo p in fi) { InvokePropertyChanged(p.Name); if (p.FieldType == typeof(ICommand)) { DelegateCommand cmd = p.GetValue(this) as DelegateCommand; if (cmd != null) cmd.RaiseCanExecuteChanged(); } } } /// /// 设备的唯一名称,UI与RT交互的ID /// [DataMember] public string DeviceName { get; set; } /// /// 显示在界面上的名称 /// [DataMember] public string DisplayName { get; set; } /// /// IO 表中定义的物理编号,物理追溯使用 比如: M122 /// [DataMember] public string DeviceSchematicId { get; set; } [DataMember] public string Description { get; set; } [DataMember] public string LastPMTime { get; set; } [DataMember] public double TimeFromLastPM { get; set; } [DataMember] public double TimeTotal { get; set; } [DataMember] public double PMInterval { get; set; } public string TimeFromLastPMDisplay { get { TimeSpan ts = TimeSpan.FromSeconds(TimeFromLastPM); return string.Format("{0} Days {1:D2}:{2:D2}:{3:D2}", ts.Days, ts.Hours, ts.Minutes, ts.Seconds); } } public string TimeTotalDisplay { get { TimeSpan ts = TimeSpan.FromSeconds(TimeTotal); return string.Format("{0} Days {1:D2}:{2:D2}:{3:D2}", ts.Days, ts.Hours, ts.Minutes, ts.Seconds); } } public AITStatisticsData() { DisplayName = "Undefined"; } public void Update(IDeviceData data) { throw new NotImplementedException(); } } public enum AITStatisticsOperation { Reset, } }