ConfigType
- public abstract class AbstractSensorModule<ConfigType extends SensorConfig> extends AbstractModule<ConfigType> implements ISensorModule<ConfigType>
Class providing 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:
All of these items can be overriden by derived classes.
It also provides helper methods to implement automatic reconnection.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_XMLID_PREFIX |
protected static String |
ERROR_NO_ENTITIES |
protected static String |
ERROR_NO_HISTORY |
protected static String |
ERROR_NO_UPDATE |
protected AbstractFeature |
foi |
protected long |
lastUpdatedSensorDescription |
protected static String |
LOCATION_OUTPUT_ID |
protected static String |
LOCATION_OUTPUT_NAME |
protected DefaultLocationOutput |
locationOutput |
protected boolean |
randomUniqueID |
protected Object |
sensorDescLock |
protected AbstractPhysicalProcess |
sensorDescription |
protected static String |
STATE_LAST_SML_UPDATE |
protected static String |
STATE_UNIQUE_ID |
protected String |
uniqueID |
protected static String |
UUID_URI_PREFIX |
protected String |
xmlID |
config, eventHandler, lastError, logger, securityHandler, startRequested, state, stateLock, statusMsg
Constructor and Description |
---|
AbstractSensorModule() |
Modifier and Type | Method and Description |
---|---|
protected void |
addControlInput(ISensorControlInterface controlInterface)
Call this method to add each sensor control input
|
protected void |
addLocationOutput(double updatePeriod)
Helper method to add a location output so that all sensors can update their location
in a consistent manner.
|
protected void |
addOutput(ISensorDataInterface dataInterface,
boolean isStatus)
Call this method to add each sensor observation or status output
|
protected void |
generateUniqueID(String prefix,
String suffix)
Generates the sensor unique ID by concatenating a prefix and suffix.
If no suffix is provided, the first 8 characters of the local ID are used to make the ID more unique |
protected void |
generateXmlID(String prefix,
String suffix)
Generates the sensor XML ID by concatenating a prefix and suffix.
If no suffix is provided, the first 8 characters of the local ID are used to make the ID more unique |
protected void |
generateXmlIDFromUUID(String uuid) |
Map<String,ISensorDataInterface> |
getAllOutputs()
Retrieves the list of interfaces to all sensor data outputs
|
Map<String,ISensorControlInterface> |
getCommandInputs()
Retrieves the list of interface to sensor command inputs
|
AbstractPhysicalProcess |
getCurrentDescription()
Retrieves most current sensor description.
|
AbstractFeature |
getCurrentFeatureOfInterest()
Retrieves the feature of interest for which this producer is
currently generating data.
In the case of a module generating data from multiple entities (e.g. |
protected String |
getDefaultIdSuffix() |
long |
getLastDescriptionUpdate()
Used to check when SensorML description was last updated.
|
protected String |
getLocalFrameID() |
Map<String,ISensorDataInterface> |
getObservationOutputs()
Retrieves the list of interface to sensor observation outputs
|
Map<String,ISensorDataInterface> |
getStatusOutputs()
Retrieves the list of interface to sensor status outputs
|
String |
getUniqueIdentifier() |
void |
init()
Initializes the module synchronously with the current configuration.
Implementations of this method must block until the module is successfully initialized or send an exception. Module lifecycle events may not be generated when calling this method directly. |
void |
init(ConfigType config)
Initializes the module synchronously with the specified configuration.
Implementations of this method must block until the module is successfully initialized or send an exception. This is equivalent to calling IModule.setConfiguration(ModuleConfig)
and then IModule.init() with no arguments.Module lifecycle events may not be generated when calling this method directly. |
void |
loadState(IModuleStateManager loader)
Restores the state of this module
Implementations of this method must block until the module state is successfully loaded or send an exception. |
protected void |
notifyNewDescription(long updateTime) |
protected void |
removeAllControlInputs()
Removes all control inputs previously added to this sensor
|
protected void |
removeAllOutputs()
Removes all outputs previously added to this sensor
|
void |
saveState(IModuleStateManager saver)
Saves the state of this module.
Implementations of this method must block until the module state is successfully saved or send an exception. |
void |
updateConfig(ConfigType config)
Updates the module's configuration dynamically.
The module must honor this new configuration unless an error is detected. |
protected void |
updateSensorDescription()
This method should be called whenever the sensor description needs to be regenerated.
This default implementation reads the base description from the SensorML file if provided and then appends the unique sensor identifier, time validity and the description of all registered outputs and control inputs. |
canInit, canStart, canStop, clearError, clearStatus, getConfiguration, getCurrentError, getCurrentState, getLocalID, getLogger, getName, getStatusMessage, isInitialized, isStarted, notifyConnectionStatus, registerListener, reportError, reportError, reportStatus, requestInit, requestStart, requestStop, setConfiguration, setState, toString, unregisterListener, waitForState
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isConnected
cleanup, getConfiguration, getCurrentError, getCurrentState, getLocalID, getName, getStatusMessage, isInitialized, isStarted, registerListener, requestInit, requestStart, requestStop, setConfiguration, start, stop, unregisterListener, waitForState
public static final String DEFAULT_XMLID_PREFIX
protected static final String LOCATION_OUTPUT_ID
protected static final String LOCATION_OUTPUT_NAME
protected static final String ERROR_NO_UPDATE
protected static final String ERROR_NO_HISTORY
protected static final String ERROR_NO_ENTITIES
protected static final String UUID_URI_PREFIX
protected static final String STATE_UNIQUE_ID
protected static final String STATE_LAST_SML_UPDATE
protected DefaultLocationOutput locationOutput
protected AbstractPhysicalProcess sensorDescription
protected long lastUpdatedSensorDescription
protected Object sensorDescLock
protected String xmlID
protected String uniqueID
protected boolean randomUniqueID
protected AbstractFeature foi
public void init() throws SensorHubException
IModule
init
in interface IModule<ConfigType extends SensorConfig>
init
in class AbstractModule<ConfigType extends SensorConfig>
SensorHubException
public final void init(ConfigType config) throws SensorHubException
IModule
IModule.setConfiguration(ModuleConfig)
and then IModule.init()
with no arguments.init
in interface IModule<ConfigType extends SensorConfig>
init
in class AbstractModule<ConfigType extends SensorConfig>
SensorHubException
protected void addOutput(ISensorDataInterface dataInterface, boolean isStatus)
dataInterface
- interface to add as sensor outputisStatus
- set to true when registering a status outputprotected void addLocationOutput(double updatePeriod)
updatePeriod
- estimated location update period or NaN if sensor is mostly staticprotected void removeAllOutputs()
protected void addControlInput(ISensorControlInterface controlInterface)
controlInterface
- interface to add as sensor control inputprotected void removeAllControlInputs()
public String getUniqueIdentifier()
getUniqueIdentifier
in interface IModuleWithDescription
public AbstractPhysicalProcess getCurrentDescription()
ISensorModule
getCurrentDescription
in interface IModuleWithDescription
getCurrentDescription
in interface ISensorModule<ConfigType extends SensorConfig>
public long getLastDescriptionUpdate()
IModuleWithDescription
getLastDescriptionUpdate
in interface IModuleWithDescription
Long.MIN_VALUE
if description was never updated.protected void updateSensorDescription()
SensorException
protected void notifyNewDescription(long updateTime)
protected String getLocalFrameID()
public Map<String,ISensorDataInterface> getAllOutputs()
ISensorModule
getAllOutputs
in interface IDataProducerModule<ConfigType extends SensorConfig>
getAllOutputs
in interface ISensorModule<ConfigType extends SensorConfig>
public Map<String,ISensorDataInterface> getStatusOutputs()
ISensorModule
getStatusOutputs
in interface ISensorModule<ConfigType extends SensorConfig>
public Map<String,ISensorDataInterface> getObservationOutputs()
ISensorModule
getObservationOutputs
in interface ISensorModule<ConfigType extends SensorConfig>
public Map<String,ISensorControlInterface> getCommandInputs()
ISensorModule
getCommandInputs
in interface ISensorModule<ConfigType extends SensorConfig>
public AbstractFeature getCurrentFeatureOfInterest()
IDataProducerModule
IMultiSourceDataProducer.getCurrentFeatureOfInterest(String)
getCurrentFeatureOfInterest
in interface IDataProducerModule<ConfigType extends SensorConfig>
public void updateConfig(ConfigType config) throws SensorHubException
IModule
updateConfig
in interface IModule<ConfigType extends SensorConfig>
updateConfig
in class AbstractModule<ConfigType extends SensorConfig>
SensorHubException
public void loadState(IModuleStateManager loader) throws SensorHubException
IModule
loadState
in interface IModule<ConfigType extends SensorConfig>
loadState
in class AbstractModule<ConfigType extends SensorConfig>
SensorHubException
public void saveState(IModuleStateManager saver) throws SensorHubException
IModule
saveState
in interface IModule<ConfigType extends SensorConfig>
saveState
in class AbstractModule<ConfigType extends SensorConfig>
SensorHubException
protected String getDefaultIdSuffix()
protected void generateUniqueID(String prefix, String suffix)
prefix
- Unique ID prefixsuffix
- Unique ID suffix or null if autogeneratedprotected void generateXmlID(String prefix, String suffix)
prefix
- XML ID prefixsuffix
- XML ID suffix or null if autogeneratedprotected void generateXmlIDFromUUID(String uuid)
Copyright © 2016 Sensia Software LLC. All rights reserved.