Exemple #1
0
        /// <summary>
        /// Инициализация переменных.
        /// </summary>
        public void Init()
        {
            Version = "v1.0.1";

            InitTime = DateTime.Now;

            string fileName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location);

            varXml = new VarXml(string.Format("{0}.xml", fileName));
            varXml.LoadFromXML();

            CollectionWithUnits = new XPCollectionWithUnits();
            DeviceCollection    = (CollectionWithUnits.Add(typeof(Device))).Collection;

            DeviceRealCollection = new Collection <DeviceReal>();

            CopyDataToReal();

            // Отправка значений на интерфейс.
            foreach (DeviceReal deviceReal in DeviceRealCollection)
            {
                deviceReal.SendDataToXPObject();
            }

            ThreadMain              = new ThreadTimer();
            ThreadMain.Period       = varXml.ThreadMainPeriod;
            ThreadMain.WorkChanged += new EventHandler(ThreadMain_WorkChanged);
            ThreadMain.Run();

            ThreadMainDelay = varXml.ThreadMainDelay;
            AppName         = varXml.AppName;

            WorkerReboot         = new BackgroundWorker();
            WorkerReboot.DoWork += new DoWorkEventHandler(WorkerReboot_DoWork);
        }
Exemple #2
0
        /// <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;
        }