aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Utilities/Tango.AlarmParametersGenerator/Program.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-07-03 12:39:41 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-07-03 12:39:41 +0300
commit06278889e794cdbbd366c106c32346d878e31b05 (patch)
tree10b7742cfee1a20529690ed861cecd295d12e2c5 /Software/Visual_Studio/Utilities/Tango.AlarmParametersGenerator/Program.cs
parentf64700dc57cbdd1d1ccceeeff9821e9809c50265 (diff)
downloadTango-06278889e794cdbbd366c106c32346d878e31b05.tar.gz
Tango-06278889e794cdbbd366c106c32346d878e31b05.zip
Implemented alarm_gen
Diffstat (limited to 'Software/Visual_Studio/Utilities/Tango.AlarmParametersGenerator/Program.cs')
-rw-r--r--Software/Visual_Studio/Utilities/Tango.AlarmParametersGenerator/Program.cs45
1 files changed, 37 insertions, 8 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.AlarmParametersGenerator/Program.cs b/Software/Visual_Studio/Utilities/Tango.AlarmParametersGenerator/Program.cs
index 027f2fc73..04d6acb5b 100644
--- a/Software/Visual_Studio/Utilities/Tango.AlarmParametersGenerator/Program.cs
+++ b/Software/Visual_Studio/Utilities/Tango.AlarmParametersGenerator/Program.cs
@@ -50,18 +50,36 @@ namespace Tango.AlarmParametersGenerator
static void Main(string[] args)
{
+ var color = Console.ForegroundColor;
+
try
{
- if (args.Count() == 0)
+
+ var options = new Options();
+
+ if (!CommandLine.Parser.Default.ParseArguments(args, options))
{
- throw new ArgumentException("Please specify an output file path");
+ ExitError();
+ return;
}
- String outputFile = args[0];
+ if (!File.Exists(options.ExcelFile))
+ {
+ throw new FileNotFoundException($"Could not locate excel file '{Path.GetFullPath(options.ExcelFile)}'.");
+ }
+
+ Console.WriteLine();
Console.WriteLine("Generating alarm parameters file...");
- ExcelReader reader = new ExcelReader(PathHelper.GetStartupPath() + "\\Tango alarm events handling chart_Rev8.xlsx");
+ Console.WriteLine();
+
+ Console.WriteLine($"Source: {Path.GetFullPath(options.ExcelFile)}");
+ Console.WriteLine($"Target: {Path.GetFullPath(options.OutputFile)}");
+
+ Console.WriteLine();
+
+ ExcelReader reader = new ExcelReader(options.ExcelFile);
var results = reader.GetDataByIndex<ExcelEventType>("ALARM EVENTS HANDLING", 2);
AlarmParameters parameters = new AlarmParameters();
@@ -70,7 +88,7 @@ namespace Tango.AlarmParametersGenerator
{
if (!String.IsNullOrWhiteSpace(item.Source))
{
- Console.WriteLine($"Parsing event {item.Code}...");
+ Console.WriteLine($"Parsing event {item.Code}, {item.Name}...");
AlarmHandlingItem alarm = new AlarmHandlingItem();
alarm.AlarmSource = item.Source.ToEnum<AlarmSourceType>();
@@ -88,17 +106,28 @@ namespace Tango.AlarmParametersGenerator
}
}
- File.WriteAllBytes(outputFile, parameters.ToBytes());
+ Console.WriteLine("Writing file...");
+ File.WriteAllBytes(options.OutputFile, parameters.ToBytes());
+
+ Console.WriteLine("Validating file...");
+ AlarmParameters checkParameters = AlarmParameters.Parser.ParseFrom(File.ReadAllBytes(options.OutputFile));
Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("File generated successfully!");
+ Console.WriteLine("File generated successfully.");
+ Console.ForegroundColor = color;
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.Message);
+ Console.ForegroundColor = color;
}
}
+
+ private static void ExitError()
+ {
+ Environment.Exit(-1);
+ }
}
public static class Extensions
@@ -118,4 +147,4 @@ namespace Tango.AlarmParametersGenerator
return String.IsNullOrWhiteSpace(str) ? false : (str.Contains("0") ? false : true);
}
}
-}
+} \ No newline at end of file