本文整理汇总了C++中Protocol::color方法的典型用法代码示例。如果您正苦于以下问题:C++ Protocol::color方法的具体用法?C++ Protocol::color怎么用?C++ Protocol::color使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Protocol
的用法示例。
在下文中一共展示了Protocol::color方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readFromSocket
void Manager::readFromSocket()
{
QDataStream in(m_tcpSocket);
in.setVersion(QDataStream::Qt_4_0);
QString response;
in >> response;
Q_EMIT message(tr("Response received: ") + response);
Protocol protocol;
bool ok = false;
bool result = protocol.str2Response(response, m_currentCommand, &ok);
if(!ok) {
Q_EMIT message("Failed to parse response.");
} else if(!result) {
Q_EMIT message("Device cannot execute request.");
} else {
switch(m_currentCommand) {
case SetLedState:
case SetLedColor:
case SetLedRate: {
Q_EMIT message("Device has changed it's state successful.");
break;
}
case GetLedState: {
Q_EMIT message("Device state received successful.");
m_state.on = protocol.on();
Q_EMIT stateChanged();
break;
}
case GetLedColor: {
Q_EMIT message("Device color received successful.");
m_state.color = protocol.color();
Q_EMIT stateChanged();
break;
}
case GetLedRate: {
Q_EMIT message("Device rate received successful.");
m_state.rate = protocol.rate();
Q_EMIT stateChanged();
break;
}
default: {
break;
}
}
}
executeCommands();
}
示例2: processCommand
QString Manager::processCommand(const QString &_command)
{
Protocol protocol;
QString result = protocol.response2Str(false, MaxCommand);
if(!m_emulator->deviceEnabled()) {
return result;
}
bool ok;
ECommand command = protocol.str2Request(_command, &ok);
if(!ok) {
return result;
}
switch(command) {
case SetLedState: {
m_emulator->setStateOn(protocol.on());
break;
}
case GetLedState: {
protocol.setStateOn(m_emulator->stateOn());
break;
}
case SetLedColor: {
m_emulator->setColor(protocol.color());
break;
}
case GetLedColor: {
protocol.setColor(m_emulator->color());
break;
}
case SetLedRate: {
if(!m_emulator->setRate(protocol.rate())) {
return result;
}
break;
}
case GetLedRate: {
protocol.setRate(m_emulator->rate());
break;
}
default: {
break;
}
}
return protocol.response2Str(true, command);
}