Class HistorianQueryExecutor
java.lang.Object
com.inductiveautomation.historian.gateway.interop.HistorianQueryExecutor
- All Implemented Interfaces:
ResultPublisher<ResultNodeDefinition>
,ValuePublisher
,HistoryQueryExecutor
This is a HistoryQueryExecutor implementation around the Historian system.
This operates on HistorianDataColumns that should already have the path normalized to the historian.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.inductiveautomation.historian.gateway.api.query.ResultPublisher
ResultPublisher.PublisherState
-
Constructor Summary
ConstructorsConstructorDescriptionHistorianQueryExecutor
(Historian historian, List<HistorianDataColumn> columns, QueryController controller, boolean isRaw) -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Cancels the publishing process.void
If startReading was called, this function must be called (that is, it should be in a finally block).void
finish()
Completes the publishing process.void
Completes the publishing process with an error.List<? extends ResultNode>
Returns the HistoryNodes of this executor.Returns an identifier for this publisher.getState()
Returns the current state of the publisher.boolean
hasMore()
Returns TRUE if there is more data available to be written on call to processData()void
Initializes the query, performing any actions necessary to get the information required to run the query.void
initialize
(ResultNodeDefinition definition, DataType dataType) Initializes the publisher with the expected data type.void
initializeWithFailure
(ResultNodeDefinition key, QualityCode qualityCode) Initializes the publisher with a key and a quality code.protected boolean
protected boolean
isOperationTimedOut
(long startMS) long
nextTime()
The timestamp of the next value.protected void
long
Puts the next value(s) into the appropriate column, returning the latest timestamp loaded, or -1 if no data was loaded.void
publish
(ResultNodeDefinition key, QualifiedValue value) Publishes a value for the given query definition.void
Begins reading data.protected void
protected void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.inductiveautomation.ignition.gateway.sqltags.history.query.HistoryQueryExecutor
getEffectiveWindowSizeMS
-
Constructor Details
-
HistorianQueryExecutor
public HistorianQueryExecutor(Historian historian, List<HistorianDataColumn> columns, QueryController controller, boolean isRaw)
-
-
Method Details
-
cancel
public void cancel()Description copied from interface:ResultPublisher
Cancels the publishing process. Must be called if the publishing process is canceled before completion.- Specified by:
cancel
in interfaceResultPublisher<ResultNodeDefinition>
-
initialize
public void initialize()Description copied from interface:HistoryQueryExecutor
Initializes the query, performing any actions necessary to get the information required to run the query.- Specified by:
initialize
in interfaceHistoryQueryExecutor
-
getColumnNodes
Description copied from interface:HistoryQueryExecutor
Returns the HistoryNodes of this executor. There MUST be one for every tag path, and they must be in the same order as the paths provided to the executor when it was created. Also, these values must be available as soon as the executor is created. However, they won't be consulted for their data type until after initialize is called, so the normal procedure is to create and returnDelegatingResultNode
s, which get filled in later.- Specified by:
getColumnNodes
in interfaceHistoryQueryExecutor
-
startReading
public void startReading()Description copied from interface:HistoryQueryExecutor
Begins reading data. IMPORTANT: endReading should always be called at some point after calling startReading.- Specified by:
startReading
in interfaceHistoryQueryExecutor
-
getIdentifier
Description copied from interface:ResultPublisher
Returns an identifier for this publisher.- Specified by:
getIdentifier
in interfaceResultPublisher<ResultNodeDefinition>
- Returns:
- A String identifying this publisher instance
-
getState
Description copied from interface:ResultPublisher
Returns the current state of the publisher.- Specified by:
getState
in interfaceResultPublisher<ResultNodeDefinition>
- Returns:
- The current PublisherState
-
initializeWithFailure
Description copied from interface:ResultPublisher
Initializes the publisher with a key and a quality code.- Specified by:
initializeWithFailure
in interfaceResultPublisher<ResultNodeDefinition>
- Parameters:
key
- The key to initialize withqualityCode
- The quality code to initialize with
-
publish
Description copied from interface:ValuePublisher
Publishes a value for the given query definition.- Specified by:
publish
in interfaceValuePublisher
- Parameters:
key
- The query definitionvalue
- The value to publish- Throws:
IllegalStateException
- if the publisher is not in PUBLISHING state
-
waitForColumnInit
protected void waitForColumnInit() -
endReading
public void endReading()Description copied from interface:HistoryQueryExecutor
If startReading was called, this function must be called (that is, it should be in a finally block).- Specified by:
endReading
in interfaceHistoryQueryExecutor
-
isOperationTimedOut
protected boolean isOperationTimedOut(long startMS) -
waitForData
protected void waitForData() -
isFinished
protected boolean isFinished() -
hasMore
public boolean hasMore()Description copied from interface:HistoryQueryExecutor
Returns TRUE if there is more data available to be written on call to processData()- Specified by:
hasMore
in interfaceHistoryQueryExecutor
-
nextTime
public long nextTime()Description copied from interface:HistoryQueryExecutor
The timestamp of the next value. -1 if no value is available.- Specified by:
nextTime
in interfaceHistoryQueryExecutor
-
processData
Description copied from interface:HistoryQueryExecutor
Puts the next value(s) into the appropriate column, returning the latest timestamp loaded, or -1 if no data was loaded.- Specified by:
processData
in interfaceHistoryQueryExecutor
- Throws:
Exception
-
initialize
public void initialize(ResultNodeDefinition definition, DataType dataType) throws IllegalStateException Description copied from interface:ValuePublisher
Initializes the publisher with the expected data type. This method must be called before any publishing operations.- Specified by:
initialize
in interfaceValuePublisher
- Parameters:
definition
- The query definitiondataType
- The class representing the type of data to be published- Throws:
IllegalStateException
- if the publisher is not in UNINITIALIZED state
-
finish
public void finish()Description copied from interface:ResultPublisher
Completes the publishing process. Must be called after everything's been published.- Specified by:
finish
in interfaceResultPublisher<ResultNodeDefinition>
-
finishWithError
Description copied from interface:ResultPublisher
Completes the publishing process with an error. Must be called if an error occurs during the publishing process.- Specified by:
finishWithError
in interfaceResultPublisher<ResultNodeDefinition>
- Parameters:
e
- The exception that caused the error.
-
notifyValueBuffer
protected void notifyValueBuffer()
-