From 4a58ffe9a80bf04a31ee2b88e42bcc60c0ce7fa5 Mon Sep 17 00:00:00 2001 From: nasicurious Date: Tue, 11 Jan 2022 16:51:57 +0330 Subject: [PATCH] Exception Whose occur stop socat is solved --- Servo/include/ServoController.h | 16 ++++++++-------- Servo/src/ModbusMaster.cpp | 3 ++- Test/MainWindow.cpp | 1 + 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Servo/include/ServoController.h b/Servo/include/ServoController.h index b0b712f..d2915ce 100644 --- a/Servo/include/ServoController.h +++ b/Servo/include/ServoController.h @@ -11,14 +11,14 @@ private: const int SRV_START_ANGLE_INT_PART_REG = 2000; const int SRV_STOP_ANGLE_INT_PART_REG = 2001; const int SRV_AZIMUTH_SPEED_REG = 2002; - const int SRV_APPLY_SETTING_REG = 2004; - const int SRV_START_STOP_REG = 2005; - const int SRV_ZERO_OFFSET_ANGLE = 2007; - const int SRV_START_ANGLE_FRAC_PART_REG = 2010; - const int SRV_STOP_ANGLE_FRAC_PART_REG = 2011; - const int SRV_CALIBRATE_REG = 2013; - const int SRV_ENABLE_DRIVE_REG = 2017; - const int SRV_AZIMUTH_REG = 2030; + const int SRV_APPLY_SETTING_REG = 2003;//2004; + const int SRV_START_STOP_REG = 2004 ;//2005; + const int SRV_ZERO_OFFSET_ANGLE =2005;// 2007; + const int SRV_START_ANGLE_FRAC_PART_REG = 2006 ;//2010; + const int SRV_STOP_ANGLE_FRAC_PART_REG = 2007; // 2011; + const int SRV_CALIBRATE_REG = 2008 ;//2013; + const int SRV_ENABLE_DRIVE_REG =2009;// 2017; + const int SRV_AZIMUTH_REG = 2010; //2030; const double SRV_ANGLE_FACTOR = 100.0; const double SRV_SPEED_FACTOR = 1000.0; diff --git a/Servo/src/ModbusMaster.cpp b/Servo/src/ModbusMaster.cpp index 5cffa40..9c7bb3c 100644 --- a/Servo/src/ModbusMaster.cpp +++ b/Servo/src/ModbusMaster.cpp @@ -20,7 +20,7 @@ void ModbusMaster::init(ExpConfig& expConfig) connect(_modbusDevice, &QModbusClient::errorOccurred, [this](QModbusDevice::Error) { _initialized = false; - throw ServoException(_modbusDevice->errorString()); + connectionStateChanged(QModbusDevice::UnconnectedState); }); connect(_modbusDevice, @@ -46,6 +46,7 @@ void ModbusMaster::init(ExpConfig& expConfig) /*************************************************************************************************/ void ModbusMaster::connectionStateChanged(QModbusDevice::State state) { + if(state == QModbusDevice::UnconnectedState) { _connected = false; diff --git a/Test/MainWindow.cpp b/Test/MainWindow.cpp index 68b519b..6e9c4c4 100644 --- a/Test/MainWindow.cpp +++ b/Test/MainWindow.cpp @@ -217,6 +217,7 @@ void MainWindow::handleGetRequestFromServo() ui->showStopAngle->setText(QString::number(_servoControler.getStopAngle())); ui->showAngleOffset->setText(QString::number(_servoControler.getAngleOffset())); ui->showAzimuth->setText(QString::number(_servoControler.getAzimuth())); + ui->showServoError->setText(""); QThread::sleep(2); } catch(ServoException exp)