historicStringArray = AttributeHelper.extractToStringArray(historicAttribute);
}
catch (DevFailed e) {
invalidateScanServerProxy(scanServerName);
e.printStackTrace();
throw new SalsaDeviceException("Error : cannot read the historic : " + e.getMessage(),
e);
}
// The historic attribute on the scan server is an array of strings that contains the scan
// historic.
// Each record is made of 5 string in the array.
// - the first one is the period,
// - the second one is the type,
// - the third one is the message,
// - we do not use the last two.
// So we are going to parse the attribute per set of 5 to build a list of HistoricRecord.
int recordsNumber = historicStringArray.length / 5;
int stopIndex = 5 * recordsNumber; // This has the advantage over historicStringArray.length
// that we have a guaranteed multiple of 5.
String periodAsString;
Double period;
String type;
String message;
HistoricRecord record;
List<HistoricRecord> recordsList = new ArrayList<HistoricRecord>();
for (int index = 0; index < stopIndex; index += 5) {
periodAsString = historicStringArray[index];
type = historicStringArray[index + 1];
message = historicStringArray[index + 2];
try {
period = periodFormat.parse(periodAsString).doubleValue();
}
catch (ParseException e) {
e.printStackTrace();
throw new SalsaDeviceException("Error : cannot parse period \"" + periodAsString
+ "\" when reading the historic : " + e.getMessage(), e);
}
record = new HistoricRecord();
record.setPeriod(period);
record.setType(type);