Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement to PLC program loading #12

Merged
merged 4 commits into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 11 additions & 6 deletions pipelines/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,25 @@ task Tests -depends CloseVs -precondition { return $isTestingEnabled } {

& "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\devenv.com" .\TcOpen.plc.slnf /Rebuild "$buildConfig|TwinCAT RT (x64)"

.\pipelines\utils\Load-XaeProject.ps1 $testTargetAmsId .\src\TcoCore\src\XaeTcoCore\
$BootDir = $solutionDir +"\src\TcoCore\src\XaeTcoCore\"
.\pipelines\utils\Load-XaeProject.ps1 $testTargetAmsId $BootDir
exec{
dotnet test .\src\TcoCore\TcoCore.slnf -c $buildConfig -f net48
dotnet test .\src\TcoCore\TcoCore.slnf -c $buildConfig -f net48 -v $msbuildVerbosity
}

.\pipelines\utils\Load-XaeProject.ps1 $testTargetAmsId .\src\TcoIoBeckhoff\src\XaeTcoIoBeckhoff\
$BootDir = $solutionDir +"\src\TcoIoBeckhoff\src\XaeTcoIoBeckhoff\"
.\pipelines\utils\Load-XaeProject.ps1 $testTargetAmsId $BootDir
exec{
dotnet test .\src\TcoIoBeckhoff\TcoIoBeckhoff.slnf -c $buildConfig -f net48
dotnet test .\src\TcoIoBeckhoff\TcoIoBeckhoff.slnf -c $buildConfig -f net48 -v $msbuildVerbosity
}

.\pipelines\utils\Load-XaeProject.ps1 $testTargetAmsId .\src\TcoPneumatics\src\XaeTcoPneumatics\
$BootDir = $solutionDir +"src\TcoPneumatics\src\XaeTcoPneumatics\"
.\pipelines\utils\Load-XaeProject.ps1 $testTargetAmsId $BootDir
exec{
dotnet test .\src\TcoPneumatics\TcoPneumatics.slnf -c $buildConfig -f net48
dotnet test .\src\TcoPneumatics\TcoPneumatics.slnf -c $buildConfig -f net48 -v $msbuildVerbosity
}
.\pipelines\utils\CleanupTargetBoot.ps1 $testTargetAmsId

}


Expand Down
73 changes: 73 additions & 0 deletions pipelines/utils/CleanupTargetBoot.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
param( [Parameter(Mandatory=$True, Position=0, ValueFromPipeline=$false)]
[string]
$TargetAmsId)

#-------------------------------------------
# Imports
#-------------------------------------------
Import-Module C:\TwinCAT\AdsApi\Powershell\TcXaeMgmt\TcXaeMgmt.psd1

#-------------------------------------------
#Set target state into the config mode
#-------------------------------------------
Write-Host "Switching target '$TargetAmsId' into the Config mode" -ForegroundColor Blue
Set-AdsState -NetId $TargetAmsId -State Config -Force
$Session = New-TcSession -NetId $TargetAmsId -Port 10000

#-------------------------------------------
#Create cleanup file on target
#-------------------------------------------
Write-Host "Cleaning up the target's boot directory"

$FileHandle = Send-TcReadWrite -IndexGroup 0x78 -IndexOffset 0x10002 -ReadType UInt32 -ReadLength 4 -WriteValue "C:\Twincat\3.1\Boot\PlcCleanup.bat" -NetId $TargetAmsId -Port 10000 -Force -ErrorAction Ignore

#Write commands into the cleanup file
$CmdList = New-Object Collections.Generic.List[String]
$CmdList.Add("rmdir /q /s C:\Twincat\3.1\Boot\CurrentConfig")
$CmdList.Add("rmdir /q /s C:\Twincat\3.1\Boot\Plc")
$CmdList.Add("mkdir C:\Twincat\3.1\Boot\Plc")
$CmdList.Add("del C:\Twincat\3.1\Boot\*.* /F /Q")


