LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing Labview code while it is paused !!!

Is there any way to change Labview code while the code execution is paused and then again resume the new changed code execution?

 

 

 

0 Kudos
Message 1 of 9
(3,290 Views)

Hi Jain,

 

no. And yes.

 

No: you cannot change code of a running executable (as you cannot change code in Word while you don't type any new text into it…)

Yes: you can change code in plugins while those plugins aren't used. After resuming your code you reload the plugin to execute your new code…

Best regards,
GerdW


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

Hi GerdW,

 

Thanks for the reply.

 

Changing code into plugins will be a huge task and also not feasilible for my application scenerio as it will create many VIs and also the code changing event is not fixed.

 

What I think is to somehow instantiate a copy of executing code when we need to change it (i.e apply pause or any other button) which has the information like a) when pause event happened, b) values of all links and controls, c) till what point code has been executed. At this time, the previous code copy gets Aborted and allow user to change anything. While resuming, the control will goes back to previous copy with all the stored information so that it will start again from where it left.

 

Hope you understand the scenerio !!

 

Regards

Sambhav

 

0 Kudos
Message 3 of 9
(3,244 Views)

Hi Jain,

 

again: No! You CANNOT change code of a running executable! And "resuming" still means "running and waiting for user input"…

 

again: You might export code parts into plugins. When the plugin is unloaded you are able the change it, then load it again into your executable.

 

Changing code into plugins will be a huge task

Only when you don't plan for it when developing your executable!

 

not feasilible for my application scenerio as it will create many VIs

What? It's not feasable because you need to create some VIs?

Creating code in a manageable way means to create more VIs…

 

also the code changing event is not fixed

This doesn't matter for plugins…

 

Best regards,
GerdW


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

If you think about the execution of a LabVIEW routine that embodies, say, a State Machine, where you have a button that says "Do This", and another that says "Do That", and you program your routine to handle both button pushes, you can certainly "change LabVIEW code" (in the sense of changing what the LabVIEW code does) during execution, even while not paused, just by pushing a button and executing the appropriate State.

 

If you mean "Pause LabVIEW, make some changes to the Block Diagram, and resume", that is much harder, and goes against LabVIEW's basic "compiled code" structure.  What you seem to be wanting is a Matlab-like interpreter that executes "code fragments" as you develop them.  I suppose, with LabVIEW scripting, you might be able to cobble together something, but it would be a ton of work, probably unstable, and almost certainly a Waste of Time and Exercise in Frustration/Futility.

 

Why do you want to do this, anyway?  What do you need to do that you can't figure out how to do?

 

Bob Schor

0 Kudos
Message 5 of 9
(3,205 Views)

Wanting to do this is almost certainly the wrong solution to a problem for which a better solution exists.

 

If you could explain what you are trying to do - why you want to do this - then perhaps a better solution can be suggested.

 

(I think) I understand your previous reply where you basically proposed saving the state information at a point where you want to make changes, stop execution, edit, and then re-load that state after changes have been made and the program re-started. But what kind of changes are you wanting to make to the code that couldn't be handled by a bit of clever programming so you don't have to stop and start it again?

0 Kudos
Message 6 of 9
(3,189 Views)

It is possible to trick LabVIEW into allowing you to edit running code (paused code counts as running), but LabVIEW usually crashes when you do that.  Even if it doesn't crash, you will have created an unstable situtaion, and possibly corrupted your VI.

 

If you really need* to edit some code while the main VI is running, put the modules that you will be editing in dynamically loaded VIs.  Put provisions in your main VI that will allow you to control the loading/unloading of dynamic VIs.

 

*It's unlikely that you really need to do that.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 7 of 9
(3,154 Views)

@Stuart.Parkinson wrote:

Wanting to do this is almost certainly the wrong solution to a problem for which a better solution exists.


Totally agree.  This is like asking, "After I compile C code into a executable can I change it while it is running?" Of course the answer is no, but there are ways to embed code to do what you want and be flexible at run time, but that logic must be built into the software.  LabVIEW is not a scripting language, it is not interpreting what you tell it to do, it compiles it, into executable code and runs it.

0 Kudos
Message 8 of 9
(3,110 Views)

While I agree with the above posters that there is probably a better way to debug your code, I did see an interesting trick the other day. When using the JKI state machine you can save the Macros in a text file and load it any point in your program. So you could edit this text file while paused, and then reload it.

Message 9 of 9
(3,097 Views)