Skip to content

Latest commit

 

History

History
217 lines (141 loc) · 7.37 KB

index.md

File metadata and controls

217 lines (141 loc) · 7.37 KB

AX# is an open-source project developed by a group of automation engineers. It provides easy access from .NET-based applications to SIMATIC-AX based PLC programs.

Open source repository is here.

Note

This project is under development. We periodically release versions that can be used for testing and in non-production environments.

Disclaimer

Important

It is necessary to have a valid license for SIMATIC AX in order to use AX#!
SIMATIC AX is currently in a limited sales release in selected European countries only. You will need to request access from the AX team which will check if your use case is suitable for the current state of the product. The first step to getting the approval is contacting your local SIEMENS sales representative or writing an email to simatic-ax@siemens.com.

What's in

Transpiles the structured text program data to .NET twin objects. These objects provide different methods of accessing the PLC data. Twin objects are suitable to use for HMI (with any .NET UI framework like WPF, Blazor, MAUI or WinForms). Twins implement value change notifications which makes it easy for the UI framework to react to changes in the PLC.

Mirroring the PLC program in a .NET object gives any solution consistency and scalability on a scale hard to achieve with traditional approaches.

The connectors provide a communication layer for twin objects generated by the compiler (ixc).

The presentations provide a mechanism for automated UI generation from PLC code. The UI layout and properties are malleable with the directives in the PLC code.

Prerequisites

Make sure you have installed both .NET6 and .NET7.

Getting started

Make sure you meet all prerequisites.

Add package source

To get early access to the packages from AX# you will need to get access to a dedicated package feed hosted on GitHub. 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)

Creating new project

There are different ways you can use to create new project. At this point we support some basic application templates, but you can create your solution also from scratch.

IMPORTANT! Prepare your PLC and AX project

Before you start using any of the method below yoiu will need to set up your PLC. Using TIA portal you need to enable WebAPI interface see here and here is a very informative youtube video.

[!Video https://youtu.be/d9EX2FixY1A?t=151]

Creating new project using templates

Install AX# template package

When using .NET7

dotnet new install AXSharp.templates

When using .NET6 and earlier

dotnet new --install AXSharp.templates

Note

Make sure all nuget feed sources are available at the time of installation of packages. If you are not sure run dotnet nuget list source and check that the sources listed are reachable. The installation may fail if some of the source is not available.

List available templates

dotnet new list --tag AX#

Template Name                   Short Name  Language  Tags
------------------------------  ----------  --------  -----------------
AX# Blazor application           axeblazor    [C#]      AX#/Blazor
AX# Simmple console application  axeconsole   [C#]      AX#/Console-Simple
.
.
.

Create new project from template

dotnet new [shortname] -n YOUR_PROJECT_NAME
#e.g. dotnet new axeblazor -n MyFristAXSharpBlazorProject

When prompted about script execution allow the script to run (answer (Y)es) in order to finish the scaffolding of the project. If you're creating the project using Visual Studion you will need to run the script manually.

Consult README.md file located in your new project for additional information.

NOTE! Templates contain some of settings that differ from the defaults. The AX# twin project might be located in different location that apax's ix folder.



Creating new project from scratch

If you don't want to use application template you can create AX# project from scratch.

Install ixc AX# compiler CLI

ixc is CLI implementation of AX# Compiler.

Open the terminal in the directory of your AX project (the one where the apax.yml file lives), and run the following commands:

dotnet new tool-manifest 
dotnet tool install --local AXSharp.ixc --prerelease

This will install the ixc compiler tool for your project.

Run ixc tool in your project directory

To run ixc do in your ax project directory:

dotnet ixc

ixc will create a new folder (defaults to ix in your ax project folder) where you can find the C# Twin project of your AX program.

The ixc help can be displayed running.

dotnet ixc --help

ixc 0.5.0-1.8+Branch.wip-webapiconnector-1.Sha.7b12285dc7e7aa72995e9e47bbcf7f4cf386f170
Copyright (C) 2022 author

  -x, --source-project-folder    Simatic-ax project folder

  -o, --output-project-folder    Output folder.

  --help                         Display this help screen.

  --version                      Display version information.

Before usage apax commanad ensure that you are logged in

apax login 

Run apax install to install dependencies of your AX project

apax install 

You will need to load your PLC with --default-server-interface in render your PLC program data accessible via WebAPI interface.

apax build
apax sld -t YOUR-SYSTEM-IP -i .\bin\1500\ --accept-security-disclaimer -r --default-server-interface

Connecting PLC.NET Twin to the PLC

using AXSharp.Connector;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AXSharp.Connector.Sax.WebApi;

namespace your_project_name
{
    public static class Entry
    {
        // Connecting to read PLC using WebAPI
        public static my_plcTwinController Plc { get; } = new (ConnectorAdapterBuilder.Build().CreateWebApi("10.10.101.1", "Everybody", "", true));
        // Connecting to dummy
        public static my_plcTwinController PlcDummy { get; } = new (ConnectorAdapterBuilder.Build().CreateDummy());
    }
}

Start PLC twin operations

// This start cyclical operation on PLCTwin at 10ms rate
your_project_name.Entry.Plc.Connector.BuildAndStart().ReadWriteCycleDelay = 10;