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