函数指针数组工程实例

在这以前曾经写过一篇关于函数指针数组文章,今天又看到了通信工程的应用,拷贝下来,作为参考!

http://blog.csdn.net/eliot_shao/article/details/8609259

1、数据结构的定义

typedef int (*IO_DETECT_FUCTION)(void);
typedef struct __IO_DETECT
{
	int id;
	IO_DETECT_FUCTION fun;
	
}IO_DETECT;

2、类型实体

IO_DETECT s_IO_Detect[]=
{
    {0x01, InputPowerDetect},        
    {0x02, InputPowerDetect1},      
    {0x03, InputPowerDetect2},       
    {0x04, InputPowerDetect3},       
    {0x05, DownBrokenDectect},      
    {0x06, UpBrokenDetect},          
    {0x07, UpBrokenDetect1},         
    {0x08, OpticalTransDetect},      
    {0x09, UpOutputDetect},         
    {0x0A, SlaveDCAlarm},           
    {0x0B, SlaveACAlarm},           
    {0x0C, SolarEnergyDetect},       
    {0x0D, MainInputPowerDetect1},
    {0x0E, MainInputPowerDetect2},
    {0x0F, BackupInputPowerDetect1},
    {0x10, BackupInputPowerDetect2},
    {0x11, GZDTInputPowerDetect},
    {0x12, GZDTOpeicalAlarmDect},
    {0x13, BJDTSlaveDCAlarm},
    {0x14, BJDTUpOutputDetect},  
    {0x15, BJDTSlaveACAlarm},
    {0x16, DCAlarm},
    {0x17, ACAlarm},
    {0x18, GSMCTDownInputPowerDetect},  
    {0x19, CMMBInputPowerDetect},
    {0x1A, BeiJingInputPowerDetect},
    {0x1B, BeiJingOutputPowerDetect},
    {0x1C, CDMAInputPowerDetect1},
    {0x1D, DCAlarm1V},                 
    {0x1E, ACAlarm1V},
    {0x1F, BAT13VDect},                
    {0x20, BAT48VDect},
    {0x21, ReportKey},                  
    {0x22, InputPowerDetect4},
    {0x23, OutputPowerDetect1},
    {0x24, RePowerDetect1},
    {0x25, ACLow_Alarm}
};

3、函数调用

int IO_DetectFunction(int Id)
{
    int  i = 0;
    int ret = 0;
    for(i=0; i < sizeof(s_IO_Detect)/sizeof(IO_DETECT); i++)
    {
        if( s_IO_Detect[i].id == Id )
        {

            ret = s_IO_Detect[i].fun();
            break;
        }
    }
    return ret;
}



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值