03-20-2024 03:26 AM - edited 03-20-2024 03:44 AM
Hello everyone,
I am automating tests and I need that as the program progresses an indicator is updated with the status of the test. The test I am going to share works correctly, it is just in case something unexpected happens, to be able to see what has failed and where.
For example, in the VI that I share with you follows the following steps:
1. Start communications.
2. Write an old date to activate the alarm.
3. Type the UTC to deactivate the alarm.
4. Close communications.
What I want is that the indicator shows the following (if it works correctly):
1. Initiating communications...
2. Typing an incorrect date...
3. Reading alarm...
4. Typing UTC...
5. Reading alarm...
6. Closing communications...
7. Test finished.
But if for example it fails in step 2 I want it to drag the error message "ERROR. Write failed." during the whole test until the test is finished (even if the test is not running or running badly).
I have tried to do it with unbundles, local variables, etc. But this messes up my code a lot and I'm sure there is a better solution but I can't think of any.
Thanks in advance. Attached is an image and the .vi.
03-20-2024 03:48 AM
Hi xespizua,
@xespizua wrote:
But if for example it fails in step 2 I want it to drag the error message "ERROR. Write failed." during the whole test until the test is finished (even if the test is not running or running badly).
Implement a proper statemachine scheme and all things will fall into place!
(And no: you should not call a STOP function somewhen in the middle of the VI execution!)
03-20-2024 04:08 AM
That's not the point of the conversation.
This test is already in a state machine with other tests working fine.
And i know about the stop function but the structure of the code its non-negociable.
Im just asking about other things.
Thank you, i guess...
03-20-2024 04:58 AM - edited 03-20-2024 05:00 AM
Hi xespizua,
@xespizua wrote:
This test is already in a state machine with other tests working fine.
My point is: you need to convert this test (that is already a state of a parent state machine) also into a state machine...
Then each step in this test could set the status indicator and you can EASILY omit other steps based on conditions given by earlier steps!
@xespizua wrote:
the structure of the code its non-negociable.
Then you need to throw even more locals, case structures and or sequence frames into this already "structure-less" block diagram...
@xespizua wrote:
Im just asking about other things.
So you ask for comments (and help) but refuse to take those comments?
03-20-2024 05:31 AM - edited 03-20-2024 05:32 AM
Hi Gerd,
Im sorry if I have bothered you by answering, I was not understanding you about the state machine and I am desperate with this problem.
I cant change this test into a state machine because i would have to change another 20 test more or less (that are more complex and work fine) and remake all the main part of the project.
So, sorry again.
03-20-2024 05:34 AM
Hi xespizua,
@xespizua wrote:
I cant change this test into a state machine because i would have to change another 20 test more or less (that are more complex and work fine) and remake all the main part of the project.
You can't change this single test VI alone?
03-20-2024 05:54 AM
Yes, I can.
But the problem I have with the indicator is for all the tests, not only for this one. My intention is to add an indicator for each test.
So I would have to change all the tests and convert them into a state machines.
I know that the answer to this is "well, you have to convert them one by one".
But if I cant find another solution that suits me better, I have no choice but not to put this function of the indicator.
03-20-2024 06:13 AM
>> I have tried to do it with unbundles, local variables, etc. But this messes up my code a lot and I'm sure there is a better solution but I can't think of any.
You've ruled out the better solution, so you're left with messy code.
>> if for example it fails in step 2 I want it to drag the error message "ERROR. Write failed." during the whole test
Inspect the value of the indicator after each test and only update it if it does not contain the string "ERROR".
03-20-2024 06:42 AM
>> Inspect the value of the indicator after each test and only update it if it does not contain the string "ERROR".
After each test i clean the errors.
What i want is to drag the error ocurred during the current test, not after the test.
03-20-2024 07:21 AM
Do the same as you have now but input a reference to a status indicator. This way you can call the test from another VI and have the test VI update an external status indicator.
Something like this as a subVI. If there is any error during the test, the error propagates and "ERROR" will be written every time.