Cross-module requests beyond otherModuleSetValue
Master/slave relationship covers otherModuleSetValue() — one module writing a single element on another. Basemodule offers four more request helpers for the other things a master commonly needs from its slave, all answered asynchronously through the same onOtherModuleEvent() already seen there.
otherModuleRequestPropertyDump(): get the whole current state of one property
Planner asks Navigator to dump its actions property right before it starts driving it, so its own onOtherModuleEvent() can react to whatever state it’s actually in rather than assuming one:
// src/modules/planner/planner.cpp, proceedToSlew()
otherModuleRequestPropertyDump(getString("slaves", "navigatormodule"), "actions");otherModuleRequestProfileLoad(): make the slave load a specific profile first
Same shape as a PL the user would click themselves (Profiles and families, the C++ side), but requested by the master. Sequencer uses it twice, once per auxiliary slave, each resolving which profile to request from its own data before asking:
// src/modules/sequencer/sequencer.cpp, SMFocusing()
QString focusProfile = getGridString("focusprofiles", "profile", "filter", QString::number(mCurrentFilterIndex));
if (focusProfile.isEmpty())
focusProfile = getString("focusparameters", "focusprofile");
if (!focusProfile.isEmpty())
otherModuleRequestProfileLoad(getString("slaves", "focusmodule"), focusProfile);// src/modules/sequencer/sequencer.cpp, SMGuideStarting()
QString guideProfile = getString("guideparameters", "guideprofile");
if (!guideProfile.isEmpty())
otherModuleRequestProfileLoad(getString("slaves", "guidermodule"), guideProfile);Planner uses the same call on its sequencer slave before handing it a target, picking the profile the user chose in the live planning grid:
// src/modules/planner/planner.cpp, proceedToSlew()
otherModuleRequestProfileLoad(getString("slaves", "sequencemodule"), getString("liveplanning", "profile"));otherModuleCreateLine(): append a row to a grid property owned by another module
Navigator sends the currently selected target straight into Planner’s own planning grid, as one new row, rather than setting each element on an existing line:
// src/modules/navigator/navigator.cpp
QVariantMap eltData;
eltData["object"] = getString("target", "targetname");
eltData["ra"] = getFloat("target", "targetra");
eltData["dec"] = getFloat("target", "targetde");
eltData["profile"] = profile;
otherModuleCreateLine(getString("slaves", "plannermodule"), "planning", eltData);otherModuleQuery()/onModuleQuery(): ask a question, get a computed answer back
The three helpers above all do something on the other module. otherModuleQuery() is different — a generic, named RPC call for asking a slave to compute and return something, without loading a profile or duplicating its data. Planner asks Sequencer how long a given profile would actually take to run, before committing to a slew:
// src/modules/planner/planner.cpp, before slewing
otherModuleQuery(getString("slaves", "sequencemodule"), "profileduration",
{{"profile", getString("liveplanning", "profile")}});The slave answers by overriding onModuleQuery() — look up the query name, compute, return a QVariantMap; anything unhandled falls through to the base implementation:
// src/modules/sequencer/sequencer.cpp
QVariantMap Sequencer::onModuleQuery(const QString &queryName, const QVariantMap ¶ms)
{
if (queryName == "profileduration")
{
// Peek at a stored profile's "sequence" grid without loading it,
// so this can be asked about any profile regardless of what is
// currently active (e.g. by the planner, before starting a line).
double totalSeconds = 0.0;
QJsonObject obj;
if (getDbProfile(getClassName(), params["profile"].toString(), obj))
{
// ... sums count*exposure across the stored grid ...
}
return { {"seconds", totalSeconds} };
}
return Basemodule::onModuleQuery(queryName, params);
}The answer travels back as an OST::EvType::qa event, delivered to the asking module’s onOtherModuleEvent() exactly like any other cross-module notification — read the query name back out to tell different pending answers apart, since a module may have more than one query in flight at once:
// src/modules/planner/planner.cpp, onOtherModuleEvent()
if (mod == getString("slaves", "sequencemodule") && ev == OST::EvType::qa && mWaitingDuration)
{
QJsonObject q = data.toJsonValue().toObject()["q"].toObject();
if (q["query"].toString() == "profileduration")
{
mWaitingDuration = false;
double seconds = q["result"].toObject()["seconds"].toDouble();
// ... decide whether there's still time to slew and shoot ...
}
}mWaitingDuration here plays the same role as the mWaitingSequence/mWaitingNavigator flags Master/slave relationship sets before a plain otherModuleSetValue() — every cross-module request is answered asynchronously, so the asking module always needs to remember what it’s still waiting for.