python automation_如何使用Python和.NET/C#自动化Princeton Instruments LightField

我想用Python来控制专有的光谱软件(Princeton Instruments LightField)。我有一个使用Matlab的LightField自动化示例。该示例使用.NET来使用提供的DLL来控制LightField。如何使用Python和.NET/C#自动化Princeton Instruments LightField

我用pythonnet将DLL加载到Python中,但是我没有和LightField通信。

这里是一个(非)工作示例:

import sys

sys.path.append(r"C:\Program Files\Princeton Instruments\LightField")

sys.path.append(r"C:\Program Files\Princeton Instruments\LightField\AddInViews")

import clr

clr.AddReference('PrincetonInstruments.LightFieldViewV4')

clr.AddReference('PrincetonInstruments.LightField.AutomationV4')

clr.AddReference('PrincetonInstruments.LightFieldAddInSupportServices')

import PrincetonInstruments.LightField.AddIns as AddIns

from PrincetonInstruments.LightField.Automation import Automation

instance = Automation(True,[])

这里是错误消息:

File "D:/python/test_lightfield.py", line 21, in instance = Automation(True,[])

TypeError: no constructor matches given arguments

但是,当我看着帮助(自动化)的开头:

help(Automation)

Help on class Automation in module PrincetonInstruments.LightField.Automation:

class Automation(System.Object)

| Void .ctor(Boolean, System.Collections.Generic.List`1[System.String])

|

| Method resolution order:

| Automation

| System.Object

| builtins.object

|

| Methods defined here:

|

| __call__(self, /, *args, **kwargs)

| Call self as a function.

或相关的Matlab示例文件:

out.automation = PrincetonInstruments.LightField.Automation.Automation(visible,[]);

它看起来像我用有效参数(一个布尔值和一个空字符串)实例化自动化类。 除了我的Matlab示例文件外,我没有太多文档。

我在做什么错?

编辑:这是一个类型的问题。使用.NET类型列表来代替Python列表。

from PrincetonInstruments.LightField.Automation import Automation

from System.Collections.Generic import List

from System import *

l = List[String]()

instance = Automation(True,l)

Hands-On Enterprise Automation with Python: Automate common administrative and security tasks with the most popular language Python Invent your own Python scripts to automate your infrastructure Hands-On Enterprise Automation with Python starts by covering the set up of a Python environment to perform automation tasks, as well as the modules, libraries, and tools you will be using. We’ll explore examples of network automation tasks using simple Python programs and Ansible. Next, we will walk you through automating administration tasks with Python Fabric, where you will learn to perform server configuration and administration, along with system administration tasks such as user management, database management, and process management. As you progress through this book, you’ll automate several testing services with Python scripts and perform automation tasks on virtual machines and cloud infrastructure with Python. In the concluding chapters, you will cover Python-based offensive security tools and learn how to automate your security tasks. By the end of this book, you will have mastered the skills of automating several system administration tasks with Python. What You Will Learn Understand common automation modules used in Python Develop Python scripts to manage network devices Automate common Linux administration tasks with Ansible and Fabric Managing Linux processes Administrate VMware, OpenStack, and AWS instances with Python Security automation and sharing code on GitHub
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值