preparing contacts in blocks
This commit is contained in:
@@ -111,6 +111,7 @@ Height : Höhe
|
||||
Help : Hilfe
|
||||
(id\: {}, length\: {}) : (Id: {}, Länge: {})
|
||||
if ({})\: : falls ({}):
|
||||
internal contacts : interne Kontakte
|
||||
inverted : invertiert
|
||||
Inverts the direction {} is heading to. : Kehrt die Richtung, in welche {} fährt, um.
|
||||
{} is oriented {} : {} ist {} gerichtet
|
||||
@@ -137,6 +138,7 @@ Minimum and maximum times (in Miliseconds) trains with the respective tag have t
|
||||
Move tiles : Kacheln verschieben
|
||||
name\: : Name:
|
||||
new car : neuer Waggon
|
||||
new contact : neuer Kontakt
|
||||
new locomotive : neue Lok
|
||||
new tag : neue Markierung
|
||||
new train : neuer Zug
|
||||
|
||||
@@ -163,6 +163,9 @@ public class Plan extends BaseClass{
|
||||
switch (params.get(ACTION)) {
|
||||
case ACTION_ADD:
|
||||
return addTile(params.get(TILE),params.get(X),params.get(Y),null);
|
||||
case Block.ACTION_ADD_CONTACT:
|
||||
Block block = get(Id.from(params));
|
||||
return block.addContact();
|
||||
case ACTION_ANALYZE:
|
||||
return analyze();
|
||||
case ACTION_AUTO:
|
||||
@@ -702,6 +705,7 @@ public class Plan extends BaseClass{
|
||||
contact.addr(0);
|
||||
LOG.debug("unsibscribed {} from {}",contact,addr);
|
||||
}
|
||||
|
||||
stream(learningContact.addr(addr).properties().toString());
|
||||
LOG.debug("learned: {} = {}",addr,learningContact);
|
||||
learningContact = null;
|
||||
|
||||
@@ -38,9 +38,11 @@ public abstract class Block extends StretchableTile{
|
||||
public static final String TAG = "tag";
|
||||
private static final String WAIT_TIMES = "wait_times";
|
||||
private static final String RAISE = "raise";
|
||||
public static final String ACTION_ADD_CONTACT = "add_contact";
|
||||
|
||||
public String name = "Block";
|
||||
public boolean turnAllowed = false;
|
||||
private Vector<BlockContact> internalContacts = new Vector<BlockContact>();
|
||||
|
||||
public Block() {
|
||||
super();
|
||||
@@ -120,6 +122,12 @@ public abstract class Block extends StretchableTile{
|
||||
|
||||
|
||||
private Vector<WaitTime> waitTimes = new Vector<WaitTime>();
|
||||
|
||||
public Object addContact() {
|
||||
BlockContact contact = new BlockContact(this);
|
||||
plan.learn(contact);
|
||||
return t("Trigger contact to learn new contact");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object click() throws IOException {
|
||||
@@ -138,6 +146,19 @@ public abstract class Block extends StretchableTile{
|
||||
return config;
|
||||
}
|
||||
|
||||
private Fieldset contactForm() {
|
||||
Fieldset fieldset = new Fieldset("internal contacts");
|
||||
this.button("new contact", Map.of(ACTION,ACTION_ADD_CONTACT)).addTo(fieldset);
|
||||
if (!internalContacts.isEmpty()) {
|
||||
Tag ul = new Tag("ul");
|
||||
for (BlockContact contact : internalContacts) {
|
||||
new Tag("li").content(contact.toString()).addTo(ul);
|
||||
}
|
||||
ul.addTo(fieldset);
|
||||
}
|
||||
return fieldset;
|
||||
}
|
||||
|
||||
public abstract Direction directionA();
|
||||
public abstract Direction directionB();
|
||||
|
||||
@@ -217,7 +238,8 @@ public abstract class Block extends StretchableTile{
|
||||
formInputs.add(t("Name"),new Input(NAME, name));
|
||||
formInputs.add("",new Checkbox(ALLOW_TURN,t("Turn allowed"),turnAllowed));
|
||||
formInputs.add(t("Train"),Train.selector(train, null));
|
||||
postForm.add(waitTimeForm());
|
||||
postForm.add(contactForm());
|
||||
postForm.add(waitTimeForm());
|
||||
return super.properties(preForm, formInputs, postForm);
|
||||
}
|
||||
|
||||
@@ -232,6 +254,11 @@ public abstract class Block extends StretchableTile{
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public BlockContact register(BlockContact contact) {
|
||||
internalContacts.add(contact);
|
||||
return contact;
|
||||
}
|
||||
|
||||
public static Select selector(Block preselected,Collection<Block> exclude) {
|
||||
if (isNull(exclude)) exclude = new Vector<Block>();
|
||||
@@ -397,5 +424,4 @@ public abstract class Block extends StretchableTile{
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
33
src/main/java/de/srsoftware/web4rail/tiles/BlockContact.java
Normal file
33
src/main/java/de/srsoftware/web4rail/tiles/BlockContact.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package de.srsoftware.web4rail.tiles;
|
||||
|
||||
import de.srsoftware.web4rail.Window;
|
||||
|
||||
public class BlockContact extends Contact {
|
||||
|
||||
public BlockContact(Block parent) {
|
||||
parent(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Contact addr(int address) {
|
||||
super.addr(address);
|
||||
Block block = (Block) parent();
|
||||
return block.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Id id() {
|
||||
if (id == null) id = new Id();
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Window properties() {
|
||||
return parent().properties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName()+"("+addr+")";
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public class Contact extends Tile{
|
||||
private static final HashMap<Integer, Contact> contactsByAddr = new HashMap<Integer, Contact>();
|
||||
private boolean state = false;
|
||||
private String trigger = null;
|
||||
private int addr = 0;
|
||||
protected int addr = 0;
|
||||
private ActionList actions;
|
||||
private OffTimer timer = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user