-
#include <stdio.h>
-
-
void procd_rec(int n, void *cmd);
-
void procd_ntrip(int n, void *cmd);
-
void procd_init(int n, void *cmd);
-
void procd_memory(int n, void *cmd);
-
void procd_monitorPower(int n, void *cmd);
-
void procd_monitorGPS(int n, void *cmd);
-
void procd_monitorRunTime(int n, void *cmd);
-
-
void procd_rec(int n, void *cmd)
-
{
-
printf("procd_rec\n");
-
}
-
void procd_ntrip(int n, void *cmd)
-
{
-
printf("procd_ntrip\n");
-
}
-
void procd_init(int n, void *cmd)
-
{
-
printf("procd_init,%d,%s\n",n,(char *)cmd);
-
}
-
void procd_memory(int n, void *cmd)
-
{
-
printf("procd_memory\n");
-
}
-
void procd_monitorPower(int n, void *cmd)
-
{
-
printf("procd_monitorPower\n");
-
}
-
void procd_monitorGPS(int n, void *cmd)
-
{
-
printf("procd_monitorGPS\n");
-
}
-
void procd_monitorRunTime(int n, void *cmd)
-
{
-
printf("procd_monitorRunTime\n");
-
}
-
-
int main(int argc, const char *argv[])
-
{
-
unsigned int i,Func_Num;
-
unsigned int count=0;
-
-
typedef struct _PROCD_FUNC{
-
int interval;//sec
-
unsigned int nexttick;
-
int options;
-
unsigned int reserve1;
-
unsigned int reserve2;
-
void (*Function)(int ,void *);
-
}PROCD_FUNC;
-
-
PROCD_FUNC Func[]={
-
{3,0,0,0,0,procd_rec},
-
{2,0,0,0,0,procd_ntrip},
-
{2,0,0,0,0,procd_init},
-
{30,0,0,0,0,procd_memory},
-
{5,0,0,0,0,procd_monitorPower},
-
{10,0,0,0,0,procd_monitorGPS},
-
{60,0,0,0,0,procd_monitorRunTime},
-
};
-
-
printf("Func[]: %d\n",sizeof(Func));
-
printf("PROCD_FUNC:%d\n",sizeof(PROCD_FUNC));
-
printf("Func_Num: %d\n",Func_Num=(sizeof(Func)/sizeof(PROCD_FUNC)));
-
-
while(1)
-
{
-
for(i=0;i<Func_Num;i++)
-
{
-
if(count>=Func[i].nexttick)
-
{
-
Func[i].Function(i,"333");
-
Func[i].nexttick=count+Func[i].interval;
-
}
-
/*
-
* count=0 ; count:0>=nexttick:0 nexttick=count:0+interval(3、2、2、30...)
-
* count=1 ; count:1<nexttick:(3、2、2、30...)
-
* count=2 ; count:2>=nexttick:2、2(3、30...) nexttick=count:2+interval(2、2)
-
* count=3 ; count:3>=nexttick:3(4、4、30...) nexttick=count:3+interval(3)
-
* count=4 ; count:4>=nexttick:4、4(6、30...) nexttick=count:4+interval(4、4)
-
*/
-
}
-
count++;
-
sleep(1);
-
printf("========%d=======\n",count);
-
}
-
return 0;
-
}
执行结果:
Func[]: 168
PROCD_FUNC:24
Func_Num: 7
procd_rec
procd_ntrip
procd_init,2,333
procd_memory
procd_monitorPower
procd_monitorGPS
procd_monitorRunTime
========1=======
========2=======
procd_ntrip
procd_init,2,333
========3=======
procd_rec
========4=======
procd_ntrip
procd_init,2,333
========5=======
procd_monitorPower
========6=======
procd_rec
procd_ntrip
procd_init,2,333
========7=======
========8=======
procd_ntrip
procd_init,2,333
========9=======
procd_rec
========10=======
procd_ntrip
procd_init,2,333
procd_monitorPower
procd_monitorGPS
阅读(1757) | 评论(0) | 转发(0) |