NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to determine the mean value of a ping test via a batch file

Solved!
Go to solution

I have a batch file, that determines the mean value.

 

How can I now use this !mittelwert!-variable in my batch file to save/implement it in my teststand variables?

 

The important lines of the batch file are attached.

0 Kudos
Message 1 of 16
(1,625 Views)
Solution
Accepted by to0bi

Use the Call Executable Step Type and write stdout to a variable that can  be parsed

Oli_Wachno_0-1691125943189.png

 

0 Kudos
Message 2 of 16
(1,584 Views)

Thank you!

 

Is it also possible to determine the mean value of any IP-adress just in Teststand so that I don't need a batch file, so I need less files at the end for my program and the program is less error prone?

0 Kudos
Message 3 of 16
(1,532 Views)

No worries 🙂

 

Brilliant idea, since he ping command calculates a meanvalue by itself.

 

So your Step Setup would look something like

 

Oli_Wachno_0-1691392337816.png

The parsing of the returned string has to be accomplished  somehow though. You might want to consider using a code module for this: though TestStand String should be technically sufficient, the expression needed will probably not be very intuitive.

 

When parsing, keep in mind, that the ping command comes localized, so parsing on different OS region settings may cause the operation to fail.

 

 

 

0 Kudos
Message 4 of 16
(1,528 Views)

I stored the string of the pingtest in my standardoutput how you can see. 

Then i tried with the find() function to determine the Mittelwert (it's german for mean value) but it didn't work as i wished.

Do you know how i could extract the 0 from Mittelwert = 0ms?

 

 

Download All
0 Kudos
Message 5 of 16
(1,511 Views)

Keep it simple and stupid, don't use overly complex expressions.

 

Store the stdout to a local variable and use an expression step to do the parsing Find() will return the postion of "Mittelwert" within the string, from there on you can work with Right(), Left() and Split()

 

 

 

 

 

0 Kudos
Message 6 of 16
(1,501 Views)

Thank you so much for your help, unfortunately i am pretty new to this program and i don't exactly know how to use the most functions properly.

 

I stored the Variable in Locals.Mittelwert but there is no Value when i look in to my Variables after i tested the sequence.

Then i wanted to use the mentioned expression to find the wanted string but it also didn't work.

I don't know exactly what I'm doing wrong.

 

 

0 Kudos
Message 7 of 16
(1,494 Views)

Brilliant opportunity to learn, so I'm not giving you the solution yet the way to find out yourself 😉

 

Some of these steps may be merged, but for reason of simplicity, I described them seperately

1.) Store stdout in a local variable, e.g. Locals.PingResult

2.) Create a numeric variable and assign the result of the Find() operation applying Locals.PingResult

3.) Create a string variable and assign the result of the Right() operation

 

This is still not going to give you what you want, yet it'll help you to find out what you need. Especially if you single step through your code and watch the variable values after each operation

 

Recommendation:

  • try this on a new sequence file and use a stdout copied from the CLI
  • Read through the descriptions of the string operators
Message 8 of 16
(1,490 Views)

I do my best to understand the functions and learn through them 🙂 So i studied all the descriptions of the string operators and that would be my suggested solution.

 

First the "Call Executable" pings my desired IP address and should store the text in the Locals.PingResult-string.
After that the position of the characters "Mittelwert = " is determined.
After that the position of the first number of the determined ping.
After that the position of "ms".
Afterwards the pure numeric value of the ping can be determined with these positions.

But unfortunately it fails already at the first step, because the executable does not write the text into the local variable.

Below you could see the steps i used and also the Variables i created and that the Locals.PingResult has no value.

 

I actually already thought that it should work like this 😞 

 

Locals.pngSteps.png

  

0 Kudos
Message 9 of 16
(1,473 Views)
Solution
Accepted by to0bi

Ok, so let's see

 

I have just placed a Call Executable in an empty seq file like this

Oli_Wachno_0-1691471888974.png

Oli_Wachno_2-1691471976067.png

As you can see, I have also routed stderr to a local variable to see any errors occuring

 

Pausing the execution after the Call Exec Step and checking the variables shows

 

Oli_Wachno_3-1691472151073.png

Ping Result looks a little strange here, but hovering over shows 

 

Oli_Wachno_4-1691472213501.png

 

so the stdout has definitely returned the desired results

 

Can you please: 

  1. Try to establish the same command setup and run it? Is there an error being reported? Do you see the value in PingResult?
  2. Confirm that given an example string written into PingResult, your parsing algorithm returns the correct result?

 

Please also feel free to attach a sample sequence file to this thread for review

 

Cheers

Oli

 

 

 

0 Kudos
Message 10 of 16
(1,458 Views)