Skip to content

Commit

Permalink
Remodel version into one file Classes/B2SVersionInfo.vb which is then…
Browse files Browse the repository at this point in the history
… used everywhere.

Add new B2SServerBuild COM method returning float: 20500.0123
  • Loading branch information
JockeJarre committed Jul 5, 2024
1 parent 7ee1970 commit a8bd31d
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 45 deletions.
47 changes: 34 additions & 13 deletions .github/workflows/b2s-backglass.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,48 @@ jobs:
name: Update AssemblyInformationalVersion
run: |
SHA7="${GITHUB_SHA::7}"
: # B2SServerPluginInterface
ASSEMBLY_INFO="B2SServerPluginInterface/B2SServerPluginInterface/Properties/AssemblyInfo.cs"
VERSION=$(grep -Eo "AssemblyVersion\(.*\)" "${ASSEMBLY_INFO}" | grep -Eo "[0-9\.]+" | tail -1)
TAG="${VERSION}-${SHA7}"
echo -e "\n[assembly: AssemblyInformationalVersion(\"${TAG}\")]" >> "${ASSEMBLY_INFO}"
: # Fetch version
VERSION_INFO="b2sbackglassserver/b2sbackglassserver/Classes/B2SVersionInfo.vb"
VERSION_MAJOR=$(grep -Eo "B2S_VERSION_MAJOR\s+=\s\"[0-9]+\"" "${VERSION_INFO}" | grep -Eo "[0-9]+" | tail -1)
VERSION_MINOR=$(grep -Eo "B2S_VERSION_MINOR\s+=\s\"[0-9]+\"" "${VERSION_INFO}" | grep -Eo "[0-9]+" | tail -1)
VERSION_REV=$(grep -Eo "B2S_VERSION_REVISION\s+=\s\"[0-9]+\"" "${VERSION_INFO}" | grep -Eo "[0-9]+" | tail -1)
VERSION_MINI="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REV}"
VERSION_SHORT="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REV}.${{ github.run_number }}"
VERSION_LONG="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REV}.${{ github.run_number }}-${SHA7}"
echo VERSION_MINI ${VERSION_MINI}
echo VERSION_SHORT ${VERSION_SHORT}
echo VERSION_LONG ${VERSION_LONG}
: # b2sbackglassserver
perl -i -pe"s/B2S_VERSION_BUILD\s+=\s+\".*\"/B2S_VERSION_BUILD = \"${{ github.run_number }}\"/g" "${VERSION_INFO}"
perl -i -pe"s/B2S_VERSION_HASH\s+=\s+\".*\"/B2S_VERSION_HASH = \"${SHA7}\"/g" "${VERSION_INFO}"
ASSEMBLY_INFO="b2sbackglassserver/b2sbackglassserver/My Project/AssemblyInfo.vb"
VERSION=$(grep -Eo "AssemblyVersion\(.*\)" "${ASSEMBLY_INFO}" | grep -Eo "[0-9\.]+" | tail -1).${{ github.run_number }}
TAG="${VERSION}-${SHA7}"
perl -i -pe"s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"${TAG}\"\)/g" "${ASSEMBLY_INFO}"
perl -i -pe"s/AssemblyVersion\(\".*\"\)/AssemblyVersion\(\"${VERSION_MINI}\"\)/g" "${ASSEMBLY_INFO}"
perl -i -pe"s/AssemblyFileVersion\(\".*\"\)/AssemblyFileVersion\(\"${VERSION_SHORT}\"\)/g" "${ASSEMBLY_INFO}"
perl -i -pe"s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"${VERSION_LONG}\"\)/g" "${ASSEMBLY_INFO}"
: # b2s_screenresidentifier
ASSEMBLY_INFO="b2s_screenresidentifier/b2s_screenresidentifier/My Project/AssemblyInfo.vb"
perl -i -pe"s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"${TAG}\"\)/g" "${ASSEMBLY_INFO}"
perl -i -pe"s/AssemblyVersion\(\".*\"\)/AssemblyVersion\(\"${VERSION_MINI}\"\)/g" "${ASSEMBLY_INFO}"
perl -i -pe"s/AssemblyFileVersion\(\".*\"\)/AssemblyFileVersion\(\"${VERSION_SHORT}\"\)/g" "${ASSEMBLY_INFO}"
perl -i -pe"s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"${VERSION_LONG}\"\)/g" "${ASSEMBLY_INFO}"
: # b2sbackglassserverregisterapp
ASSEMBLY_INFO="b2sbackglassserverregisterapp/b2sbackglassserverregisterapp/My Project/AssemblyInfo.vb"
perl -i -pe"s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"${TAG}\"\)/g" "${ASSEMBLY_INFO}"
perl -i -pe"s/AssemblyVersion\(\".*\"\)/AssemblyVersion\(\"${VERSION_MINI}\"\)/g" "${ASSEMBLY_INFO}"
perl -i -pe"s/AssemblyFileVersion\(\".*\"\)/AssemblyFileVersion\(\"${VERSION_SHORT}\"\)/g" "${ASSEMBLY_INFO}"
perl -i -pe"s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"${VERSION_LONG}\"\)/g" "${ASSEMBLY_INFO}"
: # B2SWindowPunch
ASSEMBLY_INFO="B2SWindowPunch/B2SWindowPunch/Properties/AssemblyInfo.cs"
perl -i -pe"s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"${TAG}\"\)/g" "${ASSEMBLY_INFO}"
: # Keep the TAG for later
echo "tag=${TAG}" >> $GITHUB_OUTPUT
perl -i -pe"s/AssemblyVersion\(\".*\"\)/AssemblyVersion\(\"${VERSION_MINI}\"\)/g" "${ASSEMBLY_INFO}"
perl -i -pe"s/AssemblyFileVersion\(\".*\"\)/AssemblyFileVersion\(\"${VERSION_SHORT}\"\)/g" "${ASSEMBLY_INFO}"
perl -i -pe"s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"${VERSION_LONG}\"\)/g" "${ASSEMBLY_INFO}"
: # B2SServerPluginInterface
ASSEMBLY_INFO="B2SServerPluginInterface/B2SServerPluginInterface/Properties/AssemblyInfo.cs"
VERSION=$(grep -Eo "AssemblyVersion\(.*\)" "${ASSEMBLY_INFO}" | grep -Eo "[0-9\.]+" | tail -1)
TAG="${VERSION::5}.${{ github.run_number }}"
perl -i -pe"s/AssemblyConfiguration\(\"\"\)/AssemblyConfiguration\(\"Compiled by B2S.Server\"\)/g" "${ASSEMBLY_INFO}"
echo -e "\n[assembly: AssemblyFileVersion(\"${TAG}\")]" >> "${ASSEMBLY_INFO}"
echo -e "\n[assembly: AssemblyInformationalVersion(\"${TAG}-${SHA7}\")]" >> "${ASSEMBLY_INFO}"
: # Keep the VERSION_LONG for later
echo "tag=${VERSION_LONG}" >> $GITHUB_OUTPUT
- uses: microsoft/setup-msbuild@v2
- name: Build B2SServerPluginInterface
run: |
Expand Down
17 changes: 13 additions & 4 deletions b2sbackglassserver/b2sbackglassserver/B2SBackglassServer.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
<FileAlignment>512</FileAlignment>
<MyType>Windows</MyType>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<TargetFrameworkProfile />
<DefineConstants>B2S="DLL"</DefineConstants>
</PropertyGroup>
Expand Down Expand Up @@ -99,6 +103,7 @@
<Compile Include="Classes\B2SSettings.vb" />
<Compile Include="Classes\B2SStatistics.vb" />
<Compile Include="Classes\Processes.vb" />
<Compile Include="Classes\B2SVersionInfo.vb" />
<Compile Include="Controls\B2SBaseBox.vb">
<SubType>Component</SubType>
</Compile>
Expand Down Expand Up @@ -188,23 +193,27 @@
<ItemGroup>
<EmbeddedResource Include="Forms\Background.resx">
<DependentUpon>Background.vb</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\formBackglass.resx">
<DependentUpon>formBackglass.vb</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\formDMD.resx">
<DependentUpon>formDMD.vb</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\formMode.resx">
<DependentUpon>formMode.vb</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\formSettings.resx">
<DependentUpon>formSettings.vb</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\formSettingsMore.resx">
<DependentUpon>formSettingsMore.vb</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
<FileAlignment>512</FileAlignment>
<MyType>WindowsFormsWithCustomSubMain</MyType>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
Expand Down Expand Up @@ -160,6 +164,7 @@
<Compile Include="Classes\B2SSettings.vb" />
<Compile Include="Classes\B2SStatistics.vb" />
<Compile Include="Classes\B2SSystem.vb" />
<Compile Include="Classes\B2SVersionInfo.vb" />
<Compile Include="Classes\Processes.vb" />
<Compile Include="Controls\B2SBaseBox.vb">
<SubType>Component</SubType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Imports Microsoft.Win32

