LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

create a file xml as a GXML scheme is possibile?

I see the problem, and will have an answer for you shortly (about the source of the problem, and a beginning of a fix).  But this points out a Very Important Lesson to learn when developing programs in LabVIEW:

Whenever you make a Cluster in LabVIEW, always create a TypeDef for (and use) it.

Another thing to be careful about is the order of elements in a Cluster.  The order that the elements appear in a Cluster are not necessarily the order that they actually exist in the Cluster.  For example, your FuncBlock_Cluster shown on the Front Panel has three elements:  a Cluster IdFuncBlock_Cluster, an Array BaseArea_Array, and another Array LinkArea_Array.  However, their actual (and "storage") order in the Cluster is BaseArea, LinkArea, and IdFuncBlock.  [Incidentally, you probably shouldn't add _Cluster or _Array to the end of variable names unless it is really important for their function].

 

     I'll be back shortly with more information after I play around a little with your Attachment.

 

Bob Schor

 

0 Kudos
Message 11 of 15
(390 Views)

Problems/inconsistencies between GXML Data and FuncBlock_Cluster:

  • Order of first-order Elements -- Front Panel indicates order IdFuncBlock_Cluster, BaseArea_Array, and LinkArea_Array.  Actual Cluster has IdFuncBlock as the last element. -- changed so it is the first element (also consistent with Data File).
  • Confusion about contents of Cont3_Cluster and Cont4_Cluster (awful names, by the way).  Data File suggests Cont4_Cluster has 2 elements, Name and Offset, but Front Panel shows it with only Offset.  Also, Cont3_Cluster's description in the Data File shows it as having both 1 or 2 elements (depending on which Array member), but it only appears (in the Data File) to contain Cont4_Cluster.  Changed to eliminate Cont3_Cluster and make Cont4_Cluster be a Cluster of two elements, Name and Offset.

The following changes were made:

  • A TypeDef was created for IdFuncBlock_Cluster with elements in the order IdFuncBlock, CompLow, CompHi.
  • A TypeDef was created for BaseElement_Cluster having Name (string) and Offset (U16), in that order.
    • A TypeDef was created for LinkElement_Cluster having Name (string), Offset (U16), and Type (String).
  • A TypeDef was created for FuncBlock_Cluster consisting of IdFuncBlock_Cluster, an empty Array of BaseElement_Cluster, and an empty Array of LinkElement_Cluster.
  • All defaults are <Blank> or 0.

 Oops, sorry to do this, but I've got to take a brief break, will be back shortly with code that I hope will demonstrate a possible solution (or at least a start towards one).

 

Bob Schor

0 Kudos
Message 12 of 15
(384 Views)

Forgive the interruptions.  Your example was in LabVIEW 2017, which I don't have readily available.  I opened it in LabVIEW 2018, did some testing, then realized I had a problem sending you (a) a Version you could read and run, and (b) a Version that I could also test and "tweak", as needed.  So I saved it as LabVIEW 2016 (which you can open and run just fine), and am attaching it here.

 

You'll notice that I'm sending you a LabVIEW Project, wrapped up in a Project File.  It is a whole lot easier to develop LabVIEW code in a LabVIEW Project environment, not the least of which is that QuickDrop will find all of your Project elements when you type the first few letters of their name (What?  You don't know about QuickDrop?).

 

Inside the Project file, you'll find the Project (just double-click it, and it will open, giving you access to everything), the Top Level VI (which I tend to give the prefix MAIN), and a folder, Types, holding the four Cluster TypeDefs.  Here's a Snippet of the routine:

GXML Snippet.png

The code on the left builds the three elements of the Function Block Cluster.  Notice the VI Icon sitting "on top of" the Bundle-by-Name function.  When I created the TypeDef for the Cluster, I created an Icon for the TypeDef.  When you put a Cluster (constant) on the LabVIEW Block Diagram, they tend to be "big and ugly", and don't give you any information as to what they represent.  But a few Versions ago, NI added a nifty Feature (that I wish they'd extend to Arrays) that if you right-click the Cluster Constant, it changes into its Icon.  And, if you made a Pretty (and informative) Icon, you get Self-Documenting Code!

 

The bottom two For Loops generate two Array elements.  I took a "short-cut" with the first of these (sorry).  Once the three Clusters were build, I assembled them into the Function Block Cluster, generated XML from this Cluster, and wrote it to an XML file.  I then opened the File, read the XML, and Parsed it to produce the output cluster.  Once you run this yourself, you can see how the XML file differs (in structure) from yours.  Remember that I simplified the structure of BaseArea.

 

Bob Schor

0 Kudos
Message 13 of 15
(381 Views)

Thank you very much for the information and suggestion, now i try to transform it in an array of this cluster but i couldn't, may you once more help, please. Thanks in advantage Your sincerely Michele 

0 Kudos
Message 14 of 15
(373 Views)

In the attach i try to create an array of cluster and it looks like work correctly, could be correct? thanks Michele 

0 Kudos
Message 15 of 15
(366 Views)