DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Data exchange Mainscript (SCRIPT) with script block (DAC)

Is there any way to exchange data beetwen a Mainscript (SCRIPT) with user-dialoges and script block (DAC) in this way that the script in scriptblock can access to this data?

Background: I write a DAC-Application with some script-blocks for reading and writing data to/from real devices. During the development I'd like to simulate all device accesses because I don'd have the devices in my office. I write all scripts with a branch for simulation an real measurement on startup.
How can I execute a swich (simulation / mesurement) without changing all my scripts all times? Can a script read a variable anyway (Variable from Mainscript, Diadem-Uservariable or "Hilfsvariable" like L1)?  Can I fill "DeviceParam1V" with content of a variable?

I could use a input channel connected with a formula-block for it. (The formula-block can read a variable.) But this way is uncomfortable an don't work for input blocks.

Martin Bohm
bohm@a3m.com



0 Kudos
Message 1 of 3
(3,661 Views)
Because the DAC Script is executed in its own runtime environment you cannot use the DIAdem variables as in a normal VBS or a SUD.
Still, there are ways to exchange information.

First of all by an extra channel as Input (you named it)
Secondly, there are several variables you can use. Have a look at the Script DAC block. There are two fields called Parameter1 and Parameter2. And each signal you configure has a parameter of its own.

Prior to starting the scheme, you can use a script to change the value of those parameters:
Call DACObjOpen("Script-in1")
  VBSSignalParam(1) = "abc"
Call DACObjClose("Script-in1")
Is changing the parameter of the first signal that is configured.
Call DACObjOpen("Script-in1")
  VBSParameter1 = "1st device parameter"
  VBSParameter2 = "2nd device parameter"
Call DACObjClose("Script-in1")
is changing the global device parameters.

On the side of the Script DAC driver VBS you cann use the paramP funtion to access the signal parameter that corresponds to the actual channel (as referenced by ChannelnumberP)
'------------------------------------------------------------------------------
' SFD_ReadChannel
' Zweck               : Lesen eines Wertes für den Kanal "ChannelNumberP"
'------------------------------------------------------------------------------
' ChannelNumberP      | Kanalnummer aus dem Block-Dialog
' ParamP              | Vom Anwender definierte Variable aus dem Block-Dialog
' DataP               | Variable zur Rückgabe des neuen Kanalwertes. Diese
'                     | Variable sollte zumindest auf einen gültigen Wert
'                     | initialisiert werden.
' ErrorP              | Variable zur Rückgabe einer Fehlermeldung. Wird diese
'                     | Variable gesetzt, stoppt DIAdem die Messung
'------------------------------------------------------------------------------
Sub SFD_ReadChannel( ChannelNumberP, ParamP, DataP, ErrorP )
End Sub
To acces the device Parameters, use the init function:
'------------------------------------------------------------------------------
' SFD_Init
' Zweck               : Diese Prozedur wird während des Messungsstarts aufgerufen
'------------------------------------------------------------------------------
' DeviceParam1V       | Erster Parameter, der vom Anwender im DAC-Block
'                     | eingegeben werden kann
' DeviceParam2V       | Zweiter Parameter, der vom Anwender im DAC-Block
'                     | eingegeben werden kann
' ErrorP              | Variable zur Rückgabe einer Fehlermeldung. Wird diese
'                     | Variable gesetzt, stoppt DIAdem die Messung
'------------------------------------------------------------------------------
Sub SFD_Init( DeviceParam1V, DeviceParam2V, ErrorP )
End Sub
Ingo Schumacher
Systems Engineering Manager CEERNational Instruments Germany
Message 2 of 3
(3,650 Views)
Thanks for the answer!
The second way, setting VBSParameter1 , VBSParameter2  or VBSSignalParam(1)  is known for me. I've done it before. But it has a strong limitation: The Mainscript has to manipulate every script-block in every used DAC-sheme in this way.  It means, the Mainscript has to "know" wich scripts exist.  It is not posible to write a universal procedure wich swich all my scripts between real measurment and simulation.  It seams, that there is no global variable wich can be write from mainscript and read from any script-block.

Martin Bohm
bohm@a3m.com
0 Kudos
Message 3 of 3
(3,644 Views)