?? sclproc.c
字號:
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 2004-2005 All Rights Reserved */
/* */
/* MODULE NAME : sclproc.c */
/* PRODUCT(S) : MMS-EASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* Functions to "post-proccess" information parsed from SCL file. */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* scl2_datatype_create_all */
/* scl2_ld_create_all */
/* */
/* NOTE: FC must be "ST" "MX" "CO" "SP" "SG" "SE" "SV" "CF" "DC" or "EX"*/
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 03/28/07 韓明峰 26 BRCB創(chuàng)建時開始記錄報告 */
/* 01/17/07 韓明峰 25 修改scl2_lcb_create()中日志和掃描控制塊的創(chuàng)建 */
/* 02/27/06 WLH 24 add scl2_svcb_create_all and scl2_svcb_create
tdladd_ms_or_us */
/* 02/23/06 WLH 23 delete initial vals for LCB, GCB, SCB */
/* 02/23/06 WLH 22 add scl2_gcb_create_all and scl2_gcb_create
tdladd_gcb */
/* 02/21/06 WLH 21 add scl2_sgcb_create_all and scl2_sgcb_create
tdladd_sp */
/* 02/21/06 WLH 20 scl2_ld_create_all: change report_scanrate arg to startup_cfg
in order to contain more infomation*/
/* 07/27/05 JRB 19 Don't set OptFlds len=9 (default=10 is good).*/
/* Don't set OptFlds bits bufovfl, entryID for URCB.*/
/* 07/25/05 JRB 18 scl2_ld_create_all: Add brcb_bufsize arg. */
/* 07/21/05 JRB 17 Set initial vals for LCB, GCB, SCB. */
/* 07/11/05 JRB 16 scl2_ld_create_all: Call */
/* mvl61850_ctl_lastapplerror_create. */
/* 06/27/05 JRB 15 Use mvl_nvl_add (mvlu_rpt_nvl_add is obsolete).*/
/* 05/27/05 JRB 14 Construct NVL name from LN & DataSet name */
/* as 61850-8-1 requires. */
/* 05/25/05 JRB 13 Del all code to generate RCB name & just use */
/* name configured in SCL file (scl_rcb->name). */
/* Add errflag so if one call to tdladd_string */
/* fails, subsequent calls fail too. */
/* 05/09/05 JRB 12 Chg leaf write functions for SqNum (in BRCB */
/* & URCB) to u_no_write_allowed. */
/* 04/05/05 MDE 11 Supress invalid log messages */
/* 03/18/05 JRB 10 Use mvl_max_dyn when creating domains. */
/* 02/15/05 JRB 09 Use new generated scl_ld->domName, not */
/* scl_ld->inst as domain name. */
/* Use new generated scl_fcda->domName, not */
/* scl_fcda->ldInst as domain name. */
/* Use new scl_ln->varName, generated once, */
/* instead of generating ln_name repeatedly. */
/* Compute max_num_var for mvl_dom_add call. */
/* 01/19/05 JRB 08 Add scl2_dai_set_value_all & use it to init */
/* data from DOI/SDI/DAI entries in SCL file. */
/* Fix len on all strncat calls. */
/* scl2_rcb_create_all: init ln_name just once. */
/* Improve some logging. */
/* 09/01/04 JRB 07 Map Octet64 to OVstring64 (to match 61850-8-1)*/
/* 08/29/04 JRB 06 Chg Quality type back to BVstring13 because */
/* final IEC-61850-8-1 changed back. */
/* 08/19/04 JRB 05 Init return value in scl2_ld_create_all. */
/* 07/19/04 JRB 04 Add tdladd_lg, tdladd_go_or_gs. */
/* 07/14/04 JRB 03 Chg Quality type to BVstring14. */
/* 07/09/04 JRB 02 scl2_ld_create_all: add reportScanRate arg */
/* to this and lower level functions. */
/* 07/02/04 JRB 01 Initial Revision. */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "scl.h"
#include "sx_log.h"
#include "mvl_defs.h"
#include "mvl_uca.h"
#include "mvl_log.h"
#include "str_util.h" /* for strn..._safe protos */
#include "sx_arb.h" /* for sxaText.... proto */
#include "sx_arb.h" /* for sxaText.... proto */
#include "logcon.h"
#include "msvcb.h"
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
typedef struct
{
ST_CHAR *tdlptr; /* ptr to current pos in TDL buffer */
ST_INT len_avail; /* num bytes left in TDL buffer */
ST_BOOLEAN errflag; /* Set when first error detected */
/* CALLER MUST init "errflag=SD_FALSE" */
} TDLADD_CTXT;
/* CRITICAL: this struct must be compatible with TDL "lcb_tdl". */
/* If either one changes, the other must change to match. */
typedef struct
{
ST_UINT8 LogEna; /* Bool */
ST_CHAR LogRef[66]; /* Vstring65 */
ST_CHAR DatSet[66]; /* Vstring65 */
MMS_BTIME6 OldEntrTim; /* Btime6 */
MMS_BTIME6 NewEntrTim; /* Btime6 */
ST_UINT8 OldEntr[8]; /* Ostring8 */
ST_UINT8 NewEntr[8]; /* Ostring8 */
MMS_BSTRING TrgOps; /* BVstring6 - struct includes 1 byte data. Enough.*/
ST_UINT32 IntgPd; /* Ulong */
} MVL61860_LCB_DATA; /* struct to store data for LCB (IEC Log Control Block) */
/* CRITICAL: this struct must be compatible with TDL "gcb_tdl". */
/* If either one changes, the other must change to match. */
typedef struct
{
ST_BOOLEAN GoEna;
ST_CHAR GoID[66];
ST_CHAR DatSet[66];
ST_UINT32 ConfRev;
ST_BOOLEAN NdsCom;
struct
{
ST_UCHAR Addr[6];
ST_UINT8 PRIORITY;
ST_UINT16 VID;
ST_UINT16 APPID;
} DstAddress;
} MVL61850_GCB_DATA; /* struct to store data for GCB (GOOSE Control Block) */
/* CRITICAL: this struct must be compatible with TDL "scb_tdl". */
/* If either one changes, the other must change to match. */
typedef struct
{
ST_BOOLEAN GsEna;
ST_CHAR GsID[66];
ST_CHAR DNALabels[32][66];
ST_CHAR UserSTLabels[128][66];
struct
{
ST_CHAR GsID[66];
MMS_BTIME6 t;
ST_UINT32 SqNum;
ST_UINT32 StNum;
ST_UINT32 TAL;
ST_UINT32 usec;
ST_UINT16 PhsID;
ST_UCHAR DNA[8];
ST_UCHAR UserST[32];
} LSentData;
} MVL61850_SCB_DATA; /* struct to store data for SCB (GSSE Control Block) */
/************************************************************************/
/* Fixed TDL for defining IEC Unbuffered Report Control Block (urcb) */
/************************************************************************/
ST_CHAR *urcb_tdl = "{\
(RptID)Vstring65,\
(RptEna)Bool,\
(Resv)Bool,\
(DatSet)Vstring65,\
(ConfRev)Ulong,\
(OptFlds)BVstring10,\
(BufTim)Ulong,\
(SqNum)Ubyte,\
(TrgOps)BString6,\
(IntgPd)Ulong,\
(GI)Bool\
},\n"; /* TDL for IEC Unbuffered Report Control Block */
/************************************************************************/
/* Fixed TDL for defining IEC Unbuffered Report Control Block (urcb) */
/************************************************************************/
ST_CHAR *brcb_tdl = "{\
(RptID)Vstring65,\
(RptEna)Bool,\
(DatSet)Vstring65,\
(ConfRev)Ulong,\
(OptFlds)BVstring10,\
(BufTim)Ulong,\
(SqNum)Ushort,\
(TrgOps)BString6,\
(IntgPd)Ulong,\
(GI)Bool,\
(PurgeBuf)Bool,\
(EntryID)Ostring8,\
(TimeofEntry)Btime6\
},\n"; /* TDL for IEC Buffered Report Control Block */
/************************************************************************/
/* STATIC FUNCTION PROTOTYPES */
/* Need prototypes for these static functions because tdladd_da_struct */
/* calls tdladd_da_or_bda and vice versa. */
/* Other static functions are just defined in the order they are needed */
/* so prototypes are not needed. */
/************************************************************************/
static ST_RET tdladd_da_struct (
TDLADD_CTXT *tdl_ctxt,
SCL_INFO *scl_info,
ST_CHAR *type_id);
static ST_RET tdladd_da_or_bda (
TDLADD_CTXT *tdl_ctxt,
SCL_INFO *scl_info,
ST_CHAR *name, /* DA or BDA name */
ST_CHAR *bType, /* DA or BDA bType */
ST_CHAR *type, /* DA or BDA type */
ST_UINT count); /* DA or BDA count */
/************************************************************************/
/* unique_type_name */
/* Create unique type name for a LN. */
/* NOTE: do not use '$'. This will confuse "mvlu_set_leaf_param". */
/************************************************************************/
ST_VOID unique_type_name (SCL_LD *scl_ld, SCL_LN *scl_ln,
ST_CHAR *type_name, ST_INT type_name_size)
{ /* Create unique type name for this LN. */
strncpy_safe (type_name, scl_ld->inst, type_name_size-1); /* domain name */
strncat_safe (type_name, scl_ln->prefix, type_name_size-1-strlen(type_name));
strncat_safe (type_name, scl_ln->lnClass, type_name_size-1-strlen(type_name));
strncat_safe (type_name, scl_ln->inst, type_name_size-1-strlen(type_name));
}
/************************************************************************/
/* scl_find_dotype */
/************************************************************************/
static SCL_DOTYPE *scl_find_dotype (
SCL_INFO *scl_info, /* main struct where all SCL info stored*/
ST_CHAR *type_id)
{
SCL_DOTYPE *scl_dotype;
for (scl_dotype = (SCL_DOTYPE *) list_find_last ((DBL_LNK *) scl_info->doTypeHead);
scl_dotype != NULL;
scl_dotype = (SCL_DOTYPE *) list_find_prev ((DBL_LNK *) scl_info->doTypeHead, (DBL_LNK *) scl_dotype))
{
if (strcmp (scl_dotype->id, type_id) ==0)
return (scl_dotype);
}
return (NULL); /* match not found */
}
/************************************************************************/
/* scl_find_datype */
/************************************************************************/
static SCL_DATYPE *scl_find_datype (
SCL_INFO *scl_info, /* main struct where all SCL info stored*/
ST_CHAR *type_id)
{
SCL_DATYPE *scl_datype;
for (scl_datype = (SCL_DATYPE *) list_find_last ((DBL_LNK *) scl_info->daTypeHead);
scl_datype != NULL;
scl_datype = (SCL_DATYPE *) list_find_prev ((DBL_LNK *) scl_info->daTypeHead, (DBL_LNK *) scl_datype))
{
if (strcmp (scl_datype->id, type_id) ==0)
return (scl_datype);
}
return (NULL); /* match not found */
}
/************************************************************************/
/************************************************************************/
static SCL_DATASET *scl_find_dataset (
SCL_LN *scl_ln,
ST_CHAR *dataset_name)
{
SCL_DATASET *scl_dataset;
for (scl_dataset = (SCL_DATASET *) list_find_last ((DBL_LNK *) scl_ln->datasetHead);
scl_dataset != NULL;
scl_dataset = (SCL_DATASET *) list_find_prev ((DBL_LNK *) scl_ln->datasetHead, (DBL_LNK *) scl_dataset))
{
if (strcmp (scl_dataset->name, dataset_name) ==0)
return (scl_dataset);
}
return (NULL); /* match not found */
}
/************************************************************************/
/* btype_to_raw_tdl */
/************************************************************************/
static ST_CHAR *btype_to_raw_tdl (ST_CHAR *btype)
{
if (strcmp (btype, "BOOLEAN") == 0)
return ("Bool");
if (strcmp (btype, "INT8") == 0)
return ("Byte");
if (strcmp (btype, "INT16") == 0)
return ("Short");
if (strcmp (btype, "INT32") == 0)
return ("Long");
if (strcmp (btype, "INT8U") == 0)
return ("Ubyte");
if (strcmp (btype, "INT16U") == 0)
return ("Ushort");
if (strcmp (btype, "INT32U") == 0)
return ("Ulong");
if (strcmp (btype, "FLOAT32") == 0)
return ("Float");
if (strcmp (btype, "FLOAT64") == 0)
return ("Double");
if (strcmp (btype, "Dbpos") == 0)
return ("Bstring2");
if (strcmp (btype, "Tcmd") == 0)
return ("Bstring2");
if (strcmp (btype, "Quality") == 0)
return ("BVstring13");
if (strcmp (btype, "Timestamp") == 0)
return ("Utctime");
if (strcmp (btype, "VisString32") == 0)
return ("Vstring32");
if (strcmp (btype, "VisString64") == 0)
return ("Vstring64");
if (strcmp (btype, "VisString255") == 0)
return ("Vstring255");
if (strcmp (btype, "Octet64") == 0)
return ("OVstring64"); /* 61850-8-1 says all octet strings are variable length*/
if (strcmp (btype, "EntryTime") == 0)
return ("Btime6");
if (strcmp (btype, "Unicode255") == 0)
return ("UTF8Vstring255");
return (NULL); /* ERROR: Btype not recognized */
}
/************************************************************************/
/* tdladd_string */
/* NOTE: When an error is detected, errflag is set in TDLADD_CTXT. */
/* Then all subsequent calls will fail for this TDLADD_CTXT. */
/************************************************************************/
static ST_RET tdladd_string (
TDLADD_CTXT *tdl_ctxt,
ST_CHAR *text_to_add)
{
ST_INT len_added;
/* If error already detected, just return without logging. */
if (tdl_ctxt->errflag)
return (SD_FAILURE);
/* Remove "," before end of array. Is there a better way? */
if (*text_to_add == ']' && *(tdl_ctxt->tdlptr-1) == ',')
{
tdl_ctxt->tdlptr -= 1;
tdl_ctxt->len_avail += 1;
}
len_added = strlen (text_to_add);
if (len_added > tdl_ctxt->len_avail)
{
SXLOG_ERR1 ("Not enough room in TDL buffer to add string='%s'", text_to_add);
tdl_ctxt->errflag = SD_TRUE;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -