本文整理汇总了C++中SearchController::getAsciiMode方法的典型用法代码示例。如果您正苦于以下问题:C++ SearchController::getAsciiMode方法的具体用法?C++ SearchController::getAsciiMode怎么用?C++ SearchController::getAsciiMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchController
的用法示例。
在下文中一共展示了SearchController::getAsciiMode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scan
bool ScanUART::scan(QSerialPort &port)
{
bool foundFlag = false;
SearchController contr;
float stepWidth = 100.0/(baudTable.count()*2);
float currentPercent=0;
for(int i=0;i<baudTable.count();i++) {
Request req;
req.setNetAddress(progAddr);
port.setBaudRate(baudTable.at(i));
CommandInterface* cmdBin = new GetCoreVersion();
CommandInterface* cmdAscii = new AsciiDecorator(cmdBin);
QVector<CommandInterface*> cmdList {cmdBin, cmdAscii};
foundFlag = false;
foreach(CommandInterface* cmd, cmdList) {
if(cmd->execute(req,port)){
contr.setBaudrate(baudTable.at(i));
if(QString(req.getRdData()).contains("Relkon")) contr.setBootMode(false);
else contr.setBootMode(true);
if(dynamic_cast<AsciiDecorator*>(cmd)) contr.setAsciiMode(true);
else contr.setAsciiMode(false);
GetCoreVersion* coreCmd = dynamic_cast<GetCoreVersion*>(cmdBin);
if(coreCmd) contr.setNetAddress(coreCmd->getNetAddress());
else contr.setNetAddress(0);
contr.setUartName(pName);
// get canal name
if(contr.getBootMode()==false) {
CommandInterface* cmdGetName = new GetCanName();
if(contr.getAsciiMode()) cmdGetName = new AsciiDecorator(cmdGetName);
if(cmdGetName->execute(req,port)) {
contr.setCanName(QString(req.getRdData()).remove("Canal:"));
}
delete cmdGetName;
}
emit percentUpdate(100);
emit plcHasBeenFound(contr);
foundFlag = true;
break;
}
currentPercent+=stepWidth;
emit percentUpdate(currentPercent);
}
delete cmdAscii; // cmdBin удаляется декоратором
mutex.lock();
if(stopCmd) {mutex.unlock();break;}
mutex.unlock();
if(foundFlag) break;
}
if(foundFlag) return true;
return false;
}