1、从文件register.h中重构出命令文件witcommand.h;
2、解析命令行参数; 3、修改串口类(继承基类SerialPortBase)的bug; 4、添加命令行选项--rlx1:任工想要的设置;
This commit is contained in:
125
main.cpp
125
main.cpp
@ -4,10 +4,12 @@
|
||||
#include "witmotiondll.h"
|
||||
#include "qtserialport.h"
|
||||
|
||||
#include "commandlineparser.h"
|
||||
|
||||
void delay_tc(uint32_t millisecond)
|
||||
{
|
||||
QThread::sleep(millisecond/1000);
|
||||
std::cout<<"This is delay_tc!!!!!!!!!!"<<std::endl;
|
||||
// std::cout<<"This is delay_tc!!!!!!!!!!"<<std::endl;
|
||||
}
|
||||
|
||||
void printf_tc(const char* text)
|
||||
@ -19,38 +21,111 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
// 解析命令行参数
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription("This software is used for config parameter for wit inertial navigation.");
|
||||
TcQuery query;
|
||||
QString errorMessage;
|
||||
|
||||
switch (parseCommandLine2(parser, &query, &errorMessage))
|
||||
{
|
||||
case CommandLineOk:
|
||||
break;
|
||||
case CommandLineError:
|
||||
fputs(qPrintable(errorMessage), stderr);
|
||||
fputs("\n\n", stderr);
|
||||
fputs(qPrintable(parser.helpText()), stderr);
|
||||
return 1;
|
||||
case CommandLineVersionRequested:
|
||||
printf("%s %s\n", qPrintable(QCoreApplication::applicationName()),
|
||||
qPrintable(QCoreApplication::applicationVersion()));
|
||||
return 0;
|
||||
case CommandLineHelpRequested:
|
||||
parser.showHelp();
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
|
||||
SerialPortBase * serialPort = new QtSerialport();
|
||||
// SerialPortBase * serialPort = new windowsSerialPort();
|
||||
int ret = serialPort->OpenSerialPort(query.serialPort.toStdString(), query.connectBaudrate);//"COM15"
|
||||
if(ret)
|
||||
{
|
||||
std::cout<<"Serial port open failed!!"<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
serialPort->OpenSerialPort("COM15", 9600);
|
||||
WitmotionDll * witmotion = new WitmotionDll(serialPort);
|
||||
witmotion->delayMsRegister(delay_tc);
|
||||
witmotion->printfRegister(printf_tc);
|
||||
witmotion->setDelayTimeMs(1000);
|
||||
|
||||
WitmotionDll * tmp = new WitmotionDll(serialPort);
|
||||
tmp->delayMsRegister(delay_tc);
|
||||
tmp->printfRegister(printf_tc);
|
||||
tmp->setDelayTimeMs(1000);
|
||||
if(query.isSetAlgorithm)
|
||||
{
|
||||
witmotion->algorithm(query.algorithm);
|
||||
}
|
||||
|
||||
tmp->installationOrientation(ORIENT_VERTICAL);
|
||||
// tmp->algorithm(ALGROITHM9);
|
||||
// tmp->setTimeZone(UTC_P12);
|
||||
// tmp->SetBaudrate(WIT_BAUD_115200);
|
||||
// tmp->SetReturnRate(RRATE_20HZ);
|
||||
if(query.isSetInstallationOrientation)
|
||||
{
|
||||
witmotion->installationOrientation(query.installationOrientation);
|
||||
}
|
||||
|
||||
// tmp->SetDeviceAddress(124);
|
||||
if(query.isSetTimeZone)
|
||||
{
|
||||
witmotion->setTimeZone(query.timeZone);
|
||||
}
|
||||
|
||||
// tmp->setD0Model(DOL);
|
||||
// tmp->setD0HighLevelPulseWidth(20);
|
||||
// tmp->setD0Period(5);
|
||||
|
||||
// RETURN_CONTENT_STRUCT content;
|
||||
// content.time = true;
|
||||
// content.angular_velocity = true;
|
||||
// content.euler_angle = true;
|
||||
// content.ground_velocity = true;
|
||||
// content.quaternion = true;
|
||||
// tmp->setContent(content);
|
||||
if(query.isSetDefaultReturnContent)
|
||||
{
|
||||
witmotion->setContent(query.defaultReturnContent);
|
||||
}
|
||||
|
||||
|
||||
// tmp->recordData();
|
||||
|
||||
|
||||
if(query.isSetReturnRate)
|
||||
{
|
||||
witmotion->SetReturnRate(query.returnRate);
|
||||
}
|
||||
if(query.isSetDeviceAddress)
|
||||
{
|
||||
witmotion->SetDeviceAddress(query.deviceAddress);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(query.isSetInterface_D0)
|
||||
{
|
||||
witmotion->setD0Model(query.modelForInterface_D0);
|
||||
witmotion->setD0HighLevelPulseWidth(query.pulseWidth_D0);
|
||||
witmotion->setD0Period(query.period_D0);
|
||||
}
|
||||
|
||||
if(query.isSetInterface_D1)
|
||||
{
|
||||
witmotion->setD1Model(query.modelForInterface_D1);
|
||||
witmotion->setD1HighLevelPulseWidth(query.pulseWidth_D1);
|
||||
witmotion->setD1Period(query.period_D1);
|
||||
}
|
||||
|
||||
if(query.isSetInterface_D2)
|
||||
{
|
||||
witmotion->setD2Model(query.modelForInterface_D2);
|
||||
witmotion->setD2HighLevelPulseWidth(query.pulseWidth_D2);
|
||||
witmotion->setD2Period(query.period_D2);
|
||||
}
|
||||
|
||||
if(query.isSetInterface_D3)
|
||||
{
|
||||
witmotion->setD3Model(query.modelForInterface_D3);
|
||||
witmotion->setD3HighLevelPulseWidth(query.pulseWidth_D3);
|
||||
witmotion->setD3Period(query.period_D3);
|
||||
}
|
||||
|
||||
if(query.isSetBaudrate)//设置witMotion的通讯速率要放在最后,它后面的设置都会失败
|
||||
{
|
||||
witmotion->SetBaudrate(query.baudrate);
|
||||
}
|
||||
|
||||
// witmotion->recordData();
|
||||
|
||||
serialPort->CloseSerialPort();
|
||||
|
||||
|
Reference in New Issue
Block a user