/// <summary> /// Инициализация переменных. /// </summary> public void Init() { Version = "v1.21.14"; InitTime = DateTime.Now; varXml = new VarXml("Config.xml"); varXml.LoadFromXML(); CollectionWithUnits = new XPCollectionWithUnits(); DataSourceCollection = (CollectionWithUnits.Add(typeof(DataSource))).Collection; StatisticsCollection = (CollectionWithUnits.Add(typeof(Statistics))).Collection; OPCServerCollection = (CollectionWithUnits.Add(typeof(OPCServer))).Collection; VzljotCollection = (CollectionWithUnits.Add(typeof(Vzljot))).Collection; DDEServerCollection = (CollectionWithUnits.Add(typeof(DDEServer))).Collection; TechnographCollection = (CollectionWithUnits.Add(typeof(Technograph))).Collection; PingServerCollection = (CollectionWithUnits.Add(typeof(PingServer))).Collection; KMAZSServerCollection = (CollectionWithUnits.Add(typeof(KMAZSServer))).Collection; ItemCollection = (CollectionWithUnits.Add(typeof(Item))).Collection; SQLServerCollection = (CollectionWithUnits.Add(typeof(SQLServer))).Collection; SQLServerItemForceCollection = (CollectionWithUnits.Add(typeof(SQLServerItemForceCollection))).Collection; DataSourceRealCollection = new CollectionEx <DataSourceReal>(); StatisticsRealCollection = new CollectionEx <StatisticsReal>(); OPCServerRealCollection = new CollectionEx <OPCServerReal>(); VzljotRealCollection = new CollectionEx <VzljotReal>(); DDEServerRealCollection = new CollectionEx <DDEServerReal>(); TechnographRealCollection = new CollectionEx <TechnographReal>(); PingServerRealCollection = new CollectionEx <PingServerReal>(); KMAZSServerRealCollection = new CollectionEx <KMAZSServerReal>(); ItemRealCollection = new Collection <ItemReal>(); SQLServerRealCollection = new CollectionEx <SQLServerReal>(); CopyDataToReal(); ThreadMainFautCount = 0; ThreadMain = new ThreadTimer() { Period = varXml.ThreadMainPeriod }; ThreadMain.WorkChanged += ThreadMain_WorkChanged; ThreadMain.Run(); ThreadMainDelay = varXml.ThreadMainDelay; AppName = varXml.AppName; WorkerReboot = new BackgroundWorker(); WorkerReboot.DoWork += WorkerReboot_DoWork; }
/// <summary> /// Загрузить данные из XML-файла. /// </summary> /// <returns></returns> public void LoadFromXML() { if (File.Exists(FilePath)) { XmlSerializer deserializer = new XmlSerializer(typeof(VarXml)); TextReader textReader = new StreamReader(FilePath); VarXml obj = (VarXml)deserializer.Deserialize(textReader); textReader.Close(); ThreadMainPeriod = obj.ThreadMainPeriod; ThreadMainDelay = obj.ThreadMainDelay; AppName = obj.AppName; } }
public SettingView() { InitializeComponent(); varXml = new VarXml("Config.xml"); }