-
Notifications
You must be signed in to change notification settings - Fork 12
Training ‐ 5. SensorML Sensor Description through API
- Java Programming Language: Entry Level Experience
- Training 4 complete
- Class provides the default implementation of common sensor API methods. This can be used as the base for most sensor driver implementations, as it generates defaults for the following:
- A random Unique ID using a UUID (the same is used between restarts)
- A short XML ID
- A default SensorML description including IDs, temporal validity, I/Os and position (location + orientation) if the sensor configuration provides static location and/or orientation
- A feature of interest if the sensor configuration provides static location
- All of these items can be overridden by derived classes. It also provides helper methods to implement automatic reconnection.
- This method should be called whenever the sensor description needs to be regenerated.
- The default implementation reads the base description from the SensorML file if provided and then appends the unique sensor identifier, time validity, and description of all registered outputs and control inputs.
- Override method to provide sensor description programmatically.
- All sensor description operations shall be performed within
synchronized (sensorDescLock) {
super.updateSensorDescription();
}
- Make sure to call method on parent via super
if (!sensorDescription.isSetDescription()) {
}
sensorDescription.setDescription("A simulated sensor for training purposes, demonstrating how to build a driver.");
Provides methods to build systems and processes compliant with SensorML
public SimpleProcessBuilder createSimpleProcess()
- A builder to create a new SimpleProcess
public AggregateProcessBuilder createAggregateProcess()
- A builder to create a new AggregateProcess
public PhysicalComponentBuilder createPhysicalComponent()
- A builder to create a new PhysicalComponent
public PhysicalSystemBuilder createPhysicalSystem()
- A builder to create a new PhysicalSystem
Also Provides methods to edit systems and process descriptions
public SimpleProcessBuilder edit(SimpleProcess sml)
- Helper method to edit a SimpleProcess description in-place using a builder
public AggregateProcessBuilder edit(AggregateProcess sml)
- Helper method to edit a AggregateProcess description in-place using a builder
public PhysicalComponentBuilder edit(PhysicalComponent sml)
- Helper method to edit a PhysicalComponent description in-place using a builder
public PhysicalSystemBuilder edit(PhysicalSystem sml)
- Helper method to edit a PhysicalSystem description in-place using a builder
Create instance of SMLHelper and begin editing (note the sensorDescription is cast to a PhysicalSystem):
SMLHelper smlHelper = new SMLHelper();
smlHelper.edit((PhysicalSystem)sensorDescription)
.addIdentifier(smlHelper.identifiers.serialNumber("1234567890"))
SMLHelper identifiers provides several methods to create identifiers.
.addClassifier(smlHelper.classifiers.sensorType("Simulated Sensor Platform"))
SMLHelper identifiers provides methods to create classifiers
Classifiers aid in identifying or defining the sensor type and can include ontological definitions via URL strings
.addCharacteristicList("operating-specs", smlHelper.characteristics.operatingCharacteristics()
.add("voltage", smlHelper.characteristics.operatingVoltage(3.3, "v"))
.add("temperature", smlHelper.conditions.temperatureRange(-10, 75, "Cel")));
• SMLHelper through the characteristics member allows various characteristics to be defined or added to the sensor description • These are not required but should be specified for robustness when appropriate • “uom” refers to "unit of measure"
The template sensor class provides placeholders [URN] and [XML-PREFIX] that need to be changed. The identifiers are composed of a prefix and a suffix, the UniqueId takes the form of a URN while the XmlID is a text value. If no suffix is specified one is generated automatically, however, in our case, we will retrieve suffix from config, which will be discussed in a later lab.
- SMLHelper through the capabilities member allows various capabilities to be defined or added to the sensor description
- These are not required but should be specified for robustness when appropriate
- "uom" refers to "unit of measure"
While editing the sensorDescription:
addComponentLocation
- When the sensor is at a fixed location
- Can be set through configuration
addComponent
- Adds a component, an embedded PhysicalSystem that is part of the sensor, as in a sensor platform
addLocalReferenceFrame
- Reference frame for orientation of component(s)
At this point you have
- Begun populating the body for the Sensor class
- Programmatically added a sensor description which is used to generate the SensorML description provided by OpenSensorHub upon request
Next Steps
- Defining the Output class and adding it to the sensor
- Build, redeploy, and test