You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
2.6 KiB
116 lines
2.6 KiB
|
|
|
|
#include "modelbahn.h"
|
|
#include "interface.h"
|
|
|
|
// **************************************************************************
|
|
// *
|
|
// * I N T E R F A C E (gateway to different devices)
|
|
// *
|
|
// **************************************************************************
|
|
|
|
Interface::Interface() {
|
|
debug (DEBUG_INFO | DEBUG_IFACE, "Interface:%s", __FUNCTION__);
|
|
|
|
name[0] = 0;
|
|
host[0] = 0;
|
|
flags = 0;
|
|
type = INTF_T_OFF_UNKNOWN;
|
|
needs_update = true;
|
|
};
|
|
|
|
Interface::~Interface() {
|
|
};
|
|
|
|
|
|
void Interface::Connect () {
|
|
debug (DEBUG_INFO | DEBUG_IFACE, "* Interface (%s) Connect to %s", name, host);
|
|
};
|
|
|
|
|
|
void Interface::Disconnect() {
|
|
debug (DEBUG_INFO | DEBUG_IFACE, "* Interface (%s) Disconnect", name);
|
|
};
|
|
|
|
|
|
void Interface::PowerOnOff(int onoff) {
|
|
debug (DEBUG_INFO | DEBUG_IFACE, "* Interface (%s) PowerOnOff %d", name, onoff);
|
|
};
|
|
|
|
/*
|
|
* Turnout:
|
|
* this function will check if the interface has not set any output within the past 100ms. For this we
|
|
* will save the current time in the value turnouttime.
|
|
*/
|
|
void Interface::SetTurnout(Turnout *t, int active, int outputactive) {
|
|
JSONParse jp;
|
|
|
|
debug (DEBUG_INFO | DEBUG_IFACE, "%s:%d Interface (%s) SetTurnout Addr:%d Acitve:%d Output:%d", __FILE__, __LINE__, name,
|
|
t->addr, active, outputactive);
|
|
};
|
|
|
|
//
|
|
// Locomotive
|
|
//
|
|
void Interface::SetLocoSpeed(Locomotive *l, int step) {
|
|
debug (DEBUG_INFO | DEBUG_IFACE, "* Interface (%s) SetLocoSpeed Addr:%d Speed:%d ", name, l->addr, step);
|
|
};
|
|
|
|
|
|
void Interface::SetLocoFunction(Locomotive *l, int func, int value) {
|
|
debug (DEBUG_INFO | DEBUG_IFACE, "* Interface (%s) SetLocoFunction Addr:%d Func:%d:%d", name, l->addr, func, value);
|
|
};
|
|
|
|
|
|
//
|
|
// if update is needed return 1
|
|
//
|
|
int Interface::Loop() {
|
|
int ret = 0;
|
|
|
|
// debug (DEBUG_INFO | DEBUG_IFACE, "* Interface (%s) Loop", name);
|
|
|
|
flags &= ~(INTF_F_CONNECTED | INTF_F_POWER | INTF_F_STOP | INTF_F_SHORT_CIRCUIT | INTF_F_PROGRAMMING);
|
|
if (needs_update) {
|
|
ret = 1;
|
|
needs_update = 0;
|
|
}
|
|
|
|
return ret;
|
|
};
|
|
|
|
|
|
bool Interface::IsConnected() {
|
|
bool ret = false;
|
|
debug (DEBUG_INFO | DEBUG_IFACE, "* Interface (%s) IsConnected", name);
|
|
return ret;
|
|
}
|
|
|
|
|
|
bool Interface::IsPoweron() {
|
|
bool ret = false;
|
|
debug (DEBUG_INFO | DEBUG_IFACE, "* Interface (%s) IsPoweron", name);
|
|
return ret;
|
|
}
|
|
|
|
|
|
bool Interface::IsSortCircuit() {
|
|
bool ret = false;
|
|
debug (DEBUG_INFO | DEBUG_IFACE, "* Interface (%s) IsSortCircuit", name);
|
|
return ret;
|
|
}
|
|
|
|
bool Interface::IsProgramminnMode() {
|
|
bool ret = false;
|
|
debug (DEBUG_INFO | DEBUG_IFACE, "* Interface (%s) IsProgramminnMode", name);
|
|
return ret;
|
|
}
|
|
|
|
bool Interface::IsEmergencyStop() {
|
|
bool ret = false;
|
|
debug (DEBUG_INFO | DEBUG_IFACE, "* Interface (%s) IsEmergencyStop", name);
|
|
return ret;
|
|
}
|
|
|
|
|