类 AbstractProvider<T extends ProviderEvent>
- 类型参数:
T- TheProviderEventto be dispatched.
- 所有已实现的接口:
EventListener,SentenceListener
Abstract base class for providers. Defines methods that all providers must implement and provides general services for capturing and validating the required sentences.
When constructing PositionEvent,
the maximum age for all captured sentences is 1000 ms, i.e. all sentences are
from within the default NMEA update rate (1/s).
- 作者:
- Kimmo Tuukkanen
-
字段概要
字段 -
构造器概要
构造器构造器说明AbstractProvider(SentenceReader reader, String... ids) Creates a new instance of AbstractProvider.AbstractProvider(SentenceReader reader, SentenceId... ids) Creates a new instance of AbstractProvider. -
方法概要
修饰符和类型方法说明voidaddListener(ProviderListener<T> listener) Inserts a listener to provider.protected abstract TCreates aProviderEventof typeT.Returns the collected sentences.protected final booleanTells if the provider has captured all the specified sentences.protected final booleanTells if the provider has captured at least one of the specified sentences.protected abstract booleanisReady()Tells if provider has captured the required sentences for creating new ProviderEvent.protected abstract booleanisValid()Tells if the captured sentence events contain valid data to be dispatched to ProviderListeners.voidCalled afterSentenceReaderhas timed out for receiving new data.voidCalled beforeSentenceReaderstarts dispatching events.voidCalled afterSentenceReaderhas permanently stopped reading, either due to an error or by calling theSentenceReader.stop()method.voidremoveListener(ProviderListener<T> listener) Removes the specified listener from provider.voidsentenceRead(SentenceEvent event) Called bySentenceReaderwhen a single NMEA 0183 sentence has been read and parsed from the data stream.voidsetTimeout(int millis) Sets the timeout for receiving a burst of sentences.
-
字段详细资料
-
DEFAULT_TIMEOUT
public static int DEFAULT_TIMEOUTThe default timeout for receicing a burst of sentences.
-
-
构造器详细资料
-
AbstractProvider
Creates a new instance of AbstractProvider.- 参数:
reader- Sentence reader to be used as data sourceids- Types of sentences to capture for creating provider events
-
AbstractProvider
Creates a new instance of AbstractProvider.- 参数:
reader- Sentence reader to be used as data sourceids- Types of sentences to capture for creating provider events
-
-
方法详细资料
-
addListener
Inserts a listener to provider.- 参数:
listener- Listener to add
-
createProviderEvent
Creates aProviderEventof typeT.- 返回:
- Created event, or null if failed.
-
getSentences
Returns the collected sentences.- 返回:
- List of sentences.
-
hasAll
Tells if the provider has captured all the specified sentences.- 参数:
id- Sentence type IDs to look for.- 返回:
- True if all specified IDs match the captured sentences.
-
hasOne
Tells if the provider has captured at least one of the specified sentences.- 参数:
id- Sentence type IDs to look for, in prioritized order.- 返回:
- True if any of the specified IDs matches the type of at least one captured sentences.
-
isReady
protected abstract boolean isReady()Tells if provider has captured the required sentences for creating new ProviderEvent.- 返回:
- true if ready to create ProviderEvent, otherwise false.
-
isValid
protected abstract boolean isValid()Tells if the captured sentence events contain valid data to be dispatched to ProviderListeners.- 返回:
- true if valid, otherwise false.
-
readingPaused
public void readingPaused()从接口复制的说明:SentenceListenerCalled after
SentenceReaderhas timed out for receiving new data. Indicates that the reader is still active and waiting for new data which isn't currently available for some reason. For example, the device may have stopped broadcasting or the end of a file has been reached.Default time for timeout is defined by
SentenceReader.DEFAULT_TIMEOUT. This value can be overridden withSentenceReader.setPauseTimeout(int).- 指定者:
readingPaused在接口中SentenceListener
-
readingStarted
public void readingStarted()从接口复制的说明:SentenceListenerCalled beforeSentenceReaderstarts dispatching events. Indicates that the reader is active and receiving data. Also, this notification occurs when the dispatching continues again afterSentenceListener.readingPaused()has occurred.- 指定者:
readingStarted在接口中SentenceListener
-
readingStopped
public void readingStopped()从接口复制的说明:SentenceListenerCalled afterSentenceReaderhas permanently stopped reading, either due to an error or by calling theSentenceReader.stop()method.- 指定者:
readingStopped在接口中SentenceListener
-
removeListener
Removes the specified listener from provider.- 参数:
listener- Listener to remove
-
sentenceRead
从接口复制的说明:SentenceListenerCalled bySentenceReaderwhen a single NMEA 0183 sentence has been read and parsed from the data stream. By default, only supported sentences defined inSentenceIdare dispatched.- 指定者:
sentenceRead在接口中SentenceListener- 参数:
event- SentenceEvent containing the data.
-
setTimeout
public void setTimeout(int millis) Sets the timeout for receiving a burst of sentences. The default value is 1000 ms as per default update rate of NMEA 0183 (1/s). However, the length of data bursts may vary depending on the device. If the timeout is exceeded before receiving all needed sentences, the sentences are discarded and waiting period for next burst of data is started. Use this method to increase the timeout if the bursts are constantly being discarded and thus no events are dispatched by the provider.
- 参数:
millis- Timeout to set, in milliseconds.- 另请参阅:
-