Skip to content

Commit

Permalink
Netproc.Data added wire colour and name (color or voltage) Left and R…
Browse files Browse the repository at this point in the history
…ight. Added IsOptoSwitch to SwitchConfig to display these different in a UI
  • Loading branch information
horseyhorsey committed Sep 4, 2023
1 parent 2b7eccd commit 74ea6d4
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet_nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionSuffix>1.0.31</VersionSuffix>
<VersionSuffix>1.0.32</VersionSuffix>
<AssemblyVersion>$(VersionSuffix)</AssemblyVersion>
<PackageVersion>$(VersionSuffix)</PackageVersion>
<Version>$(VersionSuffix)</Version>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
WireRColourName = table.Column<string>(nullable: true),
Name = table.Column<string>(nullable: false),
Type = table.Column<int>(nullable: false),
IsOptoSwitch = table.Column<byte>(nullable: false),
Tags = table.Column<string>(nullable: true),
SearchReset = table.Column<string>(nullable: true),
SearchStop = table.Column<string>(nullable: true)
Expand Down
3 changes: 3 additions & 0 deletions NetProc.Data/Migrations/NetProcDbContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<string>("DisplayName")
.HasColumnType("TEXT");

b.Property<byte>("IsOptoSwitch")
.HasColumnType("INTEGER");

b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
Expand Down
35 changes: 23 additions & 12 deletions NetProc.Data/NetProcDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class NetProcDbContext : DbContext, INetProcDbContext

public NetProcDbContext()
{

}

public NetProcDbContext(DbContextOptions<NetProcDbContext> dbContextOptions) : base(dbContextOptions) { }
Expand Down Expand Up @@ -66,7 +66,7 @@ public void IncrementAuditValue(string key, int increment)
{
var val = GetAuditValue(key);
val += increment;
SetAuditValue(key, val);
SetAuditValue(key, val);
}

/// <inheritdoc/>
Expand All @@ -78,8 +78,8 @@ public void IncrementAuditValue(string key, int increment)
public IEnumerable<Score> 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();
}
Expand All @@ -88,7 +88,7 @@ public IEnumerable<BallPlayed> 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();
}
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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
};
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}
}

/// <summary>
Expand Down
4 changes: 4 additions & 0 deletions NetProc.Domain/MachineConfig/SwitchConfigFileEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public class SwitchConfigFileEntry : ConfigFileEntryBase

/// <inheritdoc/>
public SwitchType Type { get; set; }

/// <summary> Defined as opto switch for UI </summary>
public byte IsOptoSwitch { get; set; }

/// <inheritdoc/>
public string Number { get; set; }
/// <inheritdoc/>
Expand Down

0 comments on commit 74ea6d4

Please sign in to comment.