Hello!
How can we copy failure rate of a component and paste it into another component using JavaScript code?
Hi Laila, can you explain a little more, what you want to achieve resp. your use-case (i.e. why do you want with JS copy data from one project into another one?)
Eckhardt
Hi Eckhardt ,
The idea behind this script is to have a project that is used as a generic library from which we can copy and paste FIT and failure modes for new projects automatically.
The script will search the partNumber of a component in the new project and look for the same PartNumber in the Generic library project in order to copy FIT and FMD and assign it automatically to the new project.
Please let me know if you need more detail.
Hello Laila,
why do you not import the library from the generic library project into your working project - no scripting would be required at all? Also usually you should not copy&paste failure data from a type in the library to your components but rather assign the type to your component. And when you import your components from an Excel-BOM the assignement of types can be done completely automatically (incl. the assignment of failure rates and failure modes to the components).
Hello Eckhardt,
could you please give us more details how to perform this.
Hi Laila,
I suppose you have access to the Ansys Learning Hub (?) - The Session #7 of the Full Tool Training has a detailed slideset (and also video) on how work with HW models and HW Libraries.
Dear Eckhardt,
We have noticed that the training process is not yielding the results we are looking for. Our objective is to populate the hardware library in a new project with properties, such as FTI and Failure Mode, from another internal generic Hardware Library that our company has created. Our aim is to run the script and have the FIT and FM automatically assigned to our new Part Number.
In the following script, we are attempting to fill the FIT, but it is not working, Is there another method to fill the FIT ?
function __createFailureRateData(scope) { if (!scope) { console.error("Scope is undefined in create method!"); } var failureRateData = FailureRateCatalogsFactory.eINSTANCE.create(FailureRateCatalogsPackage.Literals.FAILURE_RATE_DATA); // we create decisions here already var decisions = MExpressionsFactory.eINSTANCE.create(MExpressionsPackage.Literals.DECISIONS);decisions. description = description_source ; decisions. uris = uris_source ; failureRateData.decision = decisions; var feature = Metamodel.safetyModel.Failable.failureRateData; MediniModelModificationUtil.setValueOfFeature(scope, feature, failureRateData); return failureRateData;}
Best regards.Boumia Laila .
Eckhardt, I leave this to you as you started to answer, but Laila,
seems you are changing the factory.js, right? That is not a good way to do as we are publishing updates of that library from time to time.
I suggest to do any additional modifications outside of that file.
Jan
Hello Jan,
In fact, we are not modifying the factroy.js library, we are just using the function __createFailureRateData() in our script with some modifications to adapt it to our need.
The modifications are outside of that file.
What we are doing actually in our script for Failure Mode is the following:
we search the new Part Number in the generic Hardware library, if it exists, we take Failure Mode & FMD and assign them to the Part Number in the new Hardware Library using the function "CreateFailureMode"
// function to create Failures Mode function CreateFailureMode(scope) { if (!scope) { console.error("Scope is undefined in findOrCreate!"); } var found = Global.getFinder(scope).findByType(Metamodel.safetyModel.FailureMode, true); if (!found.isEmpty()) { // first() since 3.0.2 return found.first(); } // create failure mode for (var b = 0 ; b < failuresSize ; b ++){ var created = Factory.createElement(scope, Metamodel.safetyModel.FailureMode); created.name = failureMode[b]; created.failureRateDistribution = failureRateDistribution [b] ; } return created; }
The point is to the same for the FIT. We found this function as a way to do it, but we steel have difficulties to make it work:
Thank you for your support.
Laila.
first of all - as Jan mentioned, you should not fiddle around with functions which are in the core-factory function. Especially those starting with __
The creation/ copy of the failure rate data is way more complex ... you need to have the formula, the appropriate selection from the catalog, the definition of the appropriate variables, the scaling expression and much more things which impact the failure rate calculation. This all is very error prone if you have not a deep understanding of all the required data structures and for that reasons I would strongly argue against this approach - especially as errors may be un-noticed. As the numbers have a significant impact on the metrics calculation in DC Worksheet but also on the probability calculations with FTA, usually everything related to this would also require a qualification (e.g. a proof that the script does not introduce any errors)
May be we can have a call where you show me in more detail what you want to achieve and also explain to me why the build-in library support would not be sufficient.
Best regards,
Hi Eckhardt,
I appreciate to have a call and discuss in more details the topic. I will be thankfull if you can set a meeting from next week.
Laila