dlt698.45规约源代码

  • P4_483575
    了解作者
  • 2.2MB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-07 01:49
    上传日期
本附件为698.45源码,供参考学习使用。电力行业698通信协议,其中698.45协议面向对象的互操作性数据交换协议,本部分规定了电能信息采集与管理系统主站(以下简称“主站”)、采集终端或电能表(以下简称“终端”)之间,采用的面向对象具有互操作性的数据传输协议,包括通信架构、数据链路层、应用层、以及接口类及其对象和对象标识。本部分适用于主站、采集终端、电能表之间采用点对点、多点共线及一点对多点通信方式的通信数据交换。
dlt698.45-dev_save.zip
内容介绍
/* * readplc.c * * Created on: 2017-1-4 * Author: wzm */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <signal.h> #include <wait.h> #include <errno.h> #include <time.h> #include <pthread.h> #include <termios.h> #include <sys/mman.h> #include <sys/reboot.h> #include <sys/time.h> #include "lib3762.h" #include "readplc.h" #include "cjdeal.h" #include "cjsave.h" #include "dlt645.h" #include "dlt698.h" #include "dlt698def.h" static OAD OAD_PORT_ZB={0xF209,0x02,0x01}; extern ProgramInfo* JProgramInfo; extern int SaveOADData(INT8U taskid,OAD oad_m,OAD oad_r,INT8U *databuf,int datalen,TS ts_res); extern INT16U data07Tobuff698(FORMAT07 Data07,INT8U* dataContent); extern INT16U data97Tobuff698(FORMAT97 Data97,INT8U* dataContent); extern INT8U increase6035Value(INT8U taskID,INT8U type); extern INT8S OADMap07DI(OI_698 roadOI,OAD sourceOAD, C601F_645* flag645); extern void DbgPrintToFile1(INT8U comport,const char *format,...); extern void DbPrt1(INT8U comport,char *prefix, char *buf, int len, char *suffix); extern INT8U checkMeterType(MY_MS mst,INT8U usrType,TSA usrAddr); extern INT16S composeProtocol698_GetRequest(INT8U* sendBuf, CLASS_6015 obj6015,TSA meterAddr); //extern INT8U getSaveTime(DateTimeBCD* saveTime,INT8U cjType,INT8U saveTimeFlag,DATA_TYPE curvedata); //extern INT16U compose6012Buff(DateTimeBCD startTime,DateTimeBCD saveTime,TSA meterAddr,INT16U dataLen,INT8U* dataContent, INT8U port485); extern mqd_t mqd_zb_task; extern CLASS_4204 broadcase4204; extern GUI_PROXY cjGuiProxy_plc; extern Proxy_Msg* p_Proxy_Msg_Data;//液晶给抄表发送代理处理结构体,指向由guictrl.c配置的全局变量 extern TASK_CFG list6013[TASK6012_CAIJI]; extern INT8U analyzeProtocol698(INT8U* Rcvbuf, INT8U* resultCount, INT16S recvLen, INT8U* apduDataStartIndex, INT16S* dataLen) ; extern INT8U deal698RequestResponse(INT8U getResponseType,INT8U csdNum,INT8U* apdudata,OADDATA_SAVE* oadListContent,INT16U* apdudataLen); extern INT8U parseSingleROADDataHead(INT8U* oadData,OADDATA_SAVE* oadListContent,INT8U* rcvCSDnum,INT8U* recordNum); extern INT16U parseSingleROADDataBody(INT8U* oadData,OADDATA_SAVE* oadListContent,INT8U rcvCSDnum); int task_Refresh(TASK_UNIT *taskunit); void chkTsaTask(TASK_INFO *meterinfo); //----------------------------------------------------------------------------------------------------------------------------------------------------- typedef struct { INT8U startIndex; //报文中的某数据的起始字节 INT8U dataLen; //数据长度(字节数) INT8U aunite; //一个数据单元长度 INT8U intbits; //整数部分长度 INT8U decbits; //小数部分长度 char name[30]; INT8U Flg07[4];//对应07表实时数据标识 OAD oad1; OAD oad2; }MeterCurveDataType; #define CURVENUM 29 MeterCurveDataType meterCurveData[CURVENUM]= { {60, 4, 4, 6, 2, "正向有功总电能曲线", {0x00,0x01,0x00,0x00},{0x5002,0x02,0x00},{0x0010,0x02,0x00}}, {64, 4, 4, 6, 2, "反向有功总电能曲线", {0x00,0x02,0x00,0x00},{0x5002,0x02,0x00},{0x0020,0x02,0x00}}, {77, 4, 4, 6, 2, "一象限无功总电能曲线",{0x00,0x05,0x00,0x00},{0x5002,0x02,0x00},{0x0050,0x02,0x00}}, {81, 4, 4, 6, 2, "二象限无功总电能曲线",{0x00,0x06,0x00,0x00},{0x5002,0x02,0x00},{0x0060,0x02,0x00}}, {85, 4, 4, 6, 2, "三象限无功总电能曲线",{0x00,0x07,0x00,0x00},{0x5002,0x02,0x00},{0x0070,0x02,0x00}}, {89, 4, 4, 6, 2, "四象限无功总电能曲线",{0x00,0x08,0x00,0x00},{0x5002,0x02,0x00},{0x0080,0x02,0x00}}, {8, 6, 2, 3, 1, "当前电压", {0x02,0x01,0xff,0x00},{0x5002,0x02,0x00},{0x2000,0x02,0x00}}, {14, 9, 3, 3, 3, "当前电流", {0x02,0x02,0xff,0x00},{0x5002,0x02,0x00},{0x2001,0x02,0x00}}, {26, 12,3, 2, 4, "有功功率曲线", {0x02,0x03,0xff,0x00},{0x5002,0x02,0x00},{0x2004,0x02,0x00}}, {51, 8, 2, 2, 1, "功率因数曲线", {0x02,0x06,0xff,0x00},{0x5002,0x02,0x00},{0x200a,0x02,0x00}} // {8, 2, 3, 1, "A相电压", {0x01,0x01,0x10,0x06}}, // {10, 2, 3, 1, "B相电压", {0x02,0x01,0x10,0x06}}, // {12, 2, 3, 1, "C相电压", {0x03,0x01,0x10,0x06}}, // // {14, 3, 3, 3, "A相电流", {0x01,0x02,0x10,0x06}}, // {17, 3, 3, 3, "B相电流", {0x02,0x02,0x10,0x06}}, // {20, 3, 3, 3, "C相电流", {0x03,0x02,0x10,0x06}}, // // {23, 2, 2, 2, "频率曲线", {0xFF,0xFF,0xFF,0xFF}}, // // {26, 3, 2, 4, "总有功功率曲线", {0x00,0x03,0x10,0x06}}, // {29, 3, 2, 4, "A相有功功率曲线", {0x01,0x03,0x10,0x06}}, // {32, 3, 2, 4, "B相有功功率曲线", {0x02,0x03,0x10,0x06}}, // {35, 3, 2, 4, "C相有功功率曲线", {0x03,0x03,0x10,0x06}}, // // {38, 3, 2, 4, "总无功功率曲线", {0x00,0x04,0x10,0x06}}, // {41, 3, 2, 4, "A相无功功率曲线", {0x01,0x04,0x10,0x06}}, // {44, 3, 2, 4, "B相无功功率曲线", {0x02,0x04,0x10,0x06}}, // {47, 3, 2, 4, "C相无功功率曲线", {0x03,0x04,0x10,0x06}}, // // {51, 2, 3, 1, "总功率因数曲线", {0x00,0x05,0x10,0x06}}, // {53, 2, 3, 1, "A相功率因数曲线", {0x01,0x05,0x10,0x06}}, // {55, 2, 3, 1, "B相功率因数曲线", {0x02,0x05,0x10,0x06}}, // {57, 2, 3, 1, "C相功率因数曲线", {0x03,0x05,0x10,0x06}}, // // {60, 4, 6, 2, "正向有功总电能曲线",{0x01,0x06,0x10,0x06}}, // {64, 4, 6, 2, "反向有功总电能曲线",{0x02,0x06,0x10,0x06}}, // {68, 4, 6, 2, "正向无功总电能曲线",{0x03,0x06,0x10,0x06}}, // {72, 4, 6, 2, "反向无功总电能曲线",{0x04,0x06,0x10,0x06}}, // // {77, 4, 6, 2, "一象限无功总电能曲线",{0x01,0x07,0x10,0x06}}, // {81, 4, 6, 2, "二象限无功总电能曲线",{0x02,0x07,0x10,0x06}}, // {85, 4, 6, 2, "三象限无功总电能曲线",{0x03,0x07,0x10,0x06}}, // {89, 4, 6, 2, "四象限无功总电能曲线",{0x04,0x07,0x10,0x06}}, // // {94, 3, 2, 4, "当前有功需量曲线", {0xFF,0xFF,0xFF,0xFF}}, // {97, 3, 2, 4, "当前无功需量曲线", {0xFF,0xFF,0xFF,0xFF}}, }; int findFromPools_ByTsa(INT8U *addr ) { int i = 0; for(i=0;i<4;i++) { if (memcmp(addr,plcPools.pool[i].tsa.addr,8) == 0 ) { return i; } } return -1; } int findFromPools(INT8U *addr ,INT8U *itemflag) { int i = 0; for(i=0;i<4;i++) { if (memcmp(addr,plcPools.pool[i].tsa.addr,8) == 0 ) { if (memcmp(itemflag,plcPools.pool[i].item.item07,4) == 0) //抄读项 与 回码数据项相同 { return i; } } } return -1; } void myadd2Pools(int ti,int ii) { int i=0; i = plcPools.point; plcPools.pool[i].task_i = ti; plcPools.pool[i].item_i = ii; plcPools.pool[i].taskID = taskinfo.task_list[ti].taskId; plcPools.pool[i].fangAn = taskinfo.task_list[ti].fangan.No; memcpy(&plcPools.pool[i].item,&taskinfo.task_list[ti].fangan.items[ii],sizeof(DATA_ITEM)); memcpy(&plcPools.pool[i].tsa,&taskinfo.tsa,sizeof(TSA)); plcPools.point = (plcPools.point + 1)%4; } int findFangAnIndex(int code) { int i=0; for(i=0;i<FANGAN6015_MAX;i++) { if (fangAn6015[i].sernum == code) { return i; } } return -1; } void JugeLastTime_SetZero(TASK_INFO *tasklist) { DateTimeBCD ts; time_t nowt = time(NULL); int jianGe_sec=0,zhouqi_sec; int i=0 , j=0,num=0,k=0; num = tasklist->task_n; for(i=0;i<num;i++) { zhouqi_sec = TItoSec(tasklist->task_list[i].ti);//一个周期的秒数 jianGe_sec = abs(nowt - tasklist->task_list[i].beginTime);//当前时刻距离开始时刻的秒数 k = jianGe_sec/zhouqi_sec ; if (k>0)//计算上一个任务开始时刻 { DbgPrintToFile1(31,"任务%d 计算下一次开始时间,标示清零(周期秒%d 间隔总秒数%d k=%d)",tasklist->task_list[i].taskId,zhouqi_sec,jianGe_sec,k); tasklist->task_list[i].beginTime += k * zhouqi_sec; ts = timet_bcd(tasklist->task_list[i].beginTime ); tasklist->task_list[i].begin = ts; for(j=0;j<tasklist->task_list[i].fangan.item_n;j++) tasklist->task_list[i].fangan.items[j].sucessflg = 0; } } } DateTimeBCD ChgSucessFlg(TASK_INFO *taskinfo_p,DATA_ITEM item,INT8U usrtype,INT8U protocol,INT8U sucessflg) { DateTimeBCD timebcd; int i=0,j=0,tnum=0
评论
    相关推荐
    • 信息架构
      信息架构以规范化构造端到端的卓越业务流程为中心,致力于打造最强、最好的信息架构,欢迎大家下载参考!...该文档为信息架构,是一份很不错的参考资料,具有较高参考价值,感兴趣的可以下载看看
    • 架构实战.zip
      架构实战:软件架构设计的过程》从基本原理入手,介绍软件架构设计过程中涉及的一些概念、流程、方法、用到的工作产品及可重用的资源,从第6章开始,通过介绍一个具体的案例来阐述如何定义需求、创建逻辑架构、创建...
    • 渠道业务架构
      相信来查找渠道业务架构的你对于这一行业多少也有些了解,而渠道业务架构就是最好的选择,赶快下载参考使...该文档为渠道业务架构,是一份很不错的参考资料,具有较高参考价值,感兴趣的可以下载看看
    • google架构
      google的架构思想。。。新思路,新财富。。。
    • skyline 架构
      详细介绍了Skyline软件的架构、对于入门Skyline的不错。
    • 三成架构代码
      有关三层架构有很多理解。下面用养猪为比喻,介绍三层架构究竟是个什么东西。 层次结构在现实社会里随处可见,公司人员结构会分层,楼房是分层的,甚至做包子的笼屉都是分层的。虽然分层的目的各有不同,但都是为 ...
    • 架构师试题
      架构师试题架构师试题架构师试题架构师试题架构师试题架构师试题架构师试题架构师试题架构师试题架构师试题架构师试题
    • 计算机架构
      计算机架构
    • FreamSet架构
      FreamSet架构
    • eBay架构
      eBay架构