Example #1
0
QByteArray KoradSCPI::prepareCommandByteArray(
    const std::shared_ptr<SerialCommand> &com)
{
    // First job create the command
    powcon::COMMANDS command = static_cast<powcon::COMMANDS>(com->getCommand());
    if (command == powcon::COMMANDS::GETOVP ||
        command == powcon::COMMANDS::GETOCP)
        return "";
    QString commandString = korcon::SERIALCOMMANDMAP.at(command);
    /*
     * We have four different command types.
     * 1. Command that does something with a channel
     * 2. Command that does something with a channel and a value
     * 3. Command that does something with a value
     * 4. Command that does something
     */
    if (commandString.indexOf("%") > 0) {
        if (com->getPowerSupplyChannel() == 0) {
            commandString = commandString.arg(com->getValue().toString());
        } else {
            com->getValue().isNull() == true
                ? commandString = commandString.arg(com->getPowerSupplyChannel())
                : commandString = commandString.arg(com->getPowerSupplyChannel())
                                      .arg(com->getValue().toString());
        }
    }

    LogInstance::get_instance().eal_debug("Command string: " +
                                          commandString.toStdString());

    QByteArray commandByte = commandString.toLocal8Bit();
    return commandByte;
}
std::vector<std::shared_ptr<MediaSink>>
                                     MediaElementImpl::getMediaSinks (std::shared_ptr<MediaType> mediaType)
{
  std::vector<std::shared_ptr<MediaSink>> sinks;

  if (mediaType->getValue() == MediaType::AUDIO) {
    sinks.push_back (getOrCreateAudioMediaSink() );
  } else if (mediaType->getValue() == MediaType::VIDEO) {
    sinks.push_back (getOrCreateVideoMediaSink() );
  }

  return sinks;
}
Example #3
0
void NovelLayer::playDelay(std::shared_ptr<NovelAction> action) {
    const float delayTime = ::atof(action->getValue().c_str());
    int actionIdx = beginAction();
    runAction(Sequence::create(DelayTime::create(delayTime),
                               CallFunc::create([this, actionIdx]() { this->completeAction(actionIdx); }),
                               NULL));
}
Example #4
0
void MixerImpl::disconnect (std::shared_ptr<MediaType> media,
                            std::shared_ptr<HubPort> source, std::shared_ptr<HubPort> sink)
{
  std::shared_ptr<HubPortImpl> sourcePort =
    std::dynamic_pointer_cast<HubPortImpl> (source);
  std::shared_ptr<HubPortImpl> sinkPort =
    std::dynamic_pointer_cast<HubPortImpl> (sink);
  std::string  action;
  bool connected;

  switch (media->getValue() ) {
  case MediaType::AUDIO:
    action = "disconnect-audio";
    break;

  case MediaType::VIDEO:
    throw KurentoException (UNSUPPORTED_MEDIA_TYPE,
                            "Video disconnection is not implemented yet");

  default:
    /* Only audio is suppported so far */
    throw KurentoException (UNSUPPORTED_MEDIA_TYPE, "Invalid media type");
  };

  g_signal_emit_by_name (G_OBJECT (element), action.c_str(),
                         sourcePort->getHandlerId(),
                         sinkPort->getHandlerId(),
                         &connected);

  if (!connected) {
    throw KurentoException (CONNECT_ERROR, "Can not connect video ports");
  }
}
void DeviceWizardConnection::dataAvailable(
    std::shared_ptr<SerialCommand> command)
{
    if (static_cast<PowerSupplySCPI_constants::COMMANDS>(
            command->getCommand()) ==
        PowerSupplySCPI_constants::COMMANDS::GETIDN) {
        QString idString = command->getValue().toString();
        this->devID = idString;
        if (idString == "") {
            QString statustext =
                "Connection successfull but Device send back "
                "an empty identification String. Check the "
                "chosen protocol and port.";
            this->txt->appendPlainText(statustext);
            this->connectionSuccessfull = false;
            emit this->completeChanged();
        } else {
            QString statustext = "Connection successfull";
            this->txt->appendPlainText(statustext);
            statustext = "Device identified as " + idString;
            this->txt->appendPlainText(statustext);
            this->connectionSuccessfull = true;
            emit this->completeChanged();
        }
        this->startTest->setDisabled(false);
        this->powerSupplyConnector->stopPowerSupplyBackgroundThread();
        if (!this->t->wait(3000)) {
            LogInstance::get_instance().eal_warn(
                "Thread timeout while waiting for data");
        }
    }
}
Example #6
0
static GstDebugGraphDetails
convert_details (std::shared_ptr<GstreamerDotDetails> details)
{
  switch (details->getValue() ) {
  case GstreamerDotDetails::SHOW_MEDIA_TYPE:
    return GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE;

  case GstreamerDotDetails::SHOW_CAPS_DETAILS:
    return GST_DEBUG_GRAPH_SHOW_CAPS_DETAILS;

  case GstreamerDotDetails::SHOW_NON_DEFAULT_PARAMS:
    return GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS;

  case GstreamerDotDetails::SHOW_STATES:
    return GST_DEBUG_GRAPH_SHOW_STATES;

  case GstreamerDotDetails::SHOW_FULL_PARAMS:
    return GST_DEBUG_GRAPH_SHOW_FULL_PARAMS;

  case GstreamerDotDetails::SHOW_ALL:
    return GST_DEBUG_GRAPH_SHOW_ALL;

  case GstreamerDotDetails::SHOW_VERBOSE:
  default:
    return GST_DEBUG_GRAPH_SHOW_VERBOSE;
  }
}
Example #7
0
File: url.cpp Project: burner/vmime
const string url::build() const
{
	std::ostringstream oss;
	oss.imbue(std::locale::classic());

	oss << m_protocol << "://";

	if (!m_username.empty())
	{
		oss << urlUtils::encode(m_username);

		if (!m_password.empty())
		{
			oss << ":";
			oss << urlUtils::encode(m_password);
		}

		oss << "@";
	}

	oss << urlUtils::encode(m_host);

	if (m_port != UNSPECIFIED_PORT)
	{
		oss << ":";
		oss << m_port;
	}

	if (!m_path.empty())
	{
		oss << "/";
		oss << urlUtils::encode(m_path);
	}

	const std::vector <std::shared_ptr<const propertySet::property> > params
		= m_params.getPropertyList();

	if (!params.empty())
	{
		if (m_path.empty())
			oss << "/";

		oss << "?";

		for (unsigned int i = 0 ; i < params.size() ; ++i)
		{
			const std::shared_ptr<const propertySet::property> prop = params[i];

			if (i != 0)
				oss << "&";

			oss << urlUtils::encode(prop->getName());
			oss << "=";
			oss << urlUtils::encode(prop->getValue());
		}
	}

	return (oss.str());
}
void MultiThreadingDispatcher::dispatch(const renderer::RenderContext& context,
		std::shared_ptr<util::IProgressHandler> progress) {
	auto tiles = context.tile_set->getRequiredCompositeTiles();
	if (tiles.size() == 0)
		return;

	int jobs = 0;
	for (auto tile_it = tiles.begin(); tile_it != tiles.end(); ++tile_it)
		if (tile_it->getDepth() == context.tile_set->getDepth() - 2) {
			renderer::RenderWork work;
			work.tiles.insert(*tile_it);
			manager.addWork(work);
			jobs++;
		}

	int render_tiles = context.tile_set->getRequiredRenderTilesCount();
	std::cout << thread_count << " threads will render " << render_tiles;
	std::cout << " render tiles." << std::endl;

	for (int i = 0; i < thread_count; i++)
		threads.push_back(std::thread(ThreadWorker(manager, context)));

	progress->setMax(context.tile_set->getRequiredRenderTilesCount());
	renderer::RenderWorkResult result;
	while (manager.getResult(result)) {
		progress->setValue(progress->getValue() + result.tiles_rendered);
		for (auto tile_it = result.render_work.tiles.begin();
				tile_it != result.render_work.tiles.end(); ++tile_it) {
			rendered_tiles.insert(*tile_it);
			if (*tile_it == renderer::TilePath()) {
				manager.setFinished();
				continue;
			}

			renderer::TilePath parent = tile_it->parent();
			bool childs_rendered = true;
			for (int i = 1; i <= 4; i++)
				if (context.tile_set->isTileRequired(parent + i)
						&& !rendered_tiles.count(parent + i)) {
					childs_rendered = false;
				}

			if (childs_rendered) {
				renderer::RenderWork work;
				work.tiles.insert(parent);
				for (int i = 1; i <= 4; i++)
					if (context.tile_set->hasTile(parent + i))
						work.tiles_skip.insert(parent + i);
				manager.addExtraWork(work);
			}
		}
	}

	for (int i = 0; i < thread_count; i++)
		threads[i].join();
}
void
MediaElementImpl::connect (std::shared_ptr< MediaElement > sink,
                           std::shared_ptr< MediaType > mediaType)
{
  std::shared_ptr<MediaElementImpl> sinkImpl =
    std::dynamic_pointer_cast<MediaElementImpl> (sink);

  if (mediaType->getValue() == MediaType::AUDIO) {
    std::shared_ptr<MediaSource> audio_src = getOrCreateAudioMediaSrc();
    std::shared_ptr<MediaSink> audio_sink = sinkImpl->getOrCreateAudioMediaSink();

    audio_src->connect (audio_sink);
  } else if (mediaType->getValue() == MediaType::VIDEO) {
    std::shared_ptr<MediaSource> video_src = getOrCreateVideoMediaSrc();
    std::shared_ptr<MediaSink> video_sink = sinkImpl->getOrCreateVideoMediaSink();

    video_src->connect (video_sink);
  }
}
HttpGetEndpointImpl::HttpGetEndpointImpl (
  const boost::property_tree::ptree &conf,
  std::shared_ptr<MediaPipeline> mediaPipeline, bool terminateOnEOS,
  std::shared_ptr<MediaProfileSpecType> mediaProfile,
  int disconnectionTimeout) : HttpEndpointImpl (conf,
        std::dynamic_pointer_cast< MediaObjectImpl > (mediaPipeline),
        disconnectionTimeout, FACTORY_NAME)
{
  g_object_set ( G_OBJECT (element), "accept-eos", terminateOnEOS,
                 NULL);

  switch (mediaProfile->getValue() ) {
  case MediaProfileSpecType::WEBM:
    GST_INFO ("Set WEBM profile");
    g_object_set ( G_OBJECT (element), "profile", KMS_RECORDING_PROFILE_WEBM, NULL);
    break;

  case MediaProfileSpecType::MP4:
    GST_INFO ("Set MP4 profile");
    g_object_set ( G_OBJECT (element), "profile", KMS_RECORDING_PROFILE_MP4, NULL);
    break;

  case MediaProfileSpecType::WEBM_VIDEO_ONLY:
    g_object_set ( G_OBJECT (element), "profile",
                   KMS_RECORDING_PROFILE_WEBM_VIDEO_ONLY, NULL);
    GST_INFO ("Set WEBM profile");
    break;

  case MediaProfileSpecType::WEBM_AUDIO_ONLY:
    g_object_set ( G_OBJECT (element), "profile",
                   KMS_RECORDING_PROFILE_WEBM_AUDIO_ONLY, NULL);
    GST_INFO ("Set WEBM profile");
    break;

  case MediaProfileSpecType::MP4_VIDEO_ONLY:
    g_object_set ( G_OBJECT (element), "profile",
                   KMS_RECORDING_PROFILE_MP4_VIDEO_ONLY, NULL);
    GST_INFO ("Set WEBM profile");
    break;

  case MediaProfileSpecType::MP4_AUDIO_ONLY:
    g_object_set ( G_OBJECT (element), "profile",
                   KMS_RECORDING_PROFILE_MP4_AUDIO_ONLY, NULL);
    GST_INFO ("Set WEBM profile");
    break;
  }

  register_end_point();

  if (!is_registered() ) {
    throw KurentoException (HTTP_END_POINT_REGISTRATION_ERROR,
                            "Cannot register HttpGetEndPoint");
  }
}
Example #11
0
void NovelLayer::setNameImage(std::shared_ptr<NovelAction> action)
{
    auto name = action->getValue();
    auto target = action->getTarget();
    LanguageType curLanguage = UserDataManager::getInstance()->getLanguage();
    if (target == NovelAction::Target::Left) {
        if (_leftNameImage == NULL) {
            _leftNameImage = Sprite::create("chat/ui/name_rect.png");
            _leftNameImage->setAnchorPoint(Vec2::ZERO);
            _leftNameImage->setPosition(Vec2(20, 20));
            _leftNode->addChild(_leftNameImage, 11);
            auto nameImageSize = _leftNameImage->getContentSize();
            Label* label1;
            if (curLanguage == LanguageType::CHINESE) {
                label1 = Label::createWithTTF(name.c_str(), "font/simiyo.ttf", 30);
            } else {
                label1 = Label::createWithTTF(name.c_str(), "font/yasashisa.ttf", 30);

            }
            label1->setName("label");
            label1->setColor(Color3B::WHITE);
            label1->setAnchorPoint(Vec2(0.5f, 0.5f));
            label1->setPosition(Vec2(nameImageSize.width / 2, nameImageSize.height / 2));
            _leftNameImage->addChild(label1);
        } else {
            auto label = (Label*)_leftNameImage->getChildByName("label");
            label->setString(name);
        }
    } else if (target == NovelAction::Target::Right) {
        if (_rightNameImage == NULL) {
            _rightNameImage = Sprite::create("chat/ui/name_rect.png");
            _rightNameImage->setAnchorPoint(Vec2(1, 0));
            _rightNameImage->setPosition(Vec2(-20, 20));
            _rightNode->addChild(_rightNameImage, 11);
            auto nameImageSize = _rightNameImage->getContentSize();
            Label* label1;
            if (curLanguage == LanguageType::CHINESE) {
                label1 = Label::createWithTTF(name.c_str(), "font/simiyo.ttf", 30);
            } else {
                label1 = Label::createWithTTF(name.c_str(), "font/yasashisa.ttf", 30);
                
            }
            label1->setName("label");
            label1->setAnchorPoint(Vec2(0.5, 0.5f));
            label1->setColor(Color3B::WHITE);
            label1->setPosition(Vec2(nameImageSize.width / 2, nameImageSize.height / 2));
            _rightNameImage->addChild(label1);
        } else {
            auto label = (Label*)_rightNameImage->getChildByName("label");
            label->setString(name);
        }
    }
}
Example #12
0
void terrama2::core::TeDataSetFKJoin::fillPKMap(std::string referredPropertyName, std::shared_ptr<te::da::DataSet> referredDataSet)
{
  for (size_t i = 0; i < referredDataSet->size(); i++) {
    referredDataSet->move(i);

    std::unique_ptr<te::dt::AbstractData> val(referredDataSet->getValue(referredPropertyName));
    if(val)
      _referredPKMap.emplace(val->toString(), i);
    else
    {
      QString errMsg = QObject::tr("Invalid property: %1.").arg(QString::fromStdString(referredPropertyName));
      TERRAMA2_LOG_ERROR() << errMsg;
      throw Exception() << ErrorDescription(errMsg);
    }
  }
}
Example #13
0
/** \brief Show clicked event in event table widged
 * \param [in] r Clicked row
 * \param [in] c Clicked column
 */
