Skip to content

Commit

Permalink
Merge pull request #362 from ix-ax/template_library
Browse files Browse the repository at this point in the history
Template library
  • Loading branch information
PTKu authored Mar 27, 2024
2 parents 156527c + 261ad92 commit 479e3a2
Show file tree
Hide file tree
Showing 49 changed files with 218,404 additions and 579 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,9 @@ apax-lock.json

docs-test/
src/.application/

#secrets
certs

#compiled gsd
hwc\import-cache
14 changes: 13 additions & 1 deletion scripts/create_template_library.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ Remove-Item $FolderNameCtrl -r -force -ErrorAction Ignore

dotnet new axolibrary -o $OutputDirectory -p $ProjectNamespace


if (Test-Path $OutputDirectory) {
Set-Location $OutputDirectory
}

#Remove source items
$item = ".\app\ix\app_apaxappname.csproj"
Remove-Item $item -r -force -ErrorAction Ignore
$item = ".\src\"+ $ProjectNamespace + "\ix_ax_apaxlibname.csproj"
Remove-Item $item -r -force -ErrorAction Ignore

Set-Location app
apax install
apax build
Expand All @@ -40,5 +45,12 @@ dotnet build this.proj
dotnet slngen this.proj -o this.sln --folders true --launch false
# & 'C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\devenv.exe' this.sln

$dest = $OutputDirectory + ".code-workspace"
Copy-Item -Path "..\template.axolibrary\template.axolibrary.code-workspace" -Destination $dest
$dest = $OutputDirectory + ".sln"
Copy-Item -Path "this.sln" -Destination $dest



