Skip to content

AppSDK Development Environment

Development Environment For Linux

Starting from 3.0 release AppSDK development environment provides a command line interface for linux.

Package contains a folder and a bash script called 'install.sh'. install.sh script installs dependencies for AppSDK, indapp-build and AppSDK CLI.

Installation

To install package simply run install.sh script After installation finishes 'appsdk' command should be available in linux terminal.

Usage

'appsdk' has 8 different commands these are:

  • init
  • build
  • package
  • publish
  • clean
  • start
  • stop

Init

usage: appsdk init

Will go through a wizard and create an AppSDK sample project.

Wizard will ask for following inputs

  • Application language(cpp, python, java)

    Gets target language for the project.

  • Application name

    Gets the name of the application.

  • Application type

    Sample application to be created.

  • Config enabling

    Generate default configuration for miniweb and/or file upload features.

After wizard completes, it will automatically generate a sample application structure. Sources of this application is located under source directory. Default build scripts are located under scripts directory and they can be configured as your project's needs change. Also appsdk-project.yaml file is generated at the root folder of application. This file contains information for current structure of the project and any CLI command related to project should be executed at the directory of this file. In case project structure changes, build,script and config paths should also be changed from appsdk-project.yaml file.

Note: We have some naming rules for applications, chekout to see naming rules.

Build

usage: appsdk build

Executes buildProject.sh script under scripts directory of the project. This buildProject.sh script can be edited based on development needs. While developing your project buildProject.sh script should be maintained accordingly.

By default buildProject.sh script copies files required for building indapp to build directory.

Required files are

  • Dockerfile
  • docker-compose.yaml
  • delta.json
  • EdgeAPI
  • Custom project files

Every time appsdk build is executed build directory is deleted and created from the scratch.

Package

usage: appsdk package

Creates swu and indapp package.

While creating package, contents of the build directory is used. Build directory should have Dockerfile, docker-compose.yaml file, delta.json file and required project files in order to successfully create a package.

Please make sure that your build script from the build stage is up to date and successfully places required files to build directory for packaging.

Optional Arguments

Some arguments of indapp-build can be optionally used for appsdk package command.

--release_version : Sets release version of application in metaconfig.

--config_version : Sets compatible config version of the metaconfig.

Note

Default config version for applications are 1.4.1 which is compatible with Edge v3.1+ releases, while 1.4.0 is compatible with Edgev3.0+ releases; 1.4.1 is compatible with Edgev3.1+ releases; 1.4.2 is compatible with Edgev3.2+ releases; 1.5.0 is compatible with Edgev3.3+ releases

$ appsdk package -h
usage: main.py package [-h] [-w TIMEOUT RESTART]
                       [-m [CONFIGTYPE [CONFIGARG ...]]] [-pr PROXY]
                       [-nopr NO_PROXY] [-r RELEASE_VERSION]
                       [-cv CONFIG_VERSION] [-cl]

optional arguments:
  -h, --help            show this help message and exit
  -w TIMEOUT RESTART, --watchdog TIMEOUT RESTART
                        enable watchdog using timeout limit and restart delay
                        in seconds
  -m [CONFIGTYPE [CONFIGARG ...]], --metaconfig [CONFIGTYPE [CONFIGARG ...]]
                        generate meta-config of built indapp
  -pr PROXY, --proxy PROXY
                        set proxy environment
  -nopr NO_PROXY, --no-proxy NO_PROXY
                        set no_proxy environment
  -r RELEASE_VERSION, --release-version RELEASE_VERSION
                        application release version
  -cv CONFIG_VERSION, --config-version CONFIG_VERSION
                        compatible config version (1.4.0, 1.4.1, 1.4.2 or
                        1.5.0)
  -cl, --cloud-upload-config
                        add example cloudUploadConfig

Publish

usage: appsdk publish

Publishes the application to Insights Hub.

When a new project is initiated with AppSDK CLI, a default deploy configuration also added to appsdk-project.yaml project file under deploy_config element.

AppSDK publish command uses this config section from appsdk-project.yaml file and publishes given application to Insights Hub.

Information required for application publish is the same with Manage MySINUMERIK Edge /App Publishing.

Sample yaml section of deploy configuration can be seen below.

deploy_config:
  additional_documents :
  - document1:
      document_description: Additional documents sample document description
      document_file_path: ./package/Sample_document.pdf
      document_language: EN
      document_name: Additional documents sample document
  additional_documents_author: John Doe
  additional_documents_description: Additional documents author description
  application_description: Test application desctiption
  application_metadata_file_path: ./build/testapp_metaconfig.json
  application_name: testapp
  application_swu_path: ./build/testapp.indapp_1.0.0.swu
  mindsphere_apppublish_url: ''
  mindsphere_tenant: ''
  readme_oss_documents:
  - document1:
      document_description: Readme oss sample document description
      document_file_path: ./package/OSS_README_sample.txt
      document_language: EN
      document_name: README_OSS_sample_document
  release_description: Test application release description
  release_name: Release1
  release_version: v1.0.0
  terms_and_conditions_author: John Doe
  terms_and_conditions_description: Terms and conditions author description
  terms_and_conditions_documents:
  - document1:
      document_description: Sample terms and conditions document description
      document_file_path: ./package/Sample_document.pdf
      document_language: EN
      document_name: Sample terms and conditions document name 
Config section Explanation
edge_app_publish_url URL of Manage MySINUMERIK Edge /App Publishing UI
mindsphere_tenant tenant name used in Insights Hub (Formerly known as MindSphere)
document_language Should be either EN, DE or TR

Note

Please make sure that all paths points to correct files, versions are correct before publishing an application.

Once config file is updated, appsdk publish command can be executed.

