use of net.sf.mbus4j.dataframes.datablocks.LongDataBlock in project ma-modules-public by infiniteautomation.
the class MBusDataSourceRT method setValue.
protected boolean setValue(DataBlock db, boolean pointError, long time, DataPointRT point, final MBusPointLocatorRT locatorRT, final MBusPointLocatorVO locatorVo) {
try {
if ((db instanceof BcdValue) && ((BcdValue) db).isBcdError()) {
pointError = true;
LOG.fatal("BCD Error : " + ((BcdValue) db).getBcdError());
raiseEvent(POINT_READ_EXCEPTION_EVENT, time, true, new TranslatableMessage("event.exception2", point.getVO().getExtendedName(), "BCD error value: " + ((BcdValue) db).getBcdError()));
pointError = true;
} else if (db instanceof ByteDataBlock) {
point.updatePointValue(new PointValueTime(locatorRT.calcCorrectedValue(((ByteDataBlock) db).getValue(), db.getCorrectionExponent(locatorVo.effectiveSiPrefix()), db.getCorrectionConstant()), time));
} else if (db instanceof ShortDataBlock) {
point.updatePointValue(new PointValueTime(locatorRT.calcCorrectedValue(((ShortDataBlock) db).getValue(), db.getCorrectionExponent(locatorVo.effectiveSiPrefix()), db.getCorrectionConstant()), time));
} else if (db instanceof IntegerDataBlock) {
point.updatePointValue(new PointValueTime(locatorRT.calcCorrectedValue(((IntegerDataBlock) db).getValue(), db.getCorrectionExponent(locatorVo.effectiveSiPrefix()), db.getCorrectionConstant()), time));
} else if (db instanceof LongDataBlock) {
point.updatePointValue(new PointValueTime(locatorRT.calcCorrectedValue(((LongDataBlock) db).getValue(), db.getCorrectionExponent(locatorVo.effectiveSiPrefix()), db.getCorrectionConstant()), time));
} else if (db instanceof RealDataBlock) {
point.updatePointValue(new PointValueTime(locatorRT.calcCorrectedValue(((RealDataBlock) db).getValue(), db.getCorrectionExponent(locatorVo.effectiveSiPrefix()), db.getCorrectionConstant()), time));
} else if (db instanceof BigDecimalDataBlock) {
point.updatePointValue(new PointValueTime(locatorRT.calcCorrectedValue(((BigDecimalDataBlock) db).getValue().doubleValue(), db.getCorrectionExponent(locatorVo.effectiveSiPrefix()), db.getCorrectionConstant()), time));
} else if (db instanceof StringDataBlock) {
point.updatePointValue(new PointValueTime(((StringDataBlock) db).getValue(), time));
} else {
LOG.fatal("Dont know how to save: " + point.getVO().getExtendedName());
raiseEvent(POINT_READ_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("event.exception2", point.getVO().getExtendedName(), "Dont know how to save"));
pointError = true;
}
} catch (Exception ex) {
LOG.fatal("Error during saving: " + vo.getName(), ex);
raiseEvent(POINT_READ_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("event.exception2", point.getVO().getExtendedName(), "Ex: " + ex));
pointError = true;
}
return pointError;
}
Aggregations