Skip to main content

3DS平台业务层的数据查询SDK

Project description

D3SDK

D3SDK是3DS系统提供的数据开发包(以下简称SDK),用于简化Python里访问各类数据库的操作。

一、安装

1.1 安装SDK

安装SDK最新版本:

pip install -U d3sdk

二、使用SDK

1、查询报警组列表

调用SDK代码示例:

from d3sdk.d3_dataframe_db import D3DataFrameDB
from d3sdk.model.device_failure_record import DeviceFailureRecord

k2a_host = '192.168.132.167'
k2a_port = 443
k2a_user = 'zhangsan'
k2a_basic_token = '0c475ffd8960c17046b531e2xxx'

k2a_url = f'k2assets+3ds://{k2a_user}:{k2a_basic_token}@{k2a_host}:{k2a_port}'
db = D3DataFrameDB(k2a_url)
result = db.getDeviceFailureRecords(
                                devices=['T0000000002'],
                            #  earliestAlarmTimeBegin='2024-06-29 04:45:27',
                            #  earliestAlarmTimeEnd='2024-06-29 19:45:27',
                            #  latestAlarmTimeBegin='2024-06-29 04:45:27',
                            #  latestAlarmTimeEnd='2024-06-29 19:45:27',
                                alarmTypes=['failure'],
                                description='电流',
                                desc=True,
                                fmtNames=['工况与环境'],
                                limit=2)
for record in result:
    print(f"class_type: {type(record)}")
    print(f"alarmGroupCode: {record.alarmGroupCode}")
    print(f"deviceCode: {record.deviceCode}")
    print(f"alarmGroupName: {record.alarmGroupName}")
    print(f"alarmCode: {record.alarmCode}")
    print(f"alarmType: {record.alarmType}")
    print(f"description: {record.description}")
    print(f"earliestAlarmTime: {record.earliestAlarmTime}")
    print(f"fms: ")
    for fm in record.fms:
        print(f"  {fm}")
    print("-" * 120)

运行结果示例:

class_type: <class 'd3sdk.model.device_failure_record.DeviceFailureRecord'>
alarmGroupCode: AG0000114480
deviceCode: T0000000002
alarmGroupName: 三相电流不平衡度超过限值
alarmCode: FM801908
alarmType: failure
description: 三相电流不平衡度超过限值
earliestAlarmTime: 2024-06-30 13:37:20
fms: 
  Fm(fm_code=QLJ00006, fm_name=工况与环境, fmt_code=QLJ00006, fmt_name=工况与环境, fmt_type=2)
------------------------------------------------------------------------------------------------------------------------
class_type: <class 'd3sdk.model.device_failure_record.DeviceFailureRecord'>
alarmGroupCode: AG0000114275
deviceCode: T0000000002
alarmGroupName: 三相电流不平衡度超过限值
alarmCode: FM801908
alarmType: failure
description: 三相电流不平衡度超过限值
earliestAlarmTime: 2024-06-30 13:26:14
fms: 
  Fm(fm_code=QLJ00006, fm_name=工况与环境, fmt_code=QLJ00006, fmt_name=工况与环境, fmt_type=2)
------------------------------------------------------------------------------------------------------------------------

2、根据报警组编号查询报警编码、类型及其原因和建议

调用SDK代码示例:

from d3sdk.d3_dataframe_db import D3DataFrameDB
from d3sdk.model.alarm_group_detail import AlarmGroupDetail

k2a_host = '192.168.132.167'
k2a_port = 443
k2a_user = 'zhangsan'
k2a_basic_token = '0c475ffd8960c17046b531e2xxx'

k2a_url = f'k2assets+3ds://{k2a_user}:{k2a_basic_token}@{k2a_host}:{k2a_port}'
db = D3DataFrameDB(k2a_url, debug=False)
result = db.getAlarmDetails(alarmGroupCode='AG0000121409')
for record in result:
    print(f"class_type: {type(record)}")
    print(f"alarm_code: {record.dfem_sxmsbh}")
    print(f"alarm_type: {record.dfem_bjlx}")
    print(f"causes: ")
    for cause in record.causes:
        print(f"  cause_code: {cause.code}")
        print(f"  cause_display_name: {cause.display_name}")
        print(f"  cause_description: {cause.description}")
        print(f"  steps: ")
        for step in cause.steps:
            print(f"    {step}")
        print
    print("-" * 120)

运行结果示例:

class_type: <class 'd3sdk.model.alarm_group_detail.AlarmDetail'>
alarm_code: FM800412
alarm_type: failure
causes: 
  cause_code: RS800001
  cause_display_name: 定子绕组温度持续动态超限原因
  cause_description: 定子冷却水异常;线棒内部堵塞或结垢。
  steps: 
    Step(code='JY800001', display_name='定子绕组温度持续动态超限处理建议', description='检查定子冷却水流量、压力与温度等是否异常,检查机组三相负载是否平衡。')
    Step(code='JY800004', display_name='定子绕组温度超限报警处理建议', description='检查冷却水流量、压力与温度等是否正常,检查发电机是否过载,检查绝缘过热、局部放电装置数据是否正常,降负荷运行至报警信号解除,若温度继续升高,应尽快停机检查。')
------------------------------------------------------------------------------------------------------------------------

3、查询某个征兆的原因及其建议

调用SDK代码示例:

from d3sdk.d3_dataframe_db import D3DataFrameDB
from d3sdk.model.alarm_group_detail import AlarmGroupDetail

k2a_host = '192.168.132.167'
k2a_port = 443
k2a_user = 'zhangsan'
k2a_basic_token = '0c475ffd8960c17046b531e2xxx'

k2a_url = f'k2assets+3ds://{k2a_user}:{k2a_basic_token}@{k2a_host}:{k2a_port}'
db = D3DataFrameDB(k2a_url, debug=True)
result = db.getSymptomCauses('SP800511')
# 打印结果
for cause in result:
    print(f"class_type: {type(cause)}")
    print(f"code: {cause.code}")
    print(f"display_name: {cause.display_name}")
    print(f"description: {cause.description}")
    print(f"steps: ")
    for step in cause.steps:
        print(f"    {step}")
    print("-" * 120)

运行结果示例:

class_type: <class 'd3sdk.model.alarm_group_detail.Cause'>
code: RS800065
display_name: 定子冷却水进水温度超上限原因
description: 发电机定子冷却水进水温度偏大。
steps: 
    Step(code='JY800065', display_name='定子冷却水进水温度超上限处理建议', description='检查定子冷却水系统,降低进水温度,并监控发电机定子线棒温度。')
------------------------------------------------------------------------------------------------------------------------
class_type: <class 'd3sdk.model.alarm_group_detail.Cause'>
code: RS800067
display_name: 定子冷却水进水压力超上限原因
description: 发电机定子冷却水进水压力偏大。
steps: 
    Step(code='JY800067', display_name='定子冷却水进水压力超上限处理建议', description='暂无。')
------------------------------------------------------------------------------------------------------------------------
class_type: <class 'd3sdk.model.alarm_group_detail.Cause'>
code: RS800069
display_name: 定子冷却水进水流量超上限原因
description: 发电机定子冷却水进水流量偏大。
steps: 
    Step(code='JY800069', display_name='定子冷却水进水流量超上限处理建议', description='暂无。')
------------------------------------------------------------------------------------------------------------------------

4、查询某个失效的原因及其建议

调用SDK代码示例:

from d3sdk.d3_dataframe_db import D3DataFrameDB
from d3sdk.model.alarm_group_detail import AlarmGroupDetail

k2a_host = '192.168.132.167'
k2a_port = 443
k2a_user = 'zhangsan'
k2a_basic_token = '0c475ffd8960c17046b531e2xxx'

k2a_url = f'k2assets+3ds://{k2a_user}:{k2a_basic_token}@{k2a_host}:{k2a_port}'
db = D3DataFrameDB(k2a_url, debug=True)
result = db.getFailureCauses('FM000001')
for cause in result:
    print(f"class_type: {type(cause)}")
    print(f"code: {cause.code}")
    print(f"display_name: {cause.display_name}")
    print(f"description: {cause.description}")
    print(f"steps: ")
    for step in cause.steps:
        print(f"  {step}")
    print("-" * 120)

运行结果示例:

class_type: <class 'd3sdk.model.alarm_group_detail.Cause'>
code: RS000015
display_name: 发电机相电流超过额定值原因
description: 暂无
steps: 
  Step(code='JY000015', display_name='发电机相电流超过额定值处理建议', description='降低负荷')
------------------------------------------------------------------------------------------------------------------------

5、查询机组的测点列表(通过机组找到数据分组的量测及其映射到的repo和repo_column)

调用SDK代码示例:

from d3sdk.d3_dataframe_db import D3DataFrameDB
from d3sdk.model.alarm_group_detail import AlarmGroupDetail

