Hi Jan,
how can I create a profile property to show me the max. ASIL of each hazard? (e.g. in the Hazard collection table)
thanks,
Sven
Oh, yes, there is the final access to the attribute missing:
self.mediniGetOpposites('hazard').toArray().sort(function compare(a, b) { return a.compareIL(b);}).pop().asil;
Jan
Hello Sven,
I actually have something similar for FDAL in the aersopace example for the hardard.
You should be able to adjust the profile property exchanginf ARP4751A_fdal with ISO26262_asil and adjusting the inverted letter order.
var he=finder.findByType(Metamodel.hazard.HazardousEvent,true).asList();var hevents = new Array();var fdal = "E";var fdalmax = "E";for (var i=0;i<he.size();i++){ if(he.get(i).hazard==self){ hevents.push(he.get(i)); fdal=he.get(i).ARP4754_fdal; if (fdal=="E"){ } else if (fdal=="D" && (fdalmax=="E")){ fdalmax=fdal; } else if (fdal=="C" && (fdalmax=="D" || fdalmax=="E")){ fdalmax=fdal; } else if (fdal=="B" && (fdalmax=="C" || fdalmax=="D" || fdalmax=="E")){ fdalmax=fdal; } else if (fdal=="A" && (fdalmax=="B" || fdalmax=="C" || fdalmax=="D" || fdalmax=="E")){ fdalmax=fdal; } }}fdalmax
Regards Nils
Sven, Nils,
I played a bit with OCL and JS and found a rather neat solution which even should work for all domains.
Background is that we have a generic operation in place to compare the "integrity levels":
self.mediniGetOpposites('hazard').toArray().sort(function compare(a, b) { return a.compareIL(b);}).pop();
This snippet returns the hazardous event with the highest ASIL, isn't that neat?
Happy Scripting
I am not sure if I understood it right:
The script is "prompting" me the hazard with the highest ASIL?
If yes, this is not really what I need. I need an ASIL (max) for each hazard.
Ich bekomme da eine Fehlermeldung. Wo ist die funktion compare()?
Hi Sven,
which version are you using? I tested this script with 2020 R1. Could you paste the error here?
At least the top of the stacktrace, no all of it :-)
The "compare" is just used here as a name, it should not matter.
JS expects a function with two parameters.
I am using also 2020 R1.
I think my problem was that I thought this is an OCL expression. I Added the property as JS, then it works, if there is an situation attached. If the returnvalue is empty, it will promt an error.
I will try to fix this.
Ah, true, the script does not handle exceptions yet. OCL would do that better but has no good sorting feature.
Maybe you can post the working solution and mark as answered :-)
I tried to catch the exeption with:
if (self.mediniGetOpposites('hazard') == null) {"n/a"}
but it doesn't work. Do I have to check for something else?
I did it! with "try" and "catch"
Thanks for fast support
Cool! Btw:
should be
if (self.mediniGetOpposites('hazard').isEmpty()) {"n/a"}
Always a list is returned, never null but maybe empty.