|
|
@ -1,6 +1,5 @@ |
|
|
|
#include "ServoController.h" |
|
|
|
|
|
|
|
|
|
|
|
ServoController::ServoController() |
|
|
|
{ |
|
|
|
} |
|
|
@ -15,7 +14,6 @@ ModbusConfig ServoController::initiateConfig() |
|
|
|
_config.stopBits = QSerialPort::OneStop; |
|
|
|
_config.responseTime = 2000; |
|
|
|
return _config; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
@ -31,6 +29,7 @@ void ServoController::enableDrive() |
|
|
|
apply(); |
|
|
|
} |
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
|
void ServoController::setStartStop(bool start) |
|
|
|
{ |
|
|
|
if(start) |
|
|
@ -57,7 +56,7 @@ void ServoController::setStopAngle(double angle) |
|
|
|
/*************************************************************************************************/ |
|
|
|
void ServoController::setSpeed(double speed) |
|
|
|
{ |
|
|
|
_modbusWrapper.setSingleRegister(SRV_AZIMUTH_SPEED_REG, static_cast<quint16>(speed*SRV_SPEED_FACTOR)); |
|
|
|
_modbusWrapper.setSingleRegister(SRV_AZIMUTH_SPEED_REG, static_cast<quint16>(speed * SRV_SPEED_FACTOR)); |
|
|
|
} |
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
@ -76,7 +75,6 @@ void ServoController::init() |
|
|
|
{ |
|
|
|
_modbusWrapper.init(); |
|
|
|
_modbusWrapper.connectToDevice(initiateConfig()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
@ -100,7 +98,7 @@ void ServoController::resetAzimuth() |
|
|
|
/*************************************************************************************************/ |
|
|
|
void ServoController::fix(double angle) |
|
|
|
{ |
|
|
|
changeMode(angle, angle, 5/6.0); |
|
|
|
changeMode(angle, angle, 5 / 6.0); |
|
|
|
} |
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
@ -112,44 +110,31 @@ void ServoController::sector(double startAngle, double stopAngle, double speed) |
|
|
|
/*************************************************************************************************/ |
|
|
|
double ServoController::getSpeed() |
|
|
|
{ |
|
|
|
double speed; |
|
|
|
QVector<quint16> speedVector; |
|
|
|
speedVector = _modbusWrapper.getHoldingRegister(SRV_AZIMUTH_SPEED_REG,1); |
|
|
|
speed = speedVector[0] / SRV_SPEED_FACTOR; |
|
|
|
return speed; |
|
|
|
auto speedVector = _modbusWrapper.getHoldingRegister(SRV_AZIMUTH_SPEED_REG, 1); |
|
|
|
return (speedVector[0] / SRV_SPEED_FACTOR); |
|
|
|
} |
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
|
double ServoController::getStopAngle() |
|
|
|
{ |
|
|
|
double speed; |
|
|
|
QVector<quint16> speedVector1, speedVector2; |
|
|
|
speedVector1 = _modbusWrapper.getHoldingRegister(SRV_STOP_ANGLE_INT_PART_REG,1); |
|
|
|
speedVector2 = _modbusWrapper.getHoldingRegister(SRV_STOP_ANGLE_FRAC_PART_REG,1); |
|
|
|
speed = (speedVector1[0] + speedVector2[0]) / SRV_ANGLE_FACTOR; |
|
|
|
return speed; |
|
|
|
auto speedVector1 = _modbusWrapper.getHoldingRegister(SRV_STOP_ANGLE_INT_PART_REG, 1); |
|
|
|
auto speedVector2 = _modbusWrapper.getHoldingRegister(SRV_STOP_ANGLE_FRAC_PART_REG, 1); |
|
|
|
return ((speedVector1[0] + speedVector2[0]) / SRV_ANGLE_FACTOR); |
|
|
|
} |
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
|
double ServoController::getStartAngle() |
|
|
|
{ |
|
|
|
double speed; |
|
|
|
QVector<quint16> speedVector1, speedVector2; |
|
|
|
speedVector1 = _modbusWrapper.getHoldingRegister(SRV_START_ANGLE_INT_PART_REG,1); |
|
|
|
speedVector2 = _modbusWrapper.getHoldingRegister(SRV_START_ANGLE_FRAC_PART_REG,1); |
|
|
|
speed = (speedVector1[0] + speedVector2[0]) / SRV_ANGLE_FACTOR; |
|
|
|
return speed; |
|
|
|
auto speedVector1 = _modbusWrapper.getHoldingRegister(SRV_START_ANGLE_INT_PART_REG, 1); |
|
|
|
auto speedVector2 = _modbusWrapper.getHoldingRegister(SRV_START_ANGLE_FRAC_PART_REG, 1); |
|
|
|
return ((speedVector1[0] + speedVector2[0]) / SRV_ANGLE_FACTOR); |
|
|
|
} |
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
|
double ServoController::getAngleOffset() |
|
|
|
{ |
|
|
|
double angleOffset; |
|
|
|
QVector<quint16> angleOffsetVector; |
|
|
|
angleOffsetVector = _modbusWrapper.getHoldingRegister(SRV_ZERO_OFFSET_ANGLE,1); |
|
|
|
angleOffset = angleOffsetVector[0] / SRV_ANGLE_FACTOR; |
|
|
|
return angleOffset; |
|
|
|
|
|
|
|
auto angleOffsetVector = _modbusWrapper.getHoldingRegister(SRV_ZERO_OFFSET_ANGLE, 1); |
|
|
|
return (angleOffsetVector[0] / SRV_ANGLE_FACTOR); |
|
|
|
} |
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
@ -161,13 +146,8 @@ void ServoController::setAngleOffset(double offset) |
|
|
|
/*************************************************************************************************/ |
|
|
|
double ServoController::getAzimuth() |
|
|
|
{ |
|
|
|
double azimuth; |
|
|
|
QVector<quint16> azimuthVector; |
|
|
|
azimuthVector = _modbusWrapper.getHoldingRegister(SRV_AZIMUTH_REG,1); |
|
|
|
azimuth = azimuthVector[0] / SRV_ANGLE_FACTOR; |
|
|
|
return azimuth; |
|
|
|
|
|
|
|
auto azimuthVector = _modbusWrapper.getHoldingRegister(SRV_AZIMUTH_REG,1); |
|
|
|
return (azimuthVector[0] / SRV_ANGLE_FACTOR); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|