alielie
2025-03-17 c401a2f2fd1a509cdeb33e850bb5c2827074af48
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using HMI.Core.Entity;
using HMI.Core.Util;
 
namespace HMI.AlarmInfoManage.Entity
{
    public class AimSetting
    {
        public static AimSetting Instance { get; private set; }
 
        public string PlcIp { get; private set; }
        public bool PlcEnabled { get; private set; }
 
        private AimSetting() { }
 
        static AimSetting()
        {
            LoadFromXml();
        }
 
        public static void LoadFromXml()
        {
            try
            {
                string path = PathHelper.ConfigFolder + "\\AimSetting.xml";
                AimSettingModel model = XmlHelper.DeserializeFromXml<AimSettingModel>(path);
                Instance = FromModel(model);
            }
            catch
            {
                Instance = new AimSetting();
            }
        }
 
        public AimSettingModel GetModel()
        {
            return new AimSettingModel() { PlcIp = PlcIp, PlcEnabled = PlcEnabled };
        }
 
        public static AimSetting FromModel(AimSettingModel model)
        {
            return new AimSetting() { PlcIp = model.PlcIp, PlcEnabled = model.PlcEnabled };
        }
 
    }
 
    public class AimSettingModel : NotifyBase
    {
        private string plcIp;
        public string PlcIp
        {
            get => plcIp;
            set
            {
                Set(ref plcIp, value);
            }
        }
 
        private bool plcEnabled;
        public bool PlcEnabled
        {
            get { return plcEnabled; }
            set { Set(ref plcEnabled, value); }
        }
    }
}