当前位置: 首页>>代码示例>>C++>>正文


C++ SymbolString::getDataStr方法代码示例

本文整理汇总了C++中SymbolString::getDataStr方法的典型用法代码示例。如果您正苦于以下问题:C++ SymbolString::getDataStr方法的具体用法?C++ SymbolString::getDataStr怎么用?C++ SymbolString::getDataStr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SymbolString的用法示例。


在下文中一共展示了SymbolString::getDataStr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sendAndWait

result_t BusHandler::sendAndWait(SymbolString& master, SymbolString& slave)
{
	result_t result = RESULT_ERR_NO_SIGNAL;
	slave.clear();
	ActiveBusRequest request(master, slave);
	logInfo(lf_bus, "send message: %s", master.getDataStr().c_str());

	for (int sendRetries = m_failedSendRetries + 1; sendRetries >= 0; sendRetries--) {
		m_nextRequests.push(&request);
		bool success = m_finishedRequests.remove(&request, true);
		result = success ? request.m_result : RESULT_ERR_TIMEOUT;

		if (result == RESULT_OK) {
			Message* message = m_messages->find(master);
			if (message != NULL)
				m_messages->invalidateCache(message);
			break;
		}
		if (!success || result == RESULT_ERR_NO_SIGNAL || result == RESULT_ERR_SEND || result == RESULT_ERR_DEVICE) {
			logError(lf_bus, "send to %2.2x: %s, give up", master[1], getResultCode(result));
			break;
		}
		logError(lf_bus, "send to %2.2x: %s%s", master[1], getResultCode(result), sendRetries>0 ? ", retry" : "");

		request.m_busLostRetries = 0;
	}

	return result;
}
开发者ID:john30,项目名称:ebusd,代码行数:29,代码来源:bushandler.cpp

示例2: notify

bool ActiveBusRequest::notify(result_t result, SymbolString& slave)
{
	if (result == RESULT_OK)
		logDebug(lf_bus, "read res: %s", slave.getDataStr().c_str());

	m_result = result;
	m_slave.addAll(slave);

	return false;
}
开发者ID:Quantim,项目名称:ebusd,代码行数:10,代码来源:bushandler.cpp

示例3: main


//.........这里部分代码省略.........
					cout << "\"" << check[0] << "\": failed create OK" << endl;
				continue;
			}
			if (result != RESULT_OK) {
				cout << "\"" << check[0] << "\": create error: "
						<< getResultCode(result) << endl;
				printErrorPos(cout, entries.begin(), entries.end(), it, "", 0, result);
				continue;
			}
			if (deleteMessages.size()==0) {
				cout << "\"" << check[0] << "\": create error: NULL" << endl;
				continue;
			}
			if (it != entries.end()) {
				cout << "\"" << check[0] << "\": create error: trailing input " << static_cast<unsigned>(entries.end()-it) << endl;
				continue;
			}
			if (multi && deleteMessages.size()==1) {
				cout << "\"" << check[0] << "\": create error: single message instead of multiple" << endl;
				continue;
			}
			if (!multi && deleteMessages.size()>1) {
				cout << "\"" << check[0] << "\": create error: multiple messages instead of single" << endl;
				continue;
			}
			cout << "\"" << check[0] << "\": create OK" << endl;
			if (!dontMap) {
				result_t result = RESULT_OK;
				for (auto msgToDelete : deleteMessages) {
					auto deleteMessage = msgToDelete;
					result_t result = messages->add(deleteMessage);
					if (result != RESULT_OK) {
						cout << "\"" << check[0] << "\": add error: "
								<< getResultCode(result) << endl;
						break;
					}
				}
				if (result != RESULT_OK)
					continue;
				cout << "  map OK" << endl;
				message = deleteMessages.front();
				deleteMessages.clear();
				if (onlyMap)
					continue;
				auto foundMessage = messages->find(*mstrs[0]);
				if (foundMessage == message)
					cout << "  find OK" << endl;
				else if (foundMessage == NULL)
					cout << "  find error: NULL" << endl;
				else
					cout << "  find error: different" << endl;
			}
			else
				message = deleteMessages.front();
		}

		if (message->isPassive() || decode) {
			ostringstream output;
			for (unsigned char index=0; index<message->getCount(); index++) {
				message->storeLastData(*mstrs[index], *sstrs[index]);
			}
			result = message->decodeLastData(output, (decodeVerbose?OF_VERBOSE:0)|(decodeJson?OF_JSON:0), false);
			if (result != RESULT_OK) {
				cout << "  \"" << check[2] << "\" / \"" << check[3] << "\": decode error: "
						<< getResultCode(result) << endl;
				continue;
			}
			cout << "  \"" << check[2] << "\" / \"" << check[3] <<  "\": decode OK" << endl;
			bool match = inputStr == output.str();
			verify(false, "decode", check[2] + "/" + check[3], match, inputStr, output.str());
		}
		if (!message->isPassive() && (withInput || !decode)) {
			istringstream input(inputStr);
			SymbolString writeMstr;
			result = message->prepareMaster(0xff, writeMstr, input);
			if (failedPrepare) {
				if (result == RESULT_OK)
					cout << "  \"" << inputStr << "\": failed prepare error: unexpectedly succeeded" << endl;
				else
					cout << "  \"" << inputStr << "\": failed prepare OK" << endl;
				continue;
			}

			if (result != RESULT_OK) {
				cout << "  \"" << inputStr << "\": prepare error: "
						<< getResultCode(result) << endl;
				continue;
			}
			cout << "  \"" << inputStr << "\": prepare OK" << endl;

			bool match = writeMstr==*mstrs[0];
			verify(failedPrepareMatch, "prepare", inputStr, match, mstrs[0]->getDataStr(), writeMstr.getDataStr());
		}
	}

	deleteMessages.clear();

	return 0;

}
开发者ID:pnxs,项目名称:ebusd,代码行数:101,代码来源:test_message.cpp


注:本文中的SymbolString::getDataStr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。