using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Xml.Serialization;
namespace Aitex.Core.Util
{
///
/// Analog device data
///
[DataContract]
[Serializable]
public class AnalogDeviceData
{
[DataMember]
public string TechnicalName { get; set; }
[DataMember]
public string DeviceName { get; set; }
[DataMember]
public string DeviceId { get; set; }
[DataMember]
public string Unit { get; set; }
[DataMember]
public string Description { get; set; }
///
/// 量程
///
[DataMember]
public double Scale { get; set; }
///
/// 设定值
///
[DataMember]
public double SetPoint { get; set; }
///
/// 实际反馈值
///
[DataMember]
public double FeedBack { get; set; }
///
/// 默认值
///
[DataMember]
public double DefaultValue { get; set; }
///
/// 是否有报警
///
[DataMember]
public bool IsWarning { get; set; }
///
/// alarm或是erro时显示的信息
///
[DataMember]
public string ErroMessage { get; set; }
private double _factor = 1.0;
[DataMember]
public double Factor { get { return _factor; } set { _factor = value; } }
public override string ToString()
{
return FeedBack.ToString();
}
///
/// Default constructor.
///
public AnalogDeviceData()
{
}
///
/// Copy constructor of this object.
///
///
public AnalogDeviceData(AnalogDeviceData deviceData)
{
TechnicalName = deviceData.TechnicalName;
DeviceName = deviceData.DeviceName;
DeviceId = deviceData.DeviceId;
Unit = deviceData.Unit;
Description = deviceData.Description;
Scale = deviceData.Scale;
SetPoint = deviceData.SetPoint;
FeedBack = deviceData.FeedBack;
DefaultValue = deviceData.DefaultValue;
IsWarning = deviceData.IsWarning;
ErroMessage = deviceData.ErroMessage;
}
}
[Serializable]
public class DataItem
{
public string DataName { get; set; }
//public bool IsPreLoaded { get; set; }
public List TimeStamp { get; set; }
public List RawData { get; set; }
}
///
/// 标识不需要数据库记录的数据类型
///
[AttributeUsageAttribute(AttributeTargets.Property | AttributeTargets.Field)]
public class DatabaseSaveIgnoreAttribute : Attribute { }
public class ModuleStatusBackground
{
public const string Init = "Yellow";
public const string Error = "OrangeRed";
public const string Busy = "LawnGreen";
public const string Idle = "White";
public const string Offline = "Gray";
public const string UnInstalled = "Gray";
public static string GetStatusBackground(string status)
{
if (status != null)
status = status.Trim().ToLower();
switch (status)
{
case "error":
return Error;
case "idle":
case "manual_idle":
case "manual":
return _dicCustom.ContainsKey(Idle) ? _dicCustom[Idle] : Idle;
case "notconnect":
case "init":
return Init;
case "offline":
return Offline;
case "notinstall":
return UnInstalled;
default:
return Busy;
}
}
private static Dictionary _dicCustom = new Dictionary();
public static void CustomColor(string type, string color)
{
_dicCustom[type] = color;
}
}
}