LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubVI running simultaneously errors

I'm parsing a json file several times using a sub VI and when I run it in highlight execution mode I see that the input string is different in the sub VI than what is being inputted into the other VI.

Here are the VIs:SubVISubVI

 

VIVI

Attached is the json file that's being parsed.  

 

 Edit: An example of the parsing going wrong is that the McKenna_Desired_Phi is outputting zero as well as several of the other parsed values

0 Kudos
Message 1 of 8
(2,912 Views)

I'm uncertain how JSON Parsing works.  I've used an XML Parser that does "Search Parsing" -- you give it an XML String and "what you are looking for", it searches down the String until it finds the item, parses it, then gives you the rest of the String.  If each element you are trying to extract occurs exactly once in the String, then you can make the parsing "order-independent" by simply parsing the entire String each time, but this will be much slower than parsing "Element 1", then "Element 2" (from "rest of string"), as each Search will immediately succeed and you'll march down the ever-decreasing "rest of String" until you are done.

 

Does JSON work similarly?  Are elements of the Tree unique?  Are they "removed" after the Parse?  Do you always search from the entire Tree?  Is the Parse order-dependent?

 

From your description, I'm guessing the answer to the critical last question above is "Yes", and explains the issues you are seeing.

 

Bob Schor

 

 

0 Kudos
Message 2 of 8
(2,887 Views)

So you're saying that I should parse them in the order that they are in the JSON file? i.e. Pressure -> Pressure_Reference->McKenna_Desired_Velocity-> etc. ?

 Like this: Parsing new.png

 

 

 

0 Kudos
Message 3 of 8
(2,879 Views)

Well, that would be the first thing I would try ...

 

Bob Schor

0 Kudos
Message 4 of 8
(2,876 Views)

Linear Parsing.png

 

This is still giving me 0 for the desired_phi, but now I am getting a "Param not found" error

 

Edit: Never mind the error was because my JSON wasn't being read, but the reading of zero is still there

0 Kudos
Message 5 of 8
(2,866 Views)

Time to hang up your Engineer hat and put on your Scientist hat.

 

Do some Experiments. 

  1. Write a "known" JSON File, but only write a single element, and make it non-zero.  Try to read it.  If successful, go to 2.  If failure, return to Forum and attach your test VI.
  2. Write JSON file with three elements.  Try to read it.  Conditions as Step 1.
  3. Gradually add elements to the File Creation, building up to the structure of the data/JSON file that generates the Error.  If successful, then the problem isn't JSON, but somewhere else in your code.  Return to the Forum, explain output of Tests, and either say "I found the bug, it was ..., and I'm marking this as the Solution", or attach your test VI and ask for more help.

Bob Schor

0 Kudos
Message 6 of 8
(2,857 Views)

Do you have a link to the json toolkit you are using?

0 Kudos
Message 7 of 8
(2,853 Views)

I figured it out, I needed to use "Fract/Exp String To Number" to parse out the double values

0 Kudos
Message 8 of 8
(2,842 Views)