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


C++ Controller::disconnectDevice方法代码示例

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


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

示例1: main

int main(int argc, char* argv[])
{    
    Controller c;

    if (!c.connectDevice(1)) {
        std::cerr << "Connection established" << std::endl;
        return EXIT_FAILURE;
    }
    
    Device *dc = c.getConnectedDevice();
    dc->on(4,4,4);
    dc->on(3,4,4);
    dc->on(4,3,4);
    dc->on(5,4,4);
    dc->on(4,5,4);
    dc->on(3,3,4);
    dc->on(5,5,4);

    std::cout << "DeviceShape on (4,4,4)" << std::endl;
    
    c.display();
    std::cout << "DeviceShape displayed" << std::endl;

    c.disconnectDevice();
    return 0;
}
开发者ID:Oxbern,项目名称:CCube_API,代码行数:26,代码来源:Controller_test.cpp

示例2: send

/*!
 * \brief Sends a message to a device
 * \param c controller
 * \return true if the message was sent properly
 */
bool OutgoingMessage::send(Controller &c)
{
    std::cout << "Outgoing message send \n";
    if (c.getConnectedDevice() == NULL)
        return false;

    LOG(2, "[SEND] Send a message :\n" + this->toStringDebug());

    int n = this->NbBuffers();

    for (int i = 0; i < n; i++) {
        LOG(5, "[SEND] Buffer N° " + std::to_string(i));

        // Convert the buffer i into an array
        uint8_t *bufferArray = new uint8_t[sizeBuffer];
        listBuffer[i].toArray(bufferArray);

        int nbTry = 0;

        do {
            // Send the message to the device
            if (!(c.getConnectedDevice()->writeToFileDescriptor(bufferArray,
                                                                sizeBuffer))) {
                throw ErrorException("Error while sending a message : "
                                     "Number of tries to send "
                                     "the message exceeded");
                c.disconnectDevice();
            } /* Buffer sent */
            LOG(5, "Buffer sent");
            
            // ack, response ?
            if (!c.secure)
                break;
            
        } while (++nbTry < MAX_TRY);

        //If number of tries exceeded
        if (nbTry == MAX_TRY) {
            LOG(2, "[HANDLER] NB TRY EXCEDEED");

            throw ErrorException("Error while receiving a ack: "
                                 "Number of tries to receive "
                                 "the ack exceeded");
        }

        delete [] bufferArray;
    }
    LOG(1, "[SEND] Message sent");
    return true;
}
开发者ID:Oxbern,项目名称:CCube_API,代码行数:55,代码来源:OutgoingMessage.cpp

示例3: main

int main(int argc, char** argv) {
    
    Controller c;
    c.connectDevice(1);
    
    Ball b;
    
    c.getConnectedDevice()->setLedStatus(b);

    for (int i = 0; i < 100; i++) {
        b.action();
        c.getConnectedDevice()->setLedStatus(b);
        
        c.display();
        //nanosleep(TIME, NULL);
        sleep(2);
    }
    c.disconnectDevice();
    return 0;
}
开发者ID:Oxbern,项目名称:CCube_API,代码行数:20,代码来源:Ball_display_test.cpp


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