Skip to content

Training ‐ 5. SensorML Sensor Description through API

Michael Elmore edited this page Dec 18, 2023 · 1 revision

Requirements

  • Java Programming Language: Entry Level Experience
  • Training 4 complete

Adding SensorML Description Programmatically

API: AbstractSensorModule

  • 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.

Sensor extends AbstractSensorModule

step1

updateSensorDescription

  • 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.

Navigate to Sensor(.java) and Open

step2

Override updateSensorDescription

step3

Building the Description

  • All sensor description operations shall be performed within
synchronized (sensorDescLock) {
    super.updateSensorDescription();
}
  • Make sure to call method on parent via super

Update Sensor Description if not Already Set

if (!sensorDescription.isSetDescription()) {

}

step4

Textual Description – Overview of Sensor

sensorDescription.setDescription("A simulated sensor for training purposes, demonstrating how to build a driver.");

step5

SMLHelper API Builders

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

SMLHelper Editors

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

Use SMLHelper Edit Functionality

Create instance of SMLHelper and begin editing (note the sensorDescription is cast to a PhysicalSystem):

SMLHelper smlHelper = new SMLHelper();
smlHelper.edit((PhysicalSystem)sensorDescription)

step6

Adding an Identifier - SerialNumber

.addIdentifier(smlHelper.identifiers.serialNumber("1234567890"))

step7

SMLHelper identifiers provides several methods to create identifiers.

step8

Add Classifier(s)

.addClassifier(smlHelper.classifiers.sensorType("Simulated Sensor Platform"))

step9

SMLHelper identifiers provides methods to create classifiers

Classifiers aid in identifying or defining the sensor type and can include ontological definitions via URL strings

step10

Adding Characteristics

.addCharacteristicList("operating-specs", smlHelper.characteristics.operatingCharacteristics()
        .add("voltage", smlHelper.characteristics.operatingVoltage(3.3, "v"))
        .add("temperature", smlHelper.conditions.temperatureRange(-10, 75, "Cel")));

step11

• 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"

step12

Adding Identifiers

Editing doInit() to Add Identifiers

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.

step13

Other SensorML Properties

Adding Capabilities

  • 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"

Adding Other Details

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)

Closing Remarks

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
Clone this wiki locally