1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-02 06:04:39 -04:00

AMBE feature: cleanup of AMBE API support in Instance

This commit is contained in:
f4exb
2022-05-24 23:36:04 +02:00
parent 8885864e79
commit bd4c633e9d
27 changed files with 44 additions and 5564 deletions
-179
View File
@@ -51,9 +51,6 @@
#include "SWGDeviceListItem.h"
#include "SWGAudioDevices.h"
#include "SWGLocationInformation.h"
#include "SWGDVSerialDevices.h"
#include "SWGDVSerialDevice.h"
#include "SWGAMBEDevices.h"
#include "SWGPresets.h"
#include "SWGPresetGroup.h"
#include "SWGPresetItem.h"
@@ -753,182 +750,6 @@ int WebAPIAdapter::instanceLocationPut(
return 200;
}
int WebAPIAdapter::instanceDVSerialGet(
SWGSDRangel::SWGDVSerialDevices& response,
SWGSDRangel::SWGErrorResponse& error)
{
(void) error;
DSPEngine *dspEngine = DSPEngine::instance();
response.init();
std::vector<std::string> deviceNames;
dspEngine->getDVSerialNames(deviceNames);
response.setNbDevices((int) deviceNames.size());
QList<SWGSDRangel::SWGDVSerialDevice*> *deviceNamesList = response.getDvSerialDevices();
std::vector<std::string>::iterator it = deviceNames.begin();
while (it != deviceNames.end())
{
deviceNamesList->append(new SWGSDRangel::SWGDVSerialDevice);
deviceNamesList->back()->init();
*deviceNamesList->back()->getDeviceName() = QString::fromStdString(*it);
++it;
}
return 200;
}
int WebAPIAdapter::instanceDVSerialPatch(
bool dvserial,
SWGSDRangel::SWGDVSerialDevices& response,
SWGSDRangel::SWGErrorResponse& error)
{
(void) error;
DSPEngine *dspEngine = DSPEngine::instance();
dspEngine->setDVSerialSupport(dvserial);
MainCore::MsgDVSerial *msg = MainCore::MsgDVSerial::create(dvserial);
m_mainCore->m_mainMessageQueue->push(msg);
response.init();
if (dvserial)
{
std::vector<std::string> deviceNames;
dspEngine->getDVSerialNames(deviceNames);
response.setNbDevices((int) deviceNames.size());
QList<SWGSDRangel::SWGDVSerialDevice*> *deviceNamesList = response.getDvSerialDevices();
std::vector<std::string>::iterator it = deviceNames.begin();
while (it != deviceNames.end())
{
deviceNamesList->append(new SWGSDRangel::SWGDVSerialDevice);
deviceNamesList->back()->init();
*deviceNamesList->back()->getDeviceName() = QString::fromStdString(*it);
++it;
}
}
else
{
response.setNbDevices(0);
}
return 200;
}
int WebAPIAdapter::instanceAMBESerialGet(
SWGSDRangel::SWGDVSerialDevices& response,
SWGSDRangel::SWGErrorResponse& error)
{
(void) error;
DSPEngine *dspEngine = DSPEngine::instance();
response.init();
std::vector<std::string> deviceNames;
std::vector<QString> qDeviceNames;
dspEngine->getAMBEEngine()->scan(qDeviceNames);
for (std::vector<QString>::const_iterator it = qDeviceNames.begin(); it != qDeviceNames.end(); ++it) {
deviceNames.push_back(it->toStdString());
}
response.setNbDevices((int) deviceNames.size());
QList<SWGSDRangel::SWGDVSerialDevice*> *deviceNamesList = response.getDvSerialDevices();
std::vector<std::string>::iterator it = deviceNames.begin();
while (it != deviceNames.end())
{
deviceNamesList->append(new SWGSDRangel::SWGDVSerialDevice);
deviceNamesList->back()->init();
*deviceNamesList->back()->getDeviceName() = QString::fromStdString(*it);
++it;
}
return 200;
}
int WebAPIAdapter::instanceAMBEDevicesGet(
SWGSDRangel::SWGAMBEDevices& response,
SWGSDRangel::SWGErrorResponse& error)
{
(void) error;
DSPEngine *dspEngine = DSPEngine::instance();
response.init();
std::vector<std::string> deviceNames;
dspEngine->getDVSerialNames(deviceNames);
response.setNbDevices((int) deviceNames.size());
QList<SWGSDRangel::SWGAMBEDevice*> *deviceNamesList = response.getAmbeDevices();
std::vector<std::string>::iterator it = deviceNames.begin();
while (it != deviceNames.end())
{
deviceNamesList->append(new SWGSDRangel::SWGAMBEDevice);
deviceNamesList->back()->init();
*deviceNamesList->back()->getDeviceRef() = QString::fromStdString(*it);
deviceNamesList->back()->setDelete(0);
++it;
}
return 200;
}
int WebAPIAdapter::instanceAMBEDevicesDelete(
SWGSDRangel::SWGSuccessResponse& response,
SWGSDRangel::SWGErrorResponse& error)
{
(void) error;
DSPEngine *dspEngine = DSPEngine::instance();
dspEngine->getAMBEEngine()->releaseAll();
response.init();
*response.getMessage() = QString("All AMBE devices released");
return 200;
}
int WebAPIAdapter::instanceAMBEDevicesPut(
SWGSDRangel::SWGAMBEDevices& query,
SWGSDRangel::SWGAMBEDevices& response,
SWGSDRangel::SWGErrorResponse& error)
{
DSPEngine *dspEngine = DSPEngine::instance();
dspEngine->getAMBEEngine()->releaseAll();
QList<SWGSDRangel::SWGAMBEDevice *> *ambeList = query.getAmbeDevices();
for (QList<SWGSDRangel::SWGAMBEDevice *>::const_iterator it = ambeList->begin(); it != ambeList->end(); ++it) {
dspEngine->getAMBEEngine()->registerController((*it)->getDeviceRef()->toStdString());
}
instanceAMBEDevicesGet(response, error);
return 200;
}
int WebAPIAdapter::instanceAMBEDevicesPatch(
SWGSDRangel::SWGAMBEDevices& query,
SWGSDRangel::SWGAMBEDevices& response,
SWGSDRangel::SWGErrorResponse& error)
{
DSPEngine *dspEngine = DSPEngine::instance();
QList<SWGSDRangel::SWGAMBEDevice *> *ambeList = query.getAmbeDevices();
for (QList<SWGSDRangel::SWGAMBEDevice *>::const_iterator it = ambeList->begin(); it != ambeList->end(); ++it)
{
if ((*it)->getDelete()) {
dspEngine->getAMBEEngine()->releaseController((*it)->getDeviceRef()->toStdString());
} else {
dspEngine->getAMBEEngine()->registerController((*it)->getDeviceRef()->toStdString());
}
}
instanceAMBEDevicesGet(response, error);
return 200;
}
int WebAPIAdapter::instancePresetsGet(
SWGSDRangel::SWGPresets& response,
SWGSDRangel::SWGErrorResponse& error)