org.universAAL.support.utils.service.mid
Class UtilSensor

Package class diagram package UtilSensor
java.lang.Object
  extended by org.universAAL.support.utils.service.mid.UtilSensor

public class UtilSensor
extends Object

This is a helper class for those who want to use the typical services of an on/off sensor (get status) over an ontological service. It provides methods for automatically generating service profiles and service requests that can be used in ServiceCallees and ServiceCallers. If they are both with the same parameters in both sides, the services are guaranteed to match.

Author:
alfiva

Field Summary
static String IN_DEVICE
          Argument suffix.
static String OUT_GET_ON_OFF
          Argument suffix.
static String SERVICE_GET_ON_OFF
          Service suffix.
 
Constructor Summary
UtilSensor()
           
 
Method Summary
static ServiceProfile[] getServiceProfiles(String namespace, Sensor sensor)
          Gives you the typical service profile of an on/off sensor service: Get status.
static ServiceProfile[] getServiceProfiles(String namespace, String ontologyURI, Sensor sensor)
          Gives you the typical service profile of an on/off sensor service: Get status.
static ServiceRequest requestGetOnOff(Sensor sensor, Output argOut)
          Gives you the typical GET STATUS service request for sensor services.
static ServiceRequest requestGetOnOff(Sensor sensor, String out)
          Gives you the typical GET STATUS service request for sensor services.
static ServiceRequest requestGetOnOff(String ontologyURI, Object in, String out)
          Gives you the typical GET STATUS service request for sensor services.
static ServiceRequest requestGetOnOff(String ontologyURI, Sensor sensor, Output argOut)
          Gives you the typical GET STATUS service request for sensor services.
static ServiceRequest requestGetOnOff(String ontologyURI, Sensor sensor, String out)
          Gives you the typical GET STATUS service request for sensor services.
static ServiceRequest requestGetOnOff(String ontologyURI, Variable argIn, Output argOut)
          Gives you the typical GET STATUS service request for sensor services.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVICE_GET_ON_OFF

public static final String SERVICE_GET_ON_OFF
Service suffix.

See Also:
Constant Field Values

OUT_GET_ON_OFF

public static final String OUT_GET_ON_OFF
Argument suffix.

See Also:
Constant Field Values

IN_DEVICE

public static final String IN_DEVICE
Argument suffix.

See Also:
Constant Field Values
Constructor Detail

UtilSensor

public UtilSensor()
Method Detail

getServiceProfiles

public static ServiceProfile[] getServiceProfiles(String namespace,
                                                  String ontologyURI,
                                                  Sensor sensor)
                                           throws InvalidOntologyUtilException
Gives you the typical service profile of an on/off sensor service: Get status. When handling requests in your Callee, you can use the references to services and arguments URIs prepending namespace to UtilSensor constants.

BE CAREFUL: This will only work with sensors that have StatusValue as HAS_VALUE property. Others, like DimmerSensor, will throw an exception.

Example:

new SCallee(context, getServiceProfiles("http://ontology.universAAL.org/OvenServer.owl#", CarpetSensor.MY_URI, myCarpetSensor))

Parameters:
namespace - The namespace of your server, ending with the character #. You can optionally add some prefix after the # if you use UtilSensor more than once in the same Callee.
ontologyURI - The MY_URI of the class of DeviceService ontology you are going to implement. It MUST be a subclass of DeviceService.
sensor - The ontology instance of the sensor you are controlling. The more properties it has set, the better.
Returns:
An array with the 1 typical service profiles
Throws:
InvalidOntologyUtilException - when an sensor is passed that is does not have StatusValue as type restriction of its HAS_VALUE property.

getServiceProfiles

public static ServiceProfile[] getServiceProfiles(String namespace,
                                                  Sensor sensor)
                                           throws InvalidOntologyUtilException
Gives you the typical service profile of an on/off sensor service: Get status. When handling requests in your Callee, you can use the references to services and arguments URIs prepending namespace to UtilSensor constants.

