bool VegaParametersWidget::RequestAll() { PopupOperationEnvironment env; /* long timeout for first response */ unsigned timeout_ms = 3000; /* the first response that we're still waiting for */ const auto end = parameters.end(); auto start = parameters.begin(); for (auto i = parameters.begin(); i != end; ++i) { /* send up to 4 requests at a time */ if (std::distance(start, i) >= 4) { /* queue is long enough: wait for one response */ WaitForSetting(device, start->name, timeout_ms); /* reduce timeout for follow-up responses */ timeout_ms = 1000; ++start; } if (!SettingExists(device, i->name) && !device.RequestSetting(i->name, env)) return false; } /* wait for the remaining responses */ for (auto i = start; i != end; ++i) WaitForSetting(device, i->name, 500); return true; }
PSRETURN IGUIObject::SetSetting(const CStr& Setting, const CStrW& Value, const bool& SkipMessage) { if (!SettingExists(Setting)) return PSRETURN_GUI_InvalidSetting; // Get setting SGUISetting set = m_Settings[Setting]; #define TYPE(type) \ else if (set.m_Type == GUIST_##type) \ { \ type _Value; \ if (!GUI<type>::ParseString(Value, _Value)) \ return PSRETURN_GUI_UnableToParse; \ GUI<type>::SetSetting(this, Setting, _Value, SkipMessage); \ } if (0) ; // else... #include "GUItypes.h" #undef TYPE else { // Why does it always fail? //return PS_FAIL; return LogInvalidSettings(Setting); } return PSRETURN_OK; }
/** * Wait for a setting to be received from the Vega. */ static bool WaitForSetting(VegaDevice &device, const char *name, unsigned timeout_ms) { for (unsigned i = 0; i < timeout_ms / 100; ++i) { if (SettingExists(device, name)) return true; Sleep(100); } return false; }
PSRETURN IGUIObject::GetSettingType(const CStr& Setting, EGUISettingType& Type) const { if (!SettingExists(Setting)) return LogInvalidSettings(Setting); if (m_Settings.find(Setting) == m_Settings.end()) return LogInvalidSettings(Setting); Type = m_Settings.find(Setting)->second.m_Type; return PSRETURN_OK; }