1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

REST API: updates for MIMO (5)

This commit is contained in:
f4exb 2019-12-29 06:01:14 +01:00
parent d11f56adb9
commit bbba942eba
4 changed files with 50 additions and 20 deletions

View File

@ -200,9 +200,9 @@ private:
int getDeviceIndex() const { return m_deviceIndex; } int getDeviceIndex() const { return m_deviceIndex; }
int getDeviceType() const { return m_deviceType; } int getDeviceType() const { return m_deviceType; }
static MsgSetDevice* create(int deviceSetIndex, int deviceIndex, bool tx) static MsgSetDevice* create(int deviceSetIndex, int deviceIndex, int deviceType)
{ {
return new MsgSetDevice(deviceSetIndex, deviceIndex, tx); return new MsgSetDevice(deviceSetIndex, deviceIndex, deviceType);
} }
private: private:

View File

@ -1242,26 +1242,15 @@ int WebAPIAdapterGUI::devicesetDevicePut(
for (int i = 0; i < nbSamplingDevices; i++) for (int i = 0; i < nbSamplingDevices; i++)
{ {
int direction;
const PluginInterface::SamplingDevice *samplingDevice; const PluginInterface::SamplingDevice *samplingDevice;
if (query.getDirection() == 0) if (query.getDirection() == 0) {
{
direction = 0;
samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(i); samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(i);
} } else if (query.getDirection() == 1) {
else if (query.getDirection() == 1)
{
direction = 1;
samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(i); samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(i);
} } else if (query.getDirection() == 2) {
else if (query.getDirection() == 2)
{
direction = 2;
samplingDevice = DeviceEnumerator::instance()->getMIMOSamplingDevice(i); samplingDevice = DeviceEnumerator::instance()->getMIMOSamplingDevice(i);
} } else {
else
{
continue; // device not supported continue; // device not supported
} }
@ -1293,7 +1282,7 @@ int WebAPIAdapterGUI::devicesetDevicePut(
*response.getHwType() = samplingDevice->hardwareId; *response.getHwType() = samplingDevice->hardwareId;
*response.getSerial() = samplingDevice->serial; *response.getSerial() = samplingDevice->serial;
response.setSequence(samplingDevice->sequence); response.setSequence(samplingDevice->sequence);
response.setDirection(direction); response.setDirection(query.getDirection());
response.setDeviceNbStreams(samplingDevice->deviceNbItems); response.setDeviceNbStreams(samplingDevice->deviceNbItems);
response.setDeviceStreamIndex(samplingDevice->deviceItemIndex); response.setDeviceStreamIndex(samplingDevice->deviceItemIndex);
response.setDeviceSetIndex(deviceSetIndex); response.setDeviceSetIndex(deviceSetIndex);

View File

@ -167,8 +167,9 @@ bool MainCore::handleMessage(const Message& cmd)
changeSampleSink(notif.getDeviceSetIndex(), notif.getDeviceIndex()); changeSampleSink(notif.getDeviceSetIndex(), notif.getDeviceIndex());
} else if (notif.getDeviceType() == 0) { } else if (notif.getDeviceType() == 0) {
changeSampleSource(notif.getDeviceSetIndex(), notif.getDeviceIndex()); changeSampleSource(notif.getDeviceSetIndex(), notif.getDeviceIndex());
} // TODO: for MIMO } else if (notif.getDeviceType() == 2) {
changeSampleMIMO(notif.getDeviceSetIndex(), notif.getDeviceIndex());
}
return true; return true;
} }
else if (MsgAddChannel::match(cmd)) else if (MsgAddChannel::match(cmd))
@ -586,6 +587,45 @@ void MainCore::changeSampleSink(int deviceSetIndex, int selectedDeviceIndex)
} }
} }
void MainCore::changeSampleMIMO(int deviceSetIndex, int selectedDeviceIndex)
{
if (deviceSetIndex >= 0)
{
qDebug("MainCore::changeSampleMIMO: device set at %d", deviceSetIndex);
DeviceSet *deviceSet = m_deviceSets[deviceSetIndex];
deviceSet->m_deviceAPI->saveSamplingDeviceSettings(m_settings.getWorkingPreset()); // save old API settings
deviceSet->m_deviceAPI->stopDeviceEngine();
// deletes old UI and output object
deviceSet->m_deviceAPI->resetSamplingDeviceId();
deviceSet->m_deviceAPI->getPluginInterface()->deleteSampleMIMOPluginInstanceMIMO(
deviceSet->m_deviceAPI->getSampleMIMO());
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getMIMOSamplingDevice(selectedDeviceIndex);
deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
deviceSet->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
deviceSet->m_deviceAPI->setDeviceItemIndex(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()->getMIMOPluginInterface(selectedDeviceIndex));
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
if (userArgs.size() > 0) {
deviceSet->m_deviceAPI->setHardwareUserArguments(userArgs);
}
// constructs new GUI and MIMO object
DeviceSampleMIMO *mimo = deviceSet->m_deviceAPI->getPluginInterface()->createSampleMIMOPluginInstance(
deviceSet->m_deviceAPI->getSamplingDeviceId(), deviceSet->m_deviceAPI);
deviceSet->m_deviceAPI->setSampleMIMO(mimo);
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_settings.getWorkingPreset()); // load new API settings
}
}
void MainCore::addChannel(int deviceSetIndex, int selectedChannelIndex) void MainCore::addChannel(int deviceSetIndex, int selectedChannelIndex)
{ {
if (deviceSetIndex >= 0) if (deviceSetIndex >= 0)

View File

@ -65,6 +65,7 @@ public:
void removeLastDevice(); void removeLastDevice();
void changeSampleSource(int deviceSetIndex, int selectedDeviceIndex); void changeSampleSource(int deviceSetIndex, int selectedDeviceIndex);
void changeSampleSink(int deviceSetIndex, int selectedDeviceIndex); void changeSampleSink(int deviceSetIndex, int selectedDeviceIndex);
void changeSampleMIMO(int deviceSetIndex, int selectedDeviceIndex);
void addChannel(int deviceSetIndex, int selectedChannelIndex); void addChannel(int deviceSetIndex, int selectedChannelIndex);
void deleteChannel(int deviceSetIndex, int channelIndex); void deleteChannel(int deviceSetIndex, int channelIndex);