本文整理汇总了C++中Command::Parameter方法的典型用法代码示例。如果您正苦于以下问题:C++ Command::Parameter方法的具体用法?C++ Command::Parameter怎么用?C++ Command::Parameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Command
的用法示例。
在下文中一共展示了Command::Parameter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testAddAndRemoveNonGeneralCommand
void testAddAndRemoveNonGeneralCommand()
{
Command command;
// Write and read about half of the ring buffer capacity
int commandCount = ((COMMAND_BUFFER_SIZE / COMMAND_SIZE) / 2) + 1;
for (int commandIndex = 0; commandIndex < commandCount; commandIndex++)
addNonGeneralCommand(commandIndex % TEST_COMMANDS_SIZE);
for (int commandIndex = 0; commandIndex < commandCount; commandIndex++)
{
int exampleCommandIndex = commandIndex % 4;
buffer->GetCommand(command);
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(nonGeneralCommands[exampleCommandIndex][0]), command.Register());
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(nonGeneralCommands[exampleCommandIndex][1]), command.Action());
CPPUNIT_ASSERT_EQUAL(testCommandParameters[exampleCommandIndex], command.Parameter());
}
// Write/read the same number of commands to test ring buffer wrap around
for (int commandIndex = 0; commandIndex < commandCount; commandIndex++)
addNonGeneralCommand(commandIndex % TEST_COMMANDS_SIZE);
for (int commandIndex = 0; commandIndex < commandCount; commandIndex++)
{
int exampleCommandIndex = commandIndex % 4;
buffer->GetCommand(command);
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(nonGeneralCommands[exampleCommandIndex][0]), command.Register());
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(nonGeneralCommands[exampleCommandIndex][1]), command.Action());
CPPUNIT_ASSERT_EQUAL(testCommandParameters[exampleCommandIndex], command.Parameter());
}
}
示例2: testAddWhenCapacityExceeded
void testAddWhenCapacityExceeded()
{
Command command;
buffer->AddCommandByte(0x00);
// Exceed capacity
for (int i = 0; i < (COMMAND_BUFFER_SIZE / COMMAND_SIZE); i++)
for (int byteIndex = 0; byteIndex < COMMAND_SIZE; byteIndex++)
buffer->AddCommandByte(0x00);
buffer->AddCommandByte(0x00);
// The buffer stores bytes comprising entire commands until its capacity is reached
for (int i = 0; i < COMMAND_BUFFER_SIZE / COMMAND_SIZE; i++)
buffer->GetCommand(command);
// The buffer contains no elements now
// It correctly buffers additional data
addNonGeneralCommand(0);
buffer->GetCommand(command);
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(nonGeneralCommands[0][0]), command.Register());
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(nonGeneralCommands[0][1]), command.Action());
CPPUNIT_ASSERT_EQUAL(testCommandParameters[0], command.Parameter());
}
示例3: testAddStatusRegister
void testAddStatusRegister()
{
Command command;
buffer->AddCommandByte(MC_STATUS_REG);
buffer->AddCommandByte(MC_RESET);
buffer->GetCommand(command);
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(MC_GENERAL_REG), command.Register());
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(MC_RESET), command.Action());
CPPUNIT_ASSERT_EQUAL(0, command.Parameter());
}
示例4: testAddAndRemoveGeneralCommand
void testAddAndRemoveGeneralCommand()
{
Command command;
for (uint8_t i = MC_GENERAL_LOW_FENCEPOST + 1; i < MC_GENERAL_HIGH_FENCEPOST; i++)
buffer->AddCommandByte(i);
for (uint8_t i = MC_GENERAL_LOW_FENCEPOST + 1; i < MC_GENERAL_HIGH_FENCEPOST; i++)
{
buffer->GetCommand(command);
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(MC_GENERAL_REG), command.Register());
CPPUNIT_ASSERT_EQUAL(i, command.Action());
CPPUNIT_ASSERT_EQUAL(0, command.Parameter());
}
}