void SceneDataModel::xmlSceneDataParse(QDomElement &element) { Scene scene; scene.name = getAttributeValue("name", element); // Load all <sensor> from current <scene> QDomNodeList listChildElement = element.childNodes(); // Iterate through all <sensor> in current <scene> for (int i = 0; listChildElement.count() > i; i++) { QDomElement currentChildElement = listChildElement.at(i).toElement(); if (currentChildElement.isNull()) { this->showFatalError(tr("Failed to load") + " <sensor>"); } this->logToConsole(currentChildElement); Sensor sensor; sensor.sceneName = scene.name; sensor.sensorId = getAttributeValue("id", currentChildElement).toInt(); sensor.temperatureTarget = getAttributeValue("target", currentChildElement).toDouble(); sensor.text = getSensorNameById(sensor.sensorId); scene.sensors.push_back(sensor); } _scenes.push_back(scene); }
void EFX::rotateAndScale(float* x, float* y) const { float xx = *x; float yy = *y; float w = m_width * getAttributeValue(Width); float h = m_height * getAttributeValue(Height); *x = (m_xOffset * getAttributeValue(XOffset)) + xx * m_cosR * w + yy * m_sinR * h; *y = (m_yOffset * getAttributeValue(YOffset)) + -xx * m_sinR * w + yy * m_cosR * h; }
void EFX::rotateAndScale(qreal* x, qreal* y) const { qreal xx = *x; qreal yy = *y; qreal w = m_width * getAttributeValue(Width); qreal h = m_height * getAttributeValue(Height); *x = (m_xOffset * getAttributeValue(XOffset)) + xx * m_cosR * w + yy * m_sinR * h; *y = (m_yOffset * getAttributeValue(YOffset)) + -xx * m_sinR * w + yy * m_cosR * h; }
void Chaser::adjustStepIntensity(qreal fraction, int stepIndex, FadeControlMode fadeControl) { QMutexLocker runnerLocker(&m_runnerMutex); if (m_runner != NULL) { m_runner->adjustStepIntensity(fraction * getAttributeValue(Intensity), stepIndex, fadeControl); } else { m_startupAction.m_intensity = fraction * getAttributeValue(Intensity); } }
void RGBMatrix::postRun(MasterTimer* timer, QList<Universe *> universes) { if (m_fader != NULL) { QHashIterator <FadeChannel,FadeChannel> it(m_fader->channels()); while (it.hasNext() == true) { it.next(); FadeChannel fc = it.value(); // fade out only intensity channels if (fc.group(doc()) != QLCChannel::Intensity) continue; bool canFade = true; Fixture *fixture = doc()->fixture(fc.fixture()); if (fixture != NULL) canFade = fixture->channelCanFade(fc.channel()); fc.setStart(fc.current(getAttributeValue(Intensity))); fc.setCurrent(fc.current(getAttributeValue(Intensity))); fc.setElapsed(0); fc.setReady(false); if (canFade == false) { fc.setFadeTime(0); fc.setTarget(fc.current(getAttributeValue(Intensity))); } else { if (overrideFadeOutSpeed() == defaultSpeed()) fc.setFadeTime(fadeOutSpeed()); else fc.setFadeTime(overrideFadeOutSpeed()); fc.setTarget(0); } timer->faderAdd(fc); } delete m_fader; m_fader = NULL; } { QMutexLocker algorithmLocker(&m_algorithmMutex); if (m_algorithm != NULL) m_algorithm->postRun(); } Function::postRun(timer, universes); }
/** * Convenience method which attempts to find the attribute with the given * name and returns its value as a boolean. This accepts "true", "false", * "yes", "no", "1" or "0" as valid values. * * @param pcszMatch name of attribute to find (see findAttribute() for namespace remarks) * @param f out: attribute value; overwritten only if attribute was found * @return TRUE if attribute was found and str was thus updated. */ bool ElementNode::getAttributeValue(const char *pcszMatch, bool &f) const { const char *pcsz; if (getAttributeValue(pcszMatch, pcsz)) { if ( (!strcmp(pcsz, "true")) || (!strcmp(pcsz, "yes")) || (!strcmp(pcsz, "1")) ) { f = true; return true; } if ( (!strcmp(pcsz, "false")) || (!strcmp(pcsz, "no")) || (!strcmp(pcsz, "0")) ) { f = false; return true; } } return false; }
/********************************************************************* * Running *********************************************************************/ void Audio::preRun(MasterTimer* timer) { if (m_decoder != NULL) { m_decoder->seek(elapsed()); AudioParameters ap = m_decoder->audioParameters(); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) #if defined(__APPLE__) || defined(Q_OS_MAC) //m_audio_out = new AudioRendererCoreAudio(); m_audio_out = new AudioRendererPortAudio(m_audioDevice); #elif defined(WIN32) || defined(Q_OS_WIN) m_audio_out = new AudioRendererWaveOut(m_audioDevice); #else m_audio_out = new AudioRendererAlsa(m_audioDevice); #endif m_audio_out->moveToThread(QCoreApplication::instance()->thread()); #else m_audio_out = new AudioRendererQt(m_audioDevice); #endif m_audio_out->setDecoder(m_decoder); m_audio_out->initialize(ap.sampleRate(), ap.channels(), ap.format()); m_audio_out->adjustIntensity(getAttributeValue(Intensity)); m_audio_out->setFadeIn(fadeInSpeed()); m_audio_out->start(); connect(m_audio_out, SIGNAL(endOfStreamReached()), this, SLOT(slotEndOfStream())); } Function::preRun(timer); }
void AttributeColorComponent::refresh() { ElemVector attrval; getAttributeValue(attrval); if (!attrval.empty()) { float red, green, blue, alpha; const ElemVector::size_type size = attrval.size(); if(size && attrval[0].isNumber()) { red = clip((double)attrval[0], 0., 1.); } if(size > 1 && attrval[1].isNumber()) { green = clip((double)attrval[1], 0., 1.); } if(size > 2 && attrval[2].isNumber()) { blue = clip((double)attrval[2], 0., 1.); } if(size > 3 && attrval[3].isNumber()) { alpha = clip((double)attrval[3], 0., 1.); } m_color = Colour::fromFloatRGBA(red, green, blue, alpha).toDisplayString(true); repaint(); } }
Triggerconf::STRING_LIST Triggerconf::getChildsAttribute (DOMNode* root, string nodename, string attribute) { STRING_LIST ret; if (root == NULL) { setError ("invalid root node"); return ret; } DOMNodeList* childs = root->getChildNodes (); if (childs == NULL) return ret; for (unsigned int i=0; i<childs->getLength (); i++) { DOMNode* child = childs->item (i); if (child == NULL || child->getNodeType () != DOMNode::ELEMENT_NODE) continue; const XMLCh* xnodename = child->getNodeName (); char* charname = XMLString::transcode (xnodename); if (nodename.compare (charname) == 0) ret.push_back (getAttributeValue (child, attribute)); XMLString::release (&charname); } // for (unsigned int i=0; i<childs->getLength (); i++) return ret; }
void RGBMatrix::preRun(MasterTimer* timer) { Q_UNUSED(timer); { QMutexLocker algorithmLocker(&m_algorithmMutex); m_group = doc()->fixtureGroup(m_fixtureGroupID); if (m_group == NULL) { // No fixture group to control stop(); return; } if (m_algorithm != NULL) { Q_ASSERT(m_fader == NULL); m_fader = new GenericFader(doc()); m_fader->adjustIntensity(getAttributeValue(Intensity)); m_fader->setBlendMode(blendMode()); // Copy direction from parent class direction m_direction = direction(); if (m_direction == Forward) { m_step = 0; m_stepColor = m_startColor.rgb(); } else { m_step = m_algorithm->rgbMapStepCount(m_group->size()) - 1; if (m_endColor.isValid()) { m_stepColor = m_endColor.rgb(); } else { m_stepColor = m_startColor.rgb(); } } calculateColorDelta(); if (m_algorithm->type() == RGBAlgorithm::Script) { RGBScript *script = static_cast<RGBScript*> (m_algorithm); QHashIterator<QString, QString> it(m_properties); while(it.hasNext()) { it.next(); script->setProperty(it.key(), it.value()); } } } } m_roundTime->start(); Function::preRun(timer); }
std::string ParserVocabulary::resolveAttributeValue(const NonIdentifyingStringOrIndex &input) const { unsigned int stringIndex = input._stringIndex; if (stringIndex == INDEX_NOT_SET) { return decodeCharacterString(input._characterString); } return getAttributeValue(stringIndex); }
const char* XmlElement::getAttributeValue(const char* name) { int index = getAttributeIndex(name); if (index < 0) { return ""; } return getAttributeValue(index).getBase(); }
void Chaser::setStepIndex(int idx) { QMutexLocker runnerLocker(&m_runnerMutex); if (m_runner != NULL) m_runner->setCurrentStep(idx, getAttributeValue(Intensity)); else m_startStepIndex = idx; }
/** * Like getAttributeValue (ministring variant), but makes sure that all backslashes * are converted to forward slashes. * @param pcszMatch * @param str * @return */ bool ElementNode::getAttributeValuePath(const char *pcszMatch, RTCString &str) const { if (getAttributeValue(pcszMatch, str)) { str.findReplace('\\', '/'); return true; } return false; }
/** * Calls setAttributeValue on the Python object if it exists otherwise calls the * base class method * @param attName The name of the attribute * @param attr An attribute object */ void IFunctionAdapter::setAttribute(const std::string &attName, const Attribute &attr) { try { object value = object(handle<>(getAttributeValue(attr))); callMethod<void, std::string, object>(getSelf(), "setAttributeValue", attName, value); } catch (UndefinedAttributeError &) { IFunction::setAttribute(attName, attr); } }
void EFX::calculatePoint(Function::Direction direction, int startOffset, float iterator, float* x, float* y) const { iterator = calculateDirection(direction, iterator); iterator += convertOffset(startOffset + getAttributeValue(StartOffset)); if (iterator >= M_PI * 2.0) iterator -= M_PI * 2.0; calculatePoint(iterator, x, y); }
/** * Convenience method which attempts to find the attribute with the given * name and returns its value as an unsigned long integer.This calls * RTStrToUInt64Ex internally and will only output the integer if that * function returns no error. * * @param pcszMatch name of attribute to find (see findAttribute() for namespace remarks) * @param i out: attribute value; overwritten only if attribute was found * @return TRUE if attribute was found and str was thus updated. */ bool ElementNode::getAttributeValue(const char *pcszMatch, uint64_t &i) const { const char *pcsz; if ( (getAttributeValue(pcszMatch, pcsz)) && (VINF_SUCCESS == RTStrToUInt64Ex(pcsz, NULL, 0, &i)) ) return true; return false; }
Boolean XmlEntry::getAttributeValue(const char* name, String& value) const { const char* tmp; if (!getAttributeValue(name, tmp)) return false; value = String(tmp); return true; }
void SamplerWriteNode::processMessage(const char *inlet, const Message &message) { bool rec = getAttributeValue(ATTR_WRITING).getBoolean(0); if (utils::stringsMatch(inlet, INLET_WRITE)) { if (rec) { recorder_->add(message); } } }
DOMNode* Triggerconf::selectSubmodule (string modulename, string submodulename) { DOMNode* currentModule = selectModule (modulename); if (currentModule == NULL) { setError ("invalid module: " + modulename); return NULL; } DOMNodeList* childs = currentModule->getChildNodes (); if (childs == NULL) { if (autocreate == false) { setError ("submodule " + modulename + " not found"); return NULL; } else { resetError (); createSubmodule (modulename, submodulename); return selectSubmodule (modulename, submodulename); } } // if (childs == NULL) for (unsigned int i=0; i<childs->getLength (); i++) { DOMNode* node = childs->item (i); if (node == NULL || node->getNodeType () != DOMNode::ELEMENT_NODE) continue; char* xmlstring = XMLString::transcode (node->getNodeName ()); if (((string) ELEMENT_SUBMODULE_NAME).compare (xmlstring) != 0) { XMLString::release (&xmlstring); continue; } XMLString::release (&xmlstring); if ((getAttributeValue (node, ATTRIBUTE_NAME)).compare (submodulename) == 0) { resetError (); return node; } } // for (unsigned int i=0; i<childs->getLength (); i++) if (autocreate == false) { setError ("submodule " + submodulename + " not found"); return NULL; } else { resetError (); createSubmodule (modulename, submodulename); return selectSubmodule (modulename, submodulename); } }
void AttributeBoolComponent::refresh() { ElemVector state; getAttributeValue(state); bool val = false; if (!state.empty()) { val = (long)state[0]; button.setToggleState (val, dontSendNotification); } }
void AnyNode::processMessage(const char *inlet, const Message &message) { if (message.getTypes() == "") // bang only outputs the value { // pass } else // any message with some type tags sets the value and outputs it { setAttributeValue("value", message); } if (utils::stringsMatch(inlet, "0")) output("0", getAttributeValue("value")); }
pbl::PDF* ObjectModelParser::parsePDF(const TiXmlElement* pdf_elem, std::stringstream& error) { const char* pdf_type = pdf_elem->Attribute("type"); if (pdf_type) { if (string(pdf_type) == "uniform") { double dim = 0; double density = 0; if (getAttributeValue(pdf_elem, "dimensions", dim, error) && getAttributeValue(pdf_elem, "density", density, error)) { return new pbl::Uniform((int)dim, density); } } else if (string(pdf_type) == "discrete") { double domain_size; if (getAttributeValue(pdf_elem, "domain_size", domain_size, error)) { return new pbl::PMF((int)domain_size); } } else { error << "Unknown pdf type: " << pdf_type << endl; } } else { error << "PDF specification should contain 'type' attribute" << endl; } return 0; }
int AssetManagerGlue::XmlParser::nativeGetStyleAttribute() { ssize_t idx = indexOfStyle(); if (idx < 0) return 0; Res_value value; if (getAttributeValue(idx, &value) < 0) return 0; return value.dataType == value.TYPE_REFERENCE || value.dataType == value.TYPE_ATTRIBUTE ? value.data : 0; }
void EFX::preRun(MasterTimer* timer) { int serialNumber = 0; QListIterator <EFXFixture*> it(m_fixtures); while (it.hasNext() == true) { EFXFixture* ef = it.next(); Q_ASSERT(ef != NULL); ef->setSerialNumber(serialNumber++); } Q_ASSERT(m_fader == NULL); m_fader = new GenericFader(doc()); m_fader->adjustIntensity(getAttributeValue(Intensity)); Function::preRun(timer); }
DOMNode* Triggerconf::selectConfigElement (string modulename, string submodulename, string configname) { DOMNode* currentSubmodule = selectSubmodule (modulename, submodulename); if (currentSubmodule == NULL) { setError ("invalid submodule " + submodulename + " in module " + modulename); return NULL; } DOMNodeList* childs = currentSubmodule->getChildNodes (); if (childs == NULL) { setError ("submodule " + submodulename + " in module " + modulename + " not found"); return NULL; } for (unsigned int i=0; i<childs->getLength (); i++) { DOMNode* child = childs->item (i); if (child == NULL || child->getNodeType () != DOMNode::ELEMENT_NODE) continue; char* xmlstring = XMLString::transcode (child->getNodeName ()); if (((string) ELEMENT_CONFIGITEM_NAME).compare (xmlstring) != 0) { XMLString::release (&xmlstring); continue; } XMLString::release (&xmlstring); if ((getAttributeValue (child, ATTRIBUTE_NAME)).compare (configname) == 0) { resetError (); return child; } } // for (unsigned int i=0; i<childs->getLength (); i++) if (autocreate == false) { setError ("configelement " + configname + " not found"); return NULL; } else { resetError (); createConfigElement (modulename, submodulename, configname); return selectConfigElement (modulename, submodulename, configname); } }
//----------------------------------------------------------------------------- bool UIViewFactory::getAttributesForView (CView* view, IUIDescription* desc, UIAttributes& attr) const { bool result = false; std::list<std::string> attrNames; if (getAttributeNamesForView (view, attrNames)) { std::list<std::string>::const_iterator it = attrNames.begin (); while (it != attrNames.end ()) { std::string value; if (getAttributeValue (view, (*it), value, desc)) attr.setAttribute ((*it).c_str (), value.c_str ()); it++; } attr.setAttribute ("class", getViewName (view)); result = true; } return result; }
ATerm get_node_origin(int cid, ATerm t) { Node node = NodeFromTerm(t); AttributeList attrs = getNodeAttributes(node); while (!isAttributeListEmpty(attrs)) { Attribute attr = getAttributeListHead(attrs); if (isAttributeInfo(attr)) { const char *key = getAttributeKey(attr); ATerm value = getAttributeValue(attr); if (strcmp(key, "origin") == 0) { return ATmake("snd-value(origin(<term>))", value); } } attrs = getAttributeListTail(attrs); } return ATmake("snd-value(no-origin)"); }
//----------------------------------------------------------------------------- bool UIViewFactory::getAttributesForView (CView* view, const IUIDescription* desc, UIAttributes& attr) const { bool result = false; StringList attrNames; if (getAttributeNamesForView (view, attrNames)) { StringList::const_iterator it = attrNames.begin (); while (it != attrNames.end ()) { std::string value; if (getAttributeValue (view, *it, value, desc)) attr.setAttribute (*it, value); it++; } attr.setAttribute (UIViewCreator::kAttrClass, getViewName (view)); result = true; } return result; }
void Collection::write(MasterTimer* timer, QList<Universe *> universes) { Q_UNUSED(universes); if (elapsed() == 0) { Doc* doc = qobject_cast <Doc*> (parent()); Q_ASSERT(doc != NULL); QMutexLocker locker(&m_functionListMutex); QListIterator <quint32> it(m_functions); while (it.hasNext() == true) { Function* function = doc->function(it.next()); Q_ASSERT(function != NULL); // Append the IDs of all functions started by this collection // to a set so that we can track which of them are still controlled // by this collection which are not. m_runningChildren << function->id(); // Listen to the children's stopped signals so that this collection // can give up its rights to stop the function later. connect(function, SIGNAL(stopped(quint32)), this, SLOT(slotChildStopped(quint32))); function->adjustAttribute(getAttributeValue(Function::Intensity), Function::Intensity); function->start(timer, true, 0, overrideFadeInSpeed(), overrideFadeOutSpeed(), overrideDuration()); } } incrementElapsed(); { QMutexLocker locker(&m_functionListMutex); if (m_runningChildren.size() > 0) return; } stop(); }