From 74ea6d4794eb74b09bba393c947d788d2bad38bb Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 4 Sep 2023 22:38:03 +0100 Subject: [PATCH] Netproc.Data added wire colour and name (color or voltage) Left and Right. Added IsOptoSwitch to SwitchConfig to display these different in a UI --- .github/workflows/dotnet_nuget.yml | 2 +- Directory.Build.props | 2 +- ...ner.cs => 20230904213441_Init.Designer.cs} | 5 ++- ...4202742_Init.cs => 20230904213441_Init.cs} | 1 + .../NetProcDbContextModelSnapshot.cs | 3 ++ NetProc.Data/NetProcDbContext.cs | 35 ++++++++++++------- .../MachineConfig/SwitchConfigFileEntry.cs | 4 +++ 7 files changed, 37 insertions(+), 15 deletions(-) rename NetProc.Data/Migrations/{20230904202742_Init.Designer.cs => 20230904213441_Init.Designer.cs} (98%) rename NetProc.Data/Migrations/{20230904202742_Init.cs => 20230904213441_Init.cs} (99%) diff --git a/.github/workflows/dotnet_nuget.yml b/.github/workflows/dotnet_nuget.yml index f231cbea..cda61953 100644 --- a/.github/workflows/dotnet_nuget.yml +++ b/.github/workflows/dotnet_nuget.yml @@ -52,7 +52,7 @@ jobs: - name: Publish uses: softprops/action-gh-release@v1 with: - tag_name: "1.0.31" + tag_name: "1.0.32" files: "NetProc-*" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Directory.Build.props b/Directory.Build.props index cb0dc197..bf6ba1ad 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 1.0.31 + 1.0.32 $(VersionSuffix) $(VersionSuffix) $(VersionSuffix) diff --git a/NetProc.Data/Migrations/20230904202742_Init.Designer.cs b/NetProc.Data/Migrations/20230904213441_Init.Designer.cs similarity index 98% rename from NetProc.Data/Migrations/20230904202742_Init.Designer.cs rename to NetProc.Data/Migrations/20230904213441_Init.Designer.cs index 8a27e515..50618aae 100644 --- a/NetProc.Data/Migrations/20230904202742_Init.Designer.cs +++ b/NetProc.Data/Migrations/20230904213441_Init.Designer.cs @@ -9,7 +9,7 @@ namespace NetProc.Data.Migrations { [DbContext(typeof(NetProcDbContext))] - [Migration("20230904202742_Init")] + [Migration("20230904213441_Init")] partial class Init { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -312,6 +312,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("DisplayName") .HasColumnType("TEXT"); + b.Property("IsOptoSwitch") + .HasColumnType("INTEGER"); + b.Property("Name") .IsRequired() .HasColumnType("TEXT"); diff --git a/NetProc.Data/Migrations/20230904202742_Init.cs b/NetProc.Data/Migrations/20230904213441_Init.cs similarity index 99% rename from NetProc.Data/Migrations/20230904202742_Init.cs rename to NetProc.Data/Migrations/20230904213441_Init.cs index c5e30ccc..789cd0bd 100644 --- a/NetProc.Data/Migrations/20230904202742_Init.cs +++ b/NetProc.Data/Migrations/20230904213441_Init.cs @@ -154,6 +154,7 @@ protected override void Up(MigrationBuilder migrationBuilder) WireRColourName = table.Column(nullable: true), Name = table.Column(nullable: false), Type = table.Column(nullable: false), + IsOptoSwitch = table.Column(nullable: false), Tags = table.Column(nullable: true), SearchReset = table.Column(nullable: true), SearchStop = table.Column(nullable: true) diff --git a/NetProc.Data/Migrations/NetProcDbContextModelSnapshot.cs b/NetProc.Data/Migrations/NetProcDbContextModelSnapshot.cs index 47f6ade1..dac487e5 100644 --- a/NetProc.Data/Migrations/NetProcDbContextModelSnapshot.cs +++ b/NetProc.Data/Migrations/NetProcDbContextModelSnapshot.cs @@ -310,6 +310,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DisplayName") .HasColumnType("TEXT"); + b.Property("IsOptoSwitch") + .HasColumnType("INTEGER"); + b.Property("Name") .IsRequired() .HasColumnType("TEXT"); diff --git a/NetProc.Data/NetProcDbContext.cs b/NetProc.Data/NetProcDbContext.cs index 416b132a..72e42b38 100644 --- a/NetProc.Data/NetProcDbContext.cs +++ b/NetProc.Data/NetProcDbContext.cs @@ -22,7 +22,7 @@ public class NetProcDbContext : DbContext, INetProcDbContext public NetProcDbContext() { - + } public NetProcDbContext(DbContextOptions dbContextOptions) : base(dbContextOptions) { } @@ -66,7 +66,7 @@ public void IncrementAuditValue(string key, int increment) { var val = GetAuditValue(key); val += increment; - SetAuditValue(key, val); + SetAuditValue(key, val); } /// @@ -78,8 +78,8 @@ public void IncrementAuditValue(string key, int increment) public IEnumerable ScoresTop(int amt = 10) { return Scores - .Include(p=>p.Player) - .Include(g=>g.GamePlayed) + .Include(p => p.Player) + .Include(g => g.GamePlayed) .OrderByDescending(s => s.Points) .Take(amt).ToList(); } @@ -88,7 +88,7 @@ public IEnumerable ScoresBallsPlayed(int amt = 10) { return BallsPlayed .Include(p => p.Player) - .Include(c => c.Score).ThenInclude(gp => gp.GamePlayed) + .Include(c => c.Score).ThenInclude(gp => gp.GamePlayed) .OrderByDescending(s => s.Points) .Take(amt).ToList(); } @@ -107,7 +107,13 @@ public MachineConfiguration GetMachineConfiguration() SearchReset = x.SearchReset, SearchStop = x.SearchStop, Tags = x.Tags, - Type = x.Type + Type = x.Type, + DisplayName = x.DisplayName, + WireLColour = x.WireLColour, + WireLColourName = x.WireLColourName, + WireRColour = x.WireRColour, + WireRColourName = x.WireRColourName, + IsOptoSwitch = x.IsOptoSwitch, }).ToList(), PRCoils = Coils.AsNoTracking() @@ -119,7 +125,12 @@ public MachineConfiguration GetMachineConfiguration() Polarity = x.Polarity, PulseTime = x.PulseTime, Search = x.Search, - Tags = x.Tags + Tags = x.Tags, + DisplayName = x.DisplayName, + WireLColour = x.WireLColour, + WireLColourName = x.WireLColourName, + WireRColour = x.WireRColour, + WireRColourName = x.WireRColourName }).ToList(), PRLamps = Lamps.AsNoTracking() @@ -146,7 +157,7 @@ public MachineConfiguration GetMachineConfiguration() { DisplayMonitor = machine.DisplayMonitor, MachineType = machine.MachineType, - NumBalls = machine.NumBalls + NumBalls = machine.NumBalls }, //todo: PRBumpers = switches and coils when disabling flippers }; @@ -186,15 +197,15 @@ public void InitializeDatabase(bool isMachinePdb, bool delete = false) if (delete) Database.EnsureDeleted(); //migrations and create the database if doesn't exist - Database.Migrate(); + Database.Migrate(); //return if data is already populated if (Switches?.Count() > 0) { - CreateLookUpTables(); + CreateLookUpTables(); return; } - + string initFile = string.Empty; if (isMachinePdb) @@ -227,7 +238,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { System.Console.WriteLine($"{nameof(NetProcDbContext)} isn't configured, creating sqlite configuration for local netproc.db"); optionsBuilder.UseSqlite(CONNECTION_STRING); - } + } } /// diff --git a/NetProc.Domain/MachineConfig/SwitchConfigFileEntry.cs b/NetProc.Domain/MachineConfig/SwitchConfigFileEntry.cs index 22f396c8..5fa80769 100644 --- a/NetProc.Domain/MachineConfig/SwitchConfigFileEntry.cs +++ b/NetProc.Domain/MachineConfig/SwitchConfigFileEntry.cs @@ -12,6 +12,10 @@ public class SwitchConfigFileEntry : ConfigFileEntryBase /// public SwitchType Type { get; set; } + + /// Defined as opto switch for UI + public byte IsOptoSwitch { get; set; } + /// public string Number { get; set; } ///