40 :m_bUsePlatformSpecific(bUsePS),
43 m_Telegrams(Telegrams),
47 bool bConnected(
true);
52 if (m_bUsePlatformSpecific)
57 m_pProxy = new ::oETCS::DF::IBaliseDeviceIn(::oETCS::DF::IBaliseDeviceIn::staticInterfaceName(),
"/oETCS/BaliseDeviceIn", QDBusConnection::sessionBus());
60 if (not m_pProxy->isValid())
63 ::std::cerr <<
"::oETCS::DF::CBaliseDeviceIn had a problem with D-Bus connection: " << m_pProxy->lastError().message().toStdString() << ::std::endl;
75 bConnected &= QObject::connect(m_pProxy, SIGNAL(NewTelegram(
const QByteArray &,
int)),
this, SLOT(NewTelegramReceived(
const QByteArray &,
int)));
76 bConnected &= QObject::connect(m_pProxy, SIGNAL(Error(
const QString &)),
this, SLOT(Error(
const QString&)));
82 ::std::cerr <<
"::oETCS::DF::CBaliseDeviceIn could not connect all signal and slots" << ::std::endl;
89 catch (const ::std::bad_alloc& Exception)
125 ::std::vector< bool > BitVector;
126 ::std::string ErrorMessage;
127 bool bNewTelegram(
false);
128 unsigned int iSize(0);
130 ::std::vector< unsigned char > UsedIDs(0);
141 iSize = (*ba).size();
144 BitVector.resize(iSize);
147 for (x = 0; x < iSize; x++)
150 BitVector[x] = (*ba)[x];
158 #ifdef __OETCS_DF_LANGUAGE_DEBUG_OUTPUT__
160 ::std::cout <<
"CBaliseDeviceIn::HasNewTelegram() bits in balise reader: ";
161 for (decltype (BitVector.begin()) lb = BitVector.begin(); lb != BitVector.end(); lb++)
163 ::std::cout << *lb <<
"," << ::std::flush;
166 ::std::cout << ::std::endl;
167 ::std::cout <<
"# bits: "<< BitVector.size() << ::std::endl;
168 #endif // __OETCS_DF_LANGUAGE_DEBUG_OUTPUT__
174 UsedIDs = *(*t) << BitVector;
226 const int BYTES_TO_COPY(iBits / 8 + (iBits % 8 == 0 ? 0 : 1));
231 if (BYTES_TO_COPY <= Bytes.size())
237 for (by = 0; by < BYTES_TO_COPY; by++)
240 for (bi = 0; bi < 8 && bi + by * 8 < iBits; bi++)
243 Bits[bi + by * 8] = (Bytes[by] & (1 << bi)) == 0 ?
false :
true;
286 :m_bUsePlatformSpecific(bUsePS),
288 m_Telegrams(Telegrams),
293 if (m_bUsePlatformSpecific)
298 m_pProxy = new ::oETCS::DF::IBaliseDeviceOut(::oETCS::DF::IBaliseDeviceOut::staticInterfaceName(),
"/oETCS/BaliseDeviceOut", QDBusConnection::sessionBus());
301 if (not m_pProxy->isValid())
304 ::std::cerr <<
"::oETCS::DF::CBaliseDeviceOut had a problem with D-Bus connection: " << m_pProxy->lastError().message().toStdString() << ::std::endl;
316 QObject::connect(m_pProxy, SIGNAL(Error(
const QString &)),
this, SLOT(Error(
const QString&)));
324 catch (const ::std::bad_alloc& Exception)
360 QDBusPendingReply<> AsyncReply;
361 ::std::vector< bool > BitVector;
362 ::std::string ErrorMessage;
363 unsigned int iSize(0);
412 iSize = BitVector.size();
415 BitArray.resize(iSize);
418 for (x = 0; x < iSize; x++)
421 BitArray[x] = BitVector[x];
426 AsyncReply =
m_pProxy->SendTelegram(BitArray);
429 AsyncReply.waitForFinished();
432 if (not AsyncReply.isValid())
435 throw (::
oETCS::DF::Error::CInternal(
"error while calling remote method SendTelegram() -> " + AsyncReply.error().message().toStdString()));
470 m_bActivation(
false),
471 m_bUsePlatformSpecific(bUsePS),
477 if (m_bUsePlatformSpecific)
482 m_pProxy = new ::oETCS::DF::IEmergencyBrake(::oETCS::DF::IEmergencyBrake::staticInterfaceName(),
"/oETCS/EmergencyBrake", QDBusConnection::sessionBus());
485 if (not m_pProxy->isValid())
488 ::std::cerr <<
"::oETCS::DF::CEmergencyBrake had a problem with D-Bus connection: " << m_pProxy->lastError().message().toStdString() << ::std::endl;
500 QObject::connect(m_pProxy, SIGNAL(Error(
const QString&)),
this, SLOT(Error(
const QString&)));
508 catch (const ::std::bad_alloc& Exception)
542 QDBusPendingReply<> AsyncReply;
543 ::std::string ErrorMessage;
586 AsyncReply.waitForFinished();
589 if (not AsyncReply.isValid())
592 throw (::
oETCS::DF::Error::CInternal(
"error while calling remote method SetActivation() -> " + AsyncReply.error().message().toStdString()));
625 m_AbsolutePosition(0),
627 m_bUsePlatformSpecific(bUsePS),
633 if (m_bUsePlatformSpecific)
638 m_pProxy = new ::oETCS::DF::IOdometer(::oETCS::DF::IOdometer::staticInterfaceName(),
"/oETCS/Odometer", QDBusConnection::sessionBus());
641 if (not m_pProxy->isValid())
644 ::std::cerr <<
"::oETCS::DF::COdometer had a problem with D-Bus connection: " << m_pProxy->lastError().message().toStdString() << ::std::endl;
656 QObject::connect(m_pProxy, SIGNAL(Error(
const QString&)),
this, SLOT(Error(
const QString&)));
664 catch (const ::std::bad_alloc& Exception)
698 double dVelocity(0.0);
699 double dAbsolutePosition(0.0);
700 QDBusPendingReply<double> AsyncReply;
701 ::std::string ErrorMessage;
743 AsyncReply =
m_pProxy->GetVelocity();
746 AsyncReply.waitForFinished();
749 if (not AsyncReply.isValid())
752 throw (::
oETCS::DF::Error::CInternal(
"error while calling remote method GetVelocity() -> " + AsyncReply.error().message().toStdString()));
757 dVelocity = AsyncReply.value();
761 AsyncReply =
m_pProxy->GetAbsolutePosition();
764 AsyncReply.waitForFinished();
767 if (not AsyncReply.isValid())
775 dAbsolutePosition = AsyncReply.value();
790 **p = dAbsolutePosition;
823 m_dBrakeIntensity(0.0),
824 m_bUsePlatformSpecific(bUsePS),
830 if (m_bUsePlatformSpecific)
835 m_pProxy = new ::oETCS::DF::IServiceBrake(::oETCS::DF::IServiceBrake::staticInterfaceName(),
"/oETCS/ServiceBrake", QDBusConnection::sessionBus());
838 if (not m_pProxy->isValid())
841 ::std::cerr <<
"::oETCS::DF::CServiceBrake had a problem with D-Bus connection: " << m_pProxy->lastError().message().toStdString() << ::std::endl;
853 QObject::connect(m_pProxy, SIGNAL(Error(
const QString&)),
this, SLOT(Error(
const QString&)));
862 catch (const ::std::bad_alloc& Exception)
896 QDBusPendingReply<> AsyncReply;
897 ::std::string ErrorMessage;
940 AsyncReply.waitForFinished();
943 if (not AsyncReply.isValid())
946 throw (::
oETCS::DF::Error::CInternal(
"error while calling remote method SetIntensity() -> " + AsyncReply.error().message().toStdString()));