Skip to content

Python API Contents

Package Directory Layout

appsdk_python
├── EdgeAPI
│   ├── include
│   │   ├── edge.py
│   │   └── _edge.so
│   └── libs
│       ├── include
│       ├── libAdapterFrameworkApi.so
│       ├── libCommonLogApi.so -> libedgelogclient.so
│       ├── libdatabus-public2.so
│       ├── libdatabus-public2.so.2
│       ├── libEdgeAPI.so
│       ├── libedgelogclient.so
│       ├── libmosquittopp.so
│       ├── libmosquittopp.so.1
│       ├── libmosquittopp.so.1.6.3
│       ├── libmosquitto.so
│       ├── libmosquitto.so.1
│       └── libmosquitto.so.1.6.3
├── indapp-build_<version>_amd64.deb
└── SampleApps
    ├── ParameterServiceApp
    │   ├── appconfig.json
    │   └── Sample.py
    ├── EventHandlingApp
    │   ├── appconfig.json
    │   └── Sample.py
    ├── TransformationApp
    │   ├── appconfig.json
    │   └── Sample.py
    └── FileTransferApp
    │   ├── appconfig.json
    │   └── Sample.py
    └── LFDataEventApp
    │   ├── appconfig.json
    │   ├── Sample.py
    │   └── sample_metaconfig.json
    └── HFDataAsyncApp
    │   ├── appconfig.json
    │   ├── Sample.py
    │   └── sample_metaconfig.json
    └── HFDataSyncApp
    │   ├── appconfig.json
    │   ├── Sample.py
    │   └── sample_metaconfig.json
    └── InformationServiceApp
    │   ├── appconfig.json
    │   └── Sample.py
    └── UtilityFuncstionsApp
    │   ├── appconfig.json
    │   └── Sample.py
    └── MqttClientApp
        ├── appconfig.json
        └── Sample.py

AppSDK Functionality

High-Frequency Functionality

Read Blocking High-Frequency Data

1. Initialize AppSDK

2. Get Databus Instance

3. Create Consumer Instance

4. Register Consumer Instance

5. Read Data from Consumer Instance

6. Access and Read HF Data

Read Unblocking (asynchronous) High-Frequency Data

1. Initialize AppSDK

2. Get Databus Instance

3. Extend CallbackConsumer Instance

4. Register CallbackConsumer Instance

5. Access and Read HF Data

Write High-Frequency Data

1. Initialize AppSDK

2. Get Databus Instance

3. Create Producer Instance

4. Register Producer Instance

5. Write Data with Producer Instance

6. Check HF Write Result

Parameter Service Functionality

Read Parameter Service Data

1. Initialize AppSDK

2. Initialize Data Source Service

3. Get Data Source Names

4. Create Data Source Object

5. Get Parameter Services

6. Create Parameter Definition Object

7.a. Read Parameter Service Data with Parameter Definition Object

7.b. Read Parameter Service Data with Named Parameter Definition Object

8. Get Parameter Value Object

9. Access and Read Parameter Service Data

Write Parameter Service Data

1. Initialize AppSDK

2. Initialize Data Source Service

3. Get Data Source Names

4. Create Data Source Object

5. Get Parameter Services

6. Create Parameter Definition Object

7. Create Parameter Value Object

8. Populate Parameter Value Object

9. Populate Parameter Definition object with parameter value object

10. Write Parameter Service Data with Parameter Definition Object

Read Parameter Service Data Source Metaconfig

1. Initialize AppSDK

2. Initialize Data Source Service

3. Get Data Source Names

4. Create Data Source Object

5. Read Data Source Meta

Read Parameter Service Data Point Metaconfig

1. Initialize AppSDK

2. Initialize Data Source Service

3. Get Data Source Names

4. Create Data Source Object

5. Get Parameter Services

6. Read Data Point Meta

Information Service Functionality

Get Report

1. Initialize AppSDK

2. Initialize Data Source Service

3. Get Data Source Names

4. Create Data Source Object

5. Get Information Services

6. Create Information Definition Object

7. Read Information Service Data with Information Definition Object

Using Event Handling Functionality of AppSDK

Receive Events

1. Initialize AppSDK

2. Get Event Manager Instance

3. Extend Event Handler Instance

4. Subscribe to Event

Send Event Message

1. Initialize AppSDK

2. Get Event Manager Instance

3. Publish Event Message

File Upload Functionality

Sync Upload

1. Initialize AppSDK

2. Get File Upload Instance

3. Upload Sync

Async Upload

