ningshuxia
2023-02-24 1e4b358de58e36bfbf692ab2538ff9e7d60fd025
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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<Model. SignalType> _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().GetAll(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;
        }
    }
}