Bugfixes + implemented deleting and update of BlockContacts
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.srsoftware</groupId>
|
||||
<artifactId>web4rail</artifactId>
|
||||
<version>1.2.51</version>
|
||||
<version>1.2.52</version>
|
||||
<name>Web4Rail</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Java Model Railway Control</description>
|
||||
|
||||
@@ -301,6 +301,10 @@ table.brake-times{
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table tr:hover td{
|
||||
background: #cadbdb;
|
||||
}
|
||||
|
||||
table.brake-times tr > *{
|
||||
border-style: solid;
|
||||
border-color: black;
|
||||
@@ -339,7 +343,7 @@ svg.preview circle,
|
||||
svg.preview line,
|
||||
svg.preview polygon,
|
||||
svg.preview rect{
|
||||
fill:peru !important;
|
||||
fill:cyan !important;
|
||||
}
|
||||
|
||||
svg.Block text{
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="de.srsoftware.web4rail" level="DEBUG"/>
|
||||
<logger name="de.srsoftware.web4rail" level="INFO"/>
|
||||
<logger name="de.srsoftware.web4rail.Application" level="INFO"/>
|
||||
<logger name="de.srsoftware.web4rail.Command" level="INFO"/>
|
||||
<logger name="de.srsoftware.web4rail.ControlUnit" level="INFO"/>
|
||||
|
||||
<root level="debug">
|
||||
<root level="info">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
||||
|
||||
@@ -172,6 +172,7 @@ PushPullTrain : Wendezug
|
||||
Push-pull train : Wendezug
|
||||
quit autopilot : Autopilot beenden
|
||||
{} reached it`s destination! : {} ist am Ziel angekommen!
|
||||
Relay : Relais
|
||||
Relays and Turnouts : Relais und Weichen
|
||||
Relay/Turnout : Relais/Weiche
|
||||
Report Issue : Problem melden
|
||||
@@ -212,6 +213,7 @@ SetTurnout : Weiche stellen
|
||||
Setup actions : Vorbereitung-Aktionen
|
||||
ShowText : Text anzeigen
|
||||
Signals : Signale
|
||||
simplify name : Name vereinfachen
|
||||
Simulating movement of {}... : Simuliere Fahrt von {}...
|
||||
Slower (10 {}) : 10 {} langsamer
|
||||
SOUTH : Süden
|
||||
@@ -264,7 +266,9 @@ TrainSelect : Zug-Auswahl
|
||||
TrainSpeed : Zug-Geschwindigkeit
|
||||
Train speed : Zug-Geschwindigkeit
|
||||
Trigger {} : {} betätigen
|
||||
Trigger a feedback sensor to assign it with this contact! : Rückmeldekontakt auslösen, um ihn diesem Kontakt zuzuweisen!
|
||||
TriggerContact : Kontakt auslösen
|
||||
Trigger contact to learn new contact : Kontakt auslösen, um neuen Kontakt zu lernen
|
||||
Turn : Richtung wechseln
|
||||
Turn allowed : Wenden erlaubt
|
||||
{} turned. : {} gewendet.
|
||||
|
||||
@@ -33,6 +33,7 @@ import de.srsoftware.web4rail.tags.Input;
|
||||
import de.srsoftware.web4rail.tags.Label;
|
||||
import de.srsoftware.web4rail.tags.Table;
|
||||
import de.srsoftware.web4rail.tiles.Block;
|
||||
import de.srsoftware.web4rail.tiles.BlockContact;
|
||||
import de.srsoftware.web4rail.tiles.BlockH;
|
||||
import de.srsoftware.web4rail.tiles.BlockV;
|
||||
import de.srsoftware.web4rail.tiles.Bridge;
|
||||
@@ -169,7 +170,7 @@ public class Plan extends BaseClass{
|
||||
case ACTION_ANALYZE:
|
||||
return analyze();
|
||||
case ACTION_AUTO:
|
||||
return simplyfyRouteName(params);
|
||||
return simplifyRouteName(params);
|
||||
case ACTION_CLICK:
|
||||
return click(get(Id.from(params),true));
|
||||
case ACTION_CONNECT:
|
||||
@@ -623,7 +624,7 @@ public class Plan extends BaseClass{
|
||||
table.addHead(t("Name"),t("Start"),t("End"),t("Actions"));
|
||||
List<Route> routes = BaseClass.listElements(Route.class);
|
||||
for (Route route : routes) {
|
||||
table.addRow(route.link("span",route.name()),route.link("span", route.startBlock()),route.link("span", route.endBlock()),plan.button(t("simplyfy name"), Map.of(ACTION,ACTION_AUTO,ROUTE,route.id().toString())));
|
||||
table.addRow(route.link("span",route.name()),route.link("span", route.startBlock()),route.link("span", route.endBlock()),plan.button(t("simplify name"), Map.of(ACTION,ACTION_AUTO,ROUTE,route.id().toString())));
|
||||
}
|
||||
table.clazz("turnouts").addTo(win);
|
||||
|
||||
@@ -688,7 +689,7 @@ public class Plan extends BaseClass{
|
||||
JSONArray jTiles = new JSONArray();
|
||||
BaseClass.listElements(Tile.class)
|
||||
.stream()
|
||||
.filter(tile -> !(tile instanceof Shadow))
|
||||
.filter(tile -> !(tile instanceof Shadow || tile instanceof BlockContact))
|
||||
.map(tile -> tile.json())
|
||||
.forEach(jTiles::put);
|
||||
|
||||
@@ -700,7 +701,7 @@ public class Plan extends BaseClass{
|
||||
|
||||
public void sensor(int addr, boolean active) {
|
||||
Contact contact = Contact.get(addr);
|
||||
if (active && learningContact != null) {
|
||||
if (active && isSet(learningContact)) {
|
||||
if (isSet(contact)) {
|
||||
contact.addr(0);
|
||||
LOG.debug("unsibscribed {} from {}",contact,addr);
|
||||
@@ -714,7 +715,7 @@ public class Plan extends BaseClass{
|
||||
if (isSet(contact)) contact.activate(active);
|
||||
}
|
||||
|
||||
private Object simplyfyRouteName(HashMap<String, String> params) {
|
||||
private Object simplifyRouteName(HashMap<String, String> params) {
|
||||
String routeId = params.get(ROUTE);
|
||||
if (isSet(routeId)) {
|
||||
Route route = BaseClass.get(new Id(routeId));
|
||||
|
||||
@@ -431,7 +431,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
|
||||
new Tag("p").content(t("Click on a name to edit the entry.")).addTo(win);
|
||||
|
||||
Table table = new Table().addHead(t("Name"),t("Length"),t("Max. Speed"),t("Tags"),t("Route"),t("Current location"),t("Destination"),t("Auto pilot"));
|
||||
Table table = new Table().addHead(t("Name"),t("Length"),t("Maximum Speed"),t("Tags"),t("Route"),t("Current location"),t("Destination"),t("Auto pilot"));
|
||||
BaseClass.listElements(Train.class).forEach(train -> {
|
||||
int ms = train.maxSpeed();
|
||||
table.addRow(
|
||||
@@ -528,7 +528,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
dest.addTo(propList);
|
||||
if (isSet(route)) route.link("li", route).addTo(propList);
|
||||
int ms = maxSpeed();
|
||||
if (ms < Integer.MAX_VALUE) new Tag("li").content(t("Max. Speed")+": "+maxSpeed()+NBSP+speedUnit).addTo(propList);
|
||||
if (ms < Integer.MAX_VALUE) new Tag("li").content(t("Maximum Speed")+": "+maxSpeed()+NBSP+speedUnit).addTo(propList);
|
||||
|
||||
SortedSet<String> allTags = tags();
|
||||
if (!allTags.isEmpty()) {
|
||||
|
||||
@@ -152,7 +152,11 @@ public abstract class Block extends StretchableTile{
|
||||
if (!internalContacts.isEmpty()) {
|
||||
Tag ul = new Tag("ul");
|
||||
for (BlockContact contact : internalContacts) {
|
||||
new Tag("li").content(contact.toString()).addTo(ul);
|
||||
Tag li = new Tag("li").content(contact.toString()+NBSP);
|
||||
contact.button(t("learn"),Map.of(ACTION,ACTION_ANALYZE)).addTo(li);
|
||||
contact.button(t("delete"),Map.of(ACTION,ACTION_DROP)).addTo(li);
|
||||
li.addTo(ul);
|
||||
|
||||
}
|
||||
ul.addTo(fieldset);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class BlockContact extends Contact {
|
||||
super.addr(address);
|
||||
Block block = (Block) parent();
|
||||
block.removeContact(this);
|
||||
if (address != 0) block.register(this);
|
||||
if (address != 0) block.register(this).register();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -157,16 +157,21 @@ public class Contact extends Tile{
|
||||
String action = params.get(ACTION);
|
||||
Id id = Id.from(params);
|
||||
if (action == null) return t("Missing ACTION on call to {}.process()",Contact.class.getSimpleName());
|
||||
Contact contact;
|
||||
Contact contact = isSet(id) ? BaseClass.get(id) : null;
|
||||
switch (action) {
|
||||
case ACTION_ANALYZE:
|
||||
if (id == null) return t("Missing ID on call to {}.process()",Contact.class.getSimpleName());
|
||||
contact = BaseClass.get(id);
|
||||
if (contact == null) return t("No contact with id {} found!",id);
|
||||
if (isNull(id)) return t("Missing ID on call to {}.process()",Contact.class.getSimpleName());
|
||||
if (isNull(contact)) return t("No contact with id {} found!",id);
|
||||
Tag propMenu = contact.properties();
|
||||
propMenu.children().insertElementAt(new Tag("div").content(t("Trigger a feedback sensor to assign it with this contact!")), 1);
|
||||
plan.learn(contact);
|
||||
return propMenu;
|
||||
case ACTION_DROP:
|
||||
if (isNull(id)) return t("Missing ID on call to {}.process()",Contact.class.getSimpleName());
|
||||
if (isNull(contact)) return t("No contact with id {} found!",id);
|
||||
contact.remove();
|
||||
if (contact instanceof BlockContact) return contact.properties();
|
||||
return t("Removed {}.",id);
|
||||
case ACTION_UPDATE:
|
||||
return plan.update(params);
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ public class Relay extends Tile implements Device{
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName()+" ("+(isSet(name) && !name.isEmpty() ? name+")" : "")+" @("+x+", "+y+")";
|
||||
return t(getClass().getSimpleName())+" ("+(isSet(name) && !name.isEmpty() ? name+")" : "")+" @("+x+", "+y+")";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -158,8 +158,7 @@ public abstract class Tile extends BaseClass implements Comparable<Tile>{
|
||||
public JSONObject json() {
|
||||
JSONObject json = super.json();
|
||||
json.put(TYPE, getClass().getSimpleName());
|
||||
JSONObject pos = new JSONObject(Map.of(X,x,Y,y));
|
||||
json.put(POS, pos);
|
||||
json.put(POS, new JSONObject(Map.of(X,x,Y,y)));
|
||||
if (isSet(route)) json.put(ROUTE, route.id());
|
||||
if (isSet(oneWay)) json.put(ONEW_WAY, oneWay);
|
||||
if (disabled) json.put(DISABLED, true);
|
||||
@@ -353,7 +352,7 @@ public abstract class Tile extends BaseClass implements Comparable<Tile>{
|
||||
public static void saveAll(String filename) throws IOException {
|
||||
BufferedWriter file = new BufferedWriter(new FileWriter(filename));
|
||||
for (Tile tile : BaseClass.listElements(Tile.class)) {
|
||||
if (isNull(tile) || tile instanceof Shadow) continue;
|
||||
if (isNull(tile) || tile instanceof Shadow || tile instanceof BlockContact) continue;
|
||||
file.append(tile.json()+"\n");
|
||||
}
|
||||
file.close();
|
||||
@@ -454,9 +453,7 @@ public abstract class Tile extends BaseClass implements Comparable<Tile>{
|
||||
|
||||
@Override
|
||||
public BaseClass remove() {
|
||||
while (!routes.isEmpty()) {
|
||||
routes.first().remove();
|
||||
}
|
||||
while (!routes.isEmpty()) routes.first().remove();
|
||||
return super.remove();
|
||||
}
|
||||
|
||||
@@ -465,9 +462,7 @@ public abstract class Tile extends BaseClass implements Comparable<Tile>{
|
||||
String childAsString = child.toString();
|
||||
if (childAsString.length()>20) childAsString = childAsString.substring(0, 20)+"…";
|
||||
LOG.debug("Removing {} from {}",childAsString,this);
|
||||
if (child instanceof Route) {
|
||||
routes.remove(child);
|
||||
}
|
||||
if (child instanceof Route) routes.remove(child);
|
||||
|
||||
if (child == train) train = null;
|
||||
if (child == route) route = null;
|
||||
|
||||
Reference in New Issue
Block a user