Public Class B2SSettings

Public Const DirectB2SVersion As String = "3.0.0"
Public Const MinimumDirectB2SVersion As String = "1.0"
Public Shared Property BackglassFileVersion() As String = String.Empty

Expand Down
17 changes: 17 additions & 0 deletions b2sbackglassserver/b2sbackglassserver/Classes/B2SVersionInfo.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
' Add VersionInfo class

Public Class B2SVersionInfo
Public Const B2S_VERSION_MAJOR = "2"
Public Const B2S_VERSION_MINOR = "5"
Public Const B2S_VERSION_REVISION = "0"
Public Const B2S_VERSION_BUILD = "999"
Public Const B2S_VERSION_HASH = "nonset"
' 2.5.0
Public Const B2S_VERSION_STRING = B2S_VERSION_MAJOR & "." & B2S_VERSION_MINOR & "." & B2S_VERSION_REVISION
' 2.5.0.999
Public Const B2S_BUILD_STRING = B2S_VERSION_MAJOR & "." & B2S_VERSION_MINOR & "." &
B2S_VERSION_REVISION & "." & B2S_VERSION_BUILD
' 2.5.0.999-nonset Git hash
Public Const B2S_BUILD_STRING_HASH = B2S_VERSION_MAJOR & "." & B2S_VERSION_MINOR & "." &
B2S_VERSION_REVISION & "." & B2S_VERSION_BUILD & "-" & B2S_VERSION_HASH
End Class
4 changes: 2 additions & 2 deletions b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb
Original file line number Diff line number Diff line change
Expand Up @@ -2002,9 +2002,9 @@ Public Class formBackglass
End Using
#End If
' current backglass version is not allowed to be larger than server version and to be smaller minimum B2S version
If B2SSettings.BackglassFileVersion > B2SSettings.DirectB2SVersion Then
If B2SSettings.BackglassFileVersion > B2SVersionInfo.B2S_VERSION_STRING Then