When it is executed, command prompt will ask which authentication method should be used while publishing.

There are two methods for authentication. These are:

  • Username and password
  • Session and token (gathered from Insights Hub Manage MySINUMERIK Edge /App Publishing UI)

Note

To use username and password, chromedriver should be installed.

  • Download chromedriver.
  • Add it in to path environment variable(easiest way to do that is copying executable to a directory that is already in path like /usr/bin or /usr/local/bin)

It is always possible to use username and password as deploy credentials. However to give user more flexibility token and session information also can be used as credentials.

To gather token and session information information, follow the steps below:

  • Open a modern browser and login to Manage MySINUMERIK Edge /App Publishing UI
  • Open developer tools (usually f12 is shortcut. Also can be reached by right clicking on a page and selecting inspect).
  • Open network tab in the developer tools.
  • Find request start with /apps... and click on it.
  • Here there is a cookie on the request headers.
  • XSRF-TOKEN in the cookie is token information.
  • SESSION in the cookie is the session information.

Once authentication process is done, CLI will start to upload and publish given application.

Command help output which describes optional arguments is shown below :

$ appsdk publish -h
usage: main.py publish [-h] [-u USER] [-p PASSWORD] [-t TOKEN] [-s SESSION]
                       [-pr PROXY] [-nopr NO_PROXY] [-priv] [-v]

optional arguments:
  -h, --help            show this help message and exit
  -u USER, --user USER  Required username to deploy app
  -p PASSWORD, --password PASSWORD
                        Required password to deploy app
  -t TOKEN, --token TOKEN
                        Required token to deploy app
  -s SESSION, --session SESSION
                        Required session to deploy app
  -pr PROXY, --proxy PROXY
                        set http_proxy and https_proxy environments
  -nopr NO_PROXY, --no-proxy NO_PROXY
                        set no_proxy environment
  -priv, --privileged   Use script with browser's privileged mode
  -v, --verbose         Increase verbosity

Clean

usage: appsdk clean

Cleans build directory.

Start

usage: appsdk start <service>

service: databus, simulator or all (for all services available) Starts mock services provided with devenv package.

Stop

usage: appsdk stop <service>

service: databus, simulator or all (for all services available) Stops mock services provided with devenv package.

Data Simulator

The Data Simulator is made for application developers to let them work without real hardware.

Data Simulator has a very simple web-based UI.

Key Features

  • Responds Parameter Service requests
  • Feeds HF data
  • Integrated with the Development Environment
  • Feeds HF data infinitely
  • Feeds data with current timestamps
  • Allows uploading of simulation data via web UI
  • Runs both on local development machine as well as SINUMERIK Edge
  • Allows adjusting HF data feed speed
  • Allows starting from a given timestamp

Accessing Data Simulator

Data Simulator can be used in the following ways.

1- Embedded with Development Environment (Runs on your local machine)

When you download AppSDK Development Environment, Data Simulator also comes with it. You don't need to perform anything other than running Development Environment with given instructions(explained detailed in the relevant section). When the Development Environment starts to run, you can access the Data Simulator via a web browser using the following address.

http://localhost:20000

Note

Since you are running Data Simulator with Development Environment, "Devenv Mode" must be chosen from the Simulator UI. Otherwise you will get a connection error.

2- Running it standalone as a separate Docker container (Runs on your local machine)

Note:

  • While using Data Simulator standalone, you need to select "Standalone Mode" from the Simulator UI

Data Simulator can also be used standalone without using Development Environment. Since It will work without Development Environment, we need to build a Docker image and run it by manually executing the following commands.

First, build "data-simulator" Docker image (if it's not already built) with the following command. (You have to be in the same directory with the Dockerfile)

sudo docker build -f Dockerfile-simulator -t data-simulator .

Then run the Docker image with the following parameters

docker run --name data-simulator --network host data-simulator

Once a container starts to run, you can access Data Simulator via web browser using the following address

http://localhost:20000

Using Simulator

The Data Simulator is also controlled by UI. It also only has a few settings, hence it is very easy to use.

To use Data Simulator, you need simulation data. There is dummy data inserted into Data Simulator by default. You can extend data using same format and feed it through Data Simulator.

Simulator Settings

Data Simulator has following settings

Infinite loop: If this option selected, after finishing all HF data, Data Simulator starts to feed HF data from the start infinitely.

Use current timestamp: Regardless of timestamps in the recorded data payload, if this option is selected, the Data Simulator updates these timestamps with current values.

Start feeding after specific timestamp: This option enables you to start simulation from a specified timestamp. The timestamp value should be in "RFC3339" format (The HF data payload timestamps are also in "RFC3339" format).

Simulation speed: You can increase the simulation speed up to 300% by using the range bar. You can not decrease simulation speed below 100% with this option.

Select a simulation file: You can choose the simulation data that you want to use with Data Simulator here.

Upload simulation files: From this section, you can upload pre-recorded simulation data.

Starting the Simulation

Once you are done with these settings, you can start Data Simulator by clicking to the Start button. It will start to feed HF data from the simulation data file. It will also start to response to Parameter Service requests based on Parameter Service data on the simulation data file.

Stopping the Simulation

Clicking to the Stop button in the simulator tab will stop the simulation. Once the simulation stops, you can change the settings or the data file. If you stop the simulation and start it again, it will start to simulate from the beginning of the data file unless you specify a timestamp value for feeding.

Note

You can always check if Data Simulator pushes data to databus by using following command mosquitto_sub -h localhost -p 1883 -t "#" mosquitto-clients must be installed in order to use this command. If it is not installed, it can be installed with apt-get install mosquitto-clients

Any questions left?

Ask the community


Except where otherwise noted, content on this site is licensed under the The Siemens Inner Source License - 1.1.