Jump to content

Event structure


atk_nut

Recommended Posts

How do you set the "events handled by this case" in scritping?

Anyone?

4608[/snapback]

I'm afraid you don't. And thinking about it I can see why. How do you suppose should you define the different possible events you could set? Of course you could do it with strings but that is very error prone and hard to implement in the scripting engine too, as it would need to implement a state dependant (depending on the actual VI the names of the controls will change) parser and then some more. It is likely that there will be something of some sort in a futuure version but at the moment it would seem you can't do that.

Rolf Kalbermatter

Link to comment
  • 1 year later...

I don't know if there would necessarily have to be a way.

Remember that scripting is not released, so that if something would be too much of a bother, LV R&D would probably postpone it until it was more relevant.

The event structure is tricky, because different sources for events have different types of events (e.g. VI vs. control) and so you can't use a simple enum to select your event. It's quite possible that NI did not find the case for scripting event structures strong enough to do something about it until now. I know I certainly can understand how people would want more manual control of how their event structures behave.

Link to comment

<cite>QUOTE(yen @ Apr 8 2007, 11:31 PM) <a href='index.php?act=findpost&pid=27768'></a></cite>

I don't know if there would necessarily have to be a way.

That's a really good point yen - it's certainly possible that a method does exist, but it's just not exposed to us right now. That said, I still think that it's there somewhere, jbut finding it is unintuative (is that a word?) yen's right about the complexity of the event structure: think about an event - you define the control (application, VI...) and the event type that fires it, you can have multiple UI events fire one code event, there's dynamic dispatching, user events, and more!

As an aside: I'd like to see a list of tags - are there a lot of them? What do they do? What are their prototypes? So many questions...

Link to comment
No worries Ami - as I said, there has to be a way to do it, it's just not obvious to us... Good luck!

No, there doesn't have to be a way to do it. Well, not directly.

If you want to script an event structure, I recommend creating a VI that has the event on it that you want and then using scripting to copy/paste that event structure into the VI that you're scripting. A lot of scripting can be done by creating a set of template VIs to use as either starting points or partial pieces that you'll copy into your final creation. Doing that is frequently faster than scripting each individual element. For example, if you're scritping a dialog, I wouldn't start from a blank VI and try to script it up from nothing. Start with the dialog template (See File>>New... for the design pattern templates that ship with LV... the dialog template is in among them) and then add to it.

This doesn't solve all the use cases that you might have, but clever use of templates, copy/paste and replace can get you a long way.

As an aside: I'd like to see a list of tags - are there a lot of them? What do they do? What are their prototypes? So many questions...

I assume you're referring to the "tags" that can be placed onto a VI that save with the VI using the magic scripting functions.

