|
|
@ -239,7 +239,7 @@ void Actuators::parametersChanged() |
|
|
|
_actuatorTest.updateFunctions(actuators); |
|
|
|
_actuatorTest.updateFunctions(actuators); |
|
|
|
|
|
|
|
|
|
|
|
// check if there are required functions, but not set on any output
|
|
|
|
// check if there are required functions, but not set on any output
|
|
|
|
QSet<int> requiredFunctions = _mixer.requiredFunctions(); |
|
|
|
QSet<int> requiredFunctions = _mixer.getFunctions(true); |
|
|
|
_hasUnsetRequiredFunctions = false; |
|
|
|
_hasUnsetRequiredFunctions = false; |
|
|
|
for (int requiredFunction : requiredFunctions) { |
|
|
|
for (int requiredFunction : requiredFunctions) { |
|
|
|
if (uniqueConfiguredFunctions.find(requiredFunction) == uniqueConfiguredFunctions.end()) { |
|
|
|
if (uniqueConfiguredFunctions.find(requiredFunction) == uniqueConfiguredFunctions.end()) { |
|
|
@ -248,11 +248,92 @@ void Actuators::parametersChanged() |
|
|
|
} |
|
|
|
} |
|
|
|
emit hasUnsetRequiredFunctionsChanged(); |
|
|
|
emit hasUnsetRequiredFunctionsChanged(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateFunctionMetadata(); |
|
|
|
|
|
|
|
|
|
|
|
updateActuatorActions(); |
|
|
|
updateActuatorActions(); |
|
|
|
|
|
|
|
|
|
|
|
updateGeometryImage(); |
|
|
|
updateGeometryImage(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Actuators::updateFunctionMetadata() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Update the function parameter metadata:
|
|
|
|
|
|
|
|
// - remove the mixer functions that are unused with the current configration (e.g. if 4 motors -> remove motors 5-N)
|
|
|
|
|
|
|
|
// - use the specific labels
|
|
|
|
|
|
|
|
QSet<int> usedMixerFunctions = _mixer.getFunctions(false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QMap<int, QString> usedMixerLabels; |
|
|
|
|
|
|
|
for (int usedMixerFunction : usedMixerFunctions) { |
|
|
|
|
|
|
|
usedMixerLabels[usedMixerFunction] = _mixer.getSpecificLabelForFunction(usedMixerFunction); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_usedMixerLabels == usedMixerLabels) { |
|
|
|
|
|
|
|
// no update required
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
_usedMixerLabels = usedMixerLabels; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get the unused mixer functions
|
|
|
|
|
|
|
|
QSet<int> removedMixerFunctions; |
|
|
|
|
|
|
|
for(Mixer::ActuatorTypes::const_iterator iter = _mixer.actuatorTypes().constBegin(); |
|
|
|
|
|
|
|
iter != _mixer.actuatorTypes().constEnd(); ++iter) { |
|
|
|
|
|
|
|
if (iter.key() == "DEFAULT") |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = iter.value().functionMin; i <= iter.value().functionMax; ++i) { |
|
|
|
|
|
|
|
if (!usedMixerFunctions.contains(i)) { |
|
|
|
|
|
|
|
removedMixerFunctions.insert(i); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Now update all function facts (we need to treat them individually, as some might have extra functions)
|
|
|
|
|
|
|
|
for (int groupIdx = 0; groupIdx < _actuatorOutputs->count(); groupIdx++) { |
|
|
|
|
|
|
|
ActuatorOutput* group = qobject_cast<ActuatorOutput*>(_actuatorOutputs->get(groupIdx)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
group->forEachOutputFunction([&](ActuatorOutputSubgroup* subgroup, ChannelConfigInstance*, Fact* fact) { |
|
|
|
|
|
|
|
QStringList enumStrings = fact->enumStrings(); |
|
|
|
|
|
|
|
if (!enumStrings.empty()) { |
|
|
|
|
|
|
|
QVariantList enumValues = fact->enumValues(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Replace or add
|
|
|
|
|
|
|
|
for (int usedMixerFunction : usedMixerFunctions) { |
|
|
|
|
|
|
|
QString label = usedMixerLabels[usedMixerFunction]; |
|
|
|
|
|
|
|
int index = enumValues.indexOf(usedMixerFunction); |
|
|
|
|
|
|
|
if (index == -1) { |
|
|
|
|
|
|
|
// Insert at the right place
|
|
|
|
|
|
|
|
bool inserted = false; |
|
|
|
|
|
|
|
for (index = 0; index < enumValues.count() && !inserted; ++index) { |
|
|
|
|
|
|
|
if (enumValues[index].toInt() > usedMixerFunction) { |
|
|
|
|
|
|
|
enumValues.insert(index, usedMixerFunction); |
|
|
|
|
|
|
|
enumStrings.insert(index, label); |
|
|
|
|
|
|
|
inserted = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!inserted) { |
|
|
|
|
|
|
|
enumValues.append(usedMixerFunction); |
|
|
|
|
|
|
|
enumStrings.append(label); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
enumStrings[index] = label; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Remove
|
|
|
|
|
|
|
|
for (int removedMixerFunction : removedMixerFunctions) { |
|
|
|
|
|
|
|
int index = enumValues.indexOf(removedMixerFunction); |
|
|
|
|
|
|
|
if (index != -1) { |
|
|
|
|
|
|
|
enumValues.removeAt(index); |
|
|
|
|
|
|
|
enumStrings.removeAt(index); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fact->setEnumInfo(enumStrings, enumValues); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Actuators::updateActuatorActions() |
|
|
|
void Actuators::updateActuatorActions() |
|
|
|
{ |
|
|
|
{ |
|
|
|
_actuatorActions->clearAndDeleteContents(); |
|
|
|
_actuatorActions->clearAndDeleteContents(); |
|
|
|