1. Initialize AppSDK

2. Get File Upload Instance

3. Create an Async Upload Handler

4. Register Async Upload Handler

5. Upload Async

Mqtt Client Functionality

1. Get MqttClient Instance

2. Publish Data to External Broker

Utility Functionality

Read Specific Config

1. Initialize AppSDK

2. Read Specific Config Section of Configuration

Use logging features

1. Initialize AppSDK

2. Initialize Logger

3. Add Appender

4. Use Logger

Send Heartbeat

1. Initialize AppSDK

2. Send Heartbeat from AppSDK

Get System Timestamp

1. Initialize AppSDK

2. Get System Timestamp

AppSDK Methods

General Methods

Initialize AppSDK

AppSDK library must be initialized first. From the application developer’s point, it is a must call function.

from edge import *
Initialize()

Databus Methods

Return Codes

HF calls returns Status Enum. Detailed information regarding returned Status Enum can be found here

High Frequency Return Codes

Get Databus Instance

Databus object is needed and mandatory for all HF operations. It is also must call function for HF functionality.

Note: Keep in mind that the Databus object is a singleton. If this function called multiple times, it will still return the same Databus object.

db = DataBus.getInstance()

Get Databus State

This call is used to get information on the current status of the DataBus.

status = DataBus.getDataBusState()
Status Description
Status_OK It is created and initialized.
Status_DATABUS_DISCONNECTED It means that the client is not currently connected to the server
Status_ERROR Fatal error occured during creation or initialization

Create Consumer Instance

In order to read data, the Consumer object must be created first. Consumer object created with providing MessageID list. Every MessageID that you want to use with a specific consumer can be added to this list (using different messageIDs on same consumer instance and using seperate consumer instances for different messageIDs are both possible). Registering a Consumer object will be discussed in the next step.

msglst = ["sinumerik_hf_data"]
# Create consumer
consumer = Consumer(msglst)

Register Consumer Instance

Once a Consumer instance is created, you need to register it to Databus in order to use it.

db.registerConsumer(consumer)
Status Description
Status_OK The Consumer was successfully subscribed to the desired messageIdList specified in tConsumerObject
Status_ERROR The messageIdList specified in tConsumerObject is either empty or the applications's json configuration file does not contain it

Warning!

After registering to a databus message id, messages are received continuously in background by AppSDK Databus client library from databus broker. Received messages are queued in client library internally until user code consume them by a Consumer. For that reason, it is important to consume databus messages in your application code at least in same speed with messages are produced. Calling deregisterConsumer method with related Consumer instances will stop receiving messages

Read Data from Consumer Instance

Reading data performed via calling the pop method of Consumer instance. The thread that you make the pop call will be blocked until data is received and read operation completes.

result = consumer.pop()

Deregister Consumer Instance

Once a registered Consumer object is no longer needed, you might choose to deregister it. A consumer can not consume data from databus in deregistered state

db.deregisterConsumer(consumer)
Status Description
Status_OK The Consumer instance is successfully deregistered from the DataBus
Status_ERROR The Consumer instance is not registered on the DataBus or the subscriptions failed to be removed

Extend Callback Consumer Instance

After creating a Databus instance you need to implement a child class from the CallbackConsumer interface to use its asynchronous functionality. While creating this CallbackConsumer class and creating a CallbackConsumer instance, you will need to provide the MessageID list that you want to listen and then register a created instance to Databus. Now you can start reading data from Databus asynchronously.

class CallbackConsumerAB(CallbackConsumer):
    def __init__(self, msglst):
        super().__init__(msglst)

    def onData(self, topic, payload):
        print("Callback Received: " + topic + ": " + payload)

Warning!

If data that consumed is binary data, CallbackConsumerRaw should be used to access data as Python bytes. CallbackConsumer provides payload data as Python string which is encoded in unicode characters and performance issues may be observed.

Extend Raw Callback Consumer instance

If there is no encoding needed on the data consumed CallbackConsumerRaw should be extended. This consumer type returns payload as bytes instead of string.

class CallbackConsumerAB(CallbackConsumerRaw):
    def __init__(self, msglst):
        super().__init__(msglst)

    def onData(self, topic, payload):
        print("Callback Received: " + topic)
        print(payload)

Register Callback Consumer Instance

After extending the CallbackConsumer or CallbackConsumerRaw class you need to create an instance of it. Once an instance is created, it can be registered to Databus by calling a registerCallbackConsumer method.

