This commit is contained in:
Stephan Richter
2020-12-11 02:10:16 +01:00
parent 9810b453cb
commit 604b9559c4
4 changed files with 21 additions and 7 deletions

View File

@@ -40,7 +40,18 @@ public class SetRelay extends Action {
@Override
public Action load(JSONObject json) {
super.load(json);
if (json.has(RELAY)) relay = BaseClass.get(new Id(json.getString(RELAY)));
if (json.has(RELAY)) {
String relayId = json.getString(RELAY);
relay = BaseClass.get(new Id(relayId));
if (isNull(relay)) new Thread() { // if relay not loaded, yet: wait one sec and try again
public void run() {
try {
sleep(1000);
} catch (InterruptedException e) {}
relay = BaseClass.get(new Id(relayId));
};
}.start();
}
if (json.has(Relay.STATE)) state = json.getBoolean(Relay.STATE);
return this;
}

View File

@@ -137,10 +137,10 @@ public class Relay extends Tile implements Device{
}
formInputs.add(t("Decoder address"),div);
formInputs.add(t("Address"),new Input(ADDRESS, address).numeric());
formInputs.add(t("Port for state A"),new Input(PORT_A, portA).numeric());
formInputs.add(t("Label for state A"),new Input(LABEL_A, stateLabelA));
formInputs.add(t("Port for state B"),new Input(PORT_B, portB).numeric());
formInputs.add(t("Label for state B"),new Input(LABEL_B, stateLabelB));
formInputs.add(t("Label for state {}","A"),new Input(LABEL_A, stateLabelA));
formInputs.add(t("Label for state {}","B"),new Input(LABEL_B, stateLabelB));
formInputs.add(t("Port for state {}",stateLabelA),new Input(PORT_A, portA).numeric());
formInputs.add(t("Port for state {}",stateLabelB),new Input(PORT_B, portB).numeric());
return super.properties(preForm, formInputs, postForm);
}