From 61b41a4180d4a8e64871418ad1edda0c213dc48f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=AD=E6=B0=B4=E5=AE=A2?= Date: Wed, 9 Jun 2021 15:13:08 +0800 Subject: [PATCH] Update cmd.cpp --- cmd.cpp | 171 ++++++++++++++++++++------------------------------------ 1 file changed, 61 insertions(+), 110 deletions(-) diff --git a/cmd.cpp b/cmd.cpp index e52763a..7851c50 100644 --- a/cmd.cpp +++ b/cmd.cpp @@ -43,136 +43,90 @@ int FindInCmds(char* val) return -1; } -/* -**************************************************************************************** +/************************************************************* Init method if DAQ config system -**************************************************************************************** -*/ +*************************************************************/ void Cmd_Init() { - DaqFM_Read(daqFMx); + } -/* -*************************************************************************************** +/************************************************************ basic cmds of system -**************************************************************************************** -*/ +*************************************************************/ char cmd_Func_help() { - (void)printf( "Usage: command\n" ); - (void)printf( "\n" ); - (void)printf( "Commands:\n" ); - (void)printf(" help \tprint this help message\n" ); - (void)printf(" quit \tquit application\n" ); - (void)printf(" prints \tPrint the config info in ConfigFile \n"); - (void)printf(" printf \tPrint the values of all elements of the structure \n"); - (void)printf(" save \tWrite the configuration information to the configuration file\n"); - /* The main category */ - (void)printf("\n\t---Main category---\n"); - (void)printf(" sample \tConfigure all the elems of SampleRate \n"); - (void)printf(" baud \tConfigure all the elems of baud \n"); - (void)printf(" smethod \tConfigure all the elems of smethod \n"); - (void)printf(" csignal \tConfigure all the elems of csignal \n"); - (void)printf(" basicparam \tConfigure all the elems of basicparam \n"); - /* Subsidiary categories */ - (void)printf("\n\t---Subsidiary categories---\n"); - (void)printf(" samplerate \tConfigure the SampleRate \n"); - (void)printf(" dfp \tConfigure the dfp \n"); - (void)printf(" baud \tConfigure the baud \n"); - (void)printf(" fre \tConfigure the fre \n"); - (void)printf(" pp \tConfigure the pp \n"); - (void)printf(" mode \tConfigure the mode \n"); - (void)printf(" ipaddr \tConfigure the ipaddr \n"); - (void)printf(" mask \tConfigure the mask \n"); - (void)printf(" gateway \tConfigure the gateway \n"); - (void)printf(" serverip \tConfigure the serverip \n"); - (void)printf(" serverport \tConfigure the serverport \n"); - (void)printf(" sn \tConfigure the sn \n"); - (void)printf(" lon \tConfigure the lon \n"); - (void)printf(" la \tConfigure the la \n"); - (void)printf(" model \tConfigure the model \n"); + (void) printf( "Usage: cmd \n" ); + (void) printf( "\n" ); + (void) printf( "Commands:\n" ); + (void) printf( " help print this help message\n" ); + (void) printf( " quit quit application\n" ); return EXIT_SUCCESS; } -/* quit this stage */ + char cmd_Func_quit() { (void) printf( "Exiting ...\n" ); exit( EXIT_SUCCESS ); } -/* Prints out the values of all elements of the structure (has not been written into Configfile) */ +/* 打印输出结构体所有元素的值 */ char cmd_Func_prints() { + printf("basicParam_chn:%s\n",daqFMx->_basicparam._chn);; printf("sample_dfp:%s\n", daqFMx->_sample._dfp);; - printf("sample_samplerate:%s\n", daqFMx->_sample._samplerate);; - printf("sample_baud:%s\n", daqFMx->_baud._baud);; - printf("csignal_fre:%s\n", daqFMx->_csignal._fre);; - printf("csignal_pp:%s\n", daqFMx->_csignal._pp);; + printf("sample_dfp:%s\n", daqFMx->_sample._samplerate);; + printf("sample_dfp:%s\n", daqFMx->_baud._baud);; + printf("sample_dfp:%s\n", daqFMx->_csignal._fre);; + printf("sample_dfp:%s\n", daqFMx->_csignal._pp);; printf("smethod_gateway:%s\n", daqFMx->_smethod._gateway);; printf("smethod_ipaddr:%s\n", daqFMx->_smethod._ipaddr);; printf("smethod_mask:%s\n", daqFMx->_smethod._mask);; printf("smethod_mode:%s\n", daqFMx->_smethod._mode);; printf("smethod_serverip:%s\n", daqFMx->_smethod._serverip);; printf("smethod_port:%s\n", daqFMx->_smethod._serverport);; + printf("basicparam_chn:%s\n", daqFMx->_basicparam._chn);; printf("basicparam_la:%s\n", daqFMx->_basicparam._la);; printf("basicparam_lon:%s\n", daqFMx->_basicparam._lon);; printf("basicparam_model:%s\n", daqFMx->_basicparam._model);; printf("basicparam_sn:%s\n", daqFMx->_basicparam._sn);; return (EXIT_SUCCESS); } -/* print the info in ConfigFile (has been written into Configfile) */ +/* 打印输出配置文件信息 */ char cmd_Func_printf() { - DaqFileManager reader; - pDaqFM pReader = &reader; - DaqFM_StrucInit(pReader); /* read info from config file and save to daq strc */ - DaqFM_Read(pReader); + DaqFM_Read(daqFMx); /* printf vals of all elems of info strct */ - printf("sample_dfp:%s\n", pReader->_sample._dfp);; - printf("sample_samplerate:%s\n", pReader->_sample._samplerate);; - printf("sample_baud:%s\n", pReader->_baud._baud);; - printf("csignal_fre:%s\n", pReader->_csignal._fre);; - printf("csignal_pp:%s\n", pReader->_csignal._pp);; - printf("smethod_gateway:%s\n", pReader->_smethod._gateway);; - printf("smethod_ipaddr:%s\n", pReader->_smethod._ipaddr);; - printf("smethod_mask:%s\n", pReader->_smethod._mask);; - printf("smethod_mode:%s\n", pReader->_smethod._mode);; - printf("smethod_serverip:%s\n", pReader->_smethod._serverip);; - printf("smethod_port:%s\n", pReader->_smethod._serverport);; - printf("basicparam_la:%s\n", pReader->_basicparam._la);; - printf("basicparam_lon:%s\n", pReader->_basicparam._lon);; - printf("basicparam_model:%s\n", pReader->_basicparam._model);; - printf("basicparam_sn:%s\n", pReader->_basicparam._sn);; + cmd_Func_prints(); return (EXIT_SUCCESS); } -/* Write the configuration information to the configuration file */ +/* 把配置信息写入配置文件 */ char cmd_Func_save() { DaqFM_Save(daqFMx); return EXIT_SUCCESS; } -/****************************************************************************** +/************************************************************ - Specific options + 配置函数 -*******************************************************************************/ +*************************************************************/ -/***************************** The main category ******************************/ -/* Configure the SampleRate */ +/******************************** 大类配置命令 ********************************/ +/* 配置samlpe */ char cmd_Func_sample() { cmd_Func_dfp(); cmd_Func_samplerate(); return EXIT_SUCCESS; } -/* Configure the baud */ +/* 配置baud */ char cmd_Func_baud() { char quit[] = { "quit" }; @@ -187,13 +141,13 @@ char cmd_Func_baud() return EXIT_SUCCESS; } while (!(strcmp(buffer, Val_1) || strcmp(buffer, Val_2))); - /* save to structure daqFMx */ + /* 把配置值写入结构体 */ DaqFM_SetVal_baud_baud(daqFMx, buffer); return EXIT_SUCCESS; } -/* Configure the csingnal */ +/* 配置csignal */ char cmd_Func_csignal() { cmd_Func_fre(); @@ -201,7 +155,7 @@ char cmd_Func_csignal() return EXIT_SUCCESS; } -/* Configure the all options of smethod */ +/* 配置smethod */ char cmd_Func_smethod() { cmd_Func_mode(); @@ -212,7 +166,7 @@ char cmd_Func_smethod() cmd_Func_serverport(); return EXIT_SUCCESS; } -/* Configure the basic params */ +/* 配置basicparam */ char cmd_Func_basicparam() { cmd_Func_sn(); @@ -223,9 +177,9 @@ char cmd_Func_basicparam() return EXIT_SUCCESS; } -/*************************** Subsidiary categories ****************************/ +/******************************** 小项配置命令 ********************************/ -/* Configure the dfp */ +/* 配置dfp */ char cmd_Func_dfp() { char quit[] = {"quit"}; @@ -243,7 +197,7 @@ char cmd_Func_dfp() DaqFM_SetVal_sample_dfp(daqFMx, buffer); return EXIT_SUCCESS; } -/* Configure the SampleRate */ +/* 配置samlperate */ char cmd_Func_samplerate() { char quit[] = { "quit" }; @@ -255,11 +209,11 @@ char cmd_Func_samplerate() return EXIT_SUCCESS; } while (strlen(buffer) == 0); - /* save to structure daqFMx */ + /* 把配置值写入结构体 */ DaqFM_SetVal_sample_samplerate(daqFMx, buffer); return EXIT_SUCCESS; } -/* Configure the fre */ +/* 配置fre */ char cmd_Func_fre() { char quit[] = { "quit" }; @@ -271,11 +225,11 @@ char cmd_Func_fre() return EXIT_SUCCESS; } while (strlen(buffer) == 0); - /* save to structure daqFMx */ + /* 把配置值写入结构体 */ DaqFM_SetVal_csignal_fre(daqFMx, buffer); return EXIT_SUCCESS; } -/* Configure the pp */ +/* 配置pp */ char cmd_Func_pp() { char quit[] = { "quit" }; @@ -287,12 +241,12 @@ char cmd_Func_pp() return EXIT_SUCCESS; } while (strlen(buffer) == 0); - /* save to structure daqFMx */ + /* 把配置值写入结构体 */ DaqFM_SetVal_csignal_pp(daqFMx, buffer); return EXIT_SUCCESS; } -/* Configure the mode */ +/* 配置mode */ char cmd_Func_mode() { char quit[] = { "quit" }; @@ -307,11 +261,9 @@ char cmd_Func_mode() return EXIT_SUCCESS; } while (!(strcmp(buffer, Val_1) || strcmp(buffer, Val_2))); - /* save to structure daqFMx */ - DaqFM_SetVal_smethod_mode(daqFMx, buffer); return EXIT_SUCCESS; } -/* Configure the ipaddr */ +/* 配置ipaddr */ char cmd_Func_ipaddr() { char quit[] = { "quit" }; @@ -323,12 +275,12 @@ char cmd_Func_ipaddr() return EXIT_SUCCESS; } while (strlen(buffer) == 0); - /* save to structure daqFMx */ + /* 把配置值写入结构体 */ DaqFM_SetVal_smethod_ipaddr(daqFMx, buffer); return EXIT_SUCCESS; } -/* Configure the mask */ +/* 配置mask */ char cmd_Func_mask() { char quit[] = { "quit" }; @@ -340,13 +292,13 @@ char cmd_Func_mask() return EXIT_SUCCESS; } while (strlen(buffer) == 0); - /* save to structure daqFMx */ + /* 把配置值写入结构体 */ DaqFM_SetVal_smethod_mask(daqFMx, buffer); return EXIT_SUCCESS; return EXIT_SUCCESS; } -/* Configure the gateway */ +/* 配置gateway */ char cmd_Func_gateway() { char quit[] = { "quit" }; @@ -358,14 +310,14 @@ char cmd_Func_gateway() return EXIT_SUCCESS; } while (strlen(buffer) == 0); - /* save to structure daqFMx */ + /* 把配置值写入结构体 */ DaqFM_SetVal_smethod_gateway(daqFMx, buffer); return EXIT_SUCCESS; return EXIT_SUCCESS; return EXIT_SUCCESS; } -/* Configure the serverip */ +/* 配置serverip */ char cmd_Func_serverip() { char quit[] = { "quit" }; @@ -377,13 +329,13 @@ char cmd_Func_serverip() return EXIT_SUCCESS; } while (strlen(buffer) == 0); - /* save to structure daqFMx */ + /* 把配置值写入结构体 */ DaqFM_SetVal_smethod_serverip(daqFMx, buffer); return EXIT_SUCCESS; } -/* Configure the serverport */ +/* 配置serverport */ char cmd_Func_serverport() { char quit[] = { "quit" }; @@ -395,11 +347,11 @@ char cmd_Func_serverport() return EXIT_SUCCESS; } while (strlen(buffer) == 0); - /* save to structure daqFMx */ + /* 把配置值写入结构体 */ DaqFM_SetVal_smethod_serverport(daqFMx, buffer); return EXIT_SUCCESS; } -/* Configure the sn */ +/* 配置sn */ char cmd_Func_sn() { char quit[] = { "quit" }; @@ -411,12 +363,11 @@ char cmd_Func_sn() return EXIT_SUCCESS; } while (strlen(buffer) == 0); - /* save to structure daqFMx */ + /* 把配置值写入结构体 */ DaqFM_SetVal_basicparam_sn(daqFMx, buffer); - return EXIT_SUCCESS; } -/* Configure the lon */ +/* 配置lon */ char cmd_Func_lon() { char quit[] = { "quit" }; @@ -428,11 +379,11 @@ char cmd_Func_lon() return EXIT_SUCCESS; } while (strlen(buffer) == 0); - /* save to structure daqFMx */ + /* 把配置值写入结构体 */ DaqFM_SetVal_basicparam_lon(daqFMx, buffer); return EXIT_SUCCESS; } -/* Configure the la */ +/* 配置la */ char cmd_Func_la() { char quit[] = { "quit" }; @@ -444,11 +395,11 @@ char cmd_Func_la() return EXIT_SUCCESS; } while (strlen(buffer) == 0); - /* save to structure daqFMx */ + /* 把配置值写入结构体 */ DaqFM_SetVal_basicparam_la(daqFMx, buffer); return EXIT_SUCCESS; } -/* Configure the chn */ +/*配置chn*/ char cmd_Func_chn() { char quit[] = { "quit" }; @@ -460,11 +411,11 @@ char cmd_Func_chn() return EXIT_SUCCESS; } while (strlen(buffer) == 0); - /* save to structure daqFMx */ + /* 把配置值写入结构体 */ DaqFM_SetVal_basicparam_chn(daqFMx, buffer); return EXIT_SUCCESS; } -/* Configure the model */ +/*配置model*/ char cmd_Func_model() { char quit[] = { "quit" }; @@ -476,7 +427,7 @@ char cmd_Func_model() return EXIT_SUCCESS; } while (strlen(buffer) == 0); - /* save to structure daqFMx */ + /* 把配置值写入结构体 */ DaqFM_SetVal_basicparam_model(daqFMx, buffer); return EXIT_SUCCESS; } -- GitLab