Skip to content

Commit

Permalink
Merge pull request #574 from Inxton/573-fix-issues-with-previous-revert
Browse files Browse the repository at this point in the history
fix issues with previous revert
  • Loading branch information
PTKu authored Jan 31, 2025
2 parents c081a04 + 398ea55 commit 25fddd5
Show file tree
Hide file tree
Showing 67 changed files with 1,034 additions and 193 deletions.
90 changes: 90 additions & 0 deletions scripts/_pack_and_publish_catalog.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@

# Get the current script directory
$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$parentDir = Resolve-Path -Path "$scriptDir\.."

# Combine the absolute path with a relative path
$catalogRelPath = "src\ax.catalog"
$catalogAbsPath = Join-Path -Path $ParentDir -ChildPath $catalogRelPath

# Check if the folder exists
if (Test-Path -Path $catalogAbsPath)
{
# Get all .tgz files in the folder
$Files = Get-ChildItem -Path $catalogAbsPath -Filter "*.tgz"

# Check if any .tgz files were found
if ($Files)
{
# Loop through each file and delete it
foreach ($File in $Files)
{
try
{
Remove-Item -Path $File.FullName -Force
Write-Host "Deleted: $($File.FullName)" -ForegroundColor Green
}
catch
{
Write-Host "Failed to delete: $($File.FullName) - $_" -ForegroundColor Red
}
}
}
else
{
Write-Host "No .tgz files found in the folder $catalogAbsPath." -ForegroundColor Yellow
}

# Change dir to catalog path
cd $catalogAbsPath

# Pack the catalog
$packResult = apax pack --key $env:APAX_KEY

if ($packResult[0] -and -not $packResult[1])
{
Write-Host "Catalog packed succesfully" -ForegroundColor Green
}
else
{
Write-Host "Failed to pack catalog" -ForegroundColor Red
Write-Host "Error: $packResult[0]: $packResult[1]" -ForegroundColor Red
exit 1
}


# Get all .tgz files in the folder, there should be just one, currently generated
$Files = Get-ChildItem -Path $catalogAbsPath -Filter "*.tgz"
if($Files.Count -ne 1)
{
Write-Host "Error: Several *.tgz files found in the directory $catalogAbsPath." -ForegroundColor Red
}
else
{
$catalogFileName = $Files[0].Name

Write-Host "Catalog file name: $catalogFileName." -ForegroundColor Yellow


# Publish the catalog
$publishResult = apax publish --package $catalogFileName --registry https://npm.pkg.github.com


if ($publishResult[0] -and -not $publishResult[1])
{
Write-Host "Catalog published succesfully" -ForegroundColor Green
}
else
{
Write-Host "Failed to publish catalog" -ForegroundColor Red
Write-Host "Error: $publishResult[0]: $publishResult[1]" -ForegroundColor Red
}
}
Remove-Item -Path $Files[0].FullName -Force

}
else
{
Write-Host "The specified folder does not exist: $catalogAbsPath" -ForegroundColor Red
}
cd $scriptDir
58 changes: 25 additions & 33 deletions scripts/app-test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -410,20 +410,19 @@ function Start-DotNetTool {
Write-Output "Command completed successfully."
Write-Output $output

###### TODO ##### When running with github action runner, each error cause stop of the action so the error output needs to be forwarded to some logfile in the future
## Check the exit code
#if ($process.ExitCode -eq 0)
#{
# Write-Output "Command completed successfully."
# Write-Output $output
# return $true
#}
#else
#{
# Write-Error "Command failed with exit code: $($process.ExitCode)"
# Write-Error $errorOutput
# return $false
#}
# Check the exit code
if ($process.ExitCode -eq 0)
{
Write-Output "Command completed successfully."
Write-Output $output
return $true
}
else
{
Write-Error "Command failed with exit code: $($process.ExitCode)"
Write-Error $errorOutput
return $false
}
}
catch
{
Expand Down Expand Up @@ -483,11 +482,10 @@ function Start-DotNetProject {
}
else
{
###### TODO ##### When running with github action runner, each error cause stop of the action so the error output needs to be forwarded to some logfile in the
#Write-Error "Project failed to start. Check for errors."
Write-Error "Project failed to start. Check for errors."
# Read output and error streams
#$errorOutput = Get-Content $stdErrFile
#Write-Output $errorOutput
$errorOutput = Get-Content $stdErrFile
Write-Output $errorOutput
Stop-Process -Id $process.Id -Force #???
return $false
}
Expand Down Expand Up @@ -541,27 +539,22 @@ function BuildAndLoadPlc {
}
cd $appFolder
# apax install
#$result = run-command -command "apax install"
apax install > $null 2>&1
return
$result = run-command -command "apax install"
if ($($result.Success) -match "True")
{
Write-Output "Command 'apax install' finished succesfully in $appFolder"
}
###### TODO ##### When running with github action runner, each error cause stop of the action so the error output needs to be forwarded to some logfile in the future
#else
#{
# $result.error| foreach-object { write-output $_ }
#}
else
{
$result.error| foreach-object { write-output $_ }
}
# apax plcsim
$plcSimProjPath = [System.IO.Path]::GetFullPath((Join-Path -Path $appFolder -ChildPath "..\..\tools\src\PlcSimAdvancedStarter\PlcSimAdvancedStarterTool\PlcSimAdvancedStarterTool.csproj"))
$result = Start-DotNetTool -ProjectName $plcSimProjPath -Arguments "-- startplcsim -x $appName -n $plcName -t $plcIpAddress"
###### TODO ##### When running with github action runner, each error cause stop of the action so the error output needs to be forwarded to some logfile in the future
#$result.output | foreach-object { write-output $_ }
$result.output | foreach-object { write-output $_ }
# apax hwu
$result = Run-Command -Command "apax hwu"
###### TODO ##### When running with github action runner, each error cause stop of the action so the error output needs to be forwarded to some logfile in the future
#$result.Output | ForEach-Object { Write-Output $_ }
$result.Output | ForEach-Object { Write-Output $_ }
if ($($result.Success) -match "True")
{
$textToWrite = ",OK"
Expand All @@ -574,8 +567,7 @@ function BuildAndLoadPlc {
Write-Result -TextToWrite $textToWrite -LogFilePath $logFilePath -AppendToSameLine
# apax swfd
$result = Run-Command -Command "apax swfd"
###### TODO ##### When running with github action runner, each error cause stop of the action so the error output needs to be forwarded to some logfile in the future
#$result.Output | ForEach-Object { Write-Output $_ }
$result.Output | ForEach-Object { Write-Output $_ }
if ($($result.Success) -match "True")
{
$textToWrite = ",OK"
Expand Down Expand Up @@ -832,7 +824,7 @@ if ($appYamls)
###### Build and load PLC
BuildAndLoadPlc -appYamlFile $($appYaml.FilePath) -appName $($appYaml.AppName) -logFilePath $logFilePath -summaryResult ([ref]$SumaryResult)
###### Build and start HMI
#BuildAndStartHmi -appYamlFile $($appYaml.FilePath) -appName $($appYaml.AppName) -logFilePath $logFilePath -summaryResult ([ref]$SumaryResult)
BuildAndStartHmi -appYamlFile $($appYaml.FilePath) -appName $($appYaml.AppName) -logFilePath $logFilePath -summaryResult ([ref]$SumaryResult)
}
}

Expand Down
7 changes: 5 additions & 2 deletions scripts/commit_and_ready_for_review.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ else
{
$commitMessage = $args[0]
}
# Get the current script directory
$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$parentDir = Resolve-Path -Path "$scriptDir\.."
# without this probably just the content of the script folder is added to the commit
cd $parentDir
git add .
git commit -m "$commitMessage"
git push
# Get the current script directory
$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
# Construct the full path to ready_for_review.ps1
$ready_for_reviewScriptPath = Join-Path -Path $scriptDir -ChildPath "ready_for_review.ps1"
& $ready_for_reviewScriptPath
18 changes: 13 additions & 5 deletions src/abstractions/app/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ dependencies:
"@inxton/axopen.core": '0.0.0-dev.0'
"@inxton/ax.axopen.app": '0.0.0-dev.0'
"@inxton/axopen.simatic1500": '0.0.0-dev.0'
# this is just temporary to be able create hardware configuration using latest hwc version
# upto the moment of releasing new catalog
# installStrategy: strict
"@inxton/ax.latest.packages": '0.0.0-dev.0'
installStrategy: overridable
installStrategy: strict
apaxVersion: 3.4.2
scripts:
# For proper execution of these scripts, the following variables need to be defined as environment variables or local variables.
Expand Down Expand Up @@ -108,3 +104,15 @@ scripts:
START=$(date +%s)
..\\..\\scripts\\all.sh $DEFAULT_NAMESPACE $PLC_NAME $AXTARGET $AXTARGETPLATFORMINPUT $AX_USERNAME $AX_TARGET_PWD $USE_PLC_SIM_ADVANCED
echo $(date +%D)"-"$(date +%H)":"$(date +%M)":"$(date +%S) " - Finished in :" $(expr $(date +%s) - $START) "s"
ib: |
apax install
apax build
icb: |
apax install --catalog
apax ib
cib: |
apax clean
apax ib
cicb: |
apax clean
apax icb
13 changes: 13 additions & 0 deletions src/abstractions/ctrl/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ apaxVersion: 3.4.2
scripts:
postbuild:
- dotnet ixc
ib: |
apax install
apax build
icb: |
apax install --catalog
apax ib
cib: |
apax clean
apax ib
cicb: |
apax clean
apax icb
publicKeys:
"@inxton": 30c06ef7830b4dfd8f16e003508da1ac2d187714d0e1f38279a9332cbe4e4e17
...
8 changes: 8 additions & 0 deletions src/ax.axopen.app/ax.axopen.app.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"folders": [
{
"path": "ctrl"
}
],
"settings": {}
}
19 changes: 17 additions & 2 deletions src/ax.axopen.app/ctrl/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,29 @@ version: '0.0.0-dev.0'
type: generic
files:
- apax.yml
registries:
"@inxton": "https://npm.pkg.github.com/"
catalogs:
"@inxton/ax.catalog": 0.0.3
devDependencies:
"@inxton/ax-sdk": '0.0.0-dev.0'
catalogs:
"@ax/simatic-ax": 2411.0.0
dependencies:
"@ax/simatic-1500-clocks": 8.0.8
"@ax/system-bitaccess": 8.0.7
"@ax/system-math": 8.0.7
"@ax/system-serde": 8.0.7
installStrategy: strict
apaxVersion: 3.4.2
scripts:
ib: |
apax install
apax build
icb: |
apax install --catalog
apax ib
cib: |
apax clean
apax ib
cicb: |
apax clean
apax icb
8 changes: 8 additions & 0 deletions src/ax.axopen.hwlibrary/ax.axopen.hwlibrary.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"folders": [
{
"path": "ctrl"
}
],
"settings": {}
}
19 changes: 17 additions & 2 deletions src/ax.axopen.hwlibrary/ctrl/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ version: '0.0.0-dev.0'
type: generic
files:
- apax.yml
registries:
"@inxton": "https://npm.pkg.github.com/"
catalogs:
"@inxton/ax.catalog": 0.0.3
devDependencies:
"@inxton/ax-sdk": '0.0.0-dev.0'
catalogs:
"@ax/simatic-ax": 2411.0.0
dependencies:
"@inxton/ax.axopen.min": '0.0.0-dev.0'
"@ax/simatic-1500-distributedio": 8.0.6
Expand All @@ -17,3 +19,16 @@ dependencies:
"@ax/system-bitaccess": 8.0.7
installStrategy: strict
apaxVersion: 3.4.2
scripts:
ib: |
apax install
apax build
icb: |
apax install --catalog
apax ib
cib: |
apax clean
apax ib
cicb: |
apax clean
apax icb
8 changes: 8 additions & 0 deletions src/ax.axopen.min/ax.axopen.min.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"folders": [
{
"path": "ctrl"
}
],
"settings": {}
}
19 changes: 17 additions & 2 deletions src/ax.axopen.min/ctrl/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,26 @@ version: '0.0.0-dev.0'
type: generic
files:
- apax.yml
registries:
"@inxton": "https://npm.pkg.github.com/"
catalogs:
"@inxton/ax.catalog": 0.0.3
devDependencies:
"@inxton/ax-sdk": '0.0.0-dev.0'
catalogs:
"@ax/simatic-ax": 2411.0.0
dependencies:
"@ax/system-strings": 8.0.7
installStrategy: strict
apaxVersion: 3.4.2
scripts:
ib: |
apax install
apax build
icb: |
apax install --catalog
apax ib
cib: |
apax clean
apax ib
cicb: |
apax clean
apax icb
Loading

0 comments on commit 25fddd5

Please sign in to comment.