LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically get the name of the event structure which has just run

Does anyone know of a way of getting the name/other relevant details of the event structure which has just run in the location in the  screenshot below.

Worle_0-1717065144659.png

The use case is to pass it to an error handler so the error log can contain the name of the event structure which generated the error to aid with debugging.

 

I suspect the only way of doing this is to put a string constant in each event structure, but I am hoping there is a way without such a high risk of developer error.

 

Any ideas?

 

0 Kudos
Message 1 of 8
(677 Views)

What are the "relevant details" do you think of ?

 

Perhaps the first approach to achieve what you want could be :

PinguX_0-1717065843863.png

 

Then, it all depends on whether the "relevant details" are generic enough to cover all events that may occur, or not.

0 Kudos
Message 2 of 8
(670 Views)

Hi Worle,

 


@Worle wrote:

Any ideas?


You could use the VI name instead of the event structure label (or whatever).

How many event structures do you use per VI?

Best regards,
GerdW


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

Both valid points, I have considered your point PinguX, it is just code which has to be put in every structure. Definitely doable, I was just hoping to find a neater solution

 

I already include the call chain in the error log GerdW. I tend to feel a need for doing this on configuration UI's which are manipulating classes. To maintain locality of behaviour I tend to put all my manipulation into event structures, but sometimes it can be a little challenging working out exactly what event structure caused the error.

0 Kudos
Message 4 of 8
(651 Views)

@Worle wrote:

I suspect the only way of doing this is to put a string constant in each event structure, but I am hoping there is a way without such a high risk of developer error.


It would be sufficient to have one string constant before the event structure wired across via linked tunnels. (... and I don't understand the term "high risk" here. risk of making mistakes? If a developer cannot handle string constants everything else is even more dangerous! )

 

An event structure typically does not generate errors, it is the code inside one of the event cases. So, more interesting would probably be which event case of given event structure contains the code that generated the error. If your code has sufficient error handing, it should be trivial t find it.

 

Generally, a program should have very few event structures, so if you have them scattered over all parts of the diagram, maybe even hidden inside structures, something else is probably wrong. Can you explain your architecture in a bit more detail? How many event structures? How many event cases? etc.

0 Kudos
Message 5 of 8
(587 Views)

If you don't mind the hazards of XNodes, just drop this one inside and event case; its output will be the name of the case.

Warning, there's at least one bug in there somewhere.  Try this:

  1. New blank VI
  2. Put a case structure on the BD.  Leave it as the timeout event.  Don't wire anything to the timeout terminal.
  3. Drop "Event Case Name.xnode" onto the BD.
  4. Run the VI.  LabVIEW crashes.
Message 6 of 8
(567 Views)

Yeah definitely some bugs. I was left in a state of broken, but running a few times. Still I love the concept. I think you should add the Copy method and have it regenerate code on that.  I did a CTRL Click and Drag making a new copy but the string constant in the generated code was still the previous value.

0 Kudos
Message 7 of 8
(557 Views)

@Hooovahh wrote:

Yeah definitely some bugs. I was left in a state of broken, but running a few times. Still I love the concept. I think you should add the Copy method and have it regenerate code on that.  I did a CTRL Click and Drag making a new copy but the string constant in the generated code was still the previous value.


I fixed the copy bug.  But I have no idea what causes the crashes.

Do you think I need to put calls to "Setup Linker Ref.vi" in more ability VIs?

0 Kudos
Message 8 of 8
(516 Views)