void GUIOPTION::SetCurrentValue(const std::string & value) { if (m_values.empty()) { m_data = value; } else { size_t current_value = 0; for (LIST::iterator i = m_values.begin(); i != m_values.end(); ++i) { if (IsFloat()) { // number of trailing zeros might differ, use min match size_t len = std::min(i->first.length(), value.length()); if (!i->first.compare(0, len, value, 0, len)) break; } else { if (i->first == value) break; } ++current_value; } m_current_value = (current_value < m_values.size()) ? current_value : 0; } SignalValue(); }
void GuiOption::SetCurrentValue(const std::string & value) { if (m_values.empty()) { m_data = value; } else { size_t current_value = 0; for (const auto & v : m_values) { if (IsFloat()) { // number of trailing zeros might differ, use min match size_t len = std::min(v.first.length(), value.length()); if (!v.first.compare(0, len, value, 0, len)) break; } else { if (v.first == value) break; } ++current_value; } m_current_value = (current_value < m_values.size()) ? current_value : 0; } SignalValue(); }
Model::Model(quint16 startAddress, quint16 buffersCount, QObject *parent) : QAbstractTableModel(parent), client(new BufferClientImplementation(this)), startAddress(startAddress), buffersCount(buffersCount) { if (!client->blockingConnectToServer()) qFatal("Cannot connect to server"); for (quint16 address = startAddress; address < startAddress + 2 * buffersCount; address += 2) { SignalValueVector signalValues; for (int i = 0; i < buffersCount; ++i) signalValues.append(SignalValue()); signalDatas.append(signalValues); } QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), SLOT(updateValues())); timer->start(1000); }
//TODO this constructor might not be needed explicit ModuleInput(std::string name, SignalType signalType, const ModuleType &moduleType) : ModuleInput(name, SignalValue(signalType), moduleType) //zero as default value {}