using IStation.Unit; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IStation.WinFormUI.MonitorDataSet { public class UnitValueHelper { private static List _allSignalTypeList; public static string Get(long projectId,Model.Signal signal) { if (signal == null) return "未知"; var value = signal.Name; if (!string.IsNullOrEmpty(signal.UnitValue)) { if (int.TryParse(signal.UnitValue, out int unitValue)) { if (_allSignalTypeList == null || _allSignalTypeList.Count < 1) _allSignalTypeList = new BLL. SignalType().QueryAll(projectId); var type = _allSignalTypeList?.Find(x => x.Identifier == signal.SignalType); if (type != null) { var dict = UnitHelper.GetEnUnitDict(type.UnitType); if (dict != null) value = dict[unitValue]; } } } return value; } } }