basedefine.h

来自「电力系统中的保护装置全部代码」· C头文件 代码 · 共 346 行

H
346
字号
#include   "nucleus.h"

#ifndef BASEDEFINE
#define BASEDEFINE

#define    CHL_Number  	     16 	      //模拟量通道数  
#define    DI_Number         32        //开入路数
#define    DO_Number         14        //开入路数
#define    Sample_Point      24 	      //每周波采样点数
#define    AD_OneDataSize    0x100            //每个模拟量通道采样区长度
#define    PULSENUM          4                //脉冲路数

#define    REPORTRAM         100          //报告暂存区总数
#define    SETTINGNUM        8            //定值区数

#define	ALIAS_NAME	5
#define	DIMENSION	5
#define	EEP_REPORTNUM	64
#define VALUE_NAME	20			// value name length
#define SOE_NAME	20			// soe name length

typedef struct EEP_VALUE_STRUCT
{ 
	CHAR	value_name[VALUE_NAME];  			// value name         			
	CHAR	value_alias[ALIAS_NAME];						// value alias 
	UNSIGNED	value_index_number;					// value index number  	
	INT	value_calculate_style;				// value calculate style 			
	CHAR	value_dimension[DIMENSION];					// pointer to value dimension 			
	UNSIGNED	value_calculate_coefficient1;		// value calculate coefficient  	
	UNSIGNED	value_calculate_coefficient2;		// value calculate coefficient  	
	UNSIGNED	value_calculate_coefficient3;		// value calculate coefficient  	
	UNSIGNED	value_calculate_coefficient4;		// value calculate coefficient  	
	UNSIGNED	value_measure1; 					// value  				
	UNSIGNED	value_measure2; 					// value  				
	UNSIGNED	value_measure3; 					// value  				
	UNSIGNED	value_measure4; 					// value  				
	UNSIGNED	value_real1; 						// value real 		
	UNSIGNED	value_real2; 						// value real 		
	UNSIGNED	value_real3; 						// value real 		
	UNSIGNED	value_real4; 						// value real 		
	UNSIGNED	value_imaginary1; 					// value imaginary 	
	UNSIGNED	value_imaginary2; 					// value imaginary 	
	UNSIGNED	value_imaginary3; 					// value imaginary 	
	UNSIGNED	value_imaginary4; 					// value imaginary 	
}EEP_VALUE;

typedef struct EEP_REPORT_STRUCT
{ 	
	UNSIGNED	uReportEEPNumL;
	UNSIGNED	uReportEEPNumH;
	CHAR	SOE_name[SOE_NAME];  				// SOE name         			
	UNSIGNED	SOE_Inf;							// SOE INF				
	UNSIGNED	DPI; 								// DIP = 1 return; 2 = operate
	UNSIGNED	Relative_TimeL; 	            		// fault hold Time (fault_start -- fault_end time) 
	UNSIGNED	Relative_TimeH; 	            		// fault hold Time (fault_start -- fault_end time) 
	UNSIGNED	Fault_Number; 	 					// fault count      
	UNSIGNED	Year;                 				// year	
	UNSIGNED	Month;      						// month
	UNSIGNED	Day;   								// day	
	UNSIGNED	Hour;          						// hour
	UNSIGNED	Minute;      						// minute
	UNSIGNED	MillionsecondL;      				// Millionsecond
	UNSIGNED	MillionsecondH;      				// Millionsecond
  	UNSIGNED	SIN;                            	// return use(IEC103)
	UNSIGNED	pro_report_data_number;
	EEP_VALUE	Value[5];
}EEP_REPORT;


#define TIMELEN 100
typedef struct
{
     UNSIGNED    HourMinuteSec[TIMELEN];
     UNSIGNED    YearMonthDay[TIMELEN];
     UNSIGNED    DI[TIMELEN];
}TimeSTRU;

typedef struct
{
     UNSIGNED    QDB;      
     UNSIGNED    Iaqdjs;
     UNSIGNED    Ibqdjs;
     UNSIGNED    Icqdjs;
     UNSIGNED    Izqdjs;
     float*      IqdPtr;
     UNSIGNED    WaitFlag;
     UNSIGNED    Iqdsj;     //对应于故障开始时刻,为第一个突变点
/*
     UNSIGNED    year;      //对应于突变量元件动作的时间,一般为故障1/3周后动作。
     UNSIGNED    month;
     UNSIGNED    date;
     UNSIGNED    hour;
     UNSIGNED    minute;
     UNSIGNED    msec;
*/
}IQDSTRU;

