libiec61850在OpenSCADA系统中的使用

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
  1. 准备编译参数

以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

参考资料

http://libiec61850.com

本文原始链接:http://blog.zhourunsheng.com/2013/08/libiec61850%e5%9c%a8openscada%e7%b3%bb%e7%bb%9f%e4%b8%ad%e7%9a%84%e4%bd%bf%e7%94%a8/(迁移后固定链接原样保留)

历史评论 · 1 条

只读存档

以下评论来自原 WordPress 站点,已剔除邮箱、IP、浏览器标识与用户 ID,正文中的个人信息也已掩码。这是内容保全存档,不参与新评论的回复;想说点什么,请到下方「加入讨论」。

  1. libiec61850在OpenSCADA系统中的使用(二) #567
    […] 上一篇文章《libiec61850在OpenSCADA系统中的使用》介绍了libiec61850和OpenSCADA系统的混合编译,编译是没有问题,但是做成模块的话运行起来还是会出现问题,其中最主要的问题就是库的链接,导致运行时函数找不到,原因出在C和C++函数相互调用的关系,libiec61850是C库,OpenSCADA是C++。 […]

加入讨论

新评论 — 条

评论保存在本站自托管服务里,无需注册登录,填个昵称就能留言;不依赖任何第三方 Cookie 或账号。请尽量说点有用的 :)