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='降低负荷')
------------------------------------------------------------------------------------------------------------------------

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.14-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: d3sdk-0.1.14-py3-none-any.whl
  • Upload date:
  • Size: 9.3 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.14-py3-none-any.whl
Algorithm Hash digest
SHA256 6d344a8973f72f5acc96343fb3a79dd2277a0196c494043b26167d6ee8505db2
MD5 cacbfbc04182230db0f1fbc4f0e299a6
BLAKE2b-256 38db634e5de4c2bbabfe859db90d22cfe1241fcce8dd873ce048c22d806451c2

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