script void Sensors_should_be_linked_to_track_processors()
string suite = "demo";
string check = "Sensors should be linked to track processors";
string severity = "WARNING";
string message = "This is just a test";
bool checkPassed = true;
for (int i = 0; i != WsfSimulation.PlatformCount(); i += 1)
{
// For every sensor on each platform...
WsfPlatform platform = WsfSimulation.PlatformEntry(i);
for (int j = 0; j != platform.SensorCount(); j += 1)
{
WsfSensor sensor = platform.SensorEntry(j);
// ... find all track processors that it can reach.
// Do NOT follow external links from WsfTrackProcessors
// (which may have a "type" of either WSF_TRACK_PROCESSOR or WSF_TRACK_MANAGER)
Array<string> ignoreExternalLinks = Array<string>();
ignoreExternalLinks.PushBack("WSF_TRACK_PROCESSOR");
ignoreExternalLinks.PushBack("WSF_TRACK_MANAGER");
// Track processors may have a "type" of either WSF_TRACK_PROCESSOR or
// WSF_TRACK_MANAGER: Look for both, since a link to either is sufficient.
Array<WsfPlatformPart> linkedTrackProcs =
ScenarioAnalyzerUtils.LinkedAndReachablePlatformPartsChooseProcs(sensor,
"WSF_TRACK_PROCESSOR", ignoreExternalLinks, false);
Array<WsfPlatformPart> linkedTrackMgrs =
ScenarioAnalyzerUtils.LinkedAndReachablePlatformPartsChooseProcs(sensor,
"WSF_TRACK_MANAGER", ignoreExternalLinks, false);
// sensor fails the Check if it is not linked to any WsfTrackProcessor
if (linkedTrackProcs.Size() <= 0 && linkedTrackMgrs.Size() <= 0)
{
checkPassed = false;
Array<string> fileLocationTypes = Array<string>();
Array<string> fileLocationNames = Array<string>();
fileLocationTypes.PushBack("platform");
fileLocationNames.PushBack(platform.Name());
fileLocationTypes.PushBack("sensors");
fileLocationNames.PushBack(sensor.Name());
string message = "Sensor " + sensor.Name() + " on platform " + platform.Name() +
" is not linked directly or indirectly to a track processor";
ScenarioAnalyzerUtils.SendResultMessageWithLinks(suite, check, severity,
message, fileLocationTypes, fileLocationNames);
}
}
}
if (checkPassed)
{
ScenarioAnalyzerUtils.SendPassMessage(suite, check);
}
end_script