123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- using YG.Config;
- using YG.Config.DefaultList;
- using YG.DefaultList;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using IMCS.DefaultList;
- /// <summary>
- /// 设备配置,可以理解为全局的变量
- /// </summary>
- namespace YG
- {
- public class DeviceConfig
- {
- private static DeviceConfig deviceConfig = new DeviceConfig();
- public static DeviceConfig Instance { get { return deviceConfig; } }
- /// <summary>
- /// YG串口配置
- /// </summary>
- public System.ComponentModel.BindingList<ComConfig> YGConfig { get; set; } = new System.ComponentModel.BindingList<ComConfig>();
- /// <summary>
- /// PLC的配置信息
- /// </summary>
- public System.ComponentModel.BindingList<PLCConfig> PLCConfigs { get; set; } = new System.ComponentModel.BindingList<PLCConfig>();
- /// <summary>
- /// 用户信息配置
- /// </summary>
- public System.ComponentModel.BindingList<UserDefualtList> UserConfigs { get; set; } = new System.ComponentModel.BindingList<UserDefualtList>();
- public System.ComponentModel.BindingList<WeiLiTaskDefaultList> WeiLiTask { get; set; } = new System.ComponentModel.BindingList<WeiLiTaskDefaultList>();
- /// <summary>
- /// 地轨对应的点位
- /// </summary>
- public System.ComponentModel.BindingList<TrainPointDefaultList> PointDefaultList { get; set; } = new System.ComponentModel.BindingList<TrainPointDefaultList>();
- /// <summary>
- /// 版本信息
- /// </summary>
- public VersionDefaultList version { get; set; } = new VersionDefaultList();
- string compath = AppDomain.CurrentDomain.BaseDirectory + "Config\\Com.config";
- string plcpath = AppDomain.CurrentDomain.BaseDirectory + "Config\\PLC.config";
- string boardpath = AppDomain.CurrentDomain.BaseDirectory + "Config\\Board.config";
- string userpath = AppDomain.CurrentDomain.BaseDirectory + "Config\\User.config";
- string verpath = AppDomain.CurrentDomain.BaseDirectory + "Config\\Version.config";
- string machinepath = AppDomain.CurrentDomain.BaseDirectory + "Config\\Machine.config";
- string upath = AppDomain.CurrentDomain.BaseDirectory + "Config\\U.config";
- public DeviceConfig()
- {
- compath.PathIsExist();
- plcpath.PathIsExist();
- boardpath.PathIsExist();
- userpath.PathIsExist();
- verpath.PathIsExist();
- machinepath.PathIsExist();
- upath.PathIsExist();
- PointDefaultList.Add(new TrainPointDefaultList() { Train_Index=9, Point={119,120,121,122, } });
- PointDefaultList.Add(new TrainPointDefaultList() { Train_Index = 1, Point = { 1,2,3,4 } });
- PointDefaultList.Add(new TrainPointDefaultList() { Train_Index = 2, Point = { 5, 6, 7, 8, } });
- PointDefaultList.Add(new TrainPointDefaultList() { Train_Index = 3, Point = { 9, 10, 11, 12, } });
- PointDefaultList.Add(new TrainPointDefaultList() { Train_Index = 4, Point = { 13, 14, 15, 16, } });
- PointDefaultList.Add(new TrainPointDefaultList() { Train_Index = 5, Point = { 17, 18, 19, 20, } });
- PointDefaultList.Add(new TrainPointDefaultList() { Train_Index = 6, Point = { 21, 22, 23, 24, } });
- PointDefaultList.Add(new TrainPointDefaultList() { Train_Index = 7, Point = { 25, 26, 27, 28, } });
- PointDefaultList.Add(new TrainPointDefaultList() { Train_Index = 8, Point = { 29, 30, } });
- PointDefaultList.Add(new TrainPointDefaultList() { Train_Index = 15, Point = { 129 } });
- PointDefaultList.Add(new TrainPointDefaultList() { Train_Index = 10, Point = { 130 } });
- PointDefaultList.Add(new TrainPointDefaultList() { Train_Index = 11, Point = { 131 } });
- PointDefaultList.Add(new TrainPointDefaultList() { Train_Index = 12, Point = { 126 } });
- PointDefaultList.Add(new TrainPointDefaultList() { Train_Index = 13, Point = { 127 } });
- PointDefaultList.Add(new TrainPointDefaultList() { Train_Index =14, Point = { 128 } });
- }
- public void Open()
- {
- //Task.Factory.StartNew(() =>
- // {
- var Tcom = YGConfig.OpenXml(compath);
- if (Tcom != null)
- {
- YGConfig = Tcom;
- }
- var Tplc = PLCConfigs.OpenXml(plcpath);
- if (Tplc != null)
- {
- PLCConfigs = Tplc;
- }
- var user = UserConfigs.OpenXml(userpath);
- if (user != null)
- {
- UserConfigs = user;
- }
- var verus = version.OpenXml(verpath);
- if (verus != null)
- {
- version = verus;
- }
- // });
- }
- public void Save()
- {
- YGConfig.SaveXml(compath);
- PLCConfigs.SaveXml(plcpath);
- UserConfigs.SaveXml(userpath);
- version.SaveXml(verpath);
- YG.Log.Instance.WriteLogAdd("Save");
- }
- }
- }
|