|
|
|
@ -45,6 +45,11 @@ Server::Server() {
|
|
|
|
|
thread_running = 0;
|
|
|
|
|
railways.SetSize(200, 200);
|
|
|
|
|
status_text = "init server";
|
|
|
|
|
mode = SMODE_STARTUP;
|
|
|
|
|
data_reset.mr_idx = -1;
|
|
|
|
|
data_reset.mr_step = SMRESET_STEP_INIT;
|
|
|
|
|
gettimeofday(&data_reset.mr_timestamp, NULL);
|
|
|
|
|
|
|
|
|
|
Load ();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -59,6 +64,31 @@ void Server::ThreadProcess() {
|
|
|
|
|
while (running) {
|
|
|
|
|
interfaces.Loop();
|
|
|
|
|
turnouts.Loop();
|
|
|
|
|
|
|
|
|
|
debug (0, "%s:%d mode:%d data_reset.step:%d data_reset.idx:%d", __FILE__, __LINE__, mode, data_reset.mr_step, data_reset.mr_idx);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// startup process
|
|
|
|
|
if (mode == SMODE_STARTUP) {
|
|
|
|
|
SetModeReset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// reset all internal data
|
|
|
|
|
else if (mode == SMODE_RESET) {
|
|
|
|
|
SetModeManual();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// mode manual
|
|
|
|
|
else if (mode == SMODE_MANUAL) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// mode auto
|
|
|
|
|
else if (mode == SMODE_AUTO) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
usleep (25000);
|
|
|
|
|
}
|
|
|
|
|
debug (0, "Server::ThreadProcess Finished");
|
|
|
|
@ -102,14 +132,14 @@ bool Server::IsChanged() {
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Set Mode Auto
|
|
|
|
|
void Server::ModeAuto() {
|
|
|
|
|
void Server::SetModeAuto() {
|
|
|
|
|
debug (0, "%s:%d * Mode Auto", __FILE__, __LINE__);
|
|
|
|
|
status_text = "Mode Auto";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Set Mode Manual
|
|
|
|
|
void Server::ModeManual() {
|
|
|
|
|
void Server::SetModeManual() {
|
|
|
|
|
debug (0, "%s:%d * Mode Manual", __FILE__, __LINE__);
|
|
|
|
|
status_text = "Mode Manual";
|
|
|
|
|
}
|
|
|
|
@ -117,16 +147,21 @@ void Server::ModeManual() {
|
|
|
|
|
//
|
|
|
|
|
// Set Mode Error
|
|
|
|
|
// FIXME: maybe adding error text as parameter?
|
|
|
|
|
void Server::ModeError(string text) {
|
|
|
|
|
void Server::SetModeError(string text) {
|
|
|
|
|
debug (0, "%s:%d * Mode Error :'%s'", __FILE__, __LINE__, text.c_str());
|
|
|
|
|
status_text = "Error:'" + text + "'";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Set Mode Reset
|
|
|
|
|
void Server::ModeReset() {
|
|
|
|
|
void Server::SetModeReset() {
|
|
|
|
|
debug (0, "%s:%d * Reset Data", __FILE__, __LINE__);
|
|
|
|
|
status_text = "Mode Reset";
|
|
|
|
|
|
|
|
|
|
mode = SMODE_RESET;
|
|
|
|
|
data_reset.mr_step = SMRESET_STEP_INIT;
|
|
|
|
|
data_reset.mr_idx = -1;
|
|
|
|
|
gettimeofday(&data_reset.mr_timestamp, NULL);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|