msglst = ["sinumerik_hf_data"]
callbackConsumer = CallbackConsumerAB(msglst)
status = db.registerCallbackConsumer(callbackConsumer)
Status Description
Status_OK The CallbackConsumer was successfully subscribed to the desired messageIdList
Status_ERROR The provided messageIdList is either empty or the applications's json configuration file does not contain it

Warning!

After registering to a databus message id, messages are received continuously in background by AppSDK Databus client library from databus broker. Received messages are queued in client library internally until user code consume them by a CallbackConsumer. For that reason, it is important to consume databus messages in your application code at least in same speed with messages are produced. Calling deregisterCallbackConsumer methods with related CallbackConsumer instance will stop receiving messages

Deregister Callback Consumer Instance

Once a Callback Consumer is registered its on data method is triggered whenever new data comes through a specific messageId. It is possible to stop this operation by deregistering CallbackConsumer.

db.deregisterCallbackConsumer(callbackConsumer)
Status Description
Status_OK The CallbackConsumer instance is successfully deregistered from the DataBus
Status_ERROR The CallbackConsumer instance is not registered on the DataBus or the subscriptions failed to be removed

Access and Read HF Data

Accessing the read values and getting read operation result can be done by the following methods.

# access messageid of read data
outKey = result.getMessageId()
# access payload of read data 
outMessage = result.getPayload()
# access result of read data 
outStatus = result.getStatus()

Warning!

If data that consumed is binary data, getPayloadRaw should be used to access data as Python bytes. getPayload provides payload data as Python string which is encoded in unicode characters and performance issues may be observed.

Access and Read HF Data as Bytes

Accessing read value as bytes instead of string when encoding is not necessary.

# access payload with getPayloadRaw
outMessage = result.getPayloadRaw()

Create Producer Instance

In order to send data to Databus, First a Producer instance should be created by providing MessageID list that you want to send your HF data. Then this Producer instance should be registered to databus.

msglstPush = ["upload2cloud"]
# Create producer
producer = Producer(msglstPush)

Register Producer Instance

After creating a Producer object, you need to register it to Databus before using it first.

db.registerProducer(producer)
Status Description
Status_OK The Producer was successfully registered to the desired subscriptions
Status_ERROR The provided messageIdList is either empty or the applications's json configuration file does not contain it

Push Data to Producer Instance

By using the created and registered Producer object, you can use a push method to send data to Databus.

status = producer.push("upload2cloud", "dummy-payload")
Status Description
Status_OK The message was successfully added to the outgoing queue, and will be sent
Status_ERROR The message could not be added to the outgoing queue
Status_WARNING The message was successfully added to the outgoing queue, but there is a problem preventing message transfer at the moment. You can use the getDatabusState() method on the DataBus to find out more.

Deregister Producer Instance

Once a registered Producer object is no longer needed, you might choose to deregister it. A producer can not push data to databus in deregistered state

db.deregisterProducer(producer)
Status Description
Status_OK The Producer instance is successfully deregistered from the DataBus
Status_ERROR The Producer instance is not registered on the DataBus or the subscriptions failed to be removed

Check HF Write Result

After write operation, push method returns a Status object. By using this object, the status of the write operation can be retreived.

status = producer.push("upload2cloud", "dummy-payload")

Data Source Access Methods

Initialize Data Source Service

After initializing AppSDK, DataSourceAccess must be initialized in order to read or write data source service data.

DataSourceAccess.Initialize()

Warning

If you wish to use your application with data-simulator you need to use initialize method with supplying simulator's address http://localhost:55501. example: DataSourceAccess.Initialize(http://localhost:55501)

Get Data Source Names

We can get list of data source names by providing data source types. The returned list will provide all data source names with the given data source type.

#Get available data source names by supplying data source type
dataSourceNames = StringVector()
status = DataSourceAccess.GetDataSourceNames("SINUMERIK", dataSourceNames)

Create Data Source Object

DataSource object must be created before any reading or writing operation. This object created by providing a DataSource name.

This DataSource name must be one of the names returned from GetDataSourceNames method.

ncu = DataSource()
status = DataSourceAccess.GetDataSource(dataSourceName, ncu)

Parameter Service Methods

Return Codes

Parameter Service calls returns ErrorObject. Detailed information regarding returned object can be found here Parameter Service Return Codes

Get Parameter Services

Using DataSource object, ParameterService object can be created. This ParameterService object will be used while reading or writing data.

parameterServices = ncu.GetParameterServices()
paramSVC = parameterServices[0]
print("Service: " + paramSVC.GetName())

Create Parameter Definition Object

In order to read or write parameter service data to a SINUMERIK device, we need to create a ParameterDefinition object and specify which variable to read or write.

paramDef = ParameterDefinition("/channel/parameter/r[u1,5,#1]")

Optionally, index and length arguments can be supplied respectively.

paramDef = ParameterDefinition("/channel/parameter/r[u1,5,#1]", 0, 128)

Alternatively if there are named datapoints in the configuration file you can create a NamedParameterDefinition instance:

namedParamDef = NamedParameterDefinition("my parameter")

Read Parameter Service Data with Parameter Definition Object

Reading single or multiple variables are supported. There are separate methods for single and multiple read.

Reading Single Variable

For a single read, one ParameterDefinition object is needed. By supplying this object to ReadParameter method, parameter service data can be read.

response = paramSVC.ReadParameter(paramDef)
Reading Multiple Variables

For multiple reads, a vector of ParameterDefinition objects must be supplied to ReadParameters method.

ParameterDefinitionVectorvariable = ParameterDefinitionVector()
ParameterDefinitionVectorvariable.push_back(paramDef1)
ParameterDefinitionVectorvariable.push_back(paramDef2)
response = paramSVC.ReadParameters(ParameterDefinitionVectorvariable)

Read Parameter Service Data with Named Parameter Definition Object

Reading single or multiple variables are supported. There are separate methods for single and multiple read.

Reading Single Variable By Name
res = paramSVC.ReadParameterByName(namedParamDef)

an example naming for datapoint:

"requiredDatasource" : [
    {
    "datasourceId" : "SINUMERIK_NCU1",
    "services" : {
        "parameter-service/v1" : {
            "access" : [
            {
                "accessType" : "r",
                "datapoints": [
                {
                    "address": "/channel/parameter/r[u1,1,1]",
                    "datapointName":"my parameter"
                    ...

Note

In case of multiple datapoints defined with the same datapointName, first one defined in configuration will be used.

Reading Multiple Variables by Name

For multiple reads, a vector of NamedParameterDefinition objects must be supplied to ReadParameters method.

namedParameterDefinitionVector = NamedParameterDefinitionVector
namedParameterDefinitionVector.push_back(namedParamDef1)
namedParameterDefinitionVector.push_back(namedParamDef2)
res = paramSVC.ReadParametersByNames(namedParameterDefinitionVector)

Get Parameter Value Object

After the read operation, read values can be accessed via a ParameterValue object.

pvo = paramDef.GetValueObject()

If you used a named parameter for read you can access values as:

auto pvo = namedParamDef->GetValueObject()

Access and Read Parameter Service Data

After creating a ParameterValue object, values can be reached by calling GetValues method.

number_of_read_values = pvo.GetValues().size()
for i in range(number_of_read_values):
    print(str(pvo.GetValues()[i][0]) + "-" + str(pvo.GetValues()[i][1]))

Create Parameter Value Object

ParameterValue object keeps the read values or values to write. Before writing values, ParameterValue object needs to be created and populated.

pvo2 = ParameterValueObject()

Populate Parameter Value Object

AddValue method used to populate the ParameterValue object. This method has two inputs. First, value itself, second type of value.

Since all values given to this method in string format, type of value needs to be specified.

pvo2.AddValue("2", ParameterValueObject.Int)
pvo2.AddValue("3", ParameterValueObject.Int)
pvo2.AddValue("4", ParameterValueObject.Int)
#...

Populate Parameter Definition Object with Parameter Value Object

Once the ParameterValue object is created and populated with values, SetValueObject method can be used to populate the ParameterDefinition object. As a result ParameterDefinition object gets ready for write operation with values provided by the application developer.

paramDef.SetValueObject(pvo2)

Write Parameter Service Data with Parameter Definition Object

WriteParameter method can be called with populated ParameterDefinition object. Once called, it writes the data to device if write operation returns successfully.

Writing multiple variables at once also possible.

Writing Single Variable

For single write, only one populated ParameterDefinition object is needed.

response = paramSVC.WriteParameter(paramDef)
Writing Multi Variable

For multiple write, array of populated ParameterDefinition objects are needed.

response = paramSVC.WriteParameters(ParameterDefinition_object_vector)
Writing Single Variable By Name
res = paramSVC.WriteParameterByName(namedParamDef)

an example naming for datapoint:

"requiredDatasource" : [
    {
    "datasourceId" : "SINUMERIK_NCU1",
    "services" : {
        "parameter-service/v1" : {
            "access" : [
            {
                "accessType" : "w",
                "datapoints": [
                {
                    "address": "/channel/parameter/r[u1,1,1]",
                    "datapointName":"my parameter"
                    ...
Writing Multiple Variables by Name

For multiple writes, a vector of NamedParameterDefinition objects must be supplied to WriteParameters method.

namedParameterDefinitionVector = NamedParameterDefinitionVector
namedParameterDefinitionVector.push_back(namedParamDef1)
namedParameterDefinitionVector.push_back(namedParamDef2)
res = paramSVC.WriteParametersByNames(namedParameterDefinitionVector)

Read Data Source Meta

meta is a field reserved for user's specific needs To read parameter service metaconfig from data source:

ncuMetaconfig = ncu.GetMetaconfig()

In case your configuration does not contain meta field in data source, it will return empty string.

an example meta field for datasource:

"datasourceConfig": {
      "requiredDatasource" : [
        {
          "datasourceId" : "SINUMERIK_NCU1",
          "meta":{"test":"0xff"},
          "services" : {
        ...

Read Datapoint Meta

To read parameter service metaconfig from data point:

datapointMetaconfig = paramSVC.GetMetaConfigOfDatapoint("my parameter")

In case your configuration does not contain meta field in data point, it will return empty string. an exmaple meta field for datapoint:

   "datasourceConfig": {

      "requiredDatasource" : [
        {
          "datasourceId" : "SINUMERIK_NCU1",
          "meta":{"test":"0xff"},
          "services" : {
            "parameter-service/v1" : {
              "access" : [
                {
                  "accessType" : "w",
                  "datapoints": [
                    {
                      "address": "/channel/parameter/r[u1,1,1]",
                      "datapointName":"my parameter",
                      "meta":{"test":"0xaa"}
                    }
                    ...

Information Service Methods

Get Information Services

Warning

Please check available report IDs from information service provider application's documentation. Avalibility of this data is up to provider application. More detail regarding information service can be found here

Get desired information service from data source object.

#get list of information services 
infoServices = ncu.GetInformationServices()
#select desired information service
infoSVC = infoServices[0]
#get name of information service if needed 
print("Information Service Name: " + infoSVC.GetName())

This information service object will be used while getting information from data source.

Create Information Definition Object

Create information definition object with desired report ID and metadata.

infoDef = InformationDefinitionObject("alarmList","")

Read Information Service Data with Information Definition Object

Read information service data with information service object and information definition object.

response = infoSVC.GetReport(infoDef)

You can access data with following methods.

if response.Success():
  print(infoDef.GetResult())
else:
  print("Information service error: " + response.GetMessage())

Event Handling Methods

Return Codes

Event Handling Methods returns EdgeStatus object. Detailed information regarding returned object can be found here Edge API Return Codes

Get Event Manager Instance

In order to use AppSDK Event Handling functionality, EventManager instance must be created first. This is a must call method for Event Handling.

eventmanager = GetEventManagerInstance()

Extend Event Handler Instance

EventHandler is a definition of callback class. In order to receive events this class should be extended and Handle method should be overriden. In case a subscribed event received, Handle method will be triggered.

class OnShutdownEventHandler(EventHandler):
    def __init__(self):
        super().__init__()

    def Handle(self, eventDestination, eventName, eventData):
        print("Event Received: " + eventDestination + ": " + eventName + ": " + eventData)

Subscribe to Event

Application should subscribe to event with event name and extended event handler class to receive events.

onAppShutdownEventHandler = OnShutdownEventHandler()
eventmanager.SubscribeEvent("OnAppShutdown", onAppShutdownEventHandler)

Publish Event Message

Event messages can be published to specific destination application with event name and additional event data.

eventmanager.PublishEventMessage("DestinationApp", "TestEvent", "Test Data")

Once event is sent, result of the operation can be checked as below.

if ret.Success():
    logger.Info("TestEvent sent successfully")
else:
    logger.Info("TestEvent sent failed")

File Upload Methods

Return Codes

File upload methods returns EdgeStatus object. Detailed information regarding returned object can be found here Edge API Return Codes

Get File Upload Instance

Instance of FileUpload is created by calling CreateInstance method as follows

    file_uploader = FileUpload.CreateInstance(MINDSPHERE)

Returns an instance with type FileUpload

Upload Sync

After FileUpload instance is created sync file upload can be done by calling instance's UploadFile method.

    status = file_uploader.UploadFile("<absolute_path_to_file>")
Returns an EdgeStatus object.

Create an Async Upload Handler

To use the async upload functionality, a handler class should be implemented extendind FileUploadAsyncResponseHandler.

    class CoolAsyncResponseHandler(FileUploadAsyncResponseHandler):
        def __init__(self):
            super().__init__()

        def OnSuccess(self, filepath, uploadedFilename):
            print("Yaaay!")
            print("Just uploaded " + filepath + " to Insights Hub as " + uploadedFilename)

        def OnFailure(self, filepath, status):
            print("Sad trombone")
            print("Just got an error while uploading " + filepath + " error is: " + status.GetMessage())

In the example above we extend our base class and create our own handler called CoolAsyncResponseHandler. Next step is to create instance of it in application.

    handler = CoolAsyncResponseHandler()

Register Async Upload Handler

Once FileUpload and CoolAsyncResponseHandler instances are ready handler can be registered as

   status = file_uploader.SetAsyncResponseHandler(handler)

Returns EdgeStatus object

Clear Async Upload Handler

Clears async handler from FileUpload instance.

   status = file_uploader.ClearAsyncResponseHandler()

Upload Async

Async Handler

You should register an async handler in order to use this function. Otherwise application will make a false assertion and exit. (Register Async Upload Handler)

Uploads the file without blocking the flow of the application

   status = file_uploader.UploadFileAsync("<absolute_path_to_file>")

Returns EdgeStatus object.

Returned status does not mean file uploaded successfully

This status only specifies whether upload command sent successfully system or not. Even you send upload command successfully there is still a chance of failure. In that case async handler's OnFailure method will run.

In case of success

If file upload operation succeeds OnSuccess method is called with ID of transfer and file path. For the example above handler will display Yaaay!.

In case of failure

If file upload operation fails OnFailure method is called with ID of transfer and EdgeStatus object. For the example above handler will display Sad trombone.

Mqtt Client Methods

Get MqttClient Instance

MqttClient object is needed and mandatory for all MqttClient operations. Invoking this will initialize MqttClient along with Databus.

Note: Keep in mind that the MqttClient object is a singleton. If this function called multiple times, it will return the same object.

client = MqttClient.getInstance()

Publish Data to External Broker

In order to publish data to an external broker, publish method of the MqttClient can be used with relevant arguments.

Please beware that sinumerikedgemqttclient must be installed and running on the system for this. Refer to Sinumerik Edge MQTT Client documentation for furher information.

brokerLabel = "broker" # broker label must match with one of the sinumerikedgemqttclient's configured broker(s)
topicLabel = "topic"
payload = b"binary/string"

# OR
with open("file.tar.gz", "rb") as file:
  payload = file.read()

status = client.publish(brokerLabel, topicLabel, payload)

Utility Methods

Send Heartbeat from AppSDK

You can use a heartbeat in order to tell the system that your application is alive and working as expected. To do that there are two steps that should be implemented.

  1. Calling Heartbeat from AppSDK

If you configure your application for watchdog you need to call heartbeat method with an interval you choose.

hearthbeatResult = SendHearthbeat()
  1. Enabling Watchdog and Providing Parameters while Creating an Indapp.
indapp-build -n <name of your output package> -w 20 10

While building your indapp use the option -w to enter 2 arguments that indicate the watchdog timeout, and the sleep time before starting your application again. The Unit of these arguments should be seconds. For example if you enter -w 20 10 your application will be stopped if it does not receive the heartbeat for 20 seconds(timeout), then it will wait for 10 seconds and will restart (sleep time).

Get System Timestamp

This method returns the host system's UTC timestamp in RFC3339 format. (Same format as HF payload)

GetSystemTimestamp()

Initialize Logger

Before starting to log, logger needs to be initialized. The instance name is provided while initializing.

If the same instance name provided while creating multiple logger instances, the same object will be created and returned.

logger = CreateLoggerInstance("SampleApp")

Add Appender

After creating a logger instance, appender type needs to be added to logger instance. More information about appender types can be found here

logger.AddAppender(CONSOLE)

Use Logger

Finally logging functionality can be used by calling the following methods. More information about logger types can be found here

logger.Info("Some dummy log message.")

Read Specific Config Section of Configuration

Specific config section of the configuration file can be directly accessed by the following method.

ret = GetAppSpecificConfig()
if ret[0].Success():
    specificConfigAll = ret[1]

Also, there is an option of reading subsections by specifying the section.

ret = GetAppSpecificConfigSection("/specificDecimal")
if ret[0].Success():
    specificDecimal = ret[1]

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.