DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing commands to get specific data channels in the output report via script or automated script generation..

Solved!
Go to solution
In my project I have to make certain calculation and then get the data plotted in the given report template. I am using automated script for this. My script is doing all the calculations and then it not selecting and drag-dropping the selected channels on the report template. Its saving the blank report template. I am struggling to get the data for specific channels plotted by using the script. I need the selected channels to be plotted on this report template and then get it saved. Any help will be deeply appreciated. Thanks
0 Kudos
Message 1 of 6
(5,797 Views)
Solution
Accepted by topic author LaxG

Hi LaxG,

 

If your script is creating the calculated channels, then you know what you're naming them-- why couldn't your REPORT layout contain references to those channel names already?  Is it a dynamic number of curves conditional to the results of the analysis, or perhaps a dynamic number of REPORT sheets?

 

You can programmatically change the channel reference of existing curves or table columns with a DIAdem VBScript.  You can also add a curve or table column with a DIAdem VBScript.  But the more you can save in the TDR file, the less work you'll have programming, so that's the best place to start.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 6
(5,781 Views)
Solution
Accepted by topic author LaxG

Hi LaxG,

 

Brad is absolute right. It is possible to create your whole layout via script.

 

If you have loaded  the example report layout you can copy these lines to create a new line in your plot. This is the recommended object oriented way.

 

call Report.Sheets("Blatt 1").Objects("2D-Axis1").Curves2D.Add(e2DShapeLine, "anyName")

Report.Sheets("Blatt 1").Objects("2D-Axis1").Curves2D.Item("anyName").Shape.XChannel.Reference               = "[1]/Zeit"
Report.Sheets("Blatt 1").Objects("2D-Axis1").Curves2D.Item("anyName").Shape.YChannel.Reference               = "[1]/Geschwindigkeit"

 

For performance reasons it's recommended to use the it like this.

dim oLine
set oLine = Report.Sheets("Blatt 1").Objects("2D-Axis1").Curves2D.Item("anyName").Shape

oLine.XChannel.Reference               = "[1]/Zeit"
oLine.YChannel.Reference               = "[1]/Geschwindigkeit"

 

 

Like Brad mentioned it is much easier, that you have a stored template of your report with all setings and customisations already done.

You open this layout file and have stored the names of your calculated channels. When you are doing this with a script they always have the same name and belong to the same group.

Now you can customize the references of the line items.

 

Kind Regards,

 

Philipp K.

AE | NI Germany

0 Kudos
Message 3 of 6
(5,754 Views)

Dear Brad_turpin and Wendler,

 

Thanks for the useful comments. Its really helpful and works fine.

 

Best regards,

LaxG

0 Kudos
Message 4 of 6
(5,720 Views)

Hello Phil & Brad

Why do we need to use strings as Reference to XChannel in report objects? Wouldn't it be nice to use the data.channelgroups.channel-object and assign this object to be the XChannel object directly?

 

Currently my work-around is 

 

strXName = "Time"
strYName = "anyYChannel"
strArea = "2D-Axis1"

call Report.ActiveSheet.Objects(strArea).Curves2D.RemoveAll

Set oGrpList = data.GetChannelGroups("*16*")
for each oMyChnGrp in oGrpList 

Set oMyDisplayObj = Report.ActiveSheet.Objects(strArea).Curves2D.Add(e2DShapeLine,"")
Set o2DCurve = Report.ActiveSheet.Objects(strArea).Curves2D.Item(Report.ActiveSheet.Objects(strArea).Curves2D.Count)
o2DCurve.Shape.XChannel.Reference = oMyChnGrp.Channels(strXName).GetReference(eRefTypeNameName)
o2DCurve.Shape.YChannel.Reference = oMyChnGrp.Channels(strYName).GetReference(eRefTypeNameName) 

next

 

As you can see, "Reference" and "GetReference" are used to transfer the information from one object (datsa channel) to the other (graph curve).

But it could be 

set o2DCurve.Shape.XChannel = oMyChnGrp.Channels(strXName)

instead.

KR

MiC

0 Kudos
Message 5 of 6
(2,394 Views)

Hi MiC,

 

I agree that it would be nice to have a property or method with which one could just pass the object variable directly, rather than deriving a string representation of it to assign.  The reason the current approach was implemented first is that it lines up with the use of the *.TDR file.  Most customers save what they see in the REPORT panel to a *.TDR file and then load that *.TDR file back in at a later time.  The *.TDR file is saved internally as an XML file, so any channel references will HAVE to be a string when saved to disk in XML.  By forcing the programmer to choose HOW that string is formatted at the point that it's assigned to the REPORT object property, it guarantees that the programmer CHOSE the string format that eventually gets written to the XML inside the *.TDR file that is saved.

 

Admittedly, this is not a perfect rationale.  There is a default string syntax that is used when dragging and dropping channels interactively in DIAdem, which the programmer could set at any time, and this could be used automatically when assigning a channel object to a REPORT object property.  Personally, I'd love to see a GetReference() method be added (with no parameters beyond the object variable) at every location where you currently have the Reference property.  But I think you can imagine that this is lower priority than other items, given that there is a reasonable, if inelegant workaround.

 

The bottom line is that the REPORT object needs to be ready to convert any channel references to string representation at the drop of a hat.  The current implementation forces the programmer to choose that representation with the extra effort of calling the Channel.GetReference() method.  Ugly, but transparent and predictable.

 

Feel free to add a request to the DIAdem Idea Exchange (ni.com/diademideas),

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 6 of 6
(2,383 Views)