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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

libiec61850学习1

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

iec61850_client_example1的例子

  • client_example1.c的文件最上邊注釋,/*
    • client_example1.c
    • This example is intended to be used with server_example_basic_io or server_example_goose.
      */
      在libiec61850\examples\server_example_basic_io里找到simpleIO_direct_control.cid這個文件,修改ip地址127.0.0.1。使用iedscout打開simpleIO_direct_control.cid文件,運行仿真服務器功能。

    這時可以啟動調試iec61850_client_example1程序。

    int main(int argc, char** argv) {char* hostname;**int tcpPort = 102;** //服務器監聽端口,客戶端連接服務端ip+端口if (argc > 1)hostname = argv[1];else**hostname = "localhost";**if (argc > 2)tcpPort = atoi(argv[2]);IedClientError error;//創建客戶端連接對象**IedConnection con = IedConnection_create();**//連接服務器**IedConnection_connect(con, &error, hostname, tcpPort);**//error 是否有錯誤if (error == IED_ERROR_OK) {/* read an analog measurement value from server */ **//根據索引讀取模擬量值simpleIOGenericIO/GGIO1.AnIn1.mag.f**MmsValue* value = IedConnection_readObject(con, &error, "simpleIOGenericIO/GGIO1.AnIn1.mag.f", IEC61850_FC_MX);if (value != NULL) {if (MmsValue_getType(value) == MMS_FLOAT) {float fval = MmsValue_toFloat(value);printf("read float value: %f\n", fval);}else if (MmsValue_getType(value) == MMS_DATA_ACCESS_ERROR) {printf("Failed to read value (error code: %i)\n", MmsValue_getDataAccessError(value));}MmsValue_delete(value);}/* write a variable to the server */**//寫變量simpleIOGenericIO/GGIO1.NamPlt.vendor**value = MmsValue_newVisibleString("libiec61850.com");IedConnection_writeObject(con, &error, "simpleIOGenericIO/GGIO1.NamPlt.vendor", IEC61850_FC_DC, value);if (error != IED_ERROR_OK)printf("failed to write simpleIOGenericIO/GGIO1.NamPlt.vendor! (error code: %i)\n", error);MmsValue_delete(value);/* read data set */ClientDataSet clientDataSet = IedConnection_readDataSetValues(con, &error, "simpleIOGenericIO/LLN0.Events", NULL);**//讀數據集里的數據****value = ClientDataSet_getValues(clientDataSet);****//數據集里元素個數****int size = ClientDataSet_getDataSetSize(clientDataSet);**//根據索引得到元素的值//4個元素 我添加的代碼,根據索引獲得值**int size = ClientDataSet_getDataSetSize(clientDataSet);MmsValue *tmp = MmsValue_getElement(value, 0);MmsValue* tmp1 = MmsValue_getElement(value, 1);MmsValue* tmp2 = MmsValue_getElement(value, 2);MmsValue* tmp3 = MmsValue_getElement(value, 3);//bool類型if (MmsValue_getType(tmp) == MMS_BOOLEAN){bool ret = MmsValue_getBoolean(tmp);}**if (clientDataSet == NULL) {printf("failed to read dataset\n");goto close_connection;}/* Read RCB values */ClientReportControlBlock rcb =IedConnection_getRCBValues(con, &error, "simpleIOGenericIO/LLN0.RP.EventsRCB01", NULL);if (rcb) {bool rptEna = ClientReportControlBlock_getRptEna(rcb);printf("RptEna = %i\n", rptEna);/* Install handler for reports */IedConnection_installReportHandler(con, "simpleIOGenericIO/LLN0.RP.EventsRCB01",ClientReportControlBlock_getRptId(rcb), reportCallbackFunction, NULL);/* Set trigger options and enable report */ClientReportControlBlock_setTrgOps(rcb, TRG_OPT_DATA_UPDATE | TRG_OPT_INTEGRITY | TRG_OPT_GI);ClientReportControlBlock_setRptEna(rcb, true);ClientReportControlBlock_setIntgPd(rcb, 5000);IedConnection_setRCBValues(con, &error, rcb, RCB_ELEMENT_RPT_ENA | RCB_ELEMENT_TRG_OPS | RCB_ELEMENT_INTG_PD, true);if (error != IED_ERROR_OK)printf("report activation failed (code: %i)\n", error);Thread_sleep(1000);/* trigger GI report */ClientReportControlBlock_setGI(rcb, true);IedConnection_setRCBValues(con, &error, rcb, RCB_ELEMENT_GI, true);if (error != IED_ERROR_OK)printf("Error triggering a GI report (code: %i)\n", error);Thread_sleep(60000);/* disable reporting */ClientReportControlBlock_setRptEna(rcb, false);IedConnection_setRCBValues(con, &error, rcb, RCB_ELEMENT_RPT_ENA, true);if (error != IED_ERROR_OK)printf("disable reporting failed (code: %i)\n", error);ClientDataSet_destroy(clientDataSet);ClientReportControlBlock_destroy(rcb);}close_connection:IedConnection_close(con);}else {printf("Failed to connect to %s:%i\n", hostname, tcpPort);}IedConnection_destroy(con); }

    總結

    以上是生活随笔為你收集整理的libiec61850学习1的全部內容,希望文章能夠幫你解決所遇到的問題。

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