1、从文件register.h中重构出命令文件witcommand.h;

2、解析命令行参数;
3、修改串口类(继承基类SerialPortBase)的bug;
4、添加命令行选项--rlx1:任工想要的设置;
This commit is contained in:
tangchao0503
2022-07-15 22:09:06 +08:00
parent 3c0ba621ac
commit 14a4518e2e
10 changed files with 1006 additions and 189 deletions

73
commandlineparser.h Normal file
View File

@ -0,0 +1,73 @@
#ifndef COMMANDLINEPARSER_H
#define COMMANDLINEPARSER_H
#include <QCommandLineParser>
#include <QDir>
#include <string>
#include "witcommand.h"
enum CommandLineParseResult
{
CommandLineOk,
CommandLineError,
CommandLineVersionRequested,
CommandLineHelpRequested
};
struct TcQuery
{
QString serialPort;
int connectBaudrate;
bool isSetAlgorithm;
ALGROITHM_ENUM algorithm;
bool isSetInstallationOrientation;
ORIENT_ENUM installationOrientation;
bool isSetTimeZone;
TIMEZONE_ENUM timeZone;
bool isSetDefaultReturnContent;//wit默认 + 经纬度
RETURN_CONTENT_STRUCT defaultReturnContent;
RETURN_CONTENT_STRUCT returnContent;
bool isSetBaudrate;
BAUD_ENUM baudrate;
bool isSetReturnRate;
RRATE_ENUM returnRate;
bool isSetDeviceAddress;
int deviceAddress;
bool isSetInterface_D0;
MODEL_D0_D2_D3_ENUM modelForInterface_D0;//模式
int pulseWidth_D0;//脉宽
int period_D0;//周期
bool isSetInterface_D1;
MODEL_D1_ENUM modelForInterface_D1;//模式
int pulseWidth_D1;//脉宽
int period_D1;//周期
bool isSetInterface_D2;
MODEL_D0_D2_D3_ENUM modelForInterface_D2;//模式
int pulseWidth_D2;//脉宽
int period_D2;//周期
bool isSetInterface_D3;
MODEL_D0_D2_D3_ENUM modelForInterface_D3;//模式
int pulseWidth_D3;//脉宽
int period_D3;//周期
};
CommandLineParseResult parseCommandLine2(QCommandLineParser &parser, TcQuery *query, QString *errorMessage);
bool getModel(int modelIndex, MODEL_D0_D2_D3_ENUM & model);
bool getModel_D1(int modelIndex, MODEL_D1_ENUM & model);
bool processModelParm(QCommandLineParser &parser, QCommandLineOption commandLineOption, MODEL_D0_D2_D3_ENUM & model, bool &isSetInterface);
bool processModelParm_D1(QCommandLineParser &parser, QCommandLineOption commandLineOption, MODEL_D1_ENUM & model, bool &isSetInterface);
bool processPulseWidthParm(QCommandLineParser &parser, QCommandLineOption commandLineOption, int & pulseWidth, bool &isSetInterface);
bool processPeriodParm(QCommandLineParser &parser, QCommandLineOption commandLineOption, int & period, bool &isSetInterface);
#endif // COMMANDLINEPARSER_H