16 #include "interface.h"
17 #include "xnodeconnector.h"
23 XInterface::XInterfaceError::XInterfaceError(
const XString &msg,
const char *file,
int line)
25 XInterface::XConvError::XConvError(
const char *file,
int line)
26 : XInterfaceError(i18n(
"Conversion Error"), file, line) {}
27 XInterface::XCommError::XCommError(
const XString &msg,
const char *file,
int line)
28 : XInterfaceError(i18n(
"Communication Error") +
", " + msg, file, line) {}
29 XInterface::XOpenInterfaceError::XOpenInterfaceError(
const char *file,
int line)
30 : XInterfaceError(i18n(
"Open Interface Error"), file, line) {}
33 XInterface::XInterface(
const char *name,
bool runtime,
const shared_ptr<XDriver> &driver) :
36 m_device(create<
XComboNode>(
"Device", false, true)),
38 m_address(create<
XUIntNode>(
"Address", false)),
39 m_control(create<
XBoolNode>(
"Control", true)) {
42 lsnOnControlChanged = tr[ *control()].onValueChanged().connectWeakly(
43 shared_from_this(), &XInterface::onControlChanged);
50 return driver()->getLabel();
52 return driver()->getLabel() +
":" + m_label;
58 g_statusPrinter->printMessage(driver()->
getLabel() + i18n(
": Starting..."));
64 shot.talk(shot[ *
this].onClose(),
this);
73 gErrPrint(
getLabel() + i18n(
"Port has already opened"));
78 catch (XInterfaceError &e) {
79 e.print(
getLabel() + i18n(
": Opening interface failed, because "));
82 tr.unmark(lsnOnControlChanged);
88 tr[ *
device()].setUIEnabled(
false);
89 tr[ *
port()].setUIEnabled(
false);
90 tr[ *
address()].setUIEnabled(
false);
93 tr.unmark(lsnOnControlChanged);
95 shot.talk(shot[ *
this].onOpen(),
this);
104 catch (XInterfaceError &e) {
105 e.print(
getLabel() + i18n(
": Closing interface failed, because"));
109 tr[ *
device()].setUIEnabled(
true);
110 tr[ *
port()].setUIEnabled(
true);
111 tr[ *
address()].setUIEnabled(
true);
112 tr[ *
control()].setUIEnabled(
true);
115 tr.unmark(lsnOnControlChanged);