//private TreeMap<Integer,Integer> cvs = new TreeMap<Integer, Integer>();
privateDecoderdecoder;
@ -73,14 +71,8 @@ public class Locomotive extends Car implements Constants{
@@ -73,14 +71,8 @@ public class Locomotive extends Car implements Constants{
returnloco.faster(-Train.defaultSpeedStep);
caseACTION_STOP:
returnloco.stop();
caseACTION_TOGGLE_F1:
returnloco.toggleFunction(1);
caseACTION_TOGGLE_F2:
returnloco.toggleFunction(2);
caseACTION_TOGGLE_F3:
returnloco.toggleFunction(3);
caseACTION_TOGGLE_F4:
returnloco.toggleFunction(4);
caseACTION_TOGGLE_FUNCTION:
returnloco.toggleFunction(params);
caseACTION_TURN:
returnloco.turn();
caseACTION_UPDATE:
@ -116,26 +108,17 @@ public class Locomotive extends Car implements Constants{
@@ -116,26 +108,17 @@ public class Locomotive extends Car implements Constants{
@ -187,27 +170,26 @@ public class Locomotive extends Car implements Constants{
@@ -187,27 +170,26 @@ public class Locomotive extends Car implements Constants{
}
direction.addTo(fieldset);
Tagfunctions=newTag("p");
params.put(ACTION,ACTION_TOGGLE_F1);
Buttonb1=newButton(t("F1"),params);
if(fun1)b1.clazz("active");
b1.addTo(functions);
Tagfunctions=newTag("p");
params.put(ACTION,ACTION_TOGGLE_F2);
Buttonb2=newButton(t("F2"),params);
if(fun2)b2.clazz("active");
b2.addTo(functions);
if(isSet(loco)&&isSet(loco.decoder)){
for(inti=1;i<=loco.decoder.numFunctions();i++){
params.put(ACTION,ACTION_TOGGLE_FUNCTION);
params.put(FUNCTION,i);
Buttonbtn=newButton(loco.functionName(i),params);
if(loco.decoder.isEnabled(i))btn.clazz("active");
btn.addTo(functions);
}
}
params.put(ACTION,ACTION_TOGGLE_F3);
Buttonb3=newButton(t("F3"),params);
if(fun3)b3.clazz("active");
b3.addTo(functions);
if(isSet(train)){
params.put(ACTION,HEADLIGHT);
//headlight = new Button(t("Headlight"), params);
}
params.put(ACTION,ACTION_TOGGLE_F4);
Buttonb4=newButton(t("F4"),params);
if(fun4)b4.clazz("active");
b4.addTo(functions);
functions.addTo(fieldset);
if(isSet(train)){
@ -255,11 +237,26 @@ public class Locomotive extends Car implements Constants{
@@ -255,11 +237,26 @@ public class Locomotive extends Car implements Constants{
@ -289,10 +286,6 @@ public class Locomotive extends Car implements Constants{
@@ -289,10 +286,6 @@ public class Locomotive extends Car implements Constants{
@ -333,7 +326,7 @@ public class Locomotive extends Car implements Constants{
@@ -333,7 +326,7 @@ public class Locomotive extends Car implements Constants{
@ -391,48 +384,12 @@ public class Locomotive extends Car implements Constants{
@@ -391,48 +384,12 @@ public class Locomotive extends Car implements Constants{
@ -445,8 +402,8 @@ public class Locomotive extends Car implements Constants{
@@ -445,8 +402,8 @@ public class Locomotive extends Car implements Constants{
@ -459,18 +416,12 @@ public class Locomotive extends Car implements Constants{
@@ -459,18 +416,12 @@ public class Locomotive extends Car implements Constants{
returnproperties();
}
ObjecttoggleFunction(intf){
switch(f){
case1:
returnsetFunction(1,!f1);
case2:
returnsetFunction(2,!f2);
case3:
returnsetFunction(3,!f3);
case4:
returnsetFunction(4,!f4);
}
returnt("Unknown function: {}",f);
ObjecttoggleFunction(Paramsparams){
Integerindex=params.getInt(FUNCTION);
if(isNull(index))returnt("No function number provided!");
if(isNull(decoder))returnt("{} has no decoder!",this);
decoder.toggleFunction(index);
returnt("Unknown function: {}",params);
}
publicObjectturn(){
@ -504,6 +455,7 @@ public class Locomotive extends Car implements Constants{
@@ -504,6 +455,7 @@ public class Locomotive extends Car implements Constants{
LOG.debug("Settings for function {}: {}",num,settings);
@ -512,7 +464,7 @@ public class Locomotive extends Car implements Constants{
@@ -512,7 +464,7 @@ public class Locomotive extends Car implements Constants{
functions.put(type,funList);
}
if(enabled){
funList.put(num,newFunction(type,dirs));
funList.put(num,newFunction(type,name,dirs));// TODO