prepare shortstop and split tracks

master
Steffen Pohle 3 years ago
parent 67c73836f8
commit db27a5a02a

@ -1,3 +1,6 @@
2023-03-13:
- prepared split and short tracks. - needs to be tested completly.
2022-04-17:
- added "-simulation" parmeter for debugging purpose.
needed to simulate turnout manipulation

@ -1,9 +1,14 @@
#include <string>
#include "modelbahn.h"
#include "block.h"
#include <list>
#include <string>
#include <string.h>
using namespace std;
Blocks::Blocks () {
changed = 0;
blocks = (Block*) malloc(sizeof(Block)*SENSORS_MAX);
@ -35,16 +40,24 @@ int Blocks::UnLock() {
JSONParse Blocks::_GetJSON(Block *bl) {
JSONParse json;
JSONElement je;
string s = "";
json.Clear();
s = bl->name; json.AddObject("name", s);
json.AddObject("name", bl->name);
json.AddObject("flags", bl->flags);
json.AddObject("lockedby", bl->lockedby);
json.AddObject("sensor_pos_1", bl->s_pos_1);
json.AddObject("sensor_center", bl->s_center);
json.AddObject("sensor_neg_1", bl->s_neg_1);
json.AddObject("sensor_enter_0", bl->s_enter[0]);
json.AddObject("sensor_slow_0", bl->s_slow[0]);
json.AddObject("sensor_stop_0", bl->s_stop[0]);
json.AddObject("sensor_shortstop_0", bl->s_shortstop[0]);
json.AddObject("sensor_enter_1", bl->s_enter[1]);
json.AddObject("sensor_slow_1", bl->s_slow[1]);
json.AddObject("sensor_stop_1", bl->s_stop[1]);
json.AddObject("sensor_shortstop_1", bl->s_shortstop[1]);
json.AddObject("secondblock", bl->secondblock);
return json;
};
@ -102,18 +115,43 @@ Block Blocks::GetBlockFromJSON(JSONParse *j) {
j->GetValue("name", &s);
strncpy (bl.name, s.c_str(), REFERENCENAME_LEN);
j->GetValueInt("flags", &bl.flags);
// j->GetValue("lockedby", &s);
// strncpy (bl.lockedby, s.c_str(), REFERENCENAME_LEN);
s = ""; j->GetValue("sensor_pos_1", &s);
strncpy (bl.s_pos_1, s.c_str(), REFERENCENAME_LEN);
s = ""; j->GetValue("sensor_center", &s);
strncpy (bl.s_center, s.c_str(), REFERENCENAME_LEN);
s = ""; j->GetValue("sensor_neg_1", &s);
strncpy (bl.s_neg_1, s.c_str(), REFERENCENAME_LEN);
printf ("%s:%d block: %s flags: %d\n", __FILE__, __LINE__, bl.name, bl.flags);
//
// old version input data
//
s = "";
if (j->GetValue("sensor_pos_1", &s)) {
strncpy (bl.s_enter[0], s.c_str(), REFERENCENAME_LEN);
strncpy (bl.s_stop[1], s.c_str(), REFERENCENAME_LEN);
}
s = "";
if (j->GetValue("sensor_center", &s)) {
strncpy (bl.s_shortstop[0], s.c_str(), REFERENCENAME_LEN);
strncpy (bl.s_shortstop[1], s.c_str(), REFERENCENAME_LEN);
}
s = "";
if (j->GetValue("sensor_neg_1", &s)) {
strncpy (bl.s_enter[1], s.c_str(), REFERENCENAME_LEN);
strncpy (bl.s_stop[0], s.c_str(), REFERENCENAME_LEN);
}
//
// new version
//
s = ""; if (j->GetValue("sensor_enter_0", &s)) strncpy (bl.s_enter[0], s.c_str(), REFERENCENAME_LEN);
s = ""; if (j->GetValue("sensor_enter_1", &s)) strncpy (bl.s_enter[1], s.c_str(), REFERENCENAME_LEN);
s = ""; if (j->GetValue("sensor_slow_0", &s)) strncpy (bl.s_slow[0], s.c_str(), REFERENCENAME_LEN);
s = ""; if (j->GetValue("sensor_slow_1", &s)) strncpy (bl.s_slow[1], s.c_str(), REFERENCENAME_LEN);
s = ""; if (j->GetValue("sensor_stop_0", &s)) strncpy (bl.s_stop[0], s.c_str(), REFERENCENAME_LEN);
s = ""; if (j->GetValue("sensor_stop_1", &s)) strncpy (bl.s_stop[1], s.c_str(), REFERENCENAME_LEN);
s = ""; if (j->GetValue("sensor_shortstop_0", &s)) strncpy (bl.s_shortstop[0], s.c_str(), REFERENCENAME_LEN);
s = ""; if (j->GetValue("sensor_shortstop_1", &s)) strncpy (bl.s_shortstop[1], s.c_str(), REFERENCENAME_LEN);
printf ("%s:%d block: %s flags: %d\n", __FILE__, __LINE__, bl.name, bl.flags);
return bl;
};
@ -324,44 +362,59 @@ int Blocks::GetFlags (string blname) {
};
string Blocks::GetSensorMinus (string blname) {
string Blocks::GetSensorEnter (int direction, string blname) {
string res = "";
int i;
JSONParse jp;
Lock();
for (i = 0; i < max; i++) if (blname.compare(blocks[i].name) == 0) {
res = blocks[i].s_neg_1;
res = blocks[i].s_enter[direction];
}
UnLock();
return res;
};
string Blocks::GetSensorSlow (int direction, string blname) {
std::string res = "";
int i;
JSONParse jp;
Lock();
for (i = 0; i < max; i++) if (blname.compare(blocks[i].name) == 0) {
res = blocks[i].s_slow[direction];
}
UnLock();
return res;
};
string Blocks::GetSensorCenter (string blname) {
string Blocks::GetSensorStop (int direction, string blname) {
string res = "";
int i;
JSONParse jp;
Lock();
for (i = 0; i < max; i++) if (blname.compare(blocks[i].name) == 0) {
res = blocks[i].s_center;
res = blocks[i].s_stop[direction];
}
UnLock();
return res;
};
string Blocks::GetSensorPlus (string blname) {
string Blocks::GetSensorShortStop (int direction, string blname) {
string res = "";
int i;
JSONParse jp;
Lock();
for (i = 0; i < max; i++) if (blname.compare(blocks[i].name) == 0) {
res = blocks[i].s_pos_1;
res = blocks[i].s_shortstop[direction];
}
UnLock();
return res;
};

@ -2,23 +2,55 @@
#ifndef _BLOCK_H_
#define _BLOCK_H_
#include <list>
#include <string>
#include <string.h>
using namespace std;
#include "modelbahn.h"
#include "server.h"
#define BLOCK_F_OFF 0x0001
#define BLOCK_F_SPLIT 0x0002 // is this a split block? only works for short
#define BLOCK_F_SPLITPOS 0x0004 // is this a split block? only works for short
#define BLOCK_F_SHORT 0x0010
#define BLOCK_F_LONG 0x0020
#define BLOCK_F_ENDSTATION 0x0040
#define BLOCK_F_STATION 0x0080
#define BLOCK_F_SPEEDLIMIT 0x0100
#define BLOCK_F_ONLYCARGO 0x0200
#define BLOCK_F_ONLYPASSENGER 0x0400
/*
* FIXME: long trains on split blocks
* FIXME: sample how to set up positive entry side
*
* Dirction Pos: from Left to Right Neg: from Right to Left
* Dirction Pos: from Top to Bottom Neg: from Bottom to Top
*
* pos SPLIT BLOCK neg SPLIT BLOCK
* F_SPLIT | F_SPLITPOS F_SPLIT
* >----o-------------o------o-------------o---> entry direction
*
* ^ ^ ^
* | | |
* s_enter[0] s_shortstop[0] | positive_block
* s_stop[0] negative block
*/
struct s_Block {
char name[REFERENCENAME_LEN];
char s_pos_1[REFERENCENAME_LEN]; //
char s_center[REFERENCENAME_LEN];
char s_neg_1[REFERENCENAME_LEN];
// default sensors [0].. positive side [1] negative side
char s_enter[2][REFERENCENAME_LEN];
char s_slow[2][REFERENCENAME_LEN];
char s_stop[2][REFERENCENAME_LEN];
char s_shortstop[2][REFERENCENAME_LEN];
char secondblock[REFERENCENAME_LEN]; // short two blocks segment.
int flags;
char lockedby[REFERENCENAME_LEN]; // element locked by locreference (only set by server, not by JSON/Webinterface)
@ -57,9 +89,10 @@ class Blocks {
int SetOff(string blname);
int IsOff(string blname);
string GetSensorMinus (string blname);
string GetSensorCenter (string blname);
string GetSensorPlus (string blname);
string GetSensorEnter (int direction, string blname);
string GetSensorSlow (int direction, string blname);
string GetSensorStop (int direction, string blname);
string GetSensorShortStop (int direction, string blname);
int GetFlags (string blname);
int SetLockedby (string blname, string lockedby, int lock_onoff);

@ -1,4 +1,6 @@
#include <string>
#include "modelbahn.h"
#include "interface.h"
#include "interface-z21.h"

@ -3,6 +3,9 @@
#include <string>
#include <string.h>
using namespace std;
#include "debug.h"
#include "json.h"

@ -734,9 +734,13 @@ int Locomotives::Loop() {
string way;
Locomotive *loco = NULL;
string block;
string sensor;
string s_enter;
string s_slow;
string s_stop;
string s_shortstop;
JSONParse jp;
int reverse = 1;
int dir_reverse = 0;
for (lnum = 0; lnum < max; lnum++) if (locomotives[lnum].name[0] != 0) {
loco = &locomotives[lnum];
@ -885,11 +889,21 @@ int Locomotives::Loop() {
// FIXME: move this code to the block class -> we will need a better code for multiple sensors
block = loco->blocknext+2;
if (loco->blocknext[0] == '-') sensor = server->blocks.GetSensorMinus(block);
else sensor = server->blocks.GetSensorPlus(block);
if (loco->blocknext[0] == '-') dir_reverse = 1;
else dir_reverse = 0;
s_shortstop = server->blocks.GetSensorShortStop(dir_reverse, block);
s_stop = server->blocks.GetSensorStop(dir_reverse, block);
s_slow = server->blocks.GetSensorSlow(dir_reverse, block);
s_enter = server->blocks.GetSensorEnter(dir_reverse, block);
if ( server->sensors.GetActive(s_enter) == 1 || server->sensors.GetActive(s_stop) == 1 ||
server->sensors.GetActive(s_slow) == 1 || server->sensors.GetActive(s_shortstop) == 1) { // entering block?
if (server->sensors.GetActive(sensor) == 1) { // entering block?
debug (0, "* 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 (0, "* %s,%d Sensor Slow '%s' = %d", __FILE__, __LINE__, s_slow.c_str(), server->sensors.GetActive(s_slow));
debug (0, "* %s,%d Sensor Sh.Stop '%s' = %d", __FILE__, __LINE__, s_shortstop.c_str(), server->sensors.GetActive(s_shortstop));
debug (0, "* %s,%d Sensor Stop '%s' = %d", __FILE__, __LINE__, s_stop.c_str(), server->sensors.GetActive(s_stop));
// unlock old assigned block
if (loco->blockassign[0] != 0) server->blocks.SetLockedby((string)(loco->blockassign+2), loco->name, 0);
@ -974,12 +988,18 @@ int Locomotives::Loop() {
// check enter block
block = loco->blockassign+2;
if (loco->blockassign[0] == '-')
sensor = server->blocks.GetSensorPlus(block);
else
sensor = server->blocks.GetSensorMinus(block);
if (server->sensors.GetActive(sensor) == 1) {
if (loco->blockassign[0] == '-') dir_reverse = 1;
else dir_reverse = 0;
s_shortstop = server->blocks.GetSensorShortStop(dir_reverse, block);
s_stop = server->blocks.GetSensorStop(dir_reverse, block);
s_slow = server->blocks.GetSensorSlow(dir_reverse, block);
s_enter = server->blocks.GetSensorEnter(dir_reverse, block);
if ( server->sensors.GetActive(s_stop) == 1 ||
((loco->flags & LOCO_F_SHORTTRAIN) && server->sensors.GetActive(s_shortstop) == 1)) {
debug (0, "Locomotives::Loop EnterBlockStop '%s' UnLockWay\n", loco->name);
SetSpeed(loco->name, 0);
loco->auto_onroute = LOCO_OR_STOPWAIT;
@ -1005,13 +1025,22 @@ int Locomotives::Loop() {
}
block = loco->blockassign+2;
if (loco->blockassign[0] == '-')
sensor = server->blocks.GetSensorPlus(block);
else
sensor = server->blocks.GetSensorMinus(block);
if (loco->blockassign[0] == '-') dir_reverse = 1;
else dir_reverse = 0;
s_shortstop = server->blocks.GetSensorShortStop(dir_reverse, block);
s_stop = server->blocks.GetSensorStop(dir_reverse, block);
s_slow = server->blocks.GetSensorSlow(dir_reverse, block);
s_enter = server->blocks.GetSensorEnter(dir_reverse, block);
if ( server->sensors.GetActive(s_stop) == 1 ||
((loco->flags & LOCO_F_SHORTTRAIN) && server->sensors.GetActive(s_shortstop) == 1)) {
if (server->sensors.GetActive(sensor) == 1) {
debug (0, "Locomotives::Loop EnterBlockNext '%s' UnLockWay\n", loco->name);
debug (0, "Locomotives::Loop EnterBlockNext Loco:'%s' Block: '%s' UnLockWay", loco->name, block.c_str());
debug (0, "* %s,%d 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 (0, "* %s,%d Sensor Sh.Stop '%s' = %d", __FILE__, __LINE__, s_shortstop.c_str(), server->sensors.GetActive(s_shortstop));
debug (0, "* %s,%d Sensor Stop '%s' = %d", __FILE__, __LINE__, s_stop.c_str(), server->sensors.GetActive(s_stop));
server->railways.UnLockWay(loco->auto_wayold, loco->name);
server->blocks.SetLockedby(loco->blockprev+2, loco->name, 0);
@ -1053,8 +1082,6 @@ int Locomotives::Test(string loco) {
int i;
int j = 0;
printf ("%s:%d LocoTest.\n", __FILE__, __LINE__);
for (i = 0; i < max; i++) if (locomotives[i].name[0] != 0)
if (loco.compare(locomotives[i].name) == 0) {

@ -590,7 +590,6 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri
}
else if (fd_pos.enterfrom >= 0 && fd_end.x == fd_pos.x && fd_pos.y == fd_end.y && fd_pos.enterfrom == fd_end.enterfrom) {
// destination found
printf ("%s:%d destination found fd_pos (%d,%d) fd_end (%d,%d) next:%s\n", __FILE__, __LINE__, fd_pos.x, fd_pos.y, fd_end.x, fd_end.y, fd_pos.way.c_str());
found = 1;
*next = fd_pos.way + ",b:" + blockend;
fd_pos.enterfrom = -1;
@ -600,7 +599,6 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri
}
else if (fd_pos.enterfrom >= 0 && fd_start.x == fd_pos.x && fd_start.y == fd_pos.y && fd_start.enterfrom == fd_pos.enterfrom) {
// start found
printf ("%s:%d start found fd_pos (%d,%d) fd_start (%d,%d)\n", __FILE__, __LINE__, fd_pos.x, fd_pos.y, fd_start.x, fd_start.y);
fd_pos.enterfrom = -1;
fd_pos.x = -1;
fd_pos.y = -1;
@ -608,7 +606,6 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri
}
else if (fd_data[GetRIdx(fd_pos.x, fd_pos.y)].e & (1 << fd_pos.enterfrom)) {
// old entry found
printf ("old entry found (%d,%d)\n", fd_pos.x, fd_pos.y);
fd_pos.enterfrom = -1;
fd_pos.x = -1;
fd_pos.y = -1;
@ -623,7 +620,6 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri
fd_pos.parma++;
rnext = &railways[GetRIdx(fd_pos.x, fd_pos.y)];
if (rnext->lockedby[0] != 0) {
printf ("%s:%d railway is locked by %s\n", __FILE__, __LINE__, rnext->lockedby);
fd_pos.enterfrom = -1;
fd_pos.x = -1;
fd_pos.y = -1;
@ -634,24 +630,20 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri
else if (rpos->type == RAILWAY_TURNOUT) {
fd_tmp = NextPos(fd_pos, rpos->altdir);
fd_tmp.way += (string)",t:" + (string)rpos->name + (string)":1";
printf ("%s:%d turnout dir:%d altdir:%d fd_pos (%d,%d -> %d) fd_tmp (%d,%d -> %d)\n", __FILE__, __LINE__, rpos->dir, rpos->altdir, fd_pos.x, fd_pos.y, fd_pos.enterfrom, fd_tmp.x, fd_tmp.y, fd_tmp.enterfrom);
fd_tmp.parma += 10; // 10 bad point for using the turnout
fd_list.push_back(fd_tmp);
fd_pos = NextPos(fd_pos, rpos->dir);
fd_pos.way += (string)",t:" + (string)rpos->name + (string)":0";
fd_pos.parma++;
printf ("%s:%d turnout fd_newpos (%d,%d -> %d)\n", __FILE__, __LINE__, fd_pos.x, fd_pos.y, fd_pos.enterfrom);
}
else if (rpos->type == RAILWAY_CONNECTOR) {
int found = 0;
printf ("%s:%d connector found Reference:'%s'\n", __FILE__, __LINE__, rpos->name);
x = -1;
y = -1;
while (found == 0 && _FindReference(&x, &y, rpos->name) == 1) {
if (fd_pos.x != x || fd_pos.y != y) {
printf ("%s:%d found %d,%d\n", __FILE__, __LINE__, x, y);
fd_pos.oldx = fd_pos.x;
fd_pos.oldy = fd_pos.y;
fd_pos.oldenterfrom = fd_pos.enterfrom;
@ -675,7 +667,6 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri
//
// if block is off ignore it completly
else if (rpos->type == RAILWAY_BLOCK) {
printf ("%s:%d block found\n", __FILE__, __LINE__);
int blflags = server->blocks.GetFlags(rpos->name);
if ((server->blocks.IsOff(rpos->name) ||
@ -700,7 +691,6 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri
fd_pos.parma++;
}
else {
printf ("%s:%d block is locked by %s\n", __FILE__, __LINE__, lockedby.c_str());
fd_pos.enterfrom = -1;
fd_pos.x = -1;
fd_pos.y = -1;
@ -710,7 +700,6 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri
}
else { // finished
printf ("%s:%d finished?\n", __FILE__, __LINE__);
fd_pos.enterfrom = -1;
fd_pos.x = -1;
fd_pos.y = -1;
@ -724,18 +713,12 @@ int Railways::FindWay(string blockstart, string blockend, string lockedfor, stri
else {
//
// next = "b:+blockname,t:name:0,t:name:1,b:-blockname"
printf ("Temp Next: %s\n", next->c_str());
size_t npos;
if ((npos = next->find(",b:")) != string::npos) {
if ((npos = next->find(",b:")) != string::npos)
*next = next->substr(0, next->find(",", npos+1));
printf ("%s:%d next: '%s' found\n", __FILE__, __LINE__, next->c_str());
}
else {
// nothing found?
printf ("%s:%d next: '%s' but no next block?\n", __FILE__, __LINE__, next->c_str());
else // nothing found?
*next = "";
}
}
UnLock();
free (fd_data);

@ -137,7 +137,6 @@ int Server::Load(string fn) {
turnouts.Change(&to);
}
//
// read blocks
Block bl;

@ -4,15 +4,15 @@
var blocks = [];
const BLOCK_F_OFF = 0x0001;
const BLOCK_F_SPLIT = 0x0002;
const BLOCK_F_SPLITPOS = 0x0004;
const BLOCK_F_SHORT = 0x0010;
const BLOCK_F_LONG = 0x0020;
const BLOCK_F_ENDSTATION = 0x0040;
const BLOCK_F_STATION = 0x0080;
const BLOCK_F_SPEEDLIMIT = 0x0100;
const BLOCK_F_ONLYCARGO = 0x0200;
const BLOCK_F_ONLYPASSENGER = 0x0400;
//
// update or add a new element
//
@ -22,9 +22,14 @@ function block_Update(blockdata) {
blocks[i].name = blockdata.name;
blocks[i].flags = blockdata.flags;
blocks[i].lockedby = blockdata.lockedby;
blocks[i].sensor_pos_1 = blockdata.sensor_pos_1,
blocks[i].sensor_center = blockdata.sensor_center,
blocks[i].sensor_neg_1 = blockdata.sensor_neg_1
blocks[i].sensor_stop_0 = blockdata.sensor_stop_0,
blocks[i].sensor_shortstop_0 = blockdata.sensor_shortstop_0,
blocks[i].sensor_slow_0 = blockdata.sensor_slow_0,
blocks[i].sensor_enter_0 = blockdata.sensor_enter_0,
blocks[i].sensor_stop_1 = blockdata.sensor_stop_1,
blocks[i].sensor_shortstop_1 = blockdata.sensor_shortstop_1,
blocks[i].sensor_slow_1 = blockdata.sensor_slow_1,
blocks[i].sensor_enter_1 = blockdata.sensor_enter_1,
blockdetail_setData(blocks[i]);
return;
}
@ -36,9 +41,14 @@ function block_Update(blockdata) {
name: blockdata.name,
flags: blockdata.flags,
lockedby: blockdata.lockedby,
sensor_pos_1: blockdata.sensor_pos_1,
sensor_center: blockdata.sensor_center,
sensor_neg_1: blockdata.sensor_neg_1
sensor_enter_0: blockdata.sensor_enter_0,
sensor_slow_0: blockdata.sensor_slow_0,
sensor_stop_0: blockdata.sensor_stop_0,
sensor_shortstop_0: blockdata.sensor_shortstop_0,
sensor_enter_1: blockdata.sensor_enter_1,
sensor_slow_1: blockdata.sensor_slow_1,
sensor_stop_1: blockdata.sensor_stop_1,
sensor_shortstop_1: blockdata.sensor_shortstop_1
});
};
@ -186,6 +196,16 @@ function block_server_Off(blockname) {
//
// if create is set the name should be filled in
function blockdetail_fillsensor() {
let r = "<option value=\"\"></option>";
for (var i = 0; i < sensors.length; i++) {
if (sensors[i].name)
r += "<option value=\""+sensors[i].name+"\">"+sensors[i].name+"</option>";
};
return r;
}
function blockdetail_show(name, create) {
var win = document.getElementById("blockdetail");
let innerHTML = " \
@ -199,48 +219,42 @@ function blockdetail_show(name, create) {
\
<table><tr><td>\
\
<table><tr><td> \
<label><input id=\"blockdet_flagoff\" type=\"checkbox\" value=\"\" disabled>Off Service</label><br> \
<label><input id=\"blockdet_flagshort\" type=\"checkbox\" value=\"\">Short</label><br>\
<label><input id=\"blockdet_flaglong\" type=\"checkbox\" value=\"\">Long</label> \
</td><td> \
<label><input id=\"blockdet_flagend\" type=\"checkbox\" value=\"\">End</label><br> \
<label><input id=\"blockdet_flagstation\" type=\"checkbox\" value=\"\">Station</label><br> \
<label><input id=\"blockdet_flagspeedlimit\" type=\"checkbox\" value=\"\">Speed Limit</label><br> \
</td><td> \
<label><input id=\"blockdet_flagonlycargo\" type=\"checkbox\" value=\"\">Only Cargo</label><br> \
<label><input id=\"blockdet_flagonlypassenger\" type=\"checkbox\" value=\"\">Only Passenger</label><br> \
<label><input id=\"blockdet_flagunknown\" type=\"hidden\" value=\"\"></label><br> \
</td></tr></table> \
<table><tr> \
<td><label><input id=\"blockdet_flagoff\" type=\"checkbox\" value=\"\" disabled>Off Service</label></td> \
<td><label><input id=\"blockdet_flagonlycargo\" type=\"checkbox\" value=\"\">Only Cargo</label></td> \
<td><label><input id=\"blockdet_flagshort\" type=\"checkbox\" value=\"\">Short</label></td> \
</tr><tr> \
<td><label><input id=\"blockdet_flagend\" type=\"checkbox\" value=\"\">End</label></td> \
<td><label><input id=\"blockdet_flagonlypassenger\" type=\"checkbox\" value=\"\">Only Passenger</label></td> \
<td><label><input id=\"blockdet_flagsplit\" type=\"checkbox\" value=\"\">Split</label></td> \
</tr><tr> \
<td><label><input id=\"blockdet_flagspeedlimit\" type=\"checkbox\" value=\"\">Speed Limit</label></td> \
<td><label><input id=\"blockdet_flagstation\" type=\"checkbox\" value=\"\">Station</label></td> \
<td><label><input id=\"blockdet_flagsplitpos\" type=\"checkbox\" value=\"\">Splitpos</label></td> \
</tr><tr> \
<td></td> \
</tr></table> \
\
</td><td></td></tr></table> \
<fieldset><legend>Automatic Mode</legend><table> \
<tr><td>Lockedby:</td><td><input id=\"blockdet_lockedby\" style=\"width: 100\" disabled></td></tr>\
<tr><td>Sensor &larr;&uarr;:</td><td><label><select id=\"blockdet_sensorLU\">";
innerHTML += "<option value=\"\"></option>";
for (var i = 0; i < sensors.length; i++) {
if (sensors[i].name)
innerHTML += "<option value=\""+sensors[i].name+"\">"+sensors[i].name+"</option>";
}
innerHTML += "</select></label></td></tr>\
<tr><td>Sensor Center:</td><td><label><select id=\"blockdet_sensorC\">";
innerHTML += "<option value=\"\"></option>";
for (var i = 0; i < sensors.length; i++) {
if (sensors[i].name)
innerHTML += "<option value=\""+sensors[i].name+"\">"+sensors[i].name+"</option>";
}
innerHTML += "</select></label></td></tr>\
<tr><td>Sensor &rarr;&darr;:</td><td><label><select id=\"blockdet_sensorRD\">";
innerHTML += "<option value=\"\"></option>";
for (var i = 0; i < sensors.length; i++) {
if (sensors[i].name)
innerHTML += "<option value=\""+sensors[i].name+"\">"+sensors[i].name+"</option>";
}
innerHTML += "</select></label></td></tr>\
</table></fileset>\
<tr><td>Lockedby:</td><td><input id=\"blockdet_lockedby\" style=\"width: 100\" disabled></td></tr>"
innerHTML += "<table><tr><td></td><td>enter</td><td>slow</td><td>shortstop</td><td>stop</td></tr>";
innerHTML += "<tr><td>Direction &rarr;&darr;:</td>";
innerHTML += "<td align=center><label><select id=\"blockdet_sensor_enter_0\">" + blockdetail_fillsensor() + "</select></label></td>";
innerHTML += "<td align=center><label><select id=\"blockdet_sensor_slow_0\">" + blockdetail_fillsensor() + "</select></label></td>";
innerHTML += "<td align=center><label><select id=\"blockdet_sensor_shortstop_0\">" + blockdetail_fillsensor() + "</select></label></td>";
innerHTML += "<td align=center><label><select id=\"blockdet_sensor_stop_0\">" + blockdetail_fillsensor() + "</select></label></td>";
innerHTML += "</tr>";
innerHTML += "<tr><td>Direction &larr;&uarr;:</td>";
innerHTML += "<td align=center><label><select id=\"blockdet_sensor_enter_1\">" + blockdetail_fillsensor() + "</select></label></td>";
innerHTML += "<td align=center><label><select id=\"blockdet_sensor_slow_1\">" + blockdetail_fillsensor() + "</select></label></td>";
innerHTML += "<td align=center><label><select id=\"blockdet_sensor_shortstop_1\">" + blockdetail_fillsensor() + "</select></label></td>";
innerHTML += "<td align=center><label><select id=\"blockdet_sensor_stop_1\">" + blockdetail_fillsensor() + "</select></label></td>";
innerHTML += "</tr></table>";
innerHTML += "</td></tr></table></fileset>\
</div> <hr>\
<div align=right> \
<button id=\"blockdet_SAVE\" type=\"button\">Save</button> \
@ -360,30 +374,42 @@ function blockdetail_setData(elm) {
var name = document.getElementById("blockdet_name");
var flagoff = document.getElementById("blockdet_flagoff");
var flagshort = document.getElementById("blockdet_flagshort");
var flaglong = document.getElementById("blockdet_flaglong");
var flagsplit = document.getElementById("blockdet_flagsplit");
var flagsplitpos = document.getElementById("blockdet_flagsplitpos");
var flagend = document.getElementById("blockdet_flagend");
var flagonlycargo = document.getElementById("blockdet_flagonlycargo");
var flagonlypassenger = document.getElementById("blockdet_flagonlypassenger");
var flagstation = document.getElementById("blockdet_flagstation");
var flagspeedlimit = document.getElementById("blockdet_flagspeedlimit");
var sensorLU = document.getElementById("blockdet_sensorLU");
var sensorC = document.getElementById("blockdet_sensorC");
var sensorRD = document.getElementById("blockdet_sensorRD");
var sensor_enter_0 = document.getElementById("blockdet_sensor_enter_0");
var sensor_slow_0 = document.getElementById("blockdet_sensor_slow_0");
var sensor_stop_0 = document.getElementById("blockdet_sensor_stop_0");
var sensor_shortstop_0 = document.getElementById("blockdet_sensor_shortstop_0");
var sensor_enter_1 = document.getElementById("blockdet_sensor_enter_1");
var sensor_slow_1 = document.getElementById("blockdet_sensor_slow_1");
var sensor_stop_1 = document.getElementById("blockdet_sensor_stop_1");
var sensor_shortstop_1 = document.getElementById("blockdet_sensor_shortstop_1");
var lockedby = document.getElementById("blockdet_lockedby");
if (elm) {
if (name) name.value = elm.name;
if (flagoff) flagoff.checked = Number(elm.flags) & BLOCK_F_OFF;
if (flagshort) flagshort.checked = Number(elm.flags) & BLOCK_F_SHORT;
if (flaglong) flaglong.checked = Number(elm.flags) & BLOCK_F_LONG;
if (flagsplit) flagsplit.checked = Number(elm.flags) & BLOCK_F_SPLIT;
if (flagsplitpos) flagsplitpos.checked = Number(elm.flags) & BLOCK_F_SPLITPOS;
if (flagend) flagend.checked = Number(elm.flags) & BLOCK_F_ENDSTATION;
if (flagonlycargo) flagonlycargo.checked = Number(elm.flags) & BLOCK_F_ONLYCARGO;
if (flagonlypassenger) flagonlypassenger.checked = Number(elm.flags) & BLOCK_F_ONLYPASSENGER;
if (flagstation) flagstation.checked = Number(elm.flags) & BLOCK_F_STATION;
if (flagspeedlimit) flagspeedlimit.checked = Number(elm.flags) & BLOCK_F_SPEEDLIMIT;
if (sensorLU) sensorLU.value = elm.sensor_pos_1;
if (sensorC) sensorC.value = elm.sensor_center;
if (sensorRD) sensorRD.value = elm.sensor_neg_1;
if (sensor_enter_0) sensor_enter_0.value = elm.sensor_enter_0;
if (sensor_slow_0) sensor_slow_0.value = elm.sensor_slow_0;
if (sensor_stop_0) sensor_stop_0.value = elm.sensor_stop_0;
if (sensor_shortstop_0) sensor_shortstop_0.value = elm.sensor_shortstop_0;
if (sensor_enter_1) sensor_enter_1.value = elm.sensor_enter_1;
if (sensor_slow_1) sensor_slow_1.value = elm.sensor_slow_1;
if (sensor_stop_1) sensor_stop_1.value = elm.sensor_stop_1;
if (sensor_shortstop_1) sensor_shortstop_1.value = elm.sensor_shortstop_1;
if (lockedby) lockedby.value = elm.lockedby;
}
};
@ -398,15 +424,21 @@ function blockdetail_getData() {
var name = document.getElementById("blockdet_name");
var flagoff = document.getElementById("blockdet_flagoff");
var flagshort = document.getElementById("blockdet_flagshort");
var flaglong = document.getElementById("blockdet_flaglong");
var flagsplit = document.getElementById("blockdet_flagsplit");
var flagsplitpos = document.getElementById("blockdet_flagsplitpos");
var flagend = document.getElementById("blockdet_flagend");
var flagonlycargo = document.getElementById("blockdet_flagonlycargo");
var flagonlypassenger = document.getElementById("blockdet_flagonlypassenger");
var flagstation = document.getElementById("blockdet_flagstation");
var flagspeedlimit = document.getElementById("blockdet_flagspeedlimit");
var sensorLU = document.getElementById("blockdet_sensorLU");
var sensorC = document.getElementById("blockdet_sensorC");
var sensorRD = document.getElementById("blockdet_sensorRD");
var sensor_enter_0 = document.getElementById("blockdet_sensor_enter_0");
var sensor_slow_0 = document.getElementById("blockdet_sensor_slow_0");
var sensor_stop_0 = document.getElementById("blockdet_sensor_stop_0");
var sensor_shortstop_0 = document.getElementById("blockdet_sensor_shortstop_0");
var sensor_enter_1 = document.getElementById("blockdet_sensor_enter_1");
var sensor_slow_1 = document.getElementById("blockdet_sensor_slow_1");
var sensor_stop_1 = document.getElementById("blockdet_sensor_stop_1");
var sensor_shortstop_1 = document.getElementById("blockdet_sensor_shortstop_1");
if (name) res.name = name.value;
@ -416,8 +448,11 @@ function blockdetail_getData() {
if (flagshort.checked) res.flags |= BLOCK_F_SHORT;
else res.flags &= ~BLOCK_F_SHORT;
if (flaglong.checked) res.flags |= BLOCK_F_LONG;
else res.flags &= ~BLOCK_F_LONG;
if (flagsplit.checked) res.flags |= BLOCK_F_SPLIT;
else res.flags &= ~BLOCK_F_SPLIT;
if (flagsplitpos.checked) res.flags |= BLOCK_F_SPLITPOS;
else res.flags &= ~BLOCK_F_SPLITPOS;
if (flagend.checked) res.flags |= BLOCK_F_ENDSTATION;
else res.flags &= ~BLOCK_F_ENDSTATION;
@ -434,9 +469,15 @@ function blockdetail_getData() {
if (flagspeedlimit.checked) res.flags |= BLOCK_F_SPEEDLIMIT;
else res.flags &= ~BLOCK_F_SPEEDLIMIT;
if (sensorLU) res.sensor_pos_1 = sensorLU.value;
if (sensorC) res.sensor_center = sensorC.value;
if (sensorRD) res.sensor_neg_1 = sensorRD.value;
if (sensor_enter_0) res.sensor_enter_0 = sensor_enter_0.value;
if (sensor_slow_0) res.sensor_slow_0 = sensor_slow_0.value;
if (sensor_stop_0) res.sensor_stop_0 = sensor_stop_0.value;
if (sensor_shortstop_0) res.sensor_shortstop_0 = sensor_shortstop_0.value;
if (sensor_enter_1) res.sensor_enter_1 = sensor_enter_1.value;
if (sensor_slow_1) res.sensor_slow_1 = sensor_slow_1.value;
if (sensor_stop_1) res.sensor_stop_1 = sensor_stop_1.value;
if (sensor_shortstop_1) res.sensor_shortstop_1 = sensor_shortstop_1.value;
return res;
};

Loading…
Cancel
Save