using IStation.Unit; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IStation.Model { /// /// 单位系数换算 /// public class UnitRatioMatrix : JsonModel { /// /// 单位类型 /// public eUnitType UnitType { get; set; } /// /// 原始单位 /// public int FromUnit { get; set; } /// /// 目标单位 /// public int ToUnit { get; set; } /// /// 转换 /// public double Matrix(double value) { var helper = UnitHelper.GetUnitHelper(UnitType); return helper.Convert(FromUnit, ToUnit, value); } /// /// 获取表达式 /// public string GetExpression() { return $"{UnitHelper.GetEnUnitName(UnitType, FromUnit)}=>{UnitHelper.GetEnUnitName(UnitType, ToUnit)}"; } } }