improved contact learning code

This commit is contained in:
Stephan Richter
2020-11-22 23:12:55 +01:00
parent 9e3556c05c
commit d8c1d93a7f
2 changed files with 11 additions and 10 deletions

View File

@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.srsoftware</groupId>
<artifactId>web4rail</artifactId>
<version>1.0.12</version>
<version>1.0.13</version>
<name>Web4Rail</name>
<packaging>jar</packaging>
<description>Java Model Railway Control</description>

View File

@@ -686,17 +686,18 @@ public class Plan extends BaseClass{
public void sensor(int addr, boolean active) {
Contact contact = Contact.get(addr);
if (isSet(contact)) {
contact.activate(active);
} else {
LOG.debug("contact: {}", addr);
if (active && learningContact != null) {
LOG.debug("learned: {} = {}",addr,learningContact);
stream(learningContact.addr(addr).propMenu().toString());
learningContact = null;
if (active && learningContact != null) {
if (isSet(contact)) {
contact.addr(0);
LOG.debug("unsibscribed {} from {}",contact,addr);
}
stream(learningContact.addr(addr).propMenu().toString());
learningContact = null;
LOG.debug("learned: {} = {}",addr,learningContact);
return;
}
if (isSet(contact)) contact.activate(active);
}
/**