From 9256e6b0ed2f2a65c4dd8712bea08f1ceca4e5ea Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 6 Jan 2018 09:50:09 +0100 Subject: [PATCH] Web API: DeviceSetList: added focused device set index for the GUI --- sdrbase/resources/index.html | 32 +++++++++++-------- sdrgui/webapi/webapiadaptergui.cpp | 4 +++ swagger/sdrangel/api/swagger/swagger.yaml | 3 ++ swagger/sdrangel/code/html2/index.html | 32 +++++++++++-------- .../code/qt5/client/SWGDeviceSetApi.cpp | 2 +- .../code/qt5/client/SWGDeviceSetApi.h | 4 +-- .../code/qt5/client/SWGDeviceSetList.cpp | 14 ++++++++ .../code/qt5/client/SWGDeviceSetList.h | 4 +++ .../sdrangel/examples/devicesets_config.py | 2 +- 9 files changed, 65 insertions(+), 32 deletions(-) diff --git a/sdrbase/resources/index.html b/sdrbase/resources/index.html index 4b23ab4ed..203360d2d 100644 --- a/sdrbase/resources/index.html +++ b/sdrbase/resources/index.html @@ -955,6 +955,10 @@ margin-bottom: 20px; "type" : "integer", "description" : "Number of device sets opened in this instance" }, + "devicesetfocus" : { + "type" : "integer", + "description" : "Index of the deviceset that has focus (relevant for GUI only)" + }, "deviceSets" : { "type" : "array", "items" : { @@ -7693,7 +7697,7 @@ public class DeviceSetApiExample { DeviceSetApi apiInstance = new DeviceSetApi(); Integer deviceSetIndex = 56; // Integer | Index of device set in the device set list try { - DeviceSet result = apiInstance.devicesetFocusPatch(deviceSetIndex); + SuccessResponse result = apiInstance.devicesetFocusPatch(deviceSetIndex); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling DeviceSetApi#devicesetFocusPatch"); @@ -7712,7 +7716,7 @@ public class DeviceSetApiExample { DeviceSetApi apiInstance = new DeviceSetApi(); Integer deviceSetIndex = 56; // Integer | Index of device set in the device set list try { - DeviceSet result = apiInstance.devicesetFocusPatch(deviceSetIndex); + SuccessResponse result = apiInstance.devicesetFocusPatch(deviceSetIndex); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling DeviceSetApi#devicesetFocusPatch"); @@ -7731,7 +7735,7 @@ public class DeviceSetApiExample { DeviceSetApi *apiInstance = [[DeviceSetApi alloc] init]; [apiInstance devicesetFocusPatchWith:deviceSetIndex - completionHandler: ^(DeviceSet output, NSError* error) { + completionHandler: ^(SuccessResponse output, NSError* error) { if (output) { NSLog(@"%@", output); } @@ -7783,7 +7787,7 @@ namespace Example try { - DeviceSet result = apiInstance.devicesetFocusPatch(deviceSetIndex); + SuccessResponse result = apiInstance.devicesetFocusPatch(deviceSetIndex); Debug.WriteLine(result); } catch (Exception e) @@ -7886,24 +7890,24 @@ except ApiException as e:

Responses

-

Status: 200 - On success return details on the device set

+

Status: 202 - Message to focus on device set was sent successfully

-
-
+
+
- +
@@ -16890,7 +16894,7 @@ except ApiException as e:
- Generated 2018-01-06T03:02:37.398+01:00 + Generated 2018-01-06T09:41:18.709+01:00
diff --git a/sdrgui/webapi/webapiadaptergui.cpp b/sdrgui/webapi/webapiadaptergui.cpp index 4992d3627..b21a039df 100644 --- a/sdrgui/webapi/webapiadaptergui.cpp +++ b/sdrgui/webapi/webapiadaptergui.cpp @@ -1247,6 +1247,10 @@ void WebAPIAdapterGUI::getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSet deviceSetList->init(); deviceSetList->setDevicesetcount((int) m_mainWindow.m_deviceUIs.size()); + if (m_mainWindow.m_deviceUIs.size() > 0) { + deviceSetList->setDevicesetfocus(m_mainWindow.ui->tabInputsView->currentIndex()); + } + std::vector::const_iterator it = m_mainWindow.m_deviceUIs.begin(); for (int i = 0; it != m_mainWindow.m_deviceUIs.end(); ++it, i++) diff --git a/swagger/sdrangel/api/swagger/swagger.yaml b/swagger/sdrangel/api/swagger/swagger.yaml index 842977424..e79fee9bd 100644 --- a/swagger/sdrangel/api/swagger/swagger.yaml +++ b/swagger/sdrangel/api/swagger/swagger.yaml @@ -1159,6 +1159,9 @@ definitions: devicesetcount: description: "Number of device sets opened in this instance" type: integer + devicesetfocus: + description: "Index of the deviceset that has focus (relevant for GUI only)" + type: integer deviceSets: type: array items: diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html index 4b23ab4ed..203360d2d 100644 --- a/swagger/sdrangel/code/html2/index.html +++ b/swagger/sdrangel/code/html2/index.html @@ -955,6 +955,10 @@ margin-bottom: 20px; "type" : "integer", "description" : "Number of device sets opened in this instance" }, + "devicesetfocus" : { + "type" : "integer", + "description" : "Index of the deviceset that has focus (relevant for GUI only)" + }, "deviceSets" : { "type" : "array", "items" : { @@ -7693,7 +7697,7 @@ public class DeviceSetApiExample { DeviceSetApi apiInstance = new DeviceSetApi(); Integer deviceSetIndex = 56; // Integer | Index of device set in the device set list try { - DeviceSet result = apiInstance.devicesetFocusPatch(deviceSetIndex); + SuccessResponse result = apiInstance.devicesetFocusPatch(deviceSetIndex); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling DeviceSetApi#devicesetFocusPatch"); @@ -7712,7 +7716,7 @@ public class DeviceSetApiExample { DeviceSetApi apiInstance = new DeviceSetApi(); Integer deviceSetIndex = 56; // Integer | Index of device set in the device set list try { - DeviceSet result = apiInstance.devicesetFocusPatch(deviceSetIndex); + SuccessResponse result = apiInstance.devicesetFocusPatch(deviceSetIndex); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling DeviceSetApi#devicesetFocusPatch"); @@ -7731,7 +7735,7 @@ public class DeviceSetApiExample { DeviceSetApi *apiInstance = [[DeviceSetApi alloc] init]; [apiInstance devicesetFocusPatchWith:deviceSetIndex - completionHandler: ^(DeviceSet output, NSError* error) { + completionHandler: ^(SuccessResponse output, NSError* error) { if (output) { NSLog(@"%@", output); } @@ -7783,7 +7787,7 @@ namespace Example try { - DeviceSet result = apiInstance.devicesetFocusPatch(deviceSetIndex); + SuccessResponse result = apiInstance.devicesetFocusPatch(deviceSetIndex); Debug.WriteLine(result); } catch (Exception e) @@ -7886,24 +7890,24 @@ except ApiException as e:

Responses

-

Status: 200 - On success return details on the device set

+

Status: 202 - Message to focus on device set was sent successfully

-
-
+
+
- +
@@ -16890,7 +16894,7 @@ except ApiException as e:
- Generated 2018-01-06T03:02:37.398+01:00 + Generated 2018-01-06T09:41:18.709+01:00
diff --git a/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.cpp b/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.cpp index a7215e005..d08d73bc2 100644 --- a/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.cpp @@ -691,7 +691,7 @@ SWGDeviceSetApi::devicesetFocusPatchCallback(HttpRequestWorker * worker) { QString json(worker->response); - SWGDeviceSet* output = static_cast(create(json, QString("SWGDeviceSet"))); + SWGSuccessResponse* output = static_cast(create(json, QString("SWGSuccessResponse"))); worker->deleteLater(); emit devicesetFocusPatchSignal(output); diff --git a/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.h b/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.h index 744a21c6d..00afe3310 100644 --- a/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.h +++ b/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.h @@ -87,7 +87,7 @@ signals: void devicesetDeviceSettingsGetSignal(SWGDeviceSettings* summary); void devicesetDeviceSettingsPatchSignal(SWGDeviceSettings* summary); void devicesetDeviceSettingsPutSignal(SWGDeviceSettings* summary); - void devicesetFocusPatchSignal(SWGDeviceSet* summary); + void devicesetFocusPatchSignal(SWGSuccessResponse* summary); void devicesetGetSignal(SWGDeviceSet* summary); void instanceDeviceSetDeleteSignal(SWGSuccessResponse* summary); void instanceDeviceSetPostSignal(SWGSuccessResponse* summary); @@ -104,7 +104,7 @@ signals: void devicesetDeviceSettingsGetSignalE(SWGDeviceSettings* summary, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetDeviceSettingsPatchSignalE(SWGDeviceSettings* summary, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetDeviceSettingsPutSignalE(SWGDeviceSettings* summary, QNetworkReply::NetworkError error_type, QString& error_str); - void devicesetFocusPatchSignalE(SWGDeviceSet* summary, QNetworkReply::NetworkError error_type, QString& error_str); + void devicesetFocusPatchSignalE(SWGSuccessResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetGetSignalE(SWGDeviceSet* summary, QNetworkReply::NetworkError error_type, QString& error_str); void instanceDeviceSetDeleteSignalE(SWGSuccessResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str); void instanceDeviceSetPostSignalE(SWGSuccessResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str); diff --git a/swagger/sdrangel/code/qt5/client/SWGDeviceSetList.cpp b/swagger/sdrangel/code/qt5/client/SWGDeviceSetList.cpp index 7fd424367..e3f5ed46d 100644 --- a/swagger/sdrangel/code/qt5/client/SWGDeviceSetList.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGDeviceSetList.cpp @@ -38,6 +38,7 @@ SWGDeviceSetList::~SWGDeviceSetList() { void SWGDeviceSetList::init() { devicesetcount = 0; + devicesetfocus = 0; device_sets = new QList(); } @@ -45,6 +46,7 @@ void SWGDeviceSetList::cleanup() { + if(device_sets != nullptr) { QList* arr = device_sets; foreach(SWGDeviceSet* o, *arr) { @@ -66,6 +68,7 @@ SWGDeviceSetList::fromJson(QString &json) { void SWGDeviceSetList::fromJsonObject(QJsonObject &pJson) { ::SWGSDRangel::setValue(&devicesetcount, pJson["devicesetcount"], "qint32", ""); + ::SWGSDRangel::setValue(&devicesetfocus, pJson["devicesetfocus"], "qint32", ""); ::SWGSDRangel::setValue(&device_sets, pJson["deviceSets"], "QList", "SWGDeviceSet"); @@ -87,6 +90,8 @@ SWGDeviceSetList::asJsonObject() { obj->insert("devicesetcount", QJsonValue(devicesetcount)); + obj->insert("devicesetfocus", QJsonValue(devicesetfocus)); + QJsonArray device_setsJsonArray; toJsonArray((QList*)device_sets, &device_setsJsonArray, "device_sets", "SWGDeviceSet"); obj->insert("deviceSets", device_setsJsonArray); @@ -103,6 +108,15 @@ SWGDeviceSetList::setDevicesetcount(qint32 devicesetcount) { this->devicesetcount = devicesetcount; } +qint32 +SWGDeviceSetList::getDevicesetfocus() { + return devicesetfocus; +} +void +SWGDeviceSetList::setDevicesetfocus(qint32 devicesetfocus) { + this->devicesetfocus = devicesetfocus; +} + QList* SWGDeviceSetList::getDeviceSets() { return device_sets; diff --git a/swagger/sdrangel/code/qt5/client/SWGDeviceSetList.h b/swagger/sdrangel/code/qt5/client/SWGDeviceSetList.h index ece29503a..44ec95d98 100644 --- a/swagger/sdrangel/code/qt5/client/SWGDeviceSetList.h +++ b/swagger/sdrangel/code/qt5/client/SWGDeviceSetList.h @@ -46,12 +46,16 @@ public: qint32 getDevicesetcount(); void setDevicesetcount(qint32 devicesetcount); + qint32 getDevicesetfocus(); + void setDevicesetfocus(qint32 devicesetfocus); + QList* getDeviceSets(); void setDeviceSets(QList* device_sets); private: qint32 devicesetcount; + qint32 devicesetfocus; QList* device_sets; }; diff --git a/swagger/sdrangel/examples/devicesets_config.py b/swagger/sdrangel/examples/devicesets_config.py index 4ac928128..3dd312d34 100755 --- a/swagger/sdrangel/examples/devicesets_config.py +++ b/swagger/sdrangel/examples/devicesets_config.py @@ -1,4 +1,4 @@ -dev_focus_url#!/usr/bin/env python +#!/usr/bin/env python import requests, traceback, sys from optparse import OptionParser