跳转到主要内容

GE Pace库

项目描述

GE Pace库

Pace 5000

此库用于控制GE压力自动化校准设备(Pace)1000、5000和6000型号的基本功能。

它由一个核心库、一个可选的模拟器和可选的tango设备服务器组成。

它已与Pace 5000型号进行了测试,但应与其他型号兼容。

它可以使用ETH或串行线路连接(以下将介绍设置串行线路连接的推荐方法)。

安装

在您喜欢的Python环境中输入

$ pip install gepace

gepace库的核心是Pace对象。要创建Pace对象,您需要传递一个通信对象。

通信对象可以是任何支持简单API的对象,该API包含两个方法(支持同步或异步版本)

  • write_readline(buff: bytes) -> bytes

    async write_readline(buff: bytes) -> bytes

  • write(buff: bytes) -> None

    async write(buff: bytes) -> None

支持此API的库是 sockio(gepace预装,因此无需担心安装)。

此库包括TCP对象的异步和同步版本。它还支持重新连接和超时处理等功能。

以下是如何连接到GE Pace控制器

import asyncio

from sockio.aio import TCP
from gepace import Pace


async def main():
    tcp = TCP("192.168.1.123", 5000)  # use host name or IP
    pace = Pace(tcp)

    idn = await pace.idn()
    name = await pace.name()
    print("Connected to {} ({})".format(idn, name))

    # channel access:
    temp_A = await pace['A'].temperature()
    unit = await pace['A'].unit()
    print("Channel A temperature: {}{}".format(temp_A, unit))

    # loop access:
    source_1 = await pace[1].source()
    print("Loop 1 source: {}".format(source_1))

    # activate control
    await pace.control(True)

    # hardware only accepts queries every 100ms. Yo can, however,
    # group queries in single request:
    async with pace as group:
        pace.idn()
        pace.control()
        pace['A'].temperature()
    idn, ctrl, temp_A = group.replies


asyncio.run(main())

串行线

要访问基于串行的 Pace 设备,强烈建议您使用 ser2netsocat 启动串行到TCP桥接。

假设您的设备连接到 /dev/ttyS0 并且波特率设置为19200,以下是使用socat在机器端口5000上公开您的设备的方法

socat -v TCP-LISTEN:5000,reuseaddr,fork file:/dev/ttyS0,rawer,b19200,cs8,eol=10,icanon=1

可以考虑使用 supervisorcircus 将 socat 或 ser2net 作为服务启动。

模拟器

提供 Pace 模拟器。

在使用之前,请确保已安装所有内容

$ pip install gepace[simulator]

使用 sinstruments 引擎。

要启动模拟器,您需要编写一个 YAML 配置文件,其中定义您想要模拟的设备数量以及它们拥有的属性。

以下示例导出2个硬件设备。第一个是使用默认值的简化配置,第二个明确定义了一些初始值

# config.yml

devices:
- class: Pace
  package: gepace.simulator
  transports:
  - type: tcp
    url: :5000

要启动模拟器,请输入

$ sinstruments-server -c ./config.yml --log-level=DEBUG
2020-05-14 16:02:35,004 INFO  simulator: Bootstraping server
2020-05-14 16:02:35,004 INFO  simulator: no backdoor declared
2020-05-14 16:02:35,004 INFO  simulator: Creating device Pace ('Pace')
2020-05-14 16:02:35,080 INFO  simulator.Pace[('', 5000)]: listening on ('', 5000) (newline='\n') (baudrate=None)

(要查看完整选项列表,请输入 sinstruments-server --help)

您可以通过以下方式访问它,就像访问真实硬件一样

$ nc localhost 5000
*IDN?
GE,Pace5000,204683,1.01A

或使用库

$ python
>>> from sockio.sio import TCP   # use synchronous socket in the CLI!
>>> from gepace import Pace
>>> pace = Pace(TCP('localhost', 5000))
>>> print(pace.idn())
GE,Pace5000,204683,1.01A

Tango服务器

还提供tango 设备服务器。

确保已安装所有内容

$ pip install gepace[tango]

在tango数据库中注册gepace tango服务器

$ tangoctl server add -s GEPace/test -d Pace test/cryocon/1
$ tangoctl device property write -d test/pace/1 -p address -v "tcp://192.168.123:5000"

(上述示例使用 tangoctl。在使用之前,您需要使用 pip install tangoctl 安装它。您可以使用任何其他tango工具,如 fandango 或 Jive)

使用以下命令启动服务器

$ GEPace test

待办事项

  • 添加 on_connection_made 回调以使用
    • unit=K
    • 缓存IDN、fw版本、hw版本
    • 是否应该缓存system:name?和input:name?在理论上可以直接通过硬件前面板进行修改

项目详情


下载文件

下载适合您平台的应用程序。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源分发

gepace-1.1.3.tar.gz (13.8 kB 查看哈希值)

上传时间

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面