ReceiverThread::ReceiverThread() { uart_init(); setParameterValue(TOTAL_SPANNUNG, 0x1010); setParameterValue(BUS_ADRESSE, 0x31); }
IPState WeatherWatcher::updateWeather() { if (readWatchFile() == false) return IPS_BUSY; for (auto const &x : weatherMap) { if (x.first == keywordT[0].text) { setParameterValue("WEATHER_RAIN_HOUR", std::strtod(x.second.c_str(), nullptr)); } else if (x.first == keywordT[1].text) { setParameterValue("WEATHER_TEMPERATURE", std::strtod(x.second.c_str(), nullptr)); } else if (x.first == keywordT[2].text) { setParameterValue("WEATHER_WIND_SPEED", std::strtod(x.second.c_str(), nullptr)); } else if (x.first == keywordT[3].text) { setParameterValue("WEATHER_WIND_GUST", std::strtod(x.second.c_str(), nullptr)); } else if (x.first == keywordT[4].text) { setParameterValue("WEATHER_FORECAST", std::strtod(x.second.c_str(), nullptr)); } } return IPS_OK; }
BiasedDelay::BiasedDelay() : delayBuffer(MAX_CHANNELS, INITIAL_BUFFER_SIZE) { parameterNames.add("Time"); parameterNames.add("Feedback"); parameterNames.add("Bias"); parameterNames.add("Dry/Wet"); setParameterValue(PARAMETER_TIME, 0.2f); setParameterValue(PARAMETER_FEEDBACK, 0.1f); setParameterValue(PARAMETER_BIAS, 0.5f); setParameterValue(PARAMETER_DRYWET, 0.5f); }
// virtual bool CQTaskMethodParametersDM::setData(const QModelIndex &_index, const QVariant &value, int role) { CCopasiParameter * pNode = nodeFromIndex(_index); if (pNode == NULL) return false; bool success = false; if (role == Qt::EditRole || role == Qt::CheckStateRole) { switch (_index.column()) { case COL_VALUE: success = setParameterValue(pNode, value); break; default: success = true; break; } } return success; }
void BiasedDelay::setStateInformation(ScopedPointer<XmlElement> state){ if (state->hasTagName("BiasedDelayState")) { for (int i=0; i<getNumParameters(); i++) setParameterValue(i, (float)state->getDoubleAttribute(String::formatted("parameter%d", i), getParameterValue(i))); // setParameterValue(i, (float)state->getDoubleAttribute(getParameterName(i), getParameterValue(i))); } }
void ReceiverThread::receiveData() { uint16_t value; value = data[3] | (data[2]<<8); setParameterValue(parameter, value); }
void Effect::setParameterValue(const EffectParameter ¶m, const QVariant &newValue) { K_D(Effect); d->parameterValues[param] = newValue; if (d->backendObject()) { INTERFACE_CALL(setParameterValue(param, newValue)); } }
void DistrhoUISoulForce::imageSwitchClicked(ImageSwitch* imageSwitch, bool down) { const uint buttonId(imageSwitch->getId()); editParameter(buttonId, true); setParameterValue(buttonId, down ? 1.0f : 0.0f); editParameter(buttonId, false); }
void ParameterSlider::reset(float minimumValue, float maximumValue, float value) { if (maximumValue < minimumValue + EPSILON) { THROW_EXCEPTION(InvalidValueException, "The maximum value must be greater than the minimum value. Slider: " << parameter_ << '.'); } minimumValue_ = minimumValue; maximumValue_ = maximumValue; setParameterValue(value); }
bool CQLNAWidget::saveParameterTable() { size_t i, k; QString value; CCopasiParameter::Type Type; for (i = 0; i < mpMethod->size(); i++) { value = mpMethodWidget->mpTableParameter->item((int) i, 0)->text(); if (value != getParameterValue(mpMethod, i, &Type)) { setParameterValue(mpMethod, i, value); mChanged = true; } } if (mpCheckSteadyState->isChecked()) { assert(CCopasiRootContainer::getDatamodelList()->size() > 0); CSteadyStateTask * pSteadyStateTask = dynamic_cast<CSteadyStateTask *>((*(*CCopasiRootContainer::getDatamodelList())[0]->getTaskList())["Steady-State"]); if (!pSteadyStateTask) return false; CCopasiMethod * pMethod = pSteadyStateTask->getMethod(); for (i = mpMethod->size(), k = 0; k < pMethod->size(); i++, k++) { value = mpMethodWidget->mpTableParameter->item((int) i, 0)->text(); if (value != getParameterValue(pMethod, k, &Type)) { setParameterValue(pMethod, k, value); mChanged = true; } } } return true; }
bool HdfsConfig::setParameterValue(const string ¶meterName, const string ¶meterValue, const string &conftype) { if (hawq::test::lower(conftype) == "hdfs") { return setParameterValue(parameterName, parameterValue); } bool ret = LoadFromHawqConfigFile(); if (!ret) { return false; } return hawqxmlconf->setString(parameterName, parameterValue); }
void DistrhoUISoulForce::imageButtonClicked(ImageButton* imageButton, int) { const uint buttonId(imageButton->getId()); if (buttonId != DistrhoPluginSoulForce::kParameterFootswitch) return; fFootDown = !fFootDown; editParameter(buttonId, true); setParameterValue(buttonId, fFootDown ? 1.0f : 0.0f); editParameter(buttonId, false); repaint(); }
// Called by Weather::TimerHit every UpdatePeriodN[0].value seconds if we return IPS_OK or every 5 seconds otherwise IPState WeatherSafetyProxy::updateWeather() { IPState ret = IPS_ALERT; if (ScriptOrCurlS[WSP_USE_SCRIPT].s == ISS_ON) { ret = executeScript(); } else { ret = executeCurl(); } if (ret != IPS_OK) { if (Safety == WSP_SAFE) { SofterrorCount++; LOGF_WARN("Soft error %d occured during SAFE conditions, counting", SofterrorCount); if (SofterrorCount > softErrorHysteresisN[WSP_SOFT_ERROR_MAX].value) { char Warning[] = "Max softerrors reached while Weather was SAFE"; LOG_WARN(Warning); Safety = WSP_UNSAFE; setParameterValue("WEATHER_SAFETY", WSP_UNSAFE); IUSaveText(&reasonsT[0], Warning); reasonsTP.s = IPS_OK; IDSetText(&reasonsTP, nullptr); SofterrorRecoveryMode = true; ret = IPS_OK; // So that indiweather actually syncs the CriticalParameters we just set } } else { LOG_WARN("Soft error occured during UNSAFE conditions, ignore"); SofterrorCount = 0; SofterrorRecoveryCount = 0; } } else { SofterrorCount = 0; } return ret; }
/** * Initialize the object with a string of parameters * @param params :: A key=value list of parameters */ void ChopperModel::initialize(const std::string & params) { if(params.empty()) throw std::invalid_argument("ChopperModel::initialize - Empty parameter string."); static const char * keyValSep = "="; static const char * listSep = ","; auto keyValues = Kernel::Strings::splitToKeyValues(params, keyValSep, listSep); if(keyValues.empty()) { throw std::invalid_argument("ChopperModel::initialize - Parameter string was not empty but no values" " could be parsed. Check it is a comma-separated key=value string"); } setBaseParameters(keyValues); for(auto iter = keyValues.begin(); iter != keyValues.end(); ++iter) { setParameterValue(iter->first, iter->second); } }
/** * Initialize the object from a string of parameters * @param params :: A string containing the parameter names & values */ void ModeratorModel::initialize(const std::string & params) { if(params.empty()) throw std::invalid_argument("ModeratorModel::initialize - Empty parameter string."); static const char * keyValSep = "="; static const char * listSep = ","; auto keyValues = Kernel::Strings::splitToKeyValues(params, keyValSep, listSep); if(keyValues.empty()) { throw std::invalid_argument("ModeratorModel::initialize - Parameter string was not empty but no values" "could be parsed. Check it has the key=value format."); } for(auto iter = keyValues.begin(); iter != keyValues.end(); ++iter) { setParameterValue(iter->first, iter->second); } /// Any custom setup this->init(); }
bool setParameterValue(CCopasiParameterGroup * group, const std::string & name, const QString & value) {return setParameterValue(group, group->getIndex(name), value);}
//-------------------------------------------------------------- void oscReceiver::update() { if (hasWaitingMessages()) { while(getNextMessage(&m_oscMessage)) { // int indexArg = 0; ofLog() << "oscReceiver::update() - received " << m_oscMessage.getAddress(); if (m_oscMessage.getAddress() == OSC_MOD_SET_WEIGHT) { apparelModManager* pModManager = GLOBALS->getModManager(); if (pModManager) { // Name of the mod string instanceName = m_oscMessage.getArgAsString(0); // Get Mod instance apparelMod* pMod = pModManager->getMod(instanceName); // Exists ?? if (pMod && pMod->m_isWeightManual) { pMod->setWeight( m_oscMessage.getArgAsFloat(1) ); } } } else if (m_oscMessage.getAddress() == OSC_MOD_SET_PARAMETER) { apparelModManager* pModManager = GLOBALS->getModManager(); if (pModManager) { // Name of the mod string instanceName = m_oscMessage.getArgAsString(0); // Get Mod instance apparelMod* pMod = pModManager->getMod(instanceName); // Exists ?? if (pMod) { if (m_oscMessage.getNumArgs() == 3) { string parameterName = m_oscMessage.getArgAsString(1); ofAbstractParameter& modParam = pMod->getParameter(parameterName); setParameterValue(modParam, m_oscMessage, 2); //OFAPPLOG->println("instanceName="+instanceName+"/parameterName="+parameterName); // OFAPPLOG->println("value for "+instanceName+"/"+parameterName+"="+modParam.toString()); } // else if (m_oscMessage.getNumArgs() == 4) { string groupName = m_oscMessage.getArgAsString(1); string parameterName = m_oscMessage.getArgAsString(2); ofAbstractParameter& modGroupParam = pMod->getParameter(groupName); if (modGroupParam.type()==typeid(ofParameterGroup).name()) { setParameterValue(modGroupParam, m_oscMessage, 3); } } } } } } } }
IPState WeatherSafetyProxy::parseSafetyJSON(const char *clean_buf, int byte_count) { // copy clean_buf to buf which jsonParse can destroy char buf[BUFSIZ]; strncpy(buf, clean_buf, byte_count); char *source = buf; char *endptr; JsonValue value; JsonAllocator allocator; int status = jsonParse(source, &endptr, &value, allocator); if (status != JSON_OK) { LOGF_ERROR("jsonParse %s at position %zd", jsonStrError(status), endptr - source); LastParseSuccess = false; return IPS_ALERT; } JsonIterator it; JsonIterator observationIterator; bool roof_status_found = false; bool open_ok_found = false; bool reasons_found = false; bool error_found = false; for (it = begin(value); it != end(value); ++it) { if (!strcmp(it->key, "roof_status")) { roof_status_found = true; for (observationIterator = begin(it->value); observationIterator != end(it->value); ++observationIterator) { if (!strcmp(observationIterator->key, "open_ok")) { open_ok_found = true; int NewSafety = observationIterator->value.toNumber(); if (NewSafety != Safety) { if (NewSafety == WSP_UNSAFE) { LOG_WARN("Weather is UNSAFE"); } else if (NewSafety == WSP_SAFE) { if (SofterrorRecoveryMode == true) { SofterrorRecoveryCount++; if (SofterrorRecoveryCount > softErrorHysteresisN[WSP_SOFT_ERROR_RECOVERY].value) { LOG_INFO("Minimum soft recovery errors reached while Weather was SAFE"); SofterrorRecoveryCount = 0; SofterrorRecoveryMode = false; } else { LOGF_INFO("Weather is SAFE but soft error recovery %d is still counting", SofterrorRecoveryCount); NewSafety = WSP_UNSAFE; } } else { LOG_INFO("Weather is SAFE"); } } Safety = NewSafety; } setParameterValue("WEATHER_SAFETY", NewSafety); } else if (!strcmp(observationIterator->key, "reasons")) { reasons_found = true; char *reasons = observationIterator->value.toString(); if (SofterrorRecoveryMode == true) { char newReasons[MAXRBUF]; snprintf(newReasons, MAXRBUF, "SofterrorRecoveryMode, %s", reasons); IUSaveText(&reasonsT[0], newReasons); } else { IUSaveText(&reasonsT[0], reasons); } reasonsTP.s = IPS_OK; IDSetText(&reasonsTP, nullptr); } } } if (!strcmp(it->key, "error")) { error_found = true; } } if (error_found) { LOGF_ERROR("Error hint found in JSON [%s]", clean_buf); LastParseSuccess = false; return IPS_ALERT; } if (!roof_status_found) { LOGF_ERROR("Found no roof_status field in JSON [%s]", clean_buf); LastParseSuccess = false; return IPS_ALERT; } if (!open_ok_found) { LOGF_ERROR("Found no open_ok field in roof_status JSON [%s]", clean_buf); LastParseSuccess = false; return IPS_ALERT; } // do not error if reasons are missing, they're not required for safety if (!LastParseSuccess) { // show the good news. Once. LOGF_INFO("Script output fully parsed, weather is %s", (Safety == 1) ? "SAFE" : "UNSAFE"); LastParseSuccess = true; } return IPS_OK; }
void DistrhoUISoulForce::imageKnobValueChanged(ImageKnob* knob, float value) { setParameterValue(knob->getId(), value); }
IPState WunderGround::updateWeather() { CURL *curl; CURLcode res; std::string readBuffer; char requestURL[MAXRBUF]; // If location is not updated yet, return busy if (wunderLat == -1000 || wunderLong == -1000) return IPS_BUSY; char *orig = setlocale(LC_NUMERIC,"C"); snprintf(requestURL, MAXRBUF, "http://api.wunderground.com/api/%s/conditions/q/%g,%g.json", wunderAPIKeyT[0].text, wunderLat, wunderLong); curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, requestURL); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } char srcBuffer[readBuffer.size()]; strncpy(srcBuffer, readBuffer.c_str(), readBuffer.size()); char *source = srcBuffer; // do not forget terminate source string with 0 char *endptr; JsonValue value; JsonAllocator allocator; int status = jsonParse(source, &endptr, &value, allocator); if (status != JSON_OK) { DEBUGF(INDI::Logger::DBG_ERROR, "%s at %zd", jsonStrError(status), endptr - source); DEBUGF(INDI::Logger::DBG_DEBUG, "%s", requestURL); DEBUGF(INDI::Logger::DBG_DEBUG, "%s", readBuffer.c_str()); setlocale(LC_NUMERIC,orig); return IPS_ALERT; } JsonIterator it; JsonIterator observationIterator; for (it = begin(value); it!= end(value); ++it) { if (!strcmp(it->key, "current_observation")) { for (observationIterator = begin(it->value); observationIterator!= end(it->value); ++observationIterator) { if (!strcmp(observationIterator->key, "weather")) { char *value = observationIterator->value.toString(); if (!strcmp(value, "Clear")) setParameterValue("WEATHER_FORECAST", 0); else if (!strcmp(value, "Unknown") || !strcmp(value, "Scattered Clouds") || !strcmp(value, "Partly Cloudy") || !strcmp(value, "Overcast") || !strcmp(value, "Patches of Fog") || !strcmp(value, "Partial Fog") || !strcmp(value, "Light Haze")) setParameterValue("WEATHER_FORECAST", 1); else setParameterValue("WEATHER_FORECAST", 2); DEBUGF(INDI::Logger::DBG_SESSION, "Weather condition: %s", value); } else if (!strcmp(observationIterator->key, "temp_c")) { if (observationIterator->value.isDouble()) setParameterValue("WEATHER_TEMPERATURE", observationIterator->value.toNumber()); else setParameterValue("WEATHER_TEMPERATURE", atof(observationIterator->value.toString())); } else if (!strcmp(observationIterator->key, "wind_kph")) { if (observationIterator->value.isDouble()) setParameterValue("WEATHER_WIND_SPEED", observationIterator->value.toNumber()); else setParameterValue("WEATHER_WIND_SPEED", atof(observationIterator->value.toString())); } else if (!strcmp(observationIterator->key, "wind_gust_kph")) { if (observationIterator->value.isDouble()) setParameterValue("WEATHER_WIND_GUST", observationIterator->value.toNumber()); else setParameterValue("WEATHER_WIND_GUST", atof(observationIterator->value.toString())); } else if (!strcmp(observationIterator->key, "precip_1hr_metric")) { char *value = observationIterator->value.toString(); double mm=-1; if (!strcmp(value, "--")) setParameterValue("WEATHER_RAIN_HOUR", 0); else { mm = atof(value); if (mm >= 0) setParameterValue("WEATHER_RAIN_HOUR", mm); } } } } } setlocale(LC_NUMERIC,orig); return IPS_OK; }
void DistrhoUIPingPongPan::imageKnobValueChanged(ImageKnob* knob, float value) { setParameterValue(knob->getId(), value); }
void EtherCatServer::setParameterValue(unsigned int deviceAlias, int deviceOffset, std::string parameterName, int value) { setParameterValue("", deviceAlias, deviceOffset, parameterName, value); }
IPState Vantage::updateWeather() { int nbytes_written=0, nbytes_read=0, rc=-1; char errstr[MAXRBUF]; char command[VANTAGE_CMD]; char response[VANTAGE_RES]; if (wakeup() == false) return IPS_ALERT; strncpy(command, "LOOP 1", VANTAGE_CMD); command[6] = 0; tcflush(PortFD, TCIOFLUSH); DEBUGF(INDI::Logger::DBG_DEBUG, "CMD (%s)", command); command[6] = 0xA; if ( (rc = tty_write(PortFD, command, 7, &nbytes_written)) != TTY_OK) { tty_error_msg(rc, errstr, MAXRBUF); DEBUGF(INDI::Logger::DBG_ERROR, "Loop error: %s.", errstr); return IPS_ALERT; } if ( (rc = tty_read(PortFD, response, 1, VANTAGE_TIMEOUT, &nbytes_read)) != TTY_OK) { tty_error_msg(rc, errstr, MAXRBUF); DEBUGF(INDI::Logger::DBG_ERROR, "Loop error: %s.", errstr); return IPS_ALERT; } if (response[0] != 0x06) { DEBUGF(INDI::Logger::DBG_ERROR, "Expecting 0x06, received %#X", response[0]); return IPS_ALERT; } if ( (rc = tty_read(PortFD, response, 99, VANTAGE_TIMEOUT, &nbytes_read)) != TTY_OK) { tty_error_msg(rc, errstr, MAXRBUF); DEBUGF(INDI::Logger::DBG_ERROR, "Loop error: %s.", errstr); return IPS_ALERT; } uint16_t crc = crc16(response, 99); if (crc != 0) { DEBUG(INDI::Logger::DBG_ERROR, "CRC check failed."); return IPS_ALERT; } uint8_t *loopData = (uint8_t *) response; DEBUGF(INDI::Logger::DBG_DEBUG, "Packet Type (%d)", loopData[4]); uint8_t forecastValue = loopData[89]; DEBUGF(INDI::Logger::DBG_DEBUG, "Raw Forecast (%d)", forecastValue); switch (forecastValue) { // Clear case 0x08: DEBUG(INDI::Logger::DBG_SESSION, "Forecast: Mostly Clear."); setParameterValue("WEATHER_FORECAST", 0); break; case 0x06: DEBUG(INDI::Logger::DBG_SESSION, "Forecast: Partly Cloudy."); setParameterValue("WEATHER_FORECAST", 1); break; case 0x02: DEBUG(INDI::Logger::DBG_SESSION, "Forecast: Mostly Cloudy."); setParameterValue("WEATHER_FORECAST", 2); break; case 0x03: DEBUG(INDI::Logger::DBG_SESSION, "Forecast: Mostly Cloudy. Rain within 12 hours."); setParameterValue("WEATHER_FORECAST", 2); break; case 0x12: DEBUG(INDI::Logger::DBG_SESSION, "Forecast: Mostly Cloudy. Snow within 12 hours."); setParameterValue("WEATHER_FORECAST", 2); break; case 0x13: DEBUG(INDI::Logger::DBG_SESSION, "Forecast: Mostly Cloudy. Rain or Snow within 12 hours."); setParameterValue("WEATHER_FORECAST", 2); break; case 0x07: DEBUG(INDI::Logger::DBG_SESSION, "Forecast: Partly Cloudy. Rain within 12 hours."); setParameterValue("WEATHER_FORECAST", 1); break; case 0x16: DEBUG(INDI::Logger::DBG_SESSION, "Forecast: Partly Cloudy. Snow within 12 hours."); setParameterValue("WEATHER_FORECAST", 1); break; case 0x17: DEBUG(INDI::Logger::DBG_SESSION, "Forecast: Partly Cloudy. Rain or Snow within 12 hours."); setParameterValue("WEATHER_FORECAST", 1); break; } // Inside Temperature uint16_t temperatureValue = loopData[10] << 8 | loopData[9]; setParameterValue("WEATHER_TEMPERATURE", ( (temperatureValue/10.0) - 32) / 1.8); DEBUGF(INDI::Logger::DBG_DEBUG, "Raw Temperature (%d) [%#4X %#4X]", temperatureValue, loopData[9], loopData[10]); // Barometer uint16_t barometerValue = loopData[8] << 8 | loopData[7]; setParameterValue("WEATHER_BAROMETER", (barometerValue/1000.0) * 33.8639); DEBUGF(INDI::Logger::DBG_DEBUG, "Raw Barometer (%d) [%#4X %#4X]", barometerValue, loopData[7], loopData[8]); // Wind Speed uint8_t windValue = loopData[14]; DEBUGF(INDI::Logger::DBG_DEBUG, "Raw Wind Speed (%d) [%#X4]", windValue, loopData[14]); setParameterValue("WEATHER_WIND_SPEED", windValue / 0.62137); // Wind Direction uint16_t windDir = loopData[17] << 8 | loopData[16]; DEBUGF(INDI::Logger::DBG_DEBUG, "Raw Wind Direction (%d) [%#4X,%#4X]", windDir, loopData[16], loopData[17]); setParameterValue("WEATHER_WIND_DIRECTION", windDir); // Rain Rate uint16_t rainRate = loopData[42] << 8 | loopData[41]; DEBUGF(INDI::Logger::DBG_DEBUG, "Raw Rain Rate (%d) [%#4X,%#4X]", rainRate, loopData[41], loopData[42]); setParameterValue("WEATHER_RAIN_RATE", rainRate / (100 * 0.039370)); // Solar Radiation uint16_t solarRadiation = loopData[45] << 8 | loopData[44]; DEBUGF(INDI::Logger::DBG_DEBUG, "Raw Solar Radiation (%d) [%#4X,%#4X]", solarRadiation, loopData[44], loopData[45]); if (solarRadiation == 32767) solarRadiation = 0; setParameterValue("WEATHER_SOLAR_RADIATION", solarRadiation); return IPS_OK; }
void ZamNoiseUI::imageToggleClicked(ImageToggle*, int) { float toggle = fToggleNoise->getValue(); fToggleNoise->setValue(toggle); setParameterValue(ZamNoisePlugin::paramNoiseToggle, toggle); }
// TODO: we need to template this for different types of value void EtherCatServer::setParameterValue(std::string deviceName, std::string parameterName, int value) { setParameterValue(deviceName, 0, 0, parameterName, value); }