DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Assign channels to Calculation Set via dialog

Hello guys,

 

currently working on a dialog, which allows the user the selection of the data channels or values as input for calculation. The calculation itself should run via CalcSet, means the formula is not in the dialog script included, but loaded, and the inputs must be assigned depending on the user-inputs.

For values it seems to work, but the assignment of the data channels to the calc. input is a problem.

Here is the part of the corresponding code:

Spoiler
Call Dialog.RefreshAll
If Data.Root.ActiveChannelGroup.Channels.Exists("Func_result") Then Data.Root.ActiveChannelGroup.Channels.Remove("Func_result")

Call Calculationset.Load(MyFolders(0) & "2021-06-02 DAKAR test funcs.tca")
set formula = CalculationSet.CalculationGroups("DAKAR Funktionen").Calculations("Funktion #9")
' Diff. pressure
If CB1.Value = TRUE Then ' a channel as input selected
input(1) = Box1_CmB.Value
' Call msgbox("DP = " & input(1))
call formula.Inputs.Add("DP", eAdaptorTypeChannel)
formula.Inputs("DP").ReferenceType = eReferenceTypeChannel
formula.Inputs("DP").Reference.Channel = input(1) ' dp as Channel
ElseIf CB1.Value = FALSE Then
input(1) = VAL(Box1_EB.Text)
call formula.Inputs.Add("DP", eAdaptorTypeValue)
formula.Inputs("DP").Reference.ValueExpression = input(1) ' dp as value
End If

The purpose if the CheckBox is to identify the input: channel or value.

And depending on it, either the ComboBox or EditBox is used.

Any ideas what is missing here?

Or other proposals how to fix it?

 

Complete SUD and the TCA are attached in the ZIP file.

Working on DIadem 2015.

0 Kudos
Message 1 of 8
(2,219 Views)

So the same script was successfully working on DIAdem 2015 and not working on your current version of DIAdem?

What version are you using now?

0 Kudos
Message 2 of 8
(1,974 Views)

No, this code was never successfully working 🙂

We use Diadem 2015, since we need the compatibility to the 32bit - DLLs, and did get it in this version only.

 

The problem is to assign the data channel (available in Navigator) to the calculation input.

E.g. to use for example the channel [1]/[CP01] as input "pressure" in loaded calculation set.

 

For values it works; for example I can use the value of 10.05 MPa as "pressure" for the same calculation.

But for data channels it strikes...

0 Kudos
Message 3 of 8
(1,966 Views)

Hi Dia,

 

I started up the DIAdem 2015 (64bit) I have on my laptop and opened your SUDialog and Calculation Set.  I then carved out the code from the SUDialog that creates the formula input references and put them in a new standalone VBScript.  I made some minor tweaks in the VBScript (added ".Name" in line 19), and it runs fine with the standard DIAdem data set.  Please put this attached "Test TCA.VBS.txt" file in the same folder with your "2021-06-02 DAKAR test funcs.tca" file, then change the file extension back to just *.VBS, then run the script in DIAdem.  Does it work for you?

 

I am surprised that you are dynamically creating the formula inputs.  Most people define the inputs as part of the formula definition-- that way you can test the formula interactively.  If you need to then switch the inputs to point to different channels on the fly, you can just tweak the one ".Reference.Channel" property, instead of having to first create the input fresh each time: 

 

formula.Inputs("DP").Reference.Channel = input(1).Name ' dp als Kanal

 

Was there an important reason for not defining the inputs once in the *.tca file?

 

Brad Turpin

Principal Technical Support Engineer

NI

0 Kudos
Message 4 of 8
(1,897 Views)

Hello Brad!

Nice to get a feedback, it's quite a long time ago... The issue was "forgotten", but not solved yet.

Therefore I need to check first, what was missing, and how your proposal solves it.

 

But for the background I can answer.

In our data acquisition system we also calculate some values. These calculations get the inputs via LV to the DLL, where all functions are completely included.

The objective is to get all these functions in DIADEM, so that the calculated results can be changed after the test, and the formulas are exactly the same as in DLL.

 

Up to now I didn't find a way to access this DLL from DIADEM; thus I need to find another possibility.

So I decided just to write the code for the functions directly.

This would work for all funcs, as soon as it works fine for single one. The basic construct is almost the same.

 

The inputs might be different: data channel or value, channels would have different names, but the formula is the same. That's why I cannot fix the reference to a pre-defined channel or value.

Finally, the user should not change anything in the code, just select the needed inputs.

 

Hope this helps to understand the idea behind.

I will try it out and reply again.

 

Greetings,

Dia

0 Kudos
Message 5 of 8
(1,886 Views)

Hi Dia,

 

OK, that's an intriguing scenario.  I hear you saying that sometimes the "lambda" input will be a channel, while other times the "lambda" input will be a constant value, which is why you need to assign those inputs dynamically.  Happily, the formula itself never changes, so that part is simple.

 

There are a couple of ways to connect with an external DLL from DIAdem.  If you can wrap the DLL as a COM object, then you can call it directly from a DIAdem VBScript by first instantiating an object variable to that COM object using CreateObject().  It sounds like you're comfortable with LabVIEW, so you might prefer to use the LVRuntime object in a DIAdem VBScript to programmatically invoke and run an external VI and afterwards read off its indicator values.  Finally, it is possible to wrap an external DLL as a "GPI-DLL", such that you can call it directly from a DIAdem VBScript.  This last option is not for the faint of heart, but it does deliver excellent integration.

 

Brad Turpin

Principal Technical Support Engineer

NI

0 Kudos
Message 6 of 8
(1,878 Views)

Hi Brad.

 

Yes, in fact the "lambda" (coefficient of thermal expansion) is not constant even for one material, and sometimes it'S required to consider its change with the temperature. Therefore I need achannel for this 😉

 

What you write about DLLs... Single words look familiar, but the context is completely new for me.

Even with LabView, I use the running system, but - you know, never touch it.

With GPI I tried to find any solutions, but still without any results.

 

At least here I have all the code behind this DLL (C++/C#).

My last test in this regard was to call the DLL via external VI (2 way as you describe); it failed 'cause I couldn't get LV and Diadem installed on the same computer...

 

Is it possible to talk about this job as a kind of service request?

 

0 Kudos
Message 7 of 8
(1,866 Views)

Hi Dia,

 

Sure, you can contact NI and start a service request.  I'm not certain what requirements there are for the various contact mechanisms, but if you have an SSP account current with NI, then both phone and email options should be open to you.

 

I do believe DIAdem can only call LabVIEW code with the LabVIEW Runtime installed on the same computer, but it doesn't have to be the full LabVIEW installation on the same computer.  The DIAdem bitness (always 64bit for modern DIAdem) and the LabVIEW Runtime Engine bitness have to match for this to work.

 

Brad Turpin

Principal Technical Support Engineer

NI

0 Kudos
Message 8 of 8
(1,855 Views)