Logging only when conditions are satisfied

Can you point out what part of my code is wrong to enable "logging only when specific acceleration conditions are satisfied"?
I want X samples of acceleration (eg, 10) to be logged every time a peak is detected.

    acc.acceleration().addRouteAsync(new RouteBuilder () {
        @Override
        public void configure(RouteComponent source) {
            source.multicast()
                .to().limit(Passthrough.COUNT, (short) 0).name("acchistory")
                    .log(new Subscriber () {
                        @Override
                        public void apply(Data data, Object... env) {
                            // do I need stuff here to log data?
                        }
                    });
                .to().map(Function1.RMS)
                    .find(PulseOutput.PEAK, <some_threshold>, <some_peak_count>)
                    .react(token -> {
                        dataprocessor.edit("acchistory", PassthroughEditor.class).set((short)10)
                    });
        }
    }

I looked through the following old forum post but could not make it work

  1. https://mbientlab.com/community/discussion/comment/6177#Comment_6177
  2. https://mbientlab.com/community/discussion/comment/11548#Comment_11548
Sign In or Register to comment.