Discussions
Categories
Groups
Documentation
Knowledge base
Developer portal
App catalog
The Hub
GitHub
Home
Newly Imported
Restricted
NXP
Metamodel: Can't find how DCComponentENtries are connected to SafetyGoals
medini_1036867805
In the 2020 R1 meta model documentation I cannot find how safety goals are bound to the components in a FMEDA sheet. Could you please give ma a pointer? Background: I'm trying to write a script which unassigns a particular safety goal (SG-003) from all model entries in a FMEDA. I'm attaching how far I got. I'm stuck in line 59 now.
Find more posts tagged with
medini
medini legacy
Accepted answers
All comments
medini_1036867805
Also, when I add a naive "alert(entry);" statement to my code, the resulting GUI alert doesn't reveal and safety goal related hints. See screen shot.
medini_1023909254
Hi Rolf, is there any reason you want to do this with a script? The easiest (and least dangerous) way would be to deselect the goal at the cover page of the DC Worksheet: Otherwise you can also remove the goal from the DC worksheet using a script. The list of goals for a worksheet is contained in Metamodel.dc::DCWorksheet.safetyGoals On the other side, if you really want to keep the goal for the worksheet but remove it as safety related from the individual DCComponentEntry's it is probably more tricky. The DCComponentEntry is having two attributes: safetyRelated (true or false) indicates whether the component is safety related for all (i.e. displayed as "all SGs" in the worksheet) or only for selected safety goals of the worksheet (e.g. displayed as "SG002, SG003") safetyRelatedFor is the list of safety goals which are used in case of safetyRelated==false (it is empty in case safetyRelated ==true) So in this case you would have to set the safetyRelated for all DCComponentEntry's and build/set the list of relevant SG (safetyRelateFor) I hope this helps, Eckhardt
medini_1036867805
Thanks Eckhardt, yes, this helps. Background situation: I have a safety goal which is only violated by very few model elements, but not "none". Thus I need to keep this safety goal on the cover page. As soon as I add it to the cover page, automatically all model elements are marked to violate this rare safety goal. I manually have to remove it from all model elements except few. It's more efficient to remove the safety goal from all and then add it to the few again. I have finished the manual task in the mean time. So it's less urgent now. I will try to further develop my script once I find time to do so. Any code snippet how to set "safetyRelatedFor" would help. Is it a string variable? Or is it a object pointer list? Rolf
medini_1023909254
Hi Rolf, no warranty on completeness, but this should probably do it: function removeSG() {
if(verbose){
var selected = selectOption(
"Update Safety Related For",
"\nThis script will remove a selected safety goal from the list of goals shown as safety related", [ "Continue", "Cancel" ]);
if (selected == 1) {
alert("No changes have been made.");
return;
};
};
if (!selection || selection.length != 1
|| selection[0].prototype != Metamodel.dc.DCWorksheet) {
alert("No or invalid selection - please select a single DC Worksheet.");
return
}
if (selection[0].mediniGetContainer() != undefined) {
alert( "No or invalid selection - please select a single DC Worksheet.");
return
}
targetModel = selection[0];
var componentEntries = Global.getFinder(targetModel).findByType(Metamodel.dc.DCComponentEntry, true).asArray();
var theGoals = new java.util.ArrayList(targetModel.safetyGoal);
excludeGoal = selectElement("Select the Goal to remove", Metamodel.safetygoals.SafetyGoal, false, undefined, "The selected goal will be removed from all DC Components as safety related", theGoals)
theGoals.remove(excludeGoal);
componentEntries.forEach(function handleGoals(entry)
{
entry.safetyRelated = false;
entry.safetyRelatedFor = theGoals;
});
} Best regards, Eckhardt
medini_1036867805
Hi Eckhardt, Happy New Year 2021! Yes, this code helps my understanding. However, I see a risk that it modifies more than I intend do. I see how it removes "excludeGoal" from all componentEntries - that's the intent, fine. But as a side effect the code seems to assign ALL other safety goals to ALL component entries by line: entry.safetyRelatedFor
= theGoals; So any existing specific relations of components to safety goals seem to get lost? I didn't try the code out . Example: Want to remove G03 (unintended changes marked in bold): Before: comp1: G01, G02, G03 comp2: G01, G03 comp3: G02, G03 After: comp1: G01, G02 comp2: G01, G02 comp3: G01, G02 But I think I know how this could get fixed by pulling the assignment "theGoals = ..." into the "forEach". Rolf
medini_1023909254
Hi Rolf, Happy New Year to you too. yes, you are right. The script was intended to be used directly after creating the DC Sheet. In case already some (de)-selections have been done manually, it becomes a little bit more tricky, as the case "ALL" is handled differently. Therefore lines 24-30 should be replaced by excludeGoal = selectElement("Select the Goal to remove", Metamodel.safetygoals.SafetyGoal, false, theGoals)
theGoals.remove(excludeGoal);
componentEntries.forEach(function handleGoals(entry)
{
if(entry.safetyRelated == true){
entry.safetyRelated = false;
entry.safetyRelatedFor = theGoals;
}
else {
entry.safetyRelatedFor.remove(excludeGoal)
}
}); Best regards, Eckhardt
Quick Links
All Categories
Recent Posts
Activity
Unanswered
Groups
Help
Best Of