Quick Drop Enthusiasts

cancel
Showing results for 
Search instead for 
Did you mean: 

EasyConvert- QD Plugin

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

  • Byte array to string
  • String to byte array
  • Number to boolean array
  • Boolean array to number
  • Boolean to numeric
  • String to Path
  • Path to String
  • Array of Strings to Path
  • Path to Array of Strings
  • Scan String to Enum
  • Format Enum to String
  • Coerce to Enum
  • Variant to Data
  • Timestamp to Double
  • Double to Timestamp
  • Reference to More Specific
  • Reference to More Generic
  • 1D array to Element
  • 2D array to Element
  • 2D array to 1D array
  • Element to 1D array
  • 1D array to 2D array
  • Element to Cluster (selects first element it finds)
  • Cluster to Element (selects first element it finds)
  • Typecast

Example

Before.png

Then wire it up

Wire.png

Then run the plugin

After.png

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)

Josh
Software is never really finished, it's just an acceptable level of broken
Message 1 of 14
(8,519 Views)

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.

0 Kudos
Message 2 of 14
(5,627 Views)

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?

  • If the variants data types, I'm a little torn. Incredible gain in readability, but a loss in flexibility. I'll definitely look at it closely though.
  • If scripting, I'm a little lost as to which one you're referring to.
Josh
Software is never really finished, it's just an acceptable level of broken
0 Kudos
Message 3 of 14
(5,628 Views)

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.

0 Kudos
Message 4 of 14
(5,628 Views)

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"

Josh
Software is never really finished, it's just an acceptable level of broken
0 Kudos
Message 5 of 14
(5,628 Views)