more work on the spectran

This commit is contained in:
AlexandreRouma 2022-12-12 00:10:39 +01:00
parent ea23c44266
commit bd99210fd3
2 changed files with 24 additions and 17 deletions

View File

@ -112,20 +112,19 @@ private:
static void menuHandler(void* ctx) { static void menuHandler(void* ctx) {
SpectranHTTPSourceModule* _this = (SpectranHTTPSourceModule*)ctx; SpectranHTTPSourceModule* _this = (SpectranHTTPSourceModule*)ctx;
float menuWidth = ImGui::GetContentRegionAvail().x;
bool connected = (_this->client && _this->client->isOpen()); bool connected = (_this->client && _this->client->isOpen());
gui::mainWindow.playButtonLocked = !connected; gui::mainWindow.playButtonLocked = !connected;
if (connected) { SmGui::BeginDisabled(); } if (connected) { SmGui::BeginDisabled(); }
if (ImGui::InputText(CONCAT("##spectran_http_host_", _this->name), _this->hostname, 1023)) { if (SmGui::InputText(CONCAT("##spectran_http_host_", _this->name), _this->hostname, 1023)) {
config.acquire(); config.acquire();
config.conf["hostname"] = _this->hostname; config.conf["hostname"] = _this->hostname;
config.release(true); config.release(true);
} }
ImGui::SameLine(); SmGui::SameLine();
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX()); SmGui::FillWidth();
if (ImGui::InputInt(CONCAT("##spectran_http_port_", _this->name), &_this->port, 0, 0)) { if (SmGui::InputInt(CONCAT("##spectran_http_port_", _this->name), &_this->port, 0, 0)) {
config.acquire(); config.acquire();
config.conf["port"] = _this->port; config.conf["port"] = _this->port;
config.release(true); config.release(true);
@ -134,21 +133,22 @@ private:
if (connected) { SmGui::EndDisabled(); } if (connected) { SmGui::EndDisabled(); }
if (_this->running) { style::beginDisabled(); } if (_this->running) { style::beginDisabled(); }
if (!connected && ImGui::Button("Connect##spectran_http_source", ImVec2(menuWidth, 0))) { SmGui::FillWidth();
if (!connected && SmGui::Button("Connect##spectran_http_source")) {
_this->tryConnect(); _this->tryConnect();
} }
else if (connected && ImGui::Button("Disconnect##spectran_http_source", ImVec2(menuWidth, 0))) { else if (connected && SmGui::Button("Disconnect##spectran_http_source")) {
_this->client->close(); _this->client->close();
} }
if (_this->running) { style::endDisabled(); } if (_this->running) { style::endDisabled(); }
ImGui::TextUnformatted("Status:"); SmGui::Text("Status:");
ImGui::SameLine(); SmGui::SameLine();
if (connected) { if (connected) {
ImGui::TextColored(ImVec4(0.0f, 1.0f, 0.0f, 1.0f), "Connected"); SmGui::TextColored(ImVec4(0.0f, 1.0f, 0.0f, 1.0f), "Connected");
} }
else { else {
ImGui::TextUnformatted("Not connected"); SmGui::Text("Not connected");
} }
} }

View File

@ -43,6 +43,12 @@ public:
agcModeList.define("Peak", L"peak"); agcModeList.define("Peak", L"peak");
agcModeList.define("Power", L"power"); agcModeList.define("Power", L"power");
clockList.define("Consumer", L"Consumer");
clockList.define("Internal", L"Oscillator");
clockList.define("GPSDO", L"GPS");
clockList.define("PPS", L"PPS");
clockList.define("10MHz Ref", L"10MHz");
samplerate.effective = 1000000.0; samplerate.effective = 1000000.0;
handler.ctx = this; handler.ctx = this;
@ -322,11 +328,11 @@ private:
SmGui::FillWidth(); SmGui::FillWidth();
SmGui::ForceSync(); SmGui::ForceSync();
if (ImGui::Combo(CONCAT("##_spectran_dev_", _this->name), &_this->devId, _this->devList.txt)) { if (SmGui::Combo(CONCAT("##_spectran_dev_", _this->name), &_this->devId, _this->devList.txt)) {
} }
// TODO: SR sel // TODO: SR sel
if (ImGui::Combo(CONCAT("##_spectran_sr_", _this->name), &_this->srId, _this->sampleRateList.txt)) { if (SmGui::Combo(CONCAT("##_spectran_sr_", _this->name), &_this->srId, _this->sampleRateList.txt)) {
_this->samplerate = _this->sampleRateList.value(_this->srId); _this->samplerate = _this->sampleRateList.value(_this->srId);
core::setInputSampleRate(_this->samplerate.effective); core::setInputSampleRate(_this->samplerate.effective);
} }
@ -344,7 +350,7 @@ private:
SmGui::LeftLabel("USB Compression"); SmGui::LeftLabel("USB Compression");
SmGui::FillWidth(); SmGui::FillWidth();
if (ImGui::Combo(CONCAT("##_spectran_comp_", _this->name), &_this->compId, _this->compList.txt)) { if (SmGui::Combo(CONCAT("##_spectran_comp_", _this->name), &_this->compId, _this->compList.txt)) {
if (_this->running) { if (_this->running) {
AARTSAAPI_Config config; AARTSAAPI_Config config;
AARTSAAPI_ConfigFind(&_this->dev, &_this->croot, &config, L"device/usbcompression"); AARTSAAPI_ConfigFind(&_this->dev, &_this->croot, &config, L"device/usbcompression");
@ -354,7 +360,7 @@ private:
SmGui::LeftLabel("AGC Mode"); SmGui::LeftLabel("AGC Mode");
SmGui::FillWidth(); SmGui::FillWidth();
if (ImGui::Combo(CONCAT("##_spectran_agc_", _this->name), &_this->agcModeId, _this->agcModeList.txt)) { if (SmGui::Combo(CONCAT("##_spectran_agc_", _this->name), &_this->agcModeId, _this->agcModeList.txt)) {
if (_this->running) { if (_this->running) {
AARTSAAPI_Config config; AARTSAAPI_Config config;
AARTSAAPI_ConfigFind(&_this->dev, &_this->croot, &config, L"device/gaincontrol"); AARTSAAPI_ConfigFind(&_this->dev, &_this->croot, &config, L"device/gaincontrol");
@ -374,13 +380,13 @@ private:
} }
if (_this->agcModeId) { SmGui::EndDisabled(); } if (_this->agcModeId) { SmGui::EndDisabled(); }
if (ImGui::Checkbox(CONCAT("Amp##_spectran_amp_", _this->name), &_this->amp)) { if (SmGui::Checkbox(CONCAT("Amp##_spectran_amp_", _this->name), &_this->amp)) {
if (_this->running) { if (_this->running) {
_this->updateAmps(); _this->updateAmps();
} }
} }
if (ImGui::Checkbox(CONCAT("Preamp##_spectran_preamp_", _this->name), &_this->preAmp)) { if (SmGui::Checkbox(CONCAT("Preamp##_spectran_preamp_", _this->name), &_this->preAmp)) {
if (_this->running) { if (_this->running) {
_this->updateAmps(); _this->updateAmps();
} }
@ -493,6 +499,7 @@ private:
OptionList<std::string, SRCombo> sampleRateList; OptionList<std::string, SRCombo> sampleRateList;
OptionList<std::string, std::wstring> compList; OptionList<std::string, std::wstring> compList;
OptionList<std::string, std::wstring> agcModeList; OptionList<std::string, std::wstring> agcModeList;
OptionList<std::string, std::wstring> clockList;
AARTSAAPI_Handle api; AARTSAAPI_Handle api;
AARTSAAPI_Device dev; AARTSAAPI_Device dev;