|
|
|
@ -1,5 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "modelbahn.h"
|
|
|
|
#include "modelbahn.h"
|
|
|
|
#include "locomotive.h"
|
|
|
|
#include "locomotive.h"
|
|
|
|
|
|
|
|
|
|
|
|
@ -324,7 +323,7 @@ int Locomotives::SetDestination (string name, string block, int direction) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
debug (0, "Locomotives::SetDestination (Name:%s Block:%s Direction:%d) -> Final:%s"
|
|
|
|
debug ("Name:%s Block:%s Direction:%d -> Final:%s"
|
|
|
|
, name.c_str(), block.c_str(), direction, locomotives[i].blockdest);
|
|
|
|
, name.c_str(), block.c_str(), direction, locomotives[i].blockdest);
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
@ -342,10 +341,10 @@ int Locomotives::SetAssign (string name, string block, int direction) {
|
|
|
|
Lock();
|
|
|
|
Lock();
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
if (name.compare(locomotives[i].name) == 0) {
|
|
|
|
if (name.compare(locomotives[i].name) == 0) {
|
|
|
|
debug (0, "Locomotives::SetAssign (Name:%s Block:%s Direction:%d)", name.c_str(), block.c_str(), direction);
|
|
|
|
debug ("Name:%s Block:%s Direction:%d", name.c_str(), block.c_str(), direction);
|
|
|
|
|
|
|
|
|
|
|
|
if (locomotives[i].flags & LOCO_F_AUTO) {
|
|
|
|
if (locomotives[i].flags & LOCO_F_AUTO) {
|
|
|
|
debug (0, "Locomotives::SetAssign not possible Loco is stil in AUTO mode.");
|
|
|
|
debug ("not possible Loco is stil in AUTO mode.");
|
|
|
|
i = max;
|
|
|
|
i = max;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -402,7 +401,7 @@ int Locomotives::Reset(string name) {
|
|
|
|
Lock();
|
|
|
|
Lock();
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
if (name.compare(locomotives[i].name) == 0) {
|
|
|
|
if (name.compare(locomotives[i].name) == 0) {
|
|
|
|
debug (0, "Locomotives::Reset (Name:%s)", name.c_str());
|
|
|
|
debug ("Name:%s", name.c_str());
|
|
|
|
locomotives[i].flags &= ~(LOCO_F_AUTO | LOCO_F_AUTOSTOP | LOCO_F_AUTORANDOM | LOCO_F_AUTOSHED);
|
|
|
|
locomotives[i].flags &= ~(LOCO_F_AUTO | LOCO_F_AUTOSTOP | LOCO_F_AUTORANDOM | LOCO_F_AUTOSHED);
|
|
|
|
locomotives[i].blockassign[0] = 0;
|
|
|
|
locomotives[i].blockassign[0] = 0;
|
|
|
|
locomotives[i].blockdest[0] = 0;
|
|
|
|
locomotives[i].blockdest[0] = 0;
|
|
|
|
@ -436,7 +435,7 @@ int Locomotives::SetModeMan(string name) {
|
|
|
|
Lock();
|
|
|
|
Lock();
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
if (name.compare(locomotives[i].name) == 0) {
|
|
|
|
if (name.compare(locomotives[i].name) == 0) {
|
|
|
|
debug (0, "Locomotives::SetMan (Name:%s)\n", name.c_str());
|
|
|
|
debug ("Name:%s", name.c_str());
|
|
|
|
locomotives[i].flags &= ~(LOCO_F_AUTO | LOCO_F_AUTOSTOP | LOCO_F_AUTORANDOM | LOCO_F_AUTOSHED);
|
|
|
|
locomotives[i].flags &= ~(LOCO_F_AUTO | LOCO_F_AUTOSTOP | LOCO_F_AUTORANDOM | LOCO_F_AUTOSHED);
|
|
|
|
locomotives[i].auto_onroute = 0;
|
|
|
|
locomotives[i].auto_onroute = 0;
|
|
|
|
locomotives[i].auto_way[0] = 0;
|
|
|
|
locomotives[i].auto_way[0] = 0;
|
|
|
|
@ -462,7 +461,7 @@ int Locomotives::SetModeAutoMan(string name) {
|
|
|
|
Lock();
|
|
|
|
Lock();
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
if (name.compare(locomotives[i].name) == 0 && (locomotives[i].flags & LOCO_F_AUTO)) {
|
|
|
|
if (name.compare(locomotives[i].name) == 0 && (locomotives[i].flags & LOCO_F_AUTO)) {
|
|
|
|
debug (0, "Locomotives::SetAutoMan (Name:%s)\n", name.c_str());
|
|
|
|
debug ("Name:%s", name.c_str());
|
|
|
|
locomotives[i].flags |= LOCO_F_AUTOSTOP;
|
|
|
|
locomotives[i].flags |= LOCO_F_AUTOSTOP;
|
|
|
|
locomotives[i].flags &= ~LOCO_F_AUTORANDOM;
|
|
|
|
locomotives[i].flags &= ~LOCO_F_AUTORANDOM;
|
|
|
|
locomotives[i].flags &= ~LOCO_F_AUTOSHED;
|
|
|
|
locomotives[i].flags &= ~LOCO_F_AUTOSHED;
|
|
|
|
@ -485,7 +484,7 @@ int Locomotives::SetModeAuto(string name) {
|
|
|
|
Lock();
|
|
|
|
Lock();
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
if (name.compare(locomotives[i].name) == 0) {
|
|
|
|
if (name.compare(locomotives[i].name) == 0) {
|
|
|
|
debug (0, "Locomotives::SetAuto (Name:%s)\n", name.c_str());
|
|
|
|
debug ("Name:%s", name.c_str());
|
|
|
|
locomotives[i].flags |= LOCO_F_AUTO;
|
|
|
|
locomotives[i].flags |= LOCO_F_AUTO;
|
|
|
|
locomotives[i].flags &= ~LOCO_F_AUTORANDOM;
|
|
|
|
locomotives[i].flags &= ~LOCO_F_AUTORANDOM;
|
|
|
|
locomotives[i].flags &= ~LOCO_F_AUTOSHED;
|
|
|
|
locomotives[i].flags &= ~LOCO_F_AUTOSHED;
|
|
|
|
@ -508,7 +507,7 @@ int Locomotives::SetModeAutoRand(string name) {
|
|
|
|
Lock();
|
|
|
|
Lock();
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
if (name.compare(locomotives[i].name) == 0 && (locomotives[i].flags & LOCO_F_AUTO)) {
|
|
|
|
if (name.compare(locomotives[i].name) == 0 && (locomotives[i].flags & LOCO_F_AUTO)) {
|
|
|
|
debug (0, "Locomotives::SetAutoRandom (Name:%s)\n", name.c_str());
|
|
|
|
debug ("Name:%s", name.c_str());
|
|
|
|
locomotives[i].flags |= LOCO_F_AUTORANDOM;
|
|
|
|
locomotives[i].flags |= LOCO_F_AUTORANDOM;
|
|
|
|
locomotives[i].flags &= ~LOCO_F_AUTOSHED;
|
|
|
|
locomotives[i].flags &= ~LOCO_F_AUTOSHED;
|
|
|
|
locomotives[i].flags &= ~LOCO_F_AUTOSTOP;
|
|
|
|
locomotives[i].flags &= ~LOCO_F_AUTOSTOP;
|
|
|
|
@ -532,7 +531,7 @@ int Locomotives::SetModeAutoShed(string name) {
|
|
|
|
Lock();
|
|
|
|
Lock();
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
|
|
|
|
if (name.compare(locomotives[i].name) == 0 && (locomotives[i].flags & LOCO_F_AUTO)) {
|
|
|
|
if (name.compare(locomotives[i].name) == 0 && (locomotives[i].flags & LOCO_F_AUTO)) {
|
|
|
|
debug (0, "Locomotives::SetAutoShed (Name:%s)\n", name.c_str());
|
|
|
|
debug ("Name:%s", name.c_str());
|
|
|
|
locomotives[i].flags |= LOCO_F_AUTOSHED;
|
|
|
|
locomotives[i].flags |= LOCO_F_AUTOSHED;
|
|
|
|
locomotives[i].flags &= ~LOCO_F_AUTORANDOM;
|
|
|
|
locomotives[i].flags &= ~LOCO_F_AUTORANDOM;
|
|
|
|
locomotives[i].flags &= ~LOCO_F_AUTOSTOP;
|
|
|
|
locomotives[i].flags &= ~LOCO_F_AUTOSTOP;
|
|
|
|
@ -557,7 +556,7 @@ int Locomotives::SetSpeedFromBus(string ifname, int addr, int speed) {
|
|
|
|
JSONParse jp;
|
|
|
|
JSONParse jp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
debug (0, "Locomotives::SetSpeedFromBus IfName:%s Addr:%d Speed:%d", __FILE__, __LINE__, ifname.c_str(), addr, speed);
|
|
|
|
debug ("IfName:%s Addr:%d Speed:%d", __FILE__, __LINE__, ifname.c_str(), addr, speed);
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0) {
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0) {
|
|
|
|
if (ifname.compare(locomotives[i].ifname) == 0 && locomotives[i].addr == addr) {
|
|
|
|
if (ifname.compare(locomotives[i].ifname) == 0 && locomotives[i].addr == addr) {
|
|
|
|
@ -590,7 +589,7 @@ int Locomotives::SetFunctionFromBus(string ifname, int addr, int func) {
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
JSONParse jp;
|
|
|
|
JSONParse jp;
|
|
|
|
|
|
|
|
|
|
|
|
debug (0, "Locomotives::SetDirectionFromBus IfName:%s Addr:%d function:%d", __FILE__, __LINE__, ifname.c_str(), addr, func);
|
|
|
|
debug ("IfName:%s Addr:%d function:%d", __FILE__, __LINE__, ifname.c_str(), addr, func);
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0) {
|
|
|
|
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0) {
|
|
|
|
if (ifname.compare(locomotives[i].ifname) == 0 && locomotives[i].addr == addr) {
|
|
|
|
if (ifname.compare(locomotives[i].ifname) == 0 && locomotives[i].addr == addr) {
|
|
|
|
if (func & 32) locomotives[i].flags |= LOCO_F_REVERSE;
|
|
|
|
if (func & 32) locomotives[i].flags |= LOCO_F_REVERSE;
|
|
|
|
@ -632,7 +631,7 @@ int Locomotives::SchedulerNextStep(Locomotive *loc) {
|
|
|
|
|
|
|
|
|
|
|
|
if (loc == NULL) return 0;
|
|
|
|
if (loc == NULL) return 0;
|
|
|
|
|
|
|
|
|
|
|
|
debug (0, "Locomotives::SchedulerNextStep loc:%s Step:%d", loc->name, loc->sched_step);
|
|
|
|
debug ("loc:%s Step:%d", loc->name, loc->sched_step);
|
|
|
|
name = loc->name;
|
|
|
|
name = loc->name;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
@ -659,7 +658,7 @@ int Locomotives::SchedulerNextStep(Locomotive *loc) {
|
|
|
|
for (next = "", i = stepnextpos; i < WAYDATA_LEN && loc->schedway[i] != ',' && loc->schedway[i] != 0; i++) {
|
|
|
|
for (next = "", i = stepnextpos; i < WAYDATA_LEN && loc->schedway[i] != ',' && loc->schedway[i] != 0; i++) {
|
|
|
|
if (i > stepnextpos+1) next += loc->schedway[i];
|
|
|
|
if (i > stepnextpos+1) next += loc->schedway[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
debug (0, "Locomotives::SchedulerNextStep loc:%s Next Pos: '%s'", loc->name, loc->schedway+stepnextpos);
|
|
|
|
debug ("loc:%s Next Pos: '%s'", loc->name, loc->schedway+stepnextpos);
|
|
|
|
|
|
|
|
|
|
|
|
if (loc->schedway[stepnextpos] && stepnextpos < schedwaylen-2) {
|
|
|
|
if (loc->schedway[stepnextpos] && stepnextpos < schedwaylen-2) {
|
|
|
|
|
|
|
|
|
|
|
|
@ -689,8 +688,7 @@ int Locomotives::SchedulerNextStep(Locomotive *loc) {
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
debug (0, "Locomotives::SchedulerNextStep Unknown Command: '%c' loc:%s way:'%s'", loc->name,
|
|
|
|
debug ("Unknown Command: '%c' loc:%s way:'%s'", loc->name, loc->schedway[stepnextpos], loc->schedway);
|
|
|
|
loc->schedway[stepnextpos], loc->schedway);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -708,7 +706,7 @@ int Locomotives::SchedulerNextStep(Locomotive *loc) {
|
|
|
|
// if everything is set up till the destination (next) block return 1
|
|
|
|
// if everything is set up till the destination (next) block return 1
|
|
|
|
// to speed things up: we only prepare ways which we have locked already
|
|
|
|
// to speed things up: we only prepare ways which we have locked already
|
|
|
|
//
|
|
|
|
//
|
|
|
|
int Locomotives::AutoCheckWaySingleStep(string way, Locomotive *loc, int *data) {
|
|
|
|
int Locomotives::AutoCheckWaySingleStep(string way, Locomotive *loc, int *data, int mark_error) {
|
|
|
|
size_t pos1;
|
|
|
|
size_t pos1;
|
|
|
|
size_t curpos;
|
|
|
|
size_t curpos;
|
|
|
|
int cnt;
|
|
|
|
int cnt;
|
|
|
|
@ -722,7 +720,7 @@ int Locomotives::AutoCheckWaySingleStep(string way, Locomotive *loc, int *data)
|
|
|
|
Railway r;
|
|
|
|
Railway r;
|
|
|
|
|
|
|
|
|
|
|
|
if (*data < 0) *data = 0;
|
|
|
|
if (*data < 0) *data = 0;
|
|
|
|
debug (0, "Locomotives::AutoCheckWaySingleStep Prepare for Loco: %s Way:%s data:%d blocknext:%s", loc->name, way.c_str(), *data, loc->blocknext);
|
|
|
|
debug ("Prepare for Loco: %s Way:%s data:%d blocknext:%s mark_error:%d", loc->name, way.c_str(), *data, loc->blocknext, mark_error);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// find final next block
|
|
|
|
// find final next block
|
|
|
|
@ -736,7 +734,7 @@ int Locomotives::AutoCheckWaySingleStep(string way, Locomotive *loc, int *data)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nextblockpos = way.find(nextblock);
|
|
|
|
nextblockpos = way.find(nextblock);
|
|
|
|
debug (0, "Locomotives::AutoCheckWaySingleStep nextblock:%s", nextblock.c_str());
|
|
|
|
debug ("nextblock:%s", nextblock.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
curpos = 0;
|
|
|
|
curpos = 0;
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|
@ -749,7 +747,7 @@ int Locomotives::AutoCheckWaySingleStep(string way, Locomotive *loc, int *data)
|
|
|
|
if (curpos != string::npos) {
|
|
|
|
if (curpos != string::npos) {
|
|
|
|
pos1 = way.find(":", curpos+3);
|
|
|
|
pos1 = way.find(":", curpos+3);
|
|
|
|
if (pos1 == string::npos) {
|
|
|
|
if (pos1 == string::npos) {
|
|
|
|
debug (0, "%s:%d turnout without value? '%s'", __FILE__, __LINE__, way.c_str());
|
|
|
|
debug ("turnout without value? '%s'", way.c_str());
|
|
|
|
server->PowerOnOff(0);
|
|
|
|
server->PowerOnOff(0);
|
|
|
|
server->SetModeManual();
|
|
|
|
server->SetModeManual();
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
@ -758,7 +756,7 @@ int Locomotives::AutoCheckWaySingleStep(string way, Locomotive *loc, int *data)
|
|
|
|
|
|
|
|
|
|
|
|
state = server->turnouts.Get(turnout);
|
|
|
|
state = server->turnouts.Get(turnout);
|
|
|
|
if (state == -1) {
|
|
|
|
if (state == -1) {
|
|
|
|
debug (0, "%s:%d turnout not found '%s'", __FILE__, __LINE__, turnout.c_str());
|
|
|
|
debug ("turnout not found '%s'", turnout.c_str());
|
|
|
|
server->PowerOnOff(0);
|
|
|
|
server->PowerOnOff(0);
|
|
|
|
server->SetModeManual();
|
|
|
|
server->SetModeManual();
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
@ -768,32 +766,44 @@ int Locomotives::AutoCheckWaySingleStep(string way, Locomotive *loc, int *data)
|
|
|
|
while (server->railways.FindReference(&x, &y, turnout, cnt++)) {
|
|
|
|
while (server->railways.FindReference(&x, &y, turnout, cnt++)) {
|
|
|
|
cnt++;
|
|
|
|
cnt++;
|
|
|
|
r = server->railways.RailwayGet(x, y);
|
|
|
|
r = server->railways.RailwayGet(x, y);
|
|
|
|
debug (0, "Locomotives::AutoCheckWaySingleStep Loco:%s Turnout:%s LockedBy:%s", loc->name, turnout.c_str(), r.lockedby);
|
|
|
|
debug ("Loco:%s Turnout:%s LockedBy:%s", loc->name, turnout.c_str(), r.lockedby);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
if (strncmp(loc->name, r.lockedby, REFERENCENAME_LEN) == 0 || r.lockedby[0] == 0) {
|
|
|
|
if (strncmp(loc->name, r.lockedby, REFERENCENAME_LEN) == 0 || r.lockedby[0] == 0) {
|
|
|
|
if (way[pos1+1] == '0' && state != 0) {
|
|
|
|
if (way[pos1+1] == '0' && state != 0) {
|
|
|
|
debug (0, "Locomotives::AutoCheckWaySingleStep Loco:%s Turnout:%s Not Equal -> Set:0", loc->name, turnout.c_str());
|
|
|
|
debug ("Loco:%s Turnout:%s Not Equal -> Set:0", loc->name, turnout.c_str());
|
|
|
|
server->turnouts.Set(way.substr(curpos+3, pos1-curpos-3), 0);
|
|
|
|
server->turnouts.Set(way.substr(curpos+3, pos1-curpos-3), 0);
|
|
|
|
|
|
|
|
if (mark_error) {
|
|
|
|
|
|
|
|
debug ("MARK ERROR for %s", turnout.c_str());
|
|
|
|
|
|
|
|
server->turnouts.SetFlags(turnout, server->turnouts.GetFlags(turnout) | TURNOUT_F_ERROR);
|
|
|
|
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (way[pos1+1] == '1' && state != 1) {
|
|
|
|
else if (way[pos1+1] == '1' && state != 1) {
|
|
|
|
debug (0, "Locomotives::AutoCheckWaySingleStep Loco:%s Turnout:%s Not Equal -> Set:1", loc->name, turnout.c_str());
|
|
|
|
debug ("Loco:%s Turnout:%s Not Equal -> Set:1", loc->name, turnout.c_str());
|
|
|
|
server->turnouts.Set(way.substr(curpos+3, pos1-curpos-3), 1);
|
|
|
|
server->turnouts.Set(way.substr(curpos+3, pos1-curpos-3), 1);
|
|
|
|
|
|
|
|
if (mark_error) {
|
|
|
|
|
|
|
|
debug ("MARK ERROR for %s", turnout.c_str());
|
|
|
|
|
|
|
|
server->turnouts.SetFlags(turnout, server->turnouts.GetFlags(turnout) | TURNOUT_F_ERROR);
|
|
|
|
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (newdata > *data) {
|
|
|
|
else if (newdata > *data) {
|
|
|
|
debug (0, "Locomotives::AutoCheckWaySingleStep Loco:%s Turnout:%s Equal Reset:%c", loc->name, turnout.c_str(), way[pos1+1]);
|
|
|
|
debug ("Loco:%s Turnout:%s Equal Reset:%c", loc->name, turnout.c_str(), way[pos1+1]);
|
|
|
|
if (way[pos1+1] == '0') server->turnouts.Set(way.substr(curpos+3, pos1-curpos-3), 0);
|
|
|
|
if (way[pos1+1] == '0') server->turnouts.Set(way.substr(curpos+3, pos1-curpos-3), 0);
|
|
|
|
if (way[pos1+1] == '1') server->turnouts.Set(way.substr(curpos+3, pos1-curpos-3), 1);
|
|
|
|
if (way[pos1+1] == '1') server->turnouts.Set(way.substr(curpos+3, pos1-curpos-3), 1);
|
|
|
|
(*data) = newdata;
|
|
|
|
(*data) = newdata;
|
|
|
|
|
|
|
|
if (mark_error) {
|
|
|
|
|
|
|
|
debug ("MARK ERROR for %s", turnout.c_str());
|
|
|
|
|
|
|
|
server->turnouts.SetFlags(turnout, server->turnouts.GetFlags(turnout) | TURNOUT_F_ERROR);
|
|
|
|
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cnt == 0) {
|
|
|
|
if (cnt == 0) {
|
|
|
|
debug (0, "Locomotives::AutoCheckWaySingleStep Loco:%s Turnout:%s Reference not found", loc->name, turnout.c_str());
|
|
|
|
debug ("Loco:%s Turnout:%s Reference not found", loc->name, turnout.c_str());
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -837,7 +847,7 @@ int Locomotives::Loco_SearchAndLock(Locomotive *loco) {
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// destination empty? true -> random
|
|
|
|
// destination empty? true -> random
|
|
|
|
// false -> find way to destination
|
|
|
|
// false -> find way to destination
|
|
|
|
debug (0, "Locomotives::Loop Search '%s' Reverse:%d", loco->name, (loco->flags & LOCO_F_REVERSE) ? 1 : 0);
|
|
|
|
debug ("Search '%s' Reverse:%d", loco->name, (loco->flags & LOCO_F_REVERSE) ? 1 : 0);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// destination set? - need to find a random block?
|
|
|
|
// destination set? - need to find a random block?
|
|
|
|
@ -869,7 +879,7 @@ int Locomotives::Loco_SearchAndLock(Locomotive *loco) {
|
|
|
|
else if (server->railways.FindWay(loco->blockassign, loco->blockdest, loco->name, &way)) {
|
|
|
|
else if (server->railways.FindWay(loco->blockassign, loco->blockdest, loco->name, &way)) {
|
|
|
|
// try to lock way.
|
|
|
|
// try to lock way.
|
|
|
|
size_t pos, pos1;
|
|
|
|
size_t pos, pos1;
|
|
|
|
debug (0, "Locomotives::Loop %s:%d Found Way:%s", __FILE__, __LINE__, way.c_str());
|
|
|
|
debug ("Found Way:%s", way.c_str());
|
|
|
|
if ((pos = way.find(",b:", 1)) != string::npos) {
|
|
|
|
if ((pos = way.find(",b:", 1)) != string::npos) {
|
|
|
|
if ((pos1 = way.find(",", pos+3)) != string::npos) {
|
|
|
|
if ((pos1 = way.find(",", pos+3)) != string::npos) {
|
|
|
|
strncpy (loco->blocknext, way.substr(pos+3, pos1-(pos+3)).c_str(), REFERENCENAME_LEN);
|
|
|
|
strncpy (loco->blocknext, way.substr(pos+3, pos1-(pos+3)).c_str(), REFERENCENAME_LEN);
|
|
|
|
@ -886,8 +896,7 @@ int Locomotives::Loco_SearchAndLock(Locomotive *loco) {
|
|
|
|
|
|
|
|
|
|
|
|
server->LocomotiveSetMan(loco->name);
|
|
|
|
server->LocomotiveSetMan(loco->name);
|
|
|
|
server->LocomotiveSetSpeed(loco->name, 0);
|
|
|
|
server->LocomotiveSetSpeed(loco->name, 0);
|
|
|
|
debug (DEBUG_ERROR, "*** ERROR *** %s:%d locomotive %s error occured. Could not undo the locking of the way.",
|
|
|
|
debug ("*** ERROR *** locomotive %s error occured. Could not undo the locking of the way.", loco->name);
|
|
|
|
__FILE__, __LINE__, loco->name);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -909,7 +918,7 @@ int Locomotives::Loco_PrepareWay(Locomotive *loco) {
|
|
|
|
block = ((string)(loco->blocknext+2)).substr(0, ((string)(loco->blocknext+2)).find(","));
|
|
|
|
block = ((string)(loco->blocknext+2)).substr(0, ((string)(loco->blocknext+2)).find(","));
|
|
|
|
|
|
|
|
|
|
|
|
if (loco->auto_timenext.tv_sec == 0 || timer_get(&loco->auto_timenext) > LOCO_TO_TURNOUT) {
|
|
|
|
if (loco->auto_timenext.tv_sec == 0 || timer_get(&loco->auto_timenext) > LOCO_TO_TURNOUT) {
|
|
|
|
if (AutoCheckWaySingleStep(loco->auto_way, loco, &loco->auto_data) == 1) {
|
|
|
|
if (AutoCheckWaySingleStep(loco->auto_way, loco, &loco->auto_data, ERROR_SET_NONE) == 1) {
|
|
|
|
if ((loco->flags & LOCO_F_CARGO) ||
|
|
|
|
if ((loco->flags & LOCO_F_CARGO) ||
|
|
|
|
(server->blocks.GetFlags(block) & BLOCK_F_SPEEDLIMIT)) return 1;
|
|
|
|
(server->blocks.GetFlags(block) & BLOCK_F_SPEEDLIMIT)) return 1;
|
|
|
|
else return 2;
|
|
|
|
else return 2;
|
|
|
|
@ -953,10 +962,10 @@ int Locomotives::Loco_OnRoute(Locomotive *loco) {
|
|
|
|
if ( server->sensors.GetActive(s_enter) == 1 || server->sensors.GetActive(s_stop) == 1 ||
|
|
|
|
if ( server->sensors.GetActive(s_enter) == 1 || server->sensors.GetActive(s_stop) == 1 ||
|
|
|
|
server->sensors.GetActive(s_slow) == 1) { // entering block?
|
|
|
|
server->sensors.GetActive(s_slow) == 1) { // entering block?
|
|
|
|
|
|
|
|
|
|
|
|
debug (0, "* Locomotive '%s' EnterBlock '%s'", loco->name, loco->blocknext);
|
|
|
|
debug ("Locomotive '%s' EnterBlock '%s'", loco->name, loco->blocknext);
|
|
|
|
debug (0, "* %s,%d Sensor Enter '%s' = %d", __FILE__, __LINE__, s_enter.c_str(), server->sensors.GetActive(s_enter));
|
|
|
|
debug (" Sensor Enter '%s' = %d", __FILE__, __LINE__, s_enter.c_str(), server->sensors.GetActive(s_enter));
|
|
|
|
debug (0, "* %s,%d Sensor Slow '%s' = %d", __FILE__, __LINE__, s_slow.c_str(), server->sensors.GetActive(s_slow));
|
|
|
|
debug (" Sensor Slow '%s' = %d", __FILE__, __LINE__, s_slow.c_str(), server->sensors.GetActive(s_slow));
|
|
|
|
debug (0, "* %s,%d Sensor Stop '%s' = %d", __FILE__, __LINE__, s_stop.c_str(), server->sensors.GetActive(s_stop));
|
|
|
|
debug (" Sensor Stop '%s' = %d", __FILE__, __LINE__, s_stop.c_str(), server->sensors.GetActive(s_stop));
|
|
|
|
|
|
|
|
|
|
|
|
// assignment <-- next, the assignment has to be checked
|
|
|
|
// assignment <-- next, the assignment has to be checked
|
|
|
|
// against long trains and split blocks
|
|
|
|
// against long trains and split blocks
|
|
|
|
@ -983,23 +992,23 @@ int Locomotives::Loco_OnRoute(Locomotive *loco) {
|
|
|
|
loco->auto_way[0] = 0;
|
|
|
|
loco->auto_way[0] = 0;
|
|
|
|
loco->blocknext[0] = 0;
|
|
|
|
loco->blocknext[0] = 0;
|
|
|
|
|
|
|
|
|
|
|
|
debug (0, "Locomotive::Loco_OnRoute Loco:'%s' Prev:'%s' Assign:'%s' Next:'%s'",
|
|
|
|
debug ("Loco:'%s' Prev:'%s' Assign:'%s' Next:'%s'",
|
|
|
|
loco->name, loco->blockprev, loco->blockassign, loco->blocknext);
|
|
|
|
loco->name, loco->blockprev, loco->blockassign, loco->blocknext);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
if (Loco_SearchAndLock(loco) == 1) {
|
|
|
|
if (Loco_SearchAndLock(loco) == 1) {
|
|
|
|
loco->auto_onroute = LOCO_OR_ENTERBLOCKNEXT;
|
|
|
|
loco->auto_onroute = LOCO_OR_ENTERBLOCKNEXT;
|
|
|
|
debug (0, "Locomotives::Loco_OnRoute Found Way Prepare '%s'", loco->name);
|
|
|
|
debug ("Found Way Prepare '%s'", loco->name);
|
|
|
|
SetSpeed(loco->name, loco->flags & LOCO_F_REVERSE ? -loco->vslow : loco->vslow);
|
|
|
|
SetSpeed(loco->name, loco->flags & LOCO_F_REVERSE ? -loco->vslow : loco->vslow);
|
|
|
|
timer_start(&loco->auto_timenext);
|
|
|
|
timer_start(&loco->auto_timenext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (loco->flags && LOCO_F_AUTO) {
|
|
|
|
else if (loco->flags && LOCO_F_AUTO) {
|
|
|
|
loco->auto_onroute = LOCO_OR_ENTERBLOCKSTOP;
|
|
|
|
loco->auto_onroute = LOCO_OR_ENTERBLOCKSTOP;
|
|
|
|
debug (0, "Locomotives::Loco_OnRoute Slow Down '%s'", loco->name);
|
|
|
|
debug ("Slow Down '%s'", loco->name);
|
|
|
|
SetSpeed(loco->name, loco->flags & LOCO_F_REVERSE ? -loco->vslow : loco->vslow);
|
|
|
|
SetSpeed(loco->name, loco->flags & LOCO_F_REVERSE ? -loco->vslow : loco->vslow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
debug (0, "Locomotives::Loco_OnRoute '%s' some error occured.", loco->name);
|
|
|
|
debug ("'%s' some error occured.", loco->name);
|
|
|
|
SetSpeed(loco->name, 0);
|
|
|
|
SetSpeed(loco->name, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
@ -1033,10 +1042,10 @@ int Locomotives::Loco_BlockEnterStop(Locomotive *loco) {
|
|
|
|
s_slow = server->blocks.GetSensorSlow(dir_reverse, block, loco->flags);
|
|
|
|
s_slow = server->blocks.GetSensorSlow(dir_reverse, block, loco->flags);
|
|
|
|
s_enter = server->blocks.GetSensorEnter(dir_reverse, block, loco->flags);
|
|
|
|
s_enter = server->blocks.GetSensorEnter(dir_reverse, block, loco->flags);
|
|
|
|
if (server->sensors.GetActive(s_stop) == 1) {
|
|
|
|
if (server->sensors.GetActive(s_stop) == 1) {
|
|
|
|
debug (0, "Locomotives::Loop BlockEnterStop '%s' UnLockWay\n", loco->name);
|
|
|
|
debug ("Locomotives::Loop BlockEnterStop '%s' UnLockWay\n", loco->name);
|
|
|
|
debug (0, "* %s,%d Sensor Enter '%s' = %d", __FILE__, __LINE__, s_enter.c_str(), server->sensors.GetActive(s_enter));
|
|
|
|
debug (" Sensor Enter '%s' = %d", s_enter.c_str(), server->sensors.GetActive(s_enter));
|
|
|
|
debug (0, "* %s,%d Sensor Slow '%s' = %d", __FILE__, __LINE__, s_slow.c_str(), server->sensors.GetActive(s_slow));
|
|
|
|
debug (" Sensor Slow '%s' = %d", s_slow.c_str(), server->sensors.GetActive(s_slow));
|
|
|
|
debug (0, "* %s,%d Sensor Stop '%s' = %d", __FILE__, __LINE__, s_stop.c_str(), server->sensors.GetActive(s_stop));
|
|
|
|
debug (" Sensor Stop '%s' = %d", s_stop.c_str(), server->sensors.GetActive(s_stop));
|
|
|
|
|
|
|
|
|
|
|
|
SetSpeed(loco->name, 0);
|
|
|
|
SetSpeed(loco->name, 0);
|
|
|
|
loco->auto_onroute = LOCO_OR_STOPWAIT;
|
|
|
|
loco->auto_onroute = LOCO_OR_STOPWAIT;
|
|
|
|
@ -1075,11 +1084,11 @@ int Locomotives::Loco_BlockEnterNext(Locomotive *loco) {
|
|
|
|
s_enter = server->blocks.GetSensorEnter(dir_reverse, block, loco->flags);
|
|
|
|
s_enter = server->blocks.GetSensorEnter(dir_reverse, block, loco->flags);
|
|
|
|
|
|
|
|
|
|
|
|
if (server->sensors.GetActive(s_stop) == 1) {
|
|
|
|
if (server->sensors.GetActive(s_stop) == 1) {
|
|
|
|
if (!AutoCheckWaySingleStep(loco->auto_way, loco, &loco->auto_data)) {
|
|
|
|
if (!AutoCheckWaySingleStep(loco->auto_way, loco, &loco->auto_data, ERROR_SET_1)) {
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// end of block and not finished preparing the way.
|
|
|
|
// end of block and not finished preparing the way.
|
|
|
|
// stop everything
|
|
|
|
// stop everything
|
|
|
|
debug (0, "Locomotives::Loco_BlockEnterNext could not prepare way in time '%s'\n", loco->name);
|
|
|
|
debug ("could not prepare way in time '%s'\n", loco->name);
|
|
|
|
SetSpeed(loco->name, 0);
|
|
|
|
SetSpeed(loco->name, 0);
|
|
|
|
loco->auto_onroute = LOCO_OR_STOPWAIT;
|
|
|
|
loco->auto_onroute = LOCO_OR_STOPWAIT;
|
|
|
|
server->railways.LockWay(loco->auto_wayold, loco->name, 0, 0);
|
|
|
|
server->railways.LockWay(loco->auto_wayold, loco->name, 0, 0);
|
|
|
|
@ -1090,7 +1099,7 @@ int Locomotives::Loco_BlockEnterNext(Locomotive *loco) {
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
debug (0, "* Locomotives::Loco_BlockEnterNext endblock reached %s", loco->name);
|
|
|
|
debug ("endblock reached %s", loco->name);
|
|
|
|
|
|
|
|
|
|
|
|
server->railways.LockWay(loco->auto_wayold, loco->name, 0, 0);
|
|
|
|
server->railways.LockWay(loco->auto_wayold, loco->name, 0, 0);
|
|
|
|
server->blocks.SetLockedby(loco->blockprev+2, loco->name, 0);
|
|
|
|
server->blocks.SetLockedby(loco->blockprev+2, loco->name, 0);
|
|
|
|
@ -1103,11 +1112,11 @@ int Locomotives::Loco_BlockEnterNext(Locomotive *loco) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (loco->auto_timenext.tv_sec > 0 && timer_get(&loco->auto_timenext) > LOCO_TO_TURNOUT) {
|
|
|
|
if (loco->auto_timenext.tv_sec > 0 && timer_get(&loco->auto_timenext) > LOCO_TO_TURNOUT) {
|
|
|
|
debug (0, "* Locomotives::Loco_BlockEnterNext prepare way for loco: %s", loco->name);
|
|
|
|
debug ("prepare way for loco: %s", loco->name);
|
|
|
|
if (AutoCheckWaySingleStep(loco->auto_way, loco, &loco->auto_data) == 1) {
|
|
|
|
if (AutoCheckWaySingleStep(loco->auto_way, loco, &loco->auto_data, ERROR_SET_NONE) == 1) {
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// finished preparing new way, need to stay in ENTERBLOCKNEXT to unlock old way
|
|
|
|
// finished preparing new way, need to stay in ENTERBLOCKNEXT to unlock old way
|
|
|
|
debug (0, "* Locomotives::Loco_BlockEnterNext finished preparing way for loco: %s", loco->name);
|
|
|
|
debug ("finished preparing way for loco: %s", loco->name);
|
|
|
|
loco->auto_timenext.tv_sec = 0;
|
|
|
|
loco->auto_timenext.tv_sec = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else timer_start(&loco->auto_timenext);
|
|
|
|
else timer_start(&loco->auto_timenext);
|
|
|
|
@ -1143,12 +1152,12 @@ int Locomotives::Loop() {
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// only in automate do anything alone
|
|
|
|
// only in automate do anything alone
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// debug (0, "* Locomotives::Loop (%s:%d) Loco:%s auto_onroute:%d assign:'%s' next:'%s' prev:'%s' dest:'%s' way:'%s' wayold:'%s'"
|
|
|
|
// debug ("Loco:%s auto_onroute:%d assign:'%s' next:'%s' prev:'%s' dest:'%s' way:'%s' wayold:'%s'"
|
|
|
|
// , __FILE__, __LINE__, loco->name, loco->auto_onroute, loco->blockassign
|
|
|
|
// , loco->name, loco->auto_onroute, loco->blockassign
|
|
|
|
// , loco->blocknext, loco->blockprev, loco->blockdest, loco->auto_way, loco->auto_wayold);
|
|
|
|
// , loco->blocknext, loco->blockprev, loco->blockdest, loco->auto_way, loco->auto_wayold);
|
|
|
|
|
|
|
|
|
|
|
|
if (loco->blockassign[0] == 0) {
|
|
|
|
if (loco->blockassign[0] == 0) {
|
|
|
|
debug (0, "%s:%d Locomotive [%s] not assigned to any block. Set Mode to Man", __FILE__, __LINE__, loco->name);
|
|
|
|
debug ("Locomotive [%s] not assigned to any block. Set Mode to Man", loco->name);
|
|
|
|
SetModeMan(loco->name);
|
|
|
|
SetModeMan(loco->name);
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1160,7 +1169,7 @@ int Locomotives::Loop() {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
debug (0, "%s:%d Locomotive [%s] is doing NOTHING", __FILE__, __LINE__, loco->name);
|
|
|
|
debug ("Locomotive [%s] is doing NOTHING", loco->name);
|
|
|
|
timer_start(&loco->auto_timenext);
|
|
|
|
timer_start(&loco->auto_timenext);
|
|
|
|
loco->auto_onroute = LOCO_OR_SEARCH;
|
|
|
|
loco->auto_onroute = LOCO_OR_SEARCH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1180,7 +1189,7 @@ int Locomotives::Loop() {
|
|
|
|
|
|
|
|
|
|
|
|
if (strcmp(loco->blockassign, loco->blockdest) == 0) {
|
|
|
|
if (strcmp(loco->blockassign, loco->blockdest) == 0) {
|
|
|
|
loco->blockdest[0] = 0;
|
|
|
|
loco->blockdest[0] = 0;
|
|
|
|
debug (0, "* Locomotive '%s' DEST == ASSING", loco->name);
|
|
|
|
debug ("Locomotive '%s' DEST == ASSING", loco->name);
|
|
|
|
jp.Clear();
|
|
|
|
jp.Clear();
|
|
|
|
jp.AddObject("locomotive",_GetJSON(lnum));
|
|
|
|
jp.AddObject("locomotive",_GetJSON(lnum));
|
|
|
|
if(network) network->ChangeListPushToAll(jp.ToString());
|
|
|
|
if(network) network->ChangeListPushToAll(jp.ToString());
|
|
|
|
@ -1193,7 +1202,7 @@ int Locomotives::Loop() {
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
// nothing found -> try reverse
|
|
|
|
// nothing found -> try reverse
|
|
|
|
if (loco->blockassign[0] != 0 && loco->blockdest[0] != 0 && (loco->flags & LOCO_F_CANREVERSE)) {
|
|
|
|
if (loco->blockassign[0] != 0 && loco->blockdest[0] != 0 && (loco->flags & LOCO_F_CANREVERSE)) {
|
|
|
|
debug (0, "* Loco_SearchAndLock Reverse Loco %s", loco->name);
|
|
|
|
debug ("Reverse Loco %s", loco->name);
|
|
|
|
if (loco->blockassign[0] == '-') loco->blockassign[0] = '+';
|
|
|
|
if (loco->blockassign[0] == '-') loco->blockassign[0] = '+';
|
|
|
|
else if (loco->blockassign[0] == '+') loco->blockassign[0] = '-';
|
|
|
|
else if (loco->blockassign[0] == '+') loco->blockassign[0] = '-';
|
|
|
|
|
|
|
|
|
|
|
|
@ -1215,7 +1224,7 @@ int Locomotives::Loop() {
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
SetSpeed(loco->name, loco->flags & LOCO_F_REVERSE ? -loco->vmid : loco->vmid);
|
|
|
|
SetSpeed(loco->name, loco->flags & LOCO_F_REVERSE ? -loco->vmid : loco->vmid);
|
|
|
|
loco->auto_onroute = LOCO_OR_ONTHEWAY;
|
|
|
|
loco->auto_onroute = LOCO_OR_ONTHEWAY;
|
|
|
|
debug (0, "* %s:%d Locomotive '%s' Way Prepared -> Speed: VMID", __FILE__, __LINE__, loco->name);
|
|
|
|
debug ("Locomotive '%s' Way Prepared -> Speed: VMID", loco->name);
|
|
|
|
jp.Clear();
|
|
|
|
jp.Clear();
|
|
|
|
jp.AddObject("locomotive",_GetJSON(lnum));
|
|
|
|
jp.AddObject("locomotive",_GetJSON(lnum));
|
|
|
|
if(network) network->ChangeListPushToAll(jp.ToString());
|
|
|
|
if(network) network->ChangeListPushToAll(jp.ToString());
|
|
|
|
@ -1223,7 +1232,7 @@ int Locomotives::Loop() {
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
SetSpeed(loco->name, loco->flags & LOCO_F_REVERSE ? -loco->vfast : loco->vfast);
|
|
|
|
SetSpeed(loco->name, loco->flags & LOCO_F_REVERSE ? -loco->vfast : loco->vfast);
|
|
|
|
loco->auto_onroute = LOCO_OR_ONTHEWAY;
|
|
|
|
loco->auto_onroute = LOCO_OR_ONTHEWAY;
|
|
|
|
debug (0, "* %s:%d Locomotive '%s' Way Prepared -> Speed: VFAST", __FILE__, __LINE__, loco->name);
|
|
|
|
debug ("Locomotive '%s' Way Prepared -> Speed: VFAST", loco->name);
|
|
|
|
jp.Clear();
|
|
|
|
jp.Clear();
|
|
|
|
jp.AddObject("locomotive",_GetJSON(lnum));
|
|
|
|
jp.AddObject("locomotive",_GetJSON(lnum));
|
|
|
|
if(network) network->ChangeListPushToAll(jp.ToString());
|
|
|
|
if(network) network->ChangeListPushToAll(jp.ToString());
|
|
|
|
@ -1255,7 +1264,7 @@ int Locomotives::Loop() {
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
SetSpeed(loco->name, loco->flags & LOCO_F_REVERSE ? -loco->vmid : loco->vmid);
|
|
|
|
SetSpeed(loco->name, loco->flags & LOCO_F_REVERSE ? -loco->vmid : loco->vmid);
|
|
|
|
loco->auto_onroute = LOCO_OR_ONTHEWAY;
|
|
|
|
loco->auto_onroute = LOCO_OR_ONTHEWAY;
|
|
|
|
debug (0, "* %s:%d Locomotive LOCO_OR_ENTERBLOCKNEXT '%s' Way Prepared -> Speed: VMID", __FILE__, __LINE__, loco->name);
|
|
|
|
debug ("Locomotive LOCO_OR_ENTERBLOCKNEXT '%s' Way Prepared -> Speed: VMID", loco->name);
|
|
|
|
jp.Clear();
|
|
|
|
jp.Clear();
|
|
|
|
jp.AddObject("locomotive",_GetJSON(lnum));
|
|
|
|
jp.AddObject("locomotive",_GetJSON(lnum));
|
|
|
|
if(network) network->ChangeListPushToAll(jp.ToString());
|
|
|
|
if(network) network->ChangeListPushToAll(jp.ToString());
|
|
|
|
@ -1263,7 +1272,7 @@ int Locomotives::Loop() {
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
SetSpeed(loco->name, loco->flags & LOCO_F_REVERSE ? -loco->vfast : loco->vfast);
|
|
|
|
SetSpeed(loco->name, loco->flags & LOCO_F_REVERSE ? -loco->vfast : loco->vfast);
|
|
|
|
loco->auto_onroute = LOCO_OR_ONTHEWAY;
|
|
|
|
loco->auto_onroute = LOCO_OR_ONTHEWAY;
|
|
|
|
debug (0, "* Locomotive LOCO_OR_ENTERBLOCKNEXT '%s' Way Prepared -> Speed: VFAST", loco->name);
|
|
|
|
debug ("Locomotive LOCO_OR_ENTERBLOCKNEXT '%s' Way Prepared -> Speed: VFAST", loco->name);
|
|
|
|
jp.Clear();
|
|
|
|
jp.Clear();
|
|
|
|
jp.AddObject("locomotive",_GetJSON(lnum));
|
|
|
|
jp.AddObject("locomotive",_GetJSON(lnum));
|
|
|
|
if(network) network->ChangeListPushToAll(jp.ToString());
|
|
|
|
if(network) network->ChangeListPushToAll(jp.ToString());
|
|
|
|
|