You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.7 KiB
C#

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