Skip to content

Commit

Permalink
[NEW-FEATURE] Update to apax 2.0 (#255)
Browse files Browse the repository at this point in the history
* Create draft PR for #241

* fixies the messages (adds sensor overshot)

* update to apax 2.0.0 and updates ax sdk

* adjustments to template

* adjustments to template

* documentation and pre-requisites script update

---------

Co-authored-by: PTKu <[email protected]>
Co-authored-by: PTKu <[email protected]>
  • Loading branch information
3 people authored Oct 10, 2023
1 parent ae81c21 commit 3768264
Show file tree
Hide file tree
Showing 62 changed files with 710 additions and 291 deletions.
2 changes: 1 addition & 1 deletion cake/ApaxCmd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static void ApaxInstall(this BuildContext context, (string folder, string
{
foreach (var folder in context.GetAxFolders(lib))
{
var apaxArguments = context.BuildParameters.DoApaxInstallReDownload ? "install -L -r" : "install -L";
var apaxArguments = context.BuildParameters.DoApaxInstallReDownload ? "install -r" : "install";

context.Log.Information($"apax install started for '{lib.folder} : {lib.name}'");
context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings()
Expand Down
61 changes: 52 additions & 9 deletions scripts/check_requisites.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
## Check pre-requisites

# Check for dotnet 7.0
$dotnetVersion = (dotnet --version 2>$null)
if (-not $dotnetVersion -or ($dotnetVersion -lt 7.0)) {
Write-Error "dotnet 7.0 is not installed or an older version is detected."
# List all installed .NET SDKs
$dotnetSDKs = (dotnet --list-sdks 2>$null)
$dotnet6Installed = $false
$dotnet7Installed = $false

foreach ($sdk in $dotnetSDKs) {
if ($sdk -like "6.*") {
$dotnet6Installed = $true
}
if ($sdk -like "7.*") {
$dotnet7Installed = $true
}
}

if (-not $dotnet6Installed) {
Write-Error ".NET 6.0 SDK is not installed."
} else {
Write-Output "dotnet 7.0 detected."
Write-Host ".NET 6.0 SDK detected." -ForegroundColor Green
}

if (-not $dotnet7Installed) {
Write-Error ".NET 7.0 SDK is not installed."
} else {
Write-Host ".NET 7.0 SDK detected." -ForegroundColor Green
}

# Check for Visual Studio 2022
Expand All @@ -15,16 +33,41 @@ if (Test-Path $vsWhere) {
if (-not $vsVersion) {
Write-Error "Visual Studio 2022 is not detected."
} else {
Write-Output "Visual Studio 2022 detected: $vsVersion"
Write-Host "Visual Studio 2022 detected: $vsVersion" -ForegroundColor Green
}
} else {
Write-Error "vswhere tool not found. Unable to determine if Visual Studio 2022 is installed."
}

# Check for apax
try {
apax --version | Out-Null
Write-Output "Apax detected."
$apaxVersion = (apax --version).Trim()
if ($apaxVersion -eq "2.0.0") {
Write-Host "Apax 2.0.0 detected." -ForegroundColor Green
} else {
Write-Error "Apax version mismatch. Expected 2.0.0 but found $apaxVersion."
Write-Error "Run apax self-update $apaxVersion."
}
} catch {
Write-Error "Apax is not installed or not found in PATH."
Write-Error "Apax is not installed or not found in PATH. You need to have valid SIMATIC-AX license."
}


$feedUrl = "https://nuget.pkg.github.com/ix-ax/index.json"

$headers = @{
"Authorization" = "Bearer $userToken"
"User-Agent" = "PowerShell"
"Accept" = "application/vnd.github.package-preview+json"
}


try {
# Just check the access by trying to get the feed
$response = Invoke-RestMethod -Uri $feedUrl -Headers $headers -Method Get
Write-Host "Successfully accessed feed: $feedUrl" -ForegroundColor Green
}
catch {
Write-Host "Failed to access feed: $feedUrl. Error: $($_.Exception.Message)" -ForegroundColor Red
Write-Host "You will need to add $feed to your nuget sources manually (more information in src/README.md)." -ForegroundColor Red
}
31 changes: 0 additions & 31 deletions scripts/create_application.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,6 @@ param (
[string]$ProjectName
)

## Check pre-requisites

# Check for dotnet 7.0
$dotnetVersion = (dotnet --version 2>$null)
if (-not $dotnetVersion -or ($dotnetVersion -lt 7.0)) {
Write-Error "dotnet 7.0 is not installed or an older version is detected."
} else {
Write-Output "dotnet 7.0 detected."
}

# Check for Visual Studio 2022
$vsWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
if (Test-Path $vsWhere) {
$vsVersion = & $vsWhere -version "[17.0,18.0)" -products * -property catalog_productDisplayVersion
if (-not $vsVersion) {
Write-Error "Visual Studio 2022 is not detected."
} else {
Write-Output "Visual Studio 2022 detected: $vsVersion"
}
} else {
Write-Error "vswhere tool not found. Unable to determine if Visual Studio 2022 is installed."
}

# Check for apax
try {
apax --version | Out-Null
Write-Output "Apax detected."
} catch {
Write-Error "Apax is not installed or not found in PATH."
}

# Store the current directory
$lf = Get-Location

Expand Down
39 changes: 39 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
# About this Repository

## Pre-requisites

- APAX 2.0.0
- AXCODE
- DOTNET 6.0, 7.0
- VSCODE or VS2022

### Add package source

To get access to the packages from `AX#` and `AXOpen` you will need to authenticate to a dedicated package feed hosted on GitHub. Authentication is free. If you do not have a GitHub account please consider creating one by signing up at https://github.com.

~~~
dotnet nuget add source --username GITHUBUSERNAME --password PAT --store-password-in-clear-text --name gh-packages-ix-ax "https://nuget.pkg.github.com/ix-ax/index.json"
~~~

Replace GITHUBUSERNAME with your github name
Replace PAT with your Personal Access Token ([how to create your PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token))


### Checking pre-requisites using script

To check pre-requisites in your enviroment run [check_requisites.ps1](../scripts/check_requisites.ps1) script.



~~~Powershell
# cd into your `axopen` folder
.\scripts\check_requisites.ps1
~~~

## Build this repository

In order to build this repostory run [build.ps1](../build.ps1) script.

~~~Powershell
# cd into your `axopen` folder
.\build.ps1
~~~

## Directory Structure

### **docfx**
Expand Down
2 changes: 1 addition & 1 deletion src/abstractions/app/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ variables:
APAX_BUILD_ARGS:
- "--debug" # Generate debug information for target "1500"
devDependencies:
"@ax/sdk": ^4.0.8
"@ax/sdk": 4.0.12
"@ax/sld": 0.15.9
dependencies:
"@ix-ax/axopen.abstractions": '0.0.0-dev.0'
Expand Down
2 changes: 1 addition & 1 deletion src/abstractions/ctrl/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ files:
- src
- axsharp.companion.json
devDependencies:
"@ax/sdk": ^4.0.8
"@ax/sdk": 4.0.12
dependencies:
"@ax/system-strings": ^5.0.12
scripts:
Expand Down
2 changes: 1 addition & 1 deletion src/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ name: "ix-ax"
version: 0.1.0
type: workspace
devDependencies:
"@ax/sdk": ^4.0.8
"@ax/sdk": 4.0.12
2 changes: 1 addition & 1 deletion src/components.abstractions/app/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ variables:
APAX_BUILD_ARGS:
- "--debug" # Generate debug information for target "1500"
devDependencies:
"@ax/sdk": ^4.0.8
"@ax/sdk": 4.0.12
"@ax/sld": 0.15.9
dependencies:
"@ix-ax/axopen.components.abstractions": '0.0.0-dev.0'
Expand Down
2 changes: 1 addition & 1 deletion src/components.abstractions/ctrl/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ files:
- src
- axsharp.companion.json
devDependencies:
"@ax/sdk": ^4.0.8
"@ax/sdk": 4.0.12
scripts:
postbuild:
- dotnet ixc
Expand Down
2 changes: 1 addition & 1 deletion src/components.cognex.vision/app/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ targets:
- axunit-llvm
#- "1500"
devDependencies:
"@ax/sdk": ^4.0.8
"@ax/sdk": 4.0.12
"@ax/sld": 0.15.9
"@ax/stc": ^5.4.89
dependencies:
Expand Down
2 changes: 1 addition & 1 deletion src/components.cognex.vision/ctrl/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ files:
- src
- axsharp.companion.json
devDependencies:
"@ax/sdk": ^4.0.8
"@ax/sdk": 4.0.12
scripts:
# prebuild:
# - dotnet ixc
Expand Down
2 changes: 1 addition & 1 deletion src/components.elements/app/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ variables:
APAX_BUILD_ARGS:
- "--debug" # Generate debug information for target "1500"
devDependencies:
"@ax/sdk": 4.0.3
"@ax/sdk": 4.0.12
dependencies:
"@ix-ax/axopen.components.elements" : '0.0.0-dev.0'
scripts:
Expand Down
2 changes: 1 addition & 1 deletion src/components.elements/ctrl/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ files:
- src
- axsharp.companion.json
devDependencies:
"@ax/sdk": ^4.0.3
"@ax/sdk": 4.0.12
scripts:
postbuild:
- dotnet ixc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@

<ItemGroup>
<PackageReference Include="AXSharp.Abstractions" />
<PackageReference Include="AXSharp.Connector" />
<PackageReference Include="GitVersion.MsBuild">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="AXSharp.Connector" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/components.pneumatics/app/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ targets:
- axunit-llvm
- plcsim
devDependencies:
"@ax/sdk": 4.0.3
"@ax/sdk": 4.0.12
"@ax/sld": 0.15.9
dependencies:
"@ix-ax/axopen.components.pneumatics": '0.0.0-dev.0'
"@ix-ax/axopen.simatic1500": '0.0.0-dev.0'
Expand Down
2 changes: 1 addition & 1 deletion src/components.pneumatics/ctrl/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ variables:
AXUNIT_TARGET_IP: "172.20.30.110"
SIM_ENABLED: "true"
devDependencies:
"@ax/sdk": ^4.0.3
"@ax/sdk": 4.0.12
dependencies:
"@ix-ax/axopen.components.abstractions": '0.0.0-dev.0'
"@ix-ax/axopen.core": '0.0.0-dev.0'
Expand Down
13 changes: 9 additions & 4 deletions src/components.pneumatics/ctrl/src/AxoCylinder.st
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,23 @@ NAMESPACE AXOpen.Components.Pneumatics
moveHomeSignal := FALSE;
moveWorkSignal := TRUE;
_MoveToWorkTask.DoneWhen(workSensor);
_MoveToHomeTask.Restore();
_Messenger.ActivateOnCondition(UINT#1, NOT _MoveToWorkIsSuspended AND _MoveToWorkTask.Duration >= T#10S, eAxoMessageCategory#Info);
_MoveToHomeTask.Restore();
END_IF;

_Messenger.ActivateOnCondition(UINT#1, (_MoveToWorkTask.IsBusy() AND NOT _MoveToWorkIsSuspended AND _MoveToWorkTask.Duration >= T#10S), eAxoMessageCategory#Error);
_Messenger.ActivateOnCondition(UINT#9, (_MoveToWorkTask.IsDone() AND NOT workSensor), eAxoMessageCategory#Warning);


IF(_MoveToHomeTask.Execute()) THEN
moveHomeSignal := TRUE;
moveWorkSignal := FALSE;
_MoveToHomeTask.DoneWhen(homeSensor);
_MoveToWorkTask.Restore();
_Messenger.ActivateOnCondition(UINT#2, NOT _MoveToHomeIsSuspended AND _MoveToHomeTask.Duration >= T#10S, eAxoMessageCategory#Info);
_MoveToWorkTask.Restore();
END_IF;

_Messenger.ActivateOnCondition(UINT#2, (_MoveToHomeTask.IsBusy() AND NOT _MoveToHomeIsSuspended AND _MoveToHomeTask.Duration >= T#10S), eAxoMessageCategory#Error);
_Messenger.ActivateOnCondition(UINT#8, (_MoveToHomeTask.IsDone() AND NOT homeSensor), eAxoMessageCategory#Warning);

IF _MoveToWorkIsSuspended THEN
moveWorkSignal := FALSE;
END_IF;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ private void InitializeMessenger()
new KeyValuePair<ulong, AxoMessengerTextItem>(5, new AxoMessengerTextItem("Movement to home position is temporarily suspended.", "Check the blocking condition.")),
new KeyValuePair<ulong, AxoMessengerTextItem>(6, new AxoMessengerTextItem("Movement to work position is aborted.", "Check the blocking condition.")),
new KeyValuePair<ulong, AxoMessengerTextItem>(7, new AxoMessengerTextItem("Movement to home position is aborted.", "Check the blocking condition.")),
new KeyValuePair<ulong, AxoMessengerTextItem>(8, new AxoMessengerTextItem("Movement to home position overshot the extremity sensor.", "Check the sensor position.")),
new KeyValuePair<ulong, AxoMessengerTextItem>(9, new AxoMessengerTextItem("Movement to work position overshot the extremity sensor.", "Check the sensor position.")),
};

_Messenger.DotNetMessengerTextList = messengerTextList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@

<ItemGroup>
<PackageReference Include="AXSharp.Abstractions" />
<PackageReference Include="AXSharp.Connector" />
<PackageReference Include="GitVersion.MsBuild">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="AXSharp.Connector" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 3768264

Please sign in to comment.