现在的位置: 首页 > 程序设计> 正文
OpenSCADA系统添加自定义模块
2013年08月08日 程序设计 暂无评论 ⁄ 被围观 3,308+

前言

OpenSCADA作为一个开源的Scada系统,本文基于此系统来添加一个子模块,例子中准备添加一个支持61850协议的模块(名称为SP61850)。
OpenScada内置支持如下的子系统

  • "Data Bases"
  • "Communication Interfaces, Transports"
  • "Protocols of the communication interfaces"
  • "Data Sources and Data Acquisition"
  • "Archives(Histories) (of messages and values)"
  • "User Interfaces (GUI, TUI, WebGUI, speach, signal ...)"
  • "Additional modules"

我们所要添加的子模块隶属于如上的"Additional modules",即"special"子系统。

步骤

1.

$ cd openscada-0.8.0.5/src/moduls/special
$ cp -r =Tmpl= SP61850; cd SP61850
$ rm -f configure.in

2. 编辑"module.cpp"文件

2.1 module info 改为如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
//!!! Module's meta-information. Change for your module.
//*************************************************
//* Modul info! *
#define MOD_ID "SP61850"
#define MOD_NAME _("Special 61850 model")
#define MOD_TYPE SSPC_ID
#define VER_TYPE SSPC_VER
#define SUB_TYPE "LIB"
#define MOD_VER "0.0.1"
#define AUTHORS _("Carey Chow")
#define DESCRIPTION _("Special subsystem 61850 module.")
#define LICENSE "MyLicense"
//*************************************************
//!!! Module's meta-information. Change for your module.
//*************************************************
//* Modul info! *
#define MOD_ID "SP61850"
#define MOD_NAME _("Special 61850 model")
#define MOD_TYPE SSPC_ID
#define VER_TYPE SSPC_VER
#define SUB_TYPE "LIB"
#define MOD_VER "0.0.1"
#define AUTHORS _("Carey Chow")
#define DESCRIPTION _("Special subsystem 61850 module.")
#define LICENSE "MyLicense"
//*************************************************

2.2 全文搜索替换 Tmpl --> SP61850

2.3 注释掉模板中无效的地方

1
2
3
4
//!!! Place here your code for internal objects initialize.
//> Reg functions
//reg( new MathAcos() );
//reg( new MathAsin() );
//!!! Place here your code for internal objects initialize.
//> Reg functions
//reg( new MathAcos() );
//reg( new MathAsin() );

3. 编辑"module.h"文件
3.1 全文搜索替换 Tmpl --> SP61850

3.2 添加变量和函数定义

1
2
3
4
5
//Attributes
int m_fnc;
 
void list( vector<string> &ls ) { chldList(m_fnc,ls); }
AutoHD<TFunction> at( const string &id ) { return chldAt(m_fnc,id); }
//Attributes
int m_fnc;

void list( vector<string> &ls ) { chldList(m_fnc,ls); }
AutoHD<TFunction> at( const string &id ) { return chldAt(m_fnc,id); }

4. 编辑 "Makefile.am" 文件
全文搜索替换 Tmpl --> SP61850

5. 编辑 openscada-0.8.0.5/configure.in 全局配置文件,添加sp61850模块的编译项
在 SystemTests 模块
AX_MOD_EN(SystemTests,[disable build module Special.SystemTests],disable,[],
[
AC_MSG_RESULT(Build module: Special.SystemTests)
AC_CONFIG_FILES(src/moduls/special/SystemTests/Makefile)
SpecSub_mod="${SpecSub_mod}SystemTests "
])

后面添加 SP61850 模块
AX_MOD_EN(SP61850,[disable build module Special.SP61850],disable,[],
[
AC_MSG_RESULT(Build module: Special.SP61850)
AC_CONFIG_FILES(src/moduls/special/SP61850/Makefile)
SpecSub_mod="${SpecSub_mod}SP61850 "
])

6. 重新 configure,并编译我们新建立的模块

$ autoreconf -if
#### 有可能需要安装 autoreconf 工具 sudo apt-get install autoconf libtool
$ ./configure --enable-SP61850
$ make
$ sudo make install

7. 重新启动openscada系统,在special子系统下面就会找到我们的model(SP61850)

$ openscada

参考资料

  1. Manual for the creation of modules for OpenSCADA
  2. OpenSCADA系统的安装配置

给我留言

留言无头像?


×
腾讯微博