package com.libiec61850.tools;
/*
* StaticModelGenerator.java
*
* Copyright 2013-2016 Michael Zillgith
*
* This file is part of libIEC61850.
*
* libIEC61850 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* libIEC61850 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with libIEC61850. If not, see <http://www.gnu.org/licenses/>.
*
* See COPYING file for the complete license text.
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.LinkedList;
import java.util.List;
import com.libiec61850.scl.SclParser;
import com.libiec61850.scl.SclParserException;
import com.libiec61850.scl.communication.Communication;
import com.libiec61850.scl.communication.ConnectedAP;
import com.libiec61850.scl.communication.GSE;
import com.libiec61850.scl.communication.PhyComAddress;
import com.libiec61850.scl.communication.SubNetwork;
import com.libiec61850.scl.model.AccessPoint;
import com.libiec61850.scl.model.DataAttribute;
import com.libiec61850.scl.model.DataModelValue;
import com.libiec61850.scl.model.DataObject;
import com.libiec61850.scl.model.DataSet;
import com.libiec61850.scl.model.FunctionalConstraint;
import com.libiec61850.scl.model.FunctionalConstraintData;
import com.libiec61850.scl.model.GSEControl;
import com.libiec61850.scl.model.IED;
import com.libiec61850.scl.model.Log;
import com.libiec61850.scl.model.LogControl;
import com.libiec61850.scl.model.LogicalDevice;
import com.libiec61850.scl.model.LogicalNode;
import com.libiec61850.scl.model.ReportControlBlock;
import com.libiec61850.scl.model.SampledValueControl;
import com.libiec61850.scl.model.Server;
import com.libiec61850.scl.model.SettingControl;
import com.libiec61850.scl.model.TriggerOptions;
public class StaticModelGenerator {
private List<String> variablesList;
private PrintStream cOut;
private PrintStream hOut;
private StringBuffer initializerBuffer;
private StringBuffer reportControlBlocks;
private List<String> rcbVariableNames;
private int currentRcbVariableNumber = 0;
private StringBuffer logControlBlocks;
private List<String> lcbVariableNames;
private int currentLcbVariableNumber = 0;
private StringBuffer logs;
private List<String> logVariableNames;
private int currentLogVariableNumber = 0;
private StringBuffer gseControlBlocks;
private List<String> gseVariableNames;
private int currentGseVariableNumber = 0;
private StringBuffer smvControlBlocks;
private List<String> smvVariableNames;
private int currentSvCBVariableNumber = 0;
private StringBuffer settingGroupControlBlocks;
private List<String> sgcbVariableNames;
private int currentSGCBVariableNumber = 0;
private List<String> dataSetNames;
private Communication communication;
private ConnectedAP connectedAP;
private IED ied;
private AccessPoint accessPoint;
private String outputFileName;
private String hDefineName;
private String modelPrefix;
private boolean initializeOnce;
public StaticModelGenerator(InputStream stream, String icdFile, PrintStream cOut, PrintStream hOut,
String outputFileName, String iedName, String accessPointName, String modelPrefix,
boolean initializeOnce) throws SclParserException
{
this.cOut = cOut;
this.hOut = hOut;
this.initializerBuffer = new StringBuffer();
this.reportControlBlocks = new StringBuffer();
this.rcbVariableNames = new LinkedList<String>();
this.gseControlBlocks = new StringBuffer();
this.gseVariableNames = new LinkedList<String>();
this.smvControlBlocks = new StringBuffer();
this.smvVariableNames = new LinkedList<String>();
this.settingGroupControlBlocks = new StringBuffer();
this.sgcbVariableNames = new LinkedList<String>();
this.logControlBlocks = new StringBuffer();
this.lcbVariableNames = new LinkedList<String>();
this.logs = new StringBuffer();
this.logVariableNames = new LinkedList<String>();
SclParser sclParser = new SclParser(stream);
this.outputFileName = outputFileName;
this.hDefineName = outputFileName.toUpperCase().replace( '.', '_' ).replace( '-', '_' ) + "_H_";
this.modelPrefix = modelPrefix;
this.initializeOnce = initializeOnce;
if( hDefineName.lastIndexOf( '/' ) >= 0 )
{
hDefineName = hDefineName.substring( hDefineName.lastIndexOf( '/' ) + 1 );
}
ied = null;
if (iedName == null)
ied = sclParser.getFirstIed();
else
ied = sclParser.getIedByName(iedName);
if (ied == null)
System.out.println("IED model not found in SCL file! Exit.");
accessPoint = null;
if (accessPointName == null)
accessPoint = ied.getFirstAccessPoint();
else
accessPoint = ied.getAccessPointByName(accessPointName);
connectedAP = sclParser.getConnectedAP(ied, accessPoint.getName());
printCFileHeader(icdFile);
printHeaderFileHeader(icdFile);
variablesList = new LinkedList<String>();
Server server = accessPoint.getServer();
printForwardDeclarations(server);
printDeviceModelDefinitions();
printInitializerFunction();
printVariablePointerDefines();
printHeaderFileFooter();
}
private void printInitializerFunction() {
cOut.println("\nstatic void\ninitializeValues()");
cOut.println("{");
cOut.print(this.initializerBuffer);
cOut.println("}");
}
public static void main(String[] args) throws FileNotFoundException {
if (args.length < 1) {
System.out.println("Usage: genmodel <ICD file> [-ied <ied-name>] [-ap <access-point-name>] [-out <output-name>] [-modelprefix <model-prefix>]");
System.exit(1);
}
String icdFile = args[0];
String outputFileName = "static_model";
String accessPointName = null;
String iedName = null;
String modelPrefix = "iedModel";
boolean initializeOnce = false;
if (args.length > 1) {
for (int i = 1; i < args.length; i++) {
if (args[i].equals("-ap")) {
accessPointName = args[i+1];
System.out.println("Select access point " + accessPointName);
i++;
}
else if (args[i].equals("-ied")) {
iedName = args[i+1];
System.out.println("Select IED " + iedName);
i++;
}
else if (args[i].equals("-out")) {
outputFileName = args[i+1];
System.out.println("Select Output File " + outputFileName);
i++;
}
else if (args[i].equals("-modelprefix")) {
modelPrefix = args[i+1];
System.out.println("Select Model Prefix " + modelPrefix);
i++;
}
else if (args[i].equals("-initializeonce")) {
initializeOnce = true;
System.out.println("Select Initialize Once");
}
else {
System.out.println("Unknown option: \"" + args[i] + "\"");
}
}
}
PrintStream cOutStream = new PrintStream(new FileOutputStream(new File(outputFileName
没有合适的资源?快使用搜索试试~ 我知道了~
最新开源IEC61850协议栈源码(2017-08-25发布),含帮助文档(API Reference Manual)
共1218个文件
html:397个
c:240个
h:181个
3星 · 超过75%的资源 需积分: 50 186 下载量 164 浏览量
2017-09-19
23:09:50
上传
评论 7
收藏 904KB 7Z 举报
温馨提示
This new release of the IEC 61850 protocol library contains a lot of small improvements and bug fixes. New is the support of the SetDataSet service on client and server side. With this release also the limit of 64k of the MMS PDU size has been removed to support very large data sets.
资源推荐
资源详情
资源评论
收起资源包目录
最新开源IEC61850协议栈源码(2017-08-25发布),含帮助文档(API Reference Manual) (1218个子文件)
iec61850_goose.asn 2KB
SYSTEM.BIN 0B
SYSTEM.BIN 0B
static_model.c 183KB
mms_mapping.c 99KB
static_model.c 95KB
static_model.c 90KB
reporting.c 82KB
static_model.c 81KB
static_model.c 81KB
mms_client_connection.c 72KB
ied_connection.c 69KB
mms_value.c 51KB
static_model.c 46KB
static_model.c 46KB
static_model.c 46KB
control.c 46KB
static_model.c 44KB
static_model.c 43KB
cdc.c 43KB
ied_server.c 41KB
static_model.c 40KB
OCTET_STRING.c 39KB
mms_file_service.c 35KB
static_model.c 35KB
constr_SEQUENCE.c 31KB
constr_CHOICE.c 28KB
mms_named_variable_list_service.c 27KB
logging.c 27KB
goose_receiver.c 25KB
static_model.c 24KB
mms_read_service.c 24KB
client_control.c 23KB
mms_write_service.c 23KB
constr_SET_OF.c 23KB
mms_client_files.c 23KB
mms_server_connection.c 22KB
mms_client_write.c 21KB
mms_client_read.c 21KB
iso_presentation.c 21KB
iso_connection.c 21KB
static_model.c 20KB
dynamic_model.c 20KB
INTEGER.c 20KB
iso_server.c 20KB
client_report.c 19KB
client_report_control.c 19KB
mms_get_namelist_service.c 19KB
acse.c 18KB
log_storage_sqlite.c 18KB
iso_client_connection.c 18KB
config_file_parser.c 18KB
mms_journal_service.c 17KB
mms_goose.c 17KB
cotp.c 17KB
mms_client_named_variable_list.c 17KB
mms_sv.c 16KB
mms_client_journals.c 15KB
iso_session.c 15KB
TypeSpecification.c 15KB
GeneralizedTime.c 15KB
AlternateAccessSelection.c 15KB
model.c 15KB
mms_common_msg.c 14KB
client_goose_control.c 14KB
sv_subscriber.c 14KB
sv_publisher.c 13KB
static_model.c 13KB
mms_access_result.c 12KB
mms_get_var_access_service.c 12KB
RejectPDU.c 12KB
beagle_demo.c 11KB
ethernet_bsd.c 11KB
mms_server.c 11KB
mms_information_report.c 11KB
mms_utility.c 11KB
goose_publisher.c 10KB
socket_linux.c 9KB
ber_encoder.c 9KB
socket_win32.c 9KB
iec61850_common.c 9KB
client_sv_control.c 9KB
ethernet_win32.c 9KB
xer_decoder.c 9KB
socket_bsd.c 9KB
ServiceError.c 8KB
mms_server_common.c 8KB
mms_association_service.c 8KB
mms_client_initiate.c 8KB
ber_decoder.c 7KB
mms_client_get_namelist.c 7KB
server_example_logging.c 7KB
per_support.c 7KB
AccessResult.c 7KB
mms_type_spec.c 7KB
string_utilities.c 7KB
VariableSpecification.c 7KB
asn_codecs_prim.c 7KB
GetNamedVariableListAttributesResponse.c 7KB
mms_client_get_var_access.c 7KB
共 1218 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
资源评论
- 张大侠GalenZhang2019-10-21总体还说,有点用处,最好是有更新的网址。
- 宋康2017-12-14怎么没有下载,还让我评论?
- 多米诺兄弟2018-08-10网上其实有,还更新
a3573
- 粉丝: 2
- 资源: 21
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功