Skip to content

Commit

Permalink
- Rename switch and variable
Browse files Browse the repository at this point in the history
- Add temporary comment
  • Loading branch information
Abyss777 committed May 31, 2018
1 parent 3d14b65 commit 786f101
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
3 changes: 1 addition & 2 deletions setup/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
<entry key='filter.enable'>true</entry>
<entry key='filter.future'>3600</entry>

<entry key='engineHours.enable'>true</entry>

<entry key='event.enable'>true</entry>
<entry key='event.ignoreDuplicateAlerts'>true</entry>
<entry key='processing.computedAttributes.enable'>true</entry>
<entry key='processing.engineHours.enable'>true</entry>

<entry key='media.path'>./media</entry>

Expand Down
2 changes: 1 addition & 1 deletion src/org/traccar/BasePipelineFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public BasePipelineFactory(TrackerServer server, String protocol) {

motionHandler = new MotionHandler(Context.getTripsConfig().getSpeedThreshold());

if (Context.getConfig().getBoolean("engineHours.enable")) {
if (Context.getConfig().getBoolean("processing.engineHours.enable")) {
engineHoursHandler = new EngineHoursHandler();
}

Expand Down
3 changes: 2 additions & 1 deletion src/org/traccar/reports/ReportUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ private static StopReport calculateStop(
if (startStop.getAttributes().containsKey(Position.KEY_HOURS)
&& endStop.getAttributes().containsKey(Position.KEY_HOURS)) {
engineHours = endStop.getLong(Position.KEY_HOURS) - startStop.getLong(Position.KEY_HOURS);
} else if (Context.getConfig().getBoolean("engineHours.enable")) {
} else if (Context.getConfig().getBoolean("processing.engineHours.enable")) {
// Temporary fallback for old data, to be removed in May 2019
for (int i = startIndex + 1; i <= endIndex; i++) {
if (positions.get(i).getBoolean(Position.KEY_IGNITION)
&& positions.get(i - 1).getBoolean(Position.KEY_IGNITION)) {
Expand Down
7 changes: 4 additions & 3 deletions src/org/traccar/reports/Summary.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ private static SummaryReport calculateSummaryResult(long deviceId, Date from, Da
Position firstPosition = null;
Position previousPosition = null;
double speedSum = 0;
boolean needCalculateEngineHours = Context.getConfig().getBoolean("engineHours.enable");
boolean engineHoursEnabled = Context.getConfig().getBoolean("processing.engineHours.enable");
for (Position position : positions) {
if (firstPosition == null) {
firstPosition = position;
}
if (needCalculateEngineHours && previousPosition != null
if (engineHoursEnabled && previousPosition != null
&& position.getBoolean(Position.KEY_IGNITION)
&& previousPosition.getBoolean(Position.KEY_IGNITION)) {
// Temporary fallback for old data, to be removed in May 2019
result.addEngineHours(position.getFixTime().getTime()
- previousPosition.getFixTime().getTime());
}
Expand All @@ -65,7 +66,7 @@ private static SummaryReport calculateSummaryResult(long deviceId, Date from, Da
result.setAverageSpeed(speedSum / positions.size());
result.setSpentFuel(ReportUtils.calculateFuel(firstPosition, previousPosition));

if (needCalculateEngineHours
if (engineHoursEnabled
&& firstPosition.getAttributes().containsKey(Position.KEY_HOURS)
&& previousPosition.getAttributes().containsKey(Position.KEY_HOURS)) {
result.setEngineHours(
Expand Down

0 comments on commit 786f101

Please sign in to comment.