日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

61850构建流程

發布時間:2024/8/1 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 61850构建流程 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

要搭建一個61850服務器,可以通過libiec61850這個開源庫實現

首先是源碼下載,網址為libiec61850.com/libiec61850/downloads,此文使用的是libiec61850-1.4.2.1.tar.gz

接下來是編譯

tar xvf libiec61850-1.4.2.1.tar.gz cd libiec61850-1.4.2.1 mkdir build cd build export TOOLCHAIN /usr/local/arm-6ul/bin/arm-none-gnueabi- cmake -DCMAKE_INSTALL_PREFIX=/opt/libiec61850 .. make make install

執行完上面一堆操作后,在/opt/libiec61850下面就有編譯好的庫和頭文件了

libiec61850支持多種開發,C/C++,donet,python都可以使用,并且提供了demo,以下是C的用法

以一個61850服務為例,需要實現幾點

服務端程序

模型文件model.cfg

測試程序IEDScount

服務端程序可以使用examples/server_example_config_file/server_example_config_file.c

服務端程序需要一個模型配置文件,可以自己寫一個,也可以直接使用源碼提供的model.cfg
具體寫法查看另一篇文章-IEC61850建模說明

示例中給出的數據點讀取和寫入方法是相當粗糙的,這里提供一個比較方便的使用方法
編緝icd文件,找到數據點,添加一個屬性為sAddr=“41000”,sAddr就是數據點的數字id
具體添加方式可以在建模說明的文章里看到示例
通過源碼中tools/model_generator中的.jar生成model.cfg,就能生成帶sAddr的模型配置文件,這樣代碼中就能使用數字id來定位到數據對象,而不用名字了,具體定位代碼如下:

先是讀取模型的代碼

#include "iec61850_server.h" #include "hal_thread.h" #include <signal.h> #include <stdlib.h> #include <stdio.h> #include "hal_filesystem.h" #include "iec61850_config_file_parser.h"/* open configuration file */ FileHandle configFile = FileSystem_openFile("model.cfg", false);if (configFile == NULL) {printf("Error opening config file!\n");return NULL; }/* parse the configuration file and create the data model */ IedModel* model = ConfigFileParser_createModelFromConfigFile(configFile);FileSystem_closeFile(configFile);if (model == NULL) {printf("Error parsing config file!\n");return NULL; }iedServer = IedServer_create(model);//接著是模型對象的獲取DataAttribute* alarmAttribList[1500]={0};//用于存儲告警對象 DataAttribute* dataAttribList[1500]={0};//用于存儲數據對象 int i; int index=0; /*搜索模型配置中的1500個數據點*/ for(i=0;i<1500;i++) {DataAttribute* attrib=NULL;index=40000+i;//數據點的起始地址是40000attrib = (DataAttribute*)IedModel_getModelNodeByShortAddress(model, index);if(attrib!=NULL){dataAttribList[i]=attrib;}index=20000+i;//告警點的起始地址是20000attrib = (DataAttribute*)IedModel_getModelNodeByShortAddress(model, index);if(attrib!=NULL){alarmAttribList[i]=attrib;} }//之后就可以啟動服務了IedServer_start(iedServer, tcpPort);if (!IedServer_isRunning(iedServer)) {printf("Starting server failed! Exit.\n");IedServer_destroy(iedServer);return NULL;}//服務啟動完成后,就需要定時填充實時數據,實時數據是由其它模塊采集的,這里只給出示例while (1) {uint64_t timestamp = Hal_getTimeInMs()-28800000;//減8小時時差t += 0.1f;for(i=0;i<1500;i++){IedServer_lockDataModel(iedServer);Timestamp iecTimestamp;Timestamp_clearFlags(&iecTimestamp);Timestamp_setTimeInMilliseconds(&iecTimestamp, timestamp);Timestamp_setLeapSecondKnown(&iecTimestamp, true);/* toggle clock-not-synchronized flag in timestamp */if (((int) t % 2) == 0)Timestamp_setClockNotSynchronized(&iecTimestamp, true);if(dataAttribList[i]!=NULL){DataAttribute*attrib=(DataAttribute*)ModelNode_getChild((ModelNode*)dataAttribList[i],"i");if(attrib){IedServer_updateInt32AttributeValue(iedServer, attrib, GetDevIValue(0,40000+i));//更新數據到61850服務}attrib=(DataAttribute*)ModelNode_getChild((ModelNode*)dataAttribList[i]->parent,"t");if(attrib){IedServer_updateTimestampAttributeValue(iedServer,attrib, &iecTimestamp);//更新采集的時間戳}}if(alarmAttribList[i]!=NULL){IedServer_updateBooleanAttributeValue(iedServer, alarmAttribList[i], GetDevIValue(0,20000+i));//更新告警狀態DataAttribute*attrib=(DataAttribute*)ModelNode_getChild((ModelNode*)alarmAttribList[i]->parent,"t");if(attrib){IedServer_updateTimestampAttributeValue(iedServer,attrib, &iecTimestamp);//更新告警時間}}IedServer_unlockDataModel(iedServer);}Thread_sleep(100);}

總結

以上是生活随笔為你收集整理的61850构建流程的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。