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"