using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Mesnac.Action.Feeding.Qingquan { /// /// PLCSchema.xml中的存盘数据项类 - 对应add节点 /// public class PlcRecipeReaderItem { /// /// 默认构造方法 /// public PlcRecipeReaderItem() { this.DataFieldName = string.Empty; this.PlcFiledName = string.Empty; this.DataType = string.Empty; this.PlcShifting = 0; this.DefaultValue = 0; this.ValueLen = 1; this.Multiply = 1; this.SetValue = null; } /// /// 数据库字段名 /// public string DataFieldName { get; set; } /// /// Plc别名 /// public string PlcFiledName { get; set; } /// /// 偏移值 /// public int PlcShifting { get; set; } /// /// 默认值 /// public int DefaultValue { get; set; } /// /// 长度 /// public int ValueLen { get; set; } /// /// 数据处理方式 /// public string DataType { get; set; } /// /// 乘数 /// public int Multiply { get; set; } /// /// 原始值 /// public int[] SetValue { get; set; } /// /// 数据转化值 /// /// public object GetValue() { if (string.IsNullOrWhiteSpace(DataType)) { return GetValue_Null(); } return GetValue_Null(); } /// /// 对节点值进行除法运算 /// /// 要处理的值 /// 返回除法运算后的结果 private double MultiplyData(double buff) { double result = buff; if (this.Multiply != 0) { result = result / (double)this.Multiply; } return result; } /// /// 获取对应的设备值 /// /// private double GetValue_Null() { if (this.SetValue.Length == 0) { return DefaultValue; } return MultiplyData(this.SetValue[0]); } } }