void FlatBufferClient::handleImageCommand(const hyperionnet::Image *image) { // extract parameters int duration = image->duration(); const void* reqPtr; if ((reqPtr = image->data_as_RawImage()) != nullptr) { const auto *img = static_cast<const hyperionnet::RawImage*>(reqPtr); const auto & imageData = img->data(); const int width = img->width(); const int height = img->height(); if ((int) imageData->size() != width*height*3) { sendErrorReply("Size of image data does not match with the width and height"); return; } Image<ColorRgb> image(width, height); memmove(image.memptr(), imageData->data(), imageData->size()); _hyperion->setInputImage(_priority, image, duration); } // send reply sendSuccessReply(); }
void JsonClientConnection::handleImageCommand(const Json::Value &message) { // extract parameters int priority = message["priority"].asInt(); int duration = message.get("duration", -1).asInt(); int width = message["imagewidth"].asInt(); int height = message["imageheight"].asInt(); QByteArray data = QByteArray::fromBase64(QByteArray(message["imagedata"].asCString())); // check consistency of the size of the received data if (data.size() != width*height*3) { sendErrorReply("Size of image data does not match with the width and height"); return; } // set width and height of the image processor _imageProcessor->setSize(width, height); // create ImageRgb Image<ColorRgb> image(width, height); memcpy(image.memptr(), data.data(), data.size()); // process the image std::vector<ColorRgb> ledColors = _imageProcessor->process(image); _hyperion->setColors(priority, ledColors, duration); // send reply sendSuccessReply(); }
void ProtoClientConnection::handleImageCommand(const proto::ImageRequest &message) { // extract parameters int priority = message.priority(); int duration = message.has_duration() ? message.duration() : -1; int width = message.imagewidth(); int height = message.imageheight(); const std::string & imageData = message.imagedata(); // check consistency of the size of the received data if ((int) imageData.size() != width*height*3) { sendErrorReply("Size of image data does not match with the width and height"); return; } // set width and height of the image processor _imageProcessor->setSize(width, height); // create ImageRgb Image<ColorRgb> image(width, height); memcpy(image.memptr(), imageData.c_str(), imageData.size()); // process the image std::vector<ColorRgb> ledColors = _imageProcessor->process(image); _hyperion->setColors(priority, ledColors, duration); // send reply sendSuccessReply(); }
void ProtoClientConnection::handleClearallCommand() { // clear priority _hyperion->clearall(); // send reply sendSuccessReply(); }
void JsonClientConnection::handleClearallCommand(const Json::Value &) { // clear priority _hyperion->clearall(); // send reply sendSuccessReply(); }
void ProtoClientConnection::handleClearCommand(const proto::ClearRequest &message) { // extract parameters int priority = message.priority(); // clear priority _hyperion->clear(priority); // send reply sendSuccessReply(); }
void JsonClientConnection::handleClearCommand(const Json::Value &message) { // extract parameters int priority = message["priority"].asInt(); // clear priority _hyperion->clear(priority); // send reply sendSuccessReply(); }
void JsonClientConnection::handleColorCommand(const Json::Value &message) { // extract parameters int priority = message["priority"].asInt(); int duration = message.get("duration", -1).asInt(); ColorRgb color = {uint8_t(message["color"][0u].asInt()), uint8_t(message["color"][1u].asInt()), uint8_t(message["color"][2u].asInt())}; // set output _hyperion->setColor(priority, color, duration); // send reply sendSuccessReply(); }
void FlatBufferClient::handleColorCommand(const hyperionnet::Color *colorReq) { // extract parameters const int32_t rgbData = colorReq->data(); ColorRgb color; color.red = qRed(rgbData); color.green = qGreen(rgbData); color.blue = qBlue(rgbData); // set output _hyperion->setColor(_priority, color, colorReq->duration()); // send reply sendSuccessReply(); }
void JsonClientConnection::handleTransformCommand(const Json::Value &message) { const Json::Value & transform = message["transform"]; if (transform.isMember("saturationGain")) { _hyperion->setTransform(Hyperion::SATURATION_GAIN, Hyperion::INVALID, transform["saturationGain"].asDouble()); } if (transform.isMember("valueGain")) { _hyperion->setTransform(Hyperion::VALUE_GAIN, Hyperion::INVALID, transform["valueGain"].asDouble()); } if (transform.isMember("threshold")) { const Json::Value & threshold = transform["threshold"]; _hyperion->setTransform(Hyperion::THRESHOLD, Hyperion::RED, threshold[0u].asDouble()); _hyperion->setTransform(Hyperion::THRESHOLD, Hyperion::GREEN, threshold[1u].asDouble()); _hyperion->setTransform(Hyperion::THRESHOLD, Hyperion::BLUE, threshold[2u].asDouble()); } if (transform.isMember("gamma")) { const Json::Value & threshold = transform["gamma"]; _hyperion->setTransform(Hyperion::GAMMA, Hyperion::RED, threshold[0u].asDouble()); _hyperion->setTransform(Hyperion::GAMMA, Hyperion::GREEN, threshold[1u].asDouble()); _hyperion->setTransform(Hyperion::GAMMA, Hyperion::BLUE, threshold[2u].asDouble()); } if (transform.isMember("blacklevel")) { const Json::Value & threshold = transform["blacklevel"]; _hyperion->setTransform(Hyperion::BLACKLEVEL, Hyperion::RED, threshold[0u].asDouble()); _hyperion->setTransform(Hyperion::BLACKLEVEL, Hyperion::GREEN, threshold[1u].asDouble()); _hyperion->setTransform(Hyperion::BLACKLEVEL, Hyperion::BLUE, threshold[2u].asDouble()); } if (transform.isMember("whitelevel")) { const Json::Value & threshold = transform["whitelevel"]; _hyperion->setTransform(Hyperion::WHITELEVEL, Hyperion::RED, threshold[0u].asDouble()); _hyperion->setTransform(Hyperion::WHITELEVEL, Hyperion::GREEN, threshold[1u].asDouble()); _hyperion->setTransform(Hyperion::WHITELEVEL, Hyperion::BLUE, threshold[2u].asDouble()); } sendSuccessReply(); }
void ProtoClientConnection::handleColorCommand(const proto::ColorRequest &message) { // extract parameters int priority = message.priority(); int duration = message.has_duration() ? message.duration() : -1; ColorRgb color; color.red = qRed(message.rgbcolor()); color.green = qGreen(message.rgbcolor()); color.blue = qBlue(message.rgbcolor()); // set output _hyperion->setColor(priority, color, duration); // send reply sendSuccessReply(); }
void FlatBufferClient::handleClearCommand(const hyperionnet::Clear *clear) { // extract parameters const int priority = clear->priority(); if (priority == -1) { _hyperion->clearall(); } else { // Check if we are clearing ourselves. if (priority == _priority) { _priority = -1; } _hyperion->clear(priority); } sendSuccessReply(); }