aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Utilities
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2018-08-04 14:35:57 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2018-08-04 14:35:57 +0300
commitdb9119d86fa9e2efd2c3dfab8ac2c49c2ee4da70 (patch)
tree6edfb51c6fde983291a415b8b19a972b2aa78548 /Software/Visual_Studio/Utilities
parent76d311ad4690b9f88ae71ff097c6592190b65012 (diff)
downloadTango-db9119d86fa9e2efd2c3dfab8ac2c49c2ee4da70.tar.gz
Tango-db9119d86fa9e2efd2c3dfab8ac2c49c2ee4da70.zip
Added DB, Observables, PMR Hardware Break Sensors & Break Sensors.
Diffstat (limited to 'Software/Visual_Studio/Utilities')
-rw-r--r--Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs78
-rw-r--r--Software/Visual_Studio/Utilities/Tango.Protobuf.CLI/Program.cs18
2 files changed, 96 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs b/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs
index 274a381a6..c96b94dad 100644
--- a/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs
+++ b/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs
@@ -41,6 +41,8 @@ namespace Tango.PMRGenerator.CLI
GenerateHardwareDispensers(db, pmrFolder);
GenerateHardwareWinders(db, pmrFolder);
GenerateHardwareSpeedSensors(db, pmrFolder);
+ GenerateHardwareBlowers(db, pmrFolder);
+ GenerateHardwareBreakSensors(db, pmrFolder);
GenerateLiquidTypes(db, pmrFolder);
GenerateWindingMethods(db, pmrFolder);
GenerateSpoolTypes(db, pmrFolder);
@@ -291,6 +293,82 @@ namespace Tango.PMRGenerator.CLI
File.WriteAllText(Path.Combine(pmrFolder, "Hardware", messageFile.Name + ".proto"), messageString);
}
+ private static void GenerateHardwareBlowers(ObservablesContext db, String pmrFolder)
+ {
+ Console.WriteLine("Generating Hardware Blower Types...");
+
+ ProtoEnumFile enumFile = new ProtoEnumFile();
+ enumFile.Name = "HardwareBlowerType";
+ enumFile.Package = "Tango.PMR.Hardware";
+
+ foreach (var field in db.HardwareBlowerTypes.ToList().OrderBy(x => x.Code))
+ {
+ enumFile.Fields.Add(new EnumerationField()
+ {
+ Name = field.Name.Replace(" ", ""),
+ Value = field.Code,
+ Description = field.Description,
+ });
+ }
+
+ Console.WriteLine("Generating Hardware Blowers...");
+ ProtoMessageFile messageFile = new ProtoMessageFile();
+ messageFile.Name = "HardwareBlower";
+ messageFile.Package = "Tango.PMR.Hardware";
+ messageFile.Imports.Add("HardwareBlowerType.proto");
+
+ messageFile.Properties.Add(new ProtoProperty("HardwareBlowerType", "HardwareBlowerType"));
+
+ foreach (var prop in typeof(HardwareBlowerType).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(x => x.PropertyType.IsPrimitive))
+ {
+ messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType), GetDbDescription<HardwareBlowerType>(prop)));
+ }
+
+ String enumString = enumFile.GenerateCode();
+ String messageString = messageFile.GenerateCode();
+
+ File.WriteAllText(Path.Combine(pmrFolder, "Hardware", enumFile.Name + ".proto"), enumString);
+ File.WriteAllText(Path.Combine(pmrFolder, "Hardware", messageFile.Name + ".proto"), messageString);
+ }
+
+ private static void GenerateHardwareBreakSensors(ObservablesContext db, String pmrFolder)
+ {
+ Console.WriteLine("Generating Hardware Break Sensor Types...");
+
+ ProtoEnumFile enumFile = new ProtoEnumFile();
+ enumFile.Name = "HardwareBreakSensorType";
+ enumFile.Package = "Tango.PMR.Hardware";
+
+ foreach (var field in db.HardwareBreakSensorTypes.ToList().OrderBy(x => x.Code))
+ {
+ enumFile.Fields.Add(new EnumerationField()
+ {
+ Name = field.Name.Replace(" ", ""),
+ Value = field.Code,
+ Description = field.Description,
+ });
+ }
+
+ Console.WriteLine("Generating Hardware Break Sensor...");
+ ProtoMessageFile messageFile = new ProtoMessageFile();
+ messageFile.Name = "HardwareBreakSensor";
+ messageFile.Package = "Tango.PMR.Hardware";
+ messageFile.Imports.Add("HardwareBreakSensorType.proto");
+
+ messageFile.Properties.Add(new ProtoProperty("HardwareBreakSensorType", "HardwareBreakSensorType"));
+
+ foreach (var prop in typeof(HardwareBreakSensor).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(x => x.PropertyType.IsPrimitive))
+ {
+ messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType), GetDbDescription<HardwareBreakSensor>(prop)));
+ }
+
+ String enumString = enumFile.GenerateCode();
+ String messageString = messageFile.GenerateCode();
+
+ File.WriteAllText(Path.Combine(pmrFolder, "Hardware", enumFile.Name + ".proto"), enumString);
+ File.WriteAllText(Path.Combine(pmrFolder, "Hardware", messageFile.Name + ".proto"), messageString);
+ }
+
private static void GenerateLiquidTypes(ObservablesContext db, String pmrFolder)
{
Console.WriteLine("Generating Dispenser Liquid Types...");
diff --git a/Software/Visual_Studio/Utilities/Tango.Protobuf.CLI/Program.cs b/Software/Visual_Studio/Utilities/Tango.Protobuf.CLI/Program.cs
index 621a6d10f..d0c4ba1fe 100644
--- a/Software/Visual_Studio/Utilities/Tango.Protobuf.CLI/Program.cs
+++ b/Software/Visual_Studio/Utilities/Tango.Protobuf.CLI/Program.cs
@@ -15,6 +15,20 @@ namespace Tango.Protobuf.CLI
{
Console.Title = "Tango Protobuf Compiler";
+#if DEBUG
+
+ if (args.Length == 0)
+ {
+ args = new string[]
+ {
+ "-i ..\\..\\..\\PMR\\Messages",
+ "-o ..\\..\\Tango.PMR",
+ "-l CSharp",
+ };
+ }
+
+#endif
+
if (args.Length == 0)
{
return ExitHelp();
@@ -24,6 +38,10 @@ namespace Tango.Protobuf.CLI
if (CommandLine.Parser.Default.ParseArguments(args, options))
{
+ options.SourceFolder = options.SourceFolder.Trim();
+ options.OutputFolder = options.OutputFolder.Trim();
+ options.Language = options.Language.Trim();
+
if (!Directory.Exists(options.SourceFolder))
{
return ExitError("Could not locate source folder \"" + Path.GetFullPath(options.SourceFolder) + "\"");