通用扫描接口:用于科学实验自动化的python包
usit的Python项目详细描述
usit:通用扫描界面
用于科学实验自动化的python包
此软件包的目的是提供简单有效的工具来处理您的科学仪器,并使用它们运行自动化实验。 由Quentin Chateiller创建,C2N-CNRS(法国帕莱索纳米科学与技术中心) 软件包开发正在进行中,一些功能尚未出现。 安装此包后,将其导入到python控制台中。要正常工作,我们需要在您的计算机中存储配置文件。第一次导入usit(或删除它)时,将在主目录中创建本地文件夹usit 第一次,您可能还收到一条附加消息,指出您的config.ini文件配置不好。实际上,为了使用usit访问您的设备,您需要向软件包指示有关驱动程序位置和本地设备配置的一些信息。为此,需要更新在主目录中创建的config.ini(请参阅下面的说明)。完成后,您可以继续。 要查看可用的设备,只需访问 此列表对应于在设备索引配置文件中配置的设备列表(请参见下文)。要访问一个特定的设备,只需从 现在您第一次访问设备时,当您执行命令usit.devices时,会在其名称旁边附加一个 最后,您可以通过以下方式访问变量、操作、子模块: 要正确关闭到特定设备的连接,只需执行其 要关闭所有连接(加载)的设备,请使用 要恢复连接,请像以前一样从 请注意,如果以前存储了设备的变量、操作或子模块usit.devices.tunics1,则如果关闭或重新加载设备,此对象将不再可用。在这种情况下,总是直接从usit.devices.tunics1对象获取新的子对象。 在usit中,有三个对象用于对设备进行完全建模:变量、操作和模块。 模块体系结构示例: 在驱动程序的实例化过程中,usit中创建了一个空的module对象,并首先表示通用设备。然后使用python脚本usit_config.py执行上述建模,如下所述。 要正常工作,您需要设置以下几项: drivers文件夹是包含usit将使用的所有驱动程序的文件夹。它有一个最低要求的结构。在这个主文件夹中,每个不同的驱动程序都需要自己的子文件夹。理想情况下,子文件夹的名称应采用<;manufacturer>;\ult;model>;格式。然后,在这个驱动程序子文件夹中,usit至少需要两个python脚本: 驱动程序文件夹架构示例: 请注意,我们的团队在github存储库中提供了许多遵循此结构的不同驱动程序:https://github.com/bgarbin/toniq" rel="nofollow">https://github.com/bgarbin/toniq usit需要一个最小的驱动程序结构。类 驱动程序脚本示例: 在这个文件中,用户必须编写一个 使用配置py的示例: 设备索引配置文件包含连接到计算机的设备的表示形式。它包含他们的名字,他们需要的驱动程序,他们的本地连接信息(地址,端口,…)。该文件需要一个.ini扩展名(例如devices_index.ini),可以位于计算机中的任何位置(例如,靠近驱动程序文件夹)。这个文件由几个部分构成,每个部分代表一个物理设备。每个部分的名称对应于usit中用来与设备通信的名称,因此它必须是唯一的。在每个部分中,需要关键字 请注意,您可以使用同一驱动程序配置多个设备(以防多个相同的设备连接到您的计算机)。 设备索引示例
如自述文件的快速入门部分所述,USIT需要了解您的设备和驱动程序。在python控制台中第一次导入usit时,会在主目录中生成一个config.ini文件,但其中包含的默认值可能不适合您。然后您必须更新这个config.ini文件。 在此配置文件中,必须提供两条路径: 配置ini示例: 备注:快速启动
importusit# It will output the fist time:# WARNING: USIT local folder created : <your_user_path># WARNING: Local config.ini file not found, duplicated from package in the local folder.
usit的
设备
属性:
usit.devices# orprint(usit.devices.get_available_devices())
设备
访问相应的属性。然后在第一次从usit.devices
调用设备时建立与设备的连接。对它的进一步调用将使用第一次调用时创建的设备实例。usit.devices.tunics1
[loaded]
标志,这意味着设备已连接。usit.devices.tunics1.wavelength(1550) # Setting the wavelength at 1550 nm
wl = usit.devices.tunics1.wavelength() # Asking the current wavelength
wl = usit.devices.ltb1.power() # Asking the current power
usit.devices.stage.goHome() # Make a stage going home
close
功能:usit.devices.tunics1.close()
usit.devices
对象的函数close\u all
usit.devices.close_all()
usit.devices
获取设备的相应属性。
要重置与特定设备的连接(关闭并重新加载),请使用设备的重新加载
功能:
usit.devices.tunics1.reload()
设备模型化
Module "yenista_tunics"
|-- Variable "wavelength" (get and set functions)
|-- Variable "power" (get and set functions)
|-- Action "turn_off" (do function)
Module "yenista_osics"
|-- Module "sld"
|-- Variable "power" (get and set functions)
|-- Variable "output" (get and set functions)
|-- Module "t100"
|-- Variable "power" (get and set functions)
|-- Variable "output" (get and set functions)
Module "signalrecovery_lockin"
|-- Variable "time_constant" (get and set functions)
|-- Variable "amplitude" (only get function)
USIT配置
1)驱动程序文件夹
-- drivers
|-- yenista_tunics
|-- yenista_tunics.py
|-- usit.config.py
|-- exfo_ltb1
|-- exfo_ltb1.py
|-- usit.config.py
"driver.py"脚本
设备
必须存在于每个python驱动程序脚本中,该脚本具有一个仅带可选参数(地址、端口,…)的\uu init\uuu
函数。这些关键字参数(kwargs)将由usit在驱动程序实例化期间根据设备索引文件中的信息提供(见下文)。实例化时,这个类设备必须直接与设备建立连接(信息通过\u init\uu
函数的可选参数传递),并保持连接。这个类设备也应该有一个函数来正确地关闭到设备的连接。在usit中使用close
和close_all
函数时调用此函数。importusit# It will output the fist time:# WARNING: USIT local folder created : <your_user_path># WARNING: Local config.ini file not found, duplicated from package in the local folder.
0
1)使用配置py脚本
configure
函数,该函数将在驱动程序实例化后调用,以便在usit中对设备进行建模。此函数必须接受两个参数:一个是实例化后的前一个设备
类的实例,另一个是空的原始usit模块对象的实例。此函数的目的是通过创建并关联变量
,操作
,模块
来配置此模块,并使用设备
对象的功能配置它们,如下例:importusit# It will output the fist time:# WARNING: USIT local folder created : <your_user_path># WARNING: Local config.ini file not found, duplicated from package in the local folder.
1
importusit# It will output the fist time:# WARNING: USIT local folder created : <your_user_path># WARNING: Local config.ini file not found, duplicated from package in the local folder.
2
2)设备索引文件
driver
并且必须指示位于drivers文件夹中的驱动程序的名称。在实例化驱动程序的类设备
时,节中的任何其他(关键字、值)对(连接信息…)都将以kwargs形式发送。
importusit# It will output the fist time:# WARNING: USIT local folder created : <your_user_path># WARNING: Local config.ini file not found, duplicated from package in the local folder.
3
3)USIT配置文件
驱动程序路径
:这是您的驱动程序文件夹的路径(请参见步骤1)。设备索引xpath
:这是设备配置文件的路径(请参见步骤2)。importusit# It will output the fist time:# WARNING: USIT local folder created : <your_user_path># WARNING: Local config.ini file not found, duplicated from package in the local folder.
4
推荐PyPI第三方库