Jump to content

Record the commands while coding


Bo Fu

Recommended Posts

Hi all,

 

I am trying to get the history of the commands in LabVIEW for my hobby project and didn't work it out. So what I want to do is to keep a record of the functions (could be VIs, nodes, constant, control and indicators...) that I placed on the block diagram when I am doing the LabVIEW coding.

 

For example, if I do "5 + 8 = ?" function, the history it generated may be something like:

-- Placed "Add" node

-- Created Constant 1

-- Set Constant 1 to '5' (not required)

-- Created Constant 2

-- Set Constant 2 to '8' (not required)

-- Created indicator

 

Is there any way I can access to this information? I think it may have something to do with the buffer file that stores the undo/redo commands. But I don't know how I can see that information. Any thought?

 

Thank you for any input! Cheers.

 

Regards,

Bo

Link to comment

The undo buffer is exposed with some scripting methods (at least the last operation and you could build it as is changes or go through all of them and then redo), but the details it gives you are very limited (it's the same string you see in the Edit menu), probably because there's no point in trying to give details. If you delete several things together, it's easier to just say "undo delete".

 

The only other option I can think of is checking all the objects in the VI and if any of them change add something to your log and there are any number of problems with this, like:

  1. I'm not aware of any hooks for knowing about editing actions. You can use the VI Activation event to know which VI you're working on, but not anything lower. There's a Start Diagram Drag event, but I don't know what details it gives you and I don't see a corresponding drop event. Maybe an XNode could work, but I don't think they have anything which can be triggered with every change you make to their caller.
  2. Identifying the changes is difficult. You will need code to monitor every relevant property of every type of object. If a bunch of things are changed together (like if the user deletes several elements together), you need to describe that somehow.
  3. If objects are added/removed to the list, it might be difficult to realize that there's a new object in the middle and the others haven't changed.

I believe there is a way to convert diagrams to XML, which might be easier, but I don't think it's complete and I don't remember the details of where it is and whether it actually works or I'm just combining several things into a feature which doesn't actually exist.

 

Maybe there's a better way to do what you actually need. If you give more details about that people might have ideas.

  • Like 1
Link to comment

I believe there is a way to convert diagrams to XML, which might be easier, but I don't think it's complete and I don't remember the details of where it is and whether it actually works or I'm just combining several things into a feature which doesn't actually exist.

You aren't mixing features, LabVIEW can save and open in XML.  Extremely experimental.  Don't be surprised if it falls on its face with complicated VIs, mixing libraries, classes, XControls, etc.

 

https://lavag.org/topic/19173-anyone-else-interested-in-low-level-vi-editing-i-found-some-helpful-stuff/

 

Basically it shouldn't be used but is fun to look at.

  • Like 1
Link to comment

Hi Yair and hooovahh,

 

Thank you for your suggestions.

Yair, if the buffer only tells us as the edit menu, I don't think that's enough information for me. Alternatively, I would like to try the VI --> XML method and it seems more flexible for further development.

hooovahh, thanks for the link. I will have a read of that.

 

Thank both of you very much! :)

 

Cheers,

Bo

Link to comment
  • 2 months later...

Thanks to hoovahh's suggestion and I used his Low-Level VI Manipulation Hooovahh Edit.zip  in the other post. It allowed me to convert the VI to XML.

But now the tricky bit, it looks difficult for me to retrieve the names of the nodes and VIs from the XML file.

 

I don't know if there is a 'dictionary' somewhere to explain the fields in the XML file. All I need to know is which kind of subVI/node (e.g. DAQmx Timing, add, Enqueue Element) there are in the target VI and how they are connected. I tried to compare the XML files every step when I made a change in the target VI. But I failed to find the ID to stand for the type of the VI and node.

 

So is there any way to 'extract' this information from the XML file? Thanks for your help.

 

Regards,

Bo

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.