public void TestConfig()
 {
     try
     {
         PLCDeviceMonitor.DeviceMonitor monitor = PLCDeviceMonitor.DeviceMonitor.GetPLCDeviceMonitor(config);
     }
     catch (System.Exception ex)
     {
         Assert.Fail(ex.Message);
     }
 }
Exemple #2
0
        /// <summary>
        /// initialize monitor
        /// </summary>
        private void InitializeMonitor(object sender, DoWorkEventArgs e)
        {
            Thread.CurrentThread.Name = "Main";

            InitializeLogger();
            Log.Info("初始化日志系统成功.");

            InitializeConfiguration();
            Log.Info("初始化配置对象成功.");

            monitor = DeviceMonitor.GetPLCDeviceMonitor(config);
        }
        /// <summary>
        /// get device monitor object by given configuration
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static DeviceMonitor GetPLCDeviceMonitor(DeviceMonitorConfig config)
        {
            if (null == config)
            {
                throw new Exception("配置对象为空.");
            }

            DeviceMonitor monitor = new DeviceMonitor();

            monitor.InitializeCommComponent(config.LogicalStationNum);
            monitor.InitializeMonitorInterval(config.MonitorInterval);
            monitor.InitializeRecordLines(config.RecordConfigFilename);
            monitor.InitializeDataProcessor(
                config.BackupFilename,
                config.DBConnectionString,
                config.MsgFormatter,
                config.ValidatePlateCode,
                config.ValidateBoxCode,
                config.ValidateRecordNum,
                config.DBRetryInterval,
                config.DBRetryTimes);

            return(monitor);
        }
        /// <summary>
        /// get device monitor object by given configuration
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static DeviceMonitor GetPLCDeviceMonitor(DeviceMonitorConfig config)
        {
            if (null == config)
                throw new Exception("配置对象为空.");

            DeviceMonitor monitor = new DeviceMonitor();

            monitor.InitializeCommComponent(config.LogicalStationNum);
            monitor.InitializeMonitorInterval(config.MonitorInterval);
            monitor.InitializeRecordLines(config.RecordConfigFilename);
            monitor.InitializeDataProcessor(
                config.BackupFilename,
                config.DBConnectionString,
                config.MsgFormatter,
                config.ValidatePlateCode,
                config.ValidateBoxCode,
                config.ValidateRecordNum,
                config.DBRetryInterval,
                config.DBRetryTimes);

            return monitor;
        }
Exemple #5
0
        /// <summary>
        /// initialize monitor
        /// </summary>
        private void InitializeMonitor(object sender, DoWorkEventArgs e)
        {
            Thread.CurrentThread.Name = "Main";

            InitializeLogger();
            Log.Info("初始化日志系统成功.");

            InitializeConfiguration();
            Log.Info("初始化配置对象成功.");

            monitor = DeviceMonitor.GetPLCDeviceMonitor(config);
        }