Added reconnection to CAN and some fixes
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
CanController::CanController(QObject* parent)
|
||||
: QObject{parent}
|
||||
, lastPackageDateTime_(QDateTime::fromMSecsSinceEpoch(0))
|
||||
, reconnectTimer_(new QTimer(this))
|
||||
{
|
||||
setupDrivers();
|
||||
setupDefaultParameters();
|
||||
@@ -50,6 +51,9 @@ CanController::CanController(QObject* parent)
|
||||
updateCanStatusTimer->start(1000);
|
||||
connect(updateCanStatusTimer, &QTimer::timeout, this, &CanController::updateCanStatus);
|
||||
|
||||
reconnectTimer_->start(5000);
|
||||
connect(reconnectTimer_, &QTimer::timeout, this, &CanController::tryConnectCan);
|
||||
|
||||
// auto statusTimer = new QTimer(this);
|
||||
// statusTimer->start(1000);
|
||||
// statusTimer->callOnTimeout([this]
|
||||
@@ -95,6 +99,14 @@ void CanController::disconnectCan()
|
||||
Backend::instance().stopMeasurement();
|
||||
}
|
||||
|
||||
void CanController::tryConnectCan()
|
||||
{
|
||||
if (!isConnected_)
|
||||
{
|
||||
connectCan();
|
||||
}
|
||||
}
|
||||
|
||||
void CanController::switchVkuClosure()
|
||||
{
|
||||
setProperty("isVkuClosed", !isVkuClosed_);
|
||||
@@ -172,6 +184,10 @@ void CanController::sendVkuClosure()
|
||||
void CanController::handlePackage(int index)
|
||||
{
|
||||
lastPackageDateTime_ = QDateTime::currentDateTime();
|
||||
if (isFirstCheck_)
|
||||
{
|
||||
updateCanStatus();
|
||||
}
|
||||
|
||||
auto& backend = Backend::instance();
|
||||
auto message = backend.getTrace()->getMessage(index);
|
||||
@@ -222,15 +238,15 @@ void CanController::showStatus(quint32 status)
|
||||
{
|
||||
QMap<quint32, QString> statusDescriptionMap =
|
||||
{
|
||||
{0x00, tr("Reset")},
|
||||
{0x00, tr("Emergency reset")},
|
||||
{0x01, tr("No incoming messages via CAN interface")},
|
||||
{0x02, tr("Pause after breaking")},
|
||||
{0x03, tr("Waiting for a command for closing")},
|
||||
{0x04, tr("Work via CAN")},
|
||||
{0x05, tr("Work via button signal")},
|
||||
{0x06, tr("Work via CAN or button signal")},
|
||||
{0x03, tr("Pause after emergency")},
|
||||
{0x04, tr("Waiting for command for closure")},
|
||||
{0x05, tr("VKU is closed")},
|
||||
{0x18, tr("Exceeding radiator temperature")},
|
||||
{0x20, tr("Exceeding input voltage")},
|
||||
{0x21, tr("Fault signal")},
|
||||
{0x22, tr("Exceeding maximum current")},
|
||||
{0x23, tr("Exceeding switching current")},
|
||||
{0x25, tr("Voltage 5V is not normal")},
|
||||
|
||||
Reference in New Issue
Block a user