现在的位置: 首页 > 程序设计> 正文
libiec61850在OpenSCADA系统中的使用
2013年08月09日 程序设计 评论数 1 ⁄ 被围观 4,607+

libiec61850 是一套开源的C库,它实现了大多数的61850的协议转换,原理同样是基于MMS协议的映射。本文要将libiec61850用在OpenSCADA系统中,使OpenSCADA系统可以提供智能变电站61850协议的接入。

简介

libiec61850 is an open-source (GPLv3) implementation of an IEC 61850 client and server library. It is implemented in C to provide maximum portability. It can be used to implement IEC 61850 compliant client and server applications on embedded systems and PCs running Linux and Windows. Included is a set of simple example applications that can be used as a starting point to implement your own IEC 61850 compliant devices or to communicate with IEC 61850 devices.

The library implements parts of the IEC 61850 specification on top of the MMS mapping. It provides the MMS protocol stack on top of TCP/IP.

使用方法

1. 将libiec61850编译成lib的形式

$ cd libiec61850-0.4.1
$ make clean
$ make lib
$ ls build ### libiec61850.a

2. 准备编译参数
以examples/server_example5 为例进行说明
为了与原工程项目的Makefile项目文件相分离,需要抽取出原来的编译参数。

gcc -g -o server_example5 server_example5.c static_model.c -I../../inc -I../../src/common -I../../src/mms/iso_presentation -I../../src/mms/iso_session -I../../src/mms/iso_cotp -I../../src/mms/iso_acse -I../../src/mms/iso_mms/common -I../../src/mms/iso_mms/client -I../../src/mms/iso_mms/server -I../../src/mms/iso_client -I../../src/mms/iso_server -I../../src/mms/asn1 -I../../src/iedcommon -I../../src/iedserver/mms_mapping -I../../src/iedserver/model -I../../src/iedserver -I../../src/iedclient -I../../src/hal -I../../src/hal/thread -I../../src/hal/socket -I../../src/goose ../../build/libiec61850.a -lpthread
  • server_example5.c static_model.c 项目的源文件
  • 其中-I指向头文件的目录
  • ../../build/libiec61850.a指向编译出来的lib
  • -lpthread线程库的支持

3.准备头文件和库文件
拷贝源码src目录, inc目录和build/libiec61850.a文件到指定的文件夹,然后修改编译参数-I指向的相对路径,即可实现libiec61850库的调用

例如,目录结构如下:

lib61850/
  build
    libiec61850.a
  inc
    ...
  src
    ...

Makefile.am 配置如下:

############ for lib61850 include header file and lib file ##################
CFLAGS += -Ilib61850/inc -Ilib61850/src/common -Ilib61850/src/mms/iso_presentation -Ilib61850/src/mms/iso_session -Ilib61850/src/mms/iso_cotp -Ilib61850/src/mms/iso_acse -Ilib61850/src/mms/iso_mms/common -Ilib61850/src/mms/iso_mms/client -Ilib61850/src/mms/iso_mms/server -Ilib61850/src/mms/iso_client -Ilib61850/src/mms/iso_server -Ilib61850/src/mms/asn1 -Ilib61850/src/iedcommon -Ilib61850/src/iedserver/mms_mapping -Ilib61850/src/iedserver/model -Ilib61850/src/iedserver -Ilib61850/src/iedclient -Ilib61850/src/hal -Ilib61850/src/hal/thread -Ilib61850/src/hal/socket -Ilib61850/src/goose lib61850/build/libiec61850.a -lpthread
#############################################################################

4.实现IEC61850服务器
实现自己的61850服务器,详情参照server_example5.c

参考资料

1. http://libiec61850.com

目前有 1 条留言 其中:访客:0 条, 博主:0 条 引用: 1

    查看来自外部的引用: 1

    给我留言

    留言无头像?


    ×
    腾讯微博