Hi,
is there a possibility to import a mission profile?
I found nothing in the factory lib.
Sven
True, there is always a but... but luckily there is always a "but, but but" :-)
I checked a bit and this <?WORD FLAGGED?> thing should work:
var y = new java.lang.Integer(java.lang.Double.parseDouble("10.0"));
Jan
This is not supported Sven.
Hi , is there any update on this topic?
is support for a mission profile import (e.g. through the factory) planned in the future?
Regards,
Lukas
In the meantime i've created a workaround for my purposes. It's not an import, but it's a batch edit of existing mission profiles according to an excel table in a specific format.
This batch edit however only edits internal working cycles, not working phases.
The script is called "mission_profile_overwrite.js".
It requires the following custom libraries (all attached):
Hello Lukas,
did you actually try to use diff&merge to get the MP from one project in another one?
Eckhardt
Hello Eckhardt,
Thanks for the suggestion, however, the purpose of my script is for the creation of a lot of new mission profiles, which share the same Internal Working Cycles with the same "Ambient Temp" and "tau" but differ in "Self Increase Temp" (so actually not exactly the same internal working cycles).
For me and my colleagues, it was always a pain to create new mission profiles, because we just use a lot of them, and we cannot often reuse them in different projects. Being able to create the mission profiles in a spreadsheet therefore saves a lot of time (cumulative) because editing them there is quicker.
Lokas,
I had q uick look and I did not find the place where you actually really create a new mission profile, am I wrong?
You just fill data into existing mission profiles, right?
Hi Jan,
yes, my workflow is
- creating one mission profile manually with the required number of internal working cycles (they will all be the same for every mission profile)
- manually creating as many copies of that mission profile as i need
- importing the names and data with the script from an excel file
I'd love to actually create the mission profiles with the script, but i don't see how i can do this. In my understanding, this is not supported, right?
Hi Lukas, well as mentioned in some other article I was indeed working on the support and voila, it is ready just the very moment.
Find attached a draft new factory.js that can be sued. See this small snippet as an example:
// create custom mission profiles var mp = Factory.createElement(finder.getScope(), Metamodel.failureratecatalogs.MissionProfile); mp.name = "My first mission profile"; var wc = Factory.createElement(mp, Metamodel.failureratecatalogs.InternalWorkingCycle); wc.name = "My First Cycle"; var wp = Factory.createElement(mp, Metamodel.failureratecatalogs.WorkingPhase); wp.name = "My First Phase";
Important to notice is that you cannot create mission profiles in arbitrary scopes so you have to pass the project as scope and the factory will make sure it ends up in the right place.
This extension is draft so I am interested in any feedback to stabilize it.
Thanks
this is awesome, Thanks! I will change my script to a proper import/update of mission profiles, and post an update here.
One additional question: Is there a possibility to delete mission profiles or internal working cycles/working phases? I've tried to do this for a mission profile update script with the trashbin, but i guess the trashbin does not support this, am i right?
Hi Lukas,
technically that should be the same thing, maybe we added some barriers to the trashbin to avoid "entering new terraints", let me check first, maybe some tweak is necessary.
Happy Scripting
Lukas, some result:
Here a sample that I used for testing:
// $EXPERIMENTAL$load(".lib/trashbin.js");var mp = finder.findByType(Metamodel.failureratecatalogs.MissionProfile).and('name', 'My Profile').first();// works with any trashbin.js that is out there for longTrashbin.deleteElement(mp.internalWorkingCycles.get(0));Trashbin.deleteElement(mp.workingPhases.get(0));// works ONLY trashbin.js v2024-03-27 (!)Trashbin.deleteElement(mp);
Find attached the version hat supports it :-)
I tried to use the new lib, I was able to create "cycles", but I cannot set the temperature (t_ac) or "tau". I have no error message, but I cannot write.
Do this attribute needs a special data type? (I tried bigdecimal, but it does not work)
Sven, how did you try? This works for me:
var wc = Factory.createElement(mp, Metamodel.failureratecatalogs.InternalWorkingCycle);wc.name = "My First Cycle";wc.tau = parseBigDecimal("20.2");
Note: when you create the MissionProfile, there will be a default cycle already created.
I get this error message:
Failed to execute Java Script: class java.lang.Double cannot be cast to class java.math.BigDecimal (java.lang.Double and java.math.BigDecimal are in module java.base of loader 'bootstrap')
class java.lang.Double cannot be cast to class java.math.BigDecimal (java.lang.Double and java.math.BigDecimal are in module java.base of loader 'bootstrap')
When executing this:
myWorkingCycle.tau = parseBigDecimal(cycle[cycle_nr].getAttribute("factor"));
The data is an import from an XML File, which looks like this:
<tempProfiles xmi:id="L75348" uid="a95cd915-ce81-4f3f-b2af-99511b2f713c" name="Dummy">
<tempFactors xmi:id="L75349" temp="-40.0" factor="2.0"/>
<tempFactors xmi:id="L75369" temp="125.0" factor="1.0"/>
</tempProfiles>
Sven, this is strange, I even did almost the same and it worked.
Could you please try to just use parseBigDecimal with a fixed string in the first place?
It would be good to know whether that works.
So
// myWorkingCycle.tau = parseBigDecimal(cycle[cycle_nr].getAttribute("factor"));myWorkingCycle.tau = parseBigDecimal("0.2");
setting it directly works, but not with the imported "factor".
But:
The temperature averageAmbientTemperature does not work.
myWorkingCycle.averageAmbientTemperature = parseInt("10.0");
different error message:
Failed to execute Java Script: class java.lang.Double cannot be cast to class java.lang.Integer (java.lang.Double and java.lang.Integer are in module java.base of loader 'bootstrap')
class java.lang.Double cannot be cast to class java.lang.Integer (java.lang.Double and java.lang.Integer are in module java.base of loader 'bootstrap')
Sven,
yeah I saw this problem multiple times already and we don't have a nice solution yet as the value returned by parseInt is converted to Double by Rhino already. Anyway, this workaround shall work:
wc.averageAmbientTemperature = java.lang.Integer.valueOf("10");
that works. But there is always a but:
I have the "String" in the format: "15.0". How can I manage it, that only "15" is imported. (the part after the "dot" is always 0)