Example #1
0
	int HALService::main(const std::vector<std::string>& args) {
		if (help) {
			return EXIT_OK;
		}

		TBS::initLogs("hal", 4);

		std::cout << "-----------" << std::endl;
		std::cout << "HAL Service json" << std::endl;
		std::cout << "-----------" << std::endl;

		std::cout << "use BioRadar: " << (configuration.useBioRadar ? 1 : 0) << std::endl;
		std::cout << "use Manipulator: " << (configuration.useManipulator ? 1 : 0) << " port1: " << configuration.manipulatorJoint1Port << " port2: " << configuration.manipulatorJoint2Port << std::endl;
		std::cout << "-----------" << std::endl;


		std::cout << std::endl;

		{
			MBot::IHALFactory::Ptr f;

			if (virtualMode) {
				throw Poco::Exception("Cannot run virtual mode - not implemented");
				//f = new MBot::VirtualHALFactory();
			} else {
				f = new MBot::HALFactory(configuration.manipulatorJoint1Port, configuration.manipulatorJoint2Port);
			}

			TBS::Services::JsonServerParams bp(HAL::API::Communication::BioRadarPort);
			HAL::API::BioRadar::Json::Server::Ptr bioRadarSrv = HAL::API::BioRadar::Json::Server::createJsonServer(bp);

			TBS::Services::JsonServerParams cp(HAL::API::Communication::CameraPort);
			HAL::API::Camera::Json::Server::Ptr cameraSrv = HAL::API::Camera::Json::Server::createJsonServer(cp);

			TBS::Services::JsonServerParams ma(HAL::API::Communication::ManipulatorPort);
			HAL::API::Manipulator::Json::Server::Ptr manipSrv = HAL::API::Manipulator::Json::Server::createJsonServer(ma);
			{

				TBS::Services::IServer::Ptr camera = cameraSrv->createCamera(f->createCamera());

				TBS::Services::IServer::Ptr bioRadar;

				if (configuration.useBioRadar) {
					bioRadar = bioRadarSrv->createBioRadar(f->createBioRadar());
				}

				TBS::Services::IServer::Ptr manip;
				if (configuration.useManipulator) {
					manip = manipSrv->createManipulator(f->createManipulator());
				}
				cameraSrv->start();

				if (bioRadar) {
					bioRadarSrv->start();
				}
				if (manip) {
					manipSrv->start();
				}

				waitForTerminationRequest();

				cameraSrv->stop();

				if (bioRadar) {
					bioRadarSrv->stop();
				}
				if (manip) {
					manipSrv->stop();
				}
			}
		}

		std::cout << std::endl;
		std::cout << std::endl;

		std::cout << "-----------" << std::endl;
		std::cout << "HAL Service finished" << std::endl;
		std::cout << "-----------" << std::endl;

		return EXIT_OK;
	}
