08-03-2022 11:31 AM
I'm trying to automate a pretty tedious task using a combination of Python and LabVIEW. This involves two stages:
1. Renaming VI files
2. Updating their icon text
My original plan was to do stuff that's fairly verbose in LabVIEW in Python, and generate an idempotent script to do everything all at once using a LabVIEW Application. Now, I've found a pretty simple API to accomplish this programmatically, and have even put together a project demonstrating this, see here: https://github.com/ijustlovemath/fusion-support-scripts
The problem is that when I compile this to an EXE and run it from the CLI, as I originally intended to accomplish this project, it tells me the Icon API is not available from RTE.
Is there another way to accomplish this, aside from doing all the annoying bits (regex, dictionaries etc) purely in LabVIEW, or building a bespoke TCP server?
Solved! Go to Solution.
08-03-2022 02:33 PM
Hello, fellow Math-lover.
I'm intrigued by your use of the term "idempotent" -- I'm guessing it has a non-math meaning that I'm missing.
I've not had particular difficulty getting LabVIEW to help me process a set of files (VIs or otherwise) for "house-keeping duties" (such as re-naming, sizing, setting properties, determining "Tree depth"). But what do you mean by "updating their icon text"?
I thought I'd browse your API, but, alas, I "just don't git it" (that's supposed to be a pun). Are you trying to use LabVIEW Scripting to make systematic changes to the VIs, say, in a LabVIEW Project? I (and maybe others on this Forum) would be interested in learning more ...
Bob Schor
08-03-2022 03:12 PM
I assume the you mean that the result of run once is equal to the result of run N times. ( unlike pressing Ctrl +U)
The Icon API rides on top of various Scripting methods to grab references to the various Icon Layers. Scripting methods are currently unsupported by the LabVIEW RuntimeEngine. You will need to publish a development Tool that can be applied (since you git, look for "Nattify" as an example of how such a development tool could work.) I think it nattify bit ly dot git but a quick search of Darren's Nuggets will show a link.
08-03-2022 04:00 PM
Bob,
You can download a ZIP file with all the necessary code by clicking the green "Code" drop-down, then selecting "Download as Zip".
A little elaboration on the why:
I have multiple VIs that are versioned, in a very specific order. The order is very important, and so theyre named according to their place in line, and their version. These VIs also include their version and priority in their icon, so that any usage in code is completely unambiguous.
You can picture it as a simple VI where the first line of the icon text is the priority, eg "27", and the next line is the version, eg "22-08-03". It's a little more human friendly than that in practice.
When creating a new version of the package, all VIs must have their filenames and icon versions updated. Sometimes you need to insert a new VI, which bumps the priority of all subsequent VIs in the order, which is a total pain in the rear to handle manually.
Things are done this way, and not in some cleaner way, because we're dealing with a large legacy system that would be expensive to reimplement in a different way.
----
To your other questions:
Idempotency is the property that running a tool multiple times has the same effect as running it once. This is typically handy to have when your tool has destructive side effects, so you only have to deal with the first issues and not subsequent ones.
That's good to know about the scripting API. That must be why it's as sluggish as it is! Alas, it's the only one I've found that I could make heads or tails of to complete the task at hand.
08-03-2022 04:40 PM
this sounds very strange to me. It appears you are trying to implement some type of versioning system for the code using file names and icons. You already have git in place so why not just use that for version control? I understand you are working with a large legacy code base but your proposal sounds very convoluted and complex. Even with a poorly designed code base there has to be a netter way to manage things. What is the exact problem you are trying to solve?
08-03-2022 04:47 PM
The versions must be maintained for compliance and auditing purposes. By having the exact version in the filename and in the icon it's clear at a glance if the implementation matches the spec. It's about making things easier for the developer to reason about, without having lots of case structures etc.
Also, while we do have git, we need to maintain the separate copies because the VI file format makes it difficult to compare versions without having the files on hand; the diff tools don't really cut it when you're using separate branches.
08-03-2022 05:36 PM - edited 08-03-2022 05:38 PM
@ijustlovemath wrote:
The versions must be maintained for compliance and auditing purposes. By having the exact version in the filename and in the icon it's clear at a glance if the implementation matches the spec. It's about making things easier for the developer to reason about, without having lots of case structures etc.
Also, while we do have git, we need to maintain the separate copies because the VI file format makes it difficult to compare versions without having the files on hand; the diff tools don't really cut it when you're using separate branches.
It's not super-clear to me what you are trying to do, but it seems to be something to do with matching code to requirement paragraph, or something similar? Could you use bookmarks? By formatting your free labels in a specific way, it appears in your bookmark manager. Double-clicking on the bookmark brings you right to the label that contains it. Making the title of the bookmark the requirement paragraph, you can easily see exactly where the coverage is/are. (You can use the same title in different bookmarks, so if you use the same title, they get grouped together. Very useful if you have several subVIs covering one requirement.)
And (off topic) bookmarks are useful for leaving notes about "unfinished business". Double click on the bookmark and you can get right back to where you need to be.
08-03-2022 05:42 PM
To change the process now would upset years of precedent and a bunch of other existing processes. We're migrating away from LabVIEW entirely in the long term, but to keep up with how things are done, all I need to do is change icon text programmatically. That's it.
In the time since posting I've developed something which will help me do this and not upset existing processes, so I'll consider this closed for now.