⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 icta_var.c

📁 ICCP Toolkit 是在 Tru64下开发Tase.2通信协议的开发包
💻 C
📖 第 1 页 / 共 5 页
字号:
/************************************************************************//* SISCO SOFTWARE MODULE HEADER *****************************************//************************************************************************//*   (c) Copyright Systems Integration Specialists Company, Inc.,       *//*          1996-2002, All Rights Reserved                              *//*                                                                      *//* MODULE NAME : ICTA_VAR.C                                            	*//*                                                                      *//* MODULE DESCRIPTION :                                                 *//*   handle type and variable functions					*//*                                                                      *//* GLOBAL FUNCTIONS DEFINED IN THIS MODULE :				*//*				ST_VOID defCfgTypes (ST_VOID);		*//*				ST_VOID defCfgVars (ST_VOID);		*//*				ST_VOID defNewType (ST_VOID);		*//*				ST_VOID defNewVar (ST_VOID);		*//*				ST_VOID readVarTypes (ST_VOID);		*//*				ST_VOID readVarnames (ST_VOID);		*//*				ST_VOID readVar (ST_VOID);		*//*				ST_VOID writeVar (ST_VOID);		*//*				ST_VOID readLocal (ST_VOID);		*//*				ST_VOID writeLocal (ST_VOID);		*//*				ST_VOID changeVar (ST_VOID);		*//*				ST_VOID incrementVar(ICTA_VAR_INFO )	*//*									*//*                                                                      *//* MODIFICATION LOG :                                                   *//*  Date     Who   Rev                     Comments                     *//* --------  ---  ------   -------------------------------------------  *//* 02/08/02  EJV    20     Added entry for Utc Time in displayArbTbl	*//*			   displayArbGtime: changed pDest arg to time_t *//*			   Added in ctime((time_t *)...) typecating	*//* 06/27/01  EJV    19     defNewType,readNamesCallBack:corrected printf*//* 11/28/00  nav    18     Add incomingDsTs callback function		*//* 06/30/00  nav    17     Increment state and flags separately		*//* 03/13/00  nav    16     Add bRunVerbose global			*//* 02/09/00  nav    15     Log data as Data not Flow			*//* 01/17/00  nav    14     Clean up bad pointer in displayArbBs		*//* 06/29/99  nav    13     QUALITY_TEST					*//* 06/03/99  nav    12     Add bIncrementVars global			*//*				and enhanced slogging for PLC test	*//* 12/03/98  NAV    11     Y2K testing					*//* 08/18/98  NAV    10     Watch for valid LinkName and VarName		*//* 05/19/98  NAV     9     Support icWriteVariableEx with extraPtr	*//* 05/08/98  NAV     8     Use ms_process_arb_data to print_arb_data	*//* 01/21/98  EJV     7     Cleaned up warnings				*//* 01/19/98  EJV     6     Added typecast in list functions.		*//*			   Cleanup commented out code.			*//* 01/16/98  EJV     5     Unix compiler don't like '//' for comment	*//* 06/20/97  nav     4     Overhaul - One process can be client& server	*//* 06/05/97  nav     3     Convert to MMS-EASE V7.00			*//* 02/26/97  NAV     2     add incrementVar(....)			*//* 02/11/97  NAV     1     add readLocal() and writeLocal()		*//* 12/26/96  NAV           creation		                        *//************************************************************************/#include "ictamain.h"#include "scrndefs.h"#include "gvaldefs.h"#include "fkeydefs.h"#include "mms_user.h"/************************************************************************//* Global and Local variables						*//************************************************************************//*#define TEST_Y2K */static char *thisFileName = __FILE__;static icBoolean bTimedRead;/* if bRunVerbose is true, showVarValue on read/write callback		*/icBoolean bRunVerbose = icFalse;/* some defines for determining indication point values of flags	*/#define IP_VALIDITY_VALID 	0#define IP_VALIDITY_HELD	1#define IP_VALIDITY_SUSPECT	2#define IP_VALIDITY_NOTVALID	3#define IP_CURR_SRC_TELEMETERED	0#define IP_CURR_SRC_CALCULATED	1#define IP_CURR_SRC_ENTERED	2#define IP_CURR_SRC_ESTIMATED	3#define IP_NORMAL_VAL_NORMAL	0#define IP_NORMAL_VAL_ABNORMAL	1/************************************************************************//*      Static Function Declarations                           		*//************************************************************************/static ST_RET doNewClientVars(ICTA_REMOTE_INFO *pstRemote,			       ICTA_VAR_INFO    *pstVar);static ST_RET doNewServerVars(ICTA_REMOTE_INFO *pstRemote,			       ICTA_VAR_INFO    *pstVar);static ST_VOID updateData(ICTA_VAR_INFO *pstVar, char *newData, 			  ST_UCHAR *flagData);static void showVarValue(ICTA_VAR_INFO *pstVar);static void showValueOnly(ICTA_VAR_INFO *pstVar);static void showExtraVarValue(ICTA_VAR_INFO *pstVar);static void showStateFlags(icTypeState stateFlags);#ifdef QUALITY_TESTstatic void updateQualityStats (ICTA_VAR_INFO *pstVar);static void stashQualityFlags (ICTA_VAR_INFO *pstVar, ST_UCHAR flags);#endifstatic void incState (icTypeState *state);static void incStateFlags(icTypeState *stateFlags);static ST_VOID print_arb_data (ST_CHAR *src, NAMED_TYPE *type); static ST_RET displayArbBool (ST_BOOLEAN *pSrc, RT_AA_CTRL *rtaa);static ST_RET displayArbInt8 (ST_INT8 *pSrc, RT_AA_CTRL *rtaa);static ST_RET displayArbInt16 (ST_INT16 *pSrc, RT_AA_CTRL *rtaa);static ST_RET displayArbInt32 (ST_INT32 *pSrc, RT_AA_CTRL *rtaa);static ST_RET displayArbInt64 (ST_INT64 *pSrc, RT_AA_CTRL *rtaa);static ST_RET displayArbUint8 (ST_UINT8 *pSrc, RT_AA_CTRL *rtaa);static ST_RET displayArbUint16 (ST_UINT16 *pSrc, RT_AA_CTRL *rtaa);static ST_RET displayArbUint32 (ST_UINT32 *pSrc, RT_AA_CTRL *rtaa);static ST_RET displayArbUint64 (ST_UINT64 *pSrc, RT_AA_CTRL *rtaa);static ST_RET displayArbBcd1 (ST_INT8 *pSrc, RT_AA_CTRL *rtaa);static ST_RET displayArbBcd2 (ST_INT16 *pSrc, RT_AA_CTRL *rtaa);static ST_RET displayArbBcd4 (ST_INT32 *pSrc, RT_AA_CTRL *rtaa);static ST_RET displayArbFlt (ST_FLOAT *pSrc, RT_AA_CTRL *rtaa);static ST_RET displayArbDbl (ST_DOUBLE *pSrc, RT_AA_CTRL *rtaa);static ST_RET displayArbStr (ST_CHAR *pSrc, RT_AA_CTRL *rtaa);static ST_RET displayArbOct (ST_UCHAR *pDest, RT_AA_CTRL *rtaa);static ST_RET displayArbBs  (ST_UCHAR *pDest, RT_AA_CTRL *rtaa);static ST_RET displayArbBtime4 (ST_INT32 *pDest, RT_AA_CTRL *rtaa);static ST_RET displayArbBtime6 (ST_INT32 *pDest, RT_AA_CTRL *rtaa);static ST_RET displayArbGtime (time_t *pDest, RT_AA_CTRL *rtaa);static ST_VOID changeABunch (ICTA_REMOTE_INFO *pstRemote, ST_INT numToChange);static M_ARB_DATA_CTRL displayArbTbl =  {  NULL,				/* arrStart 	*/  NULL,				/* arrEnd    	*/  NULL,				/* strStart  	*/  NULL,				/* strEnd    	*/  displayArbInt8,  		/* int8      	*/  displayArbInt16,		/* int16     	*/  displayArbInt32, 		/* int32     	*/  displayArbInt64,		/* int64	*/  displayArbUint8, 		/* uint8     	*/  displayArbUint16,		/* uint16    	*/  displayArbUint32,		/* uint32    	*/  displayArbUint64,		/* uint64	*/  displayArbFlt,   		/* flt       	*/  displayArbDbl,   		/* dbl       	*/  displayArbOct,		/* oct       	*/  displayArbBool,		/* bool      	*/  displayArbBcd1, 	    	/* bcd1      	*/  displayArbBcd2, 	    	/* bcd2      	*/  displayArbBcd4, 	    	/* bcd4      	*/  displayArbBs,			/* bs	       	*/  displayArbStr,		/* visible str	*/  displayArbBtime4,		/* Bin Time    	*/  displayArbBtime6,		/* Bin Time    	*/  displayArbGtime,		/* Gen Time    	*/  NULL				/* UTC Time	*/  };				/************************************************************************//* defCfgTypes:  define configured types				*//************************************************************************/ST_VOID defCfgTypes (ST_VOID)  {  printf("\n\nDefine Configured Types . . .\n");  if (doDefTypes() != SD_SUCCESS)    printf("\n  Problems defining types - see log file for details.\n");  pause_msg("\nPress a key to continue!");  showCurrMenu();  }/************************************************************************//* defCfgVars:  define configured variables				*//************************************************************************/ST_VOID defCfgVars (ST_VOID)  {int todo;  printf("\n\nDefine Configured Variables . . .\n");  todo = findOutWho();  switch (todo)    {    case ICTA_CLIENT:      if (doDefClientVars () == SD_SUCCESS)        printf ("Client Variables Defined.\n");      else	printf ("Define Client Variables Failed - See Log File.\n");    break;    case ICTA_SERVER:      if (doDefServerVars () == SD_SUCCESS)        printf ("Server Variables Defined.\n");      else        printf ("Define Server Variables Failed - See Log File.\n");    break;    case ICTA_BOTH:      if (doDefServerVars () == SD_SUCCESS)        printf ("Server Variables Defined.\n");      else        printf ("Define Server Variables Failed - See Log File.\n");      if (doDefClientVars () == SD_SUCCESS)        printf ("Client Variables Defined.\n");      else	printf ("Define Client Variables Failed - See Log File.\n");    break;    default:      printf ("NO VARIABLES defined.\n");    break;    }  pause_msg("\nPress a key to continue!");  showCurrMenu();  }/************************************************************************//* defNewType:  define a new type - data from keyboard			*//************************************************************************/ST_VOID defNewType (ST_VOID)  {ICTA_TYPE *pstType;ST_CHAR typeName[MAX_ID_LEN];ST_CHAR tdl[500];ST_BOOLEAN dataEntered;icInt status;  printf("\n\nDefine A New Type . . .\n");  printf("\nEnter Type Name:  ");  if (dataEntered = strget(typeName))    {    if (findUserType (typeName))      printf("Type Name '%s' already exists!!!!\n", typeName);    else      {      printf("Enter TDL:  ");      if (dataEntered = strget(tdl))        {	pstType = chk_calloc(1, sizeof(ICTA_TYPE));	strcpy(pstType->typeName, typeName);	pstType->tdl = chk_calloc(1, strlen(tdl));	strcpy(pstType->tdl, tdl);        status = icDefineType(pstType->typeName, pstType->tdl, &pstType->typeId);	if (status)	  {	  printf ("Define Type Failed - see log for details.\n");	  ICA_Log_Err3("ERROR:  Define Type '%s' failed, status =%d '%s'",	                typeName, status, icPerror(status));	  chk_free(pstType->tdl);	  chk_free(pstType);          }	else	  list_add_last ((ST_VOID **)&pstVCC->typeList, pstType);	}      }    }  pause_msg("\nPress a key to continue!");  showCurrMenu();  }/************************************************************************//* defNewVar:  define a new variable - data from keyboard		*//************************************************************************/ST_VOID defNewVar (ST_VOID)  {ICTA_VAR_INFO *pstVar, *pstTempVar, *pstClientVars, *pstServerVars;ICTA_TYPE *pstType;ICTA_REMOTE_INFO *pstRemote;ST_BOOLEAN dataEntered;ST_CHAR buffer[100];int todo, stdType;ST_RET rtned;  printf("\n\nDefine a New Variables . . .\n");  pstVar = chk_calloc(1, sizeof(ICTA_VAR_INFO));  todo = findOutWho();  if (todo == ICTA_NOONE)    {    chk_free(pstVar);    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }  printf("\nEnter Remote Name:  ");    dataEntered = strget(buffer);  if (!dataEntered)    {    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }  pstRemote = findRemote(todo, buffer);  if (!pstRemote)    {    printf("\nInvalid Remote Name!!!!!\n\n");    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }  printf("\nEnter Variable Name:  ");  dataEntered = strget(pstVar->varName);  if (!dataEntered)    {    chk_free(pstVar);    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }  printf("\nEnter V=VMD Scope or D=Domain Scope:  ");  dataEntered = strget(buffer);  if (!dataEntered || ( (buffer[0]!='V') && (buffer[0]!='D') ) )    {    chk_free(pstVar);    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }  if (buffer[0] == 'D')    pstVar->varScope = IC_SCOPE_DOMAIN;  else    pstVar->varScope = IC_SCOPE_VMD;  printf("\nEnter Type Name:  ");  dataEntered = strget(buffer);  if (!dataEntered)    {    chk_free(pstVar);    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }  else    {    stdType = findStdType(buffer);    if (stdType >= 0)      {      pstVar->iccpType = stdType;      pstVar->bUserType = icFalse;      pstVar->pstType = NULL;      }    else      {      pstType = findUserType(buffer);      if (pstType)        {	pstVar->iccpType = IC_TYPE_USER_DEFINED;	pstVar->bUserType = icTrue;	pstVar->pstType = pstType;	}      else        {	printf("Type %s Not Found\n", buffer);	chk_free(pstVar);        pause_msg("\nPress a key to continue!");        showCurrMenu();	return;	}      }    }  printf("\nIs this Variable Writable?  ");  dataEntered = strget(buffer);  if (!dataEntered || ( (buffer[0] != 'Y') && (buffer[0] != 'N') ) )    {    chk_free(pstVar);    pause_msg("\nPress a key to continue!");    showCurrMenu();    return;    }  if (buffer[0] == 'Y')    pstVar->bWriteable = icTrue;  else    pstVar->bWriteable = icFalse;  pstVar->varPtr = NULL;  pstClientVars = pstRemote->clientObj->variableList;  pstServerVars = pstRemote->serverObj->variableList;  switch (todo)    {    case ICTA_CLIENT:      rtned = doNewClientVars(pstRemote, pstVar);      if (rtned == SD_SUCCESS)        list_add_last ((ST_VOID **)&pstClientVars, pstVar);      break;    case ICTA_SERVER:      rtned = doNewServerVars(pstRemote, pstVar);      if (rtned == SD_SUCCESS)        list_add_last ((ST_VOID **)&pstServerVars, pstVar);      break;    case ICTA_BOTH:      rtned = doNewServerVars(pstRemote, pstVar);      if (rtned == SD_SUCCESS)        {	list_add_last ((ST_VOID **)&pstServerVars, pstVar);	pstTempVar = pstVar;	pstVar = chk_calloc(1, sizeof(ICTA_VAR_INFO));	memcpy(pstVar, pstTempVar, sizeof(ICTA_VAR_INFO));	}      rtned = doNewClientVars(pstRemote, pstVar);      if (rtned == SD_SUCCESS)        list_add_last ((ST_VOID **)&pstClientVars, pstVar);      break;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -