diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-03-09 18:42:17 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-03-09 18:42:17 +0200 |
| commit | dff40538d054551a74034b473f9f0e0c3590bcd0 (patch) | |
| tree | 9952c19885d3fadfd075b262b9757610ffe1771c /Software/Visual_Studio/Utilities | |
| parent | da4accf92a46df56b0c2fa0e08d76aa278a72083 (diff) | |
| download | Tango-dff40538d054551a74034b473f9f0e0c3590bcd0.tar.gz Tango-dff40538d054551a74034b473f9f0e0c3590bcd0.zip | |
BIT DB, BL, PMR, OverrideData.xml, Emulator Handling, BitTypeGenerator.
Diffstat (limited to 'Software/Visual_Studio/Utilities')
6 files changed, 279 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Utilities/BitTypesGenerator.CLI/App.config b/Software/Visual_Studio/Utilities/BitTypesGenerator.CLI/App.config new file mode 100644 index 000000000..4ef5218a0 --- /dev/null +++ b/Software/Visual_Studio/Utilities/BitTypesGenerator.CLI/App.config @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <configSections> + <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> + <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> + </configSections> + <startup> + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> + </startup> + <entityFramework> + <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> + <providers> + <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> + </providers> + </entityFramework> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/BitTypesGenerator.CLI/BitTypesGenerator.CLI.csproj b/Software/Visual_Studio/Utilities/BitTypesGenerator.CLI/BitTypesGenerator.CLI.csproj new file mode 100644 index 000000000..863fde776 --- /dev/null +++ b/Software/Visual_Studio/Utilities/BitTypesGenerator.CLI/BitTypesGenerator.CLI.csproj @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{B356201F-F958-4AC9-BBEB-E4EAE9DA9EC6}</ProjectGuid> + <OutputType>Exe</OutputType> + <RootNamespace>BitTypesGenerator.CLI</RootNamespace> + <AssemblyName>BitTypesGenerator.CLI</AssemblyName> + <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> + <Deterministic>true</Deterministic> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> + <HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath> + </Reference> + <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> + <HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.ComponentModel.DataAnnotations" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="..\..\Resources\BIT\BuiltInTest.xlsx"> + <Link>BuiltInTest.xlsx</Link> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="App.config" /> + <None Include="packages.config" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\Tango.BL\Tango.BL.csproj"> + <Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project> + <Name>Tango.BL</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.Core\Tango.Core.csproj"> + <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> + <Name>Tango.Core</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.Documents\Tango.Documents.csproj"> + <Project>{ca87a608-7b17-4c98-88f2-42abee10f4c1}</Project> + <Name>Tango.Documents</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/BitTypesGenerator.CLI/Program.cs b/Software/Visual_Studio/Utilities/BitTypesGenerator.CLI/Program.cs new file mode 100644 index 000000000..5a838bc92 --- /dev/null +++ b/Software/Visual_Studio/Utilities/BitTypesGenerator.CLI/Program.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.Core.ExtensionMethods; +using Tango.Core.Helpers; +using Tango.Documents; + +namespace BitTypesGenerator.CLI +{ + class Program + { + private static string BITS_FILE = "BuiltInTest.xlsx"; + + private class ExcelBitType + { + public String Code { get; set; } + public String Name { get; set; } + public String Subject { get; set; } + public String Index { get; set; } + public String TestType { get; set; } + + public override string ToString() + { + return this.ToJsonString(); + } + } + + static void Main(string[] args) + { + Console.WriteLine("Generating BIT types..."); + + ExcelReader reader = new ExcelReader(PathHelper.GetStartupPath() + "\\" + BITS_FILE); + var results = reader.GetDataByIndex<ExcelBitType>("Sheet1", 2); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + foreach (var excelBit in results) + { + bool isNewBit = false; + + int code = int.Parse(excelBit.Code); + + BitType bitType = db.BitTypes.SingleOrDefault(x => x.Code == code); + + if (bitType == null) + { + Console.WriteLine("Inserting " + excelBit.ToString()); + bitType = new BitType(); + MapExcelBitToBitType(excelBit, bitType); + isNewBit = true; + } + else + { + if (BitRequiresUpdate(excelBit, bitType)) + { + BitType te = new BitType(); + MapExcelBitToBitType(excelBit, te); + Console.WriteLine($"Updating {bitType.Name}\nSource:\n{te.ToJsonString()}\nTarget:\n{bitType.ToJsonString()}"); + MapExcelBitToBitType(excelBit, bitType); + } + } + + if (isNewBit) + { + db.BitTypes.Add(bitType); + } + } + + + Console.WriteLine("Saving changes..."); + db.SaveChanges(); + } + + Console.WriteLine("Done!"); + Console.ReadLine(); + } + + private static void MapExcelBitToBitType(ExcelBitType evx, BitType bit) + { + bit.Code = int.Parse(evx.Code); + bit.Name = evx.Name; + bit.Subject = evx.Subject; + bit.ComponentIndex = evx.Index.IsNotNullOrEmpty() ? int.Parse(evx.Index) : -1; + bit.TestType = int.Parse(evx.TestType); + } + + private static bool BitRequiresUpdate(ExcelBitType evx, BitType bit) + { + BitType te = new BitType(); + MapExcelBitToBitType(evx, te); + + if (te.Code != bit.Code) return true; + if (te.Name != bit.Name) return true; + if (te.Subject != bit.Subject) return true; + if (te.ComponentIndex != bit.ComponentIndex) return true; + if (te.TestType != bit.TestType) return true; + + return false; + } + } +} diff --git a/Software/Visual_Studio/Utilities/BitTypesGenerator.CLI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Utilities/BitTypesGenerator.CLI/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..e9125e808 --- /dev/null +++ b/Software/Visual_Studio/Utilities/BitTypesGenerator.CLI/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("BitTypesGenerator.CLI")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("BitTypesGenerator.CLI")] +[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b356201f-f958-4ac9-bbeb-e4eae9da9ec6")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/Utilities/BitTypesGenerator.CLI/packages.config b/Software/Visual_Studio/Utilities/BitTypesGenerator.CLI/packages.config new file mode 100644 index 000000000..b3daf0d6c --- /dev/null +++ b/Software/Visual_Studio/Utilities/BitTypesGenerator.CLI/packages.config @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="EntityFramework" version="6.2.0" targetFramework="net461" /> +</packages>
\ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs b/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs index b2ddc9c7d..040559fdb 100644 --- a/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs +++ b/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs @@ -58,6 +58,7 @@ namespace Tango.PMRGenerator.CLI GenerateDiagnosticsMonitors(db, pmrFolder); GenerateInsightsMonitors(db, pmrFolder); GenerateEventTypes(db, pmrFolder); + GenerateBitTypes(db, pmrFolder); GenerateInterfaceIOs(db, pmrFolder); GenerateBtsrApplicationTypes(db, pmrFolder); GenerateBtsrYarnTypes(db, pmrFolder); @@ -758,6 +759,36 @@ namespace Tango.PMRGenerator.CLI File.WriteAllText(Path.Combine(pmrFolder, "Diagnostics", enumFile.Name + ".proto"), enumString); } + private static void GenerateBitTypes(ObservablesContext db, String pmrFolder) + { + Console.WriteLine("Generating BIT Types..."); + + ProtoEnumFile enumFile = new ProtoEnumFile(); + enumFile.Name = "BitType"; + enumFile.Package = "Tango.PMR.Diagnostics"; + + enumFile.Fields.Add(new EnumerationField() + { + Name = "Unspecified_Bit", + Description = "Must contain a 0 value", + Value = 0, + }); + + foreach (var field in db.BitTypes.ToList().OrderBy(x => x.Code)) + { + enumFile.Fields.Add(new EnumerationField() + { + Name = field.Name.Replace(" ", ""), + Description = field.Name, + Value = field.Code, + }); + } + + String enumString = enumFile.GenerateCode(); + + File.WriteAllText(Path.Combine(pmrFolder, "Diagnostics", enumFile.Name + ".proto"), enumString); + } + private static String CoercePropertyType(Type type) { if (type == typeof(bool)) |
