Esempio n. 1
0
        public HeatingController(CommandHandler cmd)
        {
            _cmd          = new PluginsCommandHandler(cmd);
            _cmdUnwrapped = cmd;

            var heatersConfigs = IOconfFile.GetHeater().ToList();

            if (!heatersConfigs.Any())
            {
                return;
            }

            var ovens = IOconfFile.GetOven().ToList();

            foreach (var heater in heatersConfigs)
            {
                _heaters.Add(new HeaterElement(
                                 heater,
                                 ovens.SingleOrDefault(x => x.HeatingElement.Name == heater.Name)));
            }

            cmd.AddCommand("emergencyshutdown", EmergencyShutdown);
            cmd.AddSubsystem(this);
            _heaterCmd = new HeaterCommand(_heaters);
            _heaterCmd.Initialize(new PluginsCommandHandler(cmd), new PluginsLogger("heater"));
            _ovenCmd = new OvenCommand(_heaters, !ovens.Any());
            _ovenCmd.Initialize(new PluginsCommandHandler(cmd), new PluginsLogger("oven"));
            _switchboardController = SwitchBoardController.GetOrCreate(cmd);
        }
        public Alerts(VectorDescription vectorDescription, CommandHandler cmd) : base()
        {
            _cmd = cmd;
            var cmdPlugins = new PluginsCommandHandler(cmd);

            Initialize(cmdPlugins, new PluginsLogger("Alerts"));
            cmdPlugins.AddCommand("removealert", RemoveAlert);
            _alerts = GetAlerts(vectorDescription, cmd);
        }
        public string Title => "SwitchboardActuation"; //not really displayed as this subsystem does not have data points

        private SwitchBoardController(CommandHandler cmd)
        {
            _cmd   = new PluginsCommandHandler(cmd);
            _ports = IOconfFile.GetEntries <IOconfOut230Vac>().Where(p => p.IsSwitchboardControllerOutput).ToList();
            var boardsTemperatures = _ports.GroupBy(p => p.BoxName).Select(b => b.Select(p => p.GetBoardTemperatureInputConf()).FirstOrDefault());
            var sensorPortsInputs  = IOconfFile.GetEntries <IOconfSwitchboardSensor>().SelectMany(i => i.GetExpandedConf());
            var inputs             = _ports.SelectMany(p => p.GetExpandedInputConf()).Concat(boardsTemperatures).Concat(sensorPortsInputs);

            //we register the subsystem before the reader auto registers, ensuring our Run is called first.
            //reason: if there are no boards connected, _reader.Stopping can be raised synchronously
            //        preventing our sub system from running and causing a deadlock as it WaitForLoopStopped.
            cmd.AddSubsystem(this);
            _reader           = new BaseSensorBox(cmd, "switchboards", string.Empty, "show switchboards inputs", inputs);
            _reader.Stopping += WaitForLoopStopped;
            cmd.AddCommand("escape", Stop);
        }