public interface OnlineCalculatable
Modifier and Type | Interface and Description |
---|---|
static class |
OnlineCalculatable.Marker
If passed as value it will cause marker to be drawn at that place (currently works only for
Layer1ApiUserMessageModifyIndicator.GraphType.PRIMARY ). |
static class |
OnlineCalculatable.ValueBundle |
Modifier and Type | Method and Description |
---|---|
default boolean |
allowPartialUpdates(java.lang.String indicatorName,
java.lang.String alias) |
void |
calculateValuesInRange(java.lang.String indicatorName,
java.lang.String indicatorAlias,
long t0,
long intervalWidth,
int intervalsNumber,
CalculatedResultListener listener)
1st request type:
Should calculate left to right values in given time points
t0; t0 + intervalWidth; t0 + 2 * intervalWidth ...
|
OnlineValueCalculatorAdapter |
createOnlineValueCalculator(java.lang.String indicatorName,
java.lang.String indicatorAlias,
long time,
java.util.function.Consumer<java.lang.Object> listener,
InvalidateInterface invalidateInterface)
2nd request type:
|
default boolean |
shouldRepeatCalculateValuesInRange(java.lang.String indicatorName,
java.lang.String indicatorAlias,
long intervalWidth,
long timePassed)
Experimental!
|
void calculateValuesInRange(java.lang.String indicatorName, java.lang.String indicatorAlias, long t0, long intervalWidth, int intervalsNumber, CalculatedResultListener listener)
indicatorName
- name of indicatorindicatorAlias
- alias of this indicatort0
- time of 1st value (in ns)intervalWidth
- width of one calculated interval (in ns)intervalsNumber
- number of values to calculate, >= 0listener
- OnlineValueCalculatorAdapter createOnlineValueCalculator(java.lang.String indicatorName, java.lang.String indicatorAlias, long time, java.util.function.Consumer<java.lang.Object> listener, InvalidateInterface invalidateInterface)
indicatorName
- name of indicatorindicatorAlias
- alias of this indicatortime
- starting with this time values are computed onlinelistener
- can be used in following ways:
CalculatedResultListener.provideResponse(Object)
for supported object types
IndicatorFullValues
to fully update historical values of your indicatorinvalidateInterface
- can be used to invalidate indicatordefault boolean shouldRepeatCalculateValuesInRange(java.lang.String indicatorName, java.lang.String indicatorAlias, long intervalWidth, long timePassed)
By default Bookmap will repeat
calculateValuesInRange(String, String, long, long, int, CalculatedResultListener)
request if by the time response is handled more than one intervalWidth
passed. However sometimes (if calculateValuesInRange is relatively slow
and/or user is zoomed in closely, so chart moves fast) it can be repeated too
many times (or even continiously, as long as chart moves). While it can be
acceptable in some cases, you can improve the performance by telling bookmap
to switch to OnlineValueCalculatorAdapter
earlier.
You should always return false when default implementation does that. However you can also return false when you believe there are not too many intervals and not too much time passed. It's strongly recommended to always return true if both more than 5 seconds and more than 3 intervals passed, since Bookmap will drop data from relevant caches when both conditions are no longer true. Ignoring that will result in not getting some of the updates in online calculator (which might be acceptable for some indicators, in which case it's ok). It's also important that this method doesn't block for too long.
indicatorName
- name of indicatorindicatorAlias
- alias of this indicatorintervalWidth
- width of one calculated interval (in ns).timePassed
- time passed since the end of
calculateValuesInRange(String, String, long, long, int, CalculatedResultListener)
rangeOnlineValueCalculatorAdapter
, true to use
calculateValuesInRange(String, String, long, long, int, CalculatedResultListener)
again.default boolean allowPartialUpdates(java.lang.String indicatorName, java.lang.String alias)
indicatorName
- name of indicatoralias
- alias of this indicator
Override you want your indicator to receive only full chart range requests (i.e. you don't want to receive 0-1000 pixels request, and then 1000-1020 request to catch up with chart)