mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-17 13:51:47 -05:00
Single DeviceAPI: REST API fixes
This commit is contained in:
parent
89e53cf179
commit
029e559824
@ -43,8 +43,8 @@ public:
|
||||
void removeTxSelection(int tabIndex);
|
||||
int getNbRxSamplingDevices() const { return m_rxEnumeration.size(); }
|
||||
int getNbTxSamplingDevices() const { return m_txEnumeration.size(); }
|
||||
PluginInterface::SamplingDevice getRxSamplingDevice(int deviceIndex) const { return m_rxEnumeration[deviceIndex].m_samplingDevice; }
|
||||
PluginInterface::SamplingDevice getTxSamplingDevice(int deviceIndex) const { return m_txEnumeration[deviceIndex].m_samplingDevice; }
|
||||
const PluginInterface::SamplingDevice* getRxSamplingDevice(int deviceIndex) const { return &m_rxEnumeration[deviceIndex].m_samplingDevice; }
|
||||
const PluginInterface::SamplingDevice* getTxSamplingDevice(int deviceIndex) const { return &m_txEnumeration[deviceIndex].m_samplingDevice; }
|
||||
PluginInterface *getRxPluginInterface(int deviceIndex) { return m_rxEnumeration[deviceIndex].m_pluginInterface; }
|
||||
PluginInterface *getTxPluginInterface(int deviceIndex) { return m_txEnumeration[deviceIndex].m_pluginInterface; }
|
||||
int getFileSourceDeviceIndex() const;
|
||||
|
@ -179,7 +179,7 @@ void MainSettings::renamePresetGroup(const QString& oldGroupName, const QString&
|
||||
}
|
||||
}
|
||||
|
||||
const Preset* MainSettings::getPreset(const QString& groupName, quint64 centerFrequency, const QString& description) const
|
||||
const Preset* MainSettings::getPreset(const QString& groupName, quint64 centerFrequency, const QString& description, const QString& type) const
|
||||
{
|
||||
int nbPresets = getPresetCount();
|
||||
|
||||
@ -189,7 +189,11 @@ const Preset* MainSettings::getPreset(const QString& groupName, quint64 centerFr
|
||||
(getPreset(i)->getCenterFrequency() == centerFrequency) &&
|
||||
(getPreset(i)->getDescription() == description))
|
||||
{
|
||||
return getPreset(i);
|
||||
if (type == "R" && getPreset(i)->isSourcePreset()) {
|
||||
return getPreset(i);
|
||||
} else if (type == "T" && !getPreset(i)->isSourcePreset()) {
|
||||
return getPreset(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
void deletePreset(const Preset* preset);
|
||||
int getPresetCount() const { return m_presets.count(); }
|
||||
const Preset* getPreset(int index) const { return m_presets[index]; }
|
||||
const Preset* getPreset(const QString& groupName, quint64 centerFrequency, const QString& description) const;
|
||||
const Preset* getPreset(const QString& groupName, quint64 centerFrequency, const QString& description, const QString& type) const;
|
||||
void sortPresets();
|
||||
void renamePresetGroup(const QString& oldGroupName, const QString& newGroupName);
|
||||
void deletePresetGroup(const QString& groupName);
|
||||
|
@ -93,11 +93,11 @@ public:
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int instanceDevices(
|
||||
bool tx,
|
||||
int direction,
|
||||
SWGSDRangel::SWGInstanceDevicesResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) tx;
|
||||
(void) direction;
|
||||
(void) response;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
@ -109,11 +109,11 @@ public:
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int instanceChannels(
|
||||
bool tx,
|
||||
int direction,
|
||||
SWGSDRangel::SWGInstanceChannelsResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) tx;
|
||||
(void) direction;
|
||||
(void) response;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
@ -437,11 +437,11 @@ public:
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int instanceDeviceSetPost(
|
||||
bool tx,
|
||||
int direction,
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) tx;
|
||||
(void) direction;
|
||||
(void) response;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
|
@ -212,14 +212,19 @@ void WebAPIRequestMapper::instanceDevicesService(qtwebapp::HttpRequest& request,
|
||||
|
||||
if (request.getMethod() == "GET")
|
||||
{
|
||||
QByteArray txStr = request.getParameter("tx");
|
||||
bool tx = false;
|
||||
QByteArray dirStr = request.getParameter("direction");
|
||||
int direction = 0;
|
||||
|
||||
if (txStr.length() != 0) {
|
||||
tx = !(txStr == "0");
|
||||
if (dirStr.length() != 0)
|
||||
{
|
||||
bool ok;
|
||||
int tmp = dirStr.toInt(&ok);
|
||||
if (ok) {
|
||||
direction = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
int status = m_adapter->instanceDevices(tx, normalResponse, errorResponse);
|
||||
int status = m_adapter->instanceDevices(direction, normalResponse, errorResponse);
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
@ -246,14 +251,19 @@ void WebAPIRequestMapper::instanceChannelsService(qtwebapp::HttpRequest& request
|
||||
|
||||
if (request.getMethod() == "GET")
|
||||
{
|
||||
QByteArray txStr = request.getParameter("tx");
|
||||
bool tx = false;
|
||||
QByteArray dirStr = request.getParameter("direction");
|
||||
int direction = 0;
|
||||
|
||||
if (txStr.length() != 0) {
|
||||
tx = !(txStr == "0");
|
||||
if (dirStr.length() != 0)
|
||||
{
|
||||
bool ok;
|
||||
int tmp = dirStr.toInt(&ok);
|
||||
if (ok) {
|
||||
direction = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
int status = m_adapter->instanceChannels(tx, normalResponse, errorResponse);
|
||||
int status = m_adapter->instanceChannels(direction, normalResponse, errorResponse);
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
@ -962,14 +972,19 @@ void WebAPIRequestMapper::instanceDeviceSetService(qtwebapp::HttpRequest& reques
|
||||
if (request.getMethod() == "POST")
|
||||
{
|
||||
SWGSDRangel::SWGSuccessResponse normalResponse;
|
||||
QByteArray txStr = request.getParameter("tx");
|
||||
bool tx = false;
|
||||
QByteArray dirStr = request.getParameter("direction");
|
||||
int direction = 0;
|
||||
|
||||
if (txStr.length() != 0) {
|
||||
tx = !(txStr == "0");
|
||||
if (dirStr.length() != 0)
|
||||
{
|
||||
bool ok;
|
||||
int tmp = dirStr.toInt(&ok);
|
||||
if (ok) {
|
||||
direction = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
int status = m_adapter->instanceDeviceSetPost(tx, normalResponse, errorResponse);
|
||||
int status = m_adapter->instanceDeviceSetPost(direction, normalResponse, errorResponse);
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
|
@ -63,15 +63,15 @@ void SamplingDeviceControl::setSelectedDeviceIndex(int index)
|
||||
{
|
||||
if (m_rxElseTx)
|
||||
{
|
||||
PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(index);
|
||||
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(index);
|
||||
DeviceEnumerator::instance()->changeRxSelection(m_deviceTabIndex, index);
|
||||
ui->deviceSelectedText->setText(samplingDevice.displayedName);
|
||||
ui->deviceSelectedText->setText(samplingDevice->displayedName);
|
||||
}
|
||||
else
|
||||
{
|
||||
PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(index);
|
||||
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(index);
|
||||
DeviceEnumerator::instance()->changeTxSelection(m_deviceTabIndex, index);
|
||||
ui->deviceSelectedText->setText(samplingDevice.displayedName);
|
||||
ui->deviceSelectedText->setText(samplingDevice->displayedName);
|
||||
}
|
||||
|
||||
m_selectedDeviceIndex = index;
|
||||
|
@ -278,14 +278,14 @@ void MainWindow::addSourceDevice(int deviceIndex)
|
||||
deviceIndex = DeviceEnumerator::instance()->getFileSourceDeviceIndex();
|
||||
}
|
||||
|
||||
PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(deviceIndex);
|
||||
m_deviceUIs.back()->m_deviceAPI->setSamplingDeviceSequence(samplingDevice.sequence);
|
||||
m_deviceUIs.back()->m_deviceAPI->setNbItems(samplingDevice.deviceNbItems);
|
||||
m_deviceUIs.back()->m_deviceAPI->setItemIndex(samplingDevice.deviceItemIndex);
|
||||
m_deviceUIs.back()->m_deviceAPI->setHardwareId(samplingDevice.hardwareId);
|
||||
m_deviceUIs.back()->m_deviceAPI->setSamplingDeviceId(samplingDevice.id);
|
||||
m_deviceUIs.back()->m_deviceAPI->setSamplingDeviceSerial(samplingDevice.serial);
|
||||
m_deviceUIs.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice.displayedName);
|
||||
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(deviceIndex);
|
||||
m_deviceUIs.back()->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
||||
m_deviceUIs.back()->m_deviceAPI->setNbItems(samplingDevice->deviceNbItems);
|
||||
m_deviceUIs.back()->m_deviceAPI->setItemIndex(samplingDevice->deviceItemIndex);
|
||||
m_deviceUIs.back()->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
||||
m_deviceUIs.back()->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
||||
m_deviceUIs.back()->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
||||
m_deviceUIs.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
||||
m_deviceUIs.back()->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(deviceIndex));
|
||||
|
||||
m_deviceUIs.back()->m_samplingDeviceControl->setSelectedDeviceIndex(deviceIndex);
|
||||
@ -349,14 +349,14 @@ void MainWindow::addSinkDevice()
|
||||
|
||||
// create a file sink by default
|
||||
int fileSinkDeviceIndex = DeviceEnumerator::instance()->getFileSinkDeviceIndex();
|
||||
PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(fileSinkDeviceIndex);
|
||||
m_deviceUIs.back()->m_deviceAPI->setSamplingDeviceSequence(samplingDevice.sequence);
|
||||
m_deviceUIs.back()->m_deviceAPI->setNbItems(samplingDevice.deviceNbItems);
|
||||
m_deviceUIs.back()->m_deviceAPI->setItemIndex(samplingDevice.deviceItemIndex);
|
||||
m_deviceUIs.back()->m_deviceAPI->setHardwareId(samplingDevice.hardwareId);
|
||||
m_deviceUIs.back()->m_deviceAPI->setSamplingDeviceId(samplingDevice.id);
|
||||
m_deviceUIs.back()->m_deviceAPI->setSamplingDeviceSerial(samplingDevice.serial);
|
||||
m_deviceUIs.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice.displayedName);
|
||||
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(fileSinkDeviceIndex);
|
||||
m_deviceUIs.back()->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
||||
m_deviceUIs.back()->m_deviceAPI->setNbItems(samplingDevice->deviceNbItems);
|
||||
m_deviceUIs.back()->m_deviceAPI->setItemIndex(samplingDevice->deviceItemIndex);
|
||||
m_deviceUIs.back()->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
||||
m_deviceUIs.back()->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
||||
m_deviceUIs.back()->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
||||
m_deviceUIs.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
||||
m_deviceUIs.back()->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(fileSinkDeviceIndex));
|
||||
|
||||
m_deviceUIs.back()->m_samplingDeviceControl->setSelectedDeviceIndex(fileSinkDeviceIndex);
|
||||
@ -795,12 +795,13 @@ bool MainWindow::handleMessage(const Message& cmd)
|
||||
else if (MsgAddDeviceSet::match(cmd))
|
||||
{
|
||||
MsgAddDeviceSet& notif = (MsgAddDeviceSet&) cmd;
|
||||
int direction = notif.getDirection();
|
||||
|
||||
if (notif.isTx()) {
|
||||
if (direction == 1) { // Single stream Tx
|
||||
addSinkDevice();
|
||||
} else {
|
||||
} else if (direction == 0) { // Single stream Rx
|
||||
addSourceDevice(-1); // create with file source device by default
|
||||
}
|
||||
} // other device types not (yet) supported
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1506,15 +1507,15 @@ void MainWindow::sampleSourceChanged()
|
||||
deviceUI->m_deviceAPI->getSampleSource());
|
||||
deviceUI->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
|
||||
|
||||
PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(
|
||||
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(
|
||||
deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex());
|
||||
deviceUI->m_deviceAPI->setSamplingDeviceSequence(samplingDevice.sequence);
|
||||
deviceUI->m_deviceAPI->setNbItems(samplingDevice.deviceNbItems);
|
||||
deviceUI->m_deviceAPI->setItemIndex(samplingDevice.deviceItemIndex);
|
||||
deviceUI->m_deviceAPI->setHardwareId(samplingDevice.hardwareId);
|
||||
deviceUI->m_deviceAPI->setSamplingDeviceId(samplingDevice.id);
|
||||
deviceUI->m_deviceAPI->setSamplingDeviceSerial(samplingDevice.serial);
|
||||
deviceUI->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice.displayedName);
|
||||
deviceUI->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
||||
deviceUI->m_deviceAPI->setNbItems(samplingDevice->deviceNbItems);
|
||||
deviceUI->m_deviceAPI->setItemIndex(samplingDevice->deviceItemIndex);
|
||||
deviceUI->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
||||
deviceUI->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
||||
deviceUI->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
||||
deviceUI->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
||||
deviceUI->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex()));
|
||||
|
||||
// add to buddies list
|
||||
@ -1569,8 +1570,8 @@ void MainWindow::sampleSourceChanged()
|
||||
|
||||
if (currentSourceTabIndex == 0) // save as default starting device
|
||||
{
|
||||
m_settings.setSourceIndex(samplingDevice.sequence);
|
||||
m_settings.setSourceDeviceId(samplingDevice.id);
|
||||
m_settings.setSourceIndex(samplingDevice->sequence);
|
||||
m_settings.setSourceDeviceId(samplingDevice->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1596,14 +1597,14 @@ void MainWindow::sampleSinkChanged()
|
||||
deviceUI->m_deviceAPI->getSampleSink());
|
||||
deviceUI->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
|
||||
|
||||
PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex());
|
||||
deviceUI->m_deviceAPI->setSamplingDeviceSequence(samplingDevice.sequence);
|
||||
deviceUI->m_deviceAPI->setNbItems(samplingDevice.deviceNbItems);
|
||||
deviceUI->m_deviceAPI->setItemIndex(samplingDevice.deviceItemIndex);
|
||||
deviceUI->m_deviceAPI->setHardwareId(samplingDevice.hardwareId);
|
||||
deviceUI->m_deviceAPI->setSamplingDeviceId(samplingDevice.id);
|
||||
deviceUI->m_deviceAPI->setSamplingDeviceSerial(samplingDevice.serial);
|
||||
deviceUI->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice.displayedName);
|
||||
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex());
|
||||
deviceUI->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
||||
deviceUI->m_deviceAPI->setNbItems(samplingDevice->deviceNbItems);
|
||||
deviceUI->m_deviceAPI->setItemIndex(samplingDevice->deviceItemIndex);
|
||||
deviceUI->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
||||
deviceUI->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
||||
deviceUI->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
||||
deviceUI->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
||||
deviceUI->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex()));
|
||||
|
||||
// add to buddies list
|
||||
|
@ -159,19 +159,19 @@ private:
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
bool isTx() const { return m_tx; }
|
||||
int getDirection() const { return m_direction; }
|
||||
|
||||
static MsgAddDeviceSet* create(bool tx)
|
||||
static MsgAddDeviceSet* create(int direction)
|
||||
{
|
||||
return new MsgAddDeviceSet(tx);
|
||||
return new MsgAddDeviceSet(direction);
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_tx;
|
||||
int m_direction;
|
||||
|
||||
MsgAddDeviceSet(bool tx) :
|
||||
MsgAddDeviceSet(int direction) :
|
||||
Message(),
|
||||
m_tx(tx)
|
||||
m_direction(direction)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
@ -115,28 +115,47 @@ int WebAPIAdapterGUI::instanceDelete(
|
||||
}
|
||||
|
||||
int WebAPIAdapterGUI::instanceDevices(
|
||||
bool tx,
|
||||
int direction,
|
||||
SWGSDRangel::SWGInstanceDevicesResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) error;
|
||||
response.init();
|
||||
int nbSamplingDevices = tx ? DeviceEnumerator::instance()->getNbTxSamplingDevices() : DeviceEnumerator::instance()->getNbRxSamplingDevices();
|
||||
|
||||
int nbSamplingDevices;
|
||||
|
||||
if (direction == 0) { // Single Rx stream device
|
||||
nbSamplingDevices = DeviceEnumerator::instance()->getNbRxSamplingDevices();
|
||||
} else if (direction == 1) { // Single Tx stream device
|
||||
nbSamplingDevices = DeviceEnumerator::instance()->getNbTxSamplingDevices();
|
||||
} else { // not supported
|
||||
nbSamplingDevices = 0;
|
||||
}
|
||||
|
||||
response.setDevicecount(nbSamplingDevices);
|
||||
QList<SWGSDRangel::SWGDeviceListItem*> *devices = response.getDevices();
|
||||
|
||||
for (int i = 0; i < nbSamplingDevices; i++)
|
||||
{
|
||||
PluginInterface::SamplingDevice samplingDevice = tx ? DeviceEnumerator::instance()->getTxSamplingDevice(i) : DeviceEnumerator::instance()->getRxSamplingDevice(i);
|
||||
const PluginInterface::SamplingDevice *samplingDevice = nullptr;
|
||||
|
||||
if (direction == 0) {
|
||||
samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(i);
|
||||
} else if (direction == 1) {
|
||||
samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(i);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
devices->append(new SWGSDRangel::SWGDeviceListItem);
|
||||
devices->back()->init();
|
||||
*devices->back()->getDisplayedName() = samplingDevice.displayedName;
|
||||
*devices->back()->getHwType() = samplingDevice.hardwareId;
|
||||
*devices->back()->getSerial() = samplingDevice.serial;
|
||||
devices->back()->setSequence(samplingDevice.sequence);
|
||||
devices->back()->setDirection((int) samplingDevice.streamType);
|
||||
devices->back()->setDeviceNbStreams(samplingDevice.deviceNbItems);
|
||||
devices->back()->setDeviceSetIndex(samplingDevice.claimed);
|
||||
*devices->back()->getDisplayedName() = samplingDevice->displayedName;
|
||||
*devices->back()->getHwType() = samplingDevice->hardwareId;
|
||||
*devices->back()->getSerial() = samplingDevice->serial;
|
||||
devices->back()->setSequence(samplingDevice->sequence);
|
||||
devices->back()->setDirection((int) samplingDevice->streamType);
|
||||
devices->back()->setDeviceNbStreams(samplingDevice->deviceNbItems);
|
||||
devices->back()->setDeviceSetIndex(samplingDevice->claimed);
|
||||
devices->back()->setIndex(i);
|
||||
}
|
||||
|
||||
@ -144,14 +163,31 @@ int WebAPIAdapterGUI::instanceDevices(
|
||||
}
|
||||
|
||||
int WebAPIAdapterGUI::instanceChannels(
|
||||
bool tx,
|
||||
int direction,
|
||||
SWGSDRangel::SWGInstanceChannelsResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) error;
|
||||
response.init();
|
||||
PluginAPI::ChannelRegistrations *channelRegistrations = tx ? m_mainWindow.m_pluginManager->getTxChannelRegistrations() : m_mainWindow.m_pluginManager->getRxChannelRegistrations();
|
||||
int nbChannelDevices = channelRegistrations->size();
|
||||
PluginAPI::ChannelRegistrations *channelRegistrations;
|
||||
int nbChannelDevices;
|
||||
|
||||
if (direction == 0) // Single sink (Rx) channel
|
||||
{
|
||||
channelRegistrations = m_mainWindow.m_pluginManager->getRxChannelRegistrations();
|
||||
nbChannelDevices = channelRegistrations->size();
|
||||
}
|
||||
else if (direction == 1) // Single source (Tx) channel
|
||||
{
|
||||
channelRegistrations = m_mainWindow.m_pluginManager->getTxChannelRegistrations();
|
||||
nbChannelDevices = channelRegistrations->size();
|
||||
}
|
||||
else // not supported
|
||||
{
|
||||
channelRegistrations = nullptr;
|
||||
nbChannelDevices = 0;
|
||||
}
|
||||
|
||||
response.setChannelcount(nbChannelDevices);
|
||||
QList<SWGSDRangel::SWGChannelListItem*> *channels = response.getChannels();
|
||||
|
||||
@ -163,7 +199,7 @@ int WebAPIAdapterGUI::instanceChannels(
|
||||
const PluginDescriptor& pluginDescriptor = channelInterface->getPluginDescriptor();
|
||||
*channels->back()->getVersion() = pluginDescriptor.version;
|
||||
*channels->back()->getName() = pluginDescriptor.displayedName;
|
||||
channels->back()->setDirection(tx ? 1 : 0);
|
||||
channels->back()->setDirection(direction);
|
||||
*channels->back()->getIdUri() = channelRegistrations->at(i).m_channelIdURI;
|
||||
*channels->back()->getId() = channelRegistrations->at(i).m_channelId;
|
||||
channels->back()->setIndex(i);
|
||||
@ -655,15 +691,17 @@ int WebAPIAdapterGUI::instancePresetPatch(
|
||||
|
||||
const Preset *selectedPreset = m_mainWindow.m_settings.getPreset(*presetIdentifier->getGroupName(),
|
||||
presetIdentifier->getCenterFrequency(),
|
||||
*presetIdentifier->getName());
|
||||
*presetIdentifier->getName(),
|
||||
*presetIdentifier->getType());
|
||||
|
||||
if (selectedPreset == 0)
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("There is no preset [%1, %2, %3]")
|
||||
*error.getMessage() = QString("There is no preset [%1, %2, %3 %4]")
|
||||
.arg(*presetIdentifier->getGroupName())
|
||||
.arg(presetIdentifier->getCenterFrequency())
|
||||
.arg(*presetIdentifier->getName());
|
||||
.arg(*presetIdentifier->getName())
|
||||
.arg(*presetIdentifier->getType());
|
||||
return 404;
|
||||
}
|
||||
|
||||
@ -713,15 +751,17 @@ int WebAPIAdapterGUI::instancePresetPut(
|
||||
|
||||
const Preset *selectedPreset = m_mainWindow.m_settings.getPreset(*presetIdentifier->getGroupName(),
|
||||
presetIdentifier->getCenterFrequency(),
|
||||
*presetIdentifier->getName());
|
||||
*presetIdentifier->getName(),
|
||||
*presetIdentifier->getType());
|
||||
|
||||
if (selectedPreset == 0)
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("There is no preset [%1, %2, %3]")
|
||||
*error.getMessage() = QString("There is no preset [%1, %2, %3 %4]")
|
||||
.arg(*presetIdentifier->getGroupName())
|
||||
.arg(presetIdentifier->getCenterFrequency())
|
||||
.arg(*presetIdentifier->getName());
|
||||
.arg(*presetIdentifier->getName())
|
||||
.arg(*presetIdentifier->getType());
|
||||
return 404;
|
||||
}
|
||||
else // update existing preset
|
||||
@ -786,7 +826,8 @@ int WebAPIAdapterGUI::instancePresetPost(
|
||||
|
||||
const Preset *selectedPreset = m_mainWindow.m_settings.getPreset(*presetIdentifier->getGroupName(),
|
||||
deviceCenterFrequency,
|
||||
*presetIdentifier->getName());
|
||||
*presetIdentifier->getName(),
|
||||
*presetIdentifier->getType());
|
||||
|
||||
if (selectedPreset == 0) // save on a new preset
|
||||
{
|
||||
@ -795,10 +836,11 @@ int WebAPIAdapterGUI::instancePresetPost(
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("Preset already exists [%1, %2, %3]")
|
||||
*error.getMessage() = QString("Preset already exists [%1, %2, %3 %4]")
|
||||
.arg(*presetIdentifier->getGroupName())
|
||||
.arg(deviceCenterFrequency)
|
||||
.arg(*presetIdentifier->getName());
|
||||
.arg(*presetIdentifier->getName())
|
||||
.arg(*presetIdentifier->getType());
|
||||
return 409;
|
||||
}
|
||||
|
||||
@ -820,14 +862,16 @@ int WebAPIAdapterGUI::instancePresetDelete(
|
||||
{
|
||||
const Preset *selectedPreset = m_mainWindow.m_settings.getPreset(*response.getGroupName(),
|
||||
response.getCenterFrequency(),
|
||||
*response.getName());
|
||||
*response.getName(),
|
||||
*response.getType());
|
||||
|
||||
if (selectedPreset == 0)
|
||||
{
|
||||
*error.getMessage() = QString("There is no preset [%1, %2, %3]")
|
||||
*error.getMessage() = QString("There is no preset [%1, %2, %3 %4]")
|
||||
.arg(*response.getGroupName())
|
||||
.arg(response.getCenterFrequency())
|
||||
.arg(*response.getName());
|
||||
.arg(*response.getName())
|
||||
.arg(*response.getType());
|
||||
return 404;
|
||||
}
|
||||
|
||||
@ -852,12 +896,12 @@ int WebAPIAdapterGUI::instanceDeviceSetsGet(
|
||||
}
|
||||
|
||||
int WebAPIAdapterGUI::instanceDeviceSetPost(
|
||||
bool tx,
|
||||
int direction,
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) error;
|
||||
MainWindow::MsgAddDeviceSet *msg = MainWindow::MsgAddDeviceSet::create(tx);
|
||||
MainWindow::MsgAddDeviceSet *msg = MainWindow::MsgAddDeviceSet::create(direction);
|
||||
m_mainWindow.m_inputMessageQueue.push(msg);
|
||||
|
||||
response.init();
|
||||
@ -972,34 +1016,40 @@ int WebAPIAdapterGUI::devicesetDevicePut(
|
||||
for (int i = 0; i < nbSamplingDevices; i++)
|
||||
{
|
||||
int tx;
|
||||
const PluginInterface::SamplingDevice *samplingDevice;
|
||||
|
||||
if (query.getDirection() == 0) {
|
||||
if (query.getDirection() == 0)
|
||||
{
|
||||
tx = 0;
|
||||
} else if (query.getDirection() == 1) {
|
||||
samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(i);
|
||||
}
|
||||
else if (query.getDirection() == 1)
|
||||
{
|
||||
tx = 1;
|
||||
} else {
|
||||
samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
continue; // TODO: any device (2) not supported yet
|
||||
}
|
||||
|
||||
PluginInterface::SamplingDevice samplingDevice = query.getDirection() == 0 ? DeviceEnumerator::instance()->getRxSamplingDevice(i) : DeviceEnumerator::instance()->getTxSamplingDevice(i);
|
||||
|
||||
if (query.getDisplayedName() && (*query.getDisplayedName() != samplingDevice.displayedName)) {
|
||||
if (query.getDisplayedName() && (*query.getDisplayedName() != samplingDevice->displayedName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (query.getHwType() && (*query.getHwType() != samplingDevice.hardwareId)) {
|
||||
if (query.getHwType() && (*query.getHwType() != samplingDevice->hardwareId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((query.getSequence() >= 0) && (query.getSequence() != samplingDevice.sequence)) {
|
||||
if ((query.getSequence() >= 0) && (query.getSequence() != samplingDevice->sequence)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (query.getSerial() && (*query.getSerial() != samplingDevice.serial)) {
|
||||
if (query.getSerial() && (*query.getSerial() != samplingDevice->serial)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((query.getDeviceStreamIndex() >= 0) && (query.getDeviceStreamIndex() != samplingDevice.deviceItemIndex)) {
|
||||
if ((query.getDeviceStreamIndex() >= 0) && (query.getDeviceStreamIndex() != samplingDevice->deviceItemIndex)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1007,13 +1057,13 @@ int WebAPIAdapterGUI::devicesetDevicePut(
|
||||
m_mainWindow.m_inputMessageQueue.push(msg);
|
||||
|
||||
response.init();
|
||||
*response.getDisplayedName() = samplingDevice.displayedName;
|
||||
*response.getHwType() = samplingDevice.hardwareId;
|
||||
*response.getSerial() = samplingDevice.serial;
|
||||
response.setSequence(samplingDevice.sequence);
|
||||
*response.getDisplayedName() = samplingDevice->displayedName;
|
||||
*response.getHwType() = samplingDevice->hardwareId;
|
||||
*response.getSerial() = samplingDevice->serial;
|
||||
response.setSequence(samplingDevice->sequence);
|
||||
response.setDirection(tx);
|
||||
response.setDeviceNbStreams(samplingDevice.deviceNbItems);
|
||||
response.setDeviceStreamIndex(samplingDevice.deviceItemIndex);
|
||||
response.setDeviceNbStreams(samplingDevice->deviceNbItems);
|
||||
response.setDeviceStreamIndex(samplingDevice->deviceItemIndex);
|
||||
response.setDeviceSetIndex(deviceSetIndex);
|
||||
response.setIndex(i);
|
||||
|
||||
|
@ -42,12 +42,12 @@ public:
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceDevices(
|
||||
bool tx,
|
||||
int direction,
|
||||
SWGSDRangel::SWGInstanceDevicesResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceChannels(
|
||||
bool tx,
|
||||
int direction,
|
||||
SWGSDRangel::SWGInstanceChannelsResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
@ -135,7 +135,7 @@ public:
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceDeviceSetPost(
|
||||
bool tx,
|
||||
int direction,
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
|
@ -142,12 +142,13 @@ bool MainCore::handleMessage(const Message& cmd)
|
||||
else if (MsgAddDeviceSet::match(cmd))
|
||||
{
|
||||
MsgAddDeviceSet& notif = (MsgAddDeviceSet&) cmd;
|
||||
int direction = notif.getDirection();
|
||||
|
||||
if (notif.isTx()) {
|
||||
if (direction == 1) { // Single stream Tx
|
||||
addSinkDevice();
|
||||
} else {
|
||||
} else if (direction == 0) { // Single stream Rx
|
||||
addSourceDevice();
|
||||
}
|
||||
} // device type not (yet) supported
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -283,14 +284,14 @@ void MainCore::addSinkDevice()
|
||||
|
||||
// create a file sink by default
|
||||
int fileSinkDeviceIndex = DeviceEnumerator::instance()->getFileSinkDeviceIndex();
|
||||
PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(fileSinkDeviceIndex);
|
||||
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSequence(samplingDevice.sequence);
|
||||
m_deviceSets.back()->m_deviceAPI->setNbItems(samplingDevice.deviceNbItems);
|
||||
m_deviceSets.back()->m_deviceAPI->setItemIndex(samplingDevice.deviceItemIndex);
|
||||
m_deviceSets.back()->m_deviceAPI->setHardwareId(samplingDevice.hardwareId);
|
||||
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceId(samplingDevice.id);
|
||||
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSerial(samplingDevice.serial);
|
||||
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice.displayedName);
|
||||
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(fileSinkDeviceIndex);
|
||||
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
||||
m_deviceSets.back()->m_deviceAPI->setNbItems(samplingDevice->deviceNbItems);
|
||||
m_deviceSets.back()->m_deviceAPI->setItemIndex(samplingDevice->deviceItemIndex);
|
||||
m_deviceSets.back()->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
||||
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
||||
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
||||
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
||||
m_deviceSets.back()->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(fileSinkDeviceIndex));
|
||||
|
||||
// delete previous plugin instance
|
||||
@ -323,14 +324,14 @@ void MainCore::addSourceDevice()
|
||||
|
||||
// Create a file source instance by default
|
||||
int fileSourceDeviceIndex = DeviceEnumerator::instance()->getFileSourceDeviceIndex();
|
||||
PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(fileSourceDeviceIndex);
|
||||
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSequence(samplingDevice.sequence);
|
||||
m_deviceSets.back()->m_deviceAPI->setNbItems(samplingDevice.deviceNbItems);
|
||||
m_deviceSets.back()->m_deviceAPI->setItemIndex(samplingDevice.deviceItemIndex);
|
||||
m_deviceSets.back()->m_deviceAPI->setHardwareId(samplingDevice.hardwareId);
|
||||
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceId(samplingDevice.id);
|
||||
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSerial(samplingDevice.serial);
|
||||
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice.displayedName);
|
||||
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(fileSourceDeviceIndex);
|
||||
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
||||
m_deviceSets.back()->m_deviceAPI->setNbItems(samplingDevice->deviceNbItems);
|
||||
m_deviceSets.back()->m_deviceAPI->setItemIndex(samplingDevice->deviceItemIndex);
|
||||
m_deviceSets.back()->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
||||
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
||||
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
||||
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
||||
m_deviceSets.back()->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(fileSourceDeviceIndex));
|
||||
|
||||
DeviceSampleSource *source = m_deviceSets.back()->m_deviceAPI->getPluginInterface()->createSampleSourcePluginInstanceInput(
|
||||
@ -399,14 +400,14 @@ void MainCore::changeSampleSource(int deviceSetIndex, int selectedDeviceIndex)
|
||||
deviceSet->m_deviceAPI->getSampleSource());
|
||||
deviceSet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
|
||||
|
||||
PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(selectedDeviceIndex);
|
||||
deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice.sequence);
|
||||
deviceSet->m_deviceAPI->setNbItems(samplingDevice.deviceNbItems);
|
||||
deviceSet->m_deviceAPI->setItemIndex(samplingDevice.deviceItemIndex);
|
||||
deviceSet->m_deviceAPI->setHardwareId(samplingDevice.hardwareId);
|
||||
deviceSet->m_deviceAPI->setSamplingDeviceId(samplingDevice.id);
|
||||
deviceSet->m_deviceAPI->setSamplingDeviceSerial(samplingDevice.serial);
|
||||
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice.displayedName);
|
||||
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(selectedDeviceIndex);
|
||||
deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
||||
deviceSet->m_deviceAPI->setNbItems(samplingDevice->deviceNbItems);
|
||||
deviceSet->m_deviceAPI->setItemIndex(samplingDevice->deviceItemIndex);
|
||||
deviceSet->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
||||
deviceSet->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
||||
deviceSet->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
||||
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
||||
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(selectedDeviceIndex));
|
||||
|
||||
// add to buddies list
|
||||
@ -467,14 +468,14 @@ void MainCore::changeSampleSink(int deviceSetIndex, int selectedDeviceIndex)
|
||||
deviceSet->m_deviceAPI->getSampleSink());
|
||||
deviceSet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
|
||||
|
||||
PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(selectedDeviceIndex);
|
||||
deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice.sequence);
|
||||
deviceSet->m_deviceAPI->setNbItems(samplingDevice.deviceNbItems);
|
||||
deviceSet->m_deviceAPI->setItemIndex(samplingDevice.deviceItemIndex);
|
||||
deviceSet->m_deviceAPI->setHardwareId(samplingDevice.hardwareId);
|
||||
deviceSet->m_deviceAPI->setSamplingDeviceId(samplingDevice.id);
|
||||
deviceSet->m_deviceAPI->setSamplingDeviceSerial(samplingDevice.serial);
|
||||
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice.displayedName);
|
||||
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(selectedDeviceIndex);
|
||||
deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
||||
deviceSet->m_deviceAPI->setNbItems(samplingDevice->deviceNbItems);
|
||||
deviceSet->m_deviceAPI->setItemIndex(samplingDevice->deviceItemIndex);
|
||||
deviceSet->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
||||
deviceSet->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
||||
deviceSet->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
||||
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
||||
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(selectedDeviceIndex));
|
||||
|
||||
// add to buddies list
|
||||
|
@ -160,19 +160,19 @@ private:
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
bool isTx() const { return m_tx; }
|
||||
int getDirection() const { return m_direction; }
|
||||
|
||||
static MsgAddDeviceSet* create(bool tx)
|
||||
static MsgAddDeviceSet* create(int direction)
|
||||
{
|
||||
return new MsgAddDeviceSet(tx);
|
||||
return new MsgAddDeviceSet(direction);
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_tx;
|
||||
int m_direction;
|
||||
|
||||
MsgAddDeviceSet(bool tx) :
|
||||
MsgAddDeviceSet(int direction) :
|
||||
Message(),
|
||||
m_tx(tx)
|
||||
m_direction(direction)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
@ -116,27 +116,47 @@ int WebAPIAdapterSrv::instanceDelete(
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::instanceDevices(
|
||||
bool tx,
|
||||
int direction,
|
||||
SWGSDRangel::SWGInstanceDevicesResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error __attribute__((unused)))
|
||||
{
|
||||
response.init();
|
||||
int nbSamplingDevices = tx ? DeviceEnumerator::instance()->getNbTxSamplingDevices() : DeviceEnumerator::instance()->getNbRxSamplingDevices();
|
||||
|
||||
int nbSamplingDevices;
|
||||
|
||||
if (direction == 0) { // Single Rx stream device
|
||||
nbSamplingDevices = DeviceEnumerator::instance()->getNbRxSamplingDevices();
|
||||
} else if (direction == 1) { // Single Tx stream device
|
||||
nbSamplingDevices = DeviceEnumerator::instance()->getNbTxSamplingDevices();
|
||||
} else { // not supported
|
||||
nbSamplingDevices = 0;
|
||||
}
|
||||
|
||||
|
||||
response.setDevicecount(nbSamplingDevices);
|
||||
QList<SWGSDRangel::SWGDeviceListItem*> *devices = response.getDevices();
|
||||
|
||||
for (int i = 0; i < nbSamplingDevices; i++)
|
||||
{
|
||||
PluginInterface::SamplingDevice samplingDevice = tx ? DeviceEnumerator::instance()->getTxSamplingDevice(i) : DeviceEnumerator::instance()->getRxSamplingDevice(i);
|
||||
const PluginInterface::SamplingDevice *samplingDevice = nullptr;
|
||||
|
||||
if (direction == 0) {
|
||||
samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(i);
|
||||
} else if (direction == 1) {
|
||||
samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(i);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
devices->append(new SWGSDRangel::SWGDeviceListItem);
|
||||
devices->back()->init();
|
||||
*devices->back()->getDisplayedName() = samplingDevice.displayedName;
|
||||
*devices->back()->getHwType() = samplingDevice.hardwareId;
|
||||
*devices->back()->getSerial() = samplingDevice.serial;
|
||||
devices->back()->setSequence(samplingDevice.sequence);
|
||||
devices->back()->setDirection((int) samplingDevice.streamType);
|
||||
devices->back()->setDeviceNbStreams(samplingDevice.deviceNbItems);
|
||||
devices->back()->setDeviceSetIndex(samplingDevice.claimed);
|
||||
*devices->back()->getDisplayedName() = samplingDevice->displayedName;
|
||||
*devices->back()->getHwType() = samplingDevice->hardwareId;
|
||||
*devices->back()->getSerial() = samplingDevice->serial;
|
||||
devices->back()->setSequence(samplingDevice->sequence);
|
||||
devices->back()->setDirection((int) samplingDevice->streamType);
|
||||
devices->back()->setDeviceNbStreams(samplingDevice->deviceNbItems);
|
||||
devices->back()->setDeviceSetIndex(samplingDevice->claimed);
|
||||
devices->back()->setIndex(i);
|
||||
}
|
||||
|
||||
@ -144,13 +164,30 @@ int WebAPIAdapterSrv::instanceDevices(
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::instanceChannels(
|
||||
bool tx,
|
||||
int direction,
|
||||
SWGSDRangel::SWGInstanceChannelsResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error __attribute__((unused)))
|
||||
{
|
||||
response.init();
|
||||
PluginAPI::ChannelRegistrations *channelRegistrations = tx ? m_mainCore.m_pluginManager->getTxChannelRegistrations() : m_mainCore.m_pluginManager->getRxChannelRegistrations();
|
||||
int nbChannelDevices = channelRegistrations->size();
|
||||
PluginAPI::ChannelRegistrations *channelRegistrations;
|
||||
int nbChannelDevices;
|
||||
|
||||
if (direction == 0) // Single sink (Rx) channel
|
||||
{
|
||||
channelRegistrations = m_mainCore.m_pluginManager->getRxChannelRegistrations();
|
||||
nbChannelDevices = channelRegistrations->size();
|
||||
}
|
||||
else if (direction == 1) // Single source (Tx) channel
|
||||
{
|
||||
channelRegistrations = m_mainCore.m_pluginManager->getTxChannelRegistrations();
|
||||
nbChannelDevices = channelRegistrations->size();
|
||||
}
|
||||
else // not supported
|
||||
{
|
||||
channelRegistrations = nullptr;
|
||||
nbChannelDevices = 0;
|
||||
}
|
||||
|
||||
response.setChannelcount(nbChannelDevices);
|
||||
QList<SWGSDRangel::SWGChannelListItem*> *channels = response.getChannels();
|
||||
|
||||
@ -162,7 +199,7 @@ int WebAPIAdapterSrv::instanceChannels(
|
||||
const PluginDescriptor& pluginDescriptor = channelInterface->getPluginDescriptor();
|
||||
*channels->back()->getVersion() = pluginDescriptor.version;
|
||||
*channels->back()->getName() = pluginDescriptor.displayedName;
|
||||
channels->back()->setDirection(tx ? 1 : 0);
|
||||
channels->back()->setDirection(direction);
|
||||
*channels->back()->getIdUri() = channelRegistrations->at(i).m_channelIdURI;
|
||||
*channels->back()->getId() = channelRegistrations->at(i).m_channelId;
|
||||
channels->back()->setIndex(i);
|
||||
@ -637,15 +674,17 @@ int WebAPIAdapterSrv::instancePresetFilePost(
|
||||
|
||||
const Preset *selectedPreset = m_mainCore.m_settings.getPreset(*presetIdentifier->getGroupName(),
|
||||
presetIdentifier->getCenterFrequency(),
|
||||
*presetIdentifier->getName());
|
||||
*presetIdentifier->getName(),
|
||||
*presetIdentifier->getType());
|
||||
|
||||
if (selectedPreset == 0)
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("There is no preset [%1, %2, %3]")
|
||||
*error.getMessage() = QString("There is no preset [%1, %2, %3, %4]")
|
||||
.arg(*presetIdentifier->getGroupName())
|
||||
.arg(presetIdentifier->getCenterFrequency())
|
||||
.arg(*presetIdentifier->getName());
|
||||
.arg(*presetIdentifier->getName())
|
||||
.arg(*presetIdentifier->getType());
|
||||
return 404;
|
||||
}
|
||||
|
||||
@ -753,15 +792,17 @@ int WebAPIAdapterSrv::instancePresetPatch(
|
||||
|
||||
const Preset *selectedPreset = m_mainCore.m_settings.getPreset(*presetIdentifier->getGroupName(),
|
||||
presetIdentifier->getCenterFrequency(),
|
||||
*presetIdentifier->getName());
|
||||
*presetIdentifier->getName(),
|
||||
*presetIdentifier->getType());
|
||||
|
||||
if (selectedPreset == 0)
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("There is no preset [%1, %2, %3]")
|
||||
*error.getMessage() = QString("There is no preset [%1, %2, %3 %4]")
|
||||
.arg(*presetIdentifier->getGroupName())
|
||||
.arg(presetIdentifier->getCenterFrequency())
|
||||
.arg(*presetIdentifier->getName());
|
||||
.arg(*presetIdentifier->getName())
|
||||
.arg(*presetIdentifier->getType());
|
||||
return 404;
|
||||
}
|
||||
|
||||
@ -811,15 +852,17 @@ int WebAPIAdapterSrv::instancePresetPut(
|
||||
|
||||
const Preset *selectedPreset = m_mainCore.m_settings.getPreset(*presetIdentifier->getGroupName(),
|
||||
presetIdentifier->getCenterFrequency(),
|
||||
*presetIdentifier->getName());
|
||||
*presetIdentifier->getName(),
|
||||
*presetIdentifier->getType());
|
||||
|
||||
if (selectedPreset == 0)
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("There is no preset [%1, %2, %3]")
|
||||
*error.getMessage() = QString("There is no preset [%1, %2, %3 %4]")
|
||||
.arg(*presetIdentifier->getGroupName())
|
||||
.arg(presetIdentifier->getCenterFrequency())
|
||||
.arg(*presetIdentifier->getName());
|
||||
.arg(*presetIdentifier->getName())
|
||||
.arg(*presetIdentifier->getType());
|
||||
return 404;
|
||||
}
|
||||
else // update existing preset
|
||||
@ -887,7 +930,8 @@ int WebAPIAdapterSrv::instancePresetPost(
|
||||
|
||||
const Preset *selectedPreset = m_mainCore.m_settings.getPreset(*presetIdentifier->getGroupName(),
|
||||
deviceCenterFrequency,
|
||||
*presetIdentifier->getName());
|
||||
*presetIdentifier->getName(),
|
||||
*presetIdentifier->getType());
|
||||
|
||||
if (selectedPreset == 0) // save on a new preset
|
||||
{
|
||||
@ -896,10 +940,11 @@ int WebAPIAdapterSrv::instancePresetPost(
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("Preset already exists [%1, %2, %3]")
|
||||
*error.getMessage() = QString("Preset already exists [%1, %2, %3 %4]")
|
||||
.arg(*presetIdentifier->getGroupName())
|
||||
.arg(deviceCenterFrequency)
|
||||
.arg(*presetIdentifier->getName());
|
||||
.arg(*presetIdentifier->getName())
|
||||
.arg(*presetIdentifier->getType());
|
||||
return 409;
|
||||
}
|
||||
|
||||
@ -921,15 +966,17 @@ int WebAPIAdapterSrv::instancePresetDelete(
|
||||
{
|
||||
const Preset *selectedPreset = m_mainCore.m_settings.getPreset(*response.getGroupName(),
|
||||
response.getCenterFrequency(),
|
||||
*response.getName());
|
||||
*response.getName(),
|
||||
*response.getType());
|
||||
|
||||
if (selectedPreset == 0)
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("There is no preset [%1, %2, %3]")
|
||||
*error.getMessage() = QString("There is no preset [%1, %2, %3 %4]")
|
||||
.arg(*response.getGroupName())
|
||||
.arg(response.getCenterFrequency())
|
||||
.arg(*response.getName());
|
||||
.arg(*response.getName())
|
||||
.arg(*response.getType());
|
||||
return 404;
|
||||
}
|
||||
|
||||
@ -953,11 +1000,11 @@ int WebAPIAdapterSrv::instanceDeviceSetsGet(
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::instanceDeviceSetPost(
|
||||
bool tx,
|
||||
int direction,
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error __attribute__((unused)))
|
||||
{
|
||||
MainCore::MsgAddDeviceSet *msg = MainCore::MsgAddDeviceSet::create(tx);
|
||||
MainCore::MsgAddDeviceSet *msg = MainCore::MsgAddDeviceSet::create(direction);
|
||||
m_mainCore.m_inputMessageQueue.push(msg);
|
||||
|
||||
response.init();
|
||||
@ -1055,35 +1102,41 @@ int WebAPIAdapterSrv::devicesetDevicePut(
|
||||
|
||||
for (int i = 0; i < nbSamplingDevices; i++)
|
||||
{
|
||||
int tx;
|
||||
int direction;
|
||||
const PluginInterface::SamplingDevice *samplingDevice;
|
||||
|
||||
if (query.getDirection() == 0) {
|
||||
tx = 0;
|
||||
} else if (query.getDirection() == 1) {
|
||||
tx = 1;
|
||||
} else {
|
||||
if (query.getDirection() == 0)
|
||||
{
|
||||
direction = 0;
|
||||
samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(i);
|
||||
}
|
||||
else if (query.getDirection() == 1)
|
||||
{
|
||||
direction = 1;
|
||||
samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
continue; // TODO: any device (2) not supported yet
|
||||
}
|
||||
|
||||
PluginInterface::SamplingDevice samplingDevice = query.getDirection() == 0 ? DeviceEnumerator::instance()->getRxSamplingDevice(i) : DeviceEnumerator::instance()->getTxSamplingDevice(i);
|
||||
|
||||
if (query.getDisplayedName() && (*query.getDisplayedName() != samplingDevice.displayedName)) {
|
||||
if (query.getDisplayedName() && (*query.getDisplayedName() != samplingDevice->displayedName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (query.getHwType() && (*query.getHwType() != samplingDevice.hardwareId)) {
|
||||
if (query.getHwType() && (*query.getHwType() != samplingDevice->hardwareId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((query.getSequence() >= 0) && (query.getSequence() != samplingDevice.sequence)) {
|
||||
if ((query.getSequence() >= 0) && (query.getSequence() != samplingDevice->sequence)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (query.getSerial() && (*query.getSerial() != samplingDevice.serial)) {
|
||||
if (query.getSerial() && (*query.getSerial() != samplingDevice->serial)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((query.getDeviceStreamIndex() >= 0) && (query.getDeviceStreamIndex() != samplingDevice.deviceItemIndex)) {
|
||||
if ((query.getDeviceStreamIndex() >= 0) && (query.getDeviceStreamIndex() != samplingDevice->deviceItemIndex)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1091,13 +1144,13 @@ int WebAPIAdapterSrv::devicesetDevicePut(
|
||||
m_mainCore.m_inputMessageQueue.push(msg);
|
||||
|
||||
response.init();
|
||||
*response.getDisplayedName() = samplingDevice.displayedName;
|
||||
*response.getHwType() = samplingDevice.hardwareId;
|
||||
*response.getSerial() = samplingDevice.serial;
|
||||
response.setSequence(samplingDevice.sequence);
|
||||
response.setDirection(tx);
|
||||
response.setDeviceNbStreams(samplingDevice.deviceNbItems);
|
||||
response.setDeviceStreamIndex(samplingDevice.deviceItemIndex);
|
||||
*response.getDisplayedName() = samplingDevice->displayedName;
|
||||
*response.getHwType() = samplingDevice->hardwareId;
|
||||
*response.getSerial() = samplingDevice->serial;
|
||||
response.setSequence(samplingDevice->sequence);
|
||||
response.setDirection(direction);
|
||||
response.setDeviceNbStreams(samplingDevice->deviceNbItems);
|
||||
response.setDeviceStreamIndex(samplingDevice->deviceItemIndex);
|
||||
response.setDeviceSetIndex(deviceSetIndex);
|
||||
response.setIndex(i);
|
||||
|
||||
|
@ -42,12 +42,12 @@ public:
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceDevices(
|
||||
bool tx,
|
||||
int direction,
|
||||
SWGSDRangel::SWGInstanceDevicesResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceChannels(
|
||||
bool tx,
|
||||
int direction,
|
||||
SWGSDRangel::SWGInstanceChannelsResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
@ -145,7 +145,7 @@ public:
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceDeviceSetPost(
|
||||
bool tx,
|
||||
int direction,
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user