}
int stanox = Integer.parseInt(body.getLocStanox());
trainInstance.setLastStanox(time, stanox);
List<TimepointElement> timepoints = trainInstance.getTimepointForStanox(stanox);
TimepointElement timepoint = null;
if (!timepoints.isEmpty()) {
_statisticsService.incrementUnknownStanoxCount();
timepoint = getBestTimepointForTrainMovement(timepoints, body);
}
if (body.getActualTimestamp() != null
&& !body.getActualTimestamp().isEmpty()
&& body.getPlannedTimestamp() != null
&& !body.getPlannedTimestamp().isEmpty()) {
long actualTimestamp = Long.parseLong(body.getActualTimestamp());
long plannedTimestamp = Long.parseLong(body.getPlannedTimestamp());
int scheduleDeviation = (int) ((actualTimestamp - plannedTimestamp) / 1000);
trainInstance.setScheduleDeviation(scheduleDeviation);
} else if (timepoint != null) {
long expectedTime = getTimeForTimepoint(trainInstance, timepoint);
int scheduleDeviation = (int) ((time - expectedTime) / 1000);
trainInstance.setScheduleDeviation(scheduleDeviation);
}
if (body.getPlatform() != null && timepoint != null) {
String platform = body.getPlatform().trim();
if (!platform.isEmpty() && !platform.equals(timepoint.getPlatform())) {
_statisticsService.incrementPlatformChange();
}
}
}