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


C++ Command::Parameter方法代码示例

本文整理汇总了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());
        }
    }
开发者ID:AllenMcAfee,项目名称:ember-firmware,代码行数:32,代码来源:CommandBufferTest.cpp

示例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());
    }
开发者ID:AllenMcAfee,项目名称:ember-firmware,代码行数:26,代码来源:CommandBufferTest.cpp

示例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());
 }
开发者ID:AllenMcAfee,项目名称:ember-firmware,代码行数:12,代码来源:CommandBufferTest.cpp

示例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());
        }
    }
开发者ID:AllenMcAfee,项目名称:ember-firmware,代码行数:15,代码来源:CommandBufferTest.cpp


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