#define	SAVE_SUBADDRESS	 1 
#define	SAVE_PASSWORD	 2
#define	SAVE_SETZONE	 3
#define	SAVE_PTRATE		 4
#define	SAVE_CTRATE		 5
#define	SAVE_JUMPER		 6
#define	SAVE_SETTING	 7
#define	CLR_EEP_REPORT	 8
#define	SAVE_SCALE	     9
#define	SAVE_ANGLE	     10
#define	SAVE_REPORT	     11
#define	SAVE_PULSE	     12
#define	SAVE_TIME	     13

typedef struct
{    
	UNSIGNED	sec;
	UNSIGNED	min;
	UNSIGNED	hour;
	UNSIGNED	date;
	UNSIGNED	month;
	UNSIGNED	day;   
	UNSIGNED	year;
	UNSIGNED	ctrl;       //以burst方式写时钟时,必须包含ctrl,否则写不进
}Clock;

typedef struct EEP_SET_STRUCT
{ 	
    UNSIGNED            value0;
    UNSIGNED            value1;
    UNSIGNED            value2;
    UNSIGNED            value3;
/*
    UNSIGNED            value0test;
    UNSIGNED            value1test;
    UNSIGNED            value2test;
    UNSIGNED            value3test;
*/
}EEP_SET;

typedef struct RUN_USET_STRUCT
{ 	
    UNSIGNED            value;
/*
    UNSIGNED            valuetest;
*/
}RUN_USET;

typedef struct RUN_ISET_STRUCT
{ 	
    INT                 value;
/*
    INT                 valuetest;
*/
}RUN_ISET;

typedef struct RUN_FSET_STRUCT
{ 	
    float               value;
/*
    float               valuetest;
*/
}RUN_FSET;

#define MEASURE_NUMBER  13
typedef struct
{
	CHAR    *pMeasure_name;
	float	rating;
	float	value;
	CHAR    *pvalue_dimension;
}MEASTRU;

/*         开入通道           	  */
#define  MC1     0          //脉冲1
#define  MC2     1
#define  MC3     2
#define  MC4     3
#define  YX1     4          //遥信1
#define  YX2     5
#define  YX3     6
#define  YX4     7
#define  YX5     8
#define  YX6     9
#define  YX7     10
#define  YX8     11
#define  YX9     12
#define  THWXN   13         //弹簧未蓄能
#define  BSCHZ   14         //闭锁重合闸
#define  JXZT    15         //检修状态
#define  TW      16         //跳位
#define  YKYX    17         //遥控允许
#define  SDTZ    18         //手动跳闸
#define  HW      19         //合位
#define  FG      20         //复归

#define  SOE_NAME  20
typedef struct DIFUN
{
     CHAR        name[SOE_NAME];
     CHAR        on_name[SOE_NAME];
     CHAR        off_name[SOE_NAME];
     UNSIGNED    inf;
     UNSIGNED    asdu;
     UNSIGNED    counter_set;
     VOID        (*proutine)(struct DIFUN *);
     UNSIGNED    done;
     UNSIGNED    state;
     UNSIGNED    counter;
     UNSIGNED    time;     
}DISTRU;

typedef struct
{
     float       value[AD_OneDataSize - 1];
     UNSIGNED    reserve;
}SAMPLE;

/*         信息代码           */
#define    SpringCode              168              //弹簧未蓄能
#define    ControlCircuitCode      203              //控制回路断线信息序号
#define    SettingZoneErrorCode    223              //定值区出错
#define    EepromErrorCode         196              //EEPROM出错
#define    SettingErrorCode        222              //定值出错
#define    PTCode                  133              //PT回路断线
                   
/*         模入通道           	      MAX336管脚    */
#define    DC_Chn       0             //pin19
#define    PIa_Chn      4             //pin23
#define    PIb_Chn      14            //pin5
#define    PIc_Chn      9             //pin10
#define    PI0_Chn      6             //pin25
#define    Ua_Chn       1            //pin20
#define    Ub_Chn       3            //pin22
#define    Uc_Chn       8            //pin11
#define    U0_Chn       5            //pin24
#define    Ux_Chn       2            //pin21
#define    MIa_Chn      15           //pin4
#define    MIb_Chn      10           //pin7
#define    MIc_Chn      12           //pin9
//Ubr1    pin8     11
//Ubr2    pin26    7
//Ubr3    pin6     13