BE CAREFUL: This will only work with sensors that have StatusValue as HAS_VALUE property. Others, like DimmerSensor, will throw an exception.

Parameters:
namespace - The namespace of your server, ending with the character #. You can optionally add some prefix after the # if you use UtilSensor more than once in the same Callee.
sensor - The ontology instance of the sensor you are controlling. The more properties it has set, the better.
Returns:
An array with the 1 typical service profiles
Throws:
InvalidOntologyUtilException - when an sensor is passed that is does not have StatusValue as type restriction of its HAS_VALUE property.

requestGetOnOff

public static ServiceRequest requestGetOnOff(String ontologyURI,
                                             Variable argIn,
                                             Output argOut)
Gives you the typical GET STATUS service request for sensor services. If the editor service also used UtilSensor the match is guaranteed.

Parameters:
ontologyURI - The MY_URI of the class of Service ontology you want to call
argIn - Value representing the input you want to pass as parameter. The sensor GET service will be called for this specific actuator.
argOut - The returned value of the sensor GET service will be placed in the URI represented by this Output. Look for it there in the response.
Returns:
The ServiceRequest that will call the matching GET STATUS service of an sensor

requestGetOnOff

public static ServiceRequest requestGetOnOff(String ontologyURI,
                                             Object in,
                                             String out)
Gives you the typical GET STATUS service request for sensor services. If the editor service also used UtilSensor the match is guaranteed.

Parameters:
ontologyURI - The MY_URI of the class of Service ontology you want to call
in - Object representing the input you want to pass as parameter. The sensor GET service will be called for this specific actuator.
out - The returned value of the sensor GET service will be placed in this URI. Look for it there in the response.
Returns:
The ServiceRequest that will call the matching GET STATUS service of an sensor

requestGetOnOff

public static ServiceRequest requestGetOnOff(String ontologyURI,
                                             Sensor sensor,
                                             Output argOut)
Gives you the typical GET STATUS service request for sensor services. If the editor service also used UtilSensor the match is guaranteed.

Parameters:
ontologyURI - The MY_URI of the class of Service ontology you want to call
sensor - The ontology instance of the sensor you want to get the status from.
argOut - The returned value of the sensor GET service will be placed in the URI represented by this Output. Look for it there in the response.
Returns:
The ServiceRequest that will call the matching GET STATUS service of an sensor

requestGetOnOff

public static ServiceRequest requestGetOnOff(String ontologyURI,
                                             Sensor sensor,
                                             String out)
Gives you the typical GET STATUS service request for sensor services. If the editor service also used UtilSensor the match is guaranteed.

Parameters:
ontologyURI - The MY_URI of the class of Service ontology you want to call
sensor - The ontology instance of the sensor you want to get the status from.
out - The returned value of the sensor GET service will be placed in the URI represented by this String. Look for it there in the response.
Returns:
The ServiceRequest that will call the matching GET STATUS service of an sensor

requestGetOnOff

public static ServiceRequest requestGetOnOff(Sensor sensor,
                                             Output argOut)
Gives you the typical GET STATUS service request for sensor services. If the editor service also used UtilSensor the match is guaranteed.

Parameters:
sensor - The ontology instance of the sensor you want to get the status from.
argOut - The returned value of the sensor GET service will be placed in the URI represented by this Output. Look for it there in the response.
Returns:
The ServiceRequest that will call the matching GET STATUS service of an sensor

requestGetOnOff

public static ServiceRequest requestGetOnOff(Sensor sensor,
                                             String out)
Gives you the typical GET STATUS service request for sensor services. If the editor service also used UtilSensor the match is guaranteed.

Parameters:
sensor - The ontology instance of the sensor you want to get the status from.
out - The returned value of the sensor GET service will be placed in the URI represented by this String. Look for it there in the response.
Returns:
The ServiceRequest that will call the matching GET STATUS service of an sensor


Copyright © 2014 universAAL Consortium. All Rights Reserved.