try {
$CmdList | ForEach-Object{
$CmdLine = $_ + "`r`n"
$WriteLength = $CmdLine.Length+1
Send-TcReadWrite -IndexGroup 0x7f -IndexOffset $FileHandle -WriteValue $CmdLine -WriteLength $WriteLength -ReadLength 4 -ReadType UInt32 -NetId $TargetAmsId -Port 10000 -Force -ErrorAction Ignore
}

}
catch {
Write-Host "Error writing file:"
Write-Host $_
}
finally {
# Close cleanup file on target
Send-TcReadWrite -IndexGroup 0x79 -IndexOffset $FileHandle -ReadLength 4 -ReadType UInt32 -WriteValue "" -WriteLength 1 -NetId $TargetAmsId -Port 10000 -Force -ErrorAction Ignore
Write-Host "Cleanup file has been created and closed on target."
}

# Prepare data for starting remote process on target
$Enc = [system.Text.Encoding]::UTF8
$Process = $Enc.GetBytes("C:\TwinCAT\3.1\Boot\PlcCleanup.bat")
$Path = $Enc.GetBytes("C:\TwinCAT\3.1\Boot")
$Data = new-object byte[] 780
$Data[0] = 0x22
$Data[4] = 0x13
$Offset =12
$Pos = 0
while($Pos -lt $Process.Count)
{
$Data[$Offset+$Pos] = $Process[$Pos]
$Pos++
}
$Offset = $Offset + $Pos + 1
$Pos = 0
while($Pos -lt $Path.Count)
{
$Data[$Offset+$Pos] = $Path[$Pos]
$Pos++
}

#Start remote process on target
$Retv = $Session | Write-TcValue -IndexGroup 0x1f4 -IndexOffset 0x0 -Value $Data -Force
21 changes: 14 additions & 7 deletions pipelines/utils/Load-XaeProject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ $Session = New-TcSession -NetId $TargetAmsId -Port 10000
#-------------------------------------------
Write-Host "Cleaning up the target's boot directory"


$FileHandle = $Session | Send-TcReadWrite -IndexGroup 0x78 -IndexOffset 0x10002 -ReadType UInt32 -ReadLength 4 -WriteValue "C:\Twincat\3.1\Boot\PlcCleanup.bat" -Force
$FileHandle = Send-TcReadWrite -IndexGroup 0x78 -IndexOffset 0x10002 -ReadType UInt32 -ReadLength 4 -WriteValue "C:\Twincat\3.1\Boot\PlcCleanup.bat" -NetId $TargetAmsId -Port 10000 -Force -ErrorAction Ignore

#Write commands into the cleanup file
$CmdList = New-Object Collections.Generic.List[String]
Expand All @@ -33,21 +32,26 @@ $CmdList.Add("rmdir /q /s C:\Twincat\3.1\Boot\Plc")
$CmdList.Add("mkdir C:\Twincat\3.1\Boot\Plc")
$CmdList.Add("del C:\Twincat\3.1\Boot\*.* /F /Q")


try {
$CmdList | ForEach-Object{
$CmdLine = $_ + "`r`n"
$Retv = $Session | Send-TcReadWrite -IndexGroup 0x7f -IndexOffset $FileHandle -ReadLength 0 -WriteValue $CmdLine -Force -ErrorAction Ignore
$WriteLength = $CmdLine.Length+1
Send-TcReadWrite -IndexGroup 0x7f -IndexOffset $FileHandle -WriteValue $CmdLine -WriteLength $WriteLength -ReadLength 4 -ReadType UInt32 -NetId $TargetAmsId -Port 10000 -Force -ErrorAction Ignore
}

# Close cleanup file on target
$Retv = $Session | Send-TcReadWrite -IndexGroup 0x79 -IndexOffset $FileHandle -ReadLength 0 -WriteValue "" -Force -ErrorAction Ignore
}
catch {

Write-Host "Error writing file:"
Write-Host $_
}
finally {
# Close cleanup file on target
Send-TcReadWrite -IndexGroup 0x79 -IndexOffset $FileHandle -ReadLength 4 -ReadType UInt32 -WriteValue "" -WriteLength 1 -NetId $TargetAmsId -Port 10000 -Force -ErrorAction Ignore
Write-Host "Cleanup file has been created and closed on target."
}

