Switch Hardware and Software

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatically Importing Switch Executive virtual devices as part of a TestStand deployment installer

Hello,

 

We use TestStand with Switch Executive.  We generate an installer for our TestStand deployments and we want to automatically import our Switch Executive devices as part of the installation process.  To accomplish this, we have created a LabVIEW executable that wraps niseCfg Import.vi.  Then, we call this executable from a batch file with the appropriate command line arguments (import name and import file path).  The batch file gets executed as a custom command at the end of the TestStand deployment installer.  This works great.  I know that in the latest version of Switch Executive you can export your NISE devices in MAX configuration (.nce) files but we aren't at that version of Switch Executive yet so we can't take advantage of that feature yet.  I also looked into calling the equivalent import entry point in nise.dll directly from the batch file using run32.dll but it doesn't seem to work.  We are using TestStand 2010 SP1, LabVIEW 2011 SP1, and Switch Executive 3.5.

 

Is there a simpler way to import Switch Executive virtual devices as part of a TestStand deployment installer (rather than calling an executable from a batch file that is executed as a custom installer command)? 

 

Thanks,

Ryan Wright

0 Kudos
Message 1 of 4
(6,663 Views)

Hi Ryan,

 

If you would like to perform the same action within TestStand, you could overwrite the SequenceFileLoad engine callback in the client sequence file. The callback could first check to see if the virtual devices have been loaded, and run the executable if they had not been. This would provide the check every time the Sequence File is loaded into memory. I hope this helps!

 

Regards,

 

Jason D

Applications Engineer

National Instruments

0 Kudos
Message 2 of 4
(6,640 Views)

Ryan:

 

Here is a script that may meet your needs. Just compile it into an .exe using AutoHotKey:

 

; NI Switch Executive Virtual Device Import
; AutoHotKey Script (niseCfg_Import.ahk)
;
; Usage:
; Compile to an .exe file using AutoHotKey (http://www.autohotkey.com/), then
; niseCfg_Import.exe <VirtualDeviceName> <ImportFilePath> <OverwriteInteger>
;
; Example:
; niseCfg_Import.exe "VirtualDevice1" "C:\VirtualDevice1.xml" 0

; Store command line parameters in variables
name16 = %1%
path16 = %2%
overwrite = %3%

; Convert strings to UTF-8
StrPutVar(name16, name8, UTF-8) 
StrPutVar(path16, path8, UTF-8)

; Call nise.dll's niseCfg_Import function
result := DllCall(A_WinDir . "\system32\nise.dll\niseCfg_Import", "Str", name8, "Str", path8, "Int", overwrite)

; Return result from import as our exit code
Exit result

; String Encoding Conversion Function
; From http://l.autohotkey.net/docs/commands/StrPutGet.htm
; Usage:
; StrPutVar(inputString, outputString, encodingString)
;
; Example:
; StrPutVar(name16, name8, UTF-8) 
StrPutVar(string, ByRef var, encoding)
{
    ; Ensure capacity.
    VarSetCapacity(var, StrPut(string, encoding)
        ; StrPut returns char count, but VarSetCapacity needs bytes.
        * ((encoding="utf-16" || encoding="cp1200") ? 2 : 1) )
    ; Copy or convert the string.
    return StrPut(string, &var, encoding)
}

 

Brian

Message 3 of 4
(6,627 Views)

Thank you all very much for your recommendations.

 

0 Kudos
Message 4 of 4
(6,604 Views)