ErrorReporting: MP error attribution
This commit is contained in:
parent
cbe46468d1
commit
de90c281a5
3 changed files with 60 additions and 5 deletions
src
|
@ -249,6 +249,11 @@ FGAIBase::removeModel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FGAIBase::setScenarioPath(const std::string& scenarioPath)
|
||||||
|
{
|
||||||
|
_scenarioPath = scenarioPath;
|
||||||
|
}
|
||||||
|
|
||||||
void FGAIBase::readFromScenario(SGPropertyNode* scFileNode)
|
void FGAIBase::readFromScenario(SGPropertyNode* scFileNode)
|
||||||
{
|
{
|
||||||
if (!scFileNode)
|
if (!scFileNode)
|
||||||
|
@ -330,6 +335,10 @@ void FGAIBase::update(double dt) {
|
||||||
if (fxpath != "")
|
if (fxpath != "")
|
||||||
{
|
{
|
||||||
simgear::ErrorReportContext ec("ai-model", _name);
|
simgear::ErrorReportContext ec("ai-model", _name);
|
||||||
|
if (!_scenarioPath.empty()) {
|
||||||
|
ec.add("scenario-path", _scenarioPath);
|
||||||
|
}
|
||||||
|
|
||||||
props->setStringValue("sim/sound/path", fxpath.c_str());
|
props->setStringValue("sim/sound/path", fxpath.c_str());
|
||||||
|
|
||||||
// Remove any existing sound FX (e.g. from another model)
|
// Remove any existing sound FX (e.g. from another model)
|
||||||
|
@ -629,6 +638,10 @@ bool FGAIBase::init(ModelSearchOrder searchOrder)
|
||||||
_modeldata->addErrorContext("ai", _name);
|
_modeldata->addErrorContext("ai", _name);
|
||||||
_modeldata->captureErrorContext("scenario-path");
|
_modeldata->captureErrorContext("scenario-path");
|
||||||
|
|
||||||
|
if (_otype == otMultiplayer) {
|
||||||
|
_modeldata->addErrorContext("multiplayer", getCallSign());
|
||||||
|
}
|
||||||
|
|
||||||
vector<string> model_list = resolveModelPath(searchOrder);
|
vector<string> model_list = resolveModelPath(searchOrder);
|
||||||
_model= SGModelLib::loadPagedModel(model_list, props, _modeldata);
|
_model= SGModelLib::loadPagedModel(model_list, props, _modeldata);
|
||||||
_model->setName("AI-model range animation node");
|
_model->setName("AI-model range animation node");
|
||||||
|
|
|
@ -147,6 +147,9 @@ public:
|
||||||
double _getCartPosZ() const;
|
double _getCartPosZ() const;
|
||||||
|
|
||||||
osg::PagedLOD* getSceneBranch() const;
|
osg::PagedLOD* getSceneBranch() const;
|
||||||
|
|
||||||
|
void setScenarioPath(const std::string& scenarioPath);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double _elevation_m;
|
double _elevation_m;
|
||||||
|
|
||||||
|
@ -167,6 +170,7 @@ protected:
|
||||||
std::string _submodel;
|
std::string _submodel;
|
||||||
std::string _name;
|
std::string _name;
|
||||||
std::string _parent;
|
std::string _parent;
|
||||||
|
std::string _scenarioPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tied-properties helper, record nodes which are tied for easy un-tie-ing
|
* Tied-properties helper, record nodes which are tied for easy un-tie-ing
|
||||||
|
|
|
@ -68,7 +68,9 @@ enum class Aggregation {
|
||||||
Scenario,
|
Scenario,
|
||||||
InputDevice,
|
InputDevice,
|
||||||
FGData,
|
FGData,
|
||||||
Unknown ///< error coudln't be attributed more specifcially
|
MultiPlayer,
|
||||||
|
Unknown, ///< error coudln't be attributed more specifcially
|
||||||
|
OutOfMemory ///< seperate category to give it a custom message
|
||||||
};
|
};
|
||||||
|
|
||||||
// these should correspond to simgear::ErrorCode enum
|
// these should correspond to simgear::ErrorCode enum
|
||||||
|
@ -83,9 +85,9 @@ string_list static_errorIds = {
|
||||||
"error-audio-fx-load",
|
"error-audio-fx-load",
|
||||||
"error-xml-load-command",
|
"error-xml-load-command",
|
||||||
"error-aircraft-systems",
|
"error-aircraft-systems",
|
||||||
"error-input-device-config"
|
"error-input-device-config",
|
||||||
"error-ai-traffic-schedule",
|
"error-ai-traffic-schedule",
|
||||||
};
|
"error-terrasync"};
|
||||||
|
|
||||||
string_list static_errorTypeIds = {
|
string_list static_errorTypeIds = {
|
||||||
"error-type-unknown",
|
"error-type-unknown",
|
||||||
|
@ -93,7 +95,9 @@ string_list static_errorTypeIds = {
|
||||||
"error-type-out-of-memory",
|
"error-type-out-of-memory",
|
||||||
"error-type-bad-header",
|
"error-type-bad-header",
|
||||||
"error-type-bad-data",
|
"error-type-bad-data",
|
||||||
"error-type-misconfigured"};
|
"error-type-misconfigured",
|
||||||
|
"error-type-io",
|
||||||
|
"error-type-network"};
|
||||||
|
|
||||||
|
|
||||||
string_list static_categoryIds = {
|
string_list static_categoryIds = {
|
||||||
|
@ -105,7 +109,9 @@ string_list static_categoryIds = {
|
||||||
"error-category-scenario",
|
"error-category-scenario",
|
||||||
"error-category-input-device",
|
"error-category-input-device",
|
||||||
"error-category-fgdata",
|
"error-category-fgdata",
|
||||||
"error-category-unknown"};
|
"error-category-multiplayer",
|
||||||
|
"error-category-unknown",
|
||||||
|
"error-category-out-of-memory"};
|
||||||
|
|
||||||
class RecentLogCallback : public simgear::LogCallback
|
class RecentLogCallback : public simgear::LogCallback
|
||||||
{
|
{
|
||||||
|
@ -164,6 +170,7 @@ public:
|
||||||
SGPropertyNode_ptr _enabledNode;
|
SGPropertyNode_ptr _enabledNode;
|
||||||
SGPropertyNode_ptr _displayNode;
|
SGPropertyNode_ptr _displayNode;
|
||||||
SGPropertyNode_ptr _activeErrorNode;
|
SGPropertyNode_ptr _activeErrorNode;
|
||||||
|
SGPropertyNode_ptr _mpReportNode;
|
||||||
|
|
||||||
using ErrorContext = std::map<std::string, std::string>;
|
using ErrorContext = std::map<std::string, std::string>;
|
||||||
/**
|
/**
|
||||||
|
@ -328,6 +335,13 @@ public:
|
||||||
auto ErrorReporter::ErrorReporterPrivate::getAggregateForOccurence(const ErrorReporter::ErrorReporterPrivate::ErrorOcurrence& oc)
|
auto ErrorReporter::ErrorReporterPrivate::getAggregateForOccurence(const ErrorReporter::ErrorReporterPrivate::ErrorOcurrence& oc)
|
||||||
-> AggregateErrors::iterator
|
-> AggregateErrors::iterator
|
||||||
{
|
{
|
||||||
|
// all OOM errors go to a dedicated category. This is so we don't blame
|
||||||
|
// out of memory on the aircraft/scenery/etc, when it's not the underlying
|
||||||
|
// cause.
|
||||||
|
if (oc.type == simgear::LoadFailure::OutOfMemory) {
|
||||||
|
return getAggregate(Aggregation::OutOfMemory, {});
|
||||||
|
}
|
||||||
|
|
||||||
if (oc.hasContextKey("primary-aircraft")) {
|
if (oc.hasContextKey("primary-aircraft")) {
|
||||||
const auto fullId = fgGetString("/sim/aircraft-id");
|
const auto fullId = fgGetString("/sim/aircraft-id");
|
||||||
if (fullId != fgGetString("/sim/aircraft")) {
|
if (fullId != fgGetString("/sim/aircraft")) {
|
||||||
|
@ -337,6 +351,16 @@ auto ErrorReporter::ErrorReporterPrivate::getAggregateForOccurence(const ErrorRe
|
||||||
return getAggregate(Aggregation::HangarAircraft, fullId);
|
return getAggregate(Aggregation::HangarAircraft, fullId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oc.hasContextKey("multiplayer")) {
|
||||||
|
return getAggregate(Aggregation::MultiPlayer, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
// all TerraSync coded errors go there: this is errors for the
|
||||||
|
// actual download process (eg, failed to write to disk)
|
||||||
|
if (oc.code == simgear::ErrorCode::TerraSync) {
|
||||||
|
return getAggregate(Aggregation::TerraSync, {});
|
||||||
|
}
|
||||||
|
|
||||||
if (oc.hasContextKey("terrain-stg")) {
|
if (oc.hasContextKey("terrain-stg")) {
|
||||||
// determine if it's custom scenery, TerraSync or FGData
|
// determine if it's custom scenery, TerraSync or FGData
|
||||||
|
|
||||||
|
@ -550,6 +574,7 @@ void ErrorReporter::bind()
|
||||||
|
|
||||||
d->_displayNode = n->getNode("display", true);
|
d->_displayNode = n->getNode("display", true);
|
||||||
d->_activeErrorNode = n->getNode("active", true);
|
d->_activeErrorNode = n->getNode("active", true);
|
||||||
|
d->_mpReportNode = n->getNode("mp-report-enabled", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ErrorReporter::unbind()
|
void ErrorReporter::unbind()
|
||||||
|
@ -594,6 +619,7 @@ void ErrorReporter::init()
|
||||||
void ErrorReporter::update(double dt)
|
void ErrorReporter::update(double dt)
|
||||||
{
|
{
|
||||||
bool showDialog = false;
|
bool showDialog = false;
|
||||||
|
bool havePendingReports = false;
|
||||||
|
|
||||||
// beginning of locked section
|
// beginning of locked section
|
||||||
{
|
{
|
||||||
|
@ -623,6 +649,13 @@ void ErrorReporter::update(double dt)
|
||||||
|
|
||||||
// check if an error is current active
|
// check if an error is current active
|
||||||
for (auto& report : d->_aggregated) {
|
for (auto& report : d->_aggregated) {
|
||||||
|
if (report.type == Aggregation::MultiPlayer) {
|
||||||
|
if (!d->_mpReportNode->getBoolValue()) {
|
||||||
|
// mark it as shown, to supress it
|
||||||
|
report.haveShownToUser = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (report.haveShownToUser) {
|
if (report.haveShownToUser) {
|
||||||
// unless we ever re-show?
|
// unless we ever re-show?
|
||||||
continue;
|
continue;
|
||||||
|
@ -635,9 +668,14 @@ void ErrorReporter::update(double dt)
|
||||||
|
|
||||||
// if we show one report, don't consider any others for now
|
// if we show one report, don't consider any others for now
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
havePendingReports = true;
|
||||||
}
|
}
|
||||||
} // of active aggregates iteration
|
} // of active aggregates iteration
|
||||||
|
|
||||||
|
if (!havePendingReports) {
|
||||||
|
d->_reportsDirty = false;
|
||||||
|
}
|
||||||
} // end of locked section
|
} // end of locked section
|
||||||
|
|
||||||
// do not call into another subsystem with our lock held,
|
// do not call into another subsystem with our lock held,
|
||||||
|
|
Loading…
Add table
Reference in a new issue