Exemple #1
0
        public Acquisition(IReadCommandEnqueuer readCommandEnqueuer, SCADAModel scadaModel)
        {
            this.readCommandEnqueuer = readCommandEnqueuer;
            this.scadaModel          = scadaModel;
            this.scadaConfig         = SCADAConfigData.Instance;

            InitializeAcquisitionThread();
        }
        /// <summary>
        /// Stops all instances of ModbusServer.
        /// </summary>
        public static void StopModbusSimulaotrs()
        {
            try
            {
                ISCADAConfigData config           = SCADAConfigData.Instance;
                Process[]        modbusSimulators = Process.GetProcessesByName(config.ModbusSimulatorExeName.Replace(".exe", ""));

                foreach (Process mdbSim in modbusSimulators)
                {
                    mdbSim.Kill();
                }
            }
            catch (Exception e)
            {
                LoggerWrapper.Instance.LogWarn("Exception on stoping modbus simulators.", e);
            }
        }
        /// <summary>
        /// Starts new ModbusServer if one is not already opened.
        /// </summary>
        public static void StartModbusSimulator()
        {
            try
            {
                ISCADAConfigData config           = SCADAConfigData.Instance;
                Process[]        modbusSimulators = Process.GetProcessesByName(config.ModbusSimulatorExeName.Replace(".exe", ""));

                if (modbusSimulators.Length == 0)
                {
                    Process process = new Process();
                    process.StartInfo.FileName = config.ModbusSimulatorExePath;
                    process.Start();
                }
            }
            catch (Exception e)
            {
                LoggerWrapper.Instance.LogWarn("Exception on starting modbus simulator.", e);
            }
        }