write-host "-----------------------------------------------------------"
write-host "Done"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NAMESPACE AXOpen.Components.Mitsubishi.Robotics
{S7.extern=ReadWrite}
{#ix-attr:[Container(Layout.Stack)]}
CLASS PUBLIC AxoMitsubishiRobotics_Component_Status_v_1_x_x EXTENDS AXOpen.Components.Robotics. AxoRobot_Status
CLASS PUBLIC AxoMitsubishiRobotics_Component_Status_v_1_x_x EXTENDS AXOpen.Components.Robotics.AxoRobot_Status
VAR PUBLIC
END_VAR
END_CLASS
Expand Down
146 changes: 144 additions & 2 deletions src/components.siemens.identification/app/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,26 @@ targets:
variables:
APAX_BUILD_ARGS:
- "--debug" # Generate debug information for target "1500"
AXTARGET: "10.10.10.120"
AXTARGETPLATFORMINPUT: "bin/1500"
PC_MAC: "00:D8:61:F0:AB:7D"
PLC_MAC: "EC:1C:5D:92:3F:F4"
PLC_NAME: "plc_line"
PLC_IP: "10.10.10.120"
RF186_MAC: "EC:1C:5D:8C:9C:62"
RF186_NAME: "rf186c"
RF186_IP: "10.10.10.99"
ET201_MAC: "EC:1C:5D:B2:E1:59"
ET201_NAME: "et200sp"
ET201_IP: "10.10.10.98"

GATEWAY_IP: "10.10.10.1"

devDependencies:
"@ix-ax/ax-sdk": '0.0.0-dev.0'
"@ax/sld": 2.0.5
"@ax/hwc": ^0.12.217
"@ax/hwld": ^0.8.23
"@ax/dcp-utility": ^1.1.1
dependencies:
"@ix-ax/axopen.core": '0.0.0-dev.0'
"@ix-ax/axopen.timers": '0.0.0-dev.0'
Expand All @@ -19,6 +36,7 @@ dependencies:
"@ix-ax/axopen.simatic1500": '0.0.0-dev.0'
"@ax/simatic-1500-clocks": ^6.0.37
"@ax/system-serde": ^6.0.94
"@ax/plc-mode": ^1.0.0
scripts:
delta:
- START=$(date +%s)
Expand Down Expand Up @@ -86,5 +104,129 @@ scripts:
- apax download_only
dd:
- apax delta

gsd: | # copy and install all gsdml files from library
if [ -d "../ctrl/assets" ]; then
echo "Directory "../ctrl/assets" exists!!!"
if ! [[ -d "../gsd/source" ]]; then
echo "Directory "../gsd/source" does not exist!!!"
mkdir -p "./gsd/source"
fi
cp ../ctrl/assets/[gG][sS][dD][mM][lL]*.xml ./gsd/source
apax hwc install-gsd --input ./gsd/source
else
echo "Directory "../ctrl/assets" does not exist!!!"
fi
dcpli: apax dcp-utility list-interfaces -f JSON # list all interfaces, used to discover MAC address of the adapter connected to PLC and set the PC_MAC value accordingly

dcpd: apax dcp-utility discover --source-mac $PC_MAC --timeout 10000 # discover all accesible devices connected to adapter with MAC address equal to PC_MAC, used to discover MAC-addresses of the slaves and setting the PLC_MAC,RF186_MAC and ET201_MAC variables

reset_plc: apax hwld -t $PLC_IP --resetPlc All --accept-security-disclaimer #total reset of the PLC including IP and name

set_IPs_and_Names:
# setting the IPs and names according to variables PLC_NAME,PLC_IP,RF186_NAME,RF186_IP,ET201_NAME and ET201_IP
- apax dcp-utility set-name --source-mac $PC_MAC --target-mac $PLC_MAC
-n $PLC_NAME --no-prompt
- apax dcp-utility set-ip --source-mac $PC_MAC --target-mac $PLC_MAC
--ip $PLC_IP --subnet-mask 255.255.255.0 --gateway
$GATEWAY_IP --no-prompt
- apax dcp-utility set-name --source-mac $PC_MAC --target-mac $RF186_MAC
-n $RF186_NAME --no-prompt
- apax dcp-utility set-ip --source-mac $PC_MAC --target-mac $RF186_MAC
--ip $RF186_IP --subnet-mask 255.255.255.0 --gateway
$GATEWAY_IP --no-prompt
- apax dcp-utility set-name --source-mac $PC_MAC --target-mac $ET201_MAC
-n $ET201_NAME --no-prompt
- apax dcp-utility set-ip --source-mac $PC_MAC --target-mac $ET201_MAC
--ip $ET201_IP --subnet-mask 255.255.255.0 --gateway
$GATEWAY_IP --no-prompt

ssc:
# setup secure communication, import certificates, setup password for 'usr'
- apax hwc setup-secure-communication -n $PLC_NAME -i "plc_line.hwl.json" -p
$MY_VERY_STRONG_PASSWORD
- apax hwc import-certificate -n $PLC_NAME -i "plc_line.hwl.json" -C
"./certs/$PLC_NAME/pkcs12ForCertificateImport.p12" -p
$MY_VERY_STRONG_PASSWORD --purpose "TLS"
- apax hwc import-certificate -n $PLC_NAME -i "plc_line.hwl.json" -C
"./certs/$PLC_NAME/pkcs12ForCertificateImport.p12" -p
$MY_VERY_STRONG_PASSWORD --purpose "WebServer"
- apax hwc manage-users -n $PLC_NAME -i "plc_line.hwl.json" set-password -u
"usr" -p $MY_VERY_STRONG_PASSWORD

hwfd:
#compile, copy the HdIds, first download HW using password and upload certificate
- apax hwc compile -i plc_line.hwl.json -o bin/hwc/
- apax hwid
- apax hwld -i bin/hwc/$PLC_NAME -t $PLC_IP -M:$MY_VERY_STRONG_PASSWORD
--accept-security-disclaimer -l Information
- apax plc-cert -t $PLC_IP -o ./certs/$PLC_NAME/$PLC_NAME.cer
hwu:
#compile, copy the HdIds, download HW using certificate
- apax hwc compile -i plc_line.hwl.json -o bin/hwc/
- apax hwid
- apax hwld -i bin/hwc/$PLC_NAME -t $PLC_IP -C
./certs/$PLC_NAME/$PLC_NAME.cer --nonInteractive
--accept-security-disclaimer -l Information

hwid: | # copy the generated HwIds from global constants into the type definition, matching the format as the TIA2AX tool creates
output_dir=src/IO/$PLC_NAME
if ! [[ -d $output_dir ]]; then
echo "Directory $output_dir does not exist!!!"
mkdir -p $output_dir
fi
output_file="$output_dir/HwIdentifiers.st"
input_file=SystemConstants/$PLC_NAME"_HwIdentifiers.st"
lines_to_replace=("CONFIGURATION HardwareIDs" "VAR_GLOBAL CONSTANT" "END_VAR" "END_CONFIGURATION")
old_substrings=(": UINT := UINT" ";")
new_substrings=(":= WORD" ",")
echo "TYPE" > "$output_file"
echo " HwIdentifiers : WORD" >> "$output_file"
echo " (" >> "$output_file"
while IFS= read -r line; do
copy_this_line=true
for line_to_replace in "${lines_to_replace[@]}"; do
if grep -qF "$line_to_replace" <<< "$line"; then
copy_this_line=false
break
fi
done
if $copy_this_line; then
modified_line="$line"
for ((i=0; i<${#old_substrings[@]}; i++)); do
old_substring="${old_substrings[i]}"
new_substring="${new_substrings[i]}"
modified_line="${modified_line//$old_substring/$new_substring}"
done
echo "$modified_line" >> "$output_file"
fi
done < "$input_file"
echo " NONE := WORD#0" >> "$output_file"
echo " );" >> "$output_file"
echo "END_TYPE" >> "$output_file"
swfd:
#software build and full download
- apax install
- apax build --ignore-scripts
- dotnet ixc
- apax sld load --accept-security-disclaimer -t $AXTARGET -i
$AXTARGETPLATFORMINPUT -r -C ./certs/$PLC_NAME/$PLC_NAME.cer

swdd:
#software build and delta download
- apax install
- apax build --ignore-scripts
- dotnet ixc
- apax sld load --accept-security-disclaimer -t $AXTARGET -i
$AXTARGETPLATFORMINPUT -r -C ./certs/$PLC_NAME/$PLC_NAME.cer --mode delta

all:
- START=$(date +%s)
- apax hwu
- apax swfd
- echo $(date +%D)"-"$(date +%H)":"$(date +%M)":"$(date +%S) " - Finished in
:" $(expr $(date +%s) - $START) "s"
installStrategy: strict
apaxVersion: 3.1.0
apaxVersion: 3.1.1
Loading

0 comments on commit 479e3a2

Please sign in to comment.