You'll never see such a list because there is no list of tags that can be put on a VI. A developer comes up with a name that he/she hopes doesn't collide with the name invented by any other programmer. There's no central registry, listing or whatever. Honestly, I've never really worried about it. It isn't like error codes where people like to use ranges and we want to avoid stepping on each other. There's a central registry for error codes (though prior to LV6.1 there wasn't, which is why the GPIB codes stack on top of LV codes for a small range, for example). But not for tags. Given the range of values for strings, if you pick something unique enough it is highly unlikely that anyone will accidentally stomp on it. Of course, the other reason for wanting such a list would be to know the complete range of functionality that has been hidden in the tags. But if we did that, where would we hide the easter eggs? So no list.

Link to comment

QUOTE(Ami @ Apr 7 2007, 05:23 PM)

Hi Crelf.

Here is the code.

Before you run the "Scripting Tool" VI, please browse for the path of the VI you wish to control (The VI is provided - "Controlled VI").

Thanks,

Ami

I only have LabVIEW 8.0 in front of me right now, but I found out that casting the Event Structure refnum to a Case Structure refnum and then writing to or reading from the "Frame Names" item crashes LabVIEW (now it's getting fun!).

However, writing an array that differs in size with the existing number of Events causes an error 1302: "The size of the array passed in does not match the expected size of the array for the operation."

Perhaps this works as of 8.2, 8.2.1, or future versions, but not in LabVIEW 8.0 at least. I'm guessing that "Frame Names" would be the desired property here.

Link to comment

QUOTE(crelf @ Apr 8 2007, 04:29 PM)

An excellent suggestion :thumbup:

Gotcha - I figured it was something like that.

PS: Scripting? Never heard of it. post-949-1173462407.gif

I'm able to copy/paste with no problems, although the current version of the PMS Assistant that I'm using doesn't have those properties in the VI methods (But I was able to use the "Try this string for a name!" feature to add them to my code).

I need someone to please explain (Or attach some code) on how to use the replace method. I'm only able to replace something with a whole VI (and I then Inline it to show it's code on the diagram). This is due to the fact that the replace method has a path input. The problem is that I want to replace a frame in an Event Structure or even replace some code in a diagram and I can't find a way to do that (Without using the copy/paste).

QUOTE

I only have LabVIEW 8.0 in front of me right now, but I found out that casting the Event Structure refnum to a Case Structure refnum and then writing to or reading from the "Frame Names" item crashes LabVIEW (now it's getting fun!).

However, writing an array that differs in size with the existing number of Events causes an error 1302: "The size of the array passed in does not match the expected size of the array for the operation."

Perhaps this works as of 8.2, 8.2.1, or future versions, but not in LabVIEW 8.0 at least. I'm guessing that "Frame Names" would be the desired property here.

I'll try this in LV 8.2 and see what happens.

Thanks!

Ami

Link to comment

QUOTE(Ami @ Apr 9 2007, 01:46 PM)

I'll try this in LV 8.2 and see what happens.

I gave it a shot and the same crash occurred. It's not like it was intended, but it seems that this functionality isn't available yet. The Add Event Method also doesn't seem to let you specify anything valuable. It seems the EventStructure has the exact same items as a MultiFrameStructure, so there's no special functions exposed with the type.

Awesome.

Link to comment
  • 11 months later...

I have several boolean buttons configured as "Switch when pressed". The integer value is calculated based on state of these buttons. Also I have Event structure which should run on changing of any button state. Event structure uses calculated value inside.

I add "Value change" of whole buttons to handled events. Event succesfully runs on any buttons but value of integer inside Event structure is old. In other words, the value inside Event structure updated 1 event later than actual value outside one (like D-trigger). I suppose the reason of this behaviour that Event runs momentary after pressing button and data from button cannot propagate to Event structure's data input.

What can I do to get actual value when event runs? Is it possible to run event after all data propageted throw math blocks to data input of Event structure?

PS Sorry for strange questions. I work with LabView 3rd day only ;)

Link to comment

QUOTE (alexadmin @ Mar 18 2008, 11:53 AM)

I have several boolean buttons configured as "Switch when pressed". The integer value is calculated based on state of these buttons. Also I have Event structure which should run on changing of any button state. Event structure uses calculated value inside.

I add "Value change" of whole buttons to handled events. Event succesfully runs on any buttons but value of integer inside Event structure is old. In other words, the value inside Event structure updated 1 event later than actual value outside one (like D-trigger). I suppose the reason of this behaviour that Event runs momentary after pressing button and data from button cannot propagate to Event structure's data input.

What can I do to get actual value when event runs? Is it possible to run event after all data propageted throw math blocks to data input of Event structure?

PS Sorry for strange questions. I work with LabView 3rd day only ;)

Seems like your code is reading the integer value and then waits for the event to fire. You can solve this by reading the integer value inside the event structure using a control reference (or local variable).

You also say that you calculate the integer value based on the states of the boolean controls, and then why don't you keep the integer value in a shift-register passed in/out of each event case, this would also solve the synchronization issue that you are experiencing.

Please show some code to get more help.

/J

Link to comment

QUOTE (JFM @ Mar 18 2008, 02:17 PM)

Seems like your code is reading the integer value and then waits for the event to fire. You can solve this by reading the integer value inside the event structure using a control reference (or local variable).

You also say that you calculate the integer value based on the states of the boolean controls, and then why don't you keep the integer value in a shift-register passed in/out of each event case, this would also solve the synchronization issue that you are experiencing.

Please show some code to get more help.

/J

Ohh... There are a lot of new words about LabView for me ;-) I try to analyze them and read respective help. Also I have attached my example model. The buttons I said is LED1..LED8; String3 and String4 are calculated value outside and inside of Event structure.

Thank you.

Link to comment

QUOTE (alexadmin @ Mar 18 2008, 07:52 AM)

Ohh... There are a lot of new words about LabView for me ;-) I try to analyze them and read respective help. Also I have attached my example model. The buttons I said is LED1..LED8; String3 and String4 are calculated value outside and inside of Event structure.

Thank you.

JFM is right - your problem is that you are reading the value of your boolean terminals outside the event structure. As a result, the computation occurs in parallel with your event structure; it doesn't wait for an event to fire. If you turn on "execution highlighting" (the lightbulb icon) and run your VI, you'll see what is happening more clearly. To fix this, put all the computation inside the event structure.

Link to comment

QUOTE (ned @ Mar 18 2008, 03:11 PM)

JFM is right - your problem is that you are reading the value of your boolean terminals outside the event structure. As a result, the computation occurs in parallel with your event structure; it doesn't wait for an event to fire. If you turn on "execution highlighting" (the lightbulb icon) and run your VI, you'll see what is happening more clearly. To fix this, put all the computation inside the event structure.

Yes, exactly. I put all elements including buttons inside Event structure and it began to work correctly. Thank you very much.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.