public String makeHardwareBody() { if (isNotValid() || value == null) { return null; } return pwmMode ? makeHardwareBody(PinType.ANALOG, pin, value) : makeHardwareBody(pinType, pin, value); }
@Override public void append(StringBuilder sb, int deviceId) { if (this.deviceId == deviceId) { append(sb, pin, pinType); } }
@Override public void erase() { super.erase(); this.startValue = null; this.stopValue = null; this.startTime = -1; this.stopTime = -1; }
@Override public void sendAppSync(Channel appChannel, int dashId, int targetId, boolean useNewSyncFormat) { //do not send SYNC message for widgets assigned to device selector //as it will be duplicated later. if (isAssignedToDeviceSelector()) { return; } if (targetId == ANY_TARGET || this.deviceId == targetId) { String hardBody = makeHardwareBody(); if (hardBody != null) { String body = prependDashIdAndDeviceId(dashId, this.deviceId, hardBody); appChannel.write(makeUTF8StringMessage(APP_SYNC, SYNC_DEFAULT_MESSAGE_ID, body)); } } }
public static String makeHardwareBody(PinType pinType, short pin, String value) { return makeHardwareBody(pinType.pintTypeChar, pin, value); }
@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 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); } } }
private void cleanPinStorage(DashBoard dash, OnePinWidget onePinWidget, int targetId, boolean removeProperties) { if (onePinWidget.isValid()) { removePinStorageValue(dash, targetId == -1 ? onePinWidget.deviceId : targetId, onePinWidget.pinType, onePinWidget.pin, removeProperties); } }
OnePinWidget onePinWidget = (OnePinWidget) widget; if (onePinWidget.isAssignedToDeviceSelector() && key.isSame(id, onePinWidget)) { DeviceSelector deviceSelector = getDeviceSelector(onePinWidget.deviceId); if (deviceSelector != null && ArrayUtil.contains(deviceSelector.deviceIds, key.deviceId)) {
@Override public void sendHardSync(ChannelHandlerContext ctx, int msgId, int deviceId) { if (this.deviceId == deviceId) { String body = makeHardwareBody(); if (body != null) { ctx.write(makeUTF8StringMessage(HARDWARE, msgId, body), ctx.voidPromise()); } } }
@Override public boolean setProperty(WidgetProperty property, String propertyValue) { switch (property) { case URL : this.url = propertyValue; return true; default: return super.setProperty(property, propertyValue); } }
public boolean isSameWebHook(int deviceId, short pin, PinType type) { return super.isSame(deviceId, pin, type); }
@Override public boolean updateIfSame(int deviceId, short pin, PinType type, String value) { if (super.updateIfSame(deviceId, pin, type, value)) { String[] values = value.split(BODY_SEPARATOR_STRING); if (values.length > 2) { startAt = calcTime(values[0]); stopAt = calcTime(values[1]); tzName = StringToZoneId.parseZoneId(values[2]); if (values.length == 3 || values[3].isEmpty()) { days = null; } else { String[] daysString = values[3].split(","); days = new int[daysString.length]; for (int i = 0; i < daysString.length; i++) { days[i] = Integer.parseInt(daysString[i]); } } } return true; } return false; }
private static String makeBody(DashBoard dash, int deviceId, short pin, PinType pinType, String pinValue) { Widget widget = dash.findWidgetByPin(deviceId, pin, pinType); if (widget instanceof OnePinWidget) { return ((OnePinWidget) widget).makeHardwareBody(); } else if (widget instanceof MultiPinWidget) { return ((MultiPinWidget) widget).makeHardwareBody(pin, pinType); } return DataStream.makeHardwareBody(pinType, pin, pinValue); }
@Override public boolean setProperty(WidgetProperty property, String propertyValue) { switch (property) { case ON_LABEL : this.onLabel = propertyValue; return true; case OFF_LABEL : this.offLabel = propertyValue; return true; default: return super.setProperty(property, propertyValue); } } }
@Override public void erase() { super.erase(); rows.clear(); } }
@Override public boolean setProperty(WidgetProperty property, String propertyValue) { switch (property) { case IS_ON_PLAY : this.isOnPlay = Boolean.parseBoolean(propertyValue); return true; default: return super.setProperty(property, propertyValue); } } }
@Override public boolean setProperty(WidgetProperty property, String propertyValue) { switch (property) { case STEP : this.step = Float.parseFloat(propertyValue); return true; default: return super.setProperty(property, propertyValue); } } }
@Override public boolean setProperty(WidgetProperty property, String propertyValue) { switch (property) { case FRACTION : this.maximumFractionDigits = Integer.parseInt(propertyValue); return true; default: return super.setProperty(property, propertyValue); } } }