Skip to content

Commit 7f0fe8f

Browse files
committed
plcsim
1 parent c1a2355 commit 7f0fe8f

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

scripts/app-test.ps1

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ function BuildAndLoadPlc {
504504
param (
505505
[string]$appYamlFile,
506506
[string]$appName,
507-
[bool]$summaryResult
507+
[ref]$summaryResult
508508
)
509509
# Check if the application folder is not empty
510510
if (-Not ($appYamlFile))
@@ -536,22 +536,28 @@ function BuildAndLoadPlc {
536536
cd $appFolder
537537
# apax install
538538
$result = run-command -command "apax install"
539-
$result.output | foreach-object { write-output $_ }
539+
if ($($result.Success) -match "True")
540+
{
541+
Write-Output "Command 'apax install' finished succesfully in $appFolder"
542+
}
543+
else
544+
{
545+
$result.error| foreach-object { write-output $_ }
546+
}
540547
# apax plcsim
541548
$plcSimProjPath = [System.IO.Path]::GetFullPath((Join-Path -Path $appFolder -ChildPath "..\..\tools\src\PlcSimAdvancedStarter\PlcSimAdvancedStarterTool\PlcSimAdvancedStarterTool.csproj"))
542549
$result = Start-DotNetTool -ProjectName $plcSimProjPath -Arguments "-- startplcsim -x $appName -n $plcName -t $plcIpAddress"
543550
$result.output | foreach-object { write-output $_ }
544551
# apax hwu
545552
$result = Run-Command -Command "apax hwu"
546-
$result.Output | ForEach-Object { Write-Output $_ }
547553
if ($($result.Success) -match "True")
548554
{
549555
$textToWrite = ",OK"
550556
}
551557
else
552558
{
553559
$textToWrite = ",NOK"
554-
$summaryResult = 0
560+
$summaryResult.Value = $false
555561
}
556562
Write-Result -TextToWrite $textToWrite -LogFilePath $logFilePath -AppendToSameLine
557563
# apax swfd
@@ -564,18 +570,17 @@ function BuildAndLoadPlc {
564570
else
565571
{
566572
$textToWrite = ",NOK"
567-
$summaryResult = 0
573+
$summaryResult.Value = $false
568574
}
569575
Write-Result -TextToWrite $textToWrite -LogFilePath $logFilePath -AppendToSameLine
570-
return $summaryResult
571576
}
572577

573578
# Build and start HMI
574579
function BuildAndStartHmi {
575580
param (
576581
[string]$appYamlFile,
577582
[string]$appName,
578-
[bool]$summaryResult
583+
[ref]$summaryResult
579584
)
580585
# Check if the application folder is not empty
581586
if (-Not ($appYamlFile))
@@ -619,7 +624,7 @@ function BuildAndStartHmi {
619624
else
620625
{
621626
$textToWrite = ",NOK"
622-
$summaryResult = 0
627+
$summaryResult.Value = $false
623628
}
624629
Write-Result -TextToWrite $textToWrite -LogFilePath $logFilePath -AppendToSameLine
625630
# get blazor projects
@@ -644,7 +649,7 @@ function BuildAndStartHmi {
644649
else
645650
{
646651
$textToWrite = ",NOK"
647-
$summaryResult = 0
652+
$summaryResult.Value = $false
648653
}
649654
$result.output | foreach-object { write-output $_ }
650655
Write-Result -TextToWrite $textToWrite -LogFilePath $logFilePath -AppendToSameLine
@@ -657,7 +662,6 @@ function BuildAndStartHmi {
657662
}
658663

659664
cd $startDir
660-
return $summaryResult
661665
}
662666

663667
# Function to create the log file
@@ -792,7 +796,7 @@ if ($appYamls)
792796
$createResult = CreateFile -DirectoryPath $resultPath -FileNamePrefix "test_result"
793797

794798
if ($createResult.Success) {
795-
$SumaryResult = 1
799+
$SumaryResult = $true
796800
$logFilePath = $createResult.FilePath
797801
Write-Result -TextToWrite "AppName,PlcHw,PlcSw,DotnetBuild,DotnetRun" -LogFilePath $logFilePath
798802
Write-Output "Files with 'type: app':"
@@ -811,9 +815,9 @@ if ($appYamls)
811815
###### Overrite security files
812816
OverwriteSecurityFiles -appYamlFile $($appYaml.FilePath) -plcName $plcName
813817
###### Build and load PLC
814-
$SumaryResult = BuildAndLoadPlc -appYamlFile $($appYaml.FilePath) -appName $($appYaml.AppName) -logFilePath $logFilePath -summaryResult $SumaryResult
818+
BuildAndLoadPlc -appYamlFile $($appYaml.FilePath) -appName $($appYaml.AppName) -logFilePath $logFilePath -summaryResult ([ref]$SumaryResult)
815819
###### Build and start HMI
816-
$SumaryResult = BuildAndStartHmi -appYamlFile $($appYaml.FilePath) -appName $($appYaml.AppName) -logFilePath $logFilePath -summaryResult $SumaryResult
820+
BuildAndStartHmi -appYamlFile $($appYaml.FilePath) -appName $($appYaml.AppName) -logFilePath $logFilePath -summaryResult ([ref]$SumaryResult)
817821
}
818822
}
819823

0 commit comments

Comments
 (0)