use of com.serotonin.m2m2.view.text.ConvertingRenderer in project ma-core-public by infiniteautomation.
the class BaseDwr method setPointImpl.
protected void setPointImpl(DataPointVO point, String valueStr, SetPointSource source) {
if (point == null)
return;
if (valueStr == null)
Common.runtimeManager.relinquish(point.getId());
else {
// Convert the string value into an object.
DataValue value = DataValue.stringToValue(valueStr, point.getPointLocator().getDataTypeId());
// do reverse conversion of renderer
TextRenderer tr = point.getTextRenderer();
if (point.getPointLocator().getDataTypeId() == DataTypes.NUMERIC && tr instanceof ConvertingRenderer) {
ConvertingRenderer cr = (ConvertingRenderer) tr;
UnitConverter converter = cr.getRenderedUnit().getConverterTo(cr.getUnit());
double convertedValue = converter.convert(value.getDoubleValue());
value = new NumericValue(convertedValue);
}
Common.runtimeManager.setDataPointValue(point.getId(), value, source);
}
}
use of com.serotonin.m2m2.view.text.ConvertingRenderer in project ma-core-public by infiniteautomation.
the class DataPointVO method setUnitsOnTextRenderer.
private void setUnitsOnTextRenderer() {
if (textRenderer instanceof ConvertingRenderer) {
ConvertingRenderer cr = (ConvertingRenderer) textRenderer;
cr.setUnit(unit);
if (useRenderedUnit) {
cr.setRenderedUnit(renderedUnit);
} else {
cr.setRenderedUnit(unit);
}
}
}
Aggregations