Skip to content

Commit

Permalink
Add control of the project name entered, if it meets the required pat…
Browse files Browse the repository at this point in the history
…tern (#28)

* Create draft PR for #27

* Project name verification added

* wip

---------

Co-authored-by: TK <61820360+TomKovac@users.noreply.github.com>
  • Loading branch information
IX-BOT and TomKovac authored Nov 20, 2024
1 parent 0b5450e commit 21a6dbc
Show file tree
Hide file tree
Showing 26 changed files with 431 additions and 6,358 deletions.
16 changes: 16 additions & 0 deletions Create-Simple.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@ param (
[Parameter(Mandatory=$true)]
[string]$ProjectName
)
# Check project name defined
$pattern = '^(@[A-Z][a-z0-9-_.~]*/)?[A-Z][a-z0-9-_~]*(?:\.[A-Z][a-z0-9-_~]*)*$'

# Validate the project name
if (-not ($ProjectName -match $pattern)) {
Write-Host "The project name value does not match the required pattern." -ForegroundColor Red
Write-Host "Rules:"
Write-Host "1. The project name must start with a capital letter."
Write-Host "2. After a dot (.), the next character must also be a capital letter."
Write-Host "3. It may optionally include a namespace starting with '@' and ending with '/'."
Write-Host "4. Subsequent characters can include lowercase letters, numbers, dashes (-), underscores (_), and tildes (~)."
Write-Host "Example of valid project names: 'Project.Name', '@Namespace/Project.Name', 'Valid.Name-Extra'." -ForegroundColor Yellow
Write-Host "Example of invalid project names: 'project.Name', 'Project.name', 'Project.123', '@namespace/project.name'." -ForegroundColor Yellow
exit 1 # Exit the script with a non-zero status code
}


# Define repository directories
$axopenRepoDir = ".\axopen"
Expand Down
82 changes: 45 additions & 37 deletions axopen.template.simple/ax/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,22 @@ dependencies:
# "@ix-ax/axopen.components.mitsubishi.robotics": '0.4.4-alpha.857'
# "@ix-ax/axopen.components.ur.robotics": '0.4.4-alpha.857'
# "@ix-ax/axopen.simatic1500": '0.4.4-alpha.857'
"@ax/hwc": ^2.0.49
"@ax/hw-s7-1500": ^2.0.49
"@ax/hwld": ^2.0.20
installStrategy: overridable
apaxVersion: 3.1.1
variables:
APAX_BUILD_ARGS: [ -d ]
PLC_NAME: "plc_line"
HWCONFIG: "TIA"
HWCONFIG: "HWC"
AXTARGET: 10.222.6.1
AXTARGETPLATFORMINPUT: .\bin\1500\
AX_USERNAME: "adm"
AX_TARGET_PWD: "123ABCDabcd$#!"
MY_VERY_STRONG_PASSWORD: $AX_TARGET_PWD
COM_CERT_PATH: .\certs\Communication.cer
scripts:
ci: apax clean apax install
ixc:
- dotnet tool restore --no-cache
- dotnet ixc -d
- dotnet ixr
postbuild: apax ixc
push:
- apax build
- apax download
Expand Down Expand Up @@ -169,65 +168,74 @@ scripts:
if [[ "$HWCONFIG" == "TIA-NON-SECURE" ]]; then
apax sld load --accept-security-disclaimer -t $AXTARGET -i $AXTARGETPLATFORMINPUT --mode delta
fi
plcsim: ..\\scripts\\StartPlcSimAdvCli.exe #start PLCSIM
r: ..\\scripts\\restart_PLC.sh $AXTARGET $PLC_NAME
dcpli: ..\\scripts\\dcp_utility_list_interfaces.sh
dcpd: ..\\scripts\\dcp_utility_discover.sh $PNIO_MAC
hdl: ..\\scripts\\hw_diag_list.sh $AXTARGET $PLC_NAME
clean_plc: |
ixc: | # run ix builder
dotnet tool restore
dotnet ixc
postbuild: apax run ixc # run after build
dcpli: | # list all interfaces, used to discover MAC address of the adapter connected to PLC
..\\..\\scripts\\dcp_utility_list_interfaces.sh
dcpd: | # discover all accesible devices connected to adapter with MAC address equal to entered MAC, used to discover MAC-addresses of the slaves
..\\..\\scripts\\dcp_utility_discover.sh $PNIO_MAC
hdl: | #List configured harware and its state
..\\..\\scripts\\hw_diag_list.sh $AXTARGET $PLC_NAME
ci: | #clean and install dependencies
apax clean
apax install
reset_plc: | #total reset of the PLC including IP and name
if [[ "$HWCONFIG" == "HWC" ]]; then
..\\scripts\\reset_plc.sh $AXTARGET
fi
clean_plc: | #total reset of the PLC excluding IP and name
if [[ "$HWCONFIG" == "HWC" ]]; then
..\\scripts\\clean_plc.sh $AXTARGET
fi
ssc: |
ssc: | # setup secure communication, create and import certificates, setup password for AX_USERNAME
if
[[ "$HWCONFIG" == "HWC" ]]; then ..\\scripts\\setup_secure_communication.sh $PLC_NAME $AX_USERNAME $AX_TARGET_PWD
fi
gsd: |
gsd: | # copy and install all gsdml files from libraries
if
[[ "$HWCONFIG" == "HWC" ]]; then
..\\scripts\\copy_and_install_gsd.sh
fi
hwl: |
hwl: | # copy all templates from libraries
if [[ "$HWCONFIG" == "HWC" ]]; then
..\\scripts\\copy_hwl_templates.sh
fi
hwid: |
hwid: | # copy the generated HwIds from global constants into the type definition, matching the format as the TIA2AX tool creates
if [[ "$HWCONFIG" == "HWC" ]]; then
..\\scripts\\copy_hardware_ids.sh
fi
hwfd: |
hwfd: | # copy and install gsd, copy templates,compile, copy the HwIds, first download HW using password and upload certificate
if [[ "$HWCONFIG" == "HWC" ]]; then
..\\scripts\\hw_first_download.sh $PLC_NAME $AXTARGET $AX_TARGET_PWD
fi
hwu: |
hwu: | # copy and install gsd, copy templates, compile, copy the HwIds, download HW using certificate
if [[ "$HWCONFIG" == "HWC" ]]; then
..\\scripts\\hw_update.sh $PLC_NAME $AXTARGET
fi
swfd: |
swfd: | # software build and full download
if [[ "$HWCONFIG" == "HWC" ]]; then
..\\scripts\\sw_build_and_download_full.sh $PLC_NAME $AXTARGET $AXTARGETPLATFORMINPUT
fi
swdd: |
swdd: | # software build and delta download
if [[ "$HWCONFIG" == "HWC" ]]; then
..\\scripts\\sw_build_and_download_delta.sh $PLC_NAME $AXTARGET $AXTARGETPLATFORMINPUT
fi
alf:
- START=$(date +%s)
- |
if
[[ "$HWCONFIG" == "HWC" ]]; then
..\\scripts\\all_first.sh $PLC_NAME $AXTARGET $AXTARGETPLATFORMINPUT $AX_USERNAME $AX_TARGET_PWD
fi
- echo $(date +%D)"-"$(date +%H)":"$(date +%M)":"$(date +%S) " - Finished in :" $(expr $(date +%s) - $START) "s"
all:
- START=$(date +%s)
- |
if
[[ "$HWCONFIG" == "HWC" ]]; then
..\\scripts\\all.sh $PLC_NAME $AXTARGET $AXTARGETPLATFORMINPUT
fi
- echo $(date +%D)"-"$(date +%H)":"$(date +%M)":"$(date +%S) " - Finished in :" $(expr $(date +%s) - $START) "s"
alf: | #clear plc except ip and name and provide all actions for install all, build and initial download hw so as sw
START=$(date +%s)
if [[ "$HWCONFIG" == "HWC" ]]; then
..\\scripts\\all_first.sh $PLC_NAME $AXTARGET $AXTARGETPLATFORMINPUT $AX_USERNAME $AX_TARGET_PWD
fi
echo $(date +%D)"-"$(date +%H)":"$(date +%M)":"$(date +%S) " - Finished in :" $(expr $(date +%s) - $START) "s"
all: | #build and download hardware and software
START=$(date +%s)
if [[ "$HWCONFIG" == "HWC" ]]; then
..\\scripts\\all.sh $PLC_NAME $AXTARGET $AXTARGETPLATFORMINPUT
fi
echo $(date +%D)"-"$(date +%H)":"$(date +%M)":"$(date +%S) " - Finished in :" $(expr $(date +%s) - $START) "s"
publicKeys:
"@ix-ax": 30c06ef7830b4dfd8f16e003508da1ac2d187714d0e1f38279a9332cbe4e4e17
installStrategy: overridable
apaxVersion: 3.1.1
Loading

0 comments on commit 21a6dbc

Please sign in to comment.