diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-03-13 15:27:16 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-03-13 15:27:16 +0200 |
| commit | 37b740c1d128d694b9dcbc3669808435b5d88fec (patch) | |
| tree | e94cc6ddc9712dfdad00b7d6041606a0e024e65a /Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI | |
| parent | e75cf513acb73558e948d6012b45f221c718dcf7 (diff) | |
| download | Tango-37b740c1d128d694b9dcbc3669808435b5d88fec.tar.gz Tango-37b740c1d128d694b9dcbc3669808435b5d88fec.zip | |
Implemented Gauge Control & Technician module controller item !
Auto generated diagnostics monitors & controllers PMR.
Diffstat (limited to 'Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI')
| -rw-r--r-- | Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs | 91 |
1 files changed, 78 insertions, 13 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs b/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs index 6fc87e085..b782952a9 100644 --- a/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs +++ b/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs @@ -36,6 +36,8 @@ namespace Tango.PMRGenerator.CLI GenerateColorLabColorSpaces(db, pmrFolder); GenerateColorLabLiquidTypes(db, pmrFolder); + GenerateDiagnosticsValueComponents(db, pmrFolder); + GenerateDiagnosticsMonitors(db, pmrFolder); } Console.WriteLine("Done"); @@ -55,6 +57,7 @@ namespace Tango.PMRGenerator.CLI { Name = field.Name.Replace(" ", ""), Value = field.Code, + Description = field.Description, }); } @@ -64,11 +67,11 @@ namespace Tango.PMRGenerator.CLI messageFile.Package = "Tango.PMR.Hardware"; messageFile.Imports.Add("HardwareMotorType.proto"); - messageFile.Properties.Add(new Property("HardwareMotorType", "HardwareMotorType")); + messageFile.Properties.Add(new ProtoProperty("HardwareMotorType", "HardwareMotorType")); foreach (var prop in typeof(HardwareMotor).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(x => x.PropertyType.IsPrimitive)) { - messageFile.Properties.Add(new Property(prop.Name, CoercePropertyType(prop.PropertyType))); + messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType))); } String enumString = enumFile.GenerateCode(); @@ -92,6 +95,7 @@ namespace Tango.PMRGenerator.CLI { Name = field.Name.Replace(" ", ""), Value = field.Code, + Description = field.Description, }); } @@ -102,11 +106,11 @@ namespace Tango.PMRGenerator.CLI messageFile.Package = "Tango.PMR.Hardware"; messageFile.Imports.Add("HardwareDancerType.proto"); - messageFile.Properties.Add(new Property("HardwareDancerType", "HardwareDancerType")); + messageFile.Properties.Add(new ProtoProperty("HardwareDancerType", "HardwareDancerType")); foreach (var prop in typeof(HardwareDancer).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(x => x.PropertyType.IsPrimitive)) { - messageFile.Properties.Add(new Property(prop.Name, CoercePropertyType(prop.PropertyType))); + messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType))); } String enumString = enumFile.GenerateCode(); @@ -130,6 +134,7 @@ namespace Tango.PMRGenerator.CLI { Name = field.Name.Replace(" ", ""), Value = field.Code, + Description = field.Description, }); } @@ -140,11 +145,11 @@ namespace Tango.PMRGenerator.CLI messageFile.Package = "Tango.PMR.Hardware"; messageFile.Imports.Add("HardwarePidControlType.proto"); - messageFile.Properties.Add(new Property("HardwarePidControlType", "HardwarePidControlType")); + messageFile.Properties.Add(new ProtoProperty("HardwarePidControlType", "HardwarePidControlType")); foreach (var prop in typeof(HardwarePidControl).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(x => x.PropertyType.IsPrimitive)) { - messageFile.Properties.Add(new Property(prop.Name, CoercePropertyType(prop.PropertyType))); + messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType))); } String enumString = enumFile.GenerateCode(); @@ -178,13 +183,13 @@ namespace Tango.PMRGenerator.CLI messageFile.Package = "Tango.PMR.Hardware"; messageFile.Imports.Add("HardwareDispenserType.proto"); - messageFile.Properties.Add(new Property("HardwareDispenserType", "HardwareDispenserType")); + messageFile.Properties.Add(new ProtoProperty("HardwareDispenserType", "HardwareDispenserType")); foreach (var prop in typeof(DispenserType).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(x => x.PropertyType.IsPrimitive)) { if (prop.Name != "Name" && prop.Name != "Code") { - messageFile.Properties.Add(new Property(prop.Name, CoercePropertyType(prop.PropertyType))); + messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType))); } } @@ -209,6 +214,7 @@ namespace Tango.PMRGenerator.CLI { Name = field.Name.Replace(" ", ""), Value = field.Code, + Description = field.Description, }); } @@ -218,11 +224,11 @@ namespace Tango.PMRGenerator.CLI messageFile.Package = "Tango.PMR.Hardware"; messageFile.Imports.Add("HardwareWinderType.proto"); - messageFile.Properties.Add(new Property("HardwareWinderType", "HardwareWinderType")); + messageFile.Properties.Add(new ProtoProperty("HardwareWinderType", "HardwareWinderType")); foreach (var prop in typeof(HardwareWinder).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(x => x.PropertyType.IsPrimitive)) { - messageFile.Properties.Add(new Property(prop.Name, CoercePropertyType(prop.PropertyType))); + messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType))); } String enumString = enumFile.GenerateCode(); @@ -268,6 +274,7 @@ namespace Tango.PMRGenerator.CLI { Name = field.Name.Replace(" ", ""), Value = field.Code, + Description = field.Description, }); } @@ -299,13 +306,13 @@ namespace Tango.PMRGenerator.CLI messageFile.Package = "Tango.PMR.Printing"; messageFile.Imports.Add("JobSpoolType.proto"); - messageFile.Properties.Add(new Property("JobSpoolType", "JobSpoolType")); + messageFile.Properties.Add(new ProtoProperty("JobSpoolType", "JobSpoolType")); foreach (var prop in typeof(SpoolType).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(x => x.PropertyType.IsPrimitive)) { if (prop.Name != "Name" && prop.Name != "Code") { - messageFile.Properties.Add(new Property(prop.Name, CoercePropertyType(prop.PropertyType))); + messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType))); } } @@ -325,7 +332,7 @@ namespace Tango.PMRGenerator.CLI foreach (var prop in typeof(ProcessParametersTable).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(x => x.PropertyType.IsPrimitive)) { - messageFile.Properties.Add(new Property(prop.Name, CoercePropertyType(prop.PropertyType))); + messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType))); } String messageString = messageFile.GenerateCode(); @@ -377,6 +384,64 @@ namespace Tango.PMRGenerator.CLI File.WriteAllText(Path.Combine(pmrFolder, "ColorLab", enumFile.Name + ".proto"), enumString); } + private static void GenerateDiagnosticsValueComponents(ObservablesContext db, String pmrFolder) + { + Console.WriteLine("Generating Diagnostics Value Component..."); + + ProtoEnumFile enumFile = new ProtoEnumFile(); + enumFile.Name = "ValueComponent"; + enumFile.Package = "Tango.PMR.Diagnostics"; + + foreach (var field in db.TechControllers.ToList().OrderBy(x => x.Code)) + { + enumFile.Fields.Add(new EnumerationField() + { + Name = field.Name.Replace(" ", ""), + Description = field.Description + String.Format(" (Min = {0}, Max = {1})", field.Min, field.Max), + Value = field.Code, + }); + } + + String enumString = enumFile.GenerateCode(); + + File.WriteAllText(Path.Combine(pmrFolder, "Diagnostics", enumFile.Name + ".proto"), enumString); + } + + private static void GenerateDiagnosticsMonitors(ObservablesContext db, String pmrFolder) + { + Console.WriteLine("Generating Monitors..."); + + ProtoMessageFile messageFile = new ProtoMessageFile(); + messageFile.Name = "DiagnosticsMonitors"; + messageFile.Package = "Tango.PMR.Diagnostics"; + + messageFile.Imports.Add("DoubleArray.proto"); + + foreach (var monitor in db.TechMonitors.ToList().OrderBy(x => x.Code)) + { + var prop = new ProtoProperty(); + prop.Name = monitor.Name.Replace(" ", ""); + prop.Description = monitor.Description + String.Format(" (Min = {0}, Max = {1}, PPF = {2})", monitor.Min, monitor.Max, monitor.PointsPerFrame); + prop.Repeated = true; + + if (!monitor.MultiChannel) + { + prop.Type = "double"; + } + else + { + prop.Type = "DoubleArray"; + prop.Description += String.Format(" Channel Count = {0}", monitor.ChannelCount); + } + + messageFile.Properties.Add(prop); + } + + String messageString = messageFile.GenerateCode(); + + File.WriteAllText(Path.Combine(pmrFolder, "Diagnostics", messageFile.Name + ".proto"), messageString); + } + private static String CoercePropertyType(Type type) { if (type == typeof(bool)) |
