working on auto and manual mode

master
Steffen Pohle 4 years ago
parent 47ebbf3ada
commit 0b0339b924

@ -613,9 +613,20 @@ int Locomotives::Loop() {
if (loco->auto_onroute == LOCO_OR_NOTHING) {
timer_start(&loco->auto_timenext);
loco->auto_onroute = LOCO_OR_SEARCH;
//
// check if the loco mode is set to autostop
if (loco->flags & LOCO_F_AUTOSTOP) {
SetMan(loco->name);
}
}
else if (loco->auto_onroute == LOCO_OR_SEARCH) {
//
// check if the loco mode is set to autostop
if (loco->flags & LOCO_F_AUTOSTOP) {
SetMan(loco->name);
}
//
// try to find and prepare(lock) a new way.
// nothing found check if we can reverse direction, this will be done only
@ -752,7 +763,7 @@ int Locomotives::Loop() {
// try to find new way
printf ("%s:%d LOCO_OR_ONTHEWAY try to find new way\n", __FILE__, __LINE__);
if (loco->blockdest[0] == 0) {
if ((loco->flags & LOCO_F_RANDOM) && (loco->flags & LOCO_F_CARGO || !(server->blocks.GetFlags(block) & BLOCK_F_STATION)))
if ((loco->flags & LOCO_F_RANDOM) && ((loco->flags & LOCO_F_CARGO) || !(server->blocks.GetFlags(block) & BLOCK_F_STATION)))
if (server->railways.FindRandomWay(loco->blockassign, loco->name, &way)) {
size_t pos;
if ((pos = way.find(",b:", 1)) != string::npos) {

@ -648,7 +648,7 @@ function lococtrl_show(name) {
<td><button id=\"lococtrl_"+name+"_btnman\" type=\"button\" value=\"vstop\">MAN</button></td> \
</tr><tr> \
<td align=center><input id=\"lococtrl_"+name+"_cbstopman\" type=\"checkbox\" value=\"\" disabled></td>\
<td><button id=\"lococtrl_"+name+"_btnstopman\" type=\"button\" value=\"vstop\">A&lArr;M</button></td> \
<td><button id=\"lococtrl_"+name+"_btnstopman\" type=\"button\" value=\"vstop\">A&rArr;M</button></td> \
</tr><tr> \
<td align=center><input id=\"lococtrl_"+name+"_cbauto\" type=\"checkbox\" value=\"\" disabled></td>\
<td><button id=\"lococtrl_"+name+"_btnauto\" type=\"button\" value=\"vstop\">AUTO</button></td> \
@ -693,6 +693,9 @@ function lococtrl_cb_btnreset() {
var name = getTextBetween(this.id, "lococtrl_", "_btnreset");
var request = { command: "locomotivereset", locomotive: name };
serverinout (request, serverinout_defaultCallback);
request = { command: "locomotivesetman", locomotive: name };
serverinout (request, serverinout_defaultCallback);
};
@ -790,7 +793,11 @@ function lococtrl_setData(data) {
var cbauto = document.getElementById("lococtrl_"+data.name+"_cbauto");
var cbrand = document.getElementById("lococtrl_"+data.name+"_cbrand");
var cbmanstop = document.getElementById("lococtrl_"+data.name+"_cbstopman");
var btnman = document.getElementById("lococtrl_"+data.name+"_btnman");
var btnautostop = document.getElementById("lococtrl_"+data.name+"_btnstopman");
var btnauto = document.getElementById("lococtrl_"+data.name+"_btnauto");
var btnautorand = document.getElementById("lococtrl_"+data.name+"_btnrand");
if (range && reverse) {
debug ("lococtrl: " + data.name + " speed:" + data.speed + " vmax:" +
data.vmax + " flags:" + data.flags);
@ -801,7 +808,26 @@ function lococtrl_setData(data) {
cbrand.checked = (data.flags & LOCO_F_RANDOM);
cbmanstop.checked = (data.flags & LOCO_F_AUTOSTOP);
range.min = 0;
if (data.flags & LOCO_F_AUTOSTOP) {
btnman.disabled = false;
btnauto.disabled = true;
btnautorand.disabled = true;
btnautostop.disabled = true;
}
else if (data.flags & LOCO_F_AUTO) {
btnman.disabled = true;
btnautorand.disabled = false;
btnautostop.disabled = false;
}
else {
btnman.disabled = true;
btnautorand.disabled = true;
btnautostop.disabled = true;
btnauto.disabled = false;
}
range.min = 0;
if (data.vmax) range.max = data.vmax;
range.value = Math.abs(Number(data.speed));
}

Loading…
Cancel
Save