did you get an solution?
Yes, I got it.
The problem was at the order of handlers
The wrong old order is:
addHandlers(
pipeline,
FilterHandler.class,
GeocoderHandler.class,
SpeedLimitHandler.class,
MotionHandler.class,
CopyAttributesHandler.class,
EngineHoursHandler.class,
ComputedAttributesHandler.class,
WebDataHandler.class,
DefaultDataHandler.class,
StopingTimeHandler.class,
IdleHandler.class);
correct order is:
addHandlers(
pipeline,
FilterHandler.class,
GeocoderHandler.class,
SpeedLimitHandler.class,
MotionHandler.class,
CopyAttributesHandler.class,
EngineHoursHandler.class,
StopingTimeHandler.class,
IdleHandler.class,
ComputedAttributesHandler.class,
WebDataHandler.class,
DefaultDataHandler.class);
Hi Anton,
I try to add new attribute "stopingTime" to the position record as you did in "EngineHours".
as the flowing code:
//in the position class I added: public static final String KEY_STOPING_TIME = "stopingTime";
//I added new handler: package org.traccar.handler; import io.netty.channel.ChannelHandler; import org.traccar.BaseDataHandler; import org.traccar.database.IdentityManager; import org.traccar.model.Position; @ChannelHandler.Sharable public class StopingTimeHandler extends BaseDataHandler { private final IdentityManager identityManager; public StopingTimeHandler(IdentityManager identityManager) { this.identityManager = identityManager; } @Override protected Position handlePosition(Position position) { if (!position.getAttributes().containsKey(Position.KEY_STOPING_TIME)) { Position last = identityManager.getLastPosition(position.getDeviceId()); if (last != null) { long stopingTime = last.getLong(Position.KEY_STOPING_TIME); if (last.getBoolean(Position.KEY_IGNITION) && position.getBoolean(Position.KEY_IGNITION)) { if(!last.getBoolean(Position.KEY_MOTION) && !position.getBoolean(Position.KEY_MOTION)) stopingTime += position.getFixTime().getTime() - last.getFixTime().getTime(); } else stopingTime = 0; position.set(Position.KEY_STOPING_TIME, stopingTime); } } return position; } }
in debug mode it come into the handler and set the attribute value but doesn't find in the database!!!
I didn't find the problem, can you help please?