Example #2
0
void ScoreView::elementPropertyAction(const QString& cmd, Element* e)
      {
      if (cmd == "a-props") {
            ArticulationProperties rp(static_cast<Articulation*>(e));
            rp.exec();
            }
      else if (cmd == "b-props") {
            Bend* bend = static_cast<Bend*>(e);
            BendProperties bp(bend, 0);
            if (bp.exec())
                  score()->undo(new ChangeBend(bend, bp.points()));
            }
      else if (cmd == "f-props") {
            BoxProperties vp(static_cast<Box*>(e), 0);
            vp.exec();
            }
      else if (cmd == "measure-props") {
            MeasureProperties vp(static_cast<Note*>(e)->chord()->segment()->measure());
            vp.exec();
            }
      else if (cmd == "frame-text") {
            Text* s = new Text(score());
//            s->setSubtype(TEXT_FRAME);
            s->setTextStyleType(TEXT_STYLE_FRAME);
            s->setParent(e);
            score()->undoAddElement(s);
            score()->select(s, SELECT_SINGLE, 0);
            startEdit(s);
            score()->setLayoutAll(true);
            }
      else if (cmd == "picture") {
            mscore->addImage(score(), static_cast<HBox*>(e));
            }
      else if (cmd == "frame-text") {
            Text* t = new Text(score());
            t->setTextStyleType(TEXT_STYLE_FRAME);
            t->setParent(e);
            score()->undoAddElement(t);
            score()->select(t, SELECT_SINGLE, 0);
            startEdit(t);
            }
      else if (cmd == "title-text") {
            Text* t = new Text(score());
            t->setTextStyleType(TEXT_STYLE_TITLE);
            t->setParent(e);
            score()->undoAddElement(t);
            score()->select(t, SELECT_SINGLE, 0);
            startEdit(t);
            }
      else if (cmd == "subtitle-text") {
            Text* t = new Text(score());
            t->setTextStyleType(TEXT_STYLE_SUBTITLE);
            t->setParent(e);
            score()->undoAddElement(t);
            score()->select(t, SELECT_SINGLE, 0);
            startEdit(t);
            }
      else if (cmd == "composer-text") {
            Text* t = new Text(score());
            t->setTextStyleType(TEXT_STYLE_COMPOSER);
            t->setParent(e);
            score()->undoAddElement(t);
            score()->select(t, SELECT_SINGLE, 0);
            startEdit(t);
            }
      else if (cmd == "poet-text") {
            Text* t = new Text(score());
            t->setTextStyleType(TEXT_STYLE_POET);
            t->setParent(e);
            score()->undoAddElement(t);
            score()->select(t, SELECT_SINGLE, 0);
            startEdit(t);
            }
      else if (cmd == "insert-hbox") {
            HBox* s = new HBox(score());
            double w = width() - s->leftMargin() * MScore::DPMM - s->rightMargin() * MScore::DPMM;
            s->setBoxWidth(Spatium(w / s->spatium()));
            s->setParent(e);
            score()->undoAddElement(s);
            score()->select(s, SELECT_SINGLE, 0);
            startEdit(s);
            }
      else if (cmd == "picture")
            mscore->addImage(score(), e);
      else if (cmd == "tuplet-props") {
            Tuplet* tuplet;
            QList<Element*> el;
            if (e->type() == Element::NOTE) {
                  tuplet = static_cast<Note*>(e)->chord()->tuplet();
                  el.append(tuplet);
                  }
            else if (e->isChordRest()) {
                  tuplet = static_cast<ChordRest*>(e)->tuplet();
                  el.append(tuplet);
                  }
            else {
                  tuplet = static_cast<Tuplet*>(e);
                  el.append(score()->selection().elements());      // apply to all selected tuplets
                  }
            TupletProperties vp(tuplet);
            if (vp.exec()) {
                  int bracketType = vp.bracketType();
                  int numberType  = vp.numberType();
                  foreach(Element* e, el) {
                        if (e->type() == Element::TUPLET) {
                              Tuplet* tuplet = static_cast<Tuplet*>(e);
                              if (bracketType != tuplet->bracketType())
                                    score()->undoChangeProperty(tuplet, P_BRACKET_TYPE, bracketType);
                              if (numberType != tuplet->numberType())
                                    score()->undoChangeProperty(tuplet, P_NUMBER_TYPE, numberType);
                              }
                        }
                  }
Example #3
0
        ///////////////////////////////////////////////////////////////////////
        // add new threads if there is some amount of work available
        std::size_t add_new(boost::int64_t add_count, thread_queue* addfrom,
            boost::unique_lock<mutex_type> &lk, bool steal = false)
        {
            HPX_ASSERT(lk.owns_lock());

            if (HPX_UNLIKELY(0 == add_count))
                return 0;

            std::size_t added = 0;
            task_description* task = 0;
            while (add_count-- && addfrom->new_tasks_.pop(task, steal))
            {
#ifdef HPX_HAVE_THREAD_QUEUE_WAITTIME
                if (maintain_queue_wait_times) {
                    addfrom->new_tasks_wait_ +=
                        util::high_resolution_clock::now() - util::get<2>(*task);
                    ++addfrom->new_tasks_wait_count_;
                }
#endif
                --addfrom->new_tasks_count_;

                // measure thread creation time
                util::block_profiler_wrapper<add_new_tag> bp(add_new_logger_);

                // create the new thread
                threads::thread_init_data& data = util::get<0>(*task);
                thread_state_enum state = util::get<1>(*task);
                threads::thread_id_type thrd;

                create_thread_object(thrd, data, state, lk);

                delete task;

                // add the new entry to the map of all threads
                std::pair<thread_map_type::iterator, bool> p =
                    thread_map_.insert(thrd);

                if (HPX_UNLIKELY(!p.second)) {
                    HPX_THROW_EXCEPTION(hpx::out_of_memory,
                        "threadmanager::add_new",
                        "Couldn't add new thread to the thread map");
                    return 0;
                }
                ++thread_map_count_;

                // only insert the thread into the work-items queue if it is in
                // pending state
                if (state == pending) {
                    // pushing the new thread into the pending queue of the
                    // specified thread_queue
                    ++added;
                    schedule_thread(thrd.get());
                }

                // this thread has to be in the map now
                HPX_ASSERT(thread_map_.find(thrd.get()) != thread_map_.end());
                HPX_ASSERT(thrd->get_pool() == &memory_pool_);
            }

            if (added) {
                LTM_(debug) << "add_new: added " << added << " tasks to queues"; //-V128
            }
            return added;
        }
Example #4
0
void testObj::test<9>(void)
{
  BoostPtr bp(new int);
  nn_=bp;
  ensure("invalid pointer value", bp.get()==nn_.get() );
}
Example #5
0
void hyp2F1(T& result, const T& a, const T& b, const T& c, const T& x)
{
  // Compute the series representation of hyperg_2f1 taken from
  // Abramowitz and Stegun 15.1.1.
  // There are no checks on input range or parameter boundaries.

   typedef typename boost::multiprecision::detail::canonical<boost::int32_t, T>::type si_type;
   typedef typename boost::multiprecision::detail::canonical<boost::uint32_t, T>::type ui_type;
   typedef typename T::exponent_type exp_type;
   typedef typename boost::multiprecision::detail::canonical<exp_type, T>::type canonical_exp_type;
   typedef typename mpl::front<typename T::float_types>::type fp_type;

   T x_pow_n_div_n_fact(x);
   T pochham_a         (a);
   T pochham_b         (b);
   T pochham_c         (c);
   T ap                (a);
   T bp                (b);
   T cp                (c);

   eval_multiply(result, pochham_a, pochham_b);
   eval_divide(result, pochham_c);
   eval_multiply(result, x_pow_n_div_n_fact);
   eval_add(result, ui_type(1));

   T lim;
   eval_ldexp(lim, result, 1 - boost::multiprecision::detail::digits2<number<T, et_on> >::value);

   if(eval_get_sign(lim) < 0)
      lim.negate();

   ui_type n;
   T term;

   static const unsigned series_limit = 
      boost::multiprecision::detail::digits2<number<T, et_on> >::value < 100
      ? 100 : boost::multiprecision::detail::digits2<number<T, et_on> >::value;
   // Series expansion of hyperg_2f1(a, b; c; x).
   for(n = 2; n < series_limit; ++n)
   {
      eval_multiply(x_pow_n_div_n_fact, x);
      eval_divide(x_pow_n_div_n_fact, n);

      eval_increment(ap);
      eval_multiply(pochham_a, ap);
      eval_increment(bp);
      eval_multiply(pochham_b, bp);
      eval_increment(cp);
      eval_multiply(pochham_c, cp);

      eval_multiply(term, pochham_a, pochham_b);
      eval_divide(term, pochham_c);
      eval_multiply(term, x_pow_n_div_n_fact);
      eval_add(result, term);

      if(eval_get_sign(term) < 0)
         term.negate();
      if(lim.compare(term) >= 0)
         break;
   }
   if(n > series_limit)
      BOOST_THROW_EXCEPTION(std::runtime_error("H2F1 failed to converge."));
}