# 实时数据 > 实时数据从`Redis`缓存获取 请求 ``` POST http://47.103.61.198:5008/api/breaker/data Header: Content-Type:application/json DD-Open-Key:d2ca79f1-4666-4ad5-953b-7ba5ee480fe0 Body: { "mac":"187ED53338C4" } ``` 响应: ``` { "data": { "serverinfo": { "port": "12345", "hardware": "T25", "execleakcheck": "false", "protocol_ver": "19", "mac": "187ED53338C4", "loginid": "187ED53338C4", "gate": "", "ip": "192.168.8.146", "version": "1.3.08", "loginpwd": "7a57a5a743894ae4", "ssidpwd": "2803f88db851c67a", "ssid": "DDINGW", "timezoneId": "Asia/Shanghai", "ServerProtocol": "2", "server": "47.103.61.198:5008/ebx-bishop/data/carry", "datetime": "2021-02-25 02:10:23", "leakcheckdate": "3,13,33", "lastleakcheckdate": "2017-01-01 10:00:00" }, "distributbox": { "breakers": { "1": { "version": "1.03", "title": "总路", "model": "JZK2L100-BL6523", "alarm": 0, "enableNetCtrl": true, "mxdw": 0, "mxgg": 14080, "mxgl": 96, "mxgw": 90, "mxgy": 260, "mxld": 30, "mxqy": 0, "openClose": false, "addr": 1, "power": 0.029, "specification": "64", "control": 1, "visibility": 1, "totalChannelId": -1, "lineType": "220", "a_A": 0, "a_T": 30.5, "a_V": 227, "a_WP": 0, "a_LD": 0, "a_PF": 0, "g_A": 0, "g_T": 0, "g_V": 0, "g_WP": 0, "g_LD": 0, "g_PF": 0, "b_A": 0, "b_T": 0, "b_V": 0, "b_WP": 0, "b_PF": 0, "c_A": 0, "c_T": 0, "c_V": 0, "c_WP": 0, "c_PF": 0, "n_A": 0, "n_T": 0 }, "2": { "version": "1.03", "title": "线路1", "model": "JZK2L100-BL6523", "alarm": 0, "enableNetCtrl": true, "mxdw": 0, "mxgg": 100, "mxgl": 30, "mxgw": 90, "mxgy": 260, "mxld": 30, "mxqy": 175, "openClose": true, "addr": 2, "power": 0, "specification": "20", "control": 1, "visibility": 1, "totalChannelId": 1, "lineType": "220", "a_A": 0, "a_T": 34.1, "a_V": 227, "a_WP": 0, "a_LD": 0, "a_PF": 0, "g_A": 0, "g_T": 0, "g_V": 0, "g_WP": 0, "g_LD": 0, "g_PF": 0, "b_A": 0, "b_T": 0, "b_V": 0, "b_WP": 0, "b_PF": 0, "c_A": 0, "c_T": 0, "c_V": 0, "c_WP": 0, "c_PF": 0, "n_A": 0, "n_T": 0 }, "3": { "version": "1.03", "title": "线路2", "model": "JZK2L100-BL6523", "alarm": 0, "enableNetCtrl": true, "mxdw": 0, "mxgg": 4400, "mxgl": 30, "mxgw": 90, "mxgy": 260, "mxld": 30, "mxqy": 175, "openClose": false, "addr": 3, "power": 0, "specification": "20", "control": 1, "visibility": 1, "totalChannelId": 1, "lineType": "220", "a_A": 0, "a_T": 34.1, "a_V": 227, "a_WP": 0, "a_LD": 0, "a_PF": 0, "g_A": 0, "g_T": 0, "g_V": 0, "g_WP": 0, "g_LD": 0, "g_PF": 0, "b_A": 0, "b_T": 0, "b_V": 0, "b_WP": 0, "b_PF": 0, "c_A": 0, "c_T": 0, "c_V": 0, "c_WP": 0, "c_PF": 0, "n_A": 0, "n_T": 0 } }, "change": null } }, "isError": false, "message": "success", "code": 200 } ``` 代码: ``` using DD.Libs.Devices.ManDun; var cacheRequest = new {mac="187ed5312345"}; var cacheResponse = await cacheUrl .WithHeader("Content-Type","application/json") .WithHeader("DD-Open-Key", "d2ca79f1-4666-4ad5-953b-7ba5ee480fe0") .PostJsonAsync(cacheRequest) .ReceiveJson(); ``` ``` public class RealtimeData { /// /// 配置信息 /// port,hardware,execleakcheck,mac,loginid,gate,ip, version, loginpwd,ssidpwd,ssid,timezoneId,server, datetime, leakcheckdate, lastleakcheckdate /// public IDictionary serverinfo { get; set; } /// /// 断路器开关数据 /// public DistributeBox distributbox { get; set; } } /// /// 分布式电箱 /// public class DistributeBox { /// /// 一个电箱有多个断路器 /// public IDictionary Breakers { get; set; } /// /// 模块关键数据是否有变化:1有变化,0没有变化。不用 /// public string Change { get; set; } } public class Breaker { #region 不带三相时的数据 /// /// 版本号 /// public string version { get; set; } /// /// 线路名称 /// public string title { get; set; } /// /// 线路型号(JZK2L100-BL6523表示是总路,JFK2L103-BL6523表示是分路) /// public string model { get; set; } /// /// 当前告警信息:0表示告警取消 /// public long Alarm { get; set; } /// /// 是否远程关闭:true是;false否 /// public bool EnableNetCtrl { get; set; } /// /// 低温门限值 /// public decimal MXDW { get; set; } /// /// 过功门限值 /// public decimal MXGG { get; set; } /// /// 过流门限值 /// public decimal MXGL { get; set; } /// /// 过温门限值 /// public decimal MXGW { get; set; } /// /// 过压门限值 /// public decimal MXGY { get; set; } /// /// 漏电门限值 /// public decimal MXLD { get; set; } /// /// 欠压门限值 /// public decimal MXQY { get; set; } /// /// 线路状态:true开;false关 /// public bool OpenClose { get; set; } /// /// 线路地址 /// public short addr { get; set; } /// /// 累计电量KW /// public decimal power { get; set; } /// /// 线路规格 /// public string specification { get; set; } /// /// 是否能控制(1为能,0为不能) /// public short control { get; set; } /// /// 线路是否显示(1显示;0不显示) /// public short visibility { get; set; } /// /// 接入到汇电线路下(-1为进线直连,非-1表示接入某总路的总路的线路ID) /// public int totalChannelId { get; set; } /// /// 线路类型(参数值有:220,380等) /// public string lineType { get; set; } /// /// A相电流(或单相电流) /// public decimal A_A { get; set; } /// /// A相温度(或单相温度) /// public decimal A_T { get; set; } /// /// A相电压(或单相电压) /// public decimal A_V { get; set; } /// /// A相功率(或单相功率) /// public decimal A_WP { get; set; } /// /// 单相漏电流(三相无值) /// public decimal A_LD { get; set; } /// /// A相功率因素(或单相功率因素) /// public decimal A_PF { get; set; } #endregion /// /// 平均电流(单相无值) /// public decimal G_A { get; set; } /// /// 机壳温度(单相无值) /// public decimal G_T { get; set; } /// /// 平均电压(单相无值) /// public decimal G_V { get; set; } /// /// 功率和值(单相无值) /// public decimal G_WP { get; set; } /// /// 三相漏电流(单相无值) /// public decimal G_LD { get; set; } /// /// 合相功率因数(单相无值) /// public decimal G_PF { get; set; } /// /// B相电流 /// public decimal B_A { get; set; } /// /// B相温度 /// public decimal B_T { get; set; } /// /// B相电压 /// public decimal B_V { get; set; } /// /// B相功率 /// public decimal B_WP { get; set; } /// /// B相功率因素 /// public decimal B_PF { get; set; } /// /// C相电流 /// public decimal C_A { get; set; } /// /// C相温度 /// public decimal C_T { get; set; } /// /// C相电压 /// public decimal C_V { get; set; } /// /// C相功率 /// public decimal C_WP { get; set; } /// /// C相功率因素 /// public decimal C_PF { get; set; } /// /// 零线电流 /// public decimal N_A { get; set; } /// /// 零线温度 /// public decimal N_T { get; set; } } ``` > 模拟模块的模拟数据,也存入`Redis`缓存 > 开放平台接口如何设计? - 任意多个模块 - 任意时间段内 - 任意数据:电流、电压、全部 # 报警报表 > 从哪里获取? 如果没有选择时间,从报警历史数据中获取,报警的历史数据保存在时序数据库。 > 有哪些有关时间的条件? - 按小时:过去60分钟 - 按天:前一天的凌晨到现在的小时 - 按周:过去7天 - 按月:过去30天 > 时间以外的条件? 报警类型。 > 时序数据库设计 ``` ts timestamp mac addr start:报警开始时间 end:报警结束时间 type:报警类型 level:报警级别 val:当前值 limit:阈值 ``` > 接口如何设计 ``` time type level mac addr ``` > 要做的事 - 创建时序数据库 - 随时创建按小时、按天、按周、按月的种子数据接口 - 根据条件查询报警历史数据 > 开放平台接口如何设计? - 任意多个模块 - 任意时间段内 - 任意报警类型 # 电量报表 > 从哪里获取 从时序数据库获取,调用开放平台的接口。 > 有哪些查询条件? - 按天:前一天的凌晨到现在的小时 - 按周:过去7天 - 按月:过去30天 - 某个开关 > 开放平台接口如何设计? - 任意多个模块 - 任意时间段内 - 任意计算 # 负荷报表 > 有哪些查询条件? - 最近60分钟 - 按开关 - 按公司 > 从哪里获取? 开放平台提供接口,从关系数据库获取。 > 开放平台如何设计? - 最近60分钟内 - 任意计算