lnk commit front code

This commit is contained in:
lnk
2025-01-16 16:17:01 +08:00
commit 1776a2bf0d
587 changed files with 257079 additions and 0 deletions

35
mms/CVS/Entries Normal file
View File

@@ -0,0 +1,35 @@
/Makefile.am/1.1/Sun Jun 12 03:13:41 2016//
/align.cfg/1.1/Sun Feb 15 07:04:59 2015//
/clntobj.c/1.1/Sat Nov 24 06:54:50 2018//
/clntobj.h/1.1/Sat Nov 24 06:54:50 2018//
/clntobj.odf/1.1/Sun Feb 15 07:04:59 2015//
/event.c/1.1/Sat Nov 24 06:54:50 2018//
/event2.c/1.1/Sun Feb 15 07:05:00 2015//
/gentypes.odf/1.1/Sun Feb 15 07:05:00 2015//
/logcfg.xml/1.1/Sun Feb 15 07:05:00 2015//
/logcfgx.c/1.1/Sat Nov 24 06:54:50 2018//
/mmsclient.h/1.1/Sat Nov 24 06:54:50 2018//
/mmslvar.c/1.1/Sat Nov 24 06:54:50 2018//
/mmsop_en.c/1.1/Sat Nov 24 06:54:50 2018//
/mmsop_en.h/1.1/Sat Nov 24 06:54:51 2018//
/myftp.cpp/1.1/Mon Oct 22 06:45:14 2018//
/oracle_process.cpp/1.1/Sat Nov 24 06:54:51 2018//
/osicfg.xml/1.1/Sun Feb 15 07:05:02 2015//
/reject.c/1.1/Sat Nov 24 06:54:51 2018//
/rpt.odf/1.1/Sun Feb 15 07:05:03 2015//
/version.txt/1.1/Tue May 29 06:09:42 2018//
/mvl_acse.c/1.2/Wed Dec 19 08:59:51 2018//
/mvlop_en.c/1.2/Thu Dec 20 06:00:55 2018//
/rdb_ext_utils.c/1.11/Sun Dec 23 12:39:52 2018//
/parse_xml.c/1.5/Sat Dec 29 03:18:14 2018//
/interface.h/1.4/Tue Jan 8 08:15:34 2019//
/mmscli_log.c/1.7/Thu Jan 10 05:24:54 2019//
/db_interface.h/1.12/Sat Jan 12 08:44:26 2019//
/rdb_client.h/1.18/Sat Jan 12 04:30:25 2019//
/main.c/1.9/Wed Oct 28 05:21:18 2020//
/rdb_client.c/1.11/Wed Oct 28 05:21:18 2020//
/mms_process.c/1.28/Mon Nov 28 07:13:13 2022//
/mmscli_rpt.c/1.12/Mon Nov 28 07:13:13 2022//
/ver_conf.h/1.18/Mon Nov 28 03:20:19 2022//
/mmsclient.c/1.12/Mon Dec 5 02:23:57 2022//
D

34
mms/CVS/Entries.Extra Normal file
View File

@@ -0,0 +1,34 @@
/Makefile.am////*////
/align.cfg////*////
/clntobj.c////*////
/clntobj.h////*////
/clntobj.odf////*////
/event.c////*////
/event2.c////*////
/gentypes.odf////*////
/logcfg.xml////*////
/logcfgx.c////*////
/mmsclient.h////*////
/mmslvar.c////*////
/mmsop_en.c////*////
/mmsop_en.h////*////
/myftp.cpp////*////
/oracle_process.cpp////*////
/osicfg.xml////*////
/reject.c////*////
/rpt.odf////*////
/version.txt////*////
/mvl_acse.c////*////
/mvlop_en.c////*////
/rdb_ext_utils.c////*////
/parse_xml.c////*////
/interface.h////*////
/mmscli_log.c////*////
/db_interface.h////*////
/rdb_client.h////*////
/main.c////*////
/rdb_client.c////*////
/mms_process.c////*////
/mmscli_rpt.c////*////
/ver_conf.h////*////
/mmsclient.c////*////

34
mms/CVS/Entries.Extra.Old Normal file
View File

@@ -0,0 +1,34 @@
/Makefile.am////*////
/align.cfg////*////
/clntobj.c////*////
/clntobj.h////*////
/clntobj.odf////*////
/event.c////*////
/event2.c////*////
/gentypes.odf////*////
/logcfg.xml////*////
/logcfgx.c////*////
/mmsclient.h////*////
/mmslvar.c////*////
/mmsop_en.c////*////
/mmsop_en.h////*////
/myftp.cpp////*////
/oracle_process.cpp////*////
/osicfg.xml////*////
/reject.c////*////
/rpt.odf////*////
/version.txt////*////
/mvl_acse.c////*////
/mvlop_en.c////*////
/rdb_ext_utils.c////*////
/parse_xml.c////*////
/interface.h////*////
/mmscli_log.c////*////
/db_interface.h////*////
/rdb_client.h////*////
/main.c////*////
/rdb_client.c////*////
/mms_process.c////*////
/mmscli_rpt.c////*////
/mmsclient.c////*////
/ver_conf.h////*////

35
mms/CVS/Entries.Old Normal file
View File

@@ -0,0 +1,35 @@
/Makefile.am/1.1/Sun Jun 12 03:13:41 2016//
/align.cfg/1.1/Sun Feb 15 07:04:59 2015//
/clntobj.c/1.1/Sat Nov 24 06:54:50 2018//
/clntobj.h/1.1/Sat Nov 24 06:54:50 2018//
/clntobj.odf/1.1/Sun Feb 15 07:04:59 2015//
/event.c/1.1/Sat Nov 24 06:54:50 2018//
/event2.c/1.1/Sun Feb 15 07:05:00 2015//
/gentypes.odf/1.1/Sun Feb 15 07:05:00 2015//
/logcfg.xml/1.1/Sun Feb 15 07:05:00 2015//
/logcfgx.c/1.1/Sat Nov 24 06:54:50 2018//
/mmsclient.h/1.1/Sat Nov 24 06:54:50 2018//
/mmslvar.c/1.1/Sat Nov 24 06:54:50 2018//
/mmsop_en.c/1.1/Sat Nov 24 06:54:50 2018//
/mmsop_en.h/1.1/Sat Nov 24 06:54:51 2018//
/myftp.cpp/1.1/Mon Oct 22 06:45:14 2018//
/oracle_process.cpp/1.1/Sat Nov 24 06:54:51 2018//
/osicfg.xml/1.1/Sun Feb 15 07:05:02 2015//
/reject.c/1.1/Sat Nov 24 06:54:51 2018//
/rpt.odf/1.1/Sun Feb 15 07:05:03 2015//
/version.txt/1.1/Tue May 29 06:09:42 2018//
/mvl_acse.c/1.2/Wed Dec 19 08:59:51 2018//
/mvlop_en.c/1.2/Thu Dec 20 06:00:55 2018//
/rdb_ext_utils.c/1.11/Sun Dec 23 12:39:52 2018//
/parse_xml.c/1.5/Sat Dec 29 03:18:14 2018//
/interface.h/1.4/Tue Jan 8 08:15:34 2019//
/mmscli_log.c/1.7/Thu Jan 10 05:24:54 2019//
/db_interface.h/1.12/Sat Jan 12 08:44:26 2019//
/rdb_client.h/1.18/Sat Jan 12 04:30:25 2019//
/main.c/1.9/Wed Oct 28 05:21:18 2020//
/rdb_client.c/1.11/Wed Oct 28 05:21:18 2020//
/mms_process.c/1.28/Mon Nov 28 07:13:13 2022//
/mmscli_rpt.c/1.12/Mon Nov 28 07:13:13 2022//
/mmsclient.c/1.12/Mon Nov 28 07:13:13 2022//
/ver_conf.h/1.18/Mon Nov 28 03:20:19 2022//
D

1
mms/CVS/Repository Normal file
View File

@@ -0,0 +1 @@
jspqfe/src/pt61850netd_pqfe/source/mms

1
mms/CVS/Root Normal file
View File

@@ -0,0 +1 @@
:ext:lizhongming@10.0.0.2:/JoyProject

0
mms/CVS/Template Normal file
View File

56
mms/Makefile.am Normal file
View File

@@ -0,0 +1,56 @@
libdir=/sas/lib
includedir=../../include
installdir=/sas/bin
INCLUDES =-I$(includedir) -I$(includedir)/apr-linux -I$(includedir)/mmslite -I$(includedir)/ora_inst_inc
D_X86_OR_PPC=
D_MMS_DEFS= -DMMS_LITE -DMOSI -DLEAN_T -DTP0_ENABLED
AM_CFLAGS =-DCLIENT -pthread -O2 -ggdb -D_DEBUG -Wall -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE $(D_X86_OR_PPC) $(D_MMS_DEFS)
bin_PROGRAMS = pt61850netd
pt61850netd_SOURCES = \
main.c \
clntobj.c \
event2.c \
logcfgx.c \
mms_process.c \
mmscli_rpt.c \
mmsclient.c \
mmslvar.c \
mmsop_en.c \
mvl_acse.c \
mvlop_en.c \
parse_xml.c \
rdb_client.c \
rdb_ext_utils.c \
reject.c \
utf8_to_gb.c \
gb_to_utf8.c \
mmscli_log.c \
save2db.cpp \
myftp.cpp \
ftp.cpp \
csv_parser.cpp
DFLAG =_n
LIBDIR =$(libdir)/mmslite
LIBS = \
$(LIBDIR)/ositcps$(DFLAG).a \
$(LIBDIR)/mvl$(DFLAG).a \
$(LIBDIR)/mmsle$(DFLAG).a \
$(LIBDIR)/mmsl$(DFLAG).a \
$(LIBDIR)/asn1l$(DFLAG).a \
$(LIBDIR)/mem$(DFLAG).a \
$(LIBDIR)/slog$(DFLAG).a \
$(LIBDIR)/util$(DFLAG).a \
$(LIBDIR)/ssec0$(DFLAG).a
pt61850netd_LDADD= $(libdir)/libjinf.a
pt61850netd_LDFLAGS =-L$(libdir) -lapr-1 -lrt -lcrypt -lpthread -ldl -laprutil-1 -lexpat -ljclite -ljcc -ljcsct -ljcutil -ljcfdb -ljcidb -locci -lclntsh -lnnz12 -lociei $(LIBS)

34
mms/align.cfg Normal file
View File

@@ -0,0 +1,34 @@
/* This data table, referred to as a 'data alignment table', is used to */
/* tell MMS-LITE how data is stored in memory by the 'C' compiler. */
/* The idea is that addresses of the data types described in the table */
/* cannot have bits set that are set in the table values. For instance, */
/* if the value is 0x0000, the corresponding data type can be on any */
/* memory boundary. If it is 0x0001, it must be on even work boundary. */
#ifdef _WIN32
ST_INT m_def_data_algn_tbl[NUM_ALGN_TYPES] =
{
0x0000, /* ARRSTRT_ALGN 00 */
0x0000, /* ARREND_ALGN 01 */
0x0000, /* STRSTRT_ALGN 02 */
0x0000, /* STREND_ALGN 03 */
0x0000, /* INT8_ALGN 04 */
0x0001, /* INT16_ALGN 05 */
0x0003, /* INT32_ALGN 06 */
0x0007, /* INT64_ALGN 07 */
0x0003, /* FLOAT_ALGN 08 */
0x0007, /* DOUBLE_ALGN 09 */
0x0000, /* OCT_ALGN 10 */
0x0000, /* BOOL_ALGN 11 */
0x0000, /* BCD1_ALGN 12 */
0x0001, /* BCD2_ALGN 13 */
0x0003, /* BCD4_ALGN 14 */
0x0000, /* BIT_ALGN 15 */
0x0000 /* VIS_ALGN 16 */
};
#define M_STRSTART_MODE M_STRSTART_MODE_LARGEST
#define M_STREND_MODE M_STREND_MODE_LARGEST
#endif

3897
mms/clntobj.c Normal file

File diff suppressed because it is too large Load Diff

399
mms/clntobj.h Normal file
View File

@@ -0,0 +1,399 @@
/**
* @file: $RCSfile: clntobj.h,v $
* @brief: $IEC 61850 Protocol
*
* @version: $Revision: 1.1 $
* @date: $Date: 2018/11/24 06:54:50 $
* @author: $Author: lizhongming $
* @state: $State: Exp $
*
* @latest: $Id: clntobj.h,v 1.1 2018/11/24 06:54:50 lizhongming Exp $
*
*/
#ifndef FOUNDRY_OUTPUT_HEADER_INCLUDED
#define FOUNDRY_OUTPUT_HEADER_INCLUDED
#include "mvl_uca.h"
#ifdef __cplusplus
extern "C" {
#endif
/************************************************************************/
/* MVL Type Control Information */
extern MVL_TYPE_CTRL *mvl_type_ctrl;
extern ST_INT mvl_num_types;
/************************************************************************/
/* MVL Type ID's */
#define RTYP_BOOL_TYPEID 0
#define RTYP_BTIME6_TYPEID 1
#define RTYP_BSTR6_TYPEID 2
#define RTYP_BSTR8_TYPEID 3
#define RTYP_BSTR9_TYPEID 4
#define RTYP_BVSTR6_TYPEID 5
#define RTYP_BVSTR8_TYPEID 6
#define RTYP_BVSTR10_TYPEID 7
#define RTYP_INT8U_TYPEID 8
#define RTYP_INT16U_TYPEID 9
#define RTYP_OSTR8_TYPEID 10
#define RTYP_VSTR32_TYPEID 11
#define RTYP_VSTR65_TYPEID 12
#define RTYP_INT32U_TYPEID 13
#define I16_TYPEID 14
#define U32_TYPEID 15
#define UTF8VSTRING13_TYPEID 16
#define phv_type_TYPEID 17
#define phsx_type_TYPEID 18
/************************************************************************/
/************************************************************************/
/* Common Strings Index Defines */
#ifndef USE_RT_TYPE_2
#define FO_PHSA_STRING_INDEX 1
#define FO_INSTCVAL_STRING_INDEX 2
#define FO_MAG_STRING_INDEX 3
#define FO_I_STRING_INDEX 4
#define FO_F_STRING_INDEX 5
#define FO_ANG_STRING_INDEX 6
#define FO_CVAL_STRING_INDEX 7
#define FO_RANGE_STRING_INDEX 8
#define FO_Q_STRING_INDEX 9
#define FO_T_STRING_INDEX 10
#define FO_PHSB_STRING_INDEX 11
#define FO_PHSC_STRING_INDEX 12
#define FO_NEUT_STRING_INDEX 13
#define FO_NET_STRING_INDEX 14
#define FO_RES_STRING_INDEX 15
#endif
/************************************************************************/
/* TYPEDEFS for MMS TYPES */
/************************************************************************/
/* Use ":CF", "-notypedefs" in the ODF file to not include this line */
#define USE_MMS_TYPEDEFS
#if defined (USE_MMS_TYPEDEFS)
typedef ST_BOOLEAN RTYP_BOOL_TDEF;
typedef MMS_BTIME6 RTYP_BTIME6_TDEF;
typedef ST_UCHAR RTYP_BSTR6_TDEF[1]; /* Bitstring */
typedef ST_UCHAR RTYP_BSTR8_TDEF[1]; /* Bitstring */
typedef ST_UCHAR RTYP_BSTR9_TDEF[2]; /* Bitstring */
typedef struct /* BVstring */
{
ST_INT16 len_1;
ST_UCHAR data_1[1];
} RTYP_BVSTR6_TDEF; /* Bitstring */
typedef struct /* BVstring */
{
ST_INT16 len_1;
ST_UCHAR data_1[1];
} RTYP_BVSTR8_TDEF; /* Bitstring */
typedef struct /* BVstring */
{
ST_INT16 len_1;
ST_UCHAR data_1[2];
} RTYP_BVSTR10_TDEF; /* Bitstring */
typedef ST_UINT8 RTYP_INT8U_TDEF;
typedef ST_UINT16 RTYP_INT16U_TDEF;
typedef ST_UCHAR RTYP_OSTR8_TDEF[8]; /* Octetstring */
typedef ST_CHAR RTYP_VSTR32_TDEF[33]; /* Visible String */
typedef ST_CHAR RTYP_VSTR65_TDEF[66]; /* Visible String */
typedef ST_UINT32 RTYP_INT32U_TDEF;
typedef ST_INT16 I16_TDEF;
typedef ST_UINT32 U32_TDEF;
typedef ST_CHAR UTF8VSTRING13_TDEF[28];
typedef struct
{
struct
{
struct
{
struct
{
ST_INT32 i;
ST_FLOAT f;
} mag;
struct
{
ST_INT32 i;
ST_FLOAT f;
} ang;
} instCVal;
struct
{
struct
{
ST_INT32 i;
ST_FLOAT f;
} mag;
struct
{
ST_INT32 i;
ST_FLOAT f;
} ang;
} cVal;
ST_INT8 range;
struct /* BVstring */
{
ST_INT16 len_1;
ST_UCHAR data_1[2];
} q;
MMS_UTC_TIME t;
} phsA;
struct
{
struct
{
struct
{
ST_INT32 i;
ST_FLOAT f;
} mag;
struct
{
ST_INT32 i;
ST_FLOAT f;
} ang;
} instCVal;
struct
{
struct
{
ST_INT32 i;
ST_FLOAT f;
} mag;
struct
{
ST_INT32 i;
ST_FLOAT f;
} ang;
} cVal;
ST_INT8 range;
struct /* BVstring */
{
ST_INT16 len_1;
ST_UCHAR data_1[2];
} q;
MMS_UTC_TIME t;
} phsB;
struct
{
struct
{
struct
{
ST_INT32 i;
ST_FLOAT f;
} mag;
struct
{
ST_INT32 i;
ST_FLOAT f;
} ang;
} instCVal;
struct
{
struct
{
ST_INT32 i;
ST_FLOAT f;
} mag;
struct
{
ST_INT32 i;
ST_FLOAT f;
} ang;
} cVal;
ST_INT8 range;
struct /* BVstring */
{
ST_INT16 len_1;
ST_UCHAR data_1[2];
} q;
MMS_UTC_TIME t;
} phsC;
struct
{
struct
{
struct
{
ST_INT32 i;
ST_FLOAT f;
} mag;
struct
{
ST_INT32 i;
ST_FLOAT f;
} ang;
} instCVal;
struct
{
struct
{
ST_INT32 i;
ST_FLOAT f;
} mag;
struct
{
ST_INT32 i;
ST_FLOAT f;
} ang;
} cVal;
ST_INT8 range;
struct /* BVstring */
{
ST_INT16 len_1;
ST_UCHAR data_1[2];
} q;
MMS_UTC_TIME t;
} neut;
struct
{
struct
{
struct
{
ST_INT32 i;
ST_FLOAT f;
} mag;
struct
{
ST_INT32 i;
ST_FLOAT f;
} ang;
} instCVal;
struct
{
struct
{
ST_INT32 i;
ST_FLOAT f;
} mag;
struct
{
ST_INT32 i;
ST_FLOAT f;
} ang;
} cVal;
ST_INT8 range;
struct /* BVstring */
{
ST_INT16 len_1;
ST_UCHAR data_1[2];
} q;
MMS_UTC_TIME t;
} net;
struct
{
struct
{
struct
{
ST_INT32 i;
ST_FLOAT f;
} mag;
struct
{
ST_INT32 i;
ST_FLOAT f;
} ang;
} instCVal;
struct
{
struct
{
ST_INT32 i;
ST_FLOAT f;
} mag;
struct
{
ST_INT32 i;
ST_FLOAT f;
} ang;
} cVal;
ST_INT8 range;
struct /* BVstring */
{
ST_INT16 len_1;
ST_UCHAR data_1[2];
} q;
MMS_UTC_TIME t;
} res;
} phv_type_TDEF;
typedef struct
{
struct
{
struct
{
ST_INT32 i;
ST_FLOAT f;
} mag;
struct
{
ST_INT32 i;
ST_FLOAT f;
} ang;
} instCVal;
struct
{
struct
{
ST_INT32 i;
ST_FLOAT f;
} mag;
struct
{
ST_INT32 i;
ST_FLOAT f;
} ang;
} cVal;
ST_INT8 range;
struct /* BVstring */
{
ST_INT16 len_1;
ST_UCHAR data_1[2];
} q;
MMS_UTC_TIME t;
} phsx_type_TDEF;
/************************************************************************/
#endif /* if defined (USE_MMS_TYPEDEFS) */
/************************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* #ifndef FOUNDRY_OUTPUT_HEADER_INCLUDED */

198
mms/clntobj.odf Normal file
View File

@@ -0,0 +1,198 @@
# REVISIONS
# 07/22/05 JRB Add phv_type, phsx_type used by cli_goose.c
# 08/10/04 EJV Chg "UTF8VSTRING13" from ":T" to ":TK".
# 11/24/03 JRB Add ":CF", ":TV" to avoid unnecessary type definitions.
# 10/09/03 JRB Add types for dealing with IEC/UCA Reports. Add "client.h".
##########################################################################
# MMS OBJECT CONFIGURATION FILE
# This file is used as input to the 'foundry' utility application.
# It is used to create the following objects for use with MMS-LITE:
# Types
# Domains
# Named Variables
# Named Variable Lists
#
# Note: All objects except for the types can also be created
# by user code at initialization time. The creation of the
# Domains, Variables, and Variable Lists via this utility
# is for convenience only.
#
# Lines beginning with pound-signs are comments and are ignored.
# The general format of object definitions in this file is described
# below. All object definition information is supplied in quotes, and
# can span multiple lines if desired. A object definition string is of
# the form :
#
# "{objectType}","Object Specific String1", "String2", ...
#
# Where the objectType field is used to specify the object and some of
# it's optional attributes. The format of the 'objectType' field is as
# follows -
#
# ":X{flags}"
#
# Where X is one of the set {I,T,D,V,L}, and the set of valid flag
# characters depends on the object type.
#
# C == Control string
# Flags
# C : Config, next string is alignment file to use
# P : Path, next string is include path for ODF files
# F : Flags, next string contains flags to set defaults
# ":VD"
# ":VP"
# ":TU"
# ":TT"
# ":TV"
# "-notypedefs"
# "-nosuffix"
# U : UCA control, next string contains UCA control info
# "MVL_UCA"
# "MVLU_USE_REF"
#
# I == User specified include file, for user object definitions
# Flags
# None
#
# T == Type
# Flags
# U : Unique, do not 'twin' this type
# T : Transient type, do not keep
# V : Keep only if referenced by a variable
# K : Keep this type unconditionally
#
# D == Domain
# Flags
# None
#
# V == Named Variable
# Flags
# D : Use 3rd string to set data pointer
# P : Use 4th (3rd for no D) string to set processing fun
# U : Use 5th (4rd for no D, 3rd for no P) string to set usr_info
#
# L == Named Variable List
# Flags
# U : Use 5th (4rd for no D, 3rd for no P) string to set usr_info
# String ":S" : End of list of variables
#
# N == UCA Model Name Generation
# Flags
# None
#
##########################################################################
# EXECUTION CONTROL
#
# Include path, used to locate included ODF files
# Path for QNX
":CP", "../../../mvl/util/foundry/uca09"
# Path on Windows
":CP", "../../mvl/util/foundry/uca09"
# Set type handling default flags for all following types
":CF", ":TV" # Delete Runtime types not used by variables
# Include SISCO UCA Object Definition Files
":CI", "gentypes.odf"
":CI", "rpt.odf"
##########################################################################
# INCLUDE FILE DEFINITION SECTION
# This section is used to specify user include files that are to be
# included in the output 'C' file. This may be necessary when creating
# variables with data or processing initialzation strings.
# Example - Include the user header file 'umvlinit.h'
# ":I", "server.h"
#
":I", "mmsclient.h"
##########################################################################
# TYPE CREATION SECTION
# This section is used to specify MMS-LITE types. There are three
# required parameters per type (plus flags) -
# 1. Type Select Define : The define created to reference the type
# 2. TDL : The SISCO type definition language string
# 3. Comment: Used only in the output 'C' file
#
# Optional flags are -
# U : Do not 'twin' this type
# T : Transient type, do not write; use only as base type
# K : Keep this type unconditionally
":T", "ANALOG","[32:Ushort]","Array Of 32 16-bit unsigned integers"
":T", "U16","Ushort","Single 16-bit unsigned integer"
":TK", "I16","Short","Single 16-bit signed integer"
":TK", "U32","Ulong","Single 32-bit unsigned integer"
":TK", "UTF8VSTRING13","UTF8Vstring13","variable len Unicode UTF8 string"
# These types (phv_type, phsx_type) used by cli_goose.c
":TK", "phv_type",
"{(phsA){(instCVal){(mag){(i)Long,(f)Float,},(ang){(i)Long,(f)Float,},},(cVal){(mag){(i)Long,(f)Float,},(ang){(i)Long,(f)Float,},},(range)Byte,(q)BVstring13,(t)Utctime,},
(phsB){(instCVal){(mag){(i)Long,(f)Float,},(ang){(i)Long,(f)Float,},},(cVal){(mag){(i)Long,(f)Float,},(ang){(i)Long,(f)Float,},},(range)Byte,(q)BVstring13,(t)Utctime,},
(phsC){(instCVal){(mag){(i)Long,(f)Float,},(ang){(i)Long,(f)Float,},},(cVal){(mag){(i)Long,(f)Float,},(ang){(i)Long,(f)Float,},},(range)Byte,(q)BVstring13,(t)Utctime,},
(neut){(instCVal){(mag){(i)Long,(f)Float,},(ang){(i)Long,(f)Float,},},(cVal){(mag){(i)Long,(f)Float,},(ang){(i)Long,(f)Float,},},(range)Byte,(q)BVstring13,(t)Utctime,},
(net){(instCVal){(mag){(i)Long,(f)Float,},(ang){(i)Long,(f)Float,},},(cVal){(mag){(i)Long,(f)Float,},(ang){(i)Long,(f)Float,},},(range)Byte,(q)BVstring13,(t)Utctime,},
(res){(instCVal){(mag){(i)Long,(f)Float,},(ang){(i)Long,(f)Float,},},(cVal){(mag){(i)Long,(f)Float,},(ang){(i)Long,(f)Float,},},(range)Byte,(q)BVstring13,(t)Utctime,},
}",
""
":TK", "phsx_type",
"{(instCVal){(mag){(i)Long,(f)Float,},(ang){(i)Long,(f)Float,},},(cVal){(mag){(i)Long,(f)Float,},(ang){(i)Long,(f)Float,},},(range)Byte,(q)BVstring13,(t)Utctime,}",
""
##########################################################################
# DOMAIN CREATION SECTION
# This section is used to create MMS-LITE domains. The single parameter
# is the domain name, which must be a legal MMS domain name.
# Example - Create a domain named mvlLiteDomain
# ":D", "mvlLiteDomain"
#
##########################################################################
# VARIABLE ASSOCIATION CREATION SECTION
# This section is used to specify MMS-LITE named variables. There are two
# required parameters per variable, and three optional parameters (plus
# flags) -
# 1. Variable Name (must be valid MMS variable name). Note that the
# name can be of the form "domainName:VariableName" for domain vars.
# 2. Type ID : This Type ID must have been created previously
# 3. Data (optional): Used to initialize the va->data element.
# 4. Proc (optional): Used to initialize the va->proc element.
# 5. User (optional): Used to initialize the va->usr_info element.
#
# Optional flags are -
# D : Use 3rd string to set va->data
# P : Use 4th (3rd for no D) string to set va->proc
# U : Use 5th (4th, 3rd for no D, no P) string to set va->usr_info
#
# Note that it may ne necessary to specify an include file to be used
# to resolve the 'data' and 'proc' initialization code.
#
# Example - Create a VMD variable named 'Temperature'
# ":VDP", "Temperature", "I16", "&Temperature", "&varProcFuns"
#
##########################################################################
# NAMED VARIABLE LIST CREATION SECTION
# This section is used to specify MMS-LITE named variable lists.
# There are two required parameters per variable list, and a list of
# variables to be included in the list (plus flags) -
# 1. Variable list Name (must be valid MMS variable name). Note that the
# name can be of the form "domainName:VariableListName" for domain vars.
# 2. List of variables to be part of the named variable list.
# 3. End of variables marker. This is a string of form ":S",
#
# Example - Create a VMD Variable List named 'nvl1' with 'Temperature',
# and 'arr1' as members.
# ":L", "nvl1", "arr1", "Temperature", ":S"
#
##########################################################################
# UCA MODEL NAME GENERATION SECTION
# This section is used to generate UCA variable names from a selected
# structure type. The first parameter is the name base to be used. The
# second parameter is the type to use in extracting the names, and will
# generally be a high level UCA object type.
# Note: These objects are used only when the '-v' or '-n' command line
# parameters is used.
# Example - Extract the names for the
# "Automatic Switch Controller Device Model"
#":N","ASWC","ASWC"
#

229
mms/db_interface.h Normal file
View File

@@ -0,0 +1,229 @@
/**
* @file: $RCSfile: db_interface.h,v $
* @brief: $IEC 61850 Protocol
*
* @version: $Revision: 1.12 $
* @date: $Date: 2019/01/12 08:44:26 $
* @author: $Author: lizhongming $
* @state: $State: Exp $
*
* @latest: $Id: db_interface.h,v 1.12 2019/01/12 08:44:26 lizhongming Exp $
*
*/
#ifndef DB_INTERFACE_7ew2327hyhy0923r_H
#define DB_INTERFACE_7ew2327hyhy0923r_H
#include "apr_time.h"
#include <stdbool.h>//lnk20241022
#define LOG_IDX (0)
#define RPT_IDX (1)
///////////////////////////////////////////////////////////////////////////////
#define INVALID_DEV_IDX -1
#define STAT_DATA_BASE_NODE_ID 100
#define THREE_SECS_DATA_BASE_NODE_ID 200
#define SOE_COMTRADE_BASE_NODE_ID 300
#define HIS_DATA_BASE_NODE_ID 400
#define NEW_HIS_DATA_BASE_NODE_ID 500
#define RECALL_HIS_DATA_BASE_NODE_ID 600
#define RECALL_ALL_DATA_BASE_NODE_ID 700
#define REPORT_TYPE_STAT 1
#define REPORT_TYPE_REAL 2
#define REPORT_TYPE_SOE 4
#define REPORT_TYPE_EVENT 8
#define SHOULD_DO_NOTHING 0
#define SHOULD_REGISTER 1
#define SHOULD_UNREGISTER 2
///////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern char* OSS_ENDPOINT;
extern char* ACCESS_KEY_ID;
extern char* ACCESS_KEY_SECRET;
extern char* BUCKET_NAME;
extern char* POSTGRES_SCHEMA;
extern char* POSTGRES_TABLEPREFIX;
void GetSM4Code(unsigned char* pSerise,char* pKey,char* output);
void MyGetSM4Code(char* input,unsigned char* szKey,char* output);
void try_start_kafka_thread();
void try_start_mqconsumer_thread();//lnk20241216
//0. json<6F><6E><EFBFBD>ɿ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
int json_block_create_start( char voltage_level[],char monid_char[],int flicker_flag, char temcode[],int line_id);
//1. json<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EABAAF>
int json_block_create_time(char monid_char[], long long Time, int flicker_flag);
//1.5 json<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>flag<61><67><EFBFBD><EFBFBD>
int json_block_create_flag(char monid_char[], int flag, int flicker_flag);
//2. json<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻص<DDBB><D8B5><EFBFBD><EFBFBD><EFBFBD>
int json_block_create_data(char monid_char[], char* mms_str , double v, int flicker_flag);
//3. json<6F><6E><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int json_block_create_end(char monid_char[], int flicker_flag); //CZY 2023-08-17 <20><><EFBFBD><EFBFBD>
//int json_block_create_end(int MonitorId,int devkind);//CZY 2023-08-17 <20><><EFBFBD><EFBFBD>
//zw 2024-01-31 <20><><EFBFBD><EFBFBD>ģʽ<C4A3>Ż<EFBFBD>
void add_mvl_type_ctrl(char doname[], int ctrl);
int sel_mvl_type_ctrl_flag(char doname[]);
void del_mvl_type_ctrl();
//<2F><><EFBFBD><EFBFBD>ģʽ<C4A3>Ż<EFBFBD> end
#ifndef DB_INTERFACE_H
#define DB_INTERFACE_H
// ǰ<><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LD_info_t
typedef struct LD_info_t LD_info_t;
int urcbRealDataHasReceived(int dev_index, LD_info_t* LD_info, long long Time); //lnk20241223
#endif
//void set_log_LineID(int id);
//void set_rpt_LineID(int id);
//void set_log_TimeID(apr_time_t time);
//void set_rpt_TimeID(apr_time_t time);
//void set_log_QualityFlag(int QualityFlag);
//void set_rpt_QualityFlag(int QualityFlag);
int is_rpt_Time_exact_hour() ;
apr_status_t app_get_private_config(const char *myfilename);
void parse_log_switch_ini(unsigned int* error,unsigned int* warn,unsigned int* info);
int parse_device_cfg_json_test();
int parse_line_cfg_pg_test();
int parse_device_cfg_json();
int parse_device_cfg_pg();
int parse_line_cfg_pg();
void init_config();
int init_ping_telnet();
int GetServerIndexFromDB();
int parse_device_cfg();
int parse_line_cfg();
int parse_rpt_log_ini();
int parse_json_cfg();
void clear_all_LD_real_soe_report_shoud_register();
void add_comm_log(char* log_str);
void prcess_monitor_comm_2_json(int monitor_id,int status,long long tm);
void clear_old_comtrade_files();
int process_login_verify();
//////////////////////////////WW 20230819<31><39><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int OTLConnect(); //OTL<54><4C><EFBFBD><EFBFBD>Oracle<6C><65><EFBFBD>ݿ<EFBFBD>
int OTLDisconnect(); //OTL<54>Ͽ<EFBFBD>Oracle<6C><65><EFBFBD>ݿ<EFBFBD>
int OTLState(); //OTL<54><4C><EFBFBD><EFBFBD>Oracle<6C><65><EFBFBD>ݿ<EFBFBD>״̬
int OTLDbconnected();
int write_to_db(const char* sqlstm); //<2F><><EFBFBD>ݿ<EFBFBD>д<EFBFBD><D0B4>
int OTLTestSelect();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>ȡ
void TestToken();
void TestBodyPost();//WW <20><><EFBFBD><EFBFBD>qt post
void TestSMSPost();//WW <20><><EFBFBD><EFBFBD>qt post
void TestJson(char* szJson);
void TestOSS();//WW <20><><EFBFBD><EFBFBD>
void PutOSS(char* File_Name, char* data); //zw<7A>޸<EFBFBD> 2023-9-7 <20><><EFBFBD><EFBFBD>oss<73>ļ<EFBFBD>
void GetOSS(char* File_Name, char* savepath); //zw<7A>޸<EFBFBD> 2023-9-7 <20><>ȡoss<73>ļ<EFBFBD>
void DelOSS(char* File_Name);
void delete_object_new(char* File_Name);
void coutTest();//CZY 2023-09-11 test
void TestOBS();//WW 20230921 <20><><EFBFBD>Ի<EFBFBD>Ϊ<EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD>
void OBSFile(char* localpath, char* cloudpath,const char* code);
void OBSFile_del(char* cloudpath, const char* code);
void DataHub_Send_Datahub(char* topic, char* data);//datahubͨѶ
void Nacos_GetParam(char* postgres_uid, char* postgres_pwd, char* web_clientid, char* web_clientsecret);//nacos
void Nacos_GetParam_Ptr(const char* code, char** ptr);
void Read_Nacos_Param_Postgres(char** database_ip, char** database_port, char** postgres_database, char** postgres_username, char** postgres_password, char** postgres_schema, char** postgres_dnsname, char** postgres_tableprefix);
void Read_Nacos_Param_Kafka(char** broker_list, char** topic_stat, char** topic_pst, char** topic_plt, char** topic_event, char** topic_alarm, char** topic_sng, char** protocol, char** mechanisms, char** service_name, char** principal, char** domain_name);
void Read_Nacos_Param_Web(char** client_id, char** client_secret, char** token_url, char** device_url, char** grant_type);
void Read_Nacos_Param_Flag(int* file_flag, int* send_flag, int* front_inst, char** front_ip);
void Read_Nacos_Param_Recall(int* recall_len, int* recall_sta, int* recall_daily);
void Read_Nacos_Param_Uds(char** uds_upload_url, char** uds_download_url, char** uds_delete_url);//nacos<6F><73>ȡuds<64><73><EFBFBD><EFBFBD>
int WebAPI_Uds_Upload(char* strUrl, char* loacl_path, char* uuid,char* filename);
void WebAPI_Uds_Download(char* strUrl, char* uuid, char* local_path,char* filename);
int base64_decode(const char* indata, int inlen, char* outdata, long* outlen);
int testbase64();
/////////////////////////////WW end
//////////////////////////////WW 20230822<32><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>WebSocket<65>߳<EFBFBD>
void try_start_sql_thread(); //<2F><><EFBFBD><EFBFBD>Sqlִ<6C><D6B4><EFBFBD>߳<EFBFBD>
void try_start_socket_thread(); //<2F><><EFBFBD><EFBFBD>Web Socket<65>߳<EFBFBD>
void try_start_ontimer_thread();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>߳<EFBFBD>s
/////////////////////////////WW end
//lnk20241029<32><39><EFBFBD><EFBFBD>http<74>߳<EFBFBD>////////////////////////////////////////
void try_start_web_http_thread(); //<2F><><EFBFBD><EFBFBD>Webhttp<74>߳<EFBFBD>
void try_start_http_thread(); //<2F><><EFBFBD><EFBFBD>http<74>߳<EFBFBD>
int try_start_mqtest_thread(int argc, char *argv[]); //20241202
//////////////////////////////////////////////////////////////////////
int OTL_Select_xmlModel(); //xmlģ<6C><C4A3><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>ȡ
void OTL_Select_recall(char* time, char* id);
int OTL_Select_DecideRecall(char* time, char* id);//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>
char* getoneday(int num);
void deletechar(char* day);
void CreateRecallXml();
void DeletcRecallXml();
/*lnk10-11*////////////////////////////////////////////////////////////////////////
void rocketmq_test();
void rocketmq_test_300(int mpnum,int front_index);
void curltest();
void SOEFileWeb_test();
void qvvr_test();
void integrity_test();
void comflag_test();
int parse_device_web_test_ext();
int parse_device_web_test_dev();
int parse_line_web_test();
int parse_model_web_test();
int parse_intact_web_test_read();
int parse_device_web_test_front_read();
int parse_device_web_test_front_write();
int parse_device_cfg_web();
//int parse_line_cfg_web();
int parse_model_cfg_web();
void SOEFileWeb(char* localpath,char* cloudpath,char* wavepath);
void OTL_Select_recall_web(char* time, char* id);
int OTL_Select_DecideRecall_web(char* time, char* id);
bool CheckPG_To_Recall_web(long long start, long long end, char* Monitorid);
//////////////////////////////////////////////////////////////////////////////////////
/*int parse_database_delete(const std::vector<std::string>& codes);
int parse_commerror_write(const std::vector<std::string>& codes);
int parse_commstatus_write(const std::vector<std::string>& codes);
int parse_match_write(const std::vector<std::string>& codes);
int parse_dataintegrity_write(const std::vector<std::string>& codes);
int parse_rationality_write(const std::vector<std::string>& codes);*/
#ifdef __cplusplus
}
#endif
#endif //DB_INTERFACE_7ew2327hyhy0923r_H

199
mms/event.c Normal file
View File

@@ -0,0 +1,199 @@
/**
* @file: $RCSfile: event.c,v $
* @brief: $IEC 61850 Protocol
*
* @version: $Revision: 1.1 $
* @date: $Date: 2018/11/24 06:54:50 $
* @author: $Author: lizhongming $
* @state: $State: Exp $
*
* @latest: $Id: event.c,v 1.1 2018/11/24 06:54:50 lizhongming Exp $
*
*/
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 All Rights Reserved */
/* */
/* MODULE NAME : event.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* Event handling functions. */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* wait_any_event () */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/20/05 JRB 08 Add header files (included indirectly before).*/
/* 07/07/04 JRB 07 Del #ifdef MOSI. May need a_get_event_handles*/
/* added to stack lib if non-MOSI stack used. */
/* 10/23/03 JRB 06 Call a_get_event_handles_unix for default system.*/
/* 05/17/02 JRB 05 Put back old code for PHARLAP_ETS, PharLap */
/* doesn't have "Wait..Ex". */
/* 04/10/00 JRB 04 Del "select.h". See "sysincs.h". */
/* 04/06/00 JRB 03 Use WaitForMultipleObjectsEx for WIN32: */
/* CRITICAL for ethernet driver interface. */
/* 08/05/99 JRB 02 Use a_get_ev.., gs_wait.. for WIN32. */
/* Use hTcpEvent for OS2. */
/* 11/10/98 JRB 01 Created */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "glbsem.h"
#include "acse2usr.h"
#include "mvl_defs.h"
#include <assert.h>
#if defined (_WIN32)
/************************************************************************/
/* wait_any_event */
/************************************************************************/
ST_VOID wait_any_event (ST_LONG max_ms_delay)
{
ST_EVENT_SEM *EventArray;
ST_INT NumEntries;
#if defined (PHARLAP_ETS)
ST_BOOLEAN activity [2]; /* We don't chk it, but gs_wait.. needs it*/
#endif
EventArray = a_get_event_handles (&NumEntries);
/* Make sure there is at least 1 event to wait on. If not, probably */
/* because library not compiled with correct switches. */
assert (NumEntries > 0);
/* If this fails, size of "activity" array must be increased. */
assert (NumEntries <= 2);
#if defined (PHARLAP_ETS) /* PharLap doesn't have/need "Wait...Ex"*/
gs_wait_mult_event_sem (NumEntries, EventArray, activity, max_ms_delay);
#else
/* CRITICAL: Use Wait..Ex with last arg TRUE so that Ethernet driver */
/* completion routines may be called. */
WaitForMultipleObjectsEx (NumEntries, EventArray,
FALSE, /* return when ANY object signaled */
max_ms_delay,
TRUE);
#endif
/* Something woke us up. Don't care if it was event or timeout. */
/* Just return to main loop to attempt processing. */
return;
}
#elif defined (__OS2__)
/************************************************************************/
/* wait_any_event */
/* DEBUG: not tested but should work on OS/2. */
/************************************************************************/
ST_VOID wait_any_event (ST_LONG max_ms_delay)
{
#define MMS_EVENT_SEM_ID 0
static SEMRECORD sems[2];
static HMUX hMux;
APIRET apiret;
ST_ULONG post_count;
ST_ULONG semId;
/* This function only waits on the MMS event. To wait on other events */
/* also, add to the "sems" array. */
if (hMux == NULL)
{
sems[0].hsemCur = (void *) hTcpEvent;
sems[0].ulUser = MMS_EVENT_SEM_ID;
apiret = DosCreateMuxWaitSem (NULL, &hMux, 1, sems, DCMW_WAIT_ANY);
if (apiret != NO_ERROR)
{
printf ("\n DosCreateMuxWaitSem failed, rc = %d",apiret);
hMux = NULL;
}
return; /* Just return. New event so no one has signaled it yet.*/
}
/* Wait on the MMS Event Semaphore. */
apiret = DosWaitMuxWaitSem (hMux, max_ms_delay, &semId);
if (apiret == NO_ERROR)
{
if (semId == MMS_EVENT_SEM_ID) /* MMS event */
{
gs_reset_event_sem (hTcpEvent); /* OS2 requires reset */
}
}
else if (apiret != ERROR_TIMEOUT)
{
printf ("\n DosWaitMuxWaitSem error, apiret = %d",apiret);
}
}
#elif defined(MSDOS) || defined(__MSDOS__)
/************************************************************************/
/* wait_any_event */
/************************************************************************/
ST_VOID wait_any_event (ST_LONG max_ms_delay)
{
return;
}
#else /* All other systems */
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* wait_any_event */
/************************************************************************/
ST_VOID wait_any_event (ST_LONG max_ms_delay)
{
struct timeval stTimeVal;
fd_set readfds;
fd_set writefds;
fd_set exceptfds;
int nfds=0;
int *fd_array; /* ptr to array of handles on which to wait */
int num_entries; /* num of entries in fd_array. */
int j; /* loop index */
FD_ZERO (&readfds);
FD_ZERO (&writefds);
FD_ZERO (&exceptfds);
// FD_SET (0, &readfds); /* select on "stdin" */
/* Ask ACSE for array of handles on which to wait. */
fd_array = a_get_event_handles_unix (&num_entries);
for (j = 0; j < num_entries; j++)
{
FD_SET (fd_array[j], &readfds);
nfds = max (nfds,fd_array[j]);
}
nfds++; /* must be 1 greater than max handle. */
/* If you want to wait for other events too, add more FD_SET calls, */
/* and recompute "nfds" (or just set it to FD_SETSIZE). */
max_ms_delay *= 1000; /*** Convert to micro seconds ***/
stTimeVal.tv_sec = max_ms_delay / 1000000;
stTimeVal.tv_usec = max_ms_delay % 1000000;
nfds = select (nfds, &readfds, &writefds, &exceptfds, &stTimeVal);
if (nfds<0){
printf("select error: errno= %i , %s",errno, strerror(errno) );
}
}
#endif /* All other systems */

74
mms/event2.c Normal file
View File

@@ -0,0 +1,74 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 2003 All Rights Reserved */
/* */
/* MODULE NAME : event2.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* Event handling function. This function may be used ONLY if */
/* the the POLLING version of the "gensock2" sockets interface is */
/* used (i.e. gensock2.c is compiled with GENSOCK_THREAD_SUPPORT */
/* NOT defined). */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* wait_any_event () */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 01/30/07 JRB 04 Shorten sleep to avoid delay detecting connect.*/
/* 12/11/06 JRB 03 Wait for Subnetwork events too. */
/* 11/01/06 JRB 02 Call sMsSleep when no connections, */
/* so we don't hog the CPU. */
/* 07/10/03 JRB 01 Created */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "gensock2.h"
#include "clnp_sne.h" /* for "Subnetwork" event stuff */
/************************************************************************/
/* wait_any_event */
/* Wait for "socket" events OR "Subnetwork" events. */
/* NOTE: See comments about "PORTING" if this function needs */
/* to wait on "other" handles. */
/************************************************************************/
ST_VOID wait_any_event (ST_LONG max_ms_delay)
{
GENSOCK_FD_SET sockFds;
int nfds;
struct timeval selectTimeout;
/* This function assumes only one group of sockets to process. */
sockInitAllFds (&sockFds);
/* If Subnetwork handle "hPktSock" is valid, add it to list. */
if (hPktSock >= 0)
sockAddReadFds (&sockFds, hPktSock);
/* PORTING: Call sockAddReadFds, sockAddWriteFds, sockAddExceptFds
* to add "other" handles on which to wait.
*/
if (sockFds.totalfds)
{
/* Convert milliseconds to seconds and microseconds */
selectTimeout.tv_sec = max_ms_delay / 1000; /* seconds */
selectTimeout.tv_usec = (max_ms_delay % 1000) * 1000; /* microseconds */
nfds = select (sockFds.selectnfds, &sockFds.readfds, &sockFds.writefds, &sockFds.exceptfds, &selectTimeout);
/* PORTING: Add code to process "other" handles. */
}
else
sMsSleep (10); /* no sockets to wait on, so sleep a little to avoid hogging CPU.*/
/* NOTE: socket events are NOT processed here. This function simply returns,
* and the caller must call "mvl_comm_serve" to process the events.
*/
return;
}

207
mms/gentypes.odf Normal file
View File

@@ -0,0 +1,207 @@
#############################################################
#Copyright 1998-2003, Systems Integration Specialists Company, Inc.
# All Rights Reserved
#############################################################
# 08/23/04 JRB Fix BOOLEAN definition.
# 05/13/04 JRB Fix INT16U definition.
# 10/08/03 RKR Added types from chapter 8
61850-8-1_CDV_R1-06_To-IEC-CO_2002-11-22.doc
# 03/13/03 JRB Reverse last chg. Use new types in "rpt.odf" instead.
# 12/16/02 JRB Chg types needed for Rpts to ":TK". Add "VBSTR5", "OSTR8".
# IEC-61850-8-1: section 8.1.1 Basic data attribute types
":T","BOOLEAN" "Bool", "0 or 1"
":T","INT8" "Byte", "-128 to 127"
":T","INT16" "Short", "-32,768 to 32,767"
":T","INT32" "Long", "-2,147,483,648 to 2,147,483,647"
":T","INT128" "Long", "-2**127 to (2**127)-1 Good luck"
":T","INT8U" "Ubyte", "0 to 255"
":T","INT16U" "Ushort", "0 to 65,535"
":T","INT32U" "Ulong", "0 to 4,294,967,295"
":T","FLOAT32" "Float", "Range of values IEEE 754 single"
":T","FLOAT64" "Double", "Range of values IEEE 754 double"
":T","ENUMERATED8", "Byte", "signed enumeration8-bits"
":T","ENUMERATED16", "Short", "signed enumeration16-bits"
":T","OCTET_STRING8", "OVstring8", "Maximum 8 Octets"
":T","OCTET_STRING64", "OVstring64", "Maximum 64 Octets"
":T","VISIBLE_STRING255","Vstring255", "Maximum 255 characters"
":T","VISIBLE_STRING64","Vstring64", "Maximum 64 characters"
":T","VISIBLE_STRING97","Vstring97", "Maximum 97 characters"
":T","UTC_TM", "Utctime", "Used by TimeStamp"
":T","CODED_ENUM2", "Bstring2", "2 bits - 4 values"
":T","UNICODE_STRING255","UTF8Vstring255","Maximum 255 Unicode"
":T", "TimeStamp" "<UTC_TM>", "UTC Time"
":T", "EntryTime" "Btime6", " 8.1 Section 8.1.3.7"
":T", "Quality" "BVstring13", "Quality"
#general types for clause 4.2.1 of GOMSFE
":T","IDENT", "Vstring65", ""
":T","BOOL", "Bool", "generalboolean"
":T","B2", "Bstring2", "GeneralDoubleBit"
":T","D", "VString32", "generaldescriptioncomponent"
":T","DB", "UShort", "Deadband"
":T","F", "Float", "Generalizedfloatingpoint"
":T","FF", "Float", "FrozenFloatingPointvalue"
":T","HL", "Short", "HighLimit"
":T","HHL", "Short", "HighHighLimit"
":T","LL", "Short", "lowlimit"
":T","LLL", "Short", "lowlowlimit"
":T","I", "Short", "Generalizedicomponenttype"
":T","FI", "Short", "frozenicomponenttype"
":T","O", "Float", "Offset"
":T","Q", "Bvstring16", "Generalizedqualitybitstringtype"
":T","R", "ULong", "runningcount"
":T","FR", "ULong", "frozenrunningcount"
":T","S", "Float", "scale"
":T","T", "Btime6", "GeneralizedTimeStamp"
":T","FT", "Btime6", "frozentimestamp"
":T","PP", "Bool", "PseudoPoint"
":T","U", "Short", "Enumeratevalue"
":T","VSTR8", "Vstring8", "VisibleString8-variablelength"
":T","VSTR16", "Vstring16", "VisibleString16-variablelength"
":T","VSTR32", "Vstring32", "VisbleString32-variablelength"
":T","VSTR64", "Vstring64", "VisibleString64-variablelength"
":T","VSTR65", "Vstring65", "VisibleString65-variablelength"
":T","VSTR128", "Vstring128", "VisibleString128-variablelength"
#From Clause 4.2.2 of GOMSFE
":T","BSTR1", "Bstring1", "Twobitbistring"
":T","BSTR2", "Bstring2", "Twobitbistring"
":T","BSTR8", "Bstring8", "Bitstring-8"
":T","BSTR16", "Bstring16", "Bitstring-16"
":T","BSTR32", "Bstring32", "Bitstring-32"
":T","VBSTR8", "Bvstring8", "VariablelengthBitstring-8"
":T","VBSTR16", "Bvstring16", "VariablelengthBitstring-16"
":T","VBSTR32", "Bvstring32", "VariablelengthBitstring-32"
#INT8U, INT16U, & INT32U already defined in IEC-61850 section above
":T","INT8S", "Byte", "SignedInteger-8"
":T","INT16S", "Short", "SignedInteger-16"
":T","INT32S", "Long", "SignedInteger-32"
":T","FLT32", "Float", "32bitfloatingpoint"
":T","FLT64", "Double", "64bitfloatingpoint"
":T","BTIME4", "Btime4", "Binarytimeofday"
":T","BTIME6", "Btime6", "Binarytimeofdaytomsec"
":T","ENUM8", "Byte", "signed enumeration8-bits"
":T","ENUM16", "Short", "signed enumeration16-bits"
#missing from GOMSFE
":T","MAG", "<INT32S>", "Magnitude"
":T","ANG", "<INT32S>", "Angle"
":T","ACCRPTENA", "<BOOL>", "AccumulatorReportEnable"
":T","ACCRS", "<BOOL>", "AccumulatorReset"
":T","ACCSET", "<VSTR16>", "AccumulatorSetting"
":T","ACTTAGARR", "<BSTR8>", "Accumulatortagarray"
":T","ANCESTRY", "<VSTR32>", "Ancestry"
":T","ANFMT", "Vstring6", "AnalogFormat"
":T","BUFTIM", "<INT32U>", "Buffertime"
":T","CID", "<INT32S>", "CanonicalID"
":T","CKTID", "<VSTR32>", "CircuitID"
":T","CKTPHS", "<ENUM8>", "CircuitPhases"
":T","CLASS", "<VSTR32>", "Classidentifier"
":T","COMMADR", "<VSTR16>", "Communicationaddress"
":T","COMMREV", "<VSTR8>", "Communicationrevision"
":T","CONTCURRTG", "<VSTR16>", "Continuouscurrentrating"
":T","COUNT", "<INT16U>", "count"
":T","CRIRPT", "<BOOL>", "criticalreport"
":T","DATSETNAM", "<VSTR16>", "Datasetname"
":T","DESTAE", "<VSTR32>", "destinationAEname"
":T","DEVFCT", "<INT16U>", "devicefunction"
":T","DEVMDLS", "<VSTR128>", "devicemodelname"
":T","DOW", "<ENUM8>", "Dayoftheweek"
":T","DOWSCHED", "[6:<BTIME4>]", "Dayoftheweekschedule"
":T","ENABLE", "<BOOL>", "enable"
":T","ENCOPT", "<BSTR8>", "encodingoptions"
":T","ENROLL", "<VSTR32>", "enrollname"
":T","EORBDESC", "<VSTR64>", ""
":T","EVACON", "<VSTR32>", "evaluationconditionname"
":T","EVACNS", "<VSTR32>", "evaluationconditionname"
":T","EVACRI", "<VSTR32>", "evaluationcriterianame"
":T","EVAFCT", "<VSTR32>", "evaluationfunctionname"
":T","EVAPAR", "<VSTR32>", "evaluationparametersname"
":T","EVTENA", "<BOOL>", "eventenable"
":T","FLTCURDUR", "<INT16U>", "Faultcurrentduration"
":T","FLTCURRTG", "<INT16S>", "Placeholder"
":T","FRZENA", "<BOOL>", "freezeenable"
":T","FRZPD", "<INT32U>", "freezeperiod"
":T","FWDPWRHA", "[31:<FLT32>]", "ForwardPowerharmonics"
":T","HWREV", "<VSTR8>", "HardwareRevision"
":T","HZRTG", "<VSTR32>", "Hertzrating"
":T","INDAT", "<IDENT>", "InputDataName"
":T","INTGPD", "<INT32U>", "IntegrityPeriod"
":T","LINLENM", "<INT16U>", "Linelengthinmeters"
":T","LOC", "<VSTR128>", "Location"
":T","LOGENA", "<BOOL>", "Logenable"
":T","LOGENR", "<VSTR32>", "Logenroll"
":T","LOGNAM", "<VSTR32>", "Logname"
":T","LOGSIZE", "<INT16U>", "Logsize"
":T","LOGWRP", "<BOOL>", "LogWrapped"
":T","MAC", "<INT8U>", "MediumAccessControl"
":T","MDL", "<VSTR32>", "Modelname"
":T","MED", "<ENUM8>", "mediatype"
":T","MXREF", "<ENUM8>", "Measurementreference"
":T","MXTYP", "<ENUM8>", "MeasurementType"
":T","NAME", "<VSTR32>", "ownername"
":T","NEWTIM", "<BTIME6>", "newesttime"
":T","NUMBITS", "<INT16U>", "numberofbits"
":T","NUMPLS", "<INT16U>", "numberofpulses"
":T","NUMSMP", "<INT16U>", "numberofsamples"
":T","NUMUNIT", "<VSTR32>", "numberofunits"
":T","OFFDUR", "<INT32U>", "Offduration"
":T","OLDTIM", "<BTIME6>", "Oldesttime"
":T","ONDUR", "<INT32U>", "Onduration"
":T","OPERDEV", "<B2>", "Operatedevice"
":T","OPTFLDS", "<VBSTR8>", "Optionalfields"
":T","OUTDAT", "<IDENT>", "outputdatasetname"
":T","OVRST", "<BOOL>", "Overflowstatus"
":T","OWN", "<VSTR32>", "Owner"
":T","PRO", "<ENUM8>", "enumeratedprotocolid"
":T","PWRHA", "[31:<FLT32>]", "powerharmonics"
":T","QURPTENA", "<BOOL>", "qualityreportenable"
":T","RBEPD", "<INT32U>", "reportperiod"
":T","RPTENA", "<BOOL>", "Reportenable"
":T","RPTID", "<VSTR32>", "ReportID"
":T","RVSPWRHA", "[31:<FLT32>]", "reversepowerharmonics"
":T","SBOENA", "<BOOL>", "SBOenable"
":T","SETTIMOUT", "<INT8U>", "SBOSelectTimeout"
":T","SEQNUM", "<INT32U>", "Sequencenumber"
":T","SERNUM", "<VSTR32>", "Serialnumber"
":T","SFTREV", "<VSTR8>", "SoftwareRevisionNumber"
":T","SMPRATE", "<INT16U>", "samplerate"
":T","TAGD", "<VSTR128>", "tagdescription"
":T","TAGID", "<INT8U>", "tagID"
":T","TAGOWN", "<VSTR32>", "tagowner"
":T","TAGTYP", "<BSTR8>", "tagtypepermitted"
":T","TEMPRAT", "<VSTR16>", "temperaturerating"
":T","TEMPRTG", "<VSTR16>", "temperaturerating"
":T","TIMOFFRZ", "<BTIME6>", "timeoffreeze"
":T","TIMRPTENA", "<BOOL>", "Timestampreportenable"
":T","TRGOPS", "<BSTR8>", "Triggeroptions"
":T","TRGS", "<INT16U>", "numberoftriggers"
":T","UNITVARRTG", "<VSTR32>", "Unitvarrating"
":T","UNKPWRHA", "[31:<FLT32>]", "Unkownharmonicdirection"
":T","USEST", "<BOOL>", "utilizationstatus"
":T","VARRTG", "<VSTR16>", "Varsrating"
":T","VARTG", "<VSTR16>", "VARsrating"
":T","VND", "<VSTR32>", "VendorID"
":T","VRTG", "<VSTR16>", "voltagerating"
":T","WRNLEV", "<INT16U>", "logwarninglevel"
":T","WRNST", "<BOOL>", "warningstatus"
":T","PHSTAR", "<ENUM8>", "PhaseTarget"
":T","SBO", "<VSTR65>", ""
#Additional types added from other sections
#to support GOOSE and PACT
":T","STNUM", "<INT32U>", ""
":T","HOLDTIM", "<INT32U>", ""
":T","BACKTIM", "<INT32U>", ""
":T","PHSID", "<INT16U>", ""
":T","DNA", "Bstring64", ""
":T","USERST", "BVstring128", ""

182
mms/interface.h Normal file
View File

@@ -0,0 +1,182 @@
/**
* @file: $RCSfile: interface.h,v $
* @brief: $IEC 61850 Protocol
*
* @version: $Revision: 1.4 $
* @date: $Date: 2019/01/08 08:15:34 $
* @author: $Author: lizhongming $
* @state: $State: Exp $
*
* @latest: $Id: interface.h,v 1.4 2019/01/08 08:15:34 lizhongming Exp $
*
*/
//$Header: /JoyProject/jspqfe/src/pt61850netd_pqfe/source/mms/interface.h,v 1.4 2019/01/08 08:15:34 lizhongming Exp $
/************************************************************************/
/* SAC HEADER ************************************************************/
/************************************************************************/
/* */
/* MODULE NAME : interface.h */
/* PRODUCT(S) : wg_sac_61850 */
/* */
/* MODULE DESCRIPTION : */
/* Defines functions that should be use between mmsease and scadacom */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 2006-6-23 lzm 01 New */
/************************************************************************/
#ifndef SAC_INTERFACE_H
#define SAC_INTERFACE_H
///////////////////////////////////////////////////////
#if defined (_WIN32)
#include <winsock2.h>
#endif
#include "sasstd.h"
#include "glbtypes.h"
#include "sysincs.h"
#include "signal.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mms_pvar.h"
#include "mms_vvar.h"
#include "mms_err.h"
#include "mms_pcon.h"
#include "asn1defs.h"
#include "mmsop_en.h"
#include "mvl_log.h"
#include "slog.h"
#include "tp4api.h"
#include "clntobj.h"
#include "mmsclient.h"
///////////////////////////////////////////////////
#define MAX_DATA_STR_SIZE 256
#define DATA_INT_TYPE 0
#define DATA_UINT_TYPE 1
#define DATA_INT64_TYPE 2
#define DATA_UINT64_TYPE 3
#define DATA_DOUBLE_TYPE 4
#define DATA_STR_TYPE 5
#define DATA_TIME_TYPE 6
typedef struct mms_decode_data_item
{
ST_CHAR comp_name[MAX_DATA_STR_SIZE];
ST_UCHAR type; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ST_UCHAR size; //<2F><><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD>Ч<EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>
union
{
ST_INT32 data_int;
ST_UINT32 data_uint;
#ifdef INT64_SUPPORT
ST_INT64 data_int64;
ST_UINT64 data_uint64;
#endif
ST_DOUBLE data_double;
ST_CHAR data_str[MAX_DATA_STR_SIZE];
MMS_BTIME6 data_bTime6;
} u;
} MMS_DECODE_DATA_ITEM;
#define MAX_DATA_ITEMS_IN_ONE_DATA 1024 // change for PQS882 2016-5-10 //10-10-26-8-53 bei jing
typedef struct mms_decode_data
{
ST_UINT item_num; //<2F><><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>
MMS_DECODE_DATA_ITEM data_item[MAX_DATA_ITEMS_IN_ONE_DATA];
} MMS_DECODE_DATA;
void init_MMS();
void exit_MMS();
ST_VOID doCommService ();
ST_VOID init_log_cfg (ST_VOID);
ST_VOID set_rem_dib_table_size (ST_INT size);
ST_VOID add_rem_dib_table (ST_INT pos,ST_CHAR *remAr,unsigned short port);
ST_RET mms_connectToServer (ST_CHAR * dev_key,ST_CHAR *dev_series, ST_CHAR *serverARName,
MVL_NET_INFO **clientNetInfo, MVL_REQ_PEND **reqCtrl);
ST_RET mms_mvla_identify (MVL_NET_INFO *net_info,char** ident,int iTimeout);
ST_RET mms_mvla_fdir (MVL_NET_INFO *net_info,ST_CHAR *filespec,int iTimeout,
char*** filenames ,int* filenum,apr_pool_t *pool);
ST_RET mms_getFile (MVL_NET_INFO *clientNetInfo, ST_CHAR *loc_file,
ST_CHAR *rem_file, ST_INT iTimeout);
ST_RET mms_mvla_status (MVL_NET_INFO *net_info,int iTimeout);
ST_RET mms_mvla_getnam (MVL_NET_INFO *net_info,ST_INT scope,
ST_CHAR *domName,ST_INT16 mms_class, int iTimeout,
char*** varnames ,int* varnum,apr_pool_t *pool);
ST_INT mms_var_type_id_create (MVL_NET_INFO *clientNetInfo, ST_INT scope,
ST_CHAR *dom_name, ST_CHAR *var_name, int iTimeOut);
ST_RET mms_named_var_read (MVL_NET_INFO *net_info, ST_CHAR *varName,
ST_INT scope, ST_CHAR *domName,
ST_INT type_id, ST_VOID *dataDest, ST_INT timeOut);
ST_VOID Callback_channel_disconnect_ind(MVL_NET_INFO * NetInfo, ST_INT discType);
ST_RET mms_disconnectFromServer (MVL_NET_INFO *clientNetInfo,MVL_REQ_PEND **reqCtrl);
RCB_INFO *mms_register_iec_rpt (MVL_NET_INFO *clientNetInfo, RPT_TYPEIDS *rpt_typeids,
ST_CHAR *dom_name, /* domain which contains the RCB*/
ST_CHAR *rcb_name, /* RCB (e.g. "LLN0$BR$PosReport")*/
ST_INT timeOut, ST_INT scanRate,ST_UCHAR trgops,ST_UINT8* pEntryID,ST_UINT8* OptFlds);
ST_RET mms_unregister_iec_rpt (MVL_NET_INFO *clientNetInfo, RPT_TYPEIDS *rpt_typeids,
ST_CHAR *dom_name, /* domain which contains the RCB*/
ST_CHAR *rcb_name, /* RCB (e.g. "LLN0$BR$PosReport")*/
ST_INT timeOut );
//WW 2023-08-29 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E8B1B8><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>
RCB_INFO *mms_register_iec_rpt_by_devtype(MVL_NET_INFO *clientNetInfo, RPT_TYPEIDS *rpt_typeids,
ST_CHAR *dom_name, /* domain which contains the RCB*/
ST_CHAR *rcb_name, /* RCB (e.g. "LLN0$BR$PosReport")*/
ST_INT timeOut, ST_CHAR *dev_type, ST_CHAR *ip, int port, ST_INT scanRate, ST_UCHAR trgops, ST_UINT8* pEntryID, ST_UINT8* OptFlds);
ST_RET mms_unregister_iec_rpt_by_devtype(MVL_NET_INFO *clientNetInfo, RPT_TYPEIDS *rpt_typeids, ST_CHAR *dev_type, ST_CHAR *ip, int port,
ST_CHAR *dom_name, /* domain which contains the RCB*/
ST_CHAR *rcb_name, /* RCB (e.g. "LLN0$BR$PosReport")*/
ST_INT timeOut);
//WW end
void my_local_to_data (ST_CHAR *datptr, SD_CONST RUNTIME_TYPE *rt_head,
ST_INT rt_num,MMS_DECODE_DATA *data);
RCB_INFO* FindRcbInfo(MVL_NET_INFO *net_info,ST_CHAR *dom_name, ST_CHAR *rcb_name);
int mms_iec_setPoint(ST_UCHAR ctlModel, MVL_NET_INFO *clientNetInfo,
ST_CHAR *dom_name, ST_CHAR *ctrl_name, float32_t fctlVal, ST_BOOLEAN Check, int iTimeOut);
int mms_iec_control (ST_UCHAR ctlModel,MVL_NET_INFO *clientNetInfo,
ST_CHAR *dom_name, ST_CHAR *ctrl_name, int ictlVal, ST_BOOLEAN Check, int iTimeOut);
int mms_iec_control_yt (ST_UCHAR ctlModel,MVL_NET_INFO *clientNetInfo,
ST_CHAR *dom_name, ST_CHAR *ctrl_name, int ictlVal, ST_BOOLEAN Check, int iTimeOut);
ST_INT mms_get_datatype_from_type_id (ST_INT type_id, ST_UCHAR* datatype,ST_INT *len);
void convert_apr_time_to_utc_time(apr_time_t tm,MMS_UTC_TIME *utc_time);
ST_RET my_asn1_convert_utc_to_btod (MMS_UTC_TIME *utc, MMS_BTOD *btod);
apr_time_t convert_btod_to_apr_time (MMS_BTOD *btod );
apr_time_t convert_btime6_to_apr_time (MMS_BTIME6 *bTime6 );
#endif //SAC_INTERFACE_H

219
mms/logcfg.xml Normal file
View File

@@ -0,0 +1,219 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v4.0 (http://www.xmlspy.com) (SISCO/Engineering) -->
<!-- ****************************************************************** -->
<!-- * SISCO MODULE HEADER ******************************************** -->
<!-- ****************************************************************** -->
<!-- * (c) Copyright Systems Integration Specialists Company, Inc., -->
<!-- * 2001 - 2003, All Rights Reserved -->
<!-- * -->
<!-- * MODULE NAME : LogCfg.xml -->
<!-- * PRODUCT(S) : MMS-Lite -->
<!-- * -->
<!-- * MODULE DESCRIPTION : Logging Configuration File -->
<!-- * -->
<!-- * This file is used to set the log masks used to control -->
<!-- * logging performed by the MMS-EASE Lite Debug Libraries, -->
<!-- * as well as to set memory debug flags. This module is -->
<!-- * read by the source module 'logcfgx.c'. -->
<!-- * -->
<!-- * MODIFICATION LOG : -->
<!-- * Date Who Rev Comments -->
<!-- * ======= ===== === ========================== -->
<!-- * 01/27/04 ASK 09 Commented out DTD and Schema references -->
<!-- * 09/05/03 EJV 08 Added security, semaphore, socket log masks -->
<!-- * Added COSP_LOG_..., COPP_LOG_... masks -->
<!-- * Rem ACSE_xxx_PRINT masks (osiul.lib only) -->
<!-- * 11/01/01 GLB 07 Added schema file -->
<!-- * 03/13/01 GLB 06 Added SX_LOG_... masks -->
<!-- * 02/22/01 GLB 05 Added MVLULOG_... masks -->
<!-- * 01/04/01 GLB 04 Added for MARBEN stack: -->
<!-- * ACSE_ERR_PRINT, ACSE_NERR_PRINT -->
<!-- * 11/29/00 GLB 03 Correct connection to DTD -->
<!-- * 11/29/00 GLB 02 Change logMemoryItems to logMemorySize -->
<!-- * 11/17/00 GLB 01 Created -->
<!-- ****************************************************************** -->
<!-- Uncomment to use DTD / Schema
<!DOCTYPE LOG_CFG SYSTEM "..\logcfg.dtd">
<LOG_CFG xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="..\logcfg.xsd">
-->
<LOG_CFG>
<SxLogMasks>
<SX_LOG_NERR>ON</SX_LOG_NERR>
<SX_LOG_DEC>OFF</SX_LOG_DEC>
<SX_LOG_ENC>OFF</SX_LOG_ENC>
<SX_LOG_FLOW>OFF</SX_LOG_FLOW>
<SX_LOG_DEBUG>OFF</SX_LOG_DEBUG>
</SxLogMasks>
<LogControl>
<LogFileAttributes>
<LogFileEnable>ON</LogFileEnable>
<LogFileSize>1000000</LogFileSize>
<LogFileName>mms.log</LogFileName>
</LogFileAttributes>
<LogMemoryAttributes>
<LogMemoryEnable>OFF</LogMemoryEnable>
<LogMemoryItems>1000</LogMemoryItems>
<MemoryFileName>mmsdmem.log</MemoryFileName>
<MemoryFileDump>OFF</MemoryFileDump>
</LogMemoryAttributes>
<MiscControlFlags>
<TimeEnable>TimeDate</TimeEnable>
<DestroyOldFile>ON</DestroyOldFile>
<Setbuf>OFF</Setbuf>
<MsgHeader>ON</MsgHeader>
<Wipe>ON</Wipe>
<Wrap>ON</Wrap>
<HardFlush>OFF</HardFlush>
<HeaderCr>ON</HeaderCr>
<HeaderFilename>ON</HeaderFilename>
<HeaderLogType>ON</HeaderLogType>
</MiscControlFlags>
</LogControl>
<UserLogMasks>
<USER_LOG_CLIENT>OFF</USER_LOG_CLIENT>
<USER_LOG_SERVER>OFF</USER_LOG_SERVER>
</UserLogMasks>
<SecurityLogMasks>
<!-- ssec.lib and secMan.lib logging -->
<SEC_LOG_NERR>ON</SEC_LOG_NERR>
<SEC_LOG_FLOW>OFF</SEC_LOG_FLOW>
<SEC_LOG_DATA>OFF</SEC_LOG_DATA>
<SEC_LOG_DEBUG>OFF</SEC_LOG_DEBUG>
<!-- sslEngine.lib logging -->
<SSLE_LOG_NERR>ON</SSLE_LOG_NERR>
<SSLE_LOG_FLOW>OFF</SSLE_LOG_FLOW>
<SSLE_LOG_DATA>OFF</SSLE_LOG_DATA>
<SSLE_LOG_DEBUG>OFF</SSLE_LOG_DEBUG>
</SecurityLogMasks>
<SemaphoreLogMasks>
<!-- semaphore/thread logging -->
<GS_LOG_NERR>OFF</GS_LOG_NERR>
<GS_LOG_FLOW>OFF</GS_LOG_FLOW>
</SemaphoreLogMasks>
<Asn1LogMasks>
<ASN1_LOG_NERR>ON</ASN1_LOG_NERR>
<ASN1_LOG_DEC>OFF</ASN1_LOG_DEC>
<ASN1_LOG_ENC>OFF</ASN1_LOG_ENC>
</Asn1LogMasks>
<MmsLogMasks>
<MMS_LOG_NERR>ON</MMS_LOG_NERR>
<MMS_LOG_DEC>OFF</MMS_LOG_DEC>
<MMS_LOG_ENC>OFF</MMS_LOG_ENC>
<MMS_LOG_RT>OFF</MMS_LOG_RT>
<MMS_LOG_RTAA>OFF</MMS_LOG_RTAA>
<MMS_LOG_AA>OFF</MMS_LOG_AA>
</MmsLogMasks>
<MvlLogMasks>
<MVLLOG_NERR>ON</MVLLOG_NERR>
<MVLLOG_ACSE>OFF</MVLLOG_ACSE>
<MVLLOG_ACSEDATA>OFF</MVLLOG_ACSEDATA>
<MVLULOG_FLOW>OFF</MVLULOG_FLOW>
<MVLULOG_DEBUG>OFF</MVLULOG_DEBUG>
<MVLULOG_TIMING>OFF</MVLULOG_TIMING>
</MvlLogMasks>
<AcseLogMasks>
<ACSE_LOG_ENC>OFF</ACSE_LOG_ENC>
<ACSE_LOG_DEC>OFF</ACSE_LOG_DEC>
<COPP_LOG_DEC>OFF</COPP_LOG_DEC>
<COPP_LOG_DEC_HEX>OFF</COPP_LOG_DEC_HEX>
<COPP_LOG_ENC>OFF</COPP_LOG_ENC>
<COPP_LOG_ENC_HEX>OFF</COPP_LOG_ENC_HEX>
<COSP_LOG_DEC>OFF</COSP_LOG_DEC>
<COSP_LOG_DEC_HEX>OFF</COSP_LOG_DEC_HEX>
<COSP_LOG_ENC>OFF</COSP_LOG_ENC>
<COSP_LOG_ENC_HEX>OFF</COSP_LOG_ENC_HEX>
</AcseLogMasks>
<Tp4LogMasks>
<TP4_LOG_FLOWUP>OFF</TP4_LOG_FLOWUP>
<TP4_LOG_FLOWDOWN>OFF</TP4_LOG_FLOWDOWN>
</Tp4LogMasks>
<ClnpLogMasks>
<CLNP_LOG_NERR>OFF</CLNP_LOG_NERR>
<CLNP_LOG_REQ>OFF</CLNP_LOG_REQ>
<CLNP_LOG_IND>OFF</CLNP_LOG_IND>
<CLSNS_LOG_REQ>OFF</CLSNS_LOG_REQ>
<CLSNS_LOG_IND>OFF</CLSNS_LOG_IND>
</ClnpLogMasks>
<SocketLogMasks>
<!-- gensock2 logging -->
<SOCK_LOG_NERR>OFF</SOCK_LOG_NERR>
<SOCK_LOG_FLOW>OFF</SOCK_LOG_FLOW>
<SOCK_LOG_TX>OFF</SOCK_LOG_TX>
<SOCK_LOG_RX>OFF</SOCK_LOG_RX>
</SocketLogMasks>
<AdlcLogMasks>
<ADLC_LOG_NERR>ON</ADLC_LOG_NERR>
<ADLC_LOG_FLOW>OFF</ADLC_LOG_FLOW>
<ADLC_LOG_IO>OFF</ADLC_LOG_IO>
<ADLC_LOG_HEXIO>OFF</ADLC_LOG_HEXIO>
<ADLC_LOG_SM>OFF</ADLC_LOG_SM>
<ADLC_LOG_HEXSM>OFF</ADLC_LOG_HEXSM>
<ADLC_LOG_USER>OFF</ADLC_LOG_USER>
<ADLC_LOG_HEXUSER>OFF</ADLC_LOG_HEXUSER>
</AdlcLogMasks>
<SmpLogMasks>
<SMP_LOG_REQ>OFF</SMP_LOG_REQ>
<SMP_LOG_IND>OFF</SMP_LOG_IND>
</SmpLogMasks>
<MemLogMasks>
<MEM_LOG_CALLOC>OFF</MEM_LOG_CALLOC>
<MEM_LOG_MALLOC>OFF</MEM_LOG_MALLOC>
<MEM_LOG_REALLOC>OFF</MEM_LOG_REALLOC>
<MEM_LOG_FREE>OFF</MEM_LOG_FREE>
</MemLogMasks>
<MemAllocDbgCtrl>
<MemFillEnable>OFF</MemFillEnable>
<MemHeapCheck>OFF</MemHeapCheck>
<MemCheckList>OFF</MemCheckList>
<MemFindNode>OFF</MemFindNode>
<MemTrackPrevFree>OFF</MemTrackPrevFree>
<MemNoReallocSmaller>OFF</MemNoReallocSmaller>
</MemAllocDbgCtrl>
</LOG_CFG>
<!--##################### GENERAL LOG CONTROL ####################
#
# Log File Attributes
# FileLogEn # Log to a file - ON/OFF
# LogFileSize= 1000000 # 0 to 32767
# LogFileName= mms.log # character string, up to 256 characters
#
#
# Memory Resident Logging Attributes
# MemLogEn # Log to memory - ON/OFF
# LogMemItems= 1000 # 0 to 32767
# DumpFileName= mmsdmem.log # character string, 0 to 256
# MemAutoDump # dump what is in memory to file
# configured as "DumpFileName"
# when "LogMenuItems" limit is reached
#
#
# Misc. Control Flags
# TimeEnable # print in log file :
# TimeDate = Time of day and date
# ElapsedTime = Elapsed time in ms
# DestroyOldFile # ON = destroy existing file
# OFF = append to existing file
# Setbuf # use setbuf(fh,NULL) after file open - ON/OFF
# Msgheader # print message header in log file - ON/OFF
# Wipe # wipe bar in wrapped log file - ON/OFF
# Wrap # wrap log file - ON/OFF
# HardFlush # close and reopen log file each time a message is logged - ON/OFF
# HeaderCr # CR after header line in log file - ON/OFF
# HeaderFilename # filename or line number printed in log file - ON/OFF
# HeaderLogtype # log type printed in log file header - ON/OFF
#
# Integrity checking on memory allocation
# (Not really related to logging, but no better place to put it.)
# MemFillEn # ON/OFF
# MemHeapCheck # ON/OFF
# CheckListEnable # ON/OFF
# FindNodeEnable # ON/OFF
# TrackPrevFree # ON/OFF
# ListDebugSel # ON/OFF
# NoReallocSmaller # ON/OFF
#
#################################################################
-->

645
mms/logcfgx.c Normal file
View File

@@ -0,0 +1,645 @@
/**
* @file: $RCSfile: logcfgx.c,v $
* @brief: $IEC 61850 Protocol
*
* @version: $Revision: 1.1 $
* @date: $Date: 2018/11/24 06:54:50 $
* @author: $Author: lizhongming $
* @state: $State: Exp $
*
* @latest: $Id: logcfgx.c,v 1.1 2018/11/24 06:54:50 lizhongming Exp $
*
*/
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 2000 - 2005, All Rights Reserved */
/* */
/* MODULE NAME : logcfgx.c */
/* PRODUCT(S) : */
/* */
/* MODULE DESCRIPTION : This module processes each value parsed in */
/* the logcfg.xml file . The logcfg.xml file */
/* assigns Log File Attributes and */
/* Miscellaneous Control Flags as well as */
/* Memory Use Logging and various Log Masks */
/* to enable specific logging required. */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ -------------------------------------------- */
/* 08/10/05 MDE 13 Added logCfgRemoveAllMaskGroups */
/* 06/21/05 EJV 12 Deleted obsolete logcfgx function. */
/* 05/23/05 EJV 11 Moved xxxLogMaskMapCtrl to respective C files.*/
/* Del m_track_prev_free (not used anymore). */
/* Force user to use logcfgx_ex insted of logcfgx*/
/* 04/25/05 MDE 10 Added MMS_LOG_CLIENT & MMS_LOG_SERVER */
/* 03/31/05 MDE 09 Put suicacse.h back, for MAP30_ACSE */
/* 03/28/05 JRB 08 Del suicacse header. */
/* 02/10/05 MDE 07 Changed MILOG_ to MI_LOG_ */
/* 02/10/05 MDE 06 Added new DATATYPE's */
/* 01/27/05 MDE 05 DEBUG_SISCO #ifdefs, LINUX warning cleanup */
/* 01/20/05 MDE 04 Lot's more work ... */
/* 12/10/04 ASK 03 Added Slog IPC params, added */
/* case _LOGCFG_DATATYPE_UINT32_MASK */
/* Modify params to use 'R'everse data type */
/* Update copyright year */
/* 11/16/04 MDE 02 Fixed to compile with MAP30_ACSE */
/* 10/12/04 MDE 01 Complete rewrite to work with SX changes, */
/* make extendable */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mem_chk.h"
#include "gen_list.h"
#include "str_util.h"
#include "slog.h"
#include "sx_defs.h"
#include "sx_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
#if defined(DEBUG_SISCO)
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
LOGCFG_VALUE_GROUP *logCfgLogMaskGroupList;
static LOGCFGX_TAG_VAL *_tagValList;
/************************************************************************/
#if defined(DEBUG_SISCO)
static LOG_CTRL tmp_sLogCtrl;
ST_UINT logcfg_debug_sel;
/* Log type strings */
SD_CONST ST_CHAR *SD_CONST _logcfg_log_err_logstr = "LOGCFG_ERR";
SD_CONST ST_CHAR *SD_CONST _logcfg_log_nerr_logstr = "LOGCFG_NERR";
SD_CONST ST_CHAR *SD_CONST _logcfg_log_flow_logstr = "LOGCFG_FLOW";
LOGCFGX_VALUE_MAP logcfgMaskMaps[] =
{
{"LOGCFG_ERR", LOGCFG_ERR, &logcfg_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Error"},
{"LOGCFG_NERR", LOGCFG_NERR, &logcfg_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Notice"},
{"LOGCFG_FLOW", LOGCFG_FLOW, &logcfg_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Flow"}
};
LOGCFG_VALUE_GROUP logcfgMaskMapCtrl =
{
{NULL,NULL},
"LOGCFG",
sizeof(logcfgMaskMaps)/sizeof(LOGCFGX_VALUE_MAP),
logcfgMaskMaps
};
/************************************************************************/
/************************************************************************/
LOGCFGX_VALUE_MAP logCfgLogMaskMaps[] =
{
/* SLOG Control */
{"LogFileEnable", LOG_FILE_EN, &tmp_sLogCtrl.logCtrl, _LOGCFG_DATATYPE_UINT32_MASK},
{"DestroyOldFile", FIL_CTRL_NO_APPEND, &tmp_sLogCtrl.fc.ctrl, _LOGCFG_DATATYPE_UINT_MASK},
{"Setbuf", FIL_CTRL_SETBUF_EN, &tmp_sLogCtrl.fc.ctrl, _LOGCFG_DATATYPE_UINT_MASK},
{"MsgHeader", FIL_CTRL_MSG_HDR_EN, &tmp_sLogCtrl.fc.ctrl, _LOGCFG_DATATYPE_UINT_MASK},
{"Wipe", FIL_CTRL_WIPE_EN, &tmp_sLogCtrl.fc.ctrl, _LOGCFG_DATATYPE_UINT_MASK},
{"Wrap", FIL_CTRL_WRAP_EN, &tmp_sLogCtrl.fc.ctrl, _LOGCFG_DATATYPE_UINT_MASK},
{"HardFlush", FIL_CTRL_HARD_FLUSH, &tmp_sLogCtrl.fc.ctrl, _LOGCFG_DATATYPE_UINT_MASK},
{"LogMemoryEnable", LOG_MEM_EN, &tmp_sLogCtrl.logCtrl, _LOGCFG_DATATYPE_UINT32_MASK},
{"MemoryFileDump", MEM_CTRL_AUTODUMP_EN, &tmp_sLogCtrl.mc.ctrl, _LOGCFG_DATATYPE_UINT_MASK},
{"LogIpcListenEnable", LOG_IPC_LISTEN_EN, &tmp_sLogCtrl.logCtrl, _LOGCFG_DATATYPE_UINT32_MASK},
{"LogIpcCallEnable", LOG_IPC_CALL_EN, &tmp_sLogCtrl.logCtrl, _LOGCFG_DATATYPE_UINT32_MASK},
{"LogIpcSmartMode", LOG_IPC_SMART, &tmp_sLogCtrl.logCtrl, _LOGCFG_DATATYPE_UINT32_MASK},
{"HeaderCr", LOG_NO_HEADER_CR, &tmp_sLogCtrl.logCtrl, _LOGCFG_DATATYPE_RUINT32_MASK},
{"HeaderFilename", LOG_FILENAME_SUPPRESS, &tmp_sLogCtrl.logCtrl, _LOGCFG_DATATYPE_RUINT32_MASK},
{"HeaderLogType", LOG_LOGTYPE_SUPPRESS, &tmp_sLogCtrl.logCtrl, _LOGCFG_DATATYPE_RUINT32_MASK},
{"LogFileSize", 0, &tmp_sLogCtrl.fc.maxSize, _LOGCFG_DATATYPE_ULONG},
{"LogFileName", 0, &tmp_sLogCtrl.fc.fileName, _LOGCFG_DATATYPE_FILENAME},
{"LogMemoryItems", 0, &tmp_sLogCtrl.mc.maxItems, _LOGCFG_DATATYPE_ULONG},
{"MemoryFileName", 0, &tmp_sLogCtrl.mc.dumpFileName, _LOGCFG_DATATYPE_FILENAME},
{"LogIpcAppId", 0, &tmp_sLogCtrl.ipc.appId, _LOGCFG_DATATYPE_STRING},
{"LogIpcListenPort", 0, &tmp_sLogCtrl.ipc.port, _LOGCFG_DATATYPE_UINT16},
{"LogIpcNumListenPorts", 0, &tmp_sLogCtrl.ipc.portCnt, _LOGCFG_DATATYPE_UINT16},
{"LogIpcMaxListenConn", 0, &tmp_sLogCtrl.ipc.maxConns, _LOGCFG_DATATYPE_UINT},
{"LogIpcCallingPort", 0, &tmp_sLogCtrl.ipc.callingPort, _LOGCFG_DATATYPE_UINT16},
{"LogIpcCallingIp", 0, &tmp_sLogCtrl.ipc.callingIp, _LOGCFG_DATATYPE_STRING},
{"LogIpcMaxQueCount", 0, &tmp_sLogCtrl.ipc.maxQueCnt, _LOGCFG_DATATYPE_UINT},
};
LOGCFG_VALUE_GROUP logCfgLogCtrlMapCtrl =
{
{NULL,NULL},
"",
sizeof(logCfgLogMaskMaps)/sizeof(LOGCFGX_VALUE_MAP),
logCfgLogMaskMaps
};
#endif /* defined(DEBUG_SISCO) */
/************************************************************************/
/************************************************************************/
static ST_RET _logcfg_data_start (SX_DEC_CTRL *sxDecCtrl, ST_CHAR *tag);
static ST_RET _logcfg_data_end (SX_DEC_CTRL *sxDecCtrl, ST_CHAR *tag);
/************************************************************************/
/* logCfgAddMaskGroup */
/************************************************************************/
ST_VOID logCfgAddMaskGroup (LOGCFG_VALUE_GROUP *logMaskGroup)
{
if (list_find_node (logCfgLogMaskGroupList, logMaskGroup) != SD_SUCCESS)
list_add_last (&logCfgLogMaskGroupList, logMaskGroup);
}
/************************************************************************/
/* logCfgRemoveMaskGroup */
/************************************************************************/
ST_VOID logCfgRemoveMaskGroup (LOGCFG_VALUE_GROUP *logMaskGroup)
{
if (list_find_node (logCfgLogMaskGroupList, logMaskGroup) == SD_SUCCESS)
list_unlink (&logCfgLogMaskGroupList, logMaskGroup);
}
/************************************************************************/
/* logCfgRemoveAllMaskGroups */
/************************************************************************/
ST_VOID logCfgRemoveAllMaskGroups ()
{
logCfgLogMaskGroupList = NULL;
}
/************************************************************************/
/* logCfgFindTagVal */
/************************************************************************/
LOGCFGX_TAG_VAL *logCfgFindTagVal (ST_CHAR *tag)
{
LOGCFGX_TAG_VAL *tagVal;
tagVal = _tagValList;
while (tagVal != NULL)
{
if (!strcmp (tag, tagVal->tag))
return (tagVal);
tagVal =(LOGCFGX_TAG_VAL*) list_get_next (_tagValList, tagVal);
}
return (NULL);
}
/************************************************************************/
/* logCfgClearTagVals */
/************************************************************************/
ST_VOID logCfgClearTagVals ()
{
LOGCFGX_TAG_VAL *tagVal;
while (_tagValList)
{
tagVal = (LOGCFGX_TAG_VAL *) list_unlink (&_tagValList, _tagValList);
if (tagVal->dataType == _LOGCFG_DATATYPE_STRING ||
tagVal->dataType == _LOGCFG_DATATYPE_FILENAME)
{
chk_free (tagVal->u.str);
}
chk_free (tagVal);
}
}
/************************************************************************/
/************************************************************************/
/* logcfgx_ex */
/* User must call logCfgAddMaskGroup for each group of log masks to be */
/* configured BEFORE calling this function to parse the file. */
/************************************************************************/
typedef struct
{
LOG_CTRL *destLogCtrl;
ST_INT state;
ST_CHAR *logFileName;
ST_CHAR *fileNamePrefix;
ST_BOOLEAN masksOnly;
ST_BOOLEAN saveTagVals;
} LOGCFGX_CTRL;
ST_RET logcfgx_ex (LOG_CTRL *destLogCtrl, ST_CHAR *logFileName, ST_CHAR *fileNamePrefix,
ST_BOOLEAN masksOnly, ST_BOOLEAN saveTagVals)
{
LOGCFGX_CTRL logCfgxCtrl;
ST_UINT sx_debug_sel_save;
ST_RET rc;
#if defined(DEBUG_SISCO)
ST_CHAR *savedFileName;
#endif
logCfgxCtrl.destLogCtrl = destLogCtrl;
logCfgxCtrl.logFileName = logFileName;
logCfgxCtrl.fileNamePrefix = fileNamePrefix;
logCfgxCtrl.masksOnly = masksOnly;
logCfgxCtrl.saveTagVals = saveTagVals;
#if defined(DEBUG_SISCO)
logcfg_debug_sel |= LOGCFG_ERR;
logcfg_debug_sel |= LOGCFG_NERR;
sx_debug_sel |= SX_LOG_ERR;
sx_debug_sel |= SX_LOG_NERR;
if (masksOnly)
logCfgRemoveMaskGroup (&logCfgLogCtrlMapCtrl);
else
logCfgAddMaskGroup (&logCfgLogCtrlMapCtrl);
/* Always allow LOGCFG & SX logging ... */
logCfgAddMaskGroup (&logcfgMaskMapCtrl);
logCfgAddMaskGroup (&sxLogMaskMapCtrl);
savedFileName = sLogCtrl->fc.fileName;
/* Copy original "sLogCtrl" to temporary struct which may be modified */
/* by the configuration. */
/* This prevents logging control changes while there may be logging. */
memcpy (&tmp_sLogCtrl, sLogCtrl, sizeof (LOG_CTRL));
#endif
rc = sx_parseEx_mt (logFileName, 0, NULL, &logCfgxCtrl, _logcfg_data_start, _logcfg_data_end);
if (rc != SD_SUCCESS)
{
/* Config failed: Do not modify "sLogCtrl". */
/* Turn on cfg logging and parse file again. */
sx_debug_sel_save = sx_debug_sel;
sx_debug_sel |= SX_LOG_DEC | SX_LOG_ENC | SX_LOG_FLOW | SX_LOG_DEBUG;
LOGCFG_ERR0 ("ERROR Parsing Logging Configuration File: Trying again w/debug on ... ");
rc = sx_parseEx_mt (logFileName, 0,NULL,&logCfgxCtrl, _logcfg_data_start, _logcfg_data_end);
sx_debug_sel = sx_debug_sel_save;
}
else /* rc == SD_SUCCESS */
{
LOGCFG_FLOW0 ("Logging configuration complete");
}
return (rc);
}
/************************************************************************/
/************************************************************************/
/* _logcfg_data_start */
/************************************************************************/
#define LOGCFGX_STATE_NONE 0
#define LOGCFGX_STATE_UNKNOWN 1
#define LOGCFGX_STATE_LOGCTRL 2
#define LOGCFGX_STATE_LOGMASKS 3
static ST_RET _logcfg_data_start (SX_DEC_CTRL *sxDecCtrl, ST_CHAR *tag)
{
LOGCFGX_CTRL *logCfgxCtrl;
logCfgxCtrl =(LOGCFGX_CTRL*) sxDecCtrl->usr;
if (!strcmp (tag, "LogControl"))
logCfgxCtrl->state = LOGCFGX_STATE_LOGCTRL;
else if (!strcmp (tag, "LogMasks"))
logCfgxCtrl->state = LOGCFGX_STATE_LOGMASKS;
return (SD_SUCCESS);
}
/************************************************************************/
/* _logcfg_data_end */
/************************************************************************/
static ST_RET _logcfg_data_end (SX_DEC_CTRL *sxDecCtrl, ST_CHAR *tag)
{
LOGCFGX_CTRL *logCfgxCtrl;
LOGCFG_VALUE_GROUP *slogMaskGroup;
LOG_CTRL *destLogCtrl;
LOGCFGX_TAG_VAL *tagVal;
SX_DEC_ELEMENT_INFO *sxDecElInfo;
ST_VOID (*logCfgCallbackFun) (SX_DEC_CTRL *sxDecCtrl, ST_CHAR *tag,
LOGCFGX_VALUE_MAP *valMap);
ST_CHAR *cp;
ST_CHAR *str;
ST_BOOLEAN *bp;
ST_BOOLEAN b;
ST_INT i;
ST_INT strLen;
ST_RET rc;
ST_UINT *up;
ST_UINT32 *u32p;
ST_UINT16 *u16p;
ST_ULONG *ulp;
ST_CHAR **cpp;
ST_DOUBLE *dp;
#if defined(DEBUG_SISCO)
ST_CHAR *oldFileName;
ST_BOOLEAN logFileChanged;
#endif
ST_BOOLEAN found;
ST_CHAR *p;
logCfgxCtrl =(LOGCFGX_CTRL*) sxDecCtrl->usr;
if (!strcmp (tag, "LogMasks"))
{
logCfgxCtrl->state = LOGCFGX_STATE_NONE;
return (SD_SUCCESS);
}
destLogCtrl = logCfgxCtrl->destLogCtrl;
sxDecElInfo = &sxDecCtrl->sxDecElInfo;
if (!strcmp (tag, "LogControl"))
{
#if defined(DEBUG_SISCO)
logFileChanged = SD_FALSE;
if (logCfgxCtrl->masksOnly == SD_FALSE)
{
/* If the log file name has changed and the log file is open, */
/* close the log file and clear state. */
if (destLogCtrl->fc.state & FIL_STATE_OPEN)
{
oldFileName = destLogCtrl->fc.fileName;
#ifdef _WIN32 /* Filenames NOT case sensitive on Windows */
if (_stricmp (tmp_sLogCtrl.fc.fileName, oldFileName) != 0)
#else
if (strcmp (tmp_sLogCtrl.fc.fileName, oldFileName) != 0)
#endif
{ /* NEW log file name different from OLD. */
fclose (destLogCtrl->fc.fp); /* close it */
destLogCtrl->fc.state &= ~(FIL_STATE_OPEN); /* clear state */
logFileChanged = SD_TRUE;
}
}
if (tmp_sLogCtrl.fc.ctrl & FIL_CTRL_MSG_HDR_EN)
tmp_sLogCtrl.mc.ctrl |= MEM_CTRL_MSG_HDR_EN;
else
tmp_sLogCtrl.mc.ctrl &= ~MEM_CTRL_MSG_HDR_EN;
destLogCtrl->logCtrl = tmp_sLogCtrl.logCtrl;
destLogCtrl->fc.ctrl = tmp_sLogCtrl.fc.ctrl;
destLogCtrl->fc.fileName = tmp_sLogCtrl.fc.fileName;
destLogCtrl->fc.maxSize = tmp_sLogCtrl.fc.maxSize;
destLogCtrl->mc.ctrl = tmp_sLogCtrl.mc.ctrl;
destLogCtrl->mc.dumpFileName = tmp_sLogCtrl.mc.dumpFileName;
destLogCtrl->mc.maxItems = tmp_sLogCtrl.mc.maxItems;
destLogCtrl->ipc.appId = tmp_sLogCtrl.ipc.appId;
destLogCtrl->ipc.port = tmp_sLogCtrl.ipc.port;
destLogCtrl->ipc.portCnt = tmp_sLogCtrl.ipc.portCnt;
destLogCtrl->ipc.maxConns = tmp_sLogCtrl.ipc.maxConns;
destLogCtrl->ipc.callingIp = tmp_sLogCtrl.ipc.callingIp;
destLogCtrl->ipc.callingPort = tmp_sLogCtrl.ipc.callingPort;
destLogCtrl->ipc.maxQueCnt = tmp_sLogCtrl.ipc.maxQueCnt;
}
LOGCFG_FLOW2 ("LogCfg loading file %s, prefix %s",
logCfgxCtrl->logFileName, logCfgxCtrl->fileNamePrefix);
if (logFileChanged)
{
_slog (destLogCtrl,_logcfg_log_flow_logstr, thisFileName,__LINE__,
"See the file '%s' for messages logged before or during Logging config",
oldFileName);
}
#endif
logCfgxCtrl->state = LOGCFGX_STATE_NONE;
return (SD_SUCCESS);
}
/* Get the pointer to the contents */
strLen = 0;
rc = sx_get_string_ptr (sxDecCtrl, &str, &strLen);
if (rc != SD_SUCCESS)
return (rc);
/* OK, this might be an Log Mask or other value of interest */
/* If we are to save this in a list, start here */
if (logCfgxCtrl->saveTagVals && logCfgxCtrl->state == LOGCFGX_STATE_LOGMASKS)
{
tagVal = logCfgFindTagVal (tag);
if (tagVal)
{
list_unlink (&_tagValList, tagVal);
if (tagVal->dataType == _LOGCFG_DATATYPE_STRING ||
tagVal->dataType == _LOGCFG_DATATYPE_FILENAME)
{
chk_free (tagVal->u.str);
}
chk_free (tagVal);
}
tagVal = (LOGCFGX_TAG_VAL*)chk_calloc (1, sizeof (LOGCFGX_TAG_VAL) + strlen (tag) + 1);
p = (ST_CHAR *) (tagVal + 1);
tagVal->tag = p;
strcpy (p, tag);
list_add_last (&_tagValList, tagVal);
}
else
tagVal = NULL;
/* Now see if we can find it ... */
found = SD_FALSE;
slogMaskGroup = logCfgLogMaskGroupList;
while (slogMaskGroup)
{
for (i = 0; i < slogMaskGroup->numMaskMap; ++i)
{
if (!strcmp (tag, slogMaskGroup->maskMapTbl[i].tag))
{
found = SD_TRUE;
if (tagVal != NULL)
tagVal->dataType = slogMaskGroup->maskMapTbl[i].dataType;
switch (slogMaskGroup->maskMapTbl[i].dataType)
{
case _LOGCFG_DATATYPE_UINT_MASK:
up =(ST_UINT*) slogMaskGroup->maskMapTbl[i].addr;
sx_get_string_OnOff_bool (sxDecCtrl, &b, SX_ERR_CONVERT);
if (b)
*up |= slogMaskGroup->maskMapTbl[i].mask; /* Set the bit */
else
*up &= ~slogMaskGroup->maskMapTbl[i].mask; /* Clear the bit */
LOGCFG_CFLOW2 ("Setting log mask %-16s %s", tag, b ? "ON" : "OFF");
if (tagVal != NULL)
tagVal->u.b = b;
break;
case _LOGCFG_DATATYPE_UINT32_MASK:
u32p =(ST_UINT32 *) slogMaskGroup->maskMapTbl[i].addr;
sx_get_string_OnOff_bool (sxDecCtrl, &b, SX_ERR_CONVERT);
if (b)
*u32p |= slogMaskGroup->maskMapTbl[i].mask; /* Set the bit */
else
*u32p &= ~slogMaskGroup->maskMapTbl[i].mask; /* Clear the bit */
LOGCFG_CFLOW2 ("Setting log mask %-16s %s", tag, b ? "ON" : "OFF");
if (tagVal != NULL)
tagVal->u.b = b;
break;
/* 'R'everse mask settings */
case _LOGCFG_DATATYPE_RUINT32_MASK:
up =(ST_UINT *) slogMaskGroup->maskMapTbl[i].addr;
sx_get_string_OnOff_bool (sxDecCtrl, &b, SX_ERR_CONVERT);
if (b)
*up &= ~slogMaskGroup->maskMapTbl[i].mask; /* Clear the bit */
else
*up |= slogMaskGroup->maskMapTbl[i].mask; /* Set the bit */
LOGCFG_CFLOW2 ("Setting log mask %-16s %s", tag, b ? "ON" : "OFF");
if (tagVal != NULL)
tagVal->u.b = b;
break;
case _LOGCFG_DATATYPE_BOOLEAN:
bp = (ST_BOOLEAN *) slogMaskGroup->maskMapTbl[i].addr;
sx_get_string_OnOff_bool (sxDecCtrl, bp, SX_ERR_CONVERT);
LOGCFG_CFLOW2 ("Setting boolean %-16s %s", tag, *bp ? "ON" : "OFF");
if (tagVal != NULL)
tagVal->u.b = *bp;
break;
case _LOGCFG_DATATYPE_INT:
case _LOGCFG_DATATYPE_UINT:
up =(ST_UINT *) slogMaskGroup->maskMapTbl[i].addr;
sx_get_uint (sxDecCtrl, up);
LOGCFG_CFLOW2 ("Setting %16s to %d", tag, (int) *up);
if (tagVal != NULL)
tagVal->u.uInt = *up;
break;
case _LOGCFG_DATATYPE_LONG:
case _LOGCFG_DATATYPE_ULONG:
ulp =(ST_ULONG *) slogMaskGroup->maskMapTbl[i].addr;
sx_get_ulong (sxDecCtrl, ulp);
LOGCFG_CFLOW2 ("Setting %16s to %ld", tag, (long int) *ulp);
if (tagVal != NULL)
tagVal->u.uLong = *ulp;
break;
case _LOGCFG_DATATYPE_INT16:
case _LOGCFG_DATATYPE_UINT16:
u16p =(ST_UINT16*) slogMaskGroup->maskMapTbl[i].addr;
sx_get_uint16 (sxDecCtrl, u16p);
LOGCFG_CFLOW2 ("Setting %16s to %d", tag, (int) *u16p);
if (tagVal != NULL)
tagVal->u.uInt16 = *u16p;
break;
case _LOGCFG_DATATYPE_INT32:
case _LOGCFG_DATATYPE_UINT32:
u32p = (ST_UINT32 *)slogMaskGroup->maskMapTbl[i].addr;
sx_get_ulong (sxDecCtrl, u32p);
LOGCFG_CFLOW2 ("Setting %16s to %d", tag, (int) *u32p);
if (tagVal != NULL)
tagVal->u.uInt32 = *u32p;
break;
case _LOGCFG_DATATYPE_DOUBLE:
dp =(ST_DOUBLE *) slogMaskGroup->maskMapTbl[i].addr;
sx_get_double (sxDecCtrl, dp);
LOGCFG_CFLOW2 ("Setting %16s to %.4f", tag, *dp);
if (tagVal != NULL)
tagVal->u.uInt32 = *u32p;
break;
case _LOGCFG_DATATYPE_STRING:
cpp =(ST_CHAR **) slogMaskGroup->maskMapTbl[i].addr;
sx_get_alloc_string (sxDecCtrl, cpp);
LOGCFG_CFLOW2 ("Setting %16s to '%s'", tag, *cpp);
if (tagVal != NULL)
tagVal->u.str = *cpp;
break;
case _LOGCFG_DATATYPE_STRINGBUF:
cp =(ST_CHAR *) slogMaskGroup->maskMapTbl[i].addr;
strLen = 0;
sx_get_string_ptr (sxDecCtrl, &str, &strLen);
LOGCFG_CFLOW2 ("Setting %16s to '%s'", tag, str);
cp =(ST_CHAR *) slogMaskGroup->maskMapTbl[i].addr;
strncpy_safe (cp, str, slogMaskGroup->maskMapTbl[i].mask);
if (tagVal != NULL)
tagVal->u.str = cp;
break;
case _LOGCFG_DATATYPE_FILENAME:
cpp = (ST_CHAR **)slogMaskGroup->maskMapTbl[i].addr;
/* The user might want a prefix for this file name */
strLen = 0;
sx_get_string_ptr (sxDecCtrl, &str, &strLen);
if (logCfgxCtrl->fileNamePrefix)
strLen += strlen (logCfgxCtrl->fileNamePrefix);
p =(ST_CHAR *) chk_malloc (strLen+1);
*cpp = p;
if (logCfgxCtrl->fileNamePrefix)
strcpy (p, logCfgxCtrl->fileNamePrefix);
else
*p = 0;
strcat (p, str);
LOGCFG_CFLOW2 ("Setting %-16s to '%s'", tag, p);
if (tagVal != NULL)
tagVal->u.str = p;
break;
case _LOGCFG_DATATYPE_CALLBACK:
logCfgCallbackFun = (ST_VOID(*)(SX_DEC_CTRL*,ST_CHAR*,LOGCFGX_VALUE_MAP*)) slogMaskGroup->maskMapTbl[i].addr;
if (logCfgCallbackFun != NULL)
(*logCfgCallbackFun) (sxDecCtrl, tag, &slogMaskGroup->maskMapTbl[i]);
break;
}
break;
}
}
slogMaskGroup =(LOGCFG_VALUE_GROUP*) list_get_next (logCfgLogMaskGroupList, slogMaskGroup);
}
/* If we did not find it but are supposed to get it's value anyway ... */
if (tagVal != NULL && found == SD_FALSE)
{
strLen = 0;
sx_get_string_ptr (sxDecCtrl, &str, &strLen);
if (!stricmp (str, "On"))
{
LOGCFG_CFLOW1 ("Setting log mask %-16s ON", tag);
tagVal->u.b = SD_TRUE;
tagVal->dataType = _LOGCFG_DATATYPE_BOOLEAN;
}
else if (!stricmp (str, "Off"))
{
LOGCFG_CFLOW1 ("Setting log mask %-16s OFF", tag);
tagVal->u.b = SD_FALSE;
tagVal->dataType = _LOGCFG_DATATYPE_BOOLEAN;
}
else
{
tagVal->u.str = chk_strdup (p);;
tagVal->dataType = _LOGCFG_DATATYPE_STRING;
}
}
return (SD_SUCCESS);
}

456
mms/main.c Normal file
View File

@@ -0,0 +1,456 @@
/**
* @file: $RCSfile: main.c,v $
* @brief: $IEC 61850 Protocol
*
* @version: $Revision: 1.9 $
* @date: $Date: 2020/10/28 05:21:18 $
* @author: $Author: lizhongming $
* @state: $State: Exp $
*
* @latest: $Id: main.c,v 1.9 2020/10/28 05:21:18 lizhongming Exp $
*
*/
#include "rdb_client.h"
#include "db_interface.h"
#include "node.h"
/*lnk10-10 */
#include "../include/rocketmq/SimpleProducer.h"
extern G_TEST_FLAG;
extern pthread_mutex_t mtx;
extern pt61850app_t *g_pt61850app;
extern node_t *g_node;
char g_my_conf_fname[256];
//extern byte_t g_Master;
char g_onlyIP[255]; //ֱ<><D6B1>ij<EFBFBD><C4B3>IP<49><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//extern byte_t g_protect_file; //0:<3A><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD> 1:<3A>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD>
apr_pool_t *g_root_pool;
apr_pool_t *g_rdb_pool;
apr_pool_t *g_cfg_pool;
uint16_t g_client_id = 0;
uint32_t g_node_id = 0;
uint32_t g_min_free_size = 1024;
int g_need_password = 0;
char subdir[128] = "cfg_stat_data" ;
int usage();
int parse_param(int argc, const char **argv);
#include "ver_conf.h"
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
///////////////////////////////////////////////////////
uint32_t g_dead_lock_counter = 0;
uint32_t g_thread_blocked_times = 0;
///////////////////////////////////////////////////////////////////////////////
int three_secs_enabled = 0;
int auto_register_report_enabled = 0;
int g_front_seg_index = 0;
int g_front_seg_num = 0;
int FRONT_MP_NUM = 0;//<2F>ն<EFBFBD><D5B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int g_front_num_count = 0;//<2F>ն<EFBFBD><D5B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>
///////////////////////////////////////////////////////////////////////////////
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<C4BF>б<EFBFBD>ȫ<EFBFBD>ֹ<EFBFBD><D6B9>ܵ<EFBFBD>Ͷ<EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD>ĸ<EFBFBD><C4B8>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܾ<EFBFBD><DCBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD>
void init_global_function_enable()
{
if (strcmp(subdir,"cfg_stat_data")==0) { //<2F><>ʷ<EFBFBD><CAB7>̬
g_node_id = STAT_DATA_BASE_NODE_ID;
auto_register_report_enabled = 1;
}else if (strcmp(subdir,"cfg_3s_data")==0) { //ʵʱ
g_node_id = THREE_SECS_DATA_BASE_NODE_ID;
three_secs_enabled = 1;
}else if (strcmp(subdir,"cfg_soe_comtrade")==0) { //<2F><EFBFBD><E6BEAF>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̬
g_node_id = SOE_COMTRADE_BASE_NODE_ID;
}else if (strcmp(subdir,"cfg_his_data")==0) { //<2F><>ʹ<EFBFBD><CAB9>
g_node_id = RECALL_ALL_DATA_BASE_NODE_ID;
g_node_id = HIS_DATA_BASE_NODE_ID;
}
else if (strcmp(subdir, "cfg_newhis_data") == 0) { //<2F><>ʹ<EFBFBD><CAB9>
g_node_id = RECALL_ALL_DATA_BASE_NODE_ID;
g_node_id = NEW_HIS_DATA_BASE_NODE_ID;
}
else if (strcmp(subdir, "cfg_recallhis_data") == 0) { //<2F><><EFBFBD><EFBFBD>
g_node_id = RECALL_HIS_DATA_BASE_NODE_ID;
}
else if (strcmp(subdir, "cfg_recallall_data") == 0) { //<2F><>ʹ<EFBFBD><CAB9>
g_node_id = RECALL_ALL_DATA_BASE_NODE_ID;
}
}
//////////////////////////////////////////////////////////////////////////////////
#ifdef _OS_UNIX_
void init_daemon(void)
{
int pid;
int i;
if( pid = fork() )
exit(0); /** <20>Ǹ<EFBFBD><C7B8><EFBFBD><EFBFBD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
else if( pid < 0 )
exit(1); /** forkʧ<6B>ܣ<EFBFBD><DCA3>˳<EFBFBD> */
/** <20>ǵ<EFBFBD>һ<EFBFBD>ӽ<EFBFBD><D3BD>̣<EFBFBD><CCA3><EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4> */
setsid(); /** <20><>һ<EFBFBD>ӽ<EFBFBD><D3BD>̳<EFBFBD>Ϊ<EFBFBD>µĻỰ<C4BB><EFBFBD>ͽ<EFBFBD><CDBD><EFBFBD><EFBFBD><EFBFBD><E9B3A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ն˷<D5B6><CBB7><EFBFBD> */
if( pid = fork() )
exit(0); /** <20>ǵ<EFBFBD>һ<EFBFBD>ӽ<EFBFBD><D3BD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD> */
else if( pid < 0)
exit(1); /** forkʧ<6B>ܣ<EFBFBD><DCA3>˳<EFBFBD> */
chdir("/FeProject/bin/"); //multi process running at same time
umask(0); /** <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
return;
}
#endif
//"--subdir, set the subdir of /CloudForward/ as the working directory, \n"
int usage()
{
// fprintf(stderr,"\n\n******** IEC61850 Protocol ********\n");
fprintf(stderr,"\nUsage : pt61850netd_pqfe -d [subdir] \n");
exit(-1);
}
int prepare_entironment_2()
{
apr_status_t rv;
/* apr library need call this first. */
apr_initialize(); //APACHE<48><45>ʼ<EFBFBD><CABC>
atexit(apr_terminate);
/* Create node root pool */
rv = apr_pool_create(&g_root_pool, NULL); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
if(rv != APR_SUCCESS) {
fprintf(stderr,"%s","Create node root pool failed!\n");
return (-1);
}
#ifdef SIGPIPE
/* Ignore writes to connections that have been closed at the other end. */
apr_signal(SIGPIPE, SIG_IGN);
#endif
rv = create_log_handle(g_root_pool);
if(rv != APR_SUCCESS) {
printf("init_log failed!\n");
return (-1);
}
else {
unsigned int error = 0;
unsigned int warn = 0;
unsigned int info = 0;
log_config_t *log_handle = get_log_handle();
parse_log_switch_ini(&error,&warn,&info);
log_handle->status.debug = info;//0;//1;
log_handle->status.warn = warn;//0;//1;
log_handle->status.error = error;//0;//1;
}
echo_msg("==============================================================\n");
rv = apr_pool_create(&g_rdb_pool, g_root_pool); //<2F><><EFBFBD><EFBFBD>RDB<44>ڴ<EFBFBD>
if(rv != APR_SUCCESS) {
echo_errg("Create system runtime pool failed!\n");
return (-1);
}
rv = apr_pool_create(&g_cfg_pool, g_root_pool); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
if(rv != APR_SUCCESS) {
echo_errg("Create system config pool failed!\n");
return (-1);
}
//g_fun_pool = 0;
//rv = apr_thread_mutex_create(&g_rdb_mutex, APR_THREAD_MUTEX_NESTED,g_root_pool);//<2F><><EFBFBD><EFBFBD>RDB<44><42>
//if ( rv != APR_SUCCESS) {
// return rv;
//}
/* Initialize the register table. Call these functions first! */
echo_msg1("%-60s","Initialize system register......");
//init_default_dbparser_table(); //<2F><><EFBFBD>ݸ<EFBFBD>XML<4D>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>RDB<44><42>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
//load_driver_library(); //<2F><><EFBFBD>ø<EFBFBD><C3B8>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
echo_msg("OK\n\n");
initTimezoneOffset();
return APR_SUCCESS;
}
#ifdef _OS_UNIX_
#include <stdio.h>
#include <pwd.h>
#include <unistd.h>
void printf_cur_user()
{
struct passwd *pwd;
pwd = getpwuid(getuid());
echo_warn1("Current user: %s\n", pwd->pw_name);
}
#endif
int main(int argc, const char **argv)
{
// ipcclient_t *ipcclient = NULL;
// void *cookie = NULL;
uint32_t stimer = 1;
apr_status_t rv;
// int pid;
/* Prepare the system context */
rv=prepare_entironment_2();
if (rv!=APR_SUCCESS){
return rv;
}
getVersion(argc,argv);
////////////////////
//WW <20><><EFBFBD><EFBFBD>json
//TestJson(NULL);
//WW 2023-08-31 end
///////////////////
//TestSMSPost();//WW 2023-08-28<32><38><EFBFBD>Թ<EFBFBD>˾post
//TestBodyPost();
//TestToken();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դҵ<D4B4><D2B5><EFBFBD><EFBFBD>̨
////////////////////
//WW <20><><EFBFBD><EFBFBD>json
//TestOSS();
//TestOBS();
//WW 2023-09-01 end
///////////////////
/* Parse the command-line parameter */
rv=parse_param(argc, argv);
if (rv!=APR_SUCCESS){
return rv;
}
#ifdef _OS_UNIX_
#ifdef QT_NO_DEBUG
if (!g_need_password)
init_daemon();
#endif
#endif
init_global_function_enable();
apr_snprintf(g_my_conf_fname,sizeof(g_my_conf_fname),"../%s/etc/pt61850netd_pqfe.xml",subdir);
#if defined (DEBUG_SISCO)
init_log_cfg ();
#endif
printf("\n\n");
#ifdef _OS_UNIX_
printf_cur_user();
#endif
if (g_need_password) {
if ( process_login_verify() == 0) {
echo_warn("User login succeeded!\n");
} else {
echo_warn("User login failed!\n");
apr_sleep(apr_time_from_sec(3));
exit(-59);
}
}
rv = init_rdb();
if (rv!=APR_SUCCESS){
return rv;
}
//lnk20241024ȥ<34><C8A5><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>
//OTLConnect();
rv = run_protocol();
if (rv!=APR_SUCCESS){
return rv;
}
while(1) {
/* sleep 1s, just like 1s timer */
apr_sleep(apr_time_from_sec(1));
/* ÿ30<33><30><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD>һ<EFBFBD><D2BB>״̬ */
/*<2A><><EFBFBD><EFBFBD>mq<6D><71><EFBFBD><EFBFBD>lnk10-10 */
//rocketmq_test_rt();
//rocketmq_test_ud();
//rocketmq_test_rc();
/*lnk20241029recall<6C>ӿڲ<D3BF><DAB2><EFBFBD>*/
//curltest();
/*202411-1lnk<6E><6B><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD> */
//SOEFileWeb_test();
//<2F><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD>
//qvvr_test();
//apr_sleep(apr_time_from_sec(3));
//comflag_test();
//apr_sleep(apr_time_from_sec(3));
if( !(stimer++ % 60) ) {//<2F><><EFBFBD><EFBFBD>
if (g_dead_lock_counter++ >=3) {//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
g_thread_blocked_times++;
g_dead_lock_counter = 0;
}
MVL_LOG_ACSE1 ("MYLOG: current g_thread_blocked_times = %u ", g_thread_blocked_times);
if (FRONT_MP_NUM <= 1) {//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
g_front_num_count++;
}
else {
g_front_num_count = 0;
}
}
//work<72>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD>3*13<31><33><EFBFBD>ӣ<EFBFBD><D3A3>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>
if (g_thread_blocked_times>=13) {
MVL_LOG_ACSE0 ("MYLOG: g_thread_blocked_times>=3, so exit to restart ");
apr_sleep(apr_time_from_sec(10));
exit(-1039);
}
//lnk20241211 <20><><EFBFBD>Ӳ<EFBFBD><D3B2>Կ<EFBFBD><D4BF><EFBFBD>
pthread_mutex_lock(&mtx);//<2F><><EFBFBD>̶߳<DFB3>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD>ȡ̨<C8A1>˼<EFBFBD><CBBC><EFBFBD>
if (!G_TEST_FLAG && g_front_num_count >= 30 && g_onlyIP[0] == 0 && g_node->n_clients>10) {//30<33><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD>˴<EFBFBD><CBB4><EFBFBD>ʮ<EFBFBD><CAAE><EFBFBD>ն<EFBFBD>
MVL_LOG_ACSE0("MYLOG: g_front_num_count>=20, so exit to restart ");
apr_sleep(apr_time_from_sec(10));
exit(-1039);
}
pthread_mutex_unlock(&mtx);
}
echo_warn1("%-60s","System shutdown now......");
apr_pool_destroy(g_root_pool);
echo_msg("OK\n");
return 0;
}
int parse_param(int argc, const char **argv)
{
apr_status_t rv;
apr_getopt_t *opt;
char *opt_arg;
char ch;
char *p;
char temp[128];
//int g_front_seg_index, g_front_seg_num;
/* Set default command-line parameter */
g_node_id = 0;
//g_protect_file = 0;
echo_warn2("================= compiled@ %s %s =================\n",__DATE__ , __TIME__ );
/* Parse the command-line parameter */
if( argc > 1 ) {
rv = apr_getopt_init(&opt, g_root_pool, argc, argv);
while (apr_getopt(opt, "q:Q:a:A:d:D:p:P:f:F:r:R:T:t:s:S", &ch, &opt_arg) == APR_SUCCESS) {
switch (ch) {
case 'q':
case 'Q':
if (opt_arg[0] >= '0' && opt_arg[0] <= '9' ) {
g_min_free_size = atoi(opt_arg);
}
else
return (usage());
break;
case 'R':
case 'r':
// if (opt_arg[0] >= '0' && opt_arg[0] <= '9' )
// {
// g_client_id = atoi(opt_arg);
// if (g_client_id>2||g_client_id<0)
// {
// printf("Do not support triple or above clients \n ");
// return (usage());
// }
////g_auto_client_id = FALSE;
// }
// else
// return (usage());
break;
case 's':
case 'S':
echo_warn1(">>>>>>>>>>>>>>>>>>>>>parse -s %s ", opt_arg);
strcpy(temp, opt_arg);
p = strtok(temp, "_"); //1_5
echo_warn1("p %s ", p);
g_front_seg_index = atoi(p);
printf("g_front_seg_index:%d",g_front_seg_index);
p = strtok(NULL, "_"); //1_5
echo_warn1("p %s ", p);
g_front_seg_num = atoi(p);
printf("g_front_seg_num:%d",g_front_seg_num);
//echo_warn2("================= compiled@ %d %d =================\n", g_front_seg_index, g_front_seg_num);
//lnk20241206<30><36><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>¼subdir<69><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
//echo_warn1("subdir %s ", opt_arg + 6);
//strcpy(subdir, opt_arg + 6);
break;
break;
case 'a':
case 'A':
strcpy(g_onlyIP,opt_arg);
break;
case 'd':
case 'D':
strcpy(subdir,opt_arg);
break;
case 'T':
case 't':
break;
case 'f':
case 'F':
//if (opt_arg[strlen(opt_arg)-1] == '/'
// || opt_arg[strlen(opt_arg)-1] == '\\') {
// echo_errg( "Error: Bad or invalid file name");
// return (usage());
// }
// //g_my_conf_fname = SHR_GetPrivateFileName(opt_arg,g_root_pool);
// echo_warn1("using config file %s!\n", g_my_conf_fname);
// break;
case 'P':
case 'p':
if (opt_arg[0] >= '0' && opt_arg[0] <= '9' ) {
g_need_password = atoi(opt_arg);
}
else
return (usage());
break;
case '?':
default:
return (usage());
}
}
}
return 0;
}

2044
mms/mms_process.c Normal file

File diff suppressed because it is too large Load Diff

609
mms/mmscli_log.c Normal file
View File

@@ -0,0 +1,609 @@
/**
* @file: $RCSfile: mmscli_log.c,v $
* @brief: $IEC 61850 Protocol
*
* @version: $Revision: 1.7 $
* @date: $Date: 2019/01/08 03:06:27 $
* @author: $Author: lizhongming $
* @state: $State: Exp $
*
* @latest: $Id: mmscli_log.c,v 1.7 2019/01/08 03:06:27 lizhongming Exp $
*
*/
/************************************************************************/
#include "rdb_client.h"
#include "glbtypes.h"
#include "sysincs.h"
#include "signal.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mms_pvar.h"
#include "mms_vvar.h"
#include "mms_err.h"
#include "mms_pcon.h"
#include "asn1defs.h"
#include "mmsop_en.h"
#include "lean_a.h" //add by lzm
#include "tp0_sock.h"
#include "mvl_defs.h"
#include "acse2.h"
#include "mvl_acse.h"
#include "mvl_log.h"
#include "tp4api.h"
#include "clntobj.h"
#include "mmsclient.h"
#include "tp4.h"
#include "db_interface.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* Global variables. */
/************************************************************************/
extern pt61850app_t* g_pt61850app;
/************************************************************************/
/* Static function prototypes. */
/************************************************************************/
static ST_VOID log_var_jou_data (ST_INT var_type_id,VAR_ACC_DATA *var ,MMS_DECODE_DATA *data, ST_CHAR* dom_name)
{
ST_INT rc;
ST_CHAR tdl_buf [500]; /* increase size if complex TDL expected*/
MVL_TYPE_CTRL *type_ctrl;
ST_INT va_data_size;
ST_CHAR* temp_data_buf;
ST_INT num_rt; /* Runtime type table */
SD_CONST RUNTIME_TYPE* rt;
ST_INT data_size; /* size of data element */
type_ctrl = mvl_type_ctrl_find (var_type_id);
//char doname[32];
//strcpy(doname, dom_name);
//type_ctrl = (MVL_TYPE_CTRL*)(sel_mvl_type_ctrl(doname));
//printf ("\naddress: %p \n", type_ctrl);
if (type_ctrl)
{
num_rt = type_ctrl->num_rt;
rt = type_ctrl->rt;
data_size = type_ctrl->data_size;
//printf ("\nTYPE: %d %d %d\n", num_rt, data_size, rt->el_size);
/* If the TDL produced is longer than max_tdl_len, this function */
/* "gracefully" fails (i.e. returns 0). */
if (ms_runtime_to_tdl (rt, num_rt, tdl_buf, sizeof(tdl_buf))>0)
;//SLOGCALWAYS1 (" TYPE: %s", tdl_buf);
else
echo_warn (" TYPE: unknown");
//printf("\nrt %p and rt_num: %d \n", &type_ctrl->rt,type_ctrl->num_rt);
//printf ("\nTYPE: %s \n", tdl_buf);
va_data_size = data_size;
temp_data_buf = (ST_CHAR*)malloc( va_data_size);
rc = ms_asn1_to_local (rt, num_rt, var->data, var->len, temp_data_buf);
//printf("type_ctrl->num_rt %d %x %x \n", type_ctrl->num_rt , &data, &(var->data));
my_local_to_data (temp_data_buf,rt,num_rt, data);
if (data->item_num==0) {
echo_warn("!!!!!!!!!!!!!!!!!!!data num is 0 !!!!!!!!!!!!!!!!\n");
}
free(temp_data_buf);
}
else
echo_warn (" ERR: type_id is invalid");
}
/************************************************************************/
/************************************************************************/
#define STEADY_DATA (0)
#define QVVR_DATA (1)
#define RDRE_DATA (2)
apr_time_t process_jou_entry_t = apr_time_from_sec(0);
static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
MVL_JOURNAL_ENTRY *jou_entry, MVL_NET_INFO *clientNetInfo, ST_CHAR *dom_name, ST_INT iTimeout)
{
ST_RET ret = SD_SUCCESS;
ST_INT var_type_id; /* type_id for "ctrl_name" arg */
int ii,j;
char *do_name;
MMS_DECODE_DATA mms_dec_data;
int log_data_type = STEADY_DATA;
ST_INT not_set_log_q_this;
ST_INT not_set_log_t_this;
int length_FCDA;
not_set_log_q_this = TRUE;
not_set_log_t_this = TRUE;
ST_INT timeflag = TRUE;//ִ<><D6B4>ǰ<EFBFBD><C7B0>ȡʱ<C8A1><CAB1>
int log_data_steady_type = 0;//<2F><>̬ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
double start, end;
static double last_check_recall_config_time = 0.0;
printf("\nbrf for");
for (j = 0; j < jou_entry->ef.data.num_of_var; j++) {
printf("\nfor %d", jou_entry->ef.data.num_of_var);
printf("\nfor %s", jou_entry->ef.data.list_of_var[j].var_tag);
if (strstr(jou_entry->ef.data.list_of_var[j].var_tag, dom_name) == NULL)
{
do_name = jou_entry->ef.data.list_of_var[j].var_tag;
}
else if (strstr(jou_entry->ef.data.list_of_var[j].var_tag, "reasonCode") != NULL)
{
continue;
}
else
{
do_name = strstr(jou_entry->ef.data.list_of_var[j].var_tag, "/");
do_name++;
}
//printf("do_name =====%s=====\n", do_name);
//start = sGetMsTime();
printf("\nbrf if");
if (sel_mvl_type_ctrl_flag(do_name) == -1)
{
var_type_id = mms_var_type_id_create(clientNetInfo, DOM_SPEC,
dom_name, do_name, iTimeout);
char doname[32];
strcpy(doname, do_name);
add_mvl_type_ctrl(doname, var_type_id);
//printf("create var_type_id =====%d=====%p======\n", var_type_id, &doname);
}
printf("\nbrf var_type_id");
var_type_id = sel_mvl_type_ctrl_flag(do_name);
printf("\nafter var_type_id");
//end = sGetMsTime();
//last_check_recall_config_time = last_check_recall_config_time + end - start;
//printf("jou_entry->ef.data.num_of_var =====%d===== =====%d=====\n", jou_entry->ef.data.num_of_var, var_type_id);
/*var_type_id = mms_var_type_id_create(clientNetInfo, DOM_SPEC,
dom_name, do_name, iTimeout);*/
//printf("var_type_id =====%d=====\n", var_type_id);
if (var_type_id < 0) {
//return SD_FAILURE;
continue;
}
log_var_jou_data(var_type_id,&(jou_entry->ef.data.list_of_var[j].value_spec),&mms_dec_data, do_name);
printf("\nafter log_var_jou_data");
if (timeflag) {
int readtime = 0;
int readquailty = 0;
apr_time_t t;
int quality;
for (ii = 0; ii < mms_dec_data.item_num; ++ii) {
double v = 0.0;
char mms_ref[256];
if (mms_dec_data.data_item[ii].type == DATA_INT_TYPE)
v = mms_dec_data.data_item[ii].u.data_int;
else if (mms_dec_data.data_item[ii].type == DATA_UINT_TYPE)
v = mms_dec_data.data_item[ii].u.data_uint;
else if (mms_dec_data.data_item[ii].type == DATA_INT64_TYPE)
v = (double)mms_dec_data.data_item[ii].u.data_int64;
else if (mms_dec_data.data_item[ii].type == DATA_UINT64_TYPE)
v = (double)mms_dec_data.data_item[ii].u.data_uint64;
else if (mms_dec_data.data_item[ii].type == DATA_DOUBLE_TYPE)
v = mms_dec_data.data_item[ii].u.data_double;
apr_snprintf(mms_ref, sizeof(mms_ref), "%s$%s", do_name, mms_dec_data.data_item[ii].comp_name);
if (strstr(mms_ref, "QVVR")) {
log_data_type = QVVR_DATA;
timeflag = FALSE;
break;
}
else if (strstr(mms_ref, "RDRE")) {
log_data_type = RDRE_DATA;
timeflag = FALSE;
break;
}
length_FCDA = strlen(mms_ref);
if (('$' == mms_ref[length_FCDA - 2]) && ('t' == mms_ref[length_FCDA - 1])) {
readtime = 1;
t = convert_btime6_to_apr_time(&(mms_dec_data.data_item[ii].u.data_bTime6));
}
if (('$' == mms_ref[length_FCDA - 2]) && ('q' == mms_ref[length_FCDA - 1])) {
if (log_data_type == STEADY_DATA) {
readquailty = 1;
char* q = mms_dec_data.data_item[ii].u.data_str;
if (q[0] == '0' && q[1] == '0')
quality = 0;
else
quality = 1;
}
}
if (readtime == 1 && readquailty == 1) {
break;
}
}
if (readtime == 1 && readquailty == 1) {
if (quality == 1) {
timeflag = TRUE;
continue;
}
else
{
timeflag = FALSE;
if (process_jou_entry_t == 0) {
process_jou_entry_t = t;
}
apr_time_exp_t newTime;
apr_time_exp_gmt(&newTime, t);
apr_time_exp_t preTime;
apr_time_exp_gmt(&preTime, process_jou_entry_t);
if (newTime.tm_year != preTime.tm_year || newTime.tm_mon != preTime.tm_mon || newTime.tm_mday != preTime.tm_mday || newTime.tm_hour != preTime.tm_hour || newTime.tm_min != preTime.tm_min) //ʱ<><EFBFBD><E4B7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>json<6F><6E><EFBFBD><EFBFBD>
{
printf("\n newTime: %d %d %d %d %d %d", newTime.tm_year, newTime.tm_mon, newTime.tm_mday, newTime.tm_hour, newTime.tm_min, newTime.tm_sec);
printf("\n preTime: %d %d %d %d %d %d", preTime.tm_year, preTime.tm_mon, preTime.tm_mday, preTime.tm_hour, preTime.tm_min, preTime.tm_sec);
json_block_create_end(loginfo->LD_info->mp_id, 0);//<2F><>̬
json_block_create_end(loginfo->LD_info->mp_id, 1);//<2F><><EFBFBD><EFBFBD>
json_block_create_end(loginfo->LD_info->mp_id, 2);//<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
process_jou_entry_t = t;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
ied_t* ied;
ied = find_ied_from_dev_code(loginfo->LD_info->terminal_code);
ied_usr_t* ied_usr = (ied_usr_t*)ied->usr_ext;
json_block_create_start(loginfo->LD_info->voltage_level, loginfo->LD_info->mp_id, 0, ied_usr->dev_type, loginfo->LD_info->line_id);//<2F><><EFBFBD>ͽ<EFBFBD><CDBD><EFBFBD> <20><><EFBFBD>³<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><C2B6><EFBFBD> <20><>̬
json_block_create_start(loginfo->LD_info->voltage_level, loginfo->LD_info->mp_id, 1, ied_usr->dev_type, loginfo->LD_info->line_id);//<2F><><EFBFBD><EFBFBD>
json_block_create_start(loginfo->LD_info->voltage_level, loginfo->LD_info->mp_id, 2, ied_usr->dev_type, loginfo->LD_info->line_id);//<2F><><EFBFBD><EFBFBD>
}
}
}
}
for ( ii = 0; ii < mms_dec_data.item_num; ++ii) {
double v = 0.0;
char mms_ref[256];
if (mms_dec_data.data_item[ii].type==DATA_INT_TYPE)
v = mms_dec_data.data_item[ii].u.data_int;
else if (mms_dec_data.data_item[ii].type==DATA_UINT_TYPE)
v = mms_dec_data.data_item[ii].u.data_uint;
else if (mms_dec_data.data_item[ii].type==DATA_INT64_TYPE)
v = (double)mms_dec_data.data_item[ii].u.data_int64;
else if (mms_dec_data.data_item[ii].type==DATA_UINT64_TYPE)
v = (double)mms_dec_data.data_item[ii].u.data_uint64;
else if (mms_dec_data.data_item[ii].type==DATA_DOUBLE_TYPE)
v = mms_dec_data.data_item[ii].u.data_double;
//printf("%s %s = %f \n",jou_entry->ef.data.list_of_var[j].var_tag, mms_dec_data.data_item[ii].comp_name,v);
apr_snprintf(mms_ref,sizeof(mms_ref),"%s$%s",do_name,mms_dec_data.data_item[ii].comp_name);
if ( (strstr(mms_ref,"]")==NULL) || (strstr(mms_ref,"0]")) )
//printf("\nlog read: %s=%f\n",mms_ref,v);
if (j==0 && ii==0) {
printf("\n ----------------------------------------------------------------log read: %s=%f--------------------------------------------------------------\n",mms_ref,v);
if ( strstr(mms_ref,"QVVR") ) {
log_data_type = QVVR_DATA;
}
else if ( strstr(mms_ref,"RDRE") ) {
log_data_type = RDRE_DATA;
}
else if (strcasestr(mms_ref, "PLT") ) {
log_data_steady_type = 1;
}
else if (strcasestr(mms_ref, "PST") || strcasestr(mms_ref, "FLUC")) {
log_data_steady_type = 2;
}
if ( ( (loginfo->need_steady==0) &&(log_data_type == STEADY_DATA))
|| ( (loginfo->need_voltage==0) &&(log_data_type != STEADY_DATA)) ){
//mvl_type_id_destroy(var_type_id);
return SD_SUCCESS;
}
if ( log_data_type == QVVR_DATA ) {
processQVVR_start(loginfo->LD_info);
//processQVVR_time(loginfo->LD_info,t/1000);
}
else if ( log_data_type == RDRE_DATA ) {
processRDRE_start(loginfo->LD_info);
}
else {
/*ied_t* ied;
ied = find_ied_from_dev_code(loginfo->LD_info->terminal_code);
ied_usr_t* ied_usr = (ied_usr_t*)ied->usr_ext;
json_block_create_start( loginfo->LD_info->voltage_level, loginfo->LD_info->mp_id,0, ied_usr->dev_type);*/
//json_block_create_time(loginfo->LD_info->line_id,t/1000);
}
}
//set_db_value(LOG_IDX,mms_ref,v,FALSE);
length_FCDA = strlen( mms_ref );
if ( ('$'==mms_ref[length_FCDA-2]) && ('q'==mms_ref[length_FCDA-1]) ) {
if(not_set_log_q_this && ( log_data_type == STEADY_DATA )) {
int quality = 0;
char* q = mms_dec_data.data_item[ii].u.data_str;
if (q[0]=='0'&& q[1]=='0')
quality = 0;
else
quality = 1;
if (quality == 1) {
continue;
}
//set_log_QualityFlag(quality);
if (log_data_steady_type == 0) {
json_block_create_flag(loginfo->LD_info->mp_id, quality, 0);
}
else if (log_data_steady_type == 1) {
json_block_create_flag(loginfo->LD_info->mp_id, quality, 1);
}
else if (log_data_steady_type == 2) {
json_block_create_flag(loginfo->LD_info->mp_id, quality, 2);
}
not_set_log_q_this = FALSE;
}
}
else if ( ('$'==mms_ref[length_FCDA-2]) && ('t'==mms_ref[length_FCDA-1]) ) {
if (not_set_log_t_this) {
apr_time_t t = convert_btime6_to_apr_time(&(mms_dec_data.data_item[ii].u.data_bTime6));
if ( log_data_type == QVVR_DATA ) {
if ( strstr(mms_ref,"VarStr$t") ) {
processQVVR_time(loginfo->LD_info,t/1000);
not_set_log_t_this = FALSE;
}
}
else if ( log_data_type == RDRE_DATA ) {
//need do nothing!
not_set_log_t_this = FALSE;
}
else {
if (log_data_steady_type == 0) {
json_block_create_time(loginfo->LD_info->mp_id, t / 1000, 0);
}
else if (log_data_steady_type == 1) {
json_block_create_time(loginfo->LD_info->mp_id, t / 1000, 1);
}
else if (log_data_steady_type == 2) {
json_block_create_time(loginfo->LD_info->mp_id, t / 1000, 2);
}
not_set_log_t_this = FALSE;
}
}
}
else {
if ( log_data_type == QVVR_DATA ){
processQVVR_data(loginfo->LD_info,mms_ref,v);
}
else if ( log_data_type == RDRE_DATA ) {
processRDRE_data(loginfo->LD_info,mms_ref,v);
}
else
{
if (log_data_steady_type == 0) {
json_block_create_data(loginfo->LD_info->mp_id, mms_ref, v, 0);
}
else if (log_data_steady_type == 1) {
json_block_create_data(loginfo->LD_info->mp_id, mms_ref, v, 1);
}
else if (log_data_steady_type == 2) {
json_block_create_data(loginfo->LD_info->mp_id, mms_ref, v, 2);
}
}
}
}
//mvl_type_id_destroy(var_type_id);
}
printf("\naft for");
if ( log_data_type == QVVR_DATA ) {
processQVVR_end(loginfo->LD_info);
}
else if ( log_data_type == RDRE_DATA ) {
processRDRE_end(loginfo->LD_info);
}
else {
//json_block_create_end(loginfo->LD_info->mp_id,0);
}
printf("\nend process_jou_entry");
//printf("process_jou_entry ==============%.2f================\n", last_check_recall_config_time);
return ret;
}
/************************************************************************/
/* mms_jread */
/************************************************************************/
ST_RET mms_jread (loginfo_t *loginfo,MVL_NET_INFO *clientNetInfo, ST_CHAR *dom_name,ST_CHAR *logName,
apr_time_t start_time,apr_time_t end_time,ST_INT iTimeout, ST_CHAR* ip)
{
ST_RET ret;
ST_INT i, k;
MVL_REQ_PEND *reqCtrl;
JREAD_REQ_INFO jread_req;
MVL_JREAD_RESP_INFO *jread_resp; /* set to reqCtrl->u.jread_resp_info*/
MVL_JOURNAL_ENTRY *jou_entry;
MMS_UTC_TIME utc_time_start,utc_time_end;
MMS_BTOD btod_time_start,btod_time_end;
ST_UCHAR entry_id[8];
ST_INT more_follows = 0;
MMS_BTOD last_occur_time;
memset(&last_occur_time,0,sizeof(MMS_BTOD));
memset(&jread_req,0,sizeof(MVL_JREAD_RESP_INFO));
jread_req.jou_name.object_tag = DOM_SPEC;
jread_req.jou_name.domain_id = dom_name;
jread_req.jou_name.obj_name.vmd_spec = logName;//vmd_spec item_id
jread_req.range_start_pres = 1;
jread_req.range_stop_pres = 1;
jread_req.start_tag = 0; //starting time
jread_req.stop_tag = 0; //ending time
convert_apr_time_to_utc_time(start_time,&utc_time_start);
my_asn1_convert_utc_to_btod (&utc_time_start, &btod_time_start);
memcpy(&jread_req.start_time, &btod_time_start, sizeof(MMS_BTOD));
convert_apr_time_to_utc_time(end_time,&utc_time_end);
my_asn1_convert_utc_to_btod (&utc_time_end, &btod_time_end);
memcpy(&jread_req.end_time, &btod_time_end, sizeof(MMS_BTOD));
jread_req.num_of_entries = 0;
jread_req.num_of_var = 0;
jread_req.list_of_var_pres = 0;
jread_req.sa_entry_pres = 0;
jread_req.entry_spec_len = 0;
jread_req.entry_spec = 0;
memcpy(&jread_req.time_spec, &btod_time_start, sizeof(MMS_BTOD));
process_jou_entry_t = apr_time_from_sec(0);
double start,end;
static double last_check_recall_config_time = 0.0;
static double heart_time_cout = 0.0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
static double heart_time_cout_start = 0.0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ <20><>ʼ
static double heart_time_cout_now = 0.0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ <20><>ǰ
do {
heart_time_cout_now = sGetMsTime();
if (heart_time_cout_now - heart_time_cout_start > 30000)//30<33><30> <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
{
printf("\n heart_time_cout OK");
heart_time_cout_start = sGetMsTime();
int i = 0;
while (i < g_pt61850app->chnl_counts)
{
chnl_usr_t* chnl_usr;
int cpuno = 0;
chnl_usr = g_pt61850app->chnl_usr[i];
//printf("\n chnl_usr->m_state ===== %d\n", chnl_usr->m_state);
if (strstr(chnl_usr->ip_str, ip) != NULL)
{
printf("\nSame Ip %s : %s", chnl_usr->ip_str, ip);
i++;
continue;
}
if (chnl_usr->m_state == CHANNEL_CONNECTED) {
char** varnames;
int varnum;
ST_RET ret = mms_mvla_getnam(chnl_usr->net_info, VMD_SPEC, NULL, MMS_CLASS_DOM, g_pt61850app->mmsOpTimeout,
&varnames, &varnum, g_pt61850app->tmp_pool);
chnl_usr->m_LastPosRespTime = sGetMsTime();
if (ret == SD_SUCCESS) {
printf("\n heart success!");
chnl_usr->m_NegRespTimes = 0;
}
else {
printf("%d--------------\n", chnl_usr->m_NegRespTimes);
chnl_usr->m_NegRespTimes++;
}
}
i++;
}
heart_time_cout_start = sGetMsTime();
}
ret = mvla_jread (clientNetInfo, &jread_req, &reqCtrl);
if (ret == SD_SUCCESS)
ret = waitReqDone (reqCtrl, iTimeout);
if (ret != SD_SUCCESS) {
more_follows = 0;
printf ("\n mvl_jread () Error, ret = 0x%X.", ret);
}
else
{
printf ("\n mvl_jread OK");
jread_resp = reqCtrl->u.jread.resp_info;
printf ("\n num_entry = %d", jread_resp->num_of_jou_entry);
printf ("\n more_follows = %d", jread_resp->more_follows);
more_follows = jread_resp->more_follows;
for (i = 0; i < jread_resp->num_of_jou_entry; i++)
{
apr_time_t t;
jou_entry = &jread_resp->jou_entry[i];
if ( ( (i+1)==jread_resp->num_of_jou_entry) && more_follows ) {
jread_req.range_start_pres = 0;
jread_req.sa_entry_pres = 1;
jread_req.entry_spec_len = jou_entry->entry_id_len;
memcpy(entry_id,jou_entry->entry_id,sizeof(entry_id));
jread_req.entry_spec = entry_id;
jread_req.time_spec = jou_entry->occur_time;
jread_req.num_of_entries = 0;
}
printf ("\n Journal Entry # %d:", i);
printf ("\n entry_id_len = %d ", jou_entry->entry_id_len);
for (k = 0; k < jou_entry->entry_id_len; k++)
printf("%02x ", jou_entry->entry_id[k]);
printf ("\n occur_time.form = %s", (jou_entry->occur_time.form == MMS_BTOD6 ? "MMS_BTOD6" : "MMS_BTOD4"));
printf ("\n occur_time.ms = %lu", jou_entry->occur_time.ms);
printf ("\n occur_time.day = %lu", jou_entry->occur_time.day);
printf ("\n entry_form_tag = %d", jou_entry->entry_form_tag);
if( (last_occur_time.day!=jou_entry->occur_time.day)||(last_occur_time.ms!=jou_entry->occur_time.ms) ) {
last_occur_time=jou_entry->occur_time;
//append_db_records(LOG_IDX);
}
printf("\nbrf convert_btod_to_apr_time");
t = convert_btod_to_apr_time(&jou_entry->occur_time);
//set_log_TimeID(convert_btod_to_apr_time(&jou_entry->occur_time));
if (jou_entry->entry_form_tag == 2)
{
printf("\nbrf jou_entry->ef.data.list_of_var_pres");
if (jou_entry->ef.data.list_of_var_pres)
{
//for (j = 0; j < jou_entry->ef.data.num_of_var; j++)
//{
// printf ("\n Var # %d: var_tag = %s", j, jou_entry->ef.data.list_of_var[j].var_tag);
// printf ("\n Var # %d: value_spec.len = %d", j,jou_entry->ef.data.list_of_var[j].value_spec.len);
//}
start = sGetMsTime();
printf("\nbrf process_jou_entry");
process_jou_entry(loginfo,t,jou_entry, clientNetInfo, dom_name, iTimeout) ;
//start = sGetMsTime();
if ( jread_resp->more_follows == 0 && ((i + 1) == jread_resp->num_of_jou_entry)) {
printf("\njread_resp->more_follows == 0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
json_block_create_end(loginfo->LD_info->mp_id, 0);//more followsΪ0 <20><><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> ǿ<>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD><CCAC><EFBFBD>ݵ<EFBFBD>json<6F><6E>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
json_block_create_end(loginfo->LD_info->mp_id, 1);
json_block_create_end(loginfo->LD_info->mp_id, 2);
ied_t* ied;
ied = find_ied_from_dev_code(loginfo->LD_info->terminal_code);
ied_usr_t* ied_usr = (ied_usr_t*)ied->usr_ext;
json_block_create_start(loginfo->LD_info->voltage_level, loginfo->LD_info->mp_id, 0, ied_usr->dev_type, loginfo->LD_info->line_id);//<2F><><EFBFBD>ͽ<EFBFBD><CDBD><EFBFBD> <20><><EFBFBD>³<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><C2B6><EFBFBD> <20><>̬
json_block_create_start(loginfo->LD_info->voltage_level, loginfo->LD_info->mp_id, 1, ied_usr->dev_type, loginfo->LD_info->line_id);//<2F><><EFBFBD><EFBFBD>
json_block_create_start(loginfo->LD_info->voltage_level, loginfo->LD_info->mp_id, 2, ied_usr->dev_type, loginfo->LD_info->line_id);//<2F><><EFBFBD><EFBFBD>
}
end = sGetMsTime();
}
last_check_recall_config_time = last_check_recall_config_time + end - start;
//printf("jread_resp->more_follows = 0 ==============%.2f================\n", last_check_recall_config_time);
}
else {
printf ("\n annotation = %s", jou_entry->ef.annotation);
}
//apr_time_exp_t newTime;
//apr_time_exp_gmt(&newTime, t);
printf("\nstart timecheck");
apr_time_exp_t newTime;
apr_time_exp_gmt(&newTime, process_jou_entry_t);
printf("\nstart timecheck_1");
apr_time_exp_t preTime;
apr_time_exp_gmt(&preTime, end_time);
printf("\nstart timecheck_2");
if (newTime.tm_year != preTime.tm_year || newTime.tm_mon != preTime.tm_mon || newTime.tm_mday != preTime.tm_mday || (newTime.tm_hour != preTime.tm_hour && newTime.tm_hour != preTime.tm_hour + 1 && newTime.tm_hour != preTime.tm_hour - 1)) //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ж<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><E4B3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ʱ <20><><EFBFBD><EFBFBD>
{
printf("\nstart timecheck_3");
printf("\n more_follows newTime: %d %d %d %d %d %d", newTime.tm_year, newTime.tm_mon, newTime.tm_mday, newTime.tm_hour, newTime.tm_min, newTime.tm_sec);
printf("\n more_follows preTime: %d %d %d %d %d %d", preTime.tm_year, preTime.tm_mon, preTime.tm_mday, preTime.tm_hour, preTime.tm_min, preTime.tm_sec);
more_follows = 0;
}
printf("\nstart timecheck_end");
} /* end "loop" */
}
mvl_free_req_ctrl (reqCtrl); /* CRITICAL: */
} while (more_follows);
//mvl_type_id_destroy(1);
//del_mvl_type_ctrl();
//printf("do while ==============%.2f================\n", last_check_recall_config_time);
//append_db_records(LOG_IDX);
return (ret);
}

2663
mms/mmscli_rpt.c Normal file

File diff suppressed because it is too large Load Diff

1969
mms/mmsclient.c Normal file

File diff suppressed because it is too large Load Diff

239
mms/mmsclient.h Normal file
View File

@@ -0,0 +1,239 @@
/**
* @file: $RCSfile: mmsclient.h,v $
* @brief: $IEC 61850 Protocol
*
* @version: $Revision: 1.1 $
* @date: $Date: 2018/11/24 06:54:50 $
* @author: $Author: lizhongming $
* @state: $State: Exp $
*
* @latest: $Id: mmsclient.h,v 1.1 2018/11/24 06:54:50 lizhongming Exp $
*
*/
//$Header: /JoyProject/jspqfe/src/pt61850netd_pqfe/source/mms/mmsclient.h,v 1.1 2018/11/24 06:54:50 lizhongming Exp $
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 2003 - 2003, All Rights Reserved */
/* */
/* MODULE NAME : mmsclient.h */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* Defines for sample "client" application. */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 07/22/05 JRB 05 Add rcb_type, RptID, varNameArray to RCB_INFO.*/
/* Add ALL_RCB_INFO struct. */
/* Chg u_iec_rpt_ind_data 4th arg to (RCB_INFO *).*/
/* 07/15/05 JRB 04 Add mvl_defs.h */
/* 05/13/04 JRB 03 Chg SqNum to INT16U to match 61850-7-2. */
/* 12/17/03 JRB 02 61850-8-1 FDIS changes: */
/* Add ConfRev to RCB_DATA & RCB_VAR. */
/* Chg bvstring9 to bvstring10 for OptFlds. */
/* 10/09/03 JRB 01 New */
/************************************************************************/
#ifndef SAC_MMSCLIENT_H
#define SAC_MMSCLIENT_H
#include "mvl_defs.h" /* need base MVL types. */
/* Defines required by Foundry generated code. */
/* Default values defined in "mvl_defs.h" but we don't like the defaults*/
/* so we undefine and redefine them here. */
#undef MVL_NUM_DYN_DOMS
#undef MVL_NUM_DYN_VMD_VARS
#undef MVL_NUM_DYN_VMD_NVLS
#undef MVL_NUM_DYN_JOUS
#undef MVL_NUM_DYN_DOM_VARS
#undef MVL_NUM_DYN_DOM_NVLS
#undef MVL_NUM_DYN_AA_VARS
#undef MVL_NUM_DYN_AA_NVLS
#undef MVLU_NUM_DYN_TYPES
#define MVL_NUM_DYN_DOMS 10
#define MVL_NUM_DYN_VMD_VARS 100
#define MVL_NUM_DYN_VMD_NVLS 10
#define MVL_NUM_DYN_JOUS 10
#define MVL_NUM_DYN_DOM_VARS 100
#define MVL_NUM_DYN_DOM_NVLS 10
#define MVL_NUM_DYN_AA_VARS 10
#define MVL_NUM_DYN_AA_NVLS 10
//???? should change if servers num is large ??????
#define MVLU_NUM_DYN_TYPES 65535+20000 /* important for UCA */
/* Struct to store common type ids needed for IEC/UCA Reports. */
typedef struct
{
ST_INT mmsbool; /* named so not confused with C++ 'bool' type */
ST_INT int8u;
ST_INT int16u; /* for SqNum. */
/* NOTE: UCA server sends int8u for SqNum */
/* but it's safe to decode it as int16u */
ST_INT int32u; /* for IntgPd */
ST_INT vstring65; /* for RptID & ObjectReference */
ST_INT btime6; /* for EntryTime */
ST_INT ostring8; /* for EntryID */
ST_INT vstring32; /* for RptId */
ST_INT bvstring6; /* for TrgOps (IEC) */
ST_INT bvstring8; /* for OptFlds,TrgOps (UCA) */
ST_INT bvstring10; /* for OptFlds (IEC) */
ST_INT bstr6; /* for Reason (IEC) */
ST_INT bstr8; /* for Reason (UCA) */
ST_INT bstr9; /* for Writing OptFlds (IEC). Can't write all 10 bits.*/
} RPT_TYPEIDS;
typedef struct
{
ST_CHAR RptID[66];
struct /* BVstring */
{
ST_INT16 len_1;
ST_UCHAR data_1[2]; /* BVstring9 - need 2 bytes */
} OptFlds;
ST_UINT16 SqNum;
MMS_BTIME6 TimeOfEntry;
ST_CHAR DatSetNa[66];
ST_BOOLEAN BufOvfl;
ST_UINT16 SubSeqNum;
ST_BOOLEAN MoreSegmentsFollow;
ST_UINT8 EntryID [8]; /* ostring8 */
ST_UINT32 ConfRev;
ST_UINT8 *Inclusion; /* ptr to bitstring */
/* Must alloc appropriate size */
/* buffer for bitstring. */
ST_CHAR *dataRefName; /* ptr to array of dataRefName */
MMS_BVSTRING *Reason; /* ptr to array of Reason bitstrings */
/* WARNING: this only works for variable*/
/* len bitstring up to 8 bits. */
} RCB_DATA;
typedef struct
{
MVL_VAR_ASSOC * RptID;
MVL_VAR_ASSOC * OptFlds;
MVL_VAR_ASSOC * SqNum;
MVL_VAR_ASSOC * TimeOfEntry;
MVL_VAR_ASSOC * DatSetNa;
MVL_VAR_ASSOC * BufOvfl;
MVL_VAR_ASSOC * SubSeqNum;
MVL_VAR_ASSOC * MoreSegmentsFollow;
MVL_VAR_ASSOC * EntryID;
MVL_VAR_ASSOC * ConfRev;
MVL_VAR_ASSOC * Inclusion;
MVL_VAR_ASSOC ** dataRefName; /* array of ptrs */
MVL_VAR_ASSOC ** dataValue; /* array of ptrs */
MVL_VAR_ASSOC ** Reason; /* array of ptrs */
} RCB_VAR;
typedef struct
{
DBL_LNK link; /* allows linked list of this struct */
ST_CHAR dom_Name[MAX_IDENT_LEN + 1];//WW 2023-08-29 <20><><EFBFBD><EFBFBD>
ST_CHAR rcb_name[MAX_IDENT_LEN + 1];//WW 2023-08-29 <20><><EFBFBD><EFBFBD>
ST_INT rcb_type; /* RCB_TYPE_UCA, RCB_TYPE_IEC_BRCB, etc. */
/* see RCB_TYPE.. defines in 'mvl_uca.h'. */
ST_CHAR RptID [66]; /* RptID of this RCB (Vstring65) */
OBJECT_NAME **varNameArray; /* array of variable names in NVL */
ST_INT numDsVar; /* num variables in rpt dataset */
ST_INT *typeIdArr; /* array of type ids */
ST_INT InclusionTypeid; /*Type ID for Inclusion Bitstring*/
RCB_DATA rcb_data;
RCB_VAR rcb_var;
ST_CHAR ds_Nam[MAX_IDENT_LEN * 2];//WW 2023-08-29 <20><><EFBFBD><EFBFBD>
} RCB_INFO;
typedef struct
{
RPT_TYPEIDS *rpt_typeids;
RCB_INFO *rcb_info_list; /* linked list of RCB_INFO structs */
} ALL_RCB_INFO; /* used to track multiple RCBs. */
/////////////////////////////////
//WW 2023-08-29 <20><><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>ն˲<D5B6><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƿ<EFBFBD>
typedef struct
{
DBL_LNK l; //<2F><><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׵<EFBFBD>ַ
ST_CHAR IP[MAX_IDENT_LEN]; //װ<><D7B0>IP[64]
int Port; //<2F>˿ں<CBBF>
} Dev_IP_Port_INFO; //װ<><D7B0>IP<49><50><EFBFBD>˿ںŽṹ
typedef struct
{
DBL_LNK l; //<2F><><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׵<EFBFBD>ַ
ST_CHAR dev_type_name[MAX_IDENT_LEN * 2]; //װ<><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[128]
Dev_IP_Port_INFO * dev_ip_port_list; //װ<><D7B0>IP<49><50><EFBFBD>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
RCB_INFO *rcb_info_list; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƿ<EFBFBD><C6BF><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
} Dev_RCB_INFO; //װ<>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD>
typedef struct //zl 2019-12-26 12:24:06
{
DBL_LNK l; //<2F><><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׵<EFBFBD>ַ
Dev_RCB_INFO *dev_rcb_info_Head;
} DEV_TYPE_LIST; //
extern DEV_TYPE_LIST gDev_rcb_list; //ȫ<>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƿ<EFBFBD><C6BF><EFBFBD><EFBFBD><EFBFBD>
//WW 2023-08-29 end
/////////////////////////////////////
/************************************************************************/
/* Global variables. */
/************************************************************************/
/* NONE */
/************************************************************************/
/* Function prototypes. */
/************************************************************************/
ST_RET waitReqDone (MVL_REQ_PEND *req, ST_INT timeout);
void doCommForSecs (ST_INT timeout);
ST_VOID doCommService (ST_VOID);
ST_RET rpt_typeids_find (RPT_TYPEIDS *rpt_typeids);
RCB_INFO *rcb_info_create (MVL_NET_INFO *net_info, ST_CHAR *domName,
ST_CHAR *rcbName, RPT_TYPEIDS *rpt_typeids, ST_INT timeOut);
ST_VOID rcb_info_destroy (RCB_INFO *rcb_info);
ST_RET rcb_enable (MVL_NET_INFO *netInfo, ST_CHAR *domName,
ST_CHAR *rcbName, ST_UCHAR *OptFlds, ST_UCHAR *TrgOps,
ST_UINT32 IntgPd, RPT_TYPEIDS *rpt_typeids, ST_INT timeOut);
ST_RET rcb_disable (MVL_NET_INFO *netInfo, ST_CHAR *domName,
ST_CHAR *rcbName, RPT_TYPEIDS *rpt_typeids, ST_INT timeOut);
/* Simple functions to read/write a single variable. */
ST_RET mms_named_var_read (MVL_NET_INFO *net_info, ST_CHAR *varName,
ST_INT scope, ST_CHAR *domName,
ST_INT type_id, ST_VOID *dataDest, ST_INT timeOut);
ST_RET mms_named_var_write (MVL_NET_INFO *netInfo, ST_CHAR *varName,
ST_INT scope, ST_CHAR *domName,
ST_INT type_id, ST_VOID *dataSrc, ST_INT timeOut);
ST_RET mms_release_connection (MVL_NET_INFO *clientNetInfo);
ST_RET u_iec_rpt_ind (MVL_COMM_EVENT *event);
ST_VOID u_iec_rpt_ind_data (MVL_VAR_ASSOC **info_va,
ST_UINT8 *OptFldsData, /* ptr to data part of OptFlds bvstring */
ST_UINT8 *InclusionData, /* ptr to Inclusion bstring */
RCB_INFO *rcb_info,
ST_INT va_total,
MVL_NET_INFO *net_info);
////////////////////////////////
//WW 2023-08-30<33><30><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD><D3B1><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD>
ST_RET u_iec_rpt_ind_by_devtype(MVL_COMM_EVENT *event);
ST_VOID u_iec_rpt_ind_data_by_devtype(MVL_VAR_ASSOC **info_va,
ST_UINT8 *OptFldsData, /* ptr to data part of OptFlds bvstring */
ST_UINT8 *InclusionData, /* ptr to Inclusion bstring */
RCB_INFO *rcb_info,
ST_INT va_total,
MVL_NET_INFO *net_info);
//WW 2023-08-30 end
////////////////////////////////
#endif //SAC_MMSCLIENT_H

245
mms/mmslvar.c Normal file
View File

@@ -0,0 +1,245 @@
/**
* @file: $RCSfile: mmslvar.c,v $
* @brief: $IEC 61850 Protocol
*
* @version: $Revision: 1.1 $
* @date: $Date: 2018/11/24 06:54:50 $
* @author: $Author: lizhongming $
* @state: $State: Exp $
*
* @latest: $Id: mmslvar.c,v 1.1 2018/11/24 06:54:50 lizhongming Exp $
*
*/
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1993 - 2005, All Rights Reserved. */
/* */
/* PROPRIETARY AND CONFIDENTIAL */
/* */
/* MODULE NAME : mmslvar.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* All global MMSEASE-LITE variables are defined in this module, */
/* and declared in LMMSDEFS.H */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* NONE */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 06/22/05 JRB 13 Remove static from usrLog* var. */
/* 06/06/05 EJV 12 usrLogMaskMapCtrl not used when FOUNDRY def. */
/* 05/23/05 EJV 11 Add xxxLogMaskMapCtrl for parsing logcfg.xml */
/* 09/04/03 EJV 10 Chg mms_debug_sel to ST_UINT (from ST_UINT32)*/
/* 03/13/03 JRB 09 Del u_ml_get_rt_type func ptr, it is func now*/
/* 01/02/03 JRB 08 Add arg to u_ml_get_rt_type. */
/* 03/15/01 JRB 07 Added user_debug_sel & _user_*_logstr */
/* 09/13/99 MDE 06 Added SD_CONST modifiers */
/* 02/23/99 JRB 05 Don't init m_data_algn_tbl, it's a constant. */
/* 10/21/98 MDE 04 Removed VMS ifdef */
/* 10/08/98 MDE 03 Migrated to updated SLOG interface */
/* 11/05/97 MDE 02 Changed mmsl_msg_start to ST_UCHAR * */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_err.h"
#include "mms_pvar.h"
#include "mms_vvar.h"
/************************************************************************/
/************************************************************************/
/* MMSEASE-LITE Global Variables */
/************************************************************************/
ST_INT mmsl_enc_buf_size;
ST_UCHAR *mmsl_enc_buf;
ST_INT mmsl_dec_info_size;
#if !defined(NO_GLB_VAR_INIT)
ST_INT16 mmsl_version = 1; /* select IS for version */
ST_UINT32 mmsl_invoke_id = 1;
#else
ST_INT16 mmsl_version; /* select IS for version */
ST_UINT32 mmsl_invoke_id;
#endif
ST_UCHAR *mmsl_msg_start;
ST_INT mmsl_msg_len;
/************************************************************************/
/* Variables in common with MMS-EASE */
#if !defined(NO_GLB_VAR_INIT)
ST_UINT _mmsdec_ctxt = MMS_PCI;/* decode context type, default to core */
ST_INT m_use_long_ints = SD_TRUE;
#else
ST_UINT _mmsdec_ctxt; /* decode context type, default to core */
ST_INT m_use_long_ints;
#endif
ST_INT _mmsdec_msglen; /* MMS decode message length */
ST_UCHAR *_mmsdec_msgptr; /* MMS decode message ptr */
ST_BOOLEAN _mms_dec_info_pres;
MMSDEC_INFO *_mmsdec_rslt;
ST_VOID *_mms_dec_info;
ADTNL_ERR_RESP_INFO adtnl_err_info;
ST_RET mms_op_err;
/************************************************************************/
/************************************************************************/
/************************************************************************/
/* Some Alternate Access related variables. These are defined in */
/* mmsvar.c for MMS-EASE, but are put here for MMS-LITE */
#if !defined(NO_GLB_VAR_INIT)
ST_INT m_max_dec_aa = 50;
ST_INT m_max_rt_aa_ctrl = 1000;
#else
ST_INT m_max_dec_aa;
ST_INT m_max_rt_aa_ctrl;
#endif
ST_INT m_hw_dec_aa;
ST_INT m_hw_rt_aa_ctrl;
ST_BOOLEAN m_alt_acc_packed;
/************************************************************************/
/************************************************************************/
/* This variable can be set to force use of the DIS MMS floating point */
/* type protocol (used in any over the wire and internal ASN.1 type */
/* definitions). */
/************************************************************************/
ST_BOOLEAN m_use_dis_float;
/************************************************************************/
/* Global variables for modifier support */
/************************************************************************/
#if !defined (NO_GLB_VAR_INIT)
LIST_OF_MODS modifier_list; /* used to encode modifier info */
ST_INT m_max_mods = 1; /* num of modifier structs calloced during dec. */
#else
LIST_OF_MODS modifier_list;
ST_INT m_max_mods;
#endif
/************************************************************************/
/* Global variables for compantion standard (IS) */
/************************************************************************/
CSI cs_send; /* SEND CS info structure */
ST_BOOLEAN cs_send_reset_val;
/************************************************************************/
/* Logging variables */
/************************************************************************/
#if !defined(NO_GLB_VAR_INIT)
ST_UINT mms_debug_sel = MMS_LOG_ERR;
ST_UINT user_debug_sel = USER_LOG_ERR;
#else
ST_UINT mms_debug_sel;
ST_UINT user_debug_sel;
#endif
#ifdef DEBUG_SISCO
SD_CONST ST_CHAR *SD_CONST _mms_log_dec_logstr = "MMS_LOG_DEC";
SD_CONST ST_CHAR *SD_CONST _mms_log_enc_logstr = "MMS_LOG_ENC";
SD_CONST ST_CHAR *SD_CONST _mms_log_acse_logstr = "MMS_LOG_ACSE";
SD_CONST ST_CHAR *SD_CONST _mms_log_llc_logstr = "MMS_LOG_LLC";
SD_CONST ST_CHAR *SD_CONST _mms_log_ique_logstr = "MMS_LOG_IQUE";
SD_CONST ST_CHAR *SD_CONST _mms_log_rque_logstr = "MMS_LOG_RQUE";
SD_CONST ST_CHAR *SD_CONST _mms_log_ind_logstr = "MMS_LOG_IND";
SD_CONST ST_CHAR *SD_CONST _mms_log_conf_logstr = "MMS_LOG_CONF";
SD_CONST ST_CHAR *SD_CONST _mms_log_vm_logstr = "MMS_LOG_VM";
SD_CONST ST_CHAR *SD_CONST _mms_log_err_logstr = "MMS_LOG_ERR";
SD_CONST ST_CHAR *SD_CONST _mms_log_nerr_logstr = "MMS_LOG_NERR";
SD_CONST ST_CHAR *SD_CONST _mms_log_pdu_logstr = "MMS_LOG_PDU";
SD_CONST ST_CHAR *SD_CONST _mms_log_config_logstr = "MMS_LOG_CONFIG";
SD_CONST ST_CHAR *SD_CONST _mms_log_always_logstr = "MMS_LOG_ALWAYS";
SD_CONST ST_CHAR *SD_CONST _user_err_logstr = "USER_LOG_ERR";
SD_CONST ST_CHAR *SD_CONST _user_client_logstr = "USER_LOG_CLIENT";
SD_CONST ST_CHAR *SD_CONST _user_server_logstr = "USER_LOG_SERVER";
LOGCFGX_VALUE_MAP mmsLogMaskMaps[] =
{
{"MMS_LOG_ERR", MMS_LOG_ERR, &mms_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Error"},
{"MMS_LOG_NERR", MMS_LOG_NERR, &mms_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Notice"},
{"MMS_LOG_DEC", MMS_LOG_DEC, &mms_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Decode"},
{"MMS_LOG_ENC", MMS_LOG_ENC, &mms_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Encode"},
{"MMS_LOG_CLIENT", MMS_LOG_REQ|MMS_LOG_CONF, &mms_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Client"},
{"MMS_LOG_SERVER", MMS_LOG_IND|MMS_LOG_RESP, &mms_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Server"},
{"MMS_LOG_REQ", MMS_LOG_REQ, &mms_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Request"},
{"MMS_LOG_RESP", MMS_LOG_RESP, &mms_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Response"},
{"MMS_LOG_IND", MMS_LOG_IND, &mms_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Indication"},
{"MMS_LOG_CONF", MMS_LOG_CONF, &mms_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Confirm"},
{"MMS_LOG_RT", MMS_LOG_RT, &mms_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Runtime Type"},
{"MMS_LOG_RTAA", MMS_LOG_RTAA, &mms_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Runtime Type Alternate Access"},
{"MMS_LOG_AA", MMS_LOG_AA, &mms_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Alternate Access"},
};
LOGCFG_VALUE_GROUP mmsLogMaskMapCtrl =
{
{NULL,NULL},
"MMS",
sizeof(mmsLogMaskMaps)/sizeof(LOGCFGX_VALUE_MAP),
mmsLogMaskMaps
};
LOGCFGX_VALUE_MAP usrLogMaskMaps[] =
{
{"USER_LOG_ERR", USER_LOG_ERR, &user_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Error"},
{"USER_LOG_CLIENT", USER_LOG_CLIENT, &user_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Client"},
{"USER_LOG_SERVER", USER_LOG_SERVER, &user_debug_sel, _LOGCFG_DATATYPE_UINT_MASK, "Server"}
};
LOGCFG_VALUE_GROUP usrLogMaskMapCtrl =
{
{NULL,NULL},
"User",
sizeof(usrLogMaskMaps)/sizeof(LOGCFGX_VALUE_MAP),
usrLogMaskMaps
};
#endif /* DEBUG_SISCO */
/************************************************************************/
/* m_init_glb_vars */
/************************************************************************/
#if defined(NO_GLB_VAR_INIT)
ST_VOID a_init_glb_vars (ST_VOID);
ST_VOID m_init_glb_vars (ST_VOID)
{
a_init_glb_vars ();
mmsl_version = 1;
mmsl_invoke_id = 1;
_mmsdec_ctxt = MMS_PCI;
m_use_long_ints = SD_TRUE;
m_max_mods = 1;
mms_debug_sel = MMS_LOG_ERR;
#if defined(NO_GLB_VAR_INIT)
if (!m_data_algn_tbl)
m_data_algn_tbl = m_packed_data_algn_tbl;
#endif
m_max_dec_aa = 50;
m_max_rt_aa_ctrl = 1000;
}
#endif

3490
mms/mmsop_en.c Normal file

File diff suppressed because it is too large Load Diff

190
mms/mmsop_en.h Normal file
View File

@@ -0,0 +1,190 @@
/*
* @version: $Revision: 1.1 $
* @date: $Date: 2018/11/24 06:54:51 $
* @author: $Author: lizhongming $
* @state: $State: Exp $
*
* @latest: $Id: mmsop_en.h,v 1.1 2018/11/24 06:54:51 lizhongming Exp $
*
*/
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1986 - 1997, All Rights Reserved. */
/* */
/* MODULE NAME : mmsop_en.h */
/* PRODUCT(S) : MMSEASE, MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* This module contains the operation enable switches used to */
/* configure the decode system, the user service system, & the */
/* supported services bit strings. */
/* */
/* Note that by enabling (or disabling) only the desired MMS */
/* operations, a limited subset may be created (the subset */
/* creation module is mmsop_en.c), thus allowing the creation of */
/* a smaller executable because: */
/* 1) references to the various MMS-EASE functions are removed */
/* and therefore are not included from the library, and */
/* 2) operation specific user application code is eliminated. */
/* */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 10/15/99 GLB 02 Added file Rename & Obtain File */
/* 08/18/97 MDE 01 Added parameter support defines */
/* 04/02/97 DTL 7.00 MMSEASE 7.0 release. See MODL70.DOC for */
/* history. */
/************************************************************************/
#ifndef MMSOP_EN_INCLUDED
#define MMSOP_EN_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
#include "mms_def2.h" /* for REQ_RESP_EN, etc. */
/************************************************************************/
/* define the opcode enable switches */
/************************************************************************/
#define MMS_INIT_EN REQ_EN
#define MMS_CONCLUDE_EN REQ_EN
#define MMS_CANCEL_EN REQ_RESP_DIS
#define MMS_STATUS_EN REQ_EN
#define MMS_USTATUS_EN REQ_RESP_DIS
#define MMS_GETNAMES_EN REQ_EN
#define MMS_IDENT_EN REQ_RESP_EN
#define MMS_RENAME_EN REQ_RESP_DIS
#define MMS_GETCL_EN REQ_RESP_DIS
#define MMS_VMD_EN 0
#define MMS_NAMED_DOM_EN 0
#define MMS_MV_DWN_EN REQ_RESP_DIS /* VM Upload */
#define MMS_INIT_DWN_EN REQ_RESP_DIS
#define MMS_DWN_LOAD_EN REQ_RESP_DIS
#define MMS_TERM_DWN_EN REQ_RESP_DIS
#define MMS_MV_UPL_EN REQ_RESP_DIS /* VM Download */
#define MMS_INIT_UPL_EN REQ_RESP_DIS
#define MMS_UP_LOAD_EN REQ_RESP_DIS
#define MMS_TERM_UPL_EN REQ_RESP_DIS
#define MMS_RDDWN_EN REQ_RESP_DIS
#define MMS_RDUPL_EN REQ_RESP_DIS
#define MMS_LOAD_DOM_EN REQ_RESP_DIS
#define MMS_STR_DOM_EN REQ_RESP_DIS
#define MMS_DEL_DOM_EN REQ_RESP_DIS
#define MMS_GET_DOM_EN REQ_EN
#define MMS_CRE_PI_EN REQ_RESP_DIS
#define MMS_DEL_PI_EN REQ_RESP_DIS
#define MMS_START_EN REQ_RESP_DIS
#define MMS_STOP_EN REQ_RESP_DIS
#define MMS_RESUME_EN REQ_RESP_DIS
#define MMS_RESET_EN REQ_RESP_DIS
#define MMS_KILL_EN REQ_RESP_DIS
#define MMS_GET_PI_EN REQ_RESP_DIS
#define MMS_VA_EN 0
#define MMS_MV_READ_EN REQ_RESP_DIS /* VM Read variable(s) */
#define MMS_MV_RDVARS_EN REQ_RESP_DIS /* General VM Rd var's */
#define MMS_READ_EN REQ_EN
#define MMS_MV_WRITE_EN REQ_RESP_DIS /* VM Write variable(s) */
#define MMS_MV_WRVARS_EN REQ_RESP_DIS /* General VM WR var's */
#define MMS_WRITE_EN REQ_EN
#define MMS_INFO_EN RESP_EN
#define MMS_GETVAR_EN REQ_EN
#define MMS_DEFVAR_EN REQ_RESP_DIS
#define MMS_DEFSCAT_EN REQ_RESP_DIS
#define MMS_GETSCAT_EN REQ_RESP_DIS
#define MMS_DELVAR_EN REQ_RESP_DIS
#define MMS_DEFVLIST_EN REQ_EN
#define MMS_GETVLIST_EN REQ_EN
#define MMS_DELVLIST_EN REQ_EN
#define MMS_MV_DEFTYPE_EN REQ_RESP_DIS /* VM DefineType */
#define MMS_DEFTYPE_EN REQ_RESP_DIS
#define MMS_GETTYPE_EN REQ_RESP_DIS
#define MMS_DELTYPE_EN REQ_RESP_DIS
#define MMS_TAKECTRL_EN REQ_RESP_DIS
#define MMS_RELCTRL_EN REQ_RESP_DIS
#define MMS_DEFINE_SEM_EN REQ_RESP_DIS
#define MMS_DELETE_SEM_EN REQ_RESP_DIS
#define MMS_REP_SEMSTAT_EN REQ_RESP_DIS
#define MMS_REP_SEMPOOL_EN REQ_RESP_DIS
#define MMS_REP_SEMENTRY_EN REQ_RESP_DIS
#define MMS_JREAD_EN REQ_EN
#define MMS_JWRITE_EN REQ_RESP_DIS
#define MMS_JINIT_EN REQ_EN
#define MMS_JSTAT_EN REQ_EN
#define MMS_JCREATE_EN REQ_RESP_DIS
#define MMS_JDELETE_EN REQ_RESP_DIS
#define MMS_DEFEC_EN REQ_RESP_DIS
#define MMS_DELEC_EN REQ_RESP_DIS
#define MMS_GETECA_EN REQ_RESP_DIS
#define MMS_REPECS_EN REQ_RESP_DIS
#define MMS_ALTECM_EN REQ_RESP_DIS
#define MMS_TRIGE_EN REQ_RESP_DIS
#define MMS_DEFEA_EN REQ_RESP_DIS
#define MMS_DELEA_EN REQ_RESP_DIS
#define MMS_GETEAA_EN REQ_RESP_DIS
#define MMS_REPEAS_EN REQ_RESP_DIS
#define MMS_DEFEE_EN REQ_RESP_DIS
#define MMS_DELEE_EN REQ_RESP_DIS
#define MMS_GETEEA_EN REQ_RESP_DIS
#define MMS_REPEES_EN REQ_RESP_DIS
#define MMS_ALTEE_EN REQ_RESP_DIS
#define MMS_EVNOT_EN REQ_RESP_DIS
#define MMS_ACKEVNOT_EN REQ_RESP_DIS
#define MMS_GETAS_EN REQ_RESP_DIS
#define MMS_GETAES_EN REQ_RESP_DIS
#define MMS_INPUT_EN REQ_RESP_DIS
#define MMS_OUTPUT_EN REQ_RESP_DIS
#define MMS_MV_FOPEN_EN REQ_RESP_DIS /* VM FileOpen */
#define MMS_MV_FREAD_EN REQ_RESP_DIS /* VM FileRead */
#define MMS_MV_FCLOSE_EN REQ_RESP_DIS /* VM FileClose */
#define MMS_MV_FCOPY_EN REQ_RESP_DIS /* VM FileCopy */
#define MMS_OBTAINFILE_EN REQ_EN
#define MMS_FOPEN_EN REQ_RESP_EN
#define MMS_FREAD_EN REQ_RESP_EN
#define MMS_FCLOSE_EN REQ_RESP_EN
#define MMS_FRENAME_EN REQ_EN
#define MMS_FDELETE_EN REQ_EN
#define MMS_FDIR_EN REQ_EN
/************************************************************************/
/************************************************************************/
/* PARAMETER SUPPORTED BITSTRING VALUES */
/************************************************************************/
#define MPARAM_STR1 0x80 /* 0x80 arrays */
#define MPARAM_STR2 0x40 /* 0x40 structures */
#define MPARAM_VNAM 0x20 /* 0x20 named variables */
#define MPARAM_VALT 0x10 /* 0x10 alternate access */
#define MPARAM_VADR 0x08 /* 0x08 address formed variables */
#define MPARAM_VSCA 0x00 /* 0x04 scattered access */
#define MPARAM_TPY 0x02 /* 0x02 third party */
#define MPARAM_VLIS 0x01 /* 0x01 variable list */
#define MPARAM_REAL 0x00 /* 0x80 real data type */
#define MPARAM_AKEC 0x00 /* 0x40 ack event cond. */
#define MPARAM_CEI 0x00 /* 0x20 cond. eval. interval */
#define MPARAM0 MPARAM_STR1 | MPARAM_STR2 | MPARAM_VNAM | MPARAM_VALT |\
MPARAM_VADR | MPARAM_VSCA | MPARAM_TPY | MPARAM_VLIS
#define MPARAM1 MPARAM_REAL | MPARAM_AKEC | MPARAM_CEI
#ifdef __cplusplus
}
#endif
#endif /* MMSOP_EN_INCLUDED */

2392
mms/mvl_acse.c Normal file

File diff suppressed because it is too large Load Diff

928
mms/mvlop_en.c Normal file
View File

@@ -0,0 +1,928 @@
/*
* @version: $Revision: 1.2 $
* @date: $Date: 2018/12/20 06:00:55 $
* @author: $Author: lizhongming $
* @state: $State: Exp $
*
* @latest: $Id: mvlop_en.c,v 1.2 2018/12/20 06:00:55 lizhongming Exp $
*
*/
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 1996, All Rights Reserved */
/* */
/* MODULE NAME : mvlop_en.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_cancel_ind_rcvd */
/* mvl_concl_ind_rcvd */
/* mvl_concl_conf_rcvd */
/* mvl_ind_rcvd */
/* mvl_conf_rcvd */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------ */
/* 11/12/07 MDE 17 Added _mvl_getpath, changed _mvl_tmpnam */
/* 08/12/05 JRB 16 Add #error if unsupported service enabled. */
/* 10/20/03 JRB 15 Fix print formats. */
/* 02/04/03 MDE 14 Added _mvl_tmpnam */
/* 07/09/02 MDE 13 Add maxpend_ind support */
/* 05/21/01 MDE 12 Now check return from indication ctrl alloc */
/* 03/15/01 JRB 11 Added call to _mvl_process_ustatus_ind. */
/* 10/25/00 JRB 10 Added #ifdef ICCP_LITE. */
/* 09/25/00 JRB 09 Added server support for Domain & PI services*/
/* 09/25/00 JRB 08 Total rewrite without function pointers. */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mvl_defs.h"
#include "mmsop_en.h"
#include "mvl_log.h"
#if defined(ICCP_LITE)
#include "mi.h"
#endif
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* mvl_cancel_ind_rcvd */
/* A MMS Cancel Indication has been received. Process it. */
/************************************************************************/
ST_VOID mvl_cancel_ind_rcvd (MVL_COMM_EVENT *event)
{
#if (MMS_CANCEL_EN & RESP_EN)
_mvl_process_cancel_ind (event);
#else
_mvl_send_reject (event);
#endif
}
/************************************************************************/
/* mvl_concl_ind_rcvd */
/* A MMS Conclude Indication has been received. Process it. */
/************************************************************************/
ST_VOID mvl_concl_ind_rcvd (MVL_COMM_EVENT *event)
{
#if (MMS_CONCLUDE_EN & RESP_EN)
_mvl_process_concl_ind (event);
#else
_mvl_send_reject (event);
#endif
}
/************************************************************************/
/* mvl_concl_conf_rcvd */
/* A MMS Conclude Confirm has been received. Process it. */
/************************************************************************/
ST_VOID mvl_concl_conf_rcvd (MVL_REQ_PEND *req_pend)
{
#if (MMS_CONCLUDE_EN & REQ_EN)
_mvl_process_concl_conf (req_pend);
#else
_mvl_conf_reject (req_pend);
#endif
}
/************************************************************************/
/* mvl_ind_rcvd */
/* A MMS request has been received. This is where the real action */
/* takes place, and the response is generated */
/* NOTE: if a service is NOT enabled, the "switch" falls through to the */
/* default case which sends a reject. */
/************************************************************************/
ST_VOID mvl_ind_rcvd (MVL_COMM_EVENT *event)
{
MVL_IND_PEND *indCtrl;
/* Information Reports & Unsol Status are special cases. Process first.*/
/* 1. "event" used instead of "indCtrl". */
/* 2. Keep different statistics. */
if (event->u.mms.dec_rslt.op == MMSOP_INFO_RPT)
{
#if (MMS_INFO_EN & RESP_EN)
#if defined(ICCP_LITE)
_mic_process_info_ind (event);
#else
_mvl_process_info_ind (event);
#endif
#else
_mvl_send_reject (event);
#endif
++mvl_mms_statistics.clientInfoRpt;
return; /* do not continue */
}
else if (event->u.mms.dec_rslt.op == MMSOP_USTATUS)
{
#if (MMS_USTATUS_EN & RESP_EN)
_mvl_process_ustatus_ind (event);
#else
_mvl_send_reject (event);
#endif
++mvl_mms_statistics.clientUstatus;
return; /* do not continue */
}
++mvl_mms_statistics.serverInd;
indCtrl = (MVL_IND_PEND *) M_CALLOC (MSMEM_IND_CTRL, 1, sizeof (MVL_IND_PEND));
if (indCtrl == NULL)
{
MVL_LOG_NERR0 ("Could not allocate indication control, rejecting");
_mvl_send_reject (event);
return;
}
indCtrl->op = event->u.mms.dec_rslt.op;
indCtrl->event = event;
list_add_first(&(event->net_info->pend_ind),indCtrl);
++event->net_info->numpend_ind;
switch (event->u.mms.dec_rslt.op)
{
#if (MMS_READ_EN & RESP_EN)
case MMSOP_READ :
#if defined(ICCP_LITE)
_mis_process_read_ind (indCtrl);
#else
_mvl_process_read_ind (indCtrl);
#endif
break;
#endif
#if (MMS_WRITE_EN & RESP_EN)
case MMSOP_WRITE :
#if defined(ICCP_LITE)
_mis_process_write_ind (indCtrl);
#else
_mvl_process_write_ind (indCtrl);
#endif
break;
#endif
/* case MMSOP_INFO_RPT : handled before switch. */
#if (MMS_IDENT_EN & RESP_EN)
case MMSOP_IDENTIFY :
_mvl_process_ident_ind (indCtrl);
break;
#endif
#if (MMS_STATUS_EN & RESP_EN)
case MMSOP_STATUS :
_mvl_process_status_ind (indCtrl);
break;
#endif
#if (MMS_GETNAMES_EN & RESP_EN)
case MMSOP_GET_NAMLIST:
#if defined(ICCP_LITE)
_mis_process_getnam_ind (indCtrl);
#else
_mvl_process_getnam_ind (indCtrl);
#endif
break;
#endif
#if (MMS_GETVAR_EN & RESP_EN)
case MMSOP_GET_VAR:
#if defined(ICCP_LITE)
_mis_process_getvaa_ind (indCtrl);
#else
_mvl_process_getvaa_ind (indCtrl);
#endif
break;
#endif
#if (MMS_GETVLIST_EN & RESP_EN)
case MMSOP_GET_VLIST:
#if defined(ICCP_LITE)
_mis_process_getvla_ind (indCtrl);
#else
_mvl_process_getvla_ind (indCtrl);
#endif
break;
#endif
#if (MMS_FDIR_EN & RESP_EN)
case MMSOP_FILE_DIR:
_mvl_process_fdir_ind (indCtrl);
break;
#endif
#if (MMS_FOPEN_EN & RESP_EN)
case MMSOP_FILE_OPEN:
_mvl_process_fopen_ind (indCtrl);
break;
#endif
#if (MMS_FREAD_EN & RESP_EN)
case MMSOP_FILE_READ:
_mvl_process_fread_ind (indCtrl);
break;
#endif
#if (MMS_FCLOSE_EN & RESP_EN)
case MMSOP_FILE_CLOSE:
_mvl_process_fclose_ind (indCtrl);
break;
#endif
#if (MMS_FDELETE_EN & RESP_EN)
case MMSOP_FILE_DELETE:
_mvl_process_fdelete_ind (indCtrl);
break;
#endif
#if (MMS_OBTAINFILE_EN & RESP_EN)
case MMSOP_OBTAIN_FILE:
_mvl_process_obtfile_ind (indCtrl);
break;
#endif
#if (MMS_FRENAME_EN & RESP_EN)
case MMSOP_FILE_RENAME:
_mvl_process_frename_ind (indCtrl);
break;
#endif
#if (MMS_DEFVLIST_EN & RESP_EN)
case MMSOP_DEF_VLIST:
#if defined(ICCP_LITE)
_mis_process_defvl_ind (indCtrl);
#else
_mvl_process_defvlist_ind (indCtrl);
#endif
break;
#endif
#if (MMS_DELVLIST_EN & RESP_EN)
case MMSOP_DEL_VLIST:
#if defined(ICCP_LITE)
_mis_process_delvlist_ind (indCtrl);
#else
_mvl_process_delvlist_ind (indCtrl);
#endif
break;
#endif
#if (MMS_JINIT_EN & RESP_EN)
case MMSOP_INIT_JOURNAL:
_mvl_process_jinit_ind (indCtrl);
break;
#endif
#if (MMS_JREAD_EN & RESP_EN)
case MMSOP_READ_JOURNAL:
_mvl_process_jread_ind (indCtrl);
break;
#endif
#if (MMS_JSTAT_EN & RESP_EN)
case MMSOP_STAT_JOURNAL:
_mvl_process_jstat_ind (indCtrl);
break;
#endif
#if (MMS_INIT_DWN_EN & RESP_EN)
case MMSOP_INIT_DOWNLOAD: /* initiate download sequence */
_mvl_process_initdown_ind (indCtrl);
break;
#endif
#if (MMS_DWN_LOAD_EN & RESP_EN)
case MMSOP_DOWN_LOAD: /* download segment */
_mvl_process_download_ind (indCtrl);
break;
#endif
#if (MMS_TERM_DWN_EN & RESP_EN)
case MMSOP_TERM_DOWNLOAD: /* terminate download sequence */
_mvl_process_termdown_ind (indCtrl);
break;
#endif
#if (MMS_INIT_UPL_EN & RESP_EN)
case MMSOP_INIT_UPLOAD: /* initiate upload sequence */
_mvl_process_initupl_ind (indCtrl);
break;
#endif
#if (MMS_UP_LOAD_EN & RESP_EN)
case MMSOP_UP_LOAD: /* upload segment */
_mvl_process_upload_ind (indCtrl);
break;
#endif
#if (MMS_TERM_UPL_EN & RESP_EN)
case MMSOP_TERM_UPLOAD: /* terminate upload sequence */
_mvl_process_termupl_ind (indCtrl);
break;
#endif
#if (MMS_DEL_DOM_EN & RESP_EN)
case MMSOP_DELETE_DOMAIN: /* delete domain */
_mvl_process_deldom_ind (indCtrl);
break;
#endif
#if (MMS_GET_DOM_EN & RESP_EN)
case MMSOP_GET_DOM_ATTR: /* get domain attribute */
_mvl_process_getdom_ind (indCtrl);
break;
#endif
#if (MMS_CRE_PI_EN & RESP_EN)
case MMSOP_CREATE_PI: /* create program invocation */
_mvl_process_crepi_ind (indCtrl);
break;
#endif
#if (MMS_DEL_PI_EN & RESP_EN)
case MMSOP_DELETE_PI: /* delete program invocation */
_mvl_process_delpi_ind (indCtrl);
break;
#endif
#if (MMS_START_EN & RESP_EN)
case MMSOP_START: /* start */
_mvl_process_start_ind (indCtrl);
break;
#endif
#if (MMS_STOP_EN & RESP_EN)
case MMSOP_STOP: /* stop */
_mvl_process_stop_ind (indCtrl);
break;
#endif
#if (MMS_RESUME_EN & RESP_EN)
case MMSOP_RESUME: /* resume */
_mvl_process_resume_ind (indCtrl);
break;
#endif
#if (MMS_RESET_EN & RESP_EN)
case MMSOP_RESET: /* reset */
_mvl_process_reset_ind (indCtrl);
break;
#endif
#if (MMS_KILL_EN & RESP_EN)
case MMSOP_KILL: /* kill */
_mvl_process_kill_ind (indCtrl);
break;
#endif
#if (MMS_GET_PI_EN & RESP_EN)
case MMSOP_GET_PI_ATTR: /* get program invocation attribute */
_mvl_process_getpi_ind (indCtrl);
break;
#endif
#if (MMS_GETCL_EN & RESP_EN)
case MMSOP_GET_CAP_LIST: /* get capability list */
_mvl_process_getcl_ind (indCtrl);
break;
#endif
default :
_mvl_ind_reject (indCtrl);
break;
}
}
/************************************************************************/
/* mvl_conf_rcvd */
/* A MMS response has been received. This is where the real action */
/* takes place, and the response data is interpreted */
/* NOTE: if a service is NOT enabled, the "switch" falls through to the */
/* default case which sends a reject. */
/************************************************************************/
ST_VOID mvl_conf_rcvd (MVL_COMM_EVENT *event)
{
MVL_REQ_PEND *req_pend;
ST_UINT32 id;
ST_INT op;
++mvl_mms_statistics.clientReqOk;
id = event->u.mms.dec_rslt.id;
op = event->u.mms.dec_rslt.op;
event->net_info->numpend_req--;
/* First find the associated request control structure */
req_pend = _mvl_find_req_ctrl (event->net_info, op, id);
if (!req_pend)
{
MVL_LOG_NERR1 ("%s Confirmation : mvl_find_req_ctrl failed",
mms_op_string [event->u.mms.dec_rslt.op]);
_mvl_free_comm_event (event); /* All done with this event */
return;
}
/* Save "event" in req_pend. Free from mvl_free_req_ctrl. */
/* This allows user code to use any data in event without copying it. */
req_pend->event = event;
switch (event->u.mms.dec_rslt.op)
{
#if (MMS_READ_EN & REQ_EN)
case MMSOP_READ :
#if defined(ICCP_LITE)
_mic_process_read_conf (req_pend);
#else
_mvl_process_read_conf (req_pend);
#endif
break;
#endif
#if (MMS_WRITE_EN & REQ_EN)
case MMSOP_WRITE :
_mvl_process_write_conf (req_pend);
break;
#endif
#if (MMS_IDENT_EN & REQ_EN)
case MMSOP_IDENTIFY :
_mvl_process_ident_conf (req_pend);
break;
#endif
#if (MMS_FOPEN_EN & REQ_EN)
case MMSOP_FILE_OPEN :
_mvl_process_fopen_conf (req_pend);
break;
#endif
#if (MMS_FREAD_EN & REQ_EN)
case MMSOP_FILE_READ :
_mvl_process_fread_conf (req_pend);
break;
#endif
#if (MMS_FCLOSE_EN & REQ_EN)
case MMSOP_FILE_CLOSE :
_mvl_process_fclose_conf (req_pend);
break;
#endif
#if (MMS_FDIR_EN & REQ_EN)
case MMSOP_FILE_DIR :
_mvl_process_fdir_conf (req_pend);
break;
#endif
#if (MMS_FDELETE_EN & REQ_EN)
case MMSOP_FILE_DELETE :
_mvl_process_fdelete_conf (req_pend);
break;
#endif
#if (MMS_FRENAME_EN & REQ_EN)
case MMSOP_FILE_RENAME :
_mvl_process_frename_conf (req_pend);
break;
#endif
#if (MMS_OBTAINFILE_EN & REQ_EN)
case MMSOP_OBTAIN_FILE :
_mvl_process_obtfile_conf (req_pend);
break;
#endif
#if (MMS_JINIT_EN & REQ_EN)
case MMSOP_INIT_JOURNAL :
_mvl_process_jinit_conf (req_pend);
break;
#endif
#if (MMS_JREAD_EN & REQ_EN)
case MMSOP_READ_JOURNAL :
_mvl_process_jread_conf (req_pend);
break;
#endif
#if (MMS_JWRITE_EN & REQ_EN)
case MMSOP_WRITE_JOURNAL :
_mvl_process_jwrite_conf (req_pend);
break;
#endif
#if (MMS_JSTAT_EN & REQ_EN)
case MMSOP_STAT_JOURNAL :
_mvl_process_jstat_conf (req_pend);
break;
#endif
#if (MMS_DEFVLIST_EN & REQ_EN)
case MMSOP_DEF_VLIST :
_mvl_process_defvlist_conf (req_pend);
break;
#endif
#if (MMS_GETVLIST_EN & REQ_EN)
case MMSOP_GET_VLIST :
_mvl_process_getvlist_conf (req_pend);
break;
#endif
#if (MMS_DELVLIST_EN & REQ_EN)
case MMSOP_DEL_VLIST :
_mvl_process_delvlist_conf (req_pend);
break;
#endif
#if (MMS_GETVAR_EN & REQ_EN)
case MMSOP_GET_VAR :
_mvl_process_getvar_conf (req_pend);
break;
#endif
#if (MMS_GETNAMES_EN & REQ_EN)
case MMSOP_GET_NAMLIST :
_mvl_process_getnam_conf (req_pend);
break;
#endif
#if (MMS_STATUS_EN & REQ_EN)
case MMSOP_STATUS :
_mvl_process_status_conf (req_pend);
break;
#endif
#if (MMS_INIT_DWN_EN & REQ_EN)
case MMSOP_INIT_DOWNLOAD: /* initiate download sequence */
_mvl_process_initdown_conf (req_pend);
break;
#endif
#if (MMS_DWN_LOAD_EN & REQ_EN)
case MMSOP_DOWN_LOAD: /* download segment */
_mvl_process_download_conf (req_pend);
break;
#endif
#if (MMS_TERM_DWN_EN & REQ_EN)
case MMSOP_TERM_DOWNLOAD: /* terminate download sequence */
_mvl_process_termdown_conf (req_pend);
break;
#endif
#if (MMS_INIT_UPL_EN & REQ_EN)
case MMSOP_INIT_UPLOAD: /* initiate upload sequence */
_mvl_process_initupl_conf (req_pend);
break;
#endif
#if (MMS_UP_LOAD_EN & REQ_EN)
case MMSOP_UP_LOAD: /* upload segment */
_mvl_process_upload_conf (req_pend);
break;
#endif
#if (MMS_TERM_UPL_EN & REQ_EN)
case MMSOP_TERM_UPLOAD: /* terminate upload sequence */
_mvl_process_termupl_conf (req_pend);
break;
#endif
#if (MMS_DEL_DOM_EN & REQ_EN)
case MMSOP_DELETE_DOMAIN: /* delete domain */
_mvl_process_deldom_conf (req_pend);
break;
#endif
#if (MMS_GET_DOM_EN & REQ_EN)
case MMSOP_GET_DOM_ATTR: /* get domain attributes */
_mvl_process_getdom_conf (req_pend);
break;
#endif
#if (MMS_CRE_PI_EN & REQ_EN)
case MMSOP_CREATE_PI: /* create program invocation */
_mvl_process_crepi_conf (req_pend);
break;
#endif
#if (MMS_DEL_PI_EN & REQ_EN)
case MMSOP_DELETE_PI: /* delete program invocation */
_mvl_process_delpi_conf (req_pend);
break;
#endif
#if (MMS_START_EN & REQ_EN)
case MMSOP_START: /* start */
_mvl_process_start_conf (req_pend);
break;
#endif
#if (MMS_STOP_EN & REQ_EN)
case MMSOP_STOP: /* stop */
_mvl_process_stop_conf (req_pend);
break;
#endif
#if (MMS_RESUME_EN & REQ_EN)
case MMSOP_RESUME: /* resume */
_mvl_process_resume_conf (req_pend);
break;
#endif
#if (MMS_RESET_EN & REQ_EN)
case MMSOP_RESET: /* reset */
_mvl_process_reset_conf (req_pend);
break;
#endif
#if (MMS_KILL_EN & REQ_EN)
case MMSOP_KILL: /* kill */
_mvl_process_kill_conf (req_pend);
break;
#endif
#if (MMS_GET_PI_EN & REQ_EN)
case MMSOP_GET_PI_ATTR: /* get program invocation attribute */
_mvl_process_getpi_conf (req_pend);
break;
#endif
#if (MMS_GETCL_EN & REQ_EN)
case MMSOP_GET_CAP_LIST: /* get capability list */
_mvl_process_getcl_conf (req_pend);
break;
#endif
default :
/* This should never happen. It means we sent a "Request" but we */
/* don't support the "Confirm" for it. */
MVL_LOG_ERR1 ("Error: Confirm received for unsupported service '%s'",
mms_op_string [event->u.mms.dec_rslt.op]);
_mvl_conf_reject (req_pend);
break;
}
_mvl_set_req_done (req_pend, req_pend->result);
}
/************************************************************************/
/************************************************************************/
/* _mvl_tmpnam */
/************************************************************************/
/* For applications that do file activity, we need this function */
#if (MMS_FOPEN_EN & REQ_EN) || (MMS_FOPEN_EN & RESP_EN)
#define MAX_TEMP_FILE_NUM 0xFFFF
#define MAX_TEMP_FILE_TRIES 0xFFFF
ST_CHAR *mvl_tmpfile_path;
//ST_RET _mvl_tmpnam (ST_CHAR *dest, ST_CHAR *tmpfile_path)
// {
//static ST_INT nextId = 0;
//ST_INT i;
//FILE *fp;
//ST_CHAR *p;
//ST_INT pathLen;
//
// if (dest == NULL)
// return (SD_FAILURE);
//
///* If the user did not pass in a path, use the global path */
// if (tmpfile_path == NULL)
// tmpfile_path = mvl_tmpfile_path;
//
///* Default is to use the current working directory */
// dest[0] = 0;
// p = dest;
//
///* See if user has path they want to use */
// if (tmpfile_path != NULL)
// {
// pathLen = strlen (tmpfile_path);
// if (pathLen > MVL_MAX_TMPFILE_PATH)
// {
// MVL_LOG_NERR0 ("Error: temp file path too long, using working dir");
// }
// else
// {
// strcpy (dest, tmpfile_path);
// p = dest + pathLen;
// }
// }
//
// for (i = 0; i < MAX_TEMP_FILE_TRIES; ++i)
// {
// apr_snprintf (p,sizeof(p), "TMP%04x.TMP", nextId);
// if (++nextId >= MAX_TEMP_FILE_NUM)
// nextId = 0;
//
// fp = fopen (dest,"r"); /* See if already present */
// if (!fp) /* nope. */
// return (SD_SUCCESS);
// else /* file is present, try again */
// fclose (fp);
// }
// return (SD_FAILURE);
// }
/************************************************************************/
/* _mvl_getpath */
/************************************************************************/
ST_VOID _mvl_getpath (ST_CHAR *file_spec, ST_CHAR *dest)
{
ST_INT i;
strcpy (dest, file_spec);
i = strlen (dest);
while (i > 0)
{
if ((dest[i-1] == '/') ||
(dest[i-1] == '\\') ||
(dest[i-1] == ':'))
{
dest[i] = 0;
break;
}
--i;
}
if (i == 0)
dest[0] = 0;
}
#endif /* #if (MMS_FOPEN_EN & REQ_EN) || (MMS_FOPEN_EN & RESP_EN) */
/************************************************************************/
/* These checks make sure that user doesn't try to enable a MMS */
/* service that is not supported. */
/************************************************************************/
#if (MMS_CANCEL_EN & REQ_EN)
#error Unsupported service must not be enabled.
#endif
#if (MMS_RENAME_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_MV_DWN_EN != REQ_RESP_DIS) /* VM Upload */
#error Unsupported service must not be enabled.
#endif
#if (MMS_INIT_DWN_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_DWN_LOAD_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_TERM_DWN_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_MV_UPL_EN != REQ_RESP_DIS) /* VM Download */
#error Unsupported service must not be enabled.
#endif
#if (MMS_INIT_UPL_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_UP_LOAD_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_TERM_UPL_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_RDDWN_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_RDUPL_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_LOAD_DOM_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_STR_DOM_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_DEL_DOM_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_CRE_PI_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_DEL_PI_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_START_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_STOP_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_RESUME_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_RESET_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_KILL_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_GET_PI_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_MV_READ_EN != REQ_RESP_DIS) /* VM Read variable(s) */
#error Unsupported service must not be enabled.
#endif
#if (MMS_MV_RDVARS_EN != REQ_RESP_DIS) /* General VM Rd var's */
#error Unsupported service must not be enabled.
#endif
#if (MMS_MV_WRITE_EN != REQ_RESP_DIS) /* VM Write variable(s) */
#error Unsupported service must not be enabled.
#endif
#if (MMS_MV_WRVARS_EN != REQ_RESP_DIS) /* General VM WR var's */
#error Unsupported service must not be enabled.
#endif
#if (MMS_DEFVAR_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_DEFSCAT_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_GETSCAT_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_DELVAR_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_MV_DEFTYPE_EN != REQ_RESP_DIS) /* VM DefineType */
#error Unsupported service must not be enabled.
#endif
#if (MMS_DEFTYPE_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_GETTYPE_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_DELTYPE_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_TAKECTRL_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_RELCTRL_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_DEFINE_SEM_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_DELETE_SEM_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_REP_SEMSTAT_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_REP_SEMPOOL_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_REP_SEMENTRY_EN!= REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_JWRITE_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_JCREATE_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_JDELETE_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_DEFEC_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_DELEC_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_GETECA_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_REPECS_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_ALTECM_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_TRIGE_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_DEFEA_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_DELEA_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_GETEAA_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_REPEAS_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_DEFEE_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_DELEE_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_GETEEA_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_REPEES_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_ALTEE_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_EVNOT_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_ACKEVNOT_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_GETAS_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_GETAES_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_INPUT_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_OUTPUT_EN != REQ_RESP_DIS)
#error Unsupported service must not be enabled.
#endif
#if (MMS_MV_FOPEN_EN != REQ_RESP_DIS) /* VM FileOpen */
#error Unsupported service must not be enabled.
#endif
#if (MMS_MV_FREAD_EN != REQ_RESP_DIS) /* VM FileRead */
#error Unsupported service must not be enabled.
#endif
#if (MMS_MV_FCLOSE_EN != REQ_RESP_DIS) /* VM FileClose */
#error Unsupported service must not be enabled.
#endif
#if (MMS_MV_FCOPY_EN != REQ_RESP_DIS) /* VM FileCopy */
#error Unsupported service must not be enabled.
#endif

90
mms/myftp.cpp Normal file
View File

@@ -0,0 +1,90 @@
#include <stdio.h>
#include <stdlib.h>
#include "../misc/ftp.h"
#include <iostream>
using namespace std;
#include "db_interface.h"
static int demo()
{
//<2F><>¼
CFTP ftpclient;
int err;
err = ftpclient.ftp_connect("192.168.1.103");
//err = ftpclient.ftp_connect("103.1.168.192");
if(err){
puts("connect ftp server failed");
exit(-1);
}
puts("connect ok");
err = ftpclient.ftp_login("root","9.9cyj");
if(err){
puts("login failed");
exit(-1);
}
puts("login ok");
err = ftpclient.ftp_download("loc_download.txt","/etc/jcf_vesion.txt");
if(err){
puts("download failed");
exit(-1);
}
puts("download ok");
err = ftpclient.ftp_upload("../comtrade/mms2db_template.csv","/22/njcn/","mms2db_template.csv");
if(err){
puts("upload failed");
exit(-1);
}
remove("");
puts("upload ok");
err = ftpclient.ftp_quit();
if(err){
puts("quit failed");
exit(-1);
}
puts("you quit");
return 0;
}
int my_ftp_upload(char* ip,char* user,char* pwd, char* localfile,char* remotepath,char* remotefilename)
{
//<2F><>¼
CFTP ftpclient;
int err;
err = ftpclient.ftp_connect(ip);
if(err){
puts("connect ftp server failed");
return(-1);
}
puts("ftp connect ok");
//err = ftpclient.ftp_login("njcn","Pq54321");
err = ftpclient.ftp_login(user,pwd);
if(err){
puts("ftp login failed");
return(-1);
}
puts("ftp login ok");
err = ftpclient.ftp_upload(localfile,remotepath,remotefilename);
if(err){
puts("ftp upload failed");
return(-1);
}
puts("ftp upload ok");
remove(localfile);
err = ftpclient.ftp_quit();
if(err){
puts("ftp quit failed");
return(-1);
}
puts("ftp quit");
return 0;
}

124
mms/oracle_process.cpp Normal file
View File

@@ -0,0 +1,124 @@
/**
* @file: $RCSfile: oracle_process.cpp,v $
* @brief: $IEC 61850 Protocol
*
* @version: $Revision: 1.1 $
* @date: $Date: 2018/11/24 06:54:51 $
* @author: $Author: lizhongming $
* @state: $State: Exp $
*
* @latest: $Id: oracle_process.cpp,v 1.1 2018/11/24 06:54:51 lizhongming Exp $
*
*/
#include <iostream>
using namespace std;
#include <stdio.h>
#define OTL_ORA11G
#include "otlv4.h" // include the OTL 4 header file
otl_connect db; // connect object
int OTLConnect (const char* pszConnStr)
{
try
{
otl_connect::otl_initialize(); // initialize OCI environment
db.rlogon(pszConnStr);
//db.auto_commit_off ( );
printf ( "CONNECT: OK!\n" );
}
catch(otl_exception& p)
{ // intercept OTL exceptions
printf ( "Connect Error: (%s) (%s) (%s)\n",p.msg, p.stm_text, p.var_info );
return -1;
}
return 0;
}
int OTLDisconnect()
{
//db.commit ( );
db.logoff();
printf ( "DISCONNECT: OK!\n" );
return 0;
}
void insert()
// insert rows into table
{
otl_stream o(50, // buffer size
"insert into test_tab values(:f1<int>,:f2<char[31]>)",
// SQL statement
db // connect object
);
char tmp[32];
for(int i=1;i<=100;++i){
sprintf(tmp,"Name%d",i);
// the old way (operators >>() / <<()) is available as always:
o<<i<<tmp;
}
}
void select()
{
otl_stream i(50, // buffer size
"select * from test_tab where f1>=:f<int> and f1<=:f*2",
// SELECT statement
db // connect object
);
// create select stream
float f1=0;
char f2[31];
// the old way (operators >>() / <<()) is available as always:
i<<8; // assigning :f = 8
// C++98/03 compiler
while(!i.eof()){ // while not end-of-data
i>>f1>>f2;
cout<<"f1="<<f1<<", f2="<<f2<<endl;
}
i<<4; // assigning :f = 4
while(!i.eof()){ // while not end-of-data
i>>f1>>f2;
cout<<"f1="<<f1<<", f2="<<f2<<endl;
}
}
int main2()
{
OTLConnect("pqsadmin/pqsadmin@PQSBASE"); // connect to Oracle
try{
otl_cursor::direct_exec
(
db,
"drop table test_tab",
otl_exception::disabled // disable OTL exceptions
); // drop table
otl_cursor::direct_exec
(
db,
"create table test_tab(f1 number, f2 varchar2(30))"
); // create table
insert(); // insert records into table
select(); // select records from table
}
catch(otl_exception& p){ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
cerr<<p.stm_text<<endl; // print out SQL that caused the error
cerr<<p.var_info<<endl; // print out the variable that caused the error
}
//OTLDisconnect();
return 0;
}

309
mms/osicfg.xml Normal file
View File

@@ -0,0 +1,309 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v4.0 (http://www.xmlspy.com) (SISCO/Engineering) -->
<!-- ****************************************************************** -->
<!-- * SISCO MODULE HEADER ******************************************** -->
<!-- ****************************************************************** -->
<!-- * (c) Copyright Systems Integration Specialists Company, Inc., -->
<!-- * 2001 - 2004, All Rights Reserved -->
<!-- * -->
<!-- * MODULE NAME : osicfg.xml -->
<!-- * PRODUCT(S) : MMSEASE-Lite -->
<!-- * -->
<!-- * MODULE DESCRIPTION : Configuration File for Lean-T Stack -->
<!-- * -->
<!-- * This file is used to set the log masks used to control -->
<!-- * logging performed by the MMS-EASE Lite Debug Libraries, -->
<!-- * as well as to set memory debug flags. This module is -->
<!-- * read by the source module 'osicfgx.c'. -->
<!-- * -->
<!-- * MODULE DESCRIPTION : -->
<!-- * -->
<!-- * Configuration file for Lean-T Stack -->
<!-- * -->
<!-- * The configuration file has three sections. -->
<!-- * The order of sections in the configuration file is relevant: -->
<!-- * -->
<!-- * Network -->
<!-- * -->
<!-- * Transport This section may be empty (default parameters -->
<!-- * will be used). -->
<!-- * -->
<!-- * Addressing This section should be present to -->
<!-- * properly terminate parsing of cfg file. -->
<!-- * -->
<!-- * Note: Most parameters are optional unless stated that -->
<!-- * they are mandatory. If an optional parameter is -->
<!-- * not configured in this file a default value will -->
<!-- * be used. -->
<!-- * -->
<!-- * MODIFICATION LOG : -->
<!-- * Date Who Rev Comments -->
<!-- * ======= ===== === ========================== -->
<!-- * 01/27/04 ASK 04 Commented out DTD and Schema references -->
<!-- * 01/15/04 EJV 03 Added Rfc1006_Max_Spdu_Outstanding -->
<!-- * 11/05/01 GLB 02 Added MMS section -->
<!-- * 08/31/00 GLB 01 Module created from existing lean.cfg -->
<!-- ****************************************************************** -->
<!--
#############################################################################
# NOTE: Descriptions of parameters are at the bottom of this module.
###########################################################################-->
<!-- Uncomment to use DTD / Schema
<!DOCTYPE STACK_CFG SYSTEM "..\osicfg.dtd">
<STACK_CFG xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="..\osicfg.xsd">
-->
<STACK_CFG>
<MMS>
<Max_Mms_Pdu_Length>32000</Max_Mms_Pdu_Length>
<Max_Calling_Connections>4</Max_Calling_Connections>
<Max_Called_Connections>0</Max_Called_Connections>
</MMS>
<Network>
<Clnp>
<Lifetime>50</Lifetime>
<Lifetime_Decrement>1</Lifetime_Decrement>
<Cfg_Timer>120</Cfg_Timer>
<Esh_Delay>5</Esh_Delay>
<Local_NSAP>49 00 01 53 49 53 43 09 01 01</Local_NSAP>
</Clnp>
</Network>
<Transport>
<Tp4>
<Max_Tpdu_Length>1024</Max_Tpdu_Length>
<Max_Remote_Cdt>4</Max_Remote_Cdt>
<Local_Cdt>4</Local_Cdt>
<Max_Num_Connections>8</Max_Num_Connections>
<Max_Spdu_Outstanding>4</Max_Spdu_Outstanding>
<Window_Time>10</Window_Time>
<Inactivity_Time>120</Inactivity_Time>
<Retransmission_Time>10</Retransmission_Time>
<Max_Transmissions>2</Max_Transmissions>
<Ak_Delay>2</Ak_Delay>
</Tp4>
<Tcp>
<Rfc1006_Max_Tpdu_Len>1024</Rfc1006_Max_Tpdu_Len>
<Rfc1006_Max_Num_Conns>8</Rfc1006_Max_Num_Conns>
<Rfc1006_Max_Spdu_Outstanding>50</Rfc1006_Max_Spdu_Outstanding>
</Tcp>
</Transport>
<NetworkAddressing>
<LocalAddressList>
<LocalAddress>
<AR_Name>local1</AR_Name>
<AP_Title>1 3 9999 33</AP_Title>
<AE_Qualifier>33</AE_Qualifier>
<Psel>00 00 00 01</Psel>
<Ssel>00 01</Ssel>
<Tsel>00 01</Tsel>
<TransportType>TCP</TransportType>
<!-- TP4 or TCP or TPX -->
</LocalAddress>
<LocalAddress>
<AR_Name>local1cl</AR_Name>
<AP_Title>1 3 9999 33</AP_Title>
<AE_Qualifier>33</AE_Qualifier>
<Psel>00 00 00 02 </Psel>
<Ssel>00 01</Ssel>
<Tsel>00 01</Tsel>
<TransportType>TCP</TransportType>
<!-- TP4 or TCP or TPX -->
</LocalAddress>
</LocalAddressList>
<RemoteAddressList>
<RemoteAddress>
<AR_Name>remote1</AR_Name>
<AP_Title>1 3 9999 23</AP_Title>
<AE_Qualifier>23</AE_Qualifier>
<Psel>00 00 00 01</Psel>
<Ssel>00 01</Ssel>
<Tsel>00 01</Tsel>
<NetAddr Type="IPADDR">127.0.0.1</NetAddr>
<!-- EXAMPLE: <NetAddr Type="IPADDR">208.176.40.52</NetAddr> -->
<!-- EXAMPLE: <NetAddr Type="NSAP">49 00 01 53 49 53 43 44 02 01</NetAddr> -->
</RemoteAddress>
</RemoteAddressList>
</NetworkAddressing>
</STACK_CFG>
<!--
#############################################################################
#
# Description of NETWORK parameters
#
# CLNP Only Parameters:
# ======================
#
# Lifetime
# Valid range is from 1 to 255 (in 500 ms units).
#
# Lifetime_Decrement
# Valid range is from 1 to 255 (in 500 ms units).
#
# Cfg_Timer The Configuration Timer specifies how
# often ESH will be sent.
# Valid range is from 0 to 32767 (seconds).
# Note that the Holding Time in ESH sent
# is set to 2*CfgTimer.
# If Cfg_Timer=0 then ESH will not be sent.
#
# Esh_Delay Delay time before first ESH is sent.
# Valid range is from 0 to 32767 (seconds).
#
# COMMON Parameters:
# ===================
#
# Local_MAC Local MAC address (up to 6 hex bytes
# separated by spaces).
# For the ADLC sub-network the local MAC is
# a required parameter and it has to match
# the address in the adlc.cfg file!
# For ADLC sub-network the MAC address is a
# USHORT number (2 hex bytes swapped,
# example: 30 00 hex swapped = 48 decimal).
# For the Ethernet this param will be read
# from the driver during initialization
# (any value from config file will be ignored).
#
# Local_NSAP Local NSAP (up to 20 hex bytes separated
# by spaces, example: 49 00 11 11).
# This is mandatory parameter.
#
#############################################################################
#
# Description of TRANSPORT parameters
#
# TP4 Only Parameters:
# ====================
#
# Max_Tpdu_Length
# Max length of TPDU. Base on SNPDU size.
# Valid values are: 128, 256, 512, 1024,
# 2048, 4096, 8192.
#
# Max_Remote_Cdt
# Max credits we can handle.
# Will allocate this many TPDU_DT structures.
# Valid values are: 2, 4, 8, 16.
# CRITICAL: MUST BE POWER OF 2.
#
# Local_Cdt Credit value we will ALWAYS send in ACK.
# We only accept in-sequence TPDUs so only
# purpose of this is to allow peer to send
# ahead.
# Valid range is from 1 to 15.
#
# Max_Num_Connections
# Max number of connections.
# Valid range is from 1 to 255.
#
# Max_Spdu_Outstanding
# Max num of SPDUs outstanding per connection.
# Will allocate this many SPDU_INFO structs
# for transmit queue.
# Valid values are: 2, 4, 8, 16.
# CRITICAL: MUST BE POWER OF 2.
#
# Max_Spdu_Length
# Max SPDU length.
# Should be based on max ACSE msg size.
# Valid range is from 1 to 65535.
#
# Window_Time
# Indicates the maximum time that the
# transport will wait before retransmitting
# up-to-date window information.
# Valid range is from 1 to 255 (seconds).
#
# Inactivity_Time
#
# Valid range is from 1 to 255 (seconds).
#
# Retransmission_Time
# Indicates the maximum time the transport
# will wait for acknowledgement before
# retransmitting a TPDU.
# Valid range is from 1 to 255 (seconds).
#
# Max_Transmissions
# Max number transmissions of a TPDU.
# Valid range is from 1 to 255.
#
# Ak_delay The TP4 skips some service cycles before
# sending the transport ACK, to allow
# concatination with DATA packet.
# The recommended value for this parameter is 2.
#
# TCP (RFC1006) only parameters:
# ==============================
#
# rfc1006_Max_Tpdu_Length
# Max length of TPDU.
# Valid values are: 128, 256, 512, 1024,
# 2048, 4096, 8192 and 65531
#
# rfc1006_Max_Num_Connections
# Max number of connections.
# Valid range is from 1 to 255.
#
# rfc1006_Max_Spdu_Outstanding
# Max num of SPDUs that can be queued in gensock2.
#
#############################################################################
#
# Description of ADDRESSING parameters
# Parameters for local and remote Directory Information Base (DIB)
#
# Common_Name Is an alias for the P-Address. It may be up
# to 64 characters long.
#
# AP-Title Is an array of up to 16 SHORT decimal integers.
# The first value should be 1 (ISO)(valid range 0-2).
# The second value should be 1, 2 or 3 (valid range 0-39).
# The third value is open for assignment (If you addressing is
# local this value should be 9999, the rest of the values are
# arbitrary.
#
# This is an Object Identifier assigned by the
# network naming authority, representing the
# Application Process Title for your particular
# application process.
#
# AE-Qualifier Is a LONG decimal integer.
#
# This is an optional integer value used to qualify the
# Application Entity.
#
# Psel Up to 16 (octets) characters of ASCII encoded hex.
#
# This octet string represents the Presentation Selector
# used to identify a Presentation SAP.
#
# Ssel Up to 16 (octets) characters of ASCII encoded hex.
#
# The octet string represents the Session Selector used
# to identify a Session SAP that can be up to 16 octets in length.
#
# Tsel Up to 32 (octets) characters of ASCII encoded hex.
#
# The octet string represents the Transport Selector used
# to identify a Transport SAP that can be up to 16 octets in length.
#
#
# Transport TP4 - for Transport Class 4
# TCP - for Transport Class 0 (RFC1006)
#
# TP4 only parameters:
# ====================
# NSAP Up to 20 characters of ASCII encoded hex
# TP4 only, in remote_begin section(s)
#
# TCP (RFC1006) only parameters:
# ==============================
# IPADDR IP address or alias name defined in hosts
# file for given IP address.
# Only in remote_begin section(s)
#
##############################################################################
-->

291
mms/parse_xml.c Normal file
View File

@@ -0,0 +1,291 @@
/**
* @file: $RCSfile: parse_xml.c,v $
* @brief: $<24><><EFBFBD><EFBFBD>xml
*
* @version: $Revision: 1.5 $
* @date: $Date: 2018/12/29 03:18:14 $
* @author: $Author: lizhongming $
* @state: $State: Exp $
*
* @latest: $Id: parse_xml.c,v 1.5 2018/12/29 03:18:14 lizhongming Exp $
*/
#include <string.h>
#include "rdb_client.h"
#include "xmltools.h"
//int comtrade_remain_file_num = 2147483647;
int comtrade_remain_file_num = 0;
//extern rdb_t* g_rdb ;
extern node_t* g_node ;
extern char g_my_conf_fname[256];
extern apr_pool_t* g_init_pool;
extern apr_pool_t* g_run_pool;
extern pt61850app_t* g_pt61850app;
//extern apr_time_t g_file_valid_time;
//extern byte_t g_file_name_len;
//extern byte_t g_file_time_from;
apr_status_t app_get_private_config(const char *myfilename)
{
//apr_status_t rv = APR_SUCCESS;
char *v = NULL;
char *str = NULL;
assert(myfilename);
if (xml_get_elem(myfilename, "//pt61850netd/mmsOpTimeout/",&v) == APR_SUCCESS) {
if((str = strtok(v,",")))
g_pt61850app->mmsOpTimeout = atoi(str);
}
else {
echo_warn("Read xml error. error at mmsOpTimeout.\n");
return APR_EBADDATE;
}
if (xml_get_elem(myfilename, "//pt61850netd/giTime/",&v) == APR_SUCCESS) {
if((str = strtok(v,",")))
g_pt61850app->giTime = atoi(str);
}
else {
echo_warn("Read xml error. error at giTime.\n");
return APR_EBADDATE;
}
if (xml_get_elem(myfilename, "//pt61850netd/cliAsuffixFrom/",&v) == APR_SUCCESS) {
if((str = strtok(v,",")))
g_pt61850app->rptSuffix[0][0] = atoi(str);
}
else {
echo_warn("Read xml error. error at cliAsuffixFrom .\n");
return APR_EBADDATE;
}
if (xml_get_elem(myfilename, "//pt61850netd/cliAsuffixTo/",&v) == APR_SUCCESS) {
if((str = strtok(v,",")))
g_pt61850app->rptSuffix[0][1] = atoi(str);
}
else {
echo_warn("Read xml error. error at cliAsuffixTo .\n");
return APR_EBADDATE;
}
if (xml_get_elem(myfilename, "//pt61850netd/accPath/",&v) == APR_SUCCESS) {
if((str = strtok(v,",")))
strcpy(g_pt61850app->accPath,str_trim_both(str," \t\'" ) );
}
else {
echo_warn("Read xml error. error at accPath .\n");
return APR_EBADDATE;
}
if (xml_get_elem(myfilename, "//pt61850netd/comtrade_remain_file_num/",&v) == APR_SUCCESS) {
if((str = strtok(v,",")))
comtrade_remain_file_num = atoi(str);
}
return APR_SUCCESS;
}
//************<2A><><EFBFBD><EFBFBD> ReportControl.xml ***************//
#define REPORTCONTROL_FILE_PATH CONFIG_FILEPATH
/*
<!-- װ<><D7B0>ID,CPUID,ReportCtrlNum -->
<ReportControlCount>104,1,2</ReportControlCount>
*/
int init_rptctrl_by_count(LD_info_t* LD_info,int rptcount)
{
int j,i;
LD_info->rptcount = rptcount;
LD_info->rptinfo = apr_pcalloc( g_init_pool,rptcount*sizeof(rptinfo_t*) );
for(j=0; j<rptcount; j++) {
LD_info->rptinfo[j] = apr_pcalloc( g_init_pool,sizeof(rptinfo_t) );
LD_info->rptinfo[j]->LD_info = LD_info;
LD_info->rptinfo[j]->m_LastRegisterFailedTime = sGetMsTime() -10*60*1000;
LD_info->rptinfo[j]->m_LastUnRegisterFailedTime = sGetMsTime() -10*60*1000;
LD_info->rptinfo[j]->IntgPd = 60;
LD_info->rptinfo[j]->m_rcb_info = NULL;
LD_info->rptinfo[j]->rpt_registered = FALSE;
LD_info->rptinfo[j]->m_curRptSuffix = -1;
for(i=0; i<8; i++)
LD_info->rptinfo[j]->m_EntryID[i] = 0xff;
}
return 0;
}
//ReportControl: װ<><D7B0>ID,CPUID,ID,RCBName, intgPd, dchg, qchg, dupd, period ,gi, ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>Ӻ<EFBFBD>׺,<2C><>
// seqNum, timeStamp, reasonCode, dataSet, dataRef, bufOvfl, entryID, configRef, segmentation
//<ReportControl>104,1,1,brcbDin,60,1,0,0,1,0,yes,1,1,0,1,1,1,1,1,0</ReportControl>
int fill_rptctrl_by_cfg(LD_info_t* LD_info,int rptno,char *buf)
{
char *str = NULL;
char *tmp_str = NULL;
rptinfo_t *rptinfo;
assert( (rptno+1) <= LD_info->rptcount ) ;
rptinfo = LD_info->rptinfo[rptno];
if(!(str = strtok(buf,",")))
return 1;
rptinfo->rptNo = rptno;//CZY 2023-08-16 WW 2022-11-14 <20><><EFBFBD>ӱ<EFBFBD><D3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6><CFB1><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EAA3AC><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
tmp_str = apr_pstrdup(g_init_pool,str);
rptinfo->rptID = str_trim_both(tmp_str," \t\'" );
if((str = strtok(NULL,","))) rptinfo->IntgPd = atoi(str); else return 1;
if((str = strtok(NULL,","))) {
if ( atoi(str) ) BSTR_BIT_SET_ON(&rptinfo->TrgOpt, TRGOPS_BITNUM_DATA_CHANGE);
}else return 1;
if((str = strtok(NULL,","))) {
if ( atoi(str) ) BSTR_BIT_SET_ON(&rptinfo->TrgOpt, TRGOPS_BITNUM_QUALITY_CHANGE);
}else return 1;
if((str = strtok(NULL,","))) {
if ( atoi(str) ) BSTR_BIT_SET_ON(&rptinfo->TrgOpt, TRGOPS_BITNUM_DATA_UPDATE);
}else return 1;
if((str = strtok(NULL,","))) {
if ( atoi(str) ) BSTR_BIT_SET_ON(&rptinfo->TrgOpt, TRGOPS_BITNUM_INTEGRITY);
}else return 1;
if((str = strtok(NULL,","))) {
if ( atoi(str) ) BSTR_BIT_SET_ON(&rptinfo->TrgOpt, TRGOPS_BITNUM_GENERAL_INTERROGATION);
}else return 1;
if(!(str = strtok(NULL,",")))
return 1;
tmp_str = apr_pstrdup(g_init_pool,str);
if (strcmp("yes", str_trim_both(tmp_str," \t\'" ) )==0 )
rptinfo->instanceNeedSuffix = TRUE;
else
rptinfo->instanceNeedSuffix = FALSE;
// seqNum, timeStamp, reasonCode, dataSet, dataRef, bufOvfl, entryID, configRef, segmentation
if((str = strtok(NULL,","))) {
if ( atoi(str) ) BSTR_BIT_SET_ON(rptinfo->OptFlds, OPTFLD_BITNUM_SQNUM);
}else return 1;
if((str = strtok(NULL,","))) {
if ( atoi(str) ) BSTR_BIT_SET_ON(rptinfo->OptFlds, OPTFLD_BITNUM_TIMESTAMP);
}else return 1;
if((str = strtok(NULL,","))) {
if ( atoi(str) ) BSTR_BIT_SET_ON(rptinfo->OptFlds, OPTFLD_BITNUM_REASON);
}else return 1;
if((str = strtok(NULL,","))) {
if ( atoi(str) ) BSTR_BIT_SET_ON(rptinfo->OptFlds, OPTFLD_BITNUM_DATSETNAME);
}else return 1;
if((str = strtok(NULL,","))) {
if ( atoi(str) ) BSTR_BIT_SET_ON(rptinfo->OptFlds, OPTFLD_BITNUM_DATAREF);
}else return 1;
if((str = strtok(NULL,","))) { //only valid in RCB_TYPE_IEC_BRCB
if ( atoi(str) ) BSTR_BIT_SET_ON(rptinfo->OptFlds, OPTFLD_BITNUM_BUFOVFL);
}else return 1;
if((str = strtok(NULL,","))) { //only valid in RCB_TYPE_IEC_BRCB
if ( atoi(str) ) BSTR_BIT_SET_ON(rptinfo->OptFlds, OPTFLD_BITNUM_ENTRYID);
}else return 1;
if((str = strtok(NULL,","))) {
if ( atoi(str) ) BSTR_BIT_SET_ON(rptinfo->OptFlds, OPTFLD_BITNUM_CONFREV);
}else return 1;
if((str = strtok(NULL,","))) {
//SUBSEQNUM is only set by the server, so don't try to set it.
if ( atoi(str) ) BSTR_BIT_SET_ON(rptinfo->OptFlds, OPTFLD_BITNUM_SUBSEQNUM);
}else return 1;
if((str = strtok(NULL,","))) {
rptinfo->report_PQ_type = atoi(str);
}else return 1;
if ((str = strtok(NULL, ","))) { //CZY 2023-08-16 WW 2022-11-14<31><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E4B1A8><EFBFBD><EFBFBD>־
rptinfo->flickerflag = atoi(str);
if (rptinfo->flickerflag == 0) {
LD_info->rptRecvFlag += 0x01 << rptno;
printf(" LD_info->rptRecvFlag=%d \n", LD_info->rptRecvFlag);
}
else if(rptinfo->flickerflag == 2)
{
LD_info->rptPstRecvFlag += 0x01 << rptno;
printf(" LD_info->rptPstRecvFlag=%d \n", LD_info->rptPstRecvFlag);
}
}
else return 1;
return 0;
}
//////////////////////////////////////////////////////////
//************<2A><><EFBFBD><EFBFBD> LogControl.xml ***************//
/*
<!-- װ<><D7B0>ID,CPUID,LogCtrlNum -->
<LogControlCount>104,1,2</LogControlCount>
*/
int init_logctrl_by_count(LD_info_t* LD_info,int logcount)
{
int j;
LD_info->logcount = logcount;
LD_info->loginfo = apr_pcalloc(g_init_pool, logcount * sizeof(loginfo_t*)); //new loginfo_t*[logcount];
for(j=0; j<logcount; j++) {
LD_info->loginfo[j] = apr_pcalloc(g_init_pool, sizeof(loginfo_t));//new loginfo_t[1];
LD_info->loginfo[j]->LD_info = LD_info;
LD_info->loginfo[j]->IntgPd = 600;
//LD_info->loginfo[j]->m_lcb_info = NULL;
}
return 0;
}
//<!--LogControl:IEDID,CPUID,ID,LCBName,DatasetName,LogName,reasonCode,intgPd,dchg,qchg,dupd,period -->
// <LogControl>106,2,1,LLN0$LG$lcStatisticData,dsStatisticData,PQM1,0,600000,1,0,0,0</LogControl>
// <LogControl>106,2,2,LLN0$LG$lcFlickerData,dsFlickerData,PQM1,0,600000,1,0,0,0</LogControl>
int fill_logctrl_by_cfg(LD_info_t* LD_info,int logno,char *buf,char* devtype)
{
char *str = NULL;
char *tmp_str = NULL;
loginfo_t *loginfo;
assert( (logno+1) <= LD_info->logcount ) ;
loginfo = LD_info->loginfo[logno];
if(!(str = strtok(buf,",")))
return 1;
tmp_str = apr_pstrdup(g_init_pool,str);
loginfo->lcbName = str_trim_both(tmp_str," \t\'" );
if(!(str = strtok(NULL,",")))
return 1;
tmp_str = apr_pstrdup(g_init_pool,str);
loginfo->datasetName = str_trim_both(tmp_str," \t\'" );
if(!(str = strtok(NULL,",")))
return 1;
//tmp_str = apr_pstrdup(g_init_pool,str);
apr_snprintf(loginfo->logName,sizeof(loginfo->logName), devtype,LD_info->cpuno);//<2F><><EFBFBD><EFBFBD>PQM1
if((str = strtok(NULL,","))) loginfo->reasonCode = atoi(str); else return 1;
if((str = strtok(NULL,","))) loginfo->IntgPd = atoi(str); else return 1;
if((str = strtok(NULL,","))) {
if ( atoi(str) ) BSTR_BIT_SET_ON(&loginfo->TrgOpt, TRGOPS_BITNUM_DATA_CHANGE);
}else return 1;
if((str = strtok(NULL,","))) {
if ( atoi(str) ) BSTR_BIT_SET_ON(&loginfo->TrgOpt, TRGOPS_BITNUM_QUALITY_CHANGE);
}else return 1;
if((str = strtok(NULL,","))) {
if ( atoi(str) ) BSTR_BIT_SET_ON(&loginfo->TrgOpt, TRGOPS_BITNUM_DATA_UPDATE);
}else return 1;
if((str = strtok(NULL,","))) {
if ( atoi(str) ) BSTR_BIT_SET_ON(&loginfo->TrgOpt, TRGOPS_BITNUM_INTEGRITY);
}else return 1;
loginfo->start_time = apr_time_now();// - apr_time_from_sec(600);//
loginfo->end_time = apr_time_now();
//loginfo->last_checktime = 0.0f;//-160*1000;//0.0f;
loginfo->need_steady = 0;
loginfo->need_voltage = 0;
//printf(" loginfo->logName=%s \n", loginfo->logName);
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////

591
mms/rdb_client.c Normal file
View File

@@ -0,0 +1,591 @@
/**
* @file: $RCSfile: rdb_client.c,v $
* @brief: $PROFIBUS <20><>SSRTDB<44><42><EFBFBD><EFBFBD>
*
* @version: $Revision: 1.11 $
* @date: $Date: 2020/10/28 05:21:18 $
* @author: $Author: lizhongming $
* @state: $State: Exp $
*
* @latest: $Id: rdb_client.c,v 1.11 2020/10/28 05:21:18 lizhongming Exp $
*/
#include <string.h>
#include "rdb_client.h"
#include "db_interface.h"
#include "node.h"
#include <pthread.h>//lnk20250114<31><34>̨<EFBFBD><CCA8><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD><EFBFBD><EFBFBD>
/*lnk10-10 */////////////////////////////////
extern int HTTP_PORT;
extern int SOCKET_PORT;
extern int G_TEST_FLAG;
extern int g_front_seg_index;
extern int g_front_seg_num;
#include "../include/rocketmq/SimpleProducer.h"
////////////////////////////////////////////
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR* SD_CONST thisFileName = __FILE__;
#endif
extern RPT_TYPEIDS g_rpt_typeids;
//ied_info_t *my_info;
extern apr_pool_t* g_root_pool;
uint8_t set_mx_q;
//rdb_t *g_rdb = NULL;
node_t* g_node = NULL;
extern char g_my_conf_fname[256];
apr_pool_t* g_init_pool;
apr_pool_t* g_run_pool;
apr_pool_t* g_temp_dev_pool;
//lnk20250114<31><34>̨<EFBFBD><CCA8><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD><EFBFBD><EFBFBD>
pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
extern char g_onlyIP[255]; //ֱ<><D6B1>ij<EFBFBD><C4B3>IP<49><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//Ϊ<><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
uint8_t set_mx_q;
pt61850app_t* g_pt61850app;
//application_t g_sysfile_app; //ϵͳ<CFB5>ļ<EFBFBD><C4BC><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>Ϣ<EFBFBD>
//int g_sysfile_appid = -1;
//char *g_sysfile_filedir;
//byte_t g_Master;
//byte_t g_protect_file; //0:<3A><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD> 1:<3A>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD>
//apr_time_t g_file_valid_time; //ֻ<>ٻ<EFBFBD>ָ<EFBFBD><D6B8>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>
//byte_t g_file_name_len; //<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD>󳤶ȣ<F3B3A4B6>Ĭ<EFBFBD><C4AC>Ϊ40<34><30><EFBFBD><EFBFBD>Ϊ0ʱ<30><CAB1>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><E2B3A4>
//byte_t g_file_time_from; //<2F>ļ<EFBFBD><C4BC><EFBFBD>Чʱ<D0A7><CAB1>ȡֵ<C8A1>δ<EFBFBD><CEB4><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>1ȡϵͳʱ<CDB3><CAB1>
static void* APR_THREAD_FUNC rtdb_worker(apr_thread_t* thd, void* data);
static apr_status_t pt61850app_init();
//static apr_status_t app_process_command(command_t *cmd);
///////////////////////////////////////////////////////////////////////////////
extern int three_secs_enabled;
///////////////////////////////////////////////////////////////////////////////
//WW 2023-08-22 start
int server_socket = -1;
extern int g_iOTLFlag;
//WW 2023-08-22 end
///////////////////////////////////////////////////////////////////////////////
static apr_status_t pt61850app_init()
{
apr_status_t rv;
if ((g_pt61850app = apr_pcalloc(g_run_pool, sizeof(pt61850app_t))) == NULL)
return APR_ENOMEM;
rv = apr_pool_create(&(g_pt61850app->tmp_pool), g_root_pool);
if (rv != APR_SUCCESS) {
return rv;
}
g_pt61850app->chnl_counts = 0;
g_pt61850app->initNum = 0;
return APR_SUCCESS;
}
static apr_status_t allocate_LD_chnl_ext_mem()
{
int iedno, cpuno, chnl_no;
ied_t* ied;
ied_usr_t* ied_usr;
chnl_usr_t* chnl_usr;
g_pt61850app->chnl_counts = 0;
for (iedno = 0; iedno < g_node->n_clients; iedno++) {
ied = g_node->clients[iedno];
ied_usr = apr_pcalloc(g_init_pool, sizeof(ied_usr_t));
ied->usr_ext = ied_usr;
if (ied_usr == NULL)
return APR_ENOMEM;
ied_usr->last_call_wavelist_time = sGetMsTime() + g_pt61850app->giTime * 1000 * 0.5;
ied_usr->LD_info = apr_pcalloc(g_init_pool, ied->cpucount * sizeof(LD_info_t));
if (ied_usr->LD_info == NULL)
return APR_ENOMEM;
for (cpuno = 0; cpuno < ied->cpucount; cpuno++) {
ied_usr->LD_info[cpuno].ied = ied;
ied_usr->LD_info[cpuno].cpuno = ied->cpuinfo[cpuno].addr;
ied_usr->LD_info[cpuno].ht_fcd = apr_hash_make(g_init_pool);
ied_usr->LD_info[cpuno].ht_full_fcda = apr_hash_make(g_init_pool);
ied_usr->LD_info[cpuno].rptcount = 0;
}
for (chnl_no = 0; chnl_no < ied->chncount; chnl_no++) {
chnl_usr = apr_pcalloc(g_init_pool, sizeof(chnl_usr_t));
ied->channel[chnl_no].connect = chnl_usr;
chnl_usr->chnl = &(ied->channel[chnl_no]);
chnl_usr->chnl_id = chnl_no;
chnl_usr->m_state = CHANNEL_DISCONNECTED;
chnl_usr->m_ClosedMsTime = NEXT_CONNECT_TIME * (-1);
}
g_pt61850app->chnl_counts += ied->chncount;
}
return APR_SUCCESS;
}
static apr_status_t read_DEV_idx_from_db()
{
int ret;
int iedno, cpuno;
ied_t* ied;
ied_usr_t* ied_usr;
LD_info_t* LD_info;
loginfo_t* loginfo = NULL;
int len, tmp;
for (iedno = 0; iedno < g_node->n_clients; iedno++) {
ied = g_node->clients[iedno];
ied_usr = GET_IEDEXT_ADDR(ied);
//read_DEV_Index_from_db(ied->channel[0].addr, &ied_usr->dev_idx);
for (cpuno = 0; cpuno < ied->cpucount; cpuno++) {
LD_info = &(ied_usr->LD_info[cpuno]);
if (LD_info->LD_name == NULL)
continue;
len = strlen(LD_info->LD_name);
tmp = LD_info->LD_name[len - 1] - '0';
LD_info->line_id = ied_usr->dev_idx * 10 + tmp;
//ret = read_line_infos_from_db(LD_info->line_id, &LD_info->SubV_Index,&LD_info->Dev_Index,&LD_info->Sub_Index,&LD_info->GD_Index);
if (ret != TRUE)
LD_info->line_id = -1;
if (LD_info->loginfo) {
loginfo = LD_info->loginfo[0];
//read_updatetime_from_db(ied->channel[0].addr, &loginfo->start_time);
}
}
}
return APR_SUCCESS;
}
apr_status_t init_rdb()
{
apr_status_t rv;
// driver_t* driver;
rv = apr_pool_create(&g_init_pool, g_root_pool);
if (rv != APR_SUCCESS) {
return rv;
}
rv = apr_pool_create(&g_run_pool, g_root_pool);
if (rv != APR_SUCCESS) {
return rv;
}
rv = apr_pool_create(&g_temp_dev_pool, g_root_pool);
if (rv != APR_SUCCESS) {
return rv;
}
g_node = apr_pcalloc(g_run_pool, sizeof(node_t));
if (rv != APR_SUCCESS) {
return rv;
}
//my_info = apr_pcalloc(g_run_pool,sizeof(ied_info_t));
rv = pt61850app_init();
if (rv != APR_SUCCESS) {
return rv;
}
/*rv = parse_json_cfg();
if ( rv != APR_SUCCESS) {
echo_errg("Failed to parse json define xml file! \n");
return rv;
}*/
init_config();
GetServerIndexFromDB();
/*lnk10-10*/
//<2F><><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD>web<65>ӿ<EFBFBD>
//rv = parse_device_web_test_ext();
//rv = parse_device_web_test_dev();
//rv = parse_device_web_test_front_read();
//rv = parse_device_web_test_front_write();
rv = parse_device_cfg_web();
//rv = parse_device_cfg();
//rv = parse_device_cfg_json();
//rv = parse_device_cfg_pg();
if (rv != APR_SUCCESS) {
echo_errg("Parsed device config xml file with error,try to run! \n");
return rv;
}
/*lnk10-10*/
//rv = parse_line_cfg_web(); <20>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD>ն<EFBFBD>̨<EFBFBD><CCA8>
//rv = parse_line_cfg();
//rv = parse_line_cfg_pg();
/*lnk10-10*/
rv = parse_model_cfg_web();
if (rv != APR_SUCCESS) {
echo_errg("Parsed model with error,try to run! \n");
return rv;
}
//OTL_Select_xmlModel(); //xmlģ<6C><C4A3><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>ȡ
Set_xml_nodeinfo();//<2F><><EFBFBD><EFBFBD>xmlģ<6C><C4A3>
rv = parse_rpt_log_ini();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
if (rv != APR_SUCCESS) {
echo_errg("Failed to parse report log define ini file! \n");
return rv;
}
if (app_get_private_config(g_my_conf_fname) != APR_SUCCESS) {
echo_errg("Failed when processing private configuration\n");
return APR_EGENERAL;
}
init_rem_dib_table();
return APR_SUCCESS;
}
extern int SOCKETENABLE;
extern int HTTPENABLE;
/*--------------------------- <20><>Լ<EFBFBD><D4BC>ʼ<EFBFBD><CABC> -----------------------------------*/
apr_status_t run_protocol()
{
apr_status_t rv;
apr_thread_t* rtdb_thread;
// apr_thread_t* mms_thread;
static apr_threadattr_t* worker_attr = NULL;
init_MMS();
if (worker_attr == NULL)
if ((rv = apr_threadattr_create(&worker_attr, g_run_pool)) != APR_SUCCESS)
return rv;
if ((rv = apr_threadattr_detach_set(worker_attr, 1)) != APR_SUCCESS)
return rv;
if ((rv = apr_threadattr_stacksize_set(worker_attr, 1920 * 1024)) != APR_SUCCESS)
return rv;
rv = apr_threadattr_guardsize_set(worker_attr, 4096);
if (rv != APR_SUCCESS && rv != APR_ENOTIMPL)
return rv;
if ((rv = apr_thread_create(&rtdb_thread, worker_attr, rtdb_worker, NULL, g_run_pool)) != APR_SUCCESS)
return rv;
try_start_kafka_thread();
//lnk20241213<31><33><EFBFBD><EFBFBD>mq<6D><71><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
try_start_mqconsumer_thread();
///////////////////WW 2023-08-22 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>WebSocket<65>߳<EFBFBD>
if (g_onlyIP[0] != 0 || g_node_id == NEW_HIS_DATA_BASE_NODE_ID || g_node_id == HIS_DATA_BASE_NODE_ID || g_node_id == RECALL_ALL_DATA_BASE_NODE_ID)
{
printf("g_onlyIP[0] != 0!\n\a");
}
else
{
printf("g_onlyIP[0] == 0!\n\a");
if(1 == SOCKETENABLE)
{
server_socket = socket(AF_INET, SOCK_STREAM, 0);
if (server_socket == -1) {
printf("Web Socket failed,error msg=%s\n\a", strerror(errno));
exit(1);
}
int ServerPort = 13000;//WW <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>ı<EFBFBD><C4B1>ж<EFBFBD>ȡ
if (g_node_id == STAT_DATA_BASE_NODE_ID)//ͳ<>Ʋɼ<C6B2>
ServerPort = SOCKET_PORT + STAT_DATA_BASE_NODE_ID + g_front_seg_index;
else if (g_node_id == RECALL_HIS_DATA_BASE_NODE_ID) {//<2F><><EFBFBD><EFBFBD>
ServerPort = SOCKET_PORT + RECALL_HIS_DATA_BASE_NODE_ID + g_front_seg_index;
}
else if (g_node_id == THREE_SECS_DATA_BASE_NODE_ID) {//3<><33><EFBFBD>ɼ<EFBFBD>
ServerPort = SOCKET_PORT + THREE_SECS_DATA_BASE_NODE_ID + g_front_seg_index;
}
else if (g_node_id == SOE_COMTRADE_BASE_NODE_ID) {//<2F><>̬¼<CCAC><C2BC>
ServerPort = SOCKET_PORT + SOE_COMTRADE_BASE_NODE_ID + g_front_seg_index;
}
struct sockaddr_in server_sockaddr;
memset(&server_sockaddr, 0, sizeof(server_sockaddr));
server_sockaddr.sin_family = AF_INET;
server_sockaddr.sin_port = htons(ServerPort);
server_sockaddr.sin_addr.s_addr = htonl(INADDR_ANY);
if (bind(server_socket, (struct sockaddr*)&server_sockaddr, sizeof(server_sockaddr)) == -1)
{
printf("bind failed, error msg = %s\n\a", strerror(errno));
printf("bind ServerPort is = %s\n\a", ServerPort);
exit(1);
}
if (listen(server_socket, 20) == -1)
{
printf("listen server_socket= %d,ServerPort= %d failed,error msg = %s\n\a", server_socket, ServerPort, strerror(errno));
exit(1);
}
printf("\n listen server_socket= %d,ServerPort= %d,wait for Web Socket client connecting......\n", server_socket, ServerPort);
printf("try_start_socket_thread \n");
try_start_socket_thread();
}
if(HTTPENABLE)
{
//lnk20241029<32><39><EFBFBD><EFBFBD>http<74>߳<EFBFBD>///////////////////////////////////////////////////////////////////////////////////////////////
if (g_node_id == STAT_DATA_BASE_NODE_ID)//ͳ<>Ʋɼ<C6B2>
HTTP_PORT = HTTP_PORT + STAT_DATA_BASE_NODE_ID + g_front_seg_index;
else if (g_node_id == RECALL_HIS_DATA_BASE_NODE_ID) {//<2F><><EFBFBD><EFBFBD>
HTTP_PORT = HTTP_PORT + RECALL_HIS_DATA_BASE_NODE_ID + g_front_seg_index;
}
else if (g_node_id == THREE_SECS_DATA_BASE_NODE_ID) {//3<><33><EFBFBD>ɼ<EFBFBD>
HTTP_PORT = HTTP_PORT + THREE_SECS_DATA_BASE_NODE_ID + g_front_seg_index;
}
else if (g_node_id == SOE_COMTRADE_BASE_NODE_ID) {//<2F><>̬¼<CCAC><C2BC>
HTTP_PORT = HTTP_PORT + SOE_COMTRADE_BASE_NODE_ID + g_front_seg_index;
}
printf("try_start_web_http_thread \n");
try_start_web_http_thread();
printf("try_start_http_thread \n");
try_start_http_thread();
//lnk20241029<32><39><EFBFBD><EFBFBD>http<74>߳<EFBFBD>///////////////////////////////////////////////////////////////////////////////////////////////////
}
}
if (1 == G_TEST_FLAG) {
//lnk<6E><6B><EFBFBD><EFBFBD>mqģ<71><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
printf("try_start_mqtest_thread \n");
try_start_mqtest_thread(0,NULL);
}
if (1 == g_iOTLFlag) {
printf("try_start_sql_thread \n");
try_start_sql_thread();
}
else
printf("sql_thread ignore \n");
printf("try_start_ontimer_thread \n");
try_start_ontimer_thread();
//OTLTestSelect();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>
///////////////////WW end
return APR_SUCCESS;
}
extern uint32_t g_dead_lock_counter;
extern uint32_t g_thread_blocked_times;
/*--------------------------- <20><><EFBFBD><EFBFBD>ʵʱ<CAB5><CAB1><EFBFBD>߳<EFBFBD> -----------------------------------*/
static void* APR_THREAD_FUNC rtdb_worker(apr_thread_t* thd, void* data)
{
// apr_event_t event;
// command_t cmd[1];
// int i =0;
/* Maintenance the clients request */
while (1) {
/*<2A><><EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>rocketmq<6D><71>Ϣ lnk10-10*/
//producer_send0();
doCommService();//<2F><><EFBFBD><EFBFBD>61850<35><30>Ϣ
check_3s_config();//3<><33><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD>̶<EFBFBD>ȡ3<C8A1><EFBFBD><EBB4A5>
pthread_mutex_lock(&mtx);
CheckNextNotConnectedChannel();//<2F><><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>״̬
pthread_mutex_unlock(&mtx);
pthread_mutex_lock(&mtx);
CheckAllConnectedChannel();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6A1A2>־<EFBFBD><D6BE><EFBFBD>١<EFBFBD><D9A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pthread_mutex_unlock(&mtx);
//check_recall_config();//<2F><><EFBFBD>ٽ<EFBFBD><D9BD>̶<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
create_recall_xml();//<2F><><EFBFBD>ɴ<EFBFBD><C9B4><EFBFBD><EFBFBD><EFBFBD>xml<6D>ļ<EFBFBD>
check_ledger_update();//lnk20250113<31><33>ȡ̨<C8A1>˸<EFBFBD><CBB8>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD>˸<EFBFBD><CBB8><EFBFBD>
//Check_Recall_Config();
/*if ((g_protect_file) && (g_pt61850app->initNum>=MIN_INIT_NUM) ) {
tryCallWaveList_in_AllIeds();
}*/
//clear_old_comtrade_files();
check_disk_quota();//<2F>жϴ<D0B6><CFB4>̿ռ<CCBF>
apr_pool_clear(g_pt61850app->tmp_pool);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
g_dead_lock_counter = 0;
g_thread_blocked_times = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
}
echo_msg("rtdb worker thread terminated...");
}
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
void Set_val_from_61850rpt(element_t* elem, double v)
{
GET_DOTEXT_ADDR(elem)->DataStatus |= VALUE_REACHED;
GET_DOTEXT_ADDR(elem)->m_v = v;
}
int Set_q_from_61850rpt(char* q)
{
int quality = 0;
if (q[0] == '0' && q[1] == '0')
quality = 0;
else
quality = 1;
return quality;
//set_rpt_QualityFlag(quality);
}
#define TIME_T_2036 (66*365* SECONDS_PER_DAY)
apr_time_t convert_btod_to_apr_time(MMS_BTOD* btod)
{
MMS_BTIME6 btime6;
btime6.day = btod->day;
btime6.ms = btod->ms;
return convert_btime6_to_apr_time(&btime6);
}
apr_time_t convert_btime6_to_apr_time(MMS_BTIME6* bTime6)
{
apr_time_t ticks;
if ((TIME_T_1984_JAN_1 + (bTime6->day * SECONDS_PER_DAY)) > TIME_T_2036) {
echo_warn("ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>󣬳<EFBFBD><EFBFBD><EFBFBD>2036<EFBFBD>");
}
ticks = TIME_T_1984_JAN_1;
ticks += (bTime6->day * SECONDS_PER_DAY);
ticks *= 1000;
ticks += bTime6->ms;
ticks *= 1000;
return ticks;
}
/*
61850
λ <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֵ
0-1 Good 00
Invalid 01
Reserved 10
Questionable11
2 Overflow
3 OutofRange
4 BadReference
5 Oscillatory
6 Failure
7 OldData
8 Inconsistent
9 Inaccurate
10 Source 0(process)/1(Substituted)
11 Test
12 OperatorBlocked
*/
/*
60870
λ <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֵ
0 <09><><EFBFBD><EFBFBD>
1 <09><><EFBFBD><EFBFBD>
2 <09><><EFBFBD><EFBFBD>
3 <09><><EFBFBD><EFBFBD>
4 <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
5 <09><>ȡ<EFBFBD><C8A1>
6 <09>ǵ<EFBFBD>ǰֵ
7 <09><>Ч
*/
byte_t get_mx_q_from_61850(char* q_61850)
{
QDS q;
q.bits = 0;
if (set_mx_q) {
if (!strlen(q_61850)) {
return q.bits;
}
if (!strcmp("0000000000000", q_61850)) {
return q.bits;
}
if (q_61850[0] == '0' && q_61850[1] == '1')
q.parts.IV = 1;
if (q_61850[0] == '1' && q_61850[1] == '1' && q_61850[7] == '1')
q.parts.NT = 1;
if (q_61850[2] == '1')
q.parts.OV = 1;
if (q_61850[12] == '1')
q.parts.BL = 1;
if (q_61850[10] == '1')
q.parts.SB = 1;
}
return q.bits;
}
/*
60870
λ <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֵ
0 <09><><EFBFBD><EFBFBD>
1 <09><><EFBFBD><EFBFBD>
2 <09><><EFBFBD><EFBFBD>
3 <09><><EFBFBD><EFBFBD>
4 <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
5 <09><>ȡ<EFBFBD><C8A1>
6 <09>ǵ<EFBFBD>ǰֵ
7 <09><>Ч
*/
byte_t get_st_q_from_61850(char* q_61850)
{
SIQ q;
q.bits = 0;
if (!strlen(q_61850)) {
return q.bits;
}
if (!strcmp("0000000000000", q_61850)) {
return q.bits;
}
if (q_61850[0] == '0' && q_61850[1] == '1')
q.parts.IV = 1;
if (q_61850[0] == '1' && q_61850[1] == '1' && q_61850[7] == '1')
q.parts.NT = 1;
if (q_61850[12] == '1')
q.parts.BL = 1;
if (q_61850[10] == '1')
q.parts.SB = 1;
return q.bits;
}
byte_t get_pulse_q_from_61850(char* q_61850)
{
if (!strlen(q_61850)) {
return 0;
}
if (q_61850[0] == '0' && q_61850[1] == '1')
return 1;
else
return 0;
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////

509
mms/rdb_client.h Normal file
View File

@@ -0,0 +1,509 @@
/**
* @file iec103ttylink.h
* @brief IEC61850 <20><>rdb <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ͷ<EFBFBD>ļ<EFBFBD>
*
* @version $Revision: 1.18 $
* @date $Date: 2018/12/29 12:30:29 $
* @author $Author: lizhongming $
* @state $State: Exp $
* @latest $Id: rdb_client.h,v 1.18 2018/12/29 12:30:29 lizhongming Exp $
*/
#ifndef _RDB_CLIENT_H_XSDFSDFSEFS15156SFS
#define _RDB_CLIENT_H_XSDFSDFSEFS15156SFS
#include "interface.h"
#include "ied.h"
#include "node.h"
//lnk20250113<31><33><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>̨<EFBFBD>˶<EFBFBD><CBB6><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD>
#include "../json/save2json.h"
#include <stdbool.h>
//<2F>ļ<EFBFBD><C4BC><EFBFBD>Чʱ<D0A7><CAB1><EFBFBD><EFBFBD>ȡֵ
#define FROM_FILE_NAME (0)
#define FROM_SYSTEM (1)
//ͨ<><CDA8><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ŵ<EFBFBD>Ŀ¼
#define GENERAL_PREFIX "0_0"
#define GENERAL_PATH "0_0\\19700101\\00"
//iec report <20><><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD>״̬
#define VALUE_REACHED (0x01) // ״̬<D7B4><CCAC>ң<EFBFBD><D2A3>ֵ<EFBFBD><D6B5><EFBFBD>յ<EFBFBD>
#define Q_REACHED (0x02) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>
#define T_REACHED (0x04) // ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>
#define REASON_REACHED (0x08) // <20><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>
//CHANNELSTATE macro defines
#define CHANNEL_CONNECTING (0x01) //
#define CHANNEL_CONNECTED (0x02) //
#define CHANNEL_DISCONNECTING (0x03) //
#define CHANNEL_DISCONNECTED (0x04) //
#define RELAY_SELECT (0x01) //
#define RELAY_RUN (0x02) //
#define RELAY_CANCEL (0x03) //
#define MIN_INIT_NUM (10) //<2F><>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ٴ<EFBFBD><D9B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD>ٻ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define NEXT_CONNECT_TIME (10000) //һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD><EFBFBD>´<EFBFBD><C2B4><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>10*1000=10s
#define MAX_SAME_FCDNAME_OBJECTS (500) // for <20><><EFBFBD><EFBFBD>PQװ<51>ã<EFBFBD><C3A3>ij<EFBFBD>64 2016-5-10 //<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>FCD<43>ֳɶ<D6B3><C9B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD> <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> ACT<43><54><EFBFBD>󣬷ֳ<F3A3ACB7>general<61><6C>phsa<73><61>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/** ======================<3D><EFBFBD><EFBFBD><E6B6BC>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>չͬ<D5B9>ڹ<EFBFBD><DAB9><EFBFBD>============================ */
/*
16:<3A><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ʽ<EFBFBD><CABD>բ
17:<3A><><EFBFBD><EFBFBD>ͬ<EFBFBD>ں<EFBFBD>բ
18:<3A><>ͬ<EFBFBD>ں<EFBFBD>բ
19:<3A><><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9>բ
CHECK_BY_SETTING CHECK_U <20><>Ӧ˳<D3A6><CBB3>Ʊͬ<C6B1><CDAC>ң<EFBFBD>ص<EFBFBD><D8B5>ĵ<EFBFBD>һ<EFBFBD><D2BB>ң<EFBFBD>ص<EFBFBD>
CHECK_NOTHING CHECK_SYN <20><>Ӧ˳<D3A6><CBB3>Ʊͬ<C6B1><CDAC>ң<EFBFBD>ص<EFBFBD><D8B5>ĵڶ<C4B5><DAB6><EFBFBD>ң<EFBFBD>ص<EFBFBD>
*/
#define CHECK_START_QU 16
#define CHECK_BY_SETTING 0
#define CHECK_NOTHING 1
#define CHECK_SYN 2
#define CHECK_U 3
#define DEFAULT_EDIT_FXDAREANO (0x80FE) /**< Ĭ<>ϱ<CFB1><E0BCAD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD> */
#define FIXED_AREA_GRP_DOT2_EDIT_AREA (2) /**< <20><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>-><3E><EFBFBD><E0BCAD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD> */
extern unsigned int g_node_id;
typedef struct element_usr_t element_usr_t;
typedef struct rptinfo_t rptinfo_t;
typedef struct loginfo_t loginfo_t;
typedef struct LD_info_t LD_info_t;
typedef struct ied_usr_t ied_usr_t;
typedef struct chnl_usr_t chnl_usr_t;
typedef struct autorecall_t autorecall_t;
typedef struct ied_info_t ied_info_t;
//////////////////////////////////////////////////////////
struct autorecall_t {
long long start;
long long end;
int need_steady; //lnk20241030<33><30><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD><CCAC>̬<EFBFBD><CCAC>־
int need_voltage;
};
//////////////////////////////////////////////////////////
struct ied_info_t{
char time[50][20];
unsigned char name[50][128];
char value[50][20];
};
//lnk20250113<31><33><EFBFBD><EFBFBD>̨<EFBFBD>˸<EFBFBD><CBB8>½ṹ///////////////////////////////
#define MAX_UPDATEA_NUM 300
typedef struct trigger_update_xml_t trigger_update_xml_t;
struct trigger_update_xml_t{
int work_update_num;
int new_update_num;
int delete_update_num;
int modify_update_num;
terminal work_updates[MAX_UPDATEA_NUM];
terminal new_updates[MAX_UPDATEA_NUM];
terminal delete_updates[MAX_UPDATEA_NUM];
terminal modify_updates[MAX_UPDATEA_NUM];
};
//////////////////////////////////////////////////////////
#define MAX_TRIGGER_NUM 300
typedef struct trigger_t trigger_t;
struct trigger_t{
int dev_idx;
int line_id;
int real_data;
int soe_data;
int limit;
int count;
};
typedef struct trigger_3s_xml_t trigger_3s_xml_t;
struct trigger_3s_xml_t{
int work_trigger_num;
int new_trigger_num;
int delete_trigger_num;
int modify_trigger_num;
trigger_t work_triggers[MAX_TRIGGER_NUM];
trigger_t new_triggers[MAX_TRIGGER_NUM];
trigger_t delete_triggers[MAX_TRIGGER_NUM];
trigger_t modify_triggers[MAX_TRIGGER_NUM];
};
/////////////////////////////////
#define MAX_RECALL_NUM 300
typedef struct recall_t recall_t;
struct recall_t{
char* line_id;
long long start_time; //<2F><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD>־<EFBFBD><D6BE>ʼʱ<CABC><CAB1>
long long end_time; //<2F><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
int need_steady;
int need_voltage;
};
typedef struct recall_xml_t recall_xml_t;
struct recall_xml_t{
int work_recall_num;
int new_recall_num;
recall_t work_recalls[MAX_RECALL_NUM];
recall_t new_recalls[MAX_RECALL_NUM];
};
/////////////////////////////////////////////////////////////
struct element_usr_t{
char* FCD_ref;
char* FCDA_ref;
char* Full_FCDA_ref;
double m_v;
char q[14]; //q use 13 bits
systime_t tm;
char reason[7]; // reserve 1 bit, use 5 bits
uint32_t DataStatus;
int m_num_same_FCD_Objects;
// element_t* m_pSameFCDObjects[MAX_SAME_FCDNAME_OBJECTS];
int num_same_FCDA_Objects;
// element_t* pSame_FCDA_Objects[MAX_SAME_FCDNAME_OBJECTS];
byte_t is_phase_soe;
byte_t last_soe_status;
};
struct rptinfo_t{
char* rptID;
byte_t instanceNeedSuffix; //ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>Ӻ<EFBFBD>׺
byte_t TrgOpt;
byte_t OptFlds [2]; /* 10 bit bitstring but only allow write of 9 bits*/
uint32_t IntgPd; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
int report_PQ_type; //<2F><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>ͳ<EFBFBD>ơ<EFBFBD>ʵʱ<CAB5><CAB1>soe<6F><65><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>͵<EFBFBD>
LD_info_t* LD_info;
int rpt_registered; //<2F>Ƿ<EFBFBD>ע<EFBFBD><D7A2><EFBFBD>ɹ<EFBFBD>
byte_t chnl_id; //<2F><><EFBFBD><EFBFBD>δע<CEB4><EFBFBD>´<EFBFBD><C2B4><EFBFBD>ͼע<CDBC><EFBFBD><E1B1A8><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><E1A3AC><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD>ע<EFBFBD><EFBFBD><E1B1A8><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>
RCB_INFO * m_rcb_info;
double m_LastDataTime; //<2F>ϴ<EFBFBD><CFB4>յ<EFBFBD><D5B5><EFBFBD><EFBFBD>ݵ<EFBFBD>ʱ<EFBFBD><CAB1>
double m_LastGITime; //<2F>ϴ<EFBFBD>GI<47><49>ʱ<EFBFBD><CAB1>
double m_LastRegisterFailedTime; //<2F>ϴ<EFBFBD>ע<EFBFBD><D7A2>ʧ<EFBFBD>ܵ<EFBFBD>ʱ<EFBFBD><CAB1>
double m_LastUnRegisterFailedTime; //<2F>ϴ<EFBFBD>ȡ<EFBFBD><C8A1>ע<EFBFBD><D7A2>ʧ<EFBFBD>ܵ<EFBFBD>ʱ<EFBFBD><CAB1>
byte_t m_EntryID[8];
int m_curRptSuffix;
int count; //<2F>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĴ<DDB5><C4B4><EFBFBD>
int rptNo;//CZY 2023-08-17 WW 2022-11-14<31><34><EFBFBD>ӱ<EFBFBD><D3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>
int flickerflag;//CZY 2023-08-17 WW 2022-11-14<31><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
int pstflag;//CZY 2023-08-17 WW 2022-11-14<31><34><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
};
struct loginfo_t{
char* lcbName;
char* datasetName;
char logName[32];
uint32_t IntgPd; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
byte_t reasonCode;
byte_t TrgOpt;
LD_info_t* LD_info;
//LCB_INFO * m_lcb_info;
apr_time_t start_time; //<2F><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD>־<EFBFBD><D6BE>ʼʱ<CABC><CAB1>
apr_time_t end_time; //<2F><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
//double last_checktime;
int need_steady;
int need_voltage;
};
#define QVVR_NUM (256)
#define QVVR_DATA_NOT_USED (0)
#define QVVR_DATA_RECEIVED (1)
#define QVVR_DATA_PAIRED (2)
typedef struct QVVR_t QVVR_t;
struct QVVR_t{
int used_status;
int QVVR_start;
int QVVR_type;
long long QVVR_time;
float QVVR_PerTime;
float QVVR_Amg;
char QVVR_Rptname[128];
uint32_t timestamp;
};
struct LD_info_t{
char name[256];
ied_t *ied;
byte_t cpuno;
char *LD_name;
apr_hash_t *ht_fcd; /**< FCD object hash<73><68><EFBFBD><EFBFBD> <20><> element */
apr_hash_t *ht_full_fcda; /**< <20><><EFBFBD><EFBFBD>FCDA object hash<73><68><EFBFBD><EFBFBD> <20><> element */
int rptcount; /**< report <20><><EFBFBD><EFBFBD> */
rptinfo_t **rptinfo; /**< rptinfo_t* <20><><EFBFBD><EFBFBD> */
int read_flag ; //CZY 2023-02-28 <20>ж<EFBFBD><D0B6>Ƿ񽫼<C7B7><F1BDABBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ч
char mp_id[256];//CZY 2023-08-20 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBA3AC><EFBFBD><EFBFBD>8afaa
char terminal_code[256];//CZY 2023-08-20 <20>ն˱<D5B6><CBB1><EFBFBD>
//int ld_ins;//CZY 2023-08-20 <20>߼<EFBFBD><DFBC>豸ʵ<E8B1B8><CAB5><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD>1
char voltage_level[256];//CZY 2023-08-20 <20><>ѹ<EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>30
char v_wiring_type[256];//CZY 2023-08-20 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD>߷<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>01-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>02-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
long long time; //CZY 2023-08-20 ʱ<><CAB1><EFBFBD><EFBFBD>(<28><>) ̨<>˸<EFBFBD><CBB8><EFBFBD>ʱ<EFBFBD><EFBFBD><E4A3AC><EFBFBD><EFBFBD>1691656669
int update_flag;//CZY 2023-08-20 ̨<>˸<EFBFBD><CBB8>±<EFBFBD>־ 0:keep 2:delete 4:update 8:add
char monitor_status[64]; //lnk20241031<33><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
//<2F><><EFBFBD><EFBFBD>
int rptRecvFlag;//CZY 2023-08-17 WW 2022-11-14<31>жϱ<D0B6><CFB1><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>,rptRecvFlag=<3D><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int rptRecvCheckFlag;//CZY 2023-08-17 WW 2022-11-14<31>жϱ<D0B6><CFB1><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>,ÿ<><C3BF><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rptRecvFlagһ<67><D2BB><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
int rptPstRecvFlag;//CZY 2023-08-17 WW 2022-11-14<31>жϱ<D0B6><CFB1><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>,rptRecvFlag=<3D><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int rptPstRecvCheckFlag;//CZY 2023-08-17 WW 2022-11-14<31>жϱ<D0B6><CFB1><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>,ÿ<><C3BF><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rptRecvFlagһ<67><D2BB><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD>
//<2F><>ʹ<EFBFBD><CAB9>
int iUnitOfTime;//CZY 2023-08-17 WW 2022<32><32>12<31><32>7<EFBFBD><37>15:43:34 װ<><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䵥λ<E4B5A5>л<EFBFBD>(0-ms; 1-s)
int iStatOfTime;//CZY 2023-08-17 WW 2022<32><32>12<31><32>7<EFBFBD><37>15:48:33 ͳ<><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> 0-<2D><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> 1-UTCʱ<43><CAB1>
int iJournalTime;//CZY 2023-08-17 WW 2022<32><32>12<31><32>7<EFBFBD><37>15:52:32 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־ʱ<D6BE><CAB1>(0-UTCʱ<43><CAB1>(<28><>־<EFBFBD><D6BE>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ΪUTCʱ<43><CAB1>); 1-<2D><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>(<28><>־<EFBFBD><D6BE><EFBFBD><EFBFBD>ʱ<EFBFBD>䡢¼<E4A1A2><C2BC><EFBFBD>ļ<EFBFBD>UTCʱ<43><CAB1> ע<><D7A2><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>+8Сʱ<D0A1><CAB1>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־))
//<2F><>ʹ<EFBFBD><CAB9>
//<2F><>־
int logcount; /**< log <20><><EFBFBD><EFBFBD> */
loginfo_t **loginfo; /**< loginfo_t* <20><><EFBFBD><EFBFBD> */
//<2F><>־
//<2F><><EFBFBD><EFBFBD>
int autorecallflag;
int autorecallcount;
autorecall_t **autorecall;
//<2F><><EFBFBD><EFBFBD>
//<2F><>ʹ<EFBFBD><CAB9>
uint32_t group; //add by rzx
//<2F><>ʹ<EFBFBD><CAB9>
//ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD>
int line_id;
//ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD>
//¼<><C2BC>
int FltNum[256];
//¼<><C2BC>
//ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD>
int real_data;
int soe_data;
int limit;
int count;
//ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD>
//<2F><>ʹ<EFBFBD><CAB9>
int SubV_Index;
int Dev_Index;
int Sub_Index;
int GD_Index;
//<2F><>ʹ<EFBFBD><CAB9>
//process QVVR
QVVR_t qvvr[QVVR_NUM];
int qvvr_idx;
//<2F><>̬
//process RDRE
int RDRE_FltNum;
//¼<><C2BC>
};
struct ied_usr_t{
LD_info_t *LD_info; /**< LD<4C><44><EFBFBD><EFBFBD> */
int dev_idx; /**< <20><EFBFBD><E8B1B8><EFBFBD><EFBFBD> */
char dev_type[256]; /**< <20><EFBFBD><E8B1B8><EFBFBD><EFBFBD> */
char dev_key[256]; /**< <20><EFBFBD><E8B1B8>Կ */
char dev_series[256]; /**< <20>豸ʶ<E8B1B8><CAB6><EFBFBD><EFBFBD> */
int dev_flag; /**< <20><EFBFBD><E8B1B8>־ */
void *cookie;
double last_call_wavelist_time ; //<2F>ϴ<EFBFBD><CFB4><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>б<EFBFBD>ʱ<EFBFBD><CAB1>
char terminal_id[256];//CZY 2023-08-20 <20>ն<EFBFBD>id<69><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8afaa9a15707483a0157262f8e78077d
char org_name[256];//CZY 2023-08-20 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͼ<EFBFBD><CFBE><EFBFBD><EFBFBD><EFBFBD>˾
char maint_name[256];//CZY 2023-08-20 <20><>ά<EFBFBD><CEAC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͼ<EFBFBD><CFBE><EFBFBD><EFBFBD><EFBFBD>˾
char station_name[256];//CZY 2023-08-20 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>վ<EFBFBD><D5BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>220kV<6B><56>̨ɽ<CCA8><C9BD>
char tmnl_factory[256];//CZY 2023-08-20 <20>ն˳<D5B6><CBB3>ң<EFBFBD><D2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͼ<EFBFBD><CFBE>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD><EFBFBD>޹<EFBFBD>˾
long long time; //CZY 2023-08-20 ʱ<><CAB1><EFBFBD><EFBFBD>(<28><>) ̨<>˸<EFBFBD><CBB8><EFBFBD>ʱ<EFBFBD><EFBFBD><E4A3AC><EFBFBD><EFBFBD>1691656669
char tmnl_status[256];//CZY 2023-08-30 <20><><EFBFBD><EFBFBD>״̬
char terminal_code[256];//CZY 2023-08-30 <20>ն˱<D5B6><CBB1><EFBFBD>
int update_flag;//CZY 2023-08-20 ̨<>˸<EFBFBD><CBB8>±<EFBFBD>־ 0:keep 2:delete 4:update 8:add
};
struct chnl_usr_t{
byte_t chnl_id;
char ip_str[20];
channel_t *chnl; /**< <20><>Ӧ<EFBFBD><D3A6>channel ָ<><D6B8> */
MVL_NET_INFO *net_info;
MVL_REQ_PEND *m_reqCtrl; //MVL_REQ_PEND
int m_state;
double m_StartConnectingTime; //<2F><><EFBFBD>ο<EFBFBD>ʼ connect <20><>ʱ<EFBFBD><CAB1>
double m_StartDisconnectingTime; //<2F><><EFBFBD>ο<EFBFBD>ʼ disconnect <20><>ʱ<EFBFBD><CAB1>
double m_ClosedMsTime; //<2F>ϴ<EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD>ر<EFBFBD>ʱ<EFBFBD><CAB1>
double m_LastPosRespTime; //<2F>ϴο϶<CEBF><CFB6><EFBFBD>Ӧ<EFBFBD><D3A6>ʱ<EFBFBD><CAB1>
int m_NegRespTimes; // <20>ۼƷ<DBBC><C6B7><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
};
typedef struct pt61850app_t pt61850app_t;
struct pt61850app_t
{
// rdb_t *rdb;
node_t *node;
// driver_t *driver;
//byte_t IsMaster; //<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
////////////////////////////
uint32_t mmsOpTimeout; //mms<6D><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ȵĽ<C8B5><C4BD><EFBFBD><EFBFBD><EFBFBD>ʱʱ<CAB1><CAB1>
//uint32_t relayTimeout; //ң<>صȴ<D8B5>ң<EFBFBD>ŷ<EFBFBD><C5B7>صij<D8B5>ʱʱ<CAB1><CAB1>
uint32_t giTime; //<2F>ܲ<EFBFBD>ѯʱ<D1AF><CAB1>
int rptSuffix[2][2]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƿ<EFBFBD><C6BF><EFBFBD>׺
//char ftp_srv_ip[16];
//char ftpsrv_path[64];
//char ftp_user[32];
//char ftp_password[32];
char accPath[65]; //װ<><D7B0>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>
//char RcdMadeAddStr[65]; //¼<><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ң<EFBFBD>ŵ<EFBFBD>ַ
//uint8_t change_file_name; //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>Ƿ<EFBFBD><C7B7>޸<EFBFBD><DEB8>ļ<EFBFBD><C4BC><EFBFBD>
uint32_t chnl_counts;
chnl_usr_t **chnl_usr;
apr_pool_t *tmp_pool; // <20><>ʱpool
//<2F><>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD>ٻ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD>ó<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>κ<EFBFBD><CEBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ٻ<EFBFBD><D9BB>ļ<EFBFBD>
uint8_t initNum;
//<2F>ٻ<EFBFBD><D9BB>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ͣ<EFBFBD>Ϊ0<CEAA><30>ֻ<EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD>ӦĿ¼<C4BF>µ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ϊ1<CEAA><31><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD>ӦĿ¼<C4BF>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ
//uint8_t call_file_type;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>Ч
uint8_t check_dgtVal;//0<><30><EFBFBD>У<EFBFBD><D0A3><EFBFBD>0<EFBFBD><30>
};
//Ϊ<><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
extern uint8_t set_mx_q;
#ifdef _OS_WIN32_
#pragma pack(push,1)
#endif
#ifdef _OS_WIN32_
#pragma pack(pop)
#endif
#ifdef __cplusplus
extern "C" {
#endif
char* str_trim_both(char* temp,const char* pattern) ;
element_usr_t* GET_DOTEXT_ADDR(element_t *elem);
ied_usr_t* GET_IEDEXT_ADDR(ied_t *ied);
ST_RET mms_jread (loginfo_t *loginfo,MVL_NET_INFO *clientNetInfo, ST_CHAR *dom_name,ST_CHAR *logName, apr_time_t start_time,apr_time_t end_time,ST_INT iTimeout, ST_CHAR* ip) ;
LD_info_t* find_LD_from_cpuId(ied_t* ied,byte_t cpuId);
LD_info_t* find_LD_from_IEDLDName(ied_t* ied, char *IEDLDName);
LD_info_t* find_LD_from_cpuCount_and_LEDRs(ied_t* ied, byte_t cpuCount);
LD_info_t* find_LD_from_IEDLDName_in_report(ied_t* ied, char *IEDLDName);
LD_info_t* find_LD_from_element(element_t* elem);
rptinfo_t* find_rptinfo_from_net_rcb_info(MVL_NET_INFO *net_info,RCB_INFO *rcb_info);
rptinfo_t* find_rptinfo_from_net_rpt_info_name(MVL_NET_INFO *net_info, RCB_INFO *rcb_info);
void get_rpt_inst_name(rptinfo_t *rptinfo, char * rpt_inst_name );
/**
* @brief <20><>ʼ<EFBFBD><CABC>rdb<64><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> APR_SUCCESS
*/
apr_status_t init_rdb();
/**
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
* @return <20><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> APR_SUCCESS
*/
apr_status_t run_protocol();
void Set_val_from_61850rpt(element_t* elem,double v);
int Set_q_from_61850rpt(char* q);
apr_status_t init_rem_dib_table();
void CheckNextNotConnectedChannel();
//WW 2023-08-22
int HandleReceiveMessage(int socketClient, char buffer[256]);
int ExecuteWebCommand(LD_info_t *LD_info, int iType);
int SendMessageToWeb(int socketClient, int iErrorCode); //<2F><>Web Socket<65>ͻ<EFBFBD><CDBB>˷<EFBFBD><CBB7><EFBFBD><EFBFBD><EFBFBD>Ϣ
//WW 2023-08-22 end
void CheckAllConnectedChannel() ;
void check_3s_config();
void check_recall_config();
void create_recall_xml();
void check_disk_quota();
apr_status_t prepare_call_cn_wavelist(LD_info_t *LD_info, int FltNum );
apr_status_t call_cn_wavelist(LD_info_t *LD_info);
void strip_file_name_tail_to_ms(char *fileName);
//////////for pq //////////////////////////////////////////
ied_t* find_ied_from_dev_idx(int dev_idx);
ied_t* find_ied_from_dev_code(char dev_idx[]);
LD_info_t* find_LD_info_from_line_id(ied_t* ied, int line_id);
LD_info_t* find_LD_info_only_from_line_id(int line_id);
LD_info_t* find_LD_info_from_mp_id(ied_t* ied, char* mp_id);
LD_info_t* find_LD_info_only_from_mp_id(char* mp_id);
////////////////////////////////lnk20250115
int parse_ledger_update_xml(trigger_update_xml_t* trigger_update_xml);
extern const int MAX_CPUNO;
extern int stringToInt(const char* str, int* result);
extern bool isCharPtrEmpty(const char* str);
extern int parse_ledger_update_xml(trigger_update_xml_t* trigger_update_xml);
extern int update_one_terminal_ledger(terminal* update, int i,ied_t* ied,int terminal_index);
extern void print_trigger_update_xml(const trigger_update_xml_t* trigger_update);
////////////////////////////////
int parse_3s_xml(trigger_3s_xml_t* trigger_3s_xml);
int create_3s_xml(trigger_3s_xml_t* trigger_3s_xml);
int get_real_report_count(LD_info_t *LD_info);
int delete_recall_xml(char* id);
int parse_recall_xml(recall_xml_t* recall_xml,char *id);
void process_recall_config(recall_xml_t* recall_xml);
int remove_recall_xml();
int init_rptctrl_by_count(LD_info_t* LD_info,int rptcount);
int fill_rptctrl_by_cfg(LD_info_t* LD_info,int rptno,char *buf);
int init_logctrl_by_count(LD_info_t* LD_info,int logcount);
int fill_logctrl_by_cfg(LD_info_t* LD_info,int logno,char *buf,char* devtype);
//////////////////////////////////////////////////////////
void processQVVR_start(LD_info_t* LD_info);
void processQVVR_time(LD_info_t* LD_info, long long Time);
void processQVVR_data(LD_info_t* LD_info,char* FULL_FCDA_Name,double v);
void processQVVR_end(LD_info_t* LD_info);
void processRDRE_start(LD_info_t* LD_info);
void processRDRE_data(LD_info_t* LD_info,char* FULL_FCDA_Name,double v);
void processRDRE_end(LD_info_t* LD_info);
int extract_timestamp_from_cfg_file(char *comtrade_fn,long long *start_tm,long long *trig_tm);
int parse_file_names(char *file_match_str,char **filenames,int filenum,int *cfg_idx,int *dat_idx,char *file_base_name,char *file_yyyymm);
int parse_file_names_by_fltnum(int fltnum, char* domname, char** filenames, int filenum, int* cfg_idx, int* dat_idx, char* file_base_name, char* file_yyyymm);
QVVR_t* find_qvvr_by_trig_tm(LD_info_t* LD_info,long long trig_tm);
//////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif
#endif /* _RDB_CLIENT_H_XSDFSDFSEFS15156SFS */

615
mms/rdb_ext_utils.c Normal file
View File

@@ -0,0 +1,615 @@
/**
* @file: $RCSfile: rdb_ext_utils.c,v $
* @brief: $ rdb <20><><EFBFBD><EFBFBD>usr_ext<78><74><EFBFBD><EFBFBD><EFBFBD>Ľṹ<C4BD><E1B9B9>һЩ<D2BB><D0A9><EFBFBD>ߺ<EFBFBD><DFBA><EFBFBD>
*
* @version: $Revision: 1.11 $
* @date: $Date: 2018/12/23 12:39:52 $
* @author: $Author: lizhongming $
* @state: $State: Exp $
*
* @latest: $Id: rdb_ext_utils.c,v 1.11 2018/12/23 12:39:52 lizhongming Exp $
*/
#include <string.h>
#include "rdb_client.h"
#include "xmltools.h"
#include "db_interface.h"
//extern rdb_t* g_rdb ;
extern node_t* g_node ;
extern char g_my_conf_fname[256];
extern apr_pool_t* g_init_pool;
extern apr_pool_t* g_run_pool;
extern pt61850app_t* g_pt61850app;
//extern int g_sysfile_appid;
//extern char *g_sysfile_filedir;
//int my_index =0;
//extern ied_info_t *my_info;
//extern byte_t g_file_name_len;
//extern byte_t g_file_time_from;
////////////////////////str <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>//////////////////////////
char* str_trim_both(char* temp,const char* pattern)
{ // pattern such as " \t" or " \t\'"
unsigned int i,j;
for(i=0;i<strlen(temp);i++) {
if ( strchr(pattern,temp[i]) == NULL )
break;
}
temp +=i;
for(j=(strlen(temp)-1);j>=0;j--) {
if ( strchr(pattern,temp[j]) )
temp[j] = 0;
else
break;
}
return(temp);
}
////////////////////////rdb 61850<35><30><EFBFBD><EFBFBD><EFBFBD><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>//////////////////////////
ied_usr_t* GET_IEDEXT_ADDR(ied_t *ied)
{
assert(ied);
return (ied_usr_t* )ied->usr_ext;
}
element_usr_t* GET_DOTEXT_ADDR(element_t *elem)
{
element_usr_t *elem_usr;
assert(elem);
if (elem->usr_ext == NULL) {
elem_usr = apr_pcalloc(g_init_pool,sizeof(element_usr_t));
elem_usr->last_soe_status = 99;
elem->usr_ext = elem_usr;
}
return (element_usr_t* )elem->usr_ext;
}
LD_info_t* find_LD_from_cpuCount_and_LEDRs(ied_t* ied, byte_t cpuCount)
{
LD_info_t *LD_info = NULL;
element_t *elem = NULL;
LD_info = & (GET_IEDEXT_ADDR(ied)->LD_info[cpuCount]);
elem = apr_hash_get(LD_info->ht_fcd, "LLN0$CO$LEDRs", APR_HASH_KEY_STRING);
if (elem)
return LD_info;
else
return NULL;
}
LD_info_t* find_LD_from_cpuId(ied_t* ied,byte_t cpuId)
{
int cpuno;
LD_info_t* LD_info = NULL;
assert(ied);
for(cpuno=0 ; cpuno<ied->cpucount; cpuno++) {
if ( ied->cpuinfo[cpuno].addr != cpuId )
continue;
LD_info = & (GET_IEDEXT_ADDR(ied)->LD_info[cpuno]) ;
}
return LD_info;
}
LD_info_t* find_LD_from_IEDLDName(ied_t* ied, char *IEDLDName)
{
int cpuno;
LD_info_t* LD_info = NULL;
assert(ied);
for(cpuno=0 ; cpuno<ied->cpucount; cpuno++) {
LD_info = & (GET_IEDEXT_ADDR(ied)->LD_info[cpuno]) ;
if(LD_info->LD_name){
if (strcmp(LD_info->LD_name, IEDLDName)==0)
return LD_info;
}
}
return NULL;
}
LD_info_t* find_LD_from_IEDLDName_in_report(ied_t* ied, char *IEDLDName)
{
ST_CHAR * DomName;
LD_info_t* LD_info = NULL;
DomName = IEDLDName; //strtok (DataReference, "/");/* extract domain name */
LD_info = find_LD_from_IEDLDName(ied, DomName);
assert(LD_info);
return LD_info;
}
LD_info_t* find_LD_from_element(element_t* elem)
{
return find_LD_from_cpuId(elem->ied, (elem->grp->id>>8)&0xff ) ;
}
RCB_INFO* FindRcbInfo(MVL_NET_INFO *net_info,ST_CHAR *dom_name, ST_CHAR *rcb_name)
{
ied_t *ied;
ied_usr_t *ied_usr;
chnl_usr_t *chnl_usr;
LD_info_t *LD_info;
rptinfo_t *rptinfo = NULL;
int cpuno,rpt_no;
char rpt_inst_name[65];
chnl_usr = net_info->user_ext;
ied = chnl_usr->chnl->ied;
ied_usr = GET_IEDEXT_ADDR(ied);
for(cpuno=0 ; cpuno<ied->cpucount; cpuno++) {
LD_info = &(ied_usr->LD_info[cpuno]);
if (!LD_info->LD_name)
continue;
if ( strcmp(LD_info->LD_name,dom_name)!=0 )
continue;
for(rpt_no=0 ; rpt_no<LD_info->rptcount; rpt_no++) {
rptinfo = LD_info->rptinfo[rpt_no];
get_rpt_inst_name(rptinfo,rpt_inst_name);
if ( strcmp(rpt_inst_name,rcb_name)==0 ) {
if (rptinfo->rpt_registered)
return rptinfo->m_rcb_info;
else
return NULL;
}
}
}
return NULL;
}
////////////////////////////////////////
//WW 2023-08-29 <20><><EFBFBD><EFBFBD>rcb_info<66><6F>dev_type<70>󶨲<EFBFBD><F3B6A8B2>Ǻͼ<C7BA><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>󶨣<EFBFBD><F3B6A8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸Ĺ<DEB8><C4B9>򣬱<EFBFBD><F2A3ACB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>
rptinfo_t* find_rptinfo_from_net_rpt_info_name(MVL_NET_INFO *net_info, RCB_INFO *rcb_info)
{
ied_t *ied;
ied_usr_t *ied_usr;
chnl_usr_t *chnl_usr;
LD_info_t *LD_info;
rptinfo_t *rptinfo = NULL;
int cpuno,rpt_no;
chnl_usr = net_info->user_ext;
ied = chnl_usr->chnl->ied;
ied_usr = GET_IEDEXT_ADDR(ied);
for(cpuno=0 ; cpuno<ied->cpucount; cpuno++) {
LD_info = &(ied_usr->LD_info[cpuno]);
for(rpt_no=0 ; rpt_no<LD_info->rptcount; rpt_no++) {
rptinfo = LD_info->rptinfo[rpt_no];
printf("%d rptinfo %s,rcbinfo %s ", rpt_no, rptinfo->rptID, rcb_info->RptID);
if (strcmp(rcb_info->RptID,rptinfo->rptID)==0)//WW <20>޸<EFBFBD>Ϊƥ<CEAA><C6A5><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
return rptinfo;
}
}
return NULL;
}
//WW 2023-08-29 ע<><D7A2>
////////////////////////////////////////
////////////////////////////////////////
//WW 2023-08-29 ע<><D7A2>
rptinfo_t* find_rptinfo_from_net_rcb_info(MVL_NET_INFO *net_info,RCB_INFO *rcb_info)
{
ied_t *ied;
ied_usr_t *ied_usr;
chnl_usr_t *chnl_usr;
LD_info_t *LD_info;
rptinfo_t *rptinfo = NULL;
int cpuno,rpt_no;
chnl_usr = net_info->user_ext;
ied = chnl_usr->chnl->ied;
ied_usr = GET_IEDEXT_ADDR(ied);
for(cpuno=0 ; cpuno<ied->cpucount; cpuno++) {
LD_info = &(ied_usr->LD_info[cpuno]);
for(rpt_no=0 ; rpt_no<LD_info->rptcount; rpt_no++) {
rptinfo = LD_info->rptinfo[rpt_no];
if (rcb_info==rptinfo->m_rcb_info)
return rptinfo;
}
}
return NULL;
}
////////////////////////////////////////
//WW 2023-08-29 ע<><D7A2> end
void get_rpt_inst_name(rptinfo_t *rptinfo, char * rpt_inst_name )
{
strcpy(rpt_inst_name,rptinfo->rptID);
if (rptinfo->instanceNeedSuffix) {
char rpt_suffix_str[8];
apr_snprintf(rpt_suffix_str,sizeof(rpt_suffix_str),"%02d",rptinfo->m_curRptSuffix);
strcat(rpt_inst_name,rpt_suffix_str);
}
}
void strip_file_name_tail_to_ms(char *fileName)
{
char *p = NULL;
assert(fileName);
assert(strlen(fileName)<128);
assert(strlen(fileName)>0);
p = fileName;
while(*p != '.') {
p++;
}
while((p>fileName)&&(*p<0x30 || *p>0x39)) {
p--;
}
*++p = '\0';
}
static void _cut_file_name(char *fileName, byte_t len)
{
size_t full_len = strlen(fileName);
if (full_len<=len)
return;
else {
memmove(fileName, fileName+(full_len-len), len);
*(fileName+len) = '\0';
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
ied_t* find_ied_from_dev_idx(int dev_idx)
{
ied_t *ied = NULL;
int iedno;
ied_usr_t *ied_usr = NULL;
for(iedno=0; iedno<g_node->n_clients; iedno++) {
ied = g_node->clients[iedno];
ied_usr = (ied_usr_t*)ied->usr_ext;
if (ied_usr && ied_usr->dev_idx == dev_idx )
return ied;
}
return NULL;
}
ied_t* find_ied_from_dev_code(char dev_idx[])
{
ied_t* ied = NULL;
int iedno;
ied_usr_t* ied_usr = NULL;
for (iedno = 0; iedno < g_node->n_clients; iedno++) {
ied = g_node->clients[iedno];
ied_usr = (ied_usr_t*)ied->usr_ext;
if (ied_usr && strcmp(ied_usr->terminal_code, dev_idx) == 0) {
return ied;
}
}
return NULL;
}
//lnk20250114<31><34><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD>ն<EFBFBD>id<69><64><EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD>
ied_t* find_ied_from_terminal_id(char terminal_id[])
{
ied_t* ied = NULL;
int iedno;
ied_usr_t* ied_usr = NULL;
for (iedno = 0; iedno < g_node->n_clients; iedno++) {
ied = g_node->clients[iedno];
ied_usr = (ied_usr_t*)ied->usr_ext;
if (ied_usr && strcmp(ied_usr->terminal_id, terminal_id) == 0) {
return ied;
}
}
return NULL;
}
LD_info_t* find_LD_info_from_line_id(ied_t* ied, int line_id)
{
LD_info_t *LD_info = NULL;
ied_usr_t *ied_usr = GET_IEDEXT_ADDR(ied);
int cpuno;
for(cpuno=0 ; cpuno<ied->cpucount; cpuno++) {
LD_info = &(ied_usr->LD_info[cpuno]);
if (LD_info && LD_info->line_id==line_id)
return LD_info;
}
return NULL;
}
LD_info_t* find_LD_info_only_from_line_id(int line_id)
{
ied_t *ied = NULL;
int iedno;
LD_info_t *LD_info = NULL;
for(iedno=0; iedno<g_node->n_clients; iedno++) {
ied = g_node->clients[iedno];
if (ied) {
LD_info = find_LD_info_from_line_id(ied,line_id);
if (LD_info)
return LD_info;
}
}
return NULL;
}
LD_info_t* find_LD_info_from_mp_id(ied_t* ied, char* mp_id)
{
LD_info_t* LD_info = NULL;
ied_usr_t* ied_usr = GET_IEDEXT_ADDR(ied);
int cpuno;
for (cpuno = 0; cpuno < ied->cpucount; cpuno++) {
LD_info = &(ied_usr->LD_info[cpuno]);
if (LD_info && strcmp(LD_info->mp_id, mp_id) == 0)
return LD_info;
}
return NULL;
}
LD_info_t* find_LD_info_only_from_mp_id(char* mp_id)
{
ied_t* ied = NULL;
int iedno;
LD_info_t* LD_info = NULL;
for (iedno = 0; iedno < g_node->n_clients; iedno++) {
ied = g_node->clients[iedno];
if (ied) {
LD_info = find_LD_info_from_mp_id(ied, mp_id);
if (LD_info)
return LD_info;
}
}
return NULL;
}
void clear_all_LD_real_soe_report_shoud_register()
{
ied_t *ied = NULL;
int iedno;
ied_usr_t *ied_usr = NULL;
LD_info_t *LD_info = NULL;
int cpuno;
for(iedno=0; iedno<g_node->n_clients; iedno++) {
ied = g_node->clients[iedno];
ied_usr = (ied_usr_t*)ied->usr_ext;
for(cpuno=0 ; cpuno<ied->cpucount; cpuno++) {
LD_info = &(ied_usr->LD_info[cpuno]);
if (LD_info ) {
LD_info->real_data = 0;
LD_info->soe_data = 0;
}
}
}
}
void clear_rpt_counter_by_trigger(trigger_t *trigger)
{
ied_t *ied;
LD_info_t *LD_info;
int rpt_no;
rptinfo_t *rptinfo = NULL;
trigger->count = 0;
ied = find_ied_from_dev_idx(trigger->dev_idx);
if (!ied)
return;
LD_info = find_LD_info_from_line_id(ied,trigger->line_id);
if (!LD_info)
return;
LD_info->count = 0;
for(rpt_no=0 ; rpt_no<LD_info->rptcount; rpt_no++) {
rptinfo = LD_info->rptinfo[rpt_no];
rptinfo->count = 0;
}
}
int get_real_report_count(LD_info_t *LD_info)
{
int rpt_no;
rptinfo_t *rptinfo = NULL;
for(rpt_no=0 ; rpt_no<LD_info->rptcount; rpt_no++) {
rptinfo = LD_info->rptinfo[rpt_no];
//if (rptinfo->report_PQ_type & REPORT_TYPE_REAL)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD>жϱ<D0B6><CFB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (rptinfo->report_PQ_type)//<2F>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD>ж<EFBFBD>ʵʱ<CAB5><CAB1><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ж<EFBFBD>
return rptinfo->count;
}
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////<2F><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/////////////////////////////
void processQVVR_start(LD_info_t* LD_info)
{
int i;
for (i=0;i<QVVR_NUM;i++) {
if (LD_info->qvvr[i].used_status==QVVR_DATA_NOT_USED) {
LD_info->qvvr_idx = i; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ûʹ<C3BB>ã<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
break;
}
}
if (i>=QVVR_NUM) { //<2F>Ѿ<EFBFBD>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
uint32_t timestamp = LD_info->qvvr[0].timestamp;//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
LD_info->qvvr_idx = 0;//<2F>ӵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ʼ<E3BFAA><CABC>¼
echo_warn1("QVVR data memory is full,to replace the oldest,line_id=%d \n",LD_info->line_id);
for (i=1;i<QVVR_NUM;i++) {
if (LD_info->qvvr[i].timestamp<timestamp) {//<2F>ҵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>С<EFBFBD>ĵ㣬ʹ<E3A3AC><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
LD_info->qvvr_idx = i;
timestamp = LD_info->qvvr[i].timestamp;
}
}
}
LD_info->qvvr[LD_info->qvvr_idx].used_status = QVVR_DATA_RECEIVED;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>յ<EFBFBD><D5B5><EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
LD_info->qvvr[LD_info->qvvr_idx].QVVR_type = 0; //<2F><><EFBFBD><EFBFBD>δ<EFBFBD><CEB4>
LD_info->qvvr[LD_info->qvvr_idx].timestamp = apr_time_sec(apr_time_now());//<2F><>¼<EFBFBD><C2BC>ǰʱ<C7B0><CAB1>Ϊ<EFBFBD><CEAA>̬ʱ<CCAC><CAB1>
printf("\n~~~~~~~~~~~~~~~~~ processQVVR_start: line_id=%d \n",LD_info->line_id);
}
void processQVVR_time(LD_info_t* LD_info, long long Time)
{
LD_info->qvvr[LD_info->qvvr_idx].QVVR_time = Time;
printf("\n~~~~~~~~~~~~~~~~~ processQVVR_time: line_id=%d ,Time=%lld \n",LD_info->line_id,Time);
}
void processQVVR_data(LD_info_t* LD_info,char* FULL_FCDA_Name,double v)
{
if ( strstr(FULL_FCDA_Name,"VarStr$stVal") ) {
LD_info->qvvr[LD_info->qvvr_idx].QVVR_start = (v>0.99) ? 1:0;
}
else if ( strstr(FULL_FCDA_Name,"VVaTm$mag$f") )
LD_info->qvvr[LD_info->qvvr_idx].QVVR_PerTime = v;
else if ( strstr(FULL_FCDA_Name,"VVa$mag$f") )
LD_info->qvvr[LD_info->qvvr_idx].QVVR_Amg = v;
else {
if ( strstr(FULL_FCDA_Name,"DipStr$stVal") && (v>0.99) ) //<2F><>ѹ<EFBFBD>ݽ<EFBFBD>
LD_info->qvvr[LD_info->qvvr_idx].QVVR_type = 1;
else if ( strstr(FULL_FCDA_Name,"SwlStr$stVal") && (v>0.99) ) //<2F><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>
LD_info->qvvr[LD_info->qvvr_idx].QVVR_type = 2;
else if ( strstr(FULL_FCDA_Name,"IntrStr$stVal") && (v>0.99) ) //<2F><>ѹ<EFBFBD>ж<EFBFBD>
LD_info->qvvr[LD_info->qvvr_idx].QVVR_type = 3;
}
if (strstr(FULL_FCDA_Name, "QVVR")) {
apr_snprintf(LD_info->qvvr[LD_info->qvvr_idx].QVVR_Rptname, sizeof(LD_info->qvvr[LD_info->qvvr_idx].QVVR_Rptname), "%s", FULL_FCDA_Name);//terminal_code
}
printf("\n~~~~~~~~~~~~~~~~~ processQVVR_data: line_id=%d ,mms_str=%s,v=%f \n",LD_info->line_id,FULL_FCDA_Name,v);
}
void processQVVR_end(LD_info_t* LD_info)
{
//lnk20241227lnk<6E><6B><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD>¼<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DZ߻<C7B1><DFBB><EFBFBD><EFBFBD>ϱ<EFBFBD>һ<EFBFBD>θ<EFBFBD><CEB8><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFB2BB><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>
ied_t *ied = LD_info->ied;
ied_usr_t *ied_usr = GET_IEDEXT_ADDR(ied);
int ret;
long long end_tm = (long long)(LD_info->qvvr[LD_info->qvvr_idx].QVVR_PerTime*1000) + LD_info->qvvr[LD_info->qvvr_idx].QVVR_time; //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>dz<EFBFBD><C7B3><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>ʱ<EFBFBD><CAB1>
ret = transfer_json_qvvr_data(g_node_id, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ʹ<EFBFBD><CAB9>
LD_info->line_id, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LD_info->qvvr[LD_info->qvvr_idx].QVVR_Amg, LD_info->qvvr[LD_info->qvvr_idx].QVVR_PerTime, LD_info->qvvr[LD_info->qvvr_idx].QVVR_time, end_tm, LD_info->qvvr[LD_info->qvvr_idx].QVVR_type, //<2F><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><E4A1A2>ʼʱ<CABC><EFBFBD><E4A1A2><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><E4A1A2>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
"", "", //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>Ϊ<EFBFBD><CEAA>
LD_info->mp_id, LD_info->qvvr[LD_info->qvvr_idx].QVVR_Rptname, ied_usr->dev_type);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3>ļ<EFBFBD><C4BC>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD>¼<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD><D5B6><EFBFBD><EFBFBD><EFBFBD>
if(!ret)//ʧ<><CAA7>
{
printf("\n~~~~~~~~~~~~~~~~~ QVVR_json_data send error: line_id=%d \n",LD_info->line_id);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
int find_paired = FALSE;
int i;
if (LD_info->qvvr[LD_info->qvvr_idx].QVVR_start)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>ʱFCDA<44><41><EFBFBD><EFBFBD>VarStr$stVal<61><6C>QVVR_startΪ1<CEAA><31><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>
return;
for (i=0;i<QVVR_NUM;i++) { //<2F>ݽ<EFBFBD>/<2F><><EFBFBD><EFBFBD>/<2F>жϵȽ<CFB5><C8BD><EFBFBD><EBB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD>λ<EFBFBD><CEBB>
if (i==LD_info->qvvr_idx) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㵱ǰ<E3B5B1><C7B0><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
continue;
if (LD_info->qvvr[i].used_status != QVVR_DATA_RECEIVED)//<2F><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
continue;
//<2F><><EFBFBD><EFBFBD>ijλ<C4B3>õIJ<C3B5><C4B2><EFBFBD>Ҳû<D2B2>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD>λ<EFBFBD>õIJ<C3B5><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͺ͵<CDBA>ǰλ<C7B0>õIJ<C3B5><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
if ( (LD_info->qvvr[i].QVVR_type==0)||(LD_info->qvvr[i].QVVR_type==LD_info->qvvr[LD_info->qvvr_idx].QVVR_type) ) {
LD_info->qvvr[i].used_status = QVVR_DATA_PAIRED; //ƥ<><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LD_info->qvvr[i].QVVR_type = LD_info->qvvr[LD_info->qvvr_idx].QVVR_type;
LD_info->qvvr[i].QVVR_PerTime = LD_info->qvvr[LD_info->qvvr_idx].QVVR_PerTime;
LD_info->qvvr[i].QVVR_Amg = LD_info->qvvr[LD_info->qvvr_idx].QVVR_Amg; //<2F><>¼<EFBFBD><C2BC>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>ҵ<EFBFBD><D2B5>ĵ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ϣ<EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>͵<EFBFBD><CDB5>¼<EFBFBD>
LD_info->qvvr[LD_info->qvvr_idx].used_status = QVVR_DATA_NOT_USED; //<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ͷ<EFBFBD>
find_paired = TRUE;
break;
}
}
if (find_paired == FALSE) {
LD_info->qvvr[LD_info->qvvr_idx].used_status = QVVR_DATA_NOT_USED; //ȫ<><C8AB>û<EFBFBD><C3BB>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD><C2B4>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
printf("\nERROR:~~~~~~~~~~~~~ processQVVR qvvr returned to 0,but found no data to pair!, line_id=%d,QVVR_type=%d \n",
LD_info->line_id, LD_info->qvvr[LD_info->qvvr_idx].QVVR_type);
}
printf("\n~~~~~~~~~~~~~~~~~ processQVVR_end: line_id=%d \n",LD_info->line_id);
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>trig_tm<74><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD> QVVR <20><><EFBFBD>ݡ<EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// - LD_info<66><6F>ָ<EFBFBD><D6B8> LD_info_t <20><><EFBFBD>ͽṹ<CDBD><E1B9B9><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> QVVR <20><><EFBFBD>ݡ<EFBFBD>
// - trig_tm<74><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> QVVR <20><><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// - <20><><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD> QVVR <20><><EFBFBD>ݵ<EFBFBD>ָ<EFBFBD><EFBFBD><EBA1A3><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ҵ<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD> QVVR <20><><EFBFBD>ݣ<EFBFBD><DDA3>򷵻<EFBFBD> NULL<4C><4C>
// <20><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>
// - <20><><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> QVVR <20><><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ָ<EFBFBD>
// - <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> QVVR <20><><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD> NULL<4C><4C>
QVVR_t* find_qvvr_by_trig_tm(LD_info_t* LD_info, long long trig_tm)
{
long long diff; // <20><><EFBFBD>ڼ<EFBFBD><DABC><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int i; // ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD> LD_info <20>е<EFBFBD> QVVR <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for (i = 0; i < QVVR_NUM; i++) {
// <20><><EFBFBD>㵱ǰ QVVR <20><><EFBFBD>ݵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB4A5>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>
diff = abs(LD_info->qvvr[i].QVVR_time - trig_tm);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> QVVR <20><><EFBFBD>ݵ<EFBFBD>״̬<D7B4><CCAC> "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<22><>QVVR_DATA_PAIRED<45><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>С<EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD> 1<><31><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>
if ((LD_info->qvvr[i].used_status == QVVR_DATA_PAIRED) && (diff <= 1)) {
// <20><><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><E4A3AC><EFBFBD>ظ<EFBFBD> QVVR <20><><EFBFBD>ݵ<EFBFBD>ָ<EFBFBD><D6B8>
return &(LD_info->qvvr[i]);
}
}
// <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ҵ<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD> QVVR <20><><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD> NULL
return NULL;
}
#if 0
QVVR_t* find_qvvr_by_trig_tm(LD_info_t* LD_info,long long trig_tm)
{
long long diff;
int i;
for (i=0;i<QVVR_NUM;i++) {
diff = abs(LD_info->qvvr[i].QVVR_time-trig_tm);
if ( (LD_info->qvvr[i].used_status==QVVR_DATA_PAIRED) && (diff<=1) ) {
return &(LD_info->qvvr[i]);
}
}
return NULL;
}
#endif
////////////////////¼<><C2BC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>/////////////////////////////
void processRDRE_start(LD_info_t* LD_info)
{
LD_info->RDRE_FltNum = -1;
printf("\n~~~~~~RDRE~~~~~~ processRDRE_start: line_id=%d \n",LD_info->line_id);
}
void processRDRE_data(LD_info_t* LD_info,char* FULL_FCDA_Name,double v)
{
if ( strstr(FULL_FCDA_Name,"FltNum$stVal") )
LD_info->RDRE_FltNum = (int)(v+0.4);
printf("\n~~~~~~RDRE~~~~~~ processRDRE_data: line_id=%d ,mms_str=%s,v=%f \n",LD_info->line_id,FULL_FCDA_Name,v);
}
void processRDRE_end(LD_info_t* LD_info)
{
if (LD_info->RDRE_FltNum<=0)
return;
prepare_call_cn_wavelist(LD_info,LD_info->RDRE_FltNum);
printf("\n~~~~~~RDRE~~~~~~ processRDRE_end: line_id=%d \n",LD_info->line_id);
}
//////////////////////////////////////////////////////////////////////////

73
mms/reject.c Normal file
View File

@@ -0,0 +1,73 @@
/**
* @file: $RCSfile: reject.c,v $
* @brief: $IEC 61850 Protocol
*
* @version: $Revision: 1.1 $
* @date: $Date: 2018/11/24 06:54:51 $
* @author: $Author: lizhongming $
* @state: $State: Exp $
*
* @latest: $Id: reject.c,v 1.1 2018/11/24 06:54:51 lizhongming Exp $
*
*/
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 2005 - 2005, All Rights Reserved */
/* */
/* MODULE NAME : reject.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* Default reject indication function. This module may be linked */
/* to any application, or the function may be copied to a user */
/* module and modified as needed. */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* u_mvl_reject_ind */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 09/07/05 JRB 01 Created */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mvl_defs.h"
#include "mvl_acse.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* u_mvl_reject_ind */
/************************************************************************/
ST_VOID u_mvl_reject_ind (MVL_NET_INFO *net_info, REJECT_RESP_INFO *rej_info)
{
if (rej_info->rej_class == MMS_REJ_CLASS_CONFIRMED_REQUEST_PDU &&
rej_info->rej_code == MMS_REJ_CODE_CONFIRMED_REQUEST_PDU_UNRECOGNIZED_SERVICE)
{ /* This is most common case. Provide extra information in log msgs.*/
if (rej_info->detected_here)
MVL_LOG_ERR0 ("MMS Reject sent, unrecognized service. Check MMS services enabled here.");
else
MVL_LOG_ERR0 ("MMS Reject received, unrecognized service. Check MMS services enabled on remote device.");
}
else
{
/* NOTE: for all other cases, it is best to abort the connection */
/* but it is not done in this callback function because no good */
/* way to inform main application that abort occurred. */
/* DEBUG: should there be extra handshaking in MVL_NET_INFO struct? */
if (rej_info->detected_here)
MVL_LOG_ERR0 ("Reject sent.");
else
MVL_LOG_ERR0 ("Reject received.");
}
}

28
mms/rpt.odf Normal file
View File

@@ -0,0 +1,28 @@
#############################################################
#Copyright 1998-2003, Systems Integration Specialists Company, Inc.
# All Rights Reserved
#############################################################
# 12/17/03 JRB For 61850-8-1 FDIS, chg RTYP_BVSTR9 to RTYP_BVSTR10,
# add RTYP_BSTR9 for client.
# 10/09/03 JRB Add RTYP_INT32U for IntgPd.
# 03/13/03 JRB Overhaul. Use RTYP_ prefix for all RPT related types.
#NOTE: These types are used directly in reporting code, and also in
# other ODF files to define Report Control Blocks (RCBs).
# It is CRITICAL that the same type is used in both places.
":TKU", "RTYP_BOOL", "<BOOL>", "UCAreporttypes"
":TKU", "RTYP_BTIME6", "<BTIME6>", "UCAreporttypes"
":TKU", "RTYP_BSTR6", "Bstring6", "UCAreporttypes"
":TKU", "RTYP_BSTR8", "Bstring8", "UCAreporttypes"
":TKU", "RTYP_BSTR9", "Bstring9", "Client needs for writing OptFlds"
":TKU", "RTYP_BVSTR6", "Bvstring6", "UCAreporttypes"
":TKU", "RTYP_BVSTR8", "Bvstring8", "UCAreporttypes"
":TKU", "RTYP_BVSTR10", "Bvstring10", "UCAreporttypes"
":TKU", "RTYP_INT8U", "<INT8U>", "UCAreporttypes"
":TKU", "RTYP_INT16U", "<INT16U>", "UCAreporttypes"
":TKU", "RTYP_OSTR8", "Ostring8", "UCAreporttypes"
":TKU", "RTYP_VSTR32", "<VSTR32>", "UCAreporttypes"
":TKU", "RTYP_VSTR65", "<VSTR65>", "UCAreporttypes"
#NOTE: Client needs this for IntgPd.
":TKU", "RTYP_INT32U", "<INT32U>", "UCAreporttypes"

40
mms/ver_conf.h Normal file
View File

@@ -0,0 +1,40 @@
#ifndef VER_CONF_H_KHCYDOPFRUYDIYFIHUIVUGUGG
#define VER_CONF_H_KHCYDOPFRUYDIYFIHUIVUGUGG
#include "stdio.h"
const char* PROGRAM_VERSION = "1.0.2.7";
const char* PROGRAM_CREATE_TIME="2024-09-18";
int getVersion(int argc,const char ** argv);
int getVersion(int argc,const char ** argv)
{
const char *str;
if (argc > 1) {
str = argv[1];
if (strcmp(str,"--version")== 0 ) {
printf ("Version: pt61850netd_pqfe_%s_%s \n", PROGRAM_VERSION, PROGRAM_CREATE_TIME);
printf (" Memo: changed after the epri integerated test!\n");
printf (" changed after the epri data detail verified!\n");
printf (" add the special communication log!\n");
printf (" optimize the 3s file process with webservice,avoid conflict!\n");
printf (" support the dev_flag configured by ini file\n");
printf (" add json create log when jump out, and detail log when first 10k datas\n");
printf (" support qvvr send 2 topics when recv report\n");
printf (" not write the period secs when register report\n");
printf (" only create LF when 2 hours\n");
printf (" add watchdog to working thread\n");
printf (" support one ip ,multi port when connect to ied\n");
printf(" 2024-02-26 add recall\n");
printf(" 2024-03-08 add recall\n");
printf(" 2024-03-26 remove Rregister rpt\n");
printf(" 2024-04-04 Compatible recall time\n");
printf(" 2024-09-18 monitor report clear cache\n");
exit(0);
}
}
return 0;
};
#endif //VER_CONF_H_KHCYDOPFRUYDIYFIHUIVUGUGG

14
mms/version.txt Normal file
View File

@@ -0,0 +1,14 @@
4.0.cn.180529 [OS_VERSION]
<EFBFBD>޸<EFBFBD>ʱ<EFBFBD><EFBFBD>: 2018.05.29
<EFBFBD><EFBFBD>䶯˵<EFBFBD><EFBFBD>:
1.<2E><><EFBFBD>ӱ<EFBFBD><D3B1><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD><DABF>Զ<EFBFBD><D4B6><EFBFBD>תѡ<D7AA><D1A1>ע<EFBFBD><EFBFBD><E1A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD>е<EFBFBD>61850<35><30><EFBFBD>õĹ<C3B5>Լ˽<D4BC><CBBD><EFBFBD><EFBFBD><EFBFBD>õġ<C3B5>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>׺<EFBFBD><D7BA>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD>ķ<EFBFBD>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><><CAB5><EFBFBD><EFBFBD>1],[ʵ<><CAB5><EFBFBD><EFBFBD>2] , <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 5<><35>12 <20><>ʾ<EFBFBD><CABE><EFBFBD>õı<C3B5><C4B1><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 05,06,07,08,09,10,11,12
2. ִ<><D6B4>UPDATEOVERLIMIT<49><54>QVVR<56>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>oracle otl<74><6C><EFBFBD><EFBFBD><EFBFBD>쳣ʱ<ECB3A3><CAB1>ֻ<EFBFBD><D6BB>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>
3. PQ_Device<63><65><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>IP1<50><31>IP2<50><32>IP3<50><33>IP4<50>ĸ<EFBFBD><C4B8>ֶκϲ<CEBA><CFB2><EFBFBD>һ<EFBFBD><D2BB>IP<49>ֶΣ<D6B6><CEA3><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
4. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>QualityFlag<61><67><EFBFBD><EFBFBD>ֵ<EFBFBD>ɱ<EFBFBD><C9B1>е<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>Q<EFBFBD><51>Ʒ<EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD>룬ֻд<D6BB><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>00-<2D><>Ʒ<EFBFBD><C6B7> 01-<2D><>Ʒ<EFBFBD><C6B7>
5.<2E>޸<EFBFBD>ʹ<EFBFBD>ø<EFBFBD><C3B8><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>
6.UPDATEEVENTCOUNT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>EventReason<6F><6E>EventType<70><65>MyGUID<49><44><EFBFBD><EFBFBD>UUID<49><44><EFBFBD><EFBFBD>
7.֧<><D6A7><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ݹ<EFBFBD><DDB9>Ϻţ<CFBA><C5A3>ٻ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ftp<74><70><EFBFBD><EFBFBD> <20><>
8. <20><><EFBFBD>ܿ<EFBFBD><DCBF><EFBFBD><EFBFBD>Ż<EFBFBD>дʵʱ<CAB5><CAB1>