Throw New Exception("B2S.Server version (" & B2SSettings.DirectB2SVersion & ") doesn't match 'directb2s' file version (" & B2SSettings.BackglassFileVersion & "). " & vbCrLf & vbCrLf &
Throw New Exception("B2S.Server version (" & B2SVersionInfo.B2S_VERSION_STRING & ") doesn't match 'directb2s' file version (" & B2SSettings.BackglassFileVersion & "). " & vbCrLf & vbCrLf &
"Please update the B2S.Server.")

ElseIf B2SSettings.BackglassFileVersion < B2SSettings.MinimumDirectB2SVersion Then
Expand Down
8 changes: 1 addition & 7 deletions b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,10 @@ Public Class formSettings
' set version info
#If B2S = "DLL" Then
lblCopyright.Text = String.Format(lblCopyright.Text, "B2S.Server.DLL", My.Application.Info.Copyright.ToString)

Dim Assembly As Assembly = Assembly.GetExecutingAssembly()
Dim FileVersionInfo As FileVersionInfo = FileVersionInfo.GetVersionInfo(Assembly.Location)
lblVersion.Text = String.Format("Server version {0} {1}, backglass file version {2}", FileVersionInfo.ProductVersion, If(Environment.Is64BitProcess, "x64", "x86"), B2SSettings.BackglassFileVersion)
#Else
lblCopyright.Text = String.Format(lblCopyright.Text, "B2S.Server.EXE", My.Application.Info.Copyright.ToString)
lblVersion.Text = String.Format("Server version {0} {1}, backglass file version {2}", Application.ProductVersion, If(Environment.Is64BitProcess, "x64", "x86"), B2SSettings.BackglassFileVersion)
#End If


lblVersion.Text = String.Format("Server version {0} {1}, backglass file version {2}", B2SVersionInfo.B2S_BUILD_STRING_HASH, If(Environment.Is64BitProcess, "x64", "x86"), B2SSettings.BackglassFileVersion)

' get more data

Expand Down
42 changes: 28 additions & 14 deletions b2sbackglassserver/b2sbackglassserver/Server.vb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Imports System.Linq.Expressions
Imports System.Drawing
Imports System.Reflection
Imports System.Runtime.InteropServices.WindowsRuntime

<ProgId("B2S.Server"), ComClass(Server.ClassID, Server.InterfaceID, Server.EventsID)>
Public Class Server
Expand Down Expand Up @@ -268,10 +270,20 @@ Public Class Server

Public ReadOnly Property B2SServerVersion() As String
Get
Return B2SSettings.DirectB2SVersion
Return B2SVersionInfo.B2S_VERSION_STRING
End Get
End Property

Public ReadOnly Property B2SServerBuild() As Double
Get
Return CInt(B2SVersionInfo.B2S_VERSION_MAJOR) * 10000 +
CInt(B2SVersionInfo.B2S_VERSION_MINOR) * 100 +
CInt(B2SVersionInfo.B2S_VERSION_REVISION) +
CInt(B2SVersionInfo.B2S_VERSION_BUILD) / 10000
End Get
End Property


Public ReadOnly Property B2SServerDirectory() As String
Get
Return System.Reflection.Assembly.GetExecutingAssembly().Location
Expand Down Expand Up @@ -2148,13 +2160,15 @@ Public Class Server

For Each picbox As B2SPictureBox In B2SData.UsedRomLampIDs(id)
If picbox IsNot Nothing AndAlso (Not B2SData.UseIlluminationLocks OrElse String.IsNullOrEmpty(picbox.GroupName) OrElse Not B2SData.IlluminationLocks.ContainsKey(picbox.GroupName)) Then
picbox.Left = xpos
picbox.Top = ypos
' Using RectangleF as this is used in the DrawImage within OnPaint for picturBoxes.
picbox.RectangleF = New RectangleF(CInt(picbox.Left / rescaleBackglass.Width), CInt(picbox.Top / rescaleBackglass.Height), picbox.RectangleF.Width, picbox.RectangleF.Height)
'Invalidating this object does not work, need to Invalidate the parent.
If picbox.Parent IsNot Nothing Then
picbox.Parent.Invalidate()
If picbox.Left <> xpos OrElse picbox.Top <> ypos Then
picbox.Left = xpos
picbox.Top = ypos
' Using RectangleF as this is used in the DrawImage within OnPaint for picturBoxes.
picbox.RectangleF = New RectangleF(CInt(picbox.Left / rescaleBackglass.Width), CInt(picbox.Top / rescaleBackglass.Height), picbox.RectangleF.Width, picbox.RectangleF.Height)
'Invalidating this object does not work, need to Invalidate the parent.
If picbox.Parent IsNot Nothing Then
picbox.Parent.Invalidate()
End If
End If
End If
Next
Expand All @@ -2168,25 +2182,25 @@ Public Class Server

If Not B2SData.IsBackglassRunning Then Return

Dim useLEDs As Boolean = (B2SData.LEDs.ContainsKey("LEDBox" & digit.ToString()) AndAlso B2SSettings.UsedLEDType = B2SSettings.eLEDTypes.Rendered)
Dim useLEDDisplays As Boolean = (B2SData.LEDDisplayDigits.ContainsKey(digit - 1) AndAlso B2SSettings.UsedLEDType = B2SSettings.eLEDTypes.Dream7)
'Dim useLEDs As Boolean = (B2SData.LEDs.ContainsKey("LEDBox" & digit.ToString()) AndAlso B2SSettings.UsedLEDType = B2SSettings.eLEDTypes.Rendered)
'Dim useLEDDisplays As Boolean = (B2SData.LEDDisplayDigits.ContainsKey(digit - 1) AndAlso B2SSettings.UsedLEDType = B2SSettings.eLEDTypes.Dream7)

If B2SData.IsBackglassStartedAsEXE Then

Using regkey As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\B2S", True)
regkey.SetValue("B2SLED" & digit.ToString(), value)
End Using

ElseIf useLEDs Then

'ElseIf useLEDs Then
ElseIf (B2SSettings.UsedLEDType = B2SSettings.eLEDTypes.Rendered AndAlso B2SData.LEDs.ContainsKey("LEDBox" & digit.ToString())) Then
' rendered LEDs are used
Dim ledname As String = "LEDBox" & digit.ToString()
If B2SData.LEDs.ContainsKey(ledname) Then
B2SData.LEDs(ledname).Value = value
End If

ElseIf useLEDDisplays Then

'ElseIf useLEDDisplays Then
ElseIf (B2SSettings.UsedLEDType = B2SSettings.eLEDTypes.Dream7 AndAlso B2SData.LEDDisplayDigits.ContainsKey(digit - 1)) Then
' Dream 7 displays are used
If B2SData.LEDDisplayDigits.ContainsKey(digit - 1) Then
With B2SData.LEDDisplayDigits(digit - 1)
Expand Down

0 comments on commit a8bd31d

Please sign in to comment.