static void Main(string[] args) { Parser.Default.ParseArguments <Options>(args) .WithParsed <Options>(o => { if (o.GenerateRTUInfo) { SCD5200TagReader.GenerateRTUTagInfo(o.Input); } InTouchExporter itr = new InTouchExporter(o); //make sure to call the io before the memory so the calcs get deferred correctly itr.ProcessIoDiscreteData(); itr.ProcessIoRealData(); itr.ProcessIoIntegerData(); itr.ProcessMemoryDiscreteData(); itr.ProcessMemoryRealData(); itr.ProcessMemoryIntegerData(); itr.ExportCompleteTagList(); itr.CheckForDuplicateIO(); itr.CheckForDuplicateNames(); itr.CheckCombinationPointsAreCombined(); itr.ValidateFeebackPoints(); itr.CopyRtus(); if (o.Archive != "") { CreateArchive(o); } Console.WriteLine("All done...."); Console.ReadKey(); }); }
public static void GenerateRTUTagInfo(string path = @".\") { var overrideFile = path + "_equipmentoverrides.csv"; DataTable dt = new DataTable(); dt.Columns.Add("RTUName"); dt.Columns.Add("TagName"); dt.Columns.Add("Type"); dt.Columns.Add("Index"); dt.Columns.Add("RelayName"); dt.Columns.Add("RelayAddress"); dt.Columns.Add("ScaleFactor"); dt.Columns.Add("DeviceIndex"); var files = Directory.GetFiles(path + @"rtu\", "*.cfg"); foreach (var file in files) { SCD5200TagReader rtu = new SCD5200TagReader(file); rtu.ReadIeds(); rtu.ProcessTags(dt); } //override the equipment from the equipment map Dictionary <string, string> overrides = new Dictionary <string, string>(); using (CachedCsvReader csv = new CachedCsvReader(new StreamReader(new FileStream(overrideFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)), true)) { while (csv.ReadNextRecord()) { overrides.Add(csv["OldEquipment"], csv["NewEquipment"]); } } for (int i = 0; i < dt.Rows.Count; i++) { string tagName = dt.Rows[i]["TagName"] as string; string equipment = dt.Rows[i]["DeviceIndex"] as string; if (overrides.ContainsKey(equipment)) { dt.Rows[i]["RelayName"] = overrides[equipment]; } else { //TODO: won't need this after sorting out deviceindexdebarcle dt.Rows[i]["RelayName"] = equipment; } } Util.ExportDatatable(dt, path + "_rtutaginfo.csv"); }