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 static SwitchBoardController GetOrCreate(CommandHandler cmd) { if (_instance != null) { return(_instance); } lock (ControllerInitializationLock) { if (_instance != null) { return(_instance); } return(_instance = new SwitchBoardController(cmd)); } }