Retrieve Internal State Counter/Buffer value
I am working with the Android Java API 3.8.1 and would like to know how to retrieve a Forced Data Producer value (https://mbientlab.com/androiddocs/latest/data_processor.html?highlight=count#internal-state). I am working with the Counter in the Accelerometer sensor for the MMS device.
The counter producer is created with:
accelerometer.acceleration().addRouteAsync(new RouteBuilder() {
@Override
public void configure(RouteComponent source) {
source.log(new Subscriber() {
@Override
public void apply(Data data, Object... env) {
Acceleration value = data.value(Acceleration.class);
}
}).count().name("**accelerometerRouteCounter**");
}
}).continueWith(new Continuation<Route, Void>() {
@Override
public Void then(Task<Route> task) throws Exception {
accelerometer.acceleration().start();
accelerometer.start();
return null;
}
});
And later retrieved with:
ForcedDataProducer producer = dataproc.state("**accelerometerRouteCounter**");
if(producer != null) {
producer.addRouteAsync(new RouteBuilder() {
@Override
public void configure(RouteComponent source) {
Log.i("MainActivity", "This is called correctly");
source.react(new RouteComponent.Action() {
@Override
public void execute(DataToken token) {
Log.i("MainActivity ", token.toString());
Log.i("MainActivity ","How to retrieve int value??");
}
});
}
}).continueWith(new Continuation<Route, Object>() {
@Override
public Object then(Task<Route> task) throws Exception {
producer.read();
return null;
}
});
}
The "ForcedDataProducer producer" object with name "accelerometerRouteCounter" is found in dataproc.state call, but I don't know how to retrieve its value. Didn’t found it on the documentation.
Could anybody advise us about this issue?
Thank you so much in advance.