Package net.solarnetwork.node.runtime
Class DefaultDatumService
java.lang.Object
net.solarnetwork.node.runtime.DefaultDatumService
- All Implemented Interfaces:
Consumer<NodeDatum>,InstructionHandler,DatumService,org.osgi.service.event.EventHandler
public class DefaultDatumService
extends Object
implements DatumService, org.osgi.service.event.EventHandler, InstructionHandler, Consumer<NodeDatum>
Default implementation of
DatumService.
This service listens for DatumDataSource.EVENT_TOPIC_DATUM_CAPTURED
events to track datum.
- Version:
- 2.1
- Author:
- matt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default history raw count.static final StringThe service name to retrieve the latest datum.Fields inherited from interface net.solarnetwork.node.reactor.InstructionHandler
PARAM_MESSAGE, PARAM_SERVICE, PARAM_SERVICE_ARGUMENT, PARAM_SERVICE_RESULT, PARAM_STATUS_CODE, TOPIC_DEMAND_BALANCE, TOPIC_SET_CONTROL_PARAMETER, TOPIC_SET_OPERATING_STATE, TOPIC_SHED_LOAD, TOPIC_SIGNAL, TOPIC_SYSTEM_CONFIGURE -
Constructor Summary
ConstructorsConstructorDescriptionDefaultDatumService(org.springframework.util.PathMatcher pathMatcher, com.fasterxml.jackson.databind.ObjectMapper objectMapper, net.solarnetwork.service.OptionalService<DatumMetadataService> datumMetadataService) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidnet.solarnetwork.domain.datum.DatumMetadataOperationsdatumMetadata(String sourceId) Get the metadata for a given datum stream.Collection<net.solarnetwork.domain.datum.DatumMetadataOperations>datumMetadata(Set<String> sourceIdFilter) Get the metadata for a set of datum streams matching a filter.voidhandleEvent(org.osgi.service.event.Event event) booleanhandlesTopic(String topic) Test if a topic is handled by this handler.<T extends NodeDatum>
TGet the latest available datum of a given type, optionally filtered by source IDs.<T extends NodeDatum>
Collection<T>Get the latest available datum of a given type, optionally filtered by source IDs.<T extends NodeDatum>
TGet an offset from the latest available datum of a given type, optionally filtered by source IDs.<T extends NodeDatum>
TGet a datum offset from a given timestamp.<T extends NodeDatum>
Collection<T>Get an offset from the latest available datum of a given type, optionally filtered by source IDs.<T extends NodeDatum>
Collection<T>Get datum offset from a given timestamp, optionally filtered by source IDs.processInstruction(Instruction instruction) Process an instruction.voidsetHistoryRawCount(int rawCount) Change the history raw count.
-
Field Details
-
SETUP_SERVICE_LATEST_DATUM
The service name to retrieve the latest datum.- See Also:
-
DEFAFULT_HISTORY_RAW_COUNT
public static final int DEFAFULT_HISTORY_RAW_COUNTThe default history raw count.- See Also:
-
-
Constructor Details
-
DefaultDatumService
public DefaultDatumService(org.springframework.util.PathMatcher pathMatcher, com.fasterxml.jackson.databind.ObjectMapper objectMapper, net.solarnetwork.service.OptionalService<DatumMetadataService> datumMetadataService) Constructor.- Parameters:
pathMatcher- the path matcher to useobjectMapper- the object mapper to usedatumMetadataService- the datum metadata service to use- Throws:
IllegalArgumentException- if any argument is null
-
-
Method Details
-
latest
Description copied from interface:DatumServiceGet the latest available datum of a given type, optionally filtered by source IDs.This is equivalent to calling
offset(sourceIdFilter, 0, type).- Specified by:
latestin interfaceDatumService- Type Parameters:
T- the type of datum to get- Parameters:
sourceIdFilter- an optional set of Ant-style source ID patterns to filter bytype- the type of datum- Returns:
- the matching datum, never null
- See Also:
-
latest
Description copied from interface:DatumServiceGet the latest available datum of a given type, optionally filtered by source IDs.This is equivalent to calling
offset(sourceIdFilter, 0, type).- Specified by:
latestin interfaceDatumService- Type Parameters:
T- the type of datum to get- Parameters:
sourceId- the source ID to findtype- the type of datum- Returns:
- the matching datum, never null
- See Also:
-
offset
Description copied from interface:DatumServiceGet an offset from the latest available datum of a given type, optionally filtered by source IDs.- Specified by:
offsetin interfaceDatumService- Type Parameters:
T- the type of datum to get- Parameters:
sourceId- the source ID to findoffset- the offset from the latest, 0 being the latest and 1 the next later, and so ontype- the type of datum- Returns:
- the matching datum, never null
-
offset
public <T extends NodeDatum> Collection<T> offset(Set<String> sourceIdFilter, int offset, Class<T> type) Description copied from interface:DatumServiceGet an offset from the latest available datum of a given type, optionally filtered by source IDs.- Specified by:
offsetin interfaceDatumService- Type Parameters:
T- the type of datum to get- Parameters:
sourceIdFilter- an optional set of Ant-style source ID patterns to filter by; use null or an empty set to return all available sourcesoffset- the offset from the latest, 0 being the latest and 1 the next later, and so ontype- the type of datum- Returns:
- the matching datum, never null
-
offset
public <T extends NodeDatum> Collection<T> offset(Set<String> sourceIdFilter, Instant timestamp, int offset, Class<T> type) Description copied from interface:DatumServiceGet datum offset from a given timestamp, optionally filtered by source IDs.- Specified by:
offsetin interfaceDatumService- Type Parameters:
T- the type of datum to get- Parameters:
sourceIdFilter- an optional set of Ant-style source ID patterns to filter by; use null or an empty set to return all available sourcestimestamp- the timestamp to referenceoffset- the offset fromtimestamp, 0 being the latest and 1 the next later, and so ontype- the type of datum- Returns:
- the matching datum, never null
-
offset
public <T extends NodeDatum> T offset(String sourceId, Instant timestamp, int offset, Class<T> type) Description copied from interface:DatumServiceGet a datum offset from a given timestamp.- Specified by:
offsetin interfaceDatumService- Type Parameters:
T- the type of datum to get- Parameters:
sourceId- the source ID of the datum to findtimestamp- the timestamp to referenceoffset- the offset fromtimestamp, 0 being the latest and 1 the next later, and so ontype- the type of datum- Returns:
- the datum, or null if no such datum is available
-
accept
-
handleEvent
public void handleEvent(org.osgi.service.event.Event event) - Specified by:
handleEventin interfaceorg.osgi.service.event.EventHandler
-
handlesTopic
Description copied from interface:InstructionHandlerTest if a topic is handled by this handler.- Specified by:
handlesTopicin interfaceInstructionHandler- Parameters:
topic- the topic- Returns:
- true only if this handler can execute the job for the given topic
-
processInstruction
Description copied from interface:InstructionHandlerProcess an instruction.- Specified by:
processInstructionin interfaceInstructionHandler- Parameters:
instruction- the instruction to process- Returns:
- the status for the instruction, or null if the instruction was not handled
-
datumMetadata
Description copied from interface:DatumServiceGet the metadata for a given datum stream.- Specified by:
datumMetadatain interfaceDatumService- Parameters:
sourceId- the source ID of the datum metadata to get- Returns:
- the metadata, or null if no such metadata is available
-
datumMetadata
public Collection<net.solarnetwork.domain.datum.DatumMetadataOperations> datumMetadata(Set<String> sourceIdFilter) Description copied from interface:DatumServiceGet the metadata for a set of datum streams matching a filter.- Specified by:
datumMetadatain interfaceDatumService- Parameters:
sourceIdFilter- an optional set of Ant-style source ID patterns to filter by; use null or an empty set to return all available sources- Returns:
- the matching metadata, never null
-
setHistoryRawCount
public void setHistoryRawCount(int rawCount) Change the history raw count.Calling this resets the entire history.
- Parameters:
rawCount- the raw count to set
-