# Prepare data for starting remote process on target

$Enc = [system.Text.Encoding]::UTF8
$Process = $Enc.GetBytes("C:\TwinCAT\3.1\Boot\PlcCleanup.bat")
$Path = $Enc.GetBytes("C:\TwinCAT\3.1\Boot")
Expand All @@ -72,6 +76,7 @@ while($Pos -lt $Path.Count)
#Start remote process on target
$Retv = $Session | Write-TcValue -IndexGroup 0x1f4 -IndexOffset 0x0 -Value $Data -Force


#-------------------------------------------
#Copying files to the target
#-------------------------------------------
Expand All @@ -90,6 +95,8 @@ Start-Sleep -Milliseconds 1000
Copy-AdsFile -SessionId $Session.Id -Upload -Path $FileSource -Destination $FileDestination -Directory Generic -Force -ErrorAction Ignore
}
catch {
Write-Host "Error copying file: $FileSource"
Write-Host $_

}

Expand Down
2 changes: 1 addition & 1 deletion src/TcoCore/src/TcoCore.Wpf/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
[assembly:Vortex.Presentation.Wpf.RenderableAssembly()]
[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0-alpha.115+Branch.dev.Sha.ebf34b2b9f1732969e5053230f12ca12a2c39a8d")]
[assembly: AssemblyInformationalVersion("0.1.0-alpha.118+Branch.dev.Sha.577cdcde529537ab30c3818b20bd577fe6a9c468")]
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0-alpha.115+Branch.dev.Sha.ebf34b2b9f1732969e5053230f12ca12a2c39a8d")]
[assembly: AssemblyInformationalVersion("0.1.0-alpha.118+Branch.dev.Sha.577cdcde529537ab30c3818b20bd577fe6a9c468")]
2 changes: 1 addition & 1 deletion src/TcoCore/src/TcoCoreConnector/_meta/version.info
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0.115
0.1.0.118
2 changes: 1 addition & 1 deletion src/TcoCore/src/XaeTcoCore/TcoCore/TcoCore.plcproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<Company>Vortex.Library</Company>
<Released>false</Released>
<Title>TcoCore</Title>
<ProjectVersion>0.1.0.115</ProjectVersion>
<ProjectVersion>0.1.0.118</ProjectVersion>
<DefaultNamespace>TcoCore</DefaultNamespace>
<Placeholder>TcoCore</Placeholder>
<Author>Inxton</Author>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<Company>Vortex.Library</Company>
<Released>false</Released>
<Title>TcoCore</Title>
<ProjectVersion>0.1.0.115</ProjectVersion>
<ProjectVersion>0.1.0.118</ProjectVersion>
<DefaultNamespace>TcoCore</DefaultNamespace>
<Placeholder>TcoCore</Placeholder>
<Author>Inxton</Author>
Expand Down
6 changes: 3 additions & 3 deletions src/TcoCore/src/XaeTcoCore/TcoCoreTests/TcoCoreTests.plcproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<Company>Vortex.Library</Company>
<Released>false</Released>
<Title>TcoCoreTests</Title>
<ProjectVersion>0.1.0.115</ProjectVersion>
<ProjectVersion>0.1.0.118</ProjectVersion>
<DefaultNamespace>TcoCoreTests</DefaultNamespace>
<Placeholder>TcoCoreTests</Placeholder>
<CombineIds>true</CombineIds>
Expand Down Expand Up @@ -134,7 +134,7 @@
<Namespace>Tc3_Module</Namespace>
</PlaceholderReference>
<PlaceholderReference Include="TcoCore">
<DefaultResolution>TcoCore, 0.1.0.113 (Vortex.Library)</DefaultResolution>
<DefaultResolution>TcoCore, 0.1.0.118 (Vortex.Library)</DefaultResolution>
<Namespace>TcoCore</Namespace>
</PlaceholderReference>
</ItemGroup>
Expand All @@ -145,7 +145,7 @@
</ItemGroup>
<ItemGroup>
<PlaceholderResolution Include="TcoCore">
<Resolution>TcoCore, 0.1.0.113 (Vortex.Library)</Resolution>
<Resolution>TcoCore, 0.1.0.118 (Vortex.Library)</Resolution>
</PlaceholderResolution>
</ItemGroup>
<ProjectExtensions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<Company>Vortex.Library</Company>
<Released>false</Released>
<Title>TcoCoreTests</Title>
<ProjectVersion>0.1.0.115</ProjectVersion>
<ProjectVersion>0.1.0.118</ProjectVersion>
<DefaultNamespace>TcoCoreTests</DefaultNamespace>
<Placeholder>TcoCoreTests</Placeholder>
<CombineIds>true</CombineIds>
Expand Down Expand Up @@ -134,7 +134,7 @@
<Namespace>Tc3_Module</Namespace>
</PlaceholderReference>
<PlaceholderReference Include="TcoCore">
<DefaultResolution>TcoCore, 0.1.0.113 (Vortex.Library)</DefaultResolution>
<DefaultResolution>TcoCore, 0.1.0.118 (Vortex.Library)</DefaultResolution>
<Namespace>TcoCore</Namespace>
</PlaceholderReference>
</ItemGroup>
Expand All @@ -145,7 +145,7 @@
</ItemGroup>
<ItemGroup>
<PlaceholderResolution Include="TcoCore">
<Resolution>TcoCore, 0.1.0.113 (Vortex.Library)</Resolution>
<Resolution>TcoCore, 0.1.0.118 (Vortex.Library)</Resolution>
</PlaceholderResolution>
</ItemGroup>
<ProjectExtensions>
Expand Down
2 changes: 1 addition & 1 deletion src/TcoCore/tests/TcoCore.Sandbox.Wpf/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@

[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0-alpha.115+Branch.dev.Sha.ebf34b2b9f1732969e5053230f12ca12a2c39a8d")]
[assembly: AssemblyInformationalVersion("0.1.0-alpha.118+Branch.dev.Sha.577cdcde529537ab30c3818b20bd577fe6a9c468")]

2 changes: 1 addition & 1 deletion src/TcoCore/tests/TcoCoreTestsConnector/_meta/version.info
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0.115
0.1.0.118
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
[assembly:RenderableAssembly]
[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0-alpha.115+Branch.dev.Sha.ebf34b2b9f1732969e5053230f12ca12a2c39a8d")]
[assembly: AssemblyInformationalVersion("0.1.0-alpha.118+Branch.dev.Sha.577cdcde529537ab30c3818b20bd577fe6a9c468")]
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
[assembly: InternalsVisibleTo("xUnitTcOpenTests")]
[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0-alpha.115+Branch.dev.Sha.ebf34b2b9f1732969e5053230f12ca12a2c39a8d")]
[assembly: AssemblyInformationalVersion("0.1.0-alpha.118+Branch.dev.Sha.577cdcde529537ab30c3818b20bd577fe6a9c468")]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0.115
0.1.0.118
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<LibraryReferences>{03f8892c-d1d0-44d2-9e9d-b9c1ad614a91}</LibraryReferences>
<Released>false</Released>
<Title>TcoIoBeckhoff</Title>
<ProjectVersion>0.1.0.115</ProjectVersion>
<ProjectVersion>0.1.0.118</ProjectVersion>
<Author></Author>
<Company>Vortex.Library</Company>
<DefaultNamespace>TcoIoBeckhoff</DefaultNamespace>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<LibraryReferences>{03f8892c-d1d0-44d2-9e9d-b9c1ad614a91}</LibraryReferences>
<Released>false</Released>
<Title>TcoIoBeckhoff</Title>
<ProjectVersion>0.1.0.115</ProjectVersion>
<ProjectVersion>0.1.0.118</ProjectVersion>
<Author></Author>
<Company>Vortex.Library</Company>
<DefaultNamespace>TcoIoBeckhoff</DefaultNamespace>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@

[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0-alpha.115+Branch.dev.Sha.ebf34b2b9f1732969e5053230f12ca12a2c39a8d")]
[assembly: AssemblyInformationalVersion("0.1.0-alpha.118+Branch.dev.Sha.577cdcde529537ab30c3818b20bd577fe6a9c468")]

Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
[assembly:RenderableAssembly]
[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0-alpha.115+Branch.dev.Sha.ebf34b2b9f1732969e5053230f12ca12a2c39a8d")]
[assembly: AssemblyInformationalVersion("0.1.0-alpha.118+Branch.dev.Sha.577cdcde529537ab30c3818b20bd577fe6a9c468")]
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
[assembly: InternalsVisibleTo("xUnitTcOpenTests")]
[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0-alpha.115+Branch.dev.Sha.ebf34b2b9f1732969e5053230f12ca12a2c39a8d")]
[assembly: AssemblyInformationalVersion("0.1.0-alpha.118+Branch.dev.Sha.577cdcde529537ab30c3818b20bd577fe6a9c468")]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0.115
0.1.0.118
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<LibraryReferences>{6041bb0d-625b-4e6f-a92c-90179c0efe88}</LibraryReferences>
<Released>false</Released>
<Title>TcoPneumatics</Title>
<ProjectVersion>0.1.0.115</ProjectVersion>
<ProjectVersion>0.1.0.118</ProjectVersion>
<Author>Dustin Hullett</Author>
<Company>Vortex.Library</Company>
<DefaultNamespace>TcoPneumatics</DefaultNamespace>
Expand Down Expand Up @@ -55,7 +55,7 @@
<Namespace>Tc3_Module</Namespace>
</PlaceholderReference>
<PlaceholderReference Include="TcoCore">
<DefaultResolution>TcoCore, 0.1.0.115 (Vortex.Library)</DefaultResolution>
<DefaultResolution>TcoCore, 0.1.0.118 (Vortex.Library)</DefaultResolution>
<Namespace>TcoCore</Namespace>
</PlaceholderReference>
</ItemGroup>
Expand All @@ -66,7 +66,7 @@
</ItemGroup>
<ItemGroup>
<PlaceholderResolution Include="TcoCore">
<Resolution>TcoCore, 0.1.0.115 (Vortex.Library)</Resolution>
<Resolution>TcoCore, 0.1.0.118 (Vortex.Library)</Resolution>
</PlaceholderResolution>
</ItemGroup>
<ProjectExtensions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<LibraryReferences>{6041bb0d-625b-4e6f-a92c-90179c0efe88}</LibraryReferences>
<Released>false</Released>
<Title>TcoPneumatics</Title>
<ProjectVersion>0.1.0.115</ProjectVersion>
<ProjectVersion>0.1.0.118</ProjectVersion>
<Author>Dustin Hullett</Author>
<Company>Vortex.Library</Company>
<DefaultNamespace>TcoPneumatics</DefaultNamespace>
Expand Down Expand Up @@ -55,7 +55,7 @@
<Namespace>Tc3_Module</Namespace>
</PlaceholderReference>
<PlaceholderReference Include="TcoCore">
<DefaultResolution>TcoCore, 0.1.0.115 (Vortex.Library)</DefaultResolution>
<DefaultResolution>TcoCore, 0.1.0.118 (Vortex.Library)</DefaultResolution>
<Namespace>TcoCore</Namespace>
</PlaceholderReference>
</ItemGroup>
Expand All @@ -66,7 +66,7 @@
</ItemGroup>
<ItemGroup>
<PlaceholderResolution Include="TcoCore">
<Resolution>TcoCore, 0.1.0.115 (Vortex.Library)</Resolution>
<Resolution>TcoCore, 0.1.0.118 (Vortex.Library)</Resolution>
</PlaceholderResolution>
</ItemGroup>
<ProjectExtensions>
Expand Down