I am trying to create a failure across a few stations utilizing SimTalk.
I am using a dialog box to retrieve the Name, Availability, and MTTR of a failure. I am then storing the name in a variable and creating a failure off of the information provided.
The problem I am having is that the variable cannot be used in an assignment statement for Availability or MTTR.
See the following code below:
tempName := FailureDialog.getValue("NameEditBox");
Station1.Failures.tempName.Availability := 95.00;
Station1.Failures.tempName.MTTR := str_to_time("1:00:00");
This code does not work as I get an error for an Unknown identifier for Failures.tempName.
Is there a way to assign Availability and MTTR to a specific failure in simtalk?
Station1.Failures.tempName addresses a Failure named "tempName". If the local variable 'tempName' contains the string "abc", you would have to write Station1.Failures.abc instead. So for your code to work, you first have to retrieve the just created failure like this:
local tempName : string := FailureDialog.getValue("NameEditBox"); Station1.Failures.createFailure(tempName); local f := Station1.Failures.getFailure(tempName); f.Availability := 95.00; f.MTTR := str_to_time("1:00:00");
Thank you Michael!
That worked perfectly.
Now, I have one more question:
I have this code in my reset method and so if I click reset twice, I get the error that the name already exists in the name scope of the object. This is because it is trying to create the same failure again. Is there an if statement or something that can ignore the createFailure call if the failure name already exists?
Thank you in advance!
have you tried
if Station1.Failures.getFailure("failureName") = VOID then Station1.Failures.createFailure("failureName"); . .