JAVA - Worker APIs
This section describes how to use the common worker functions available to interact with the deviceWISE Cloud. The API groups and API functions are listed below. By selecting the link provided on the function, you'll be redirected to the equivalent function description provided by the M2M Service interface and a more detailed description of each TR50 Java API and usage examples.
TR50 Alarm
Class DwOpenAlarm
- java.lang.Object
- com.devicewise.tr50.api.DwOpenGeneric
- com.devicewise.tr50.api.DwOpenAlarm
- com.devicewise.tr50.api.DwOpenGeneric
Methods
Modifier and Type | Method and Description |
---|---|
int
|
publish(java.lang.String thingKey,
java.lang.String timestamp,
java.lang.String corrId,
java.lang.String key, int state,
java.lang.String message,DwOpenReceiveActionListener recv,
java.lang.Object response) |
int
|
publish(java.lang.String thingKey,
java.lang.String timestamp,
java.lang.String corrId,
java.lang.String key, int state,
java.lang.String message,
java.lang.Object response) |
TR50 Property
Class DwOpenProperty
- java.lang.Object
- com.devicewise.tr50.api.DwOpenGeneric
- com.devicewise.tr50.api.DwOpenProperty
- com.devicewise.tr50.api.DwOpenGeneric
Methods
Modifier and Type | Method and Description |
---|---|
int
|
current(java.lang.String thingKey,
java.lang.String propKey, DwOpenReceiveActionListener recv,
java.lang.Object response) |
int
|
current(java.lang.String thingKey,
java.lang.String propKey,
java.lang.Object response) |
int
|
publish(java.lang.String thingKey,
java.lang.String timestamp,
java.lang.String propKey,
double propValue,
java.lang.String corrId,DwOpenReceiveActionListener recv,
java.lang.Object response) |
int
|
|
TR50 Location
Class DwOpenLocation
- java.lang.Object
- com.devicewise.tr50.api.DwOpenGeneric
- com.devicewise.tr50.api.DwOpenLocation
- com.devicewise.tr50.api.DwOpenGeneric
Methods
Modifier and Type | Method and Description |
---|---|
int
|
publish(java.lang.String thingKey,
java.lang.String timestamp,
java.lang.String corrId,
java.lang.Double lat,
java.lang.Double lng,
java.lang.Double heading,
java.lang.Double altitude,
java.lang.Double speed,
java.lang.Double fixAcc,
java.lang.String fixType, DwOpenReceiveActionListener recv,
java.lang.Object response) |
int
|
publish(java.lang.String thingKey,
java.lang.String timestamp,
java.lang.String corrId,
java.lang.Double lat,
java.lang.Double lng,
java.lang.Double heading,
java.lang.Double altitude,
java.lang.Double speed,
java.lang.Double fixAcc,
java.lang.String fixType,
java.lang.Object response) |
TR50 Log
Class DwOpenLog
- java.lang.Object
- com.devicewise.tr50.api.DwOpenGeneric
- com.devicewise.tr50.api.DwOpenLog
- com.devicewise.tr50.api.DwOpenGeneric
Methods
Modifier and Type | Method and Description |
---|---|
int
|
publish(java.lang.String thingKey,
java.lang.String ts,
java.lang.Integer level,
java.lang.String corrId,
java.lang.String msg,DwOpenReceiveActionListener recv,
java.lang.Object response) |
int
|
publish(java.lang.String thingKey,
java.lang.String ts,
java.lang.Integer level,
java.lang.String corrId,
java.lang.String msg,
java.lang.Object response) |
TR50 Thing
Class DwOpenThing
- java.lang.Object
- com.devicewise.tr50.api.DwOpenGeneric
- com.devicewise.tr50.api.DwOpenThing
- com.devicewise.tr50.api.DwOpenGeneric
Methods
Modifier and Type | Method and Description |
---|---|
int
|
attributeGet(java.lang.String thingKey,
java.lang.String attrKey,
DwOpenReceiveActionListener recv,
java.lang.Object response)
|
int
|
attributeGet(java.lang.String thingKey,
java.lang.String attrKey,
DwOpenReceiveActionListener recv,
java.lang.Object response)
|
int
|
attributeSet(java.lang.String thingKey,
java.lang.String attrKey,
java.lang.String attrValue, DwOpenReceiveActionListener recv,
java.lang.Object response) |
int
|
attributeSet(java.lang.String thingKey,
java.lang.String attrKey,
java.lang.String attrValue,
java.lang.Object response) |
int
|
attributeUnset(java.lang.String thingKey,
java.lang.String attrKey, DwOpenReceiveActionListener recv,
java.lang.Object response) |
int
|
attributeUnset(java.lang.String thingKey,
java.lang.String attrKey,
java.lang.Object response) |
int
|
bind(java.lang.String key,
java.lang.String autoDefKey,
java.lang.Object response) |
int
|
bind(java.lang.String key,
java.lang.String autoDefKey,
DwOpenReceiveActionListener recv,
java.lang.Object response) |
int
|
tagAdd(java.lang.String[] thingKey,
DwOpenReceiveActionListener recv,
java.lang.Object response,
java.lang.String... tags) |
int
|
tagAdd(java.lang.String[] thingKey,
java.lang.Object response,
java.lang.String... tags) |
int
|
tagAdd(java.lang.String[] thingKey,
java.util.Vector<java.lang.String> tags, DwOpenReceiveActionListener recv,
java.lang.Object response) |
int
|
tagAdd(java.lang.String[] thingKey,
java.util.Vector<java.lang.String> tags,
java.lang.Object response) |
int
|
tagDelete(java.lang.String[] thingKey,
DwOpenReceiveActionListener recv,
java.lang.Object response,
java.lang.String... tags) |
int
|
tagDelete(java.lang.String[] thingKey,
java.lang.Object response,
java.lang.String... tags) |
int
|
tagDelete(java.lang.String[] thingKey,
java.util.Vector<java.lang.String> tags, DwOpenReceiveActionListener recv,
java.lang.Object response) |
int
|
tagDelete(java.lang.String[] thingKey,
java.util.Vector<java.lang.String> tags,
java.lang.Object response) |
int
|
unbind(java.lang.String key,
java.lang.Object response) |
int
|
unbind(java.lang.String key,
DwOpenReceiveActionListener recv,
java.lang.Object response) |
TR50 Mailbox (Client)
Class DwOpenMailbox
- java.lang.Object
- com.devicewise.tr50.api.DwOpenGeneric
- com.devicewise.tr50.api.DwOpenMailbox
- com.devicewise.tr50.api.DwOpenGeneric
Methods
Modifier and Type | Method and Description |
---|---|
int
|
send(java.lang.String thingKey,
java.lang.String command, DwOpenCommandParam params,
java.lang.Integer ackTimeout,
java.lang.Boolean singleton,DwOpenReceiveActionListener recv,
java.lang.Object response) |
int
|
send(java.lang.String thingKey,
java.lang.String command, DwOpenCommandParam params,
java.lang.Integer ackTimeout,
java.lang.Boolean singleton,
java.lang.String sessionId,
java.lang.Object response) |
int
|
send(java.lang.String sessionId,
java.lang.String command, DwOpenCommandParam params,
java.lang.Integer ackTimeout,
java.lang.Boolean singleton,DwOpenReceiveActionListener recv,
java.lang.Object response) |
int
|
send(java.lang.String sessionId,
java.lang.String command, DwOpenCommandParam params,
java.lang.Integer ackTimeout,
java.lang.Boolean singleton,
java.lang.Object response) |
TR50 Method (Client)
Class DwOpenMethod
- java.lang.Object
-
com.devicewise.tr50.api.DwOpenGeneric
- com.devicewise.tr50.api.DwOpenMethod
-
com.devicewise.tr50.api.DwOpenGeneric
Methods
Modifier and Type | Method and Description |
---|---|
int
|
exec(java.lang.String thingKey,
java.lang.String method, java.lang.Boolean
singleton, java.lang.Integer ackTimeout,
java.util.LinkedHashMap<java.lang.String,
java.lang.Object> params,
java.lang.Object response) |
int
|
exec(java.lang.String thingKey,
java.lang.String method, java.lang.Boolean
singleton, java.lang.Integer ackTimeout,
java.util.LinkedHashMap<java.lang.String,
java.lang.Object> params,
DwOpenReceiveActionListener recv,
java.lang.Object response) |
TR50 Response Handling
Two generic helper response classes are available to every API function in the worker library. These are DwOpenResponse and StringReply, which can be passed in to each worker API function (synchronous or asynchronous) to get the response for each TR50 message that is sent to the deviceWISE Cloud Handler. The StringReply object is a wrapper object that returns the TR50 response in JSON format from the deviceWISE Cloud. The DwOpenResponse is a generic response object that collects and parses the JSON formatted TR50 response message with helper functions that return the success or failure status of the TR50 API call, along with error messages/error codes if any, returned specifically by the deviceWISE Cloud. Any Worker API function will accept these two objects as its 'java.lang.Object response' parameter. This is an output parameter that will return the result of the TR50 API call.
In addition, each worker API returns an int which is an internal API error (non-TR50) for any error that occurs within the API library itself or the client protocol (MQTT or HTTP). This is different from the error codes returned by the deviceWISE Cloud APIs which is available generically in the DwOpenResponse object. Examples of these include, JSON parser errors, MQTT connect errors or invalid/null parameters supplied to the worker function.
In addition to the two generic response objects mentioned above, each API call, pertaining to the level of detail of the TR50 response message from the deviceWISE Cloud, has additional helper response objects that can be passed in as the 'java.lang.Object response' out parameter to parse additional reply parameters returned by the M2M Service. For a complete listing of these helper response objects for each worker function please refer to the above links to each API function. These helper response objects extend the generic DwOpenResponse object and its helper functions.
Notes:
- All helper response objects must be initialized before passing them in as a 'java.lang.Object response' parameter to the worker function.
- StringReply when used as a 'java.lang.Object response' parameter returns the TR50 reply message in JSON (string) format. No parsing of the response message is done.
Class StringReply
- java.lang.Object
- com.devicewise.tr50.helpers.StringReply
Constructors
Constructor and Description |
---|
StringReply() -
Initializes the StringReply
response Object. This constructor must
be called before passing in the object
as an out parameter to any API
function. |
Methods
Modifier and Type | Method and Description |
---|---|
java.lang.String
|
getValue() |
void
|
setValue(java.lang.String val) |
Class DwOpenResponse
- java.lang.Object
-
com.devicewise.tr50.api.response.DwOpenGenericResponse
- com.devicewise.tr50.api.response.DwOpenResponse
-
com.devicewise.tr50.api.response.DwOpenGenericResponse
Constructors
Constructor and Description |
---|
DwOpenResponse() -
Initializes the DwOpenResponse
Object. This constructor must
be called before passing in the
object as an out parameter to
any API function. |
Methods
Modifier and Type | Method and Description |
---|---|
void
|
parseResponse(java.lang.String json) |
Methods inherited from class DwOpenGenericResponse
See table below.
Class DwOpenGenericResponse
- java.lang.Object
- com.devicewise.tr50.api.response.DwOpenGenericResponse
Methods
Modifier and Type | Method and Description |
---|---|
java.lang.String
|
getCorrId() |
java.lang.String
|
getJsonResponse() |
boolean
|
isSuccess() |
void
|
parseCustomResponse(java.lang.String json) |
void
|
parseGenericResponse(java.lang.String json) |
void
|
parseResponse(java.lang.String json) |
void
|
parseResponse(java.lang.String corrId,
java.lang.String json) |
void
|
setCorrId(java.lang.String corrId) |
void
|
setErrorCodes(int[] errorCode) |
void
|
setErrorMessages(java.lang.String[] errorMessages) |
void
|
setJsonResponse(java.lang.String response) |
void
|
setSuccess(boolean success) |
Usage Examples
public void tr50ReponseHandlingExamples(){
DwMqttClient client = new DwMqttClient();
client.initialize(MqttConstants.DEFAULT_MQTTHOST, true, "tr50_client_id");
client.authenticate("myThingKey","myAppToken");
StringReply replyString = new StringReply(); //initialize String helper response Object
DwOpenResponse respGen = new DwOpenResponse(); //initialize Generic helper response Object
DwOpenLocationEncodeDecode respExt = new DwOpenLocationEncodeDecode(); //initialize response Object
// api call with string helper response object. No parsing of response JSON
client.getWorker().Location().publish("myThingKey", TimeFormatter.toRFC3339(new Date(System.currentTimeMillis())), "zzz1", 30.455, -84.253333, 10.0, 15.2,30.1,5.3,"fixType", replyString);
// api call with generic helper response object. Basic parsing of response JSON
client.getWorker().Location().publish("myThingKey", TimeFormatter.toRFC3339(new Date(System.currentTimeMillis())), "corrId", 30.455, -84.253333, 10.0, 15.2,30.1,5.3,"fixType", respGen);
// api call with extender helper response object. Extended parsing of response JSON
client.getWorker().Location().decode(30.455, -84.253333, respExt);
System.out.println("JSON Response from deviceWISE Cloud for Location Publish = "+replyString.getValue());
if(respGen.isSuccess())
System.out.println("TR50 Location Publish API Call Successful!");
else
System.out.println("TR50 Location Publish API Call Failed with Error Message: "+respGen.getErrormessages()[0]+" Error Code: "+respGen.getErrorcodes()[0]);
if(respExt.isSuccess()){
System.out.println("TR50 Location Decode API Call Successful!");
System.out.println("Location Latitude = "+respExt.getLat()); //additional response helper functions available over generic DwOpenResponse helper functions
System.out.println("Location Longitude = "+respExt.getLng());
System.out.println("Location City = "+respExt.getAddress().getCity());
System.out.println("Location State = "+respExt.getAddress().getState());
System.out.println("Location Country = "+respExt.getAddress().getCountry());
}
else{
System.out.println("TR50 Location Decode API Call Failed with Error Message: "+respExt.getErrormessages()[0]+" Error Code: "+respExt.getErrorcodes()[0]);
}
client.disconnect();
}
public class DwOpenWorkerAsyncExample implements DwOpenReceiveActionListener, DwOpenSendActionListener, DwOpenDisconnectActionListener {
public void tr50AsyncWorkerAPIExamples() throws IOException, DwOpenException, MqttException, InterruptedException {
DwMqttClient client = new DwMqttClient();
client.initialize(MqttConstants.DEFAULT_MQTTHOST, true, "tr50_client_id");
client.authenticate("mythingkey", "myapptoken");
client.registerDisconnectActionListener(this); //register for callbacks
client.registerSendActionListener(this);
client.registerReceiveActionListener(this);
synchronized(this) {
// api call with string helper response object. No parsing of response JSON
client.getWorker().Location().publish("myThingKey", TimeFormatter.toRFC3339(new Date(System.currentTimeMillis())), "zzz1", 30.455, -84.253333, 10.0, 15.2, 30.1, 5.3, "fixType", this, new StringReply());
this.wait();
// api call with generic helper response object. Basic parsing of response JSON
client.getWorker().Location().publish("myThingKey", TimeFormatter.toRFC3339(new Date(System.currentTimeMillis())), "corrId", 30.455, -84.253333, 10.0, 15.2, 30.1, 5.3, "fixType", this, new DwOpenResponse());
this.wait();
// api call with extender helper response object. Extended parsing of response JSON
client.getWorker().Location().decode(30.455, -84.253333, this, new DwOpenLocationEncodeDecode());
this.wait();
}
client.disconnect();
}
@Override
public void onDisconnect(DwClient source, Throwable cause) {
// TR50 disconnect handler
}
@Override
public void onSend(DwClient source, int responseCode, Throwable cause, DwPacket packet) {
// send TR50 message handler
}
@Override //handle response callbacks from async calls
public void onReceive(DwClient source, int responseCode, Throwable cause, DwPacket packet, Object response) {
synchronized(this) {
if (response instanceof StringReply)
System.out.println("JSON Response from deviceWISE Cloud for Location Publish = " + ((StringReply) response).getValue());
else if (response instanceof DwOpenResponse) {
DwOpenResponse respGen = (DwOpenResponse) response;
if (respGen.isSuccess())
System.out.println("TR50 Location Publish API Call Successful!");
else
System.out.println("TR50 Location Publish API Call Failed with Error Message: " + respGen.getErrormessages()[0] + " Error Code: " + respGen.getErrorcodes()[0]);
} else if (response instanceof DwOpenLocationEncodeDecode) {
DwOpenLocationEncodeDecode respExt = (DwOpenLocationEncodeDecode) response;
if (respExt.isSuccess()) {
System.out.println("TR50 Location Decode API Call Successful!");
System.out.println("Location Latitude = " + respExt.getLat()); //additional response helper functions available over generic DwOpenResponse helper functions
System.out.println("Location Longitude = " + respExt.getLng());
System.out.println("Location City = " + respExt.getAddress().getCity());
System.out.println("Location State = " + respExt.getAddress().getState());
System.out.println("Location Country = " + respExt.getAddress().getCountry());
} else {
System.out.println("TR50 Location Decode API Call Failed with Error Message: " + respExt.getErrormessages()[0] + " Error Code: " + respExt.getErrorcodes()[0]);
}
}
this.notify();
}
}
}
TR50 Mailbox/Method Handling (Server)
The TR50 Java Library handles incoming Mailbox items via listeners. A generic DwOpenMailboxEventListener interface allows for any Java class that implements this interface to receive all incoming mailbox items with no filter. A more custom DwOpenMailboxCommandListener abstract class allows for any Java class that extends this class to filter on a mailbox item command key, so an instance of the Java class will only receive mailbox items whose command key matches its own. A more custom implementation of the MailboxCommandListener class is the DwOpenMethodCallback abstract class. Any instance of a Java class (TR50 Method) that extends this class will receive mailbox items whose command key is "method.exec".
Each of the above mailbox listener implementations has an OnRecv() callback function that receives the mailbox message. In case of the DwOpenMethodCallback class, the OnRecv() callback function has additional logic to filter on the method key of the mailbox method event. If the method key of a mailbox message (that is of type "method.exec") matches the method key of an instance of DwOpenMethodCallback, the executeMethod() function for that instance is called with input parameters that are supplied to it in the incoming mailbox message (if any). An additional OnMethodAckFailure() is called if the method fails to successfully ack (mailbox.ack) the response from the function after a maximum number of retry attempts.
Notes:
- Each of the three mailbox listener implementations - MailboxEventListener, MailboxCommandListener and DwOpenMethodCallback objects must be registered with the TR50 client object (session) to receive mailbox message events via their respective callback functions. The functions to register the callback objects are listed in the DwClient APIs -Methods
- The instance of MailboxCommandListener has to be registered with a valid command key parameter while the instance of DwOpenMethodCallback has to be registered with a valid method key parameter to receive callbacks.
- Only one type of command key (other than method.exec) and one type of method key can be registered with the same client object.
- At least one implementation of a mailbox event listener must ack (mailbox.ack api call) the received mailbox message.
- To stop receiving messages each listener implementation has its own unregister function listed in the DwClient APIs -Methods.
Interface DwOpenMailboxEventListener
com.devicewise.tr50.listeners
All known implementing classes: DwOpenMailboxCommandListener, DwOpenMethodCallback
Methods
Modifier and Type | Method and Description |
---|---|
void | onReceive(DwClient client,
int retCode,
java.lang.Throwable error, DwOpenMailboxMessage msg) |
Abstract Class DwOpenMailboxCommandListener
- java.lang.Object
- com.devicewise.tr50.listeners.DwOpenMailboxCommandListener
- All implemented interfaces: DwOpenMailboxEventListener
Constructors
Constructor and Description |
---|
DwOpenMailboxCommandListener()
- Initializes an
instance of a Java TR50
Command
Listener |
Methods
Modifier and Type | Method and Description |
---|---|
java.lang.String | getCommand() |
void | setCommand(java.lang.String command) |
Abstract Class DwOpenMethodCallback
- java.lang.Object
-
com.devicewise.tr50.listeners.DwOpenMailboxCommandListener
- com.devicewise.tr50.api.events.DwOpenMethodCallback
-
com.devicewise.tr50.listeners.DwOpenMailboxCommandListener
All implemented interfaces: DwOpenMailboxEventListener
Constructors
Constructor and Description |
---|
DwOpenMethodCallback(java.lang.String methodKey)
- Initializes an
instance of a Java TR50
Method
Object |
Methods
Modifier and Type | Method and Description |
---|---|
abstract
int | executeMethod(java.lang.String execId,
java.util.LinkedHashMap<java.lang.String,java.lang.Object> inParams,
java.util.LinkedHashMap<java.lang.String,java.lang.Object> outParams, StringReply errorMessage) |
DwOpenMailboxMessage | getCurrentMailboxMessage() |
java.lang.String | getMethodName() |
abstract
void | onMethodAckFailure(int errorCode,
java.lang.String errorMessage,
java.lang.Throwable error) |
void | onReceive(DwClient client,
int retCode,
java.lang.Throwable error, DwOpenMailboxMessage msg) |
void | setCurrentMailboxMessage(DwOpenMailboxMessage currentMailboxMessage) |
void | setMethodName(java.lang.String methodName) |
Usage Examples:
public void runMailboxEventListener(DwMqttClient client, MailboxMessageAckEvent event) throws InterruptedException{
client.registerMailboxEventListener(event);
while(client.isConnected()){
Thread.sleep(500);
}
client.unregisterMailboxEventListener(event);
}
public class MailboxMessageAckEvent implements DwOpenMailboxEventListener{
@Override
public void onReceive(DwClient client, int retCode, Throwable error,
DwOpenMailboxMessage msg){
// Implement Callback Logic Here
//Remember to Ack
DwOpenResponse response = new DwOpenResponse();
try {
client.getWorker().Mailbox().ack(msg.getId(), 0, null, null, new DwOpenResponse());
if(response.isSuccess())
{
System.out.println("Successful Mailbox Ack !");
}
} catch (IOException | DwOpenException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Test
public void testMailboxCommandListener() throws DwOpenException, IOException, InterruptedException{
DwOpenResponse response = new DwOpenResponse();
DiagPingCommandEvent event = new DiagPingCommandEvent();
Assert.assertEquals(client.registerMailboxCommandListener("diag.ping",event),0);
client.getWorker().Generic().sendParamsWithReply("gateway.ping", "do", response);
Thread.sleep(1000); // Wait 1 second for ping to response
Assert.assertTrue(response.isSuccess());
Assert.assertTrue(event.getResponse().isSuccess()); // Successful Ack !
Assert.assertEquals(client.unregisterMailboxCommandListener(event),0);
}
public class DiagPingCommandEvent extends DwOpenMailboxCommandListener{
private DwOpenResponse response;
public DiagPingCommandEvent(){
response = new DwOpenResponse();
}
@Override
public void onReceive(DwClient client, int retCode, Throwable error,
DwOpenMailboxMessage msg) {
try {
client.getWorker().Mailbox().ack(msg.getId(), 0, null, null, response);
} catch (IOException | DwOpenException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public DwOpenResponse getResponse() {
return response;
}
public void setResponse(DwOpenResponse response) {
this.response = response;
}
}
@Test
public void testMethodEvent() throws DwOpenException, IOException{
DwOpenMethodExec response = new DwOpenMethodExec();
LinkedHashMap<String,Object> params = new LinkedHashMap<String,Object>();
DoubleValues method = new DoubleValues("double_values");
Assert.assertEquals(client.registerMethod(method),0);
Assert.assertEquals(client.registerMethod(method), DwOpenErrors.API_METHOD_ALREADY_REGISTERED);
params.put("float_param", 3.5);
params.put("int_param", -13);
params.put("uint_param", 5);
client.getWorker().Method().exec("tr50user", true, "double_values", false, 60, params, response);
Assert.assertTrue(response.isSuccess());
Assert.assertEquals(response.getParams().get("float_param_out"),7.0);
Assert.assertEquals(response.getParams().get("int_param_out"),-26);
Assert.assertEquals(response.getParams().get("uint_param_out"),10);
Assert.assertEquals(client.unregisterMethod(method),0);
Assert.assertEquals(client.unregisterMethod(method),DwOpenErrors.API_METHOD_NOT_REGISTERED);
}
public class DoubleValues extends DwOpenMethodCallback{
public DoubleValues(String methodName) {
super(methodName);
// TODO Auto-generated constructor stub
}
@Override
public int executeMethod(String execId,
LinkedHashMap<String, Object> inParams,
LinkedHashMap<String, Object> outParams, StringReply errorMessage) {
try{
System.out.println("Current Mailbox ID:"+getCurrentMailboxMessage().getId());
System.out.println("Current ThingKey:"+getCurrentMailboxMessage().getThingKey());
System.out.println("Current From:"+getCurrentMailboxMessage().getFrom());
if(inParams.containsKey("int_param")){
outParams.put("int_param_out", 2 * (int)inParams.get("int_param"));
}
else{
errorMessage.setValue("Required Param int_param missing");
return(-7777);
}
if(inParams.containsKey("float_param")){
outParams.put("float_param_out", 2 * (float)inParams.get("float_param"));
}
else{
errorMessage.setValue("Required Param float_param missing");
return(-8888);
}
if(inParams.containsKey("uint_param") && (int)inParams.get("uint_param")>=0){
outParams.put("uint_param_out", 2 * (int)inParams.get("uint_param"));
}
else{
errorMessage.setValue("Required Param uint_param missing or invalid");
return(-9999);
}
}catch(Exception e){
errorMessage.setValue(e.getMessage());
return(-1);
}
return 0;
}
@Override
public void onMethodAckFailure(int errorCode, String errorMessage,
Throwable error) {
System.out.println("Ack Failed for Method Double Values");
}
}