/*       IO口地址            */
#define         DIN1PORT            0x810000    
#define         DIN2PORT            0x811000
//DIN1为低16位,DIN2为高16位
//D0~D3为脉冲1~4;
//D4~D12为开入1~9;
//D13为弹簧未蓄能,D14为闭锁重合闸,D15为检修状态    
//D16为跳位,D17为遥控允许,D18为手跳,D19为合位,D20为复归 
#define         OUTRET              0x1
#define         GPSIN               0x2
#define         DIN3PORT            0x812000    
/* d0:out_ret  d1:gps  d2:inta   d3:intb   d4:intc   d5:intd   */

#define         KEYPORT             0x813000    
#define         DOPORT              0x814000    
#define         CTRLPORT            0x815000    
/* d0:runled   d1:oe_485  d2:clr_hdog  d3:close_n  */
#define         CTRL_DOG            2
#define         CTRL_485            1
#define         CTRL_RUNLED         0
#define         CTRL_LIGHT          3

#define         COM1PORT            0x816000    
#define         COM2PORT            0x817000    
#define         COM3PORT            0x818000    
#define         COM4PORT            0x819000    
#define         ADPORT              0x81A000    
#define         LCD1PORT            0x820000
#define         LCD2PORT            0x821000

/*         开关量输出         */
typedef struct
{
     UNSIGNED   clock;              //动作的时间
     UNSIGNED   state;              //当前的状态
}DOSTRU;

#define    BSJ         13
#define    QDJ         0
#define    GXJ         1
#define    FGJ         12
#define    TZJ         2
#define    HZJ         7
#define    YHJ         6
#define    YTJ         5
#define    BY1         3
#define    BY2         4
#define    BY3         9
#define    BY4         10
#define    BY5         11

#define    Bsj()       Switch_Output_off(BSJ)
#define    BsjBack()   Switch_Output_on(BSJ)

#define    Qdj()       Switch_Output_on(QDJ)
#define    QdjBack()   Switch_Output_off(QDJ)
		       
#define    Gxj()       Switch_Output_on(GXJ)
#define    GxjBack()   Switch_Output_off(GXJ)

#define    Fgj()       Switch_Output_on(FGJ)
#define    FgjBack()   Switch_Output_off(FGJ)

#define    Tzj()       Switch_Output_on(TZJ)
#define    TzjBack()   Switch_Output_off(TZJ)

#define    Hzj()       Switch_Output_on(HZJ)
#define    HzjBack()   Switch_Output_off(HZJ)

#define    Yhj()       Switch_Output_on(YHJ)
#define    YhjBack()   Switch_Output_off(YHJ)

#define    Ytj()       Switch_Output_on(YTJ)
#define    YtjBack()   Switch_Output_off(YTJ)

#define    By1()       Switch_Output_on(BY1)
#define    By1Back()   Switch_Output_off(BY1)

#define    By2()       Switch_Output_on(BY2)
#define    By2Back()   Switch_Output_off(BY2)

#define    By3()       Switch_Output_on(BY3)
#define    By3Back()   Switch_Output_off(BY3)

#define    By4()       Switch_Output_on(BY4)
#define    By4Back()   Switch_Output_off(BY4)

#define    By5()       Switch_Output_on(BY5)
#define    By5Back()   Switch_Output_off(BY5)

#define    clrdog()    Ctrl_Output_on(CTRL_DOG);\
                       Ctrl_Output_off(CTRL_DOG);

#define    enable485() Ctrl_Output_off(CTRL_485);
#define    disable485() Ctrl_Output_on(CTRL_485);

#define    lcdlighton() Ctrl_Output_on(CTRL_LIGHT);
#define    lcdlightoff() Ctrl_Output_off(CTRL_LIGHT);

#define    runledon()   Ctrl_Output_reverse(CTRL_RUNLED);

#define    NU_ENABLE_USE_INTERRUPTS  0x00010708     //正常运行时使用的中断
#define    INTT1MASK       0x0200

#endif

⌨️ 快捷键说明

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