LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a "smart" String Output to the Front Panel

Solved!
Go to solution

 


for(imstuck) wrote:

 

My arrays should really all be outside the for loop, with autoindexing disabled as necessary Smiley Surprised

Of course...  😉

 

0 Kudos
Message 11 of 19
(1,126 Views)

@Richard2950 wrote:

I agree that it is an elegant solution, but I don't think it does what the user wants. The initial poster said that he has an array of strings coming in, and wants an array of strings going out, with those entries corresponding to incoming empty strings removed. Each retained array entry should have a corresponding sensor identifier added. In the snippet below the "Error Strings" array is the user's incoming array of strings and Output Array is the output. Each non-blank incoming entry has the sensor label attached and is appended to the output array. Blank entries in the incoming array are dropped and do not appear in the output array.

 

code snippet


Okay, the confused guy is back.

 

In regards to Richard's initial comments and suggestions (Message 8 and below), I tried this solution, but it contained one major flaw. My output error array (and you are correct, I am looking for an array) shows all of the errors and labels. The labels are appended to the error array as hoped, but for the errors that are blank I still have the sensor label. So my output array looks something like:

 

Sensor Label 1 - Output Error 1

Sensor Label 2 -

Sensor Label 3 - Output Error 3

Sensor Label 4 - Output Error 4

 

What I'm trying to do is get rid of the 2nd element in that example completely. I'm concerned that perhaps it is because I am defining the blank sensor errors in MATLAB and they actually aren't blank, but are rather a single character of a space. Perhaps there is either a way to take this into account or to change the error in the MATLAB script so that it is more LabVIEW friendly?

 

I have not tried the other method proposed, but it sounds that I need to use the combination of the 2 methods proposed by "for(imstuck)" (which is a great name BTW). One thing I don't fully understand about this method is what is going on with the 1-D Search Array function? I'm thinking that perhaps this is meant to cross-reference my output error array with a set error array that includes all of the errors I I could have.

 

If this is true, the problem with this is that each element of the array is unknown and can be infinite different possibilites. (Each element of the array says something like: "Warning: Sensor value ## exceeds (lower or upper) limit: ##" This is simply one option the error can have. It can also have 2 other forms not including the blank space, but the point being that I cannot simply cross-reference my array with another array and remove the blank entries.)

0 Kudos
Message 12 of 19
(1,117 Views)

You can scale up from Altenbach or for(imstuck)'s proposed solution.

 

For instance, you can use a Format Into String function to customize the error message. 

 

Are you trying to automatically build up a list of error codes based on whatever new error message that your code encounters?

Have you started implementing your own solution?  If so, can you post what you have so far?

0 Kudos
Message 13 of 19
(1,111 Views)

 


@twolfe13 wrote:
If this is true, the problem with this is that each element of the array is unknown and can be infinite different possibilites. (Each element of the array says something like: "Warning: Sensor value ## exceeds (lower or upper) limit: ##" This is simply one option the error can have. It can also have 2 other forms not including the blank space, but the point being that I cannot simply cross-reference my array with another array and remove the blank entries.)

 

You simply need a trivial modification:

 

  1. If the input string element is empty, remove it
  2. If the input string element is not found, return it unchanged
  3. if the input string element is in the lookup table, append the additional string
I thought the string is program generated, so why would it have different forms?

 

0 Kudos
Message 14 of 19
(1,109 Views)

The program is implemented as a script node in LabVIEW. It inputs the sensor data and checks the following things:

 

a) If the sensor is in range it does nothing (outputs a blank entry into my error array)

b) If the sensor is approaching the limit by a specified percentage, it gives a caution and outputs the sensor value and the limit it is approaching in the string.

c) If the sensor is beyond the limit, it gives a warning and outputs the sensor value the limit that has been exceeded in the string.

d) If the sensor is NaN or zero is outputs that the sensor may be disconnected or not reading properly.

 

So because the string may includes the sensor value (a double precision number), I cannot use a lookup table to cross-reference the array.

 

Also, I apologize for not uploading my program. I am using a government issued computer and there is this lovely rule where we can't use USB drives to transfer data from the computer I'm using to the computer I'm using for internet access. (Actually it's more complicated than that since I can transfer the data, but then it become encrypted which is of no use to anyone except myself when that occurs.)

0 Kudos
Message 15 of 19
(1,103 Views)

Try something like this:

 

  1. Use "trim whitespace" to clean up spurious characters.
  2. If the input string element is empty, ignore it
  3. If the input string element is not found, return it unchanged
  4. if the input string element is in the lookup table, append the additional string
  5. Build an array of all elements from steps 3&4.

 

Message 16 of 19
(1,102 Views)

Okay. Simple solution to my problem from earlier with Richard's program. I simply replaced the "Empty String/Path?" comparison tool with the "White Space?" comparison tool and it worked like a charm. Thanks very much for everyone's help!

0 Kudos
Message 17 of 19
(1,101 Views)

 


@twolfe13 wrote:

So because the string may includes the sensor value (a double precision number), I cannot use a lookup table to cross-reference the array.


 

OK, search the string for certain key words, e.g. using "search string" or "scan string for tokens" and parse the number depending on the outcome.

 

Can you at least upload a simple test file containing typically encountered strings?

0 Kudos
Message 18 of 19
(1,098 Views)

@altenbach wrote:

Try something like this:

 

  1. ... spurious ...

Kudos for teaching me a new word.

0 Kudos
Message 19 of 19
(1,091 Views)