LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview scripting of event structures

I am trying to use labview scripting to create event structures.  I have used it successfully to create and populate case structures, but event structures are proving to be somewhat of a challenge.  Examples seem to be very limited at this time (I think it's a relatively new feature to scripting w/ LV 2013).  Regardless...

 

What I want to do is create a single event structure and populate it with many cases.  The cases will be switched on value changes of front panel indicators.  Each time I run my code, I get an error about object reference is invalid.  I don't know how this can be, because it's actually creating the object and putting it inside the event structure.

 

I have 3 questions:

1. how/why is the event structure case not named (i.e why does the title bar just say Timeout instead of, Boolean: Value Change or what not)?

2. Why do I get the error about an invalid object?

3. In the end, each case will have multiple boolean objects OR-ed together, and the output of that OR will be used to drive something else.  I want all of that code inside the event structure.  But several different objects mean several different references, so which one(s) do I wire to the reference input of the cluster?

 

I have attached 2 screenshots....the first is the code I'm executing, the second is the resulting code.

 

Apologies for what I'm sure is some wrong terminology, and thanks in advance for any help.  Perhaps the best thing is if anyone has links to examples on scripting w/ event structures.

0 Kudos
Message 1 of 9
(4,743 Views)

1. Because you haven't given it a proper event yet, the default (even if you manually drop the event structure) is the timeout

2. Because you can't have a value change event for a not equal node, create a control instead, and use that as the reference

3. Not sure as I haven't played with scripting event structures yet, I'll give it a whirl and see if I can find you an answer

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
Message 2 of 9
(4,738 Views)

@Charles_CLA wrote:

1. Because you haven't given it a proper event yet, the default (even if you manually drop the event structure) is the timeout

2. Because you can't have a value change event for a not equal node, create a control instead, and use that as the reference

3. Not sure as I haven't played with scripting event structures yet, I'll give it a whirl and see if I can find you an answer


Regarding #3, the "StaticControlEvents" is an array of clusters input. For each boolean that you want to handle the value change, you build the same exact same cluster except that you replace the control refnum with the new control refnum, then build an array of all of these clusters and wire it to the input. Hope that helps.

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
Message 3 of 9
(4,730 Views)

Here's a bit of code to do what you are asking. You will probably notice that this does not remove the timeout event from the state. I'm pretty sure there is a bug here. If you call "SetHandledEvents" and wire the input "StaticAppVIEvents" to a null array, LabVIEW crashes immediately, if you wire it to an array containing one element and set that element to event of "null", it runs successfully but attempting to save or even close the new vi will cause LabVIEW to crash. If you leave it unwired, it doesn't clear the timeout event :(. I would call NI and ask them to file a CAR on this, I've sent them the crashing code from the popup that you get when you crash LabVIEW.

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
Message 4 of 9
(4,716 Views)

@Charles_CLA wrote:

Here's a bit of code to do what you are asking. You will probably notice that this does not remove the timeout event from the state. I'm pretty sure there is a bug here. If you call "SetHandledEvents" and wire the input "StaticAppVIEvents" to a null array, LabVIEW crashes immediately, if you wire it to an array containing one element and set that element to event of "null", it runs successfully but attempting to save or even close the new vi will cause LabVIEW to crash. If you leave it unwired, it doesn't clear the timeout event :(. I would call NI and ask them to file a CAR on this, I've sent them the crashing code from the popup that you get when you crash LabVIEW.


And here's the code to work around that particular bug... Basically, create a new frame and delete the old frame 0.

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
Message 5 of 9
(4,711 Views)

Thanks Charles...I was out of the office and just now was able to view your reply.  Your example looks like a great start for me...I'll work on it.  Thanks again.  Kudos to you...

0 Kudos
Message 6 of 9
(4,656 Views)

Any idea how to get a given frame of the event structure to 'own' the controls/indicators I create?  For case structures, you can use the move method to get access to the owner property, and wire the 'diagram' parameter to the owner property and then all the code you create will appear inside that specific entry in the case structure.

 

For these even structures, I tried something similar using the move method and then wiring in the diagram refnum from the Add Frame method, but I get the error about the object cannot own the specified object...

0 Kudos
Message 7 of 9
(4,641 Views)

Nevermind, the property node has the diagrams array...

0 Kudos
Message 8 of 9
(4,636 Views)

Hey there, 

 

Saw this post and thouht it would help. I am having some issues with scripting the event cases. I see in this example using the "StaticControlEvents", I can get this working just fine, but what I am trying to do is use the "DynamicEvents" to populate my event structure with the dynamic user events. 

 

I have used the code above as a base. What I have achieved so far and found. If I have an event strucute with three seperate events register Bool, num, string I can add one of these the event sructure. How ever if I try to add another I get error 1. Where am I going wrong?
Where

 

User Events.PNGEvent.PNG

 

Attached is my scripting. 

 

Any help is welcome, I am new to VI scripting so trying to learn as much as I can. Sorry to hijack this post. 

 

 

Thanks

 

 

Kev

0 Kudos
Message 9 of 9
(4,321 Views)