void LogAnalyser::showEventInEventTableWidged(int r,int c)
{
    const auto event = xmlParser->getEventsContainer()->getEvent(r);

    for(auto i = 0; i < event->getLength(); i++){
        const std::shared_ptr<XmlElement> xmlElement = event->getXmlElement(i);
        ui->tableEvent->setRowCount(i+1);
        ui->tableEvent->setItem(i,0, new QTableWidgetItem(xmlElement->getTag()));
        ui->tableEvent->setItem(i,1, new QTableWidgetItem(xmlElement->getValue()));
        ui->tableEvent->resizeRowToContents(i);
        ui->tableEvent->horizontalHeader()->setStretchLastSection(true);
        ui->tableEvent->item(i,0)->setBackgroundColor(xmlElement->getBackroundColor());
        ui->tableEvent->item(i,0)->setTextColor(xmlElement->getFontColor());
        ui->tableEvent->item(i,1)->setBackgroundColor(xmlElement->getBackroundColor());
        ui->tableEvent->item(i,1)->setTextColor(xmlElement->getFontColor());
    }
}
std::string MediaPipelineImpl::getGstreamerDot (
  std::shared_ptr<GstreamerDotDetails> details)
{
  switch (details->getValue() ) {
  case GstreamerDotDetails::SHOW_MEDIA_TYPE:
    return generateDotGraph (GST_BIN (pipeline), GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE);

  case GstreamerDotDetails::SHOW_CAPS_DETAILS:
    return generateDotGraph (GST_BIN (pipeline), GST_DEBUG_GRAPH_SHOW_CAPS_DETAILS);

  case GstreamerDotDetails::SHOW_NON_DEFAULT_PARAMS:
    return generateDotGraph (GST_BIN (pipeline),
                             GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS);

  case GstreamerDotDetails::SHOW_STATES:
    return generateDotGraph (GST_BIN (pipeline), GST_DEBUG_GRAPH_SHOW_STATES);

  case GstreamerDotDetails::SHOW_ALL:
  default:
    return generateDotGraph (GST_BIN (pipeline), GST_DEBUG_GRAPH_SHOW_ALL);
  }
}
Example #15
0
        NoiseTexture2D::NoiseTexture2D(TextureDescriptor const& descriptor, std::shared_ptr<Math::Noise::ANoise> noise, uint32_t xOffset, uint32_t yOffset)
            : Texture2D(descriptor)
        {
            uint32_t numPixels = descriptor.width * descriptor.height;
            float pixelColor = 0.0f;

            for(uint32_t y = 0; y < descriptor.height; y++)
            {
                for(uint32_t x = 0; x <descriptor.width; x++)
                {
                    if(noise)
                    {
                        // Noise methods return on range [-1.0, 1.0] but we want [0.0, 1.0]
                        pixelColor = (noise->getValue(static_cast<float>(x + xOffset), static_cast<float>(y + yOffset)) + 1.0f) * 0.5f;
                    }

                    m_Pixels[(y * descriptor.width) + x] = Core::Color(pixelColor, pixelColor, pixelColor, 1.0f);
                }
            }

            m_IsInMemory = true;
        }
