aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-07-10 15:24:06 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-07-10 15:24:06 +0300
commit5d795170b304199383ac967583830acaf313ff05 (patch)
treef8888b3ae72410a02a4b7361c235540138950ac8 /Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI
parent9244c34a40d572f071cdf1c00ad6428132e1ab5c (diff)
downloadTango-5d795170b304199383ac967583830acaf313ff05.tar.gz
Tango-5d795170b304199383ac967583830acaf313ff05.zip
Some work on PPC.
Implemented retrieval of column description for auto generated observables & pmr's.
Diffstat (limited to 'Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI')
-rw-r--r--Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs38
1 files changed, 31 insertions, 7 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs b/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs
index ae18bb6f4..274a381a6 100644
--- a/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs
+++ b/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs
@@ -8,11 +8,16 @@ using System.Threading.Tasks;
using Tango.CodeGeneration;
using Tango.BL.Entities;
using Tango.BL;
+using static Tango.Core.Components.DataBaseDescriptionsHelper;
+using Tango.Core.Components;
+using System.ComponentModel.DataAnnotations.Schema;
namespace Tango.PMRGenerator.CLI
{
class Program
{
+ private static List<DbDescription> _dbDescriptions;
+
static void Main(string[] args)
{
Console.Title = "Tango PMR Generator";
@@ -25,6 +30,10 @@ namespace Tango.PMRGenerator.CLI
using (ObservablesContext db = ObservablesContext.CreateDefault())
{
+ db.Database.Connection.Open();
+
+ _dbDescriptions = DataBaseDescriptionsHelper.GetDescriptions(db.Database.Connection);
+
db.Configuration.LazyLoadingEnabled = true;
GenerateHardwareMotors(db, pmrFolder);
GenerateHardwareDancers(db, pmrFolder);
@@ -75,7 +84,7 @@ namespace Tango.PMRGenerator.CLI
foreach (var prop in typeof(HardwareMotor).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(x => x.PropertyType.IsPrimitive))
{
- messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType)));
+ messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType), GetDbDescription<HardwareMotor>(prop)));
}
String enumString = enumFile.GenerateCode();
@@ -114,7 +123,7 @@ namespace Tango.PMRGenerator.CLI
foreach (var prop in typeof(HardwareDancer).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(x => x.PropertyType.IsPrimitive))
{
- messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType)));
+ messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType), GetDbDescription<HardwareDancer>(prop)));
}
String enumString = enumFile.GenerateCode();
@@ -153,7 +162,7 @@ namespace Tango.PMRGenerator.CLI
foreach (var prop in typeof(HardwarePidControl).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(x => x.PropertyType.IsPrimitive))
{
- messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType)));
+ messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType), GetDbDescription<HardwarePidControl>(prop)));
}
String enumString = enumFile.GenerateCode();
@@ -195,7 +204,7 @@ namespace Tango.PMRGenerator.CLI
{
if (prop.Name != "Name" && prop.Name != "Code")
{
- messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType)));
+ messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType), GetDbDescription<DispenserType>(prop)));
}
}
@@ -234,7 +243,7 @@ namespace Tango.PMRGenerator.CLI
foreach (var prop in typeof(HardwareWinder).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(x => x.PropertyType.IsPrimitive))
{
- messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType)));
+ messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType), GetDbDescription<HardwareWinder>(prop)));
}
String enumString = enumFile.GenerateCode();
@@ -272,7 +281,7 @@ namespace Tango.PMRGenerator.CLI
foreach (var prop in typeof(HardwareSpeedSensor).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(x => x.PropertyType.IsPrimitive))
{
- messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType)));
+ messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType), GetDbDescription<HardwareSpeedSensor>(prop)));
}
String enumString = enumFile.GenerateCode();
@@ -376,7 +385,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 ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType)));
+ messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType), GetDbDescription<ProcessParametersTable>(prop)));
}
String messageString = messageFile.GenerateCode();
@@ -520,5 +529,20 @@ namespace Tango.PMRGenerator.CLI
return type.Name.ToLower();
}
}
+
+ private static String GetDbDescription<T>(PropertyInfo prop)
+ {
+ String tableName = typeof(T).GetCustomAttribute<TableAttribute>().Name;
+ String columnName = prop.GetCustomAttribute<ColumnAttribute>().Name;
+
+ var db_des = _dbDescriptions.FirstOrDefault(x => x.TableName == tableName && x.ColumnName == columnName);
+
+ if (db_des != null)
+ {
+ return db_des.ColumnDescription.ToLines().Take(1).Concat(db_des.ColumnDescription.ToLines().Skip(1).Select(x => "//" + x)).Join(Environment.NewLine);
+ }
+
+ return null;
+ }
}
}