public void eraseWidgetValuesForDevice(int deviceId) { for (Widget widget : widgets) { if (widget.isAssignedToDevice(deviceId)) { widget.erase(); } if (widget instanceof DeviceCleaner) { ((DeviceCleaner) widget).deleteDevice(deviceId); } } }
public Widget findWidgetByPin(int deviceId, short pin, PinType pinType) { for (Widget widget : widgets) { if (widget.isSame(deviceId, pin, pinType)) { return widget; } } return null; }
public void erase() { if (dataStream != null) { dataStream.value = null; } this.deviceIds = EMPTY_INTS; for (Widget widget : widgets) { widget.erase(); } }
public Widget updateProperty(int deviceId, short pin, WidgetProperty widgetProperty, String propertyValue) { Widget widget = null; for (Widget dashWidget : widgets) { if (dashWidget.isSame(deviceId, pin, PinType.VIRTUAL)) { if (dashWidget.setProperty(widgetProperty, propertyValue)) { widget = dashWidget; } } } return widget; }
public String makeHardwareBody() { if (isNotValid() || value == null) { return null; } return pwmMode ? makeHardwareBody(PinType.ANALOG, pin, value) : makeHardwareBody(pinType, pin, value); }
public int getPrice() { int sum = 0; for (Widget widget : widgets) { sum += widget.getPrice(); } return sum; }
@Override public boolean setProperty(WidgetProperty property, String propertyValue) { switch (property) { case SUFFIX : this.suffix = propertyValue; return true; default: return super.setProperty(property, propertyValue); } }
@Override public boolean updateIfSame(int deviceId, short pin, PinType type, String value) { if (isSame(deviceId, pin, type)) { this.value = value; return true; } return false; }
@Override public boolean isTicked(long now) { if (hasReadingInterval() && now >= lastRequestTS + frequency) { this.lastRequestTS = now; return true; } return false; }
@Override public void append(StringBuilder sb, int deviceId) { if (this.deviceId == deviceId) { append(sb, pin, pinType); } }
public boolean updateWidgets(int deviceId, short pin, PinType type, String value) { boolean hasWidget = false; for (Widget widget : widgets) { if (widget.updateIfSame(deviceId, pin, type, value)) { hasWidget = true; } } return hasWidget; }
public boolean hasWidgetsByDeviceId(int deviceId) { for (Widget widget : widgets) { if (widget.isAssignedToDevice(deviceId)) { return true; } } return false; }
@Override public void updateValue(Widget oldWidget) { if (oldWidget instanceof OnePinWidget) { OnePinWidget onePinWidget = (OnePinWidget) oldWidget; if (onePinWidget.value != null) { updateIfSame(onePinWidget.deviceId, onePinWidget.pin, onePinWidget.pinType, onePinWidget.value); } } }
@Override public boolean setProperty(WidgetProperty property, String propertyValue) { switch (property) { case VALUE_FORMATTING : this.valueFormatting = propertyValue; return true; default: return super.setProperty(property, propertyValue); } }
@Override public void updateValue(Widget oldWidget) { if (oldWidget instanceof MultiPinWidget) { MultiPinWidget multiPinWidget = (MultiPinWidget) oldWidget; if (multiPinWidget.dataStreams != null) { for (DataStream dataStream : multiPinWidget.dataStreams) { updateIfSame(multiPinWidget.deviceId, dataStream.pin, dataStream.pinType, dataStream.value); } } } }
@Override public void erase() { super.erase(); this.startValue = null; this.stopValue = null; this.startTime = -1; this.stopTime = -1; }
@Override public void append(StringBuilder sb, int deviceId) { if (dataStreams != null && this.deviceId == deviceId) { for (DataStream dataStream : dataStreams) { append(sb, dataStream.pin, dataStream.pinType); } } }
public int energySum() { //means this is app preview project so do no manipulation with energy if (parentId != IS_PARENT_DASH) { return 0; } int sum = 0; for (Widget widget : widgets) { sum += widget.getPrice(); } return sum; }
public void eraseWidgetValues() { for (Widget widget : widgets) { widget.erase(); } }
@Override public boolean setProperty(WidgetProperty property, String propertyValue) { switch (property) { case URL : this.url = propertyValue; return true; default: return super.setProperty(property, propertyValue); } }