LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help

Solved!
Go to solution

Guys,

 

I would like to know if there is an elegant way (maybe using regular expressions) to solve this:

 

incoming string looks like this:

 

Event Log Started: 11/10/2011 11:49:28 AM
Time, System Event
11/10/2011 11:49:29 AM, FILE SAVING ENABLED
11/10/2011 11:49:33 AM, PUMP STARTING
11/10/2011 11:49:34 AM, PUMP DISCONNECTED
11/10/2011 11:49:35 AM, PUMP STOPPED
11/10/2011 11:49:36 AM, PUMP STARTING
11/10/2011 11:49:42 AM, PUMP RUNNING
11/10/2011 11:49:43 AM, STARTING CURRENT: 2.10 (A)

 

I want to be able to detects incoming strings that have this sequence:

 

PUMP STARTING
PUMP DISCONNECTED
PUMP STOPPED
PUMP STARTING
PUMP RUNNING

 

my first approach was to search for one at the time and then check indexes (but that looks to me to be messy)

 

any help will be appreciated.

 

regards,

0 Kudos
Message 1 of 10
(3,141 Views)

@El_Tipo wrote:

Guys,

 

I would like to know if there is an elegant way (maybe using regular expressions) to solve this:

 

incoming string looks like this:

 

Event Log Started: 11/10/2011 11:49:28 AM
Time, System Event
11/10/2011 11:49:29 AM, FILE SAVING ENABLED
11/10/2011 11:49:33 AM, PUMP STARTING
11/10/2011 11:49:34 AM, PUMP DISCONNECTED
11/10/2011 11:49:35 AM, PUMP STOPPED
11/10/2011 11:49:36 AM, PUMP STARTING
11/10/2011 11:49:42 AM, PUMP RUNNING
11/10/2011 11:49:43 AM, STARTING CURRENT: 2.10 (A)

 

I want to be able to detects incoming strings that have this sequence:

 

PUMP STARTING
PUMP DISCONNECTED
PUMP STOPPED
PUMP STARTING
PUMP RUNNING

 

my first approach was to search for one at the time and then check indexes (but that looks to me to be messy)

 

any help will be appreciated.

 

regards,


The most elegant way to do something is the way you've figured out for yourself.  😉

 

Go ahead and try.  We promise not to laugh too hard.  (Aww, j/k - I hate RegEx, so my code would probably look worse than whatever you can show us.)  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 10
(3,133 Views)

Hi Tipo,

 

- read in your file as text string.

- use SpreadsheetStringToArray with comma as delimiter and format "%s"

- index the 2nd column and search for strings starting with "PUMP"…

 

In case you receive strings as single lines you only need to look for "PUMP"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 10
(3,130 Views)

Billko,

 

Before you were a Low-level minion I was around LV for some time.

If you are not going to add to the question anything with substance please dont waste the energy.

 

I posted the question to see if someone with more experience than me doing regex could figure out my problem quickly. 

I have never intended on the various question i have posted to get easy answers without try if first.

 

0 Kudos
Message 4 of 10
(3,127 Views)
Solution
Accepted by El_Tipo

I used a loop to generate the larger regular expression needed to find your terms:

 

Example_VI_BD.png

 

A more general regexp might be sufficient.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 5 of 10
(3,115 Views)

jcrmody,

 

right what I was lookig for thanks a bunch for your help.

 

regards,

 

0 Kudos
Message 6 of 10
(3,110 Views)

This is what I'd do...

 

help.png

0 Kudos
Message 7 of 10
(3,106 Views)

Oops!  I didn't notice you needed the exact sequense. Misread. I found myself looking at Jim's code thinking "that is way too complex".

 

My solution would still work with some adjusting, but his is better.

0 Kudos
Message 8 of 10
(3,097 Views)

the input string can have any flavor example:

 

Event Log Started: 11/11/2011 1:44:19 PM
Time, System Event
11/11/2011 1:44:19 PM, FILE SAVING ENABLED
11/11/2011 1:44:24 PM, PUMP STARTING
11/11/2011 1:44:30 PM, PUMP RUNNING
11/11/2011 1:44:31 PM, STARTING CURRENT: 1.90 (A)
11/11/2011 2:39:10 PM, PUMP DISCONNECTED
11/11/2011 2:39:11 PM, PUMP STOPPED
11/11/2011 2:39:21 PM, PUMP STARTING
11/11/2011 2:39:26 PM, PUMP RUNNING
11/11/2011 2:39:27 PM, STARTING CURRENT: 2.00 (A)

 

the string should be desregard because does not contain the exact sequence.

0 Kudos
Message 9 of 10
(3,096 Views)

@El_Tipo wrote:

Billko,

 

Before you were a Low-level minion I was around LV for some time.

If you are not going to add to the question anything with substance please dont waste the energy.

 

I posted the question to see if someone with more experience than me doing regex could figure out my problem quickly. 

I have never intended on the various question i have posted to get easy answers without try if first.

 


I know you were around for a long time.  I apologize if you didn't pick up on my humor.  Part of the humor was BECAUSE I knew you were experienced.  I was also laughing at myself because I know my attempts probably would look worse than ANYthing you could show us.

 

And I was actually contributing to the topic by trying to encourage you to post something first so we can all get a look at it and help you out.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 10
(3,081 Views)