0

我正在尝试从 Windows 服务自动运行“Teststand”脚本。到目前为止,我已经通过从命令提示符调用以下命令来完成自动化:

C:\Program Files (x86)\National Instruments\TestStand 2013\Bin> 
SeqEdit.exe /runEntryPoint "Single Pass" "c:\Users\pathtofile\MyTests.seq" /quit

我正在使用 Python,所以我使用 subprocess 模块来实现这一点。它会自行打开、运行、保存结果并自行关闭。完美的!!!但是,因为它会启动 Teststand GUI,所以它不能在 Windows 服务中工作。我什至不需要 GUI(因为我不碰它,结果存储在一个文件夹中),但没有它我似乎无法运行 Teststand。

我已经使用 win32 搞砸了 CreateProcessAsUser(),但我似乎无法得到任何工作。任何人都可以提供使用上述命令从 Windows 服务(Windows 10)运行 Teststand 序列的 Python 解决方案吗?

4

1 回答 1

0

选项可以是使用 TestStand API 直接使用引擎运行序列。以下是NI 知识库中的示例

import win32com.client
tsEngine = win32com.client.Dispatch('TestStand.Engine.1')
print('TestStand %s.%s ready' % (tsEngine.MajorVersion, tsEngine.MinorVersion))
sequencePath = 'C:\\Users\\Desktop\\Sequence File 1.seq'
seqFile = tsEngine.GetSequenceFileEx(sequencePath)
execution = tsEngine.NewExecution(seqFile, "MainSequence", None, False, 0)
execution.WaitForEndEx(60000)
print(execution.ResultStatus)
tsEngine.ReleaseSequenceFileEx(seqFile, 0x4)

我发现使用它要干净地关闭它,我必须使用它del来清除对 UIMessages 的引用,executionseqFile处理 UIMessages 以确保在执行结束时没有未完成的。

于 2018-10-26T08:53:52.183 回答