06-24-2015 02:23 PM
What it does
Takes selected wires and inserts a conversion for that wire. To do this, you have to intentionally create a broken wire, select it, then run the plugin.
The plugin will insert the relevant function and create any necessary constants (like typecast type).
If no conversion is found, a type cast is automatically used. You can also default to typecast by holding shift while running the plugin.
What it converts
Example
Then wire it up
Then run the plugin
Version History
V 1.0- Release as document (from prototype: added conversion binary file instead of contant, fixed U8 enum conversions, error doesn't undo)
06-24-2015 03:45 PM
Couple things. When you have a wire and it returns an array of terminals, I believe index 0 is always a source and the last index is always a sink. You can use the index to get the first, and a delete from array with nothing wired to the index or length to get the last. Then you don't need your Find Wire Sink and Source VI.
As for simplifying the constant creation. You could use the private method Create Constant, on the Block Diagram. This function takes a variant data type and creates a constant at the location you specify. You can read the Data Type of the sink terminal and use that, then you just need to move it and wire it. No need for creating the constant, finding the wire, deleteing the wire, move it, then wiring it. Maybe it doesn't save much space. Also if you know your function is a Type Cast you can probably get away with using a constant for indexing the terminals to find the "type".
Have you looked at the scripting functions in the hidden gems? I think a few in there could be helpful too.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
06-24-2015 07:10 PM
Great. Thanks a lot. These will definitely simply the code. Even if the create constant doesn't save space, the current method feels Rube Goldberg to me and created odd behavior like that bumped wire seen above.
I may keep the terminal "type" search, because I'm adding "Variant to Data" insertion to this plugin and that VI happens to have the same "type" terminal.
For the hidden gems, are you talking about the Variant Data Type functions or the Scripting ones?
06-25-2015 07:07 AM
It's labeled under Hidden Gems >> VI Server and Scripting.
Looking at it I don't see all the awesome things I thought were there, but there are some good gems still. I might have been thinking of the LAVA scripting tools. But it probably isn't desirable to add additional external dependencies.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
06-25-2015 09:28 AM
List of things it can do so far (currently not uploaded)
Byte Array to String
String to Byte Array
Number to Boolean Array
Boolean Array to Number
Boolean To (0,1)
String to Path
Path to String
Array of Strings to Path
Path to Array of Strings
To Timestamp
Type Cast
I'm working on:
Variant to Data
Unsigned to Enum using the Coerce to Type
I guess this shouldn't be call "typecast". More like "Easy Convert" with the added "With great power comes great responsibility"
06-25-2015 01:15 PM
Sorry if I'm hitting this group too often.
I have a version (attached here) that is working and stable (as far as I've seen). I've also renamed it to EasyConvert.
Working conversions
Byte Array to String
String to Byte Array
Number to Boolean Array
Boolean Array to Number
Boolean To (0,1)
String to Path
Path to String
Array of Strings to Path
Path to Array of Strings
To Timestamp
To Double (from timestamp)
Type Cast
Variant to Data
Coerce to Type (number to enum)
Ideas I'm considering:
Scanning string to enum (via scan from string)- A lot of hand-placed/connected objects... not thrilled to try
More generic or More specific references- Not sure how to identify if it needs to Up/Down the hierchy (to use specific or generic)
06-29-2015 08:04 AM
New version. Fixes the following bugs
I think I'm finished for now unless anyone comes up with new ideas/bugs/feedback.
07-01-2015 08:35 AM
Ok, I wasn't finished.
New things added:
07-01-2015 10:24 AM
This is shaping up to have some pretty useful features. It might read my mind and know the conversion I want but I can always undo quickly if it doesn't work right. Haven't used it yet but enum and string, and build array is something I could see myself using.
What's your thought on clusters? If I have a cluster wired to a string indicator, would automatically inserting the unbundle and selecting the first string be useful?
And if we go from scalar to array, could we go from array to scalar, or 2D to 1D using index?
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
07-01-2015 01:07 PM
Done and done (jumped on this because that sounded really useful)
Added:
Also of note, "build array" and "Index" work for arrays of numerics, strings, enums, booleans, paths, waveforms, refnums, and variants.
Haven't done 2D->1D and 1D->2D yet.