Example #16
0
	camera->setValue("ViewportSize", viewport);
	camera->setValue("AmbientColor", SurgSim::Math::Vector4d(0.1, 0.2, 0.3, 0.4));
	camera->setViewport(10, 20, 30, 50);

	// Serialize.
	YAML::Node node;
	EXPECT_NO_THROW(node = YAML::convert<SurgSim::Framework::Component>::encode(*camera););

	// Deserialize.
	std::shared_ptr<Camera> newCamera;
	newCamera = std::dynamic_pointer_cast<OsgCamera>(node.as<std::shared_ptr<SurgSim::Framework::Component>>());
	EXPECT_NE(nullptr, newCamera);

	// Verify.
	EXPECT_TRUE(boost::any_cast<SurgSim::Math::Matrix44d>(camera->getValue("ProjectionMatrix")).isApprox(
					boost::any_cast<SurgSim::Math::Matrix44d>(newCamera->getValue("ProjectionMatrix"))));

	typedef std::array<double, 2> ParamType;
	EXPECT_TRUE(boost::any_cast<ParamType>(camera->getValue("ViewportSize")) ==
				boost::any_cast<ParamType>(newCamera->getValue("ViewportSize")));

	EXPECT_TRUE(boost::any_cast<SurgSim::Math::Vector4d>(camera->getValue("AmbientColor")).isApprox(
					boost::any_cast<SurgSim::Math::Vector4d>(newCamera->getValue("AmbientColor"))));
}