k2a_host = '192.168.132.167'
k2a_port = 443
k2a_user = 'zhangsan'
k2a_basic_token = '0c475ffd8960c17046b531e2xxx'

k2a_url = f'k2assets+3ds://{k2a_user}:{k2a_basic_token}@{k2a_host}:{k2a_port}'
db = D3DataFrameDB(k2a_url, debug=True)
result = db.getInstanceMeasurements(devices=['T0000000002'])
for instanceMeasurements in result:
    print(f"  {instanceMeasurements}")

运行结果示例:

InstanceMeasurement(device_code=T0000000002, measurement=Steam.Turbine.10LAB11CP101, repo_code=YY_GN_unit1_thermo_raw, repo_column=10LAB11CP101)
InstanceMeasurement(device_code=T0000000002, measurement=Steam.Turbine.10LAB11CT301, repo_code=YY_GN_unit1_thermo_raw, repo_column=10LAB11CT301)
InstanceMeasurement(device_code=T0000000002, measurement=Steam.Turbine.10LAB31CP101, repo_code=YY_GN_unit1_thermo_raw, repo_column=10LAB31CP101)
InstanceMeasurement(device_code=T0000000002, measurement=Steam.Turbine.10LAB31CP102, repo_code=YY_GN_unit1_thermo_raw, repo_column=10LAB31CP102)
InstanceMeasurement(device_code=T0000000002, measurement=Steam.Turbine.10LAB31CT301, repo_code=YY_GN_unit1_thermo_raw, repo_column=10LAB31CT301)
InstanceMeasurement(device_code=T0000000002, measurement=Steam.Turbine.10LAB51CT301, repo_code=YY_GN_unit1_thermo_raw, repo_column=10LAB51CT301)
more ...

6、查询机组报警相关的测点列表(业务对象-报警诊断依据配置的量测,及其映射到的repo和repo_column)

调用SDK代码示例:

from d3sdk.d3_dataframe_db import D3DataFrameDB
from d3sdk.model.alarm_group_detail import AlarmGroupDetail

k2a_host = '192.168.132.167'
k2a_port = 443
k2a_user = 'zhangsan'
k2a_basic_token = '0c475ffd8960c17046b531e2xxx'

k2a_url = f'k2assets+3ds://{k2a_user}:{k2a_basic_token}@{k2a_host}:{k2a_port}'
db = D3DataFrameDB(k2a_url, debug=True)
result = db.getInstanceMeasurementsFilter(device='T0000000002', alarms=['FM800412'])
for instanceMeasurements in result:
    print(f"  {instanceMeasurements}")

运行结果示例:

InstanceMeasurement(device_code=T0000000002, measurement=Steam.Turbine.10LAB11CP101, repo_code=YY_GN_unit1_thermo_raw, repo_column=10LAB11CP101)
InstanceMeasurement(device_code=T0000000002, measurement=Steam.Turbine.10LAB11CT301, repo_code=YY_GN_unit1_thermo_raw, repo_column=10LAB11CT301)
InstanceMeasurement(device_code=T0000000002, measurement=Steam.Turbine.10LAB31CP101, repo_code=YY_GN_unit1_thermo_raw, repo_column=10LAB31CP101)
InstanceMeasurement(device_code=T0000000002, measurement=Steam.Turbine.10LAB31CP102, repo_code=YY_GN_unit1_thermo_raw, repo_column=10LAB31CP102)
InstanceMeasurement(device_code=T0000000002, measurement=Steam.Turbine.10LAB31CT301, repo_code=YY_GN_unit1_thermo_raw, repo_column=10LAB31CT301)
InstanceMeasurement(device_code=T0000000002, measurement=Steam.Turbine.10LAB51CT301, repo_code=YY_GN_unit1_thermo_raw, repo_column=10LAB51CT301)
more ...

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

d3sdk-0.1.16-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file d3sdk-0.1.16-py3-none-any.whl.

File metadata

  • Download URL: d3sdk-0.1.16-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.0

File hashes

Hashes for d3sdk-0.1.16-py3-none-any.whl
Algorithm Hash digest
SHA256 e6e61b2f70d48b9e9d403dd22396c6bda09587480bc93eb023e8261e8ad18ca6
MD5 9a5e280b7bc10e524300cfaae0c347ae
BLAKE2b-256 f5bb94097b0af6e14d4bc26fb15202ce01f5a87a26d8460e9a2f03a90baaf3f0

See more details on using hashes here.

Supported by

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