A package is a bundle of code that provides specific functionality and can be easily shared and reused. It typically includes tools, compiled code, or source code. Examples of packages are:
Packages can be individually updated, which significantly simplifies the process of updating a library.
The full package name then becomes something like @ax/package-name
, helping in organizing and managing packages, especially when dealing with multiple registries.
Packages in Apax use semantic versioning (semver): MAJOR.MINOR.PATCH
.
1.0.0
to 2.0.0
)1.0.0
to 1.1.0
)1.0.0
to 1.0.1
)Examples:
@ax/system-timer@1.0.0
to @ax/system-timer@2.0.0
: major update@ax/system-timer@1.0.0
to @ax/system-timer@1.1.0
: minor update@ax/system-timer@1.0.0
to @ax/system-timer@1.0.1
: patch updateThe caret symbol ^
in version (e.g., ^1.0.0
) allows updates that do not change the first non-zero digit (e.g., 1.x.x
). Example apax.yml
configuration:
dependencies:
"@ax/system-timer": ^1.0.0
Dependencies are external libraries or tools that your project needs to function correctly.
There are two types of dependencies:
@ax
for SIMATIC AX packages00 - Prerequisites
01 - Introduction to package management
02 - Use Apax
03 - Building the project
04 - Summary
05 - Feedback
In this section, you will learn about:
apax --version
apax create [template] [project-name]
apax install
To verify that Apax is installed correctly and to check its version, you can use the following command in your terminal:
apax --version
this command will display the current version of Apax installed on your system.
Before you can fetch packages from a registry, you need to log in. This is done using the apax login
command. Since we are not using any external registries at this point, we will log in to the @ax
registry.
apax login
This command will login for the @ax
registry. Once logged in, you will be able to fetch and manage packages from this registry.
apax create
There are two main templates you can use with apax create
:
In addition to the app and lib templates, Apax offers several other templates to help you get started with different types of projects:
These templates can be used to streamline the project creation process and ensure that you have the necessary structure and dependencies in place from the start.
The apax create
command allows you to create a new project from a template. The syntax for this command is:
apax create [template] [project-name]
Here, [template]
is the name of the template you want to use, and [project-name]
is the name of the new project. There are several templates available, but the most important ones are app and lib.
For example, to create a new application project named "my-first-app", you would use the following command:
apax create app my-first-app
After creating the project and opening it in AxCode, you will see the following structure:
configuration.st
and a program.st
, both written in Structured Text, a standardized language for automation systems. These files will be covered in detail in the chapter on ST ProgrammingThis structure helps in organizing your project files and dependencies efficiently.
When you open the project with AX Code, you will find an apax.yml
file. This file is the project manifest and contains important information about the project, such as:
This file helps in defining everything specific to the project, automating workflows with scripts, and specifying where the code is supposed to run.
The type
field in the apax.yml
file defines the nature of the project. The possible values are:
For now, we will focus on lib and app types, as they are essential for the daily work of automation engineers.
Let's take a closer look at the app and lib types:
The devDependencies
field in the apax.yml
file lists the tools and libraries required for developing and testing your project. By default, it includes the latest SDK (Software Development Kit).
The targets
field in the apax.yml
file specifies the target platforms for your project. Currently, the possible values are 1500 and LLVM.
By defining the target, you ensure that the project is compiled and built for the correct platform, whether it's for deployment on a PLC or for running unit tests.
Before starting your project, install the dependencies with:
apax install
To add a new dependency to your project, you can use the apax add
command. For example, to add the @ax/system-timer
package, you would use the following command:
apax add @ax/system-timer
When you run this command, the following happens:
@ax/system-timer
package is fetched from the registryapax.yml
has a new entry dependencies:
dependencies:
"@ax/system-timer": ^8.0.8
apax-lock.json
file is updated to lock the version of the added package00 - Prerequisites
01 - Introduction to package management
02 - Use Apax
03 - Building the project
04 - Summary
05 - Feedback
In this section, you will learn about:
apax build
Now that all packages have been installed, we can build the project using this command:
apax build
This will invoke the stc
(Structured Text compiler) and transform the source code into a target specific binary. This binary can then be loaded onto the PLC.
The compiler will check for any syntactical or semantical errors and abort the compilation if the code has errors.
> apax build ✔ Package verification succeeded. using targets stc --input C:\MyProject\src --target s7generic --output bin\1500 --compile-to app:myapp:0.1.0 --debug AX Structured Text (ST) compiler V7.0.52.28545. info: stc[0] Compile finished with 0 error(s).
Now that you have compiled, you will be able to find the binary file in the respective target subfolder in the bin directory. You can define the target in the apax.yml manifest.
> apax build ✔ Package verification succeeded. using targets stc --input C:\MyProject\src --target s7generic --output bin\1500 --compile-to app:myapp:0.1.0 --debug AX Structured Text (ST) compiler V7.0.52.28545. info: stc[0] Compile finished with 0 error(s).
For a detailed guide on the complete workflow from creating a project to downloading it onto a PLC, refer to the Getting Started guide.
In the Getting Started guide, you will learn about:
apax install
apax build
In this section you learned about...
you can now create your own project and continue with the next section