Skip to main content

YSDB Python Client SDK

Project description

YSDB SDK

目前支持 Windows、CentOS 和 Debian 环境(Debian为K2Assets的python运行环境)。

此SDK为二次开发人员提供ysdb数据库的python客户端开发接口。

ysdb提供标准C动态库,由python封装C动态库,对外提供标准python的接口SDK。用户只需要调用python的对象既可以访问ysdb数据库。

一、安装和验证

安装SDK最新版本:

pip install -U ysdb

在python代码里引用并建立到指定ysdb服务器的连接:

from ysdb.ysdbLib import RdbClient

client = RdbClient()
ret = client.connect("192.168.131.238", 30221)

以上代码若运行成功将返回下面的结果,表示连接成功:

rdbConnectOk, handle:1

二、直接使用SDK

直接使用ysdb sdk的方法,例如读取ysdb中的散点或波形数据,请参考《ysdb数据库开发接口(Python)》文档。

三、通过封装类使用SDK

昆仑数据基于ysdb原有接口做了一层封装(RdbWrapper类),去掉了不常用的参数,使得调用更方便。

目前RdbWrapper只提供个别接口的功能,未来视情况扩展。

1、写入遥控命令

基于原SDK中的loginwriteCtrlDataById接口封装,用于向ysdb写入遥控命令。

接口定义

  • write_ctrl_data(mode, point_id, point_value)

输入参数

参数名称 参数含义
mode 写入模式,0表示写入状态量,1表示写入模拟量
point_id 要遥控的测点ID
point_value 要写入的遥控值。mode为0时,1代表打开,0代表关闭;

返回值

  • 返回1表示写入成功,非1表示写入失败
  • 若connect或login失败将抛出异常

示例

from ysdb.wrapper import RdbWrapper

rdbWrapper = RdbWrapper('192.168.130.13', 30221, 'Administrator', '123')
ret = rdbWrapper.write_ctrl_data(0, 2, 1)  # 写入状态量到2号测点
ret = rdbWrapper.write_ctrl_data(1, 4, 3.0)  # 写入模拟量到4号测点

# 登录ysdb得到的token有效期为10分钟,若持续写入遥控命令,需要定期更新token
rdbWrapper.refresh_token()

2、更新token

登录ysdb得到的token有效期为10分钟,若持续调用需要token的接口,需要定期更新token。

接口定义

  • refresh_token()

返回值

  • 若更新成功返回token值
  • 若更新失败将抛出异常

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ysdb-0.2.0-py3-none-any.whl (53.4 MB view details)

Uploaded Python 3

File details

Details for the file ysdb-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ysdb-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 53.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for ysdb-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a993d4e3d893c8361d75f95e08b78be21bee80722eea32c0c158f6bd930a22fa
MD5 d27b64c59fa5be327e771d40753e31e4
BLAKE2b-256 cf606f5dfb8b45a541440a35209e4da49bfeb614bf883caaa1b4262d02ed3b20

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page