TEST(OsgCameraTests, SetProjection)
{
	std::shared_ptr<OsgCamera> camera = std::make_shared<OsgCamera>("TestOsgCamera");

	Math::Matrix44d identity = Math::Matrix44d::Identity();
Example #17
0
	yks::vec3 diffuse_brdf(const Intersection& i, const yks::vec3 /*in_dir*/, const yks::vec3 /*out_dir*/) const {
		return diffuse->getValue(i) * (1.0f / yks::pi);
	}
Example #18
0
 int getValue(){
   return _element->getValue();
 }
Example #19
0
void scope_test(std::shared_ptr<Base> base)
{
  std::cout << base->getValue() << std::endl;
  std::cout << "scope test ..." << std::endl;
}
Example #20
0
 bool operator() (const std::shared_ptr<MediaType> &a,
                  const std::shared_ptr<MediaType> &b) const
 {
   return a->getValue () < b->getValue ();
 }
RecorderEndpointImpl::RecorderEndpointImpl (const boost::property_tree::ptree
    &conf,
    std::shared_ptr<MediaPipeline> mediaPipeline, const std::string &uri,
    std::shared_ptr<MediaProfileSpecType> mediaProfile,
    bool stopOnEndOfStream) : UriEndpointImpl (conf,
          std::dynamic_pointer_cast<MediaObjectImpl> (mediaPipeline), FACTORY_NAME, uri)
{
  g_object_set (G_OBJECT (getGstreamerElement() ), "accept-eos",
                stopOnEndOfStream, NULL);

  switch (mediaProfile->getValue() ) {
  case MediaProfileSpecType::WEBM:
    g_object_set ( G_OBJECT (element), "profile", KMS_RECORDING_PROFILE_WEBM, NULL);
    GST_INFO ("Set WEBM profile");
    break;

  case MediaProfileSpecType::MP4:
    g_object_set ( G_OBJECT (element), "profile", KMS_RECORDING_PROFILE_MP4, NULL);
    GST_INFO ("Set MP4 profile");
    break;

  case MediaProfileSpecType::WEBM_VIDEO_ONLY:
    g_object_set ( G_OBJECT (element), "profile",
                   KMS_RECORDING_PROFILE_WEBM_VIDEO_ONLY, NULL);
    GST_INFO ("Set WEBM VIDEO ONLY profile");
    break;

  case MediaProfileSpecType::WEBM_AUDIO_ONLY:
    g_object_set ( G_OBJECT (element), "profile",
                   KMS_RECORDING_PROFILE_WEBM_AUDIO_ONLY, NULL);
    GST_INFO ("Set WEBM AUDIO ONLY profile");
    break;

  case MediaProfileSpecType::MP4_VIDEO_ONLY:
    g_object_set ( G_OBJECT (element), "profile",
                   KMS_RECORDING_PROFILE_MP4_VIDEO_ONLY, NULL);
    GST_INFO ("Set MP4 VIDEO ONLY profile");
    break;

  case MediaProfileSpecType::MP4_AUDIO_ONLY:
    g_object_set ( G_OBJECT (element), "profile",
                   KMS_RECORDING_PROFILE_MP4_AUDIO_ONLY, NULL);
    GST_INFO ("Set MP4 AUDIO ONLY profile");
    break;

  case MediaProfileSpecType::JPEG_VIDEO_ONLY:
    g_object_set ( G_OBJECT (element), "profile",
                   KMS_RECORDING_PROFILE_JPEG_VIDEO_ONLY, NULL);
    GST_INFO ("Set JPEG profile");
    break;

  case MediaProfileSpecType::KURENTO_SPLIT_RECORDER:
    if (!RecorderEndpointImpl::support_ksr) {
      throw KurentoException (MEDIA_OBJECT_ILLEGAL_PARAM_ERROR,
                              "Kurento Split Recorder not supported");
    }

    g_object_set ( G_OBJECT (element), "profile", KMS_RECORDING_PROFILE_KSR, NULL);
    GST_INFO ("Set KSR profile");
    break;
  }
}
GStreamerFilterImpl::GStreamerFilterImpl (const boost::property_tree::ptree
    &conf, std::shared_ptr<MediaPipeline>
    mediaPipeline, const std::string &command,
    std::shared_ptr<FilterType> filterType) : FilterImpl (conf,
          std::dynamic_pointer_cast<MediaObjectImpl> ( mediaPipeline) )
{
  GstElement *filter, *filter_check;
  GError *error = NULL;

  this->cmd = command;

  GST_DEBUG ("Command %s", command.c_str() );

  switch (filterType->getValue() ) {
  case FilterType::VIDEO:
    g_object_set (element, "type", 2, NULL);
    break;

  case FilterType::AUDIO:
    g_object_set (element, "type", 1, NULL);
    break;

  case FilterType::AUTODETECT:
    g_object_set (element, "type", 0, NULL);
    break;

  default:
    break;
  }

  filter = gst_parse_launch (command.c_str(), &error);

  if (filter == NULL || error != NULL) {
    std::string error_str = "GStreamer filter cannot be created";

    if (filter) {
      g_object_unref (filter);
    }

    if (error != NULL) {
      if (error->message != NULL) {
        error_str += ": " + std::string (error->message);
      }

      g_error_free (error);
    }

    throw KurentoException (MARSHALL_ERROR, error_str);
  } else if (GST_IS_BIN (filter) ) {
    g_object_unref (filter);

    throw KurentoException (MARSHALL_ERROR,
                            "Given command is not valid, just one element can be created");
  }

  g_object_set (element, "filter", filter, NULL);

  g_object_get (element, "filter", &filter_check, NULL);

  if (filter_check != filter) {
    g_object_unref (filter);
    g_object_unref (filter_check);

    throw KurentoException (MARSHALL_ERROR,
                            "Given command is not valid, pad templates does not match");
  }

  g_object_unref (filter);
  g_object_unref (filter_check);
}
Example #23
0
void KoradSCPI::processCommands(const std::shared_ptr<PowerSupplyStatus> &status,
                                const std::shared_ptr<SerialCommand> &com)
{
    LogInstance::get_instance().eal_debug("Processing command " +
                                          std::to_string(com->getCommand()));
    LogInstance::get_instance().eal_debug(
        "Command value" + com->getValue().toString().toStdString());
    if (com->getCommand() == powcon::COMMANDS::GETSTATUS) {
        /*
         * Decoding the Korad Status Byte is pretty simple.
         * MSB -> LSB
         * 7   not defined
         * 6   Output
         * 5   Lock
         * 4   Beep
         * 2,3 Channel Tracking Mode
         * 1   CH2 CC|CV mode
         * 0   CH1 CC|CV mode
         */
        QByteArray val = com->getValue().toByteArray();
        LogInstance::get_instance().eal_debug("Korad Status byte: " +
                                              val.toStdString());
        // Unfortunately Korad SCPI does not seem to be able to determine
        // between different channels regarding output setting.
        if (val[0] & (1 << 6)) {
            for (int i = 1; i <= this->noOfChannels; i++) {
                status->setChannelOutput(std::make_pair(i, true));
            }
        } else {
            for (int i = 1; i <= this->noOfChannels; i++) {
                status->setChannelOutput(std::make_pair(i, false));
            }
        }
        if (val[0] & (1 << 5)) {
            status->setLocked(true);
        }
        if (val[0] & (1 << 4)) {
            status->setBeeper(true);
        }

        // TODO: Add check for tracking mode

        if (val[0] & (1 << 1)) {
            status->setChannelMode(
                std::make_pair(2, globcon::LPQ_MODE::CONSTANT_VOLTAGE));
        } else {
            status->setChannelMode(
                std::make_pair(2, globcon::LPQ_MODE::CONSTANT_CURRENT));
        }
        if (val[0] & (1 << 0)) {
            status->setChannelMode(
                std::make_pair(1, globcon::LPQ_MODE::CONSTANT_VOLTAGE));
        } else {
            status->setChannelMode(
                std::make_pair(1, globcon::LPQ_MODE::CONSTANT_CURRENT));
        }
    }

    if (com->getCommand() == powcon::COMMANDS::GETIDN) {
        QString val = com->getValue().toString();
    }

    if (com->getCommand() == powcon::COMMANDS::GETCURRENTSET) {
        QString val = com->getValue().toString();

        // strangely current values seem to end with a "K". Therefor it is not
        // possible to get a double with toDouble() directly. This fimrware is
        // really buggy.
        if (val.endsWith("K", Qt::CaseSensitivity::CaseInsensitive)) {
            val = val.left(val.length() - 1);
            com->setValue(std::move(val));
        }
    }

    if (com->getCommand() == powcon::COMMANDS::GETCURRENT) {
        if (status)
            status->setCurrent(std::make_pair(com->getPowerSupplyChannel(),
                                              com->getValue().toDouble()));
    }

    if (com->getCommand() == powcon::COMMANDS::GETVOLTAGESET) {
    }

    if (com->getCommand() == powcon::COMMANDS::GETVOLTAGE) {
        if (status)
            status->setVoltage(std::make_pair(com->getPowerSupplyChannel(),
                                              com->getValue().toDouble()));
    }
}
Example #24
0
void NovelLayer::setImage(std::shared_ptr<NovelAction> action)
{
    auto visibleSize = Director::getInstance()->getVisibleSize();
    auto value = action->getValue();
    auto imageName = action->getValue();
    auto target = action->getTarget();
    auto effect = action->getValue2();
    if (target == NovelAction::Target::Left) {
        imageName = StringUtils::format("chat/character/chat_%s.png", imageName.c_str());
        if (_leftChara == NULL) {
            _leftNode = Node::create();
            _leftNode->setPosition(Vec2(0, 0));
            _leftChara = Sprite::create(imageName);
            _leftChara->setAnchorPoint(Vec2(0, 0));
            _leftChara->setPosition(Vec2(20, 50));
            addChild(_leftNode);
            _leftNode->addChild(_leftChara);
        } else {
            if (value == "remove") {
                _leftNameImage->removeFromParent();
                _leftNameImage = NULL;
                _leftChara->removeFromParent();
                _leftChara = NULL;
                _leftBalloon->removeFromParent();
                _leftBalloon = NULL;
                _leftNode->removeFromParent();
                _leftNode = NULL;
            } else {
                _leftChara->setTexture(imageName);
            }
        }
    } else if (target == NovelAction::Target::Right) {
        imageName = StringUtils::format("chat/character/chat_%s.png", imageName.c_str());
        if (_rightChara == NULL) {
            _rightNode = Node::create();
            _rightNode->setPosition(Vec2(visibleSize.width, 0));
            _rightChara = Sprite::create(imageName);
            _rightChara->setAnchorPoint(Vec2(1, 0));
            _rightChara->setPosition(Vec2(-20, 50));
            addChild(_rightNode);
            _rightNode->addChild(_rightChara);
        } else {
            if (value == "remove") {
                _rightNameImage->removeFromParent();
                _rightNameImage = NULL;
                _rightChara->removeFromParent();
                _rightChara = NULL;
                _rightBalloon->removeFromParent();
                _rightBalloon = NULL;
                _rightNode->removeFromParent();
                _rightNode = NULL;
            } else {
                _rightChara->setTexture(imageName);
            }
        }
    } else if (target == NovelAction::Target::Background) {
        if (value == "remove") {
            if (effect == "nextPage") {
                _backGroundImage->runAction(Sequence::create(
                    PageTurn3D::create(0.6f, Size(100, 100)),
                    RemoveSelf::create(),
                    NULL
                ));
            } else if (effect == "fade") {
                _backGroundImage->runAction(Sequence::create(FadeOut::create(1.0f), RemoveSelf::create(), NULL));
            } else {
                _backGroundImage->removeFromParent();
            }
            _backGroundImage = NULL;
        } else {
            if (_backGroundImage == NULL) {
                auto back = Sprite::create(StringUtils::format("chat/back/%s", imageName.c_str()));
                back->setScale(visibleSize.width/back->getContentSize().width);
                back->setAnchorPoint(Vec2(0, 0));
                back->setPosition(Vec2::ZERO);
                back->setZOrder(-1);
                _backGroundImage = NodeGrid::create();
                _backGroundImage->addChild(back);
                _backGroundImage->setCascadeOpacityEnabled(true);
                addChild(_backGroundImage);
                
            } else {
                clearBalloons();
                
                auto removedImage = _backGroundImage;

                auto back = Sprite::create(StringUtils::format("chat/back/%s", imageName.c_str()));
                back->setScale(visibleSize.width/back->getContentSize().width);
                back->setAnchorPoint(Vec2(0, 0));
                back->setPosition(Vec2::ZERO);
                back->setZOrder(removedImage->getZOrder()-1);
                _backGroundImage = NodeGrid::create();
                _backGroundImage->addChild(back);
                _backGroundImage->setCascadeOpacityEnabled(true);
                addChild(_backGroundImage);
                
                if (effect == "nextPage") {
                    removedImage->runAction(Sequence::create(
                        PageTurn3D::create(0.6f, Size(100, 100)),
                        RemoveSelf::create(),
                        NULL
                    ));
                } else {
                    auto dummyBack = LayerColor::create(Color4B::BLACK, visibleSize.width, visibleSize.height);
                    addChild(dummyBack, -100);
                    dummyBack->runAction(Sequence::create(
                        DelayTime::create(1.0f),
                        RemoveSelf::create(),
                        NULL
                    ));

                    removedImage->runAction(Sequence::create(
                        FadeOut::create(1.0f),
                        RemoveSelf::create(),
                        NULL
                    ));
                
                    _backGroundImage->setOpacity(0);
                    _backGroundImage->runAction(FadeIn::create(1.0f));
                }

            }
        }
    }
}