Java API Contents¶
Package Directory Layout¶
appsdk_java
├── EdgeAPI
│  ├── include
│  │  └── edge.jar
│  └── libs
│  ├── include
│  ├── libAdapterFrameworkApi.so
│  ├── libCommonLogApi.so -> libedgelogclient.so
│  ├── libdatabus-public2.so
│  ├── libdatabus-public2.so.2
│  ├── libEdgeAPI.so
│  ├── libedgelogclient.so
│  ├── libedge.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.java
├── EventHandlingApp
│  ├── appconfig.json
│  └── Sample.java
├── TransformationApp
│ ├── appconfig.json
│ └── Sample.java
└── FileTransferApp
│ ├── appconfig.json
│ └── Sample.java
└── LFDataEventApp
│ ├── appconfig.json
│ ├── Sample.java
│ └── sample_metaconfig.json
└── HFDataAsyncApp
│ ├── appconfig.json
│ ├── Sample.java
│ └── sample_metaconfig.json
└── HFDataSyncApp
│ ├── appconfig.json
│ ├── Sample.java
│ └── sample_metaconfig.json
└── InformationServiceApp
│ ├── appconfig.json
│ └── Sample.java
│── UtilityFuncstionsApp
│ ├── appconfig.json
│ └── Sample.java
└── MqttClientApp
├── appconfig.json
└── Sample.java
AppSDK Functionality¶
High-Frequency Functionality¶
Read Blocking High-Frequency Data¶
5. Read Data from Consumer Instance
Read Unblocking (asynchronous) High-Frequency Data¶
3. Extend CallbackConsumer Instance
4. Register CallbackConsumer instance
Write High-Frequency Data¶
5. Write Data with Producer Instance
Parameter Service Functionality¶
Read Parameter Service Data¶
2. Initialize Data Source Service
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
9. Access and Read Parameter Service Data
Write Parameter Service data¶
2. Initialize Data Source Service
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¶
2. Initialize Data Source Service
Read Parameter Service Data Point Metaconfig¶
2. Initialize Data Source Service
Information Service Functionality¶
Get Report¶
2. Initialize Data Source Service
6. Create Information Definition Object
7. Read Information Service Data with Information Definition Object
Using Event Handling Functionality of AppSDK¶
Receive Events¶
3. Extend Event Handler Instance
Send Event Message¶
File Upload Functionality¶
Sync Upload¶
Async Upload¶
3. Create an Async Upload Handler
4. Register Async Upload Handler
Mqtt Client Functionality¶
2. Publish Data to External Broker
Utility Functionality¶
Read Specific Config¶
2. Read Specific Config Section of Configuration
Use Logging features¶
Send Heartbeat¶
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.
edge.Initialize();
Databus methods¶
Return Codes¶
HF calls returns Status Enum. Detailed information regarding returned Status Enum can be found here
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.
DataBus db = DataBus.getInstance();
Get Databus State¶
This call is used to get information on the current status of the DataBus.
Status 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.
StringVector msglst = new StringVector();
msglst.add("sinumerik_hf_data");
Consumer consumer = new Consumer(msglst);
Register Consumer Instance¶
Once a consumer instance is created, you need to register it to Databus in order to use it.
Status status = 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.
MessageStruct result = consumer.pop();
Note
Since AppSDK's Java language support is implemented with JNI, Java users may find JVM's overall memory usage to exceed assigned limits such as heap (-Xmx) limit. This is because objects returned by JNI invoked consumer.pop()
are tracked with shallow objects. These objects have a low memory footprint and may not trigger garbage collector before exceeding assigned memory thresholds.
In case of memory problems, there are few ways to reduce overall memory usage. It's advised to tune JVM arguments such like Xmx before these.
- Using delete()
method of MessageStruct
can force to release JNI object memory. This method must be only called when object's lifetime over.
- Hinting JVM to trigger garbage collector by invoking System.gc()
periodically.
- Hinting JVM to trigger garbage collector by command line utilities such as jmap
/jcmd
.
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
Status status = 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 extends CallbackConsumer{
CallbackConsumerAB(StringVector msglst){
super(msglst);
}
public void onData(String topic, String payload){
System.out.println("Callback Received: " + topic + "Payload: " +payload);
}
}
Register Callback Consumer Instance¶
After extending the CallbackConsumer 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.
StringVector msglst = new StringVector();
msglst.add("sinumerik_hf_data");
CallbackConsumerAB callbackConsumer = new CallbackConsumerAB(msglst);
Status 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
String outKey = result.getMessageId();
// access payload of read data
String outMessage = result.getPayload();
// access result of read data
String outStatus = result.getStatus();
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.
StringVector msglst = new StringVector();
msglst.add("upload2cloud");
Producer producer = new Producer(msglst);
Register Producer Instance¶
After creating a Producer object, you need to register it to Databus before using it first.
Status status = 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 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 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 information service data.
DataSourceAccess.Initialize();
Warning
If you wish to use your application with Data Simulator on your local machine, you need to use initialize method with supplying simulator's address http://localhost:55501. example: "DataSourceAccess.Initialize(http://localhost:55501);". If you wish to use both application and Data Simulator in Docker container, you need to use "http://data-simulator:55501" address with initialize method.
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.
StringVector dataSourceNames = new StringVector();
ErrorObject 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 data source name.
This data source name must be one of the names returned from GetDataSourceNames method.
DataSource ncu = new 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.
ParameterServiceVector parameterServices = ncu.GetParameterServices();
ParameterService paramSVC = parameterServices.get(0);
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.
ParameterDefinition paramDef = new ParameterDefinition("/channel/parameter/r[u1,5,#1]");
Optionally, index
and length
arguments can be supplied respectively.
ParameterDefinition paramDef = new 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:
NamedParameterDefinition 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.
ErrorObject res = paramSVC.ReadParameter(paramDef);
Reading Multiple Variables¶
For multiple reads, a vector of ParameterDefinition objects must be supplied to ReadParameters method.
ParameterDefinitionVector ParameterDefinitionVectorVariable = new ParameterDefinitionVector();
ParameterDefinitionVectorVariable.add(paramDef1);
ParameterDefinitionVectorVariable.add(paramDef2);
ParameterDefinitionVectorVariable.add(paramDef3);
ErrorObject res = paramSVC.ReadParameters(ParameterDefinitionVector);
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¶
ErrorObject 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 = new NamedParameterDefinitionVector();
namedParameterDefinitionVector.add(namedParamDef1);
namedParameterDefinitionVector.add(namedParamDef2);
namedParameterDefinitionVector.add(namedParamDef3);
ErrorObject res = paramSVC.ReadParametersByNames(namedParameterDefinitionVector);
Get Parameter Value Object¶
After the read operation, read values can be accessed via a ParameterValue object.
ParameterValueObject pvo = paramDef.GetValueObject();
If you used a named parameter for read you can access values as:
ParameterValueObject pvo = namedParamDef.GetValueObject();
Access and Read Parameter Service Data¶
After creating a ParameterValue object, values can be reached by calling GetValues method.
ParameterValueVector val = pvo.GetValues();
for(int i = 0; i < val.size(); i++){
System.out.println("value: " + val.get(i).getFirst());
System.out.println("value type: " + val.get(i).getSecond());
}
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.
ParameterValueObject pvo2 = new 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.type_code.Int);
pvo2.AddValue("3", ParameterValueObject.type_code.Int);
pvo2.AddValue("4", ParameterValueObject.type_code.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.
res = paramSVC.WriteParameter(paramDef);
Writing Multi Variable¶
For multiple write, array of populated ParameterDefinition objects are needed.
ErrorObjectVector responseVector = paramSVC.WriteParameters(ParameterDefinitionVector);
Writing Single Variable By Name¶
ErrorObject 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 = new NamedParameterDefinitionVector();
namedParameterDefinitionVector.add(namedParamDef1);
namedParameterDefinitionVector.add(namedParamDef2);
namedParameterDefinitionVector.add(namedParamDef3);
ErrorObject 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:
String 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:
String 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
InformationServiceVector infoServices = ncu.GetInformationServices();
//select desired information service
InformationService infoSVC = infoServices.get(0);
//get name of information service if needed
System.out.println("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.
InformationDefinitionObject infoDef = new InformationDefinitionObject("alarmList","");
Read Information Service Data with Information Definition Object¶
Read information service data with information service object and information definition object.
ErrorObject res = infoSVC.GetReport(infoDef);
You can access data with following methods.
if(res.Success())
System.out.println(infoDef.GetResult());
else
System.out.println("Information service error: " + res.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 eventmanager = edge.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 OnAppShutdownEventHandler extends EventHandler{
OnAppShutdownEventHandler(){
super();
}
public void Handle(String eventSource, String eventName, String eventData){
System.out.println("EventSource: " + eventSource + " eventName: " +eventName + " eventData: " + eventData);
}
}
Subscribe to Event¶
Application should subscribe to event with event name and extended event handler class to receive events.
OnAppShutdownEventHandler onAppShutdownEventHandler = new OnAppShutdownEventHandler();
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
FileUpload fileUploader = FileUpload.CreateInstance(Target.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.
Edge Status status = fileUploader.UploadFile("<absolute_path_to_file>");
EdgeStatus
object.
Create an Async Upload Handler¶
To use the async upload functionality, a handler class should be implemented extendind FileUploadAsyncResponseHandler
.
class CoolAsyncResponseHandler extends FileUploadAsyncResponseHandler{
protected MyFileUploadAsyncResponseHandler() {
super();
}
public void OnSuccess(String filepath, String uploadedFilename){
System.out.println("Yaaay!");
System.out.println("Just uploaded " + filepath + " to Insights Hub as " + uploadedFilename);
}
public void OnFailure(String filepath, EdgeStatus status) {
System.out.println("Sad trombone");
System.out.println("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.
CoolAsyncResponseHandler handler = new CoolAsyncResponseHandler();
Register Async Upload Handler¶
Once FileUpload
and CoolAsyncResponseHandler
instances are ready handler can be registered as
EdgeStatus status = fileUploader.SetAsyncResponseHandler(handler);
Returns EdgeStatus
object
Clear Async Upload Handler¶
Clears async handler from FileUpload
instance.
EdgeStatus status = fileUploader.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
EdgeStatus status = fileUploader.UploadFileAsync("<absolute_path_to_file>");
Returns EdgeStatus
object.
Returned status' meaning
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.
MqttClient 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.
String brokerLabel = "broker"; // broker label must match with one of the sinumerikedgemqttclient's configured broker(s)
String topicLabel = "topic";
byte[] payload = "binary".getBytes();
// OR
byte[] payload = Files.readAllBytes(Paths.get("file.tar.gz"));
Status 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.
- Calling Heartbeat from AppSDK
If you configure your application for watchdog you need to call heartbeat method with an interval you choose.
edge.SendHearthbeat();
- 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)
edge.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 logger = edge.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(LoggerAppenderType.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 = edge.GetAppSpecificConfig();
if(ret.getFirst().Success()){
specificConfigAll = ret.getSecond();
}
Also, there is an option of reading subsections by specifying the section.
ret = edge.GetAppSpecificConfigSection("/specificArray/1");
if(ret.getFirst().Success()){
specificArraySecondItem = ret.getSecond();
}
Any questions left?
Except where otherwise noted, content on this site is licensed under the The Siemens Inner Source License - 1.1.