using IniParser.Model; using System; namespace Barsik { class BaseMonitoringUnit { protected SectionData config; protected RegistersContainer registers; protected int baseAddress; public BaseMonitoringUnit(SectionData config, RegistersContainer registers) { this.config = config; this.registers = registers; baseAddress = int.Parse(config.Keys["BaseAddress"]); } public virtual void Run() { } public static BaseMonitoringUnit Create(SectionData config, RegistersContainer registers) { var type = config.Keys["Type"]; if (type == "Sensors") { return new SensorsMonitoringUnit(config, registers); } else if (type == "MDStat") { return new MDStatMonitoringUnit(config, registers); } else { Console.WriteLine("Unknown unit type " + type); return null; } } } }