• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ period函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中period函数的典型用法代码示例。如果您正苦于以下问题:C++ period函数的具体用法?C++ period怎么用?C++ period使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: timer_alloc

void clock_device::update_timer()
{
	if (!m_signal_handler.isnull() && m_clock > 0)
	{
		if (m_timer == nullptr)
		{
			m_timer = timer_alloc(0);
			m_timer->adjust(period());
		}
		else
		{
			attotime next = period() - m_timer->elapsed();

			if (next < attotime::zero)
			{
				next = attotime::zero;
			}

			m_timer->adjust(next);
		}
	}
	else if (m_timer != nullptr)
	{
		m_timer->adjust(attotime::never);
	}
}
开发者ID:RafTacker,项目名称:mame,代码行数:26,代码来源:clock.cpp


示例2: main

int main()
{
	int i,c=0,cPrev=-1;
	for(i=3;i<=1000;i++)
	{
		c=period(i);
		if(c>cPrev)
		{
			cPrev=c;
			//printf("ok 1");
			printf("%d = %d\n",i,period(i));//printf("Period : %d = %d \n",i,period(i));
		}
	}
}
开发者ID:devanshu-ghosh,项目名称:Competitive-Programming,代码行数:14,代码来源:26.cpp


示例3: period

// Note: not guaranteed to print entire state
void PulseWave::printState(void) {
  const char *enabledStr = enabled ? "enabled" : "disabled";
  float frequency = 1.0 / period();
  printf("Pulse wave channel %d: %s, duty %f, divider %d (%f Hz)\n",
         // dummy channel number below
         -1, enabledStr, duty, divider, frequency);
}
开发者ID:mkbehr,项目名称:missingnes,代码行数:8,代码来源:PulseWave.cpp


示例4: sigaddset

  void
  GroupNodeImpl::update_groups()
  {
#ifndef _WIN32
    sigset_t signal_set;
    sigaddset(&signal_set, SIGINT);
    sigaddset(&signal_set, SIGTERM);
    sigaddset(&signal_set, SIGHUP);
    sigaddset(&signal_set, SIGPIPE);
    pthread_sigmask(SIG_BLOCK, &signal_set, NULL);
#endif
    // called by a thread in an infinite loop at a fixed rate (i.e. 1s)    
    while (ok()) {
      auto start = std::chrono::high_resolution_clock::now();
      zlist_t* all_groups = zyre_peer_groups(node_);
      void* item = zlist_first(all_groups);
      while (item != NULL) {
	char* grp = static_cast<char*>(item);
	// zyre only joins the group if we are not ALREADY in the group
	// so it does a hash lookup - we would be duplicating work 
	zyre_join(node_, grp);
	item = zlist_next(all_groups);
      }
      std::chrono::duration<double,std::milli> period(1000);
      std::this_thread::sleep_until(start + period);
    }
  }
开发者ID:mikegulf,项目名称:quickmsg,代码行数:27,代码来源:group_node.cpp


示例5: assert

OsStatus MpodBufferRecorder::enableDevice(unsigned samplesPerFrame, 
                                          unsigned samplesPerSec,
                                          MpFrameTime currentFrameTime,
                                          OsCallback &frameTicker)
{
   assert(!isEnabled());
   assert(mpBuffer == NULL);

   mSamplesPerFrame = samplesPerFrame;
   mSamplesPerSec = samplesPerSec;
   
   mBufferLength = mBufferLengthMS * mSamplesPerSec / 1000;

   mpBuffer = new MpAudioSample[mBufferLength];
   mBufferEnd = 0;

   mIsEnabled = TRUE;

   if (mpTickerTimer != NULL)
   {
      mpTickerTimer->stop(TRUE);
      delete mpTickerTimer;
      mpTickerTimer = NULL;
   }

   mpTickerNotification = &frameTicker;

   // Start firing events
   mpTickerTimer = new OsTimer((OsNotification&)*mpTickerNotification);
   OsTime period(samplesPerFrame*1000/samplesPerSec);
   mpTickerTimer->periodicEvery(period, period);

   return OS_SUCCESS;
}
开发者ID:John-Chan,项目名称:sipXtapi,代码行数:34,代码来源:MpodBufferRecorder.cpp


示例6: period

void z80ctc_device::ctc_channel::trigger(uint8_t data)
{
	// normalize data
	data = data ? 1 : 0;

	// see if the trigger value has changed
	if (data != m_extclk)
	{
		m_extclk = data;

		// see if this is the active edge of the trigger
		if (((m_mode & EDGE) == EDGE_RISING && data) || ((m_mode & EDGE) == EDGE_FALLING && !data))
		{
			// if we're waiting for a trigger, start the timer
			if ((m_mode & WAITING_FOR_TRIG) && (m_mode & MODE) == MODE_TIMER)
			{
				attotime curperiod = period();
				VPRINTF_CHANNEL(("CTC period %s\n", curperiod.as_string()));
				m_timer->adjust(curperiod, m_index, curperiod);
			}

			// we're no longer waiting
			m_mode &= ~WAITING_FOR_TRIG;

			// if we're clocking externally, decrement the count
			if ((m_mode & MODE) == MODE_COUNTER)
			{
				// if we hit zero, do the same thing as for a timer interrupt
				if (--m_down == 0)
					timer_callback(nullptr,0);
			}
		}
	}
}
开发者ID:Robbbert,项目名称:store1,代码行数:34,代码来源:z80ctc.cpp


示例7: spin

  bool spin()
  {
    ros::Duration period(4,0) ;         // Repeat Every 4 seconds
        
    ros::Time next_time = ros::Time::now() ;

    while ( ok() )
    {
      usleep(100) ;
      if (ros::Time::now() >= next_time)
      {
        next_time.from_double(next_time.to_double() + period.to_double()) ;
        
        BuildCloud::request req ;
        BuildCloud::response resp ;
        
        req.begin.from_double(next_time.to_double() - period.to_double() ) ;
        req.end   = next_time ;
        req.target_frame_id = "base" ;
        
        printf("Making Service Call...\n") ;
        ros::service::call("build_cloud", req, resp) ;
        printf("Done with service call\n") ;
        
        publish("full_cloud", resp.cloud) ;
        printf("Published Cloud size=%u\n", resp.cloud.get_pts_size()) ;
      }
    }
    return true ;
  }
开发者ID:goretkin,项目名称:kwc-ros-pkg,代码行数:30,代码来源:grab_cloud_data.cpp


示例8: install_readwrite_handler

void hp98035_io_card::device_reset()
{
	hp9845_io_card_device::device_reset();
	install_readwrite_handler(read16_delegate(FUNC(hp98035_io_card::reg_r) , this) , write16_delegate(FUNC(hp98035_io_card::reg_w) , this));

	m_idr_full = false;
	m_idr = 0;
	m_odr = 0;
	m_ibuffer_ptr = 0;
	m_obuffer_len = 0;
	m_obuffer_ptr = 0;
	sts_w(true);
	set_flg(true);

	// Set real time from the real world
	system_time systime;
	machine().base_datetime(systime);
	m_msec = 0;
	m_sec = systime.local_time.second;
	m_min = systime.local_time.minute;
	m_hrs = systime.local_time.hour;
	m_dom = systime.local_time.mday;
	m_mon = systime.local_time.month + 1;

	attotime period(attotime::from_msec(1));
	m_msec_timer->adjust(period , 0 , period);

	half_init();
}
开发者ID:goofwear,项目名称:mame,代码行数:29,代码来源:98035.cpp


示例9: PWMObject

FastPWM::FastPWM(PinName pin) : PWMObject(pin){
    //Set clock source
    LPC_SC->PCLKSEL0|=1<<12;
    
    _duty=0;
    _period=0.02;
    if (pin==p26||pin==LED1) {
        PWMUnit=1;
        MR=&LPC_PWM1->MR1;
        }
    else if (pin==p25||pin==LED2){
        PWMUnit=2;
        MR=&LPC_PWM1->MR2;
        }
    else if (pin==p24||pin==LED3){
        PWMUnit=3;
        MR=&LPC_PWM1->MR3;
        }
    else if (pin==p23||pin==LED4){
        PWMUnit=4;
        MR=&LPC_PWM1->MR4;
        }
    else if (pin==p22){
        PWMUnit=5;
        MR=&LPC_PWM1->MR5;
        }
    else if (pin==p21){
        PWMUnit=6;
        MR=&LPC_PWM1->MR6;
        }
    else
        error("No hardware PWM pin\n\r");
    
    period(_period);
}
开发者ID:RyanNaughton,项目名称:seas_ese350_neato_hacking,代码行数:35,代码来源:FastPWM.cpp


示例10: m_signal_handler

void clock_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	m_signal = !m_signal;
	m_signal_handler(m_signal);

	m_timer->adjust(period());
}
开发者ID:RafTacker,项目名称:mame,代码行数:7,代码来源:clock.cpp


示例11: TEST_F

TEST_F(PeriodicActionPoolTest, cancellation)
{
    PeriodicActionPool::Ptr pool(PeriodicActionPool::create("TestPool",
                                                            nthreads_));

    boost::promise<bool> promise;
    boost::unique_future<bool> future(promise.get_future());
    bool running = false;

    auto fun([&]() -> PeriodicActionContinue
             {
                 if (not running)
                 {
                     promise.set_value(true);
                     running = true;
                 }

                 return PeriodicActionContinue::T;
             });

    std::atomic<uint64_t> period(3600);

    std::unique_ptr<PeriodicActionPool::Task> t(pool->create_task("LongPeriod",
                                                                  std::move(fun),
                                                                  period,
                                                                  true));

    EXPECT_TRUE(future.get());
}
开发者ID:bigclouds,项目名称:volumedriver,代码行数:29,代码来源:PeriodicActionPoolTest.cpp


示例12: NS_ENSURE_TRUE

nsresult
nsDASHWebMODParser::SetPeriods(MPD* aMpd)
{
  NS_ENSURE_TRUE(mRoot, NS_ERROR_NOT_INITIALIZED);

  nsCOMPtr<nsIDOMElement> child, nextChild;
  nsresult rv = mRoot->GetFirstElementChild(getter_AddRefs(child));
  NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);

#ifdef PR_LOGGING
  int i = 0;
#endif
  while (child) {
    nsAutoString tagName;
    rv = child->GetTagName(tagName);
    NS_ENSURE_SUCCESS(rv, rv);
    if (tagName.EqualsLiteral("Period")) {
      nsAutoPtr<Period> period(new Period());

      // Get start time and duration
      nsAutoString value;
      rv = GetAttribute(child, NS_LITERAL_STRING("start"), value);
      NS_ENSURE_SUCCESS(rv, rv);
      if (!value.IsEmpty()) {
        double startTime = -1;
        rv = GetTime(value, startTime);
        NS_ENSURE_SUCCESS(rv, rv);
        NS_ENSURE_TRUE(0 <= startTime, NS_ERROR_ILLEGAL_VALUE);
        period->SetStart(startTime);
      }

      rv = GetAttribute(child, NS_LITERAL_STRING("duration"), value);
      NS_ENSURE_SUCCESS(rv, rv);
      if (!value.IsEmpty()) {
        double duration = -1;
        rv = GetTime(value, duration);
        NS_ENSURE_SUCCESS(rv, rv);
        NS_ENSURE_TRUE(0 <= duration, NS_ERROR_ILLEGAL_VALUE);
        period->SetDuration(duration);
      }

      bool bIgnoreThisPeriod;
      rv = SetAdaptationSets(child, period, bIgnoreThisPeriod);
      NS_ENSURE_SUCCESS(rv, rv);

      // |Period| should be ignored if its child elems are invalid
      if (bIgnoreThisPeriod) {
        LOG("Ignoring period");
      } else {
        aMpd->AddPeriod(period.forget());
        LOG("Period #%d: added to MPD", i++);
      }
    }
    rv = child->GetNextElementSibling(getter_AddRefs(nextChild));
    NS_ENSURE_SUCCESS(rv, rv);
    child = nextChild;
  }
  return NS_OK;
}
开发者ID:mikeaich,项目名称:releases-mozilla-central,代码行数:59,代码来源:nsDASHWebMODParser.cpp


示例13: periodChanged

void EasingGraph::setPeriod(qreal newPeriod)
{
    if ((period() != newPeriod) && (easingShape()==QLatin1String("Elastic"))) {
        m_curveFunction.setPeriod(newPeriod);
        emit periodChanged();
        update();
    }
}
开发者ID:FlavioFalcao,项目名称:qt-creator,代码行数:8,代码来源:easinggraph.cpp


示例14: idle_callback

        void idle_callback(std::size_t /*num_thread*/)
        {
#if defined(HPX_HAVE_THREAD_MANAGER_IDLE_BACKOFF)
            // Put this thread to sleep for some time, additionally it gets
            // woken up on new work.
#if BOOST_VERSION < 105000
            boost::posix_time::millisec period(++wait_count_);

            boost::unique_lock<boost::mutex> l(mtx_);
            cond_.timed_wait(l, period);
#else
            boost::chrono::milliseconds period(++wait_count_);

            boost::unique_lock<boost::mutex> l(mtx_);
            cond_.wait_for(l, period);
#endif
#endif
        }
开发者ID:Bcorde5,项目名称:hpx,代码行数:18,代码来源:scheduler_base.hpp


示例15: bind

            static inline void bind(const std::shared_ptr<threading::Reaction>& reaction) {

                // If this is the first time we have used this watchdog service it
                if (!operation::CacheGet<message::ServiceWatchdog<WatchdogGroup>>::template get<DSL>(*reaction)) {
                    reaction->reactor.emit(std::make_unique<message::ServiceWatchdog<WatchdogGroup>>());
                }


                reaction->unbinders.push_back([](const threading::Reaction& r) {
                    r.reactor.emit<emit::Direct>(std::make_unique<operation::Unbind<operation::ChronoTask>>(r.id));
                });

                // Send our configuration out
                reaction->reactor.emit<emit::Direct>(std::make_unique<operation::ChronoTask>(
                    [reaction](NUClear::clock::time_point& time) {
                        // Get the latest time the watchdog was serviced
                        auto service_time =
                            operation::CacheGet<message::ServiceWatchdog<WatchdogGroup>>::template get<DSL>(*reaction)
                                ->time;

                        // Check if our watchdog has timed out
                        if (NUClear::clock::now() > (service_time + period(ticks))) {
                            try {
                                // Submit the reaction to the thread pool
                                auto task = reaction->get_task();
                                if (task) { reaction->reactor.powerplant.submit(std::move(task)); }
                            }
                            catch (...) {
                            }

                            // Now automatically service the watchdog
                            time = NUClear::clock::now() + period(ticks);
                        }
                        // Change our wait time to our new watchdog time
                        else {
                            time = service_time + period(ticks);
                        }

                        // We renew!
                        return true;
                    },
                    NUClear::clock::now() + period(ticks),
                    reaction->id));
            }
开发者ID:Fastcode,项目名称:NUClear,代码行数:44,代码来源:Watchdog.hpp


示例16: main

int main( int argc, char** argv ) {
  // initialize ROS
  ros::init(argc, argv, "iiwa_hw", ros::init_options::NoSigintHandler);
  
  // ros spinner
  ros::AsyncSpinner spinner(1);
  spinner.start();
  
  // custom signal handlers
  signal(SIGTERM, quitRequested);
  signal(SIGINT, quitRequested);
  signal(SIGHUP, quitRequested);
  
  // construct the lbr iiwa
  ros::NodeHandle iiwa_nh;
  IIWA_HW iiwa_robot(iiwa_nh);
  
  // configuration routines
  iiwa_robot.start();
  
  ros::Time last(ros::Time::now());
  ros::Time now;
  ros::Duration period(1.0);
  
  //the controller manager
  controller_manager::ControllerManager manager(&iiwa_robot, iiwa_nh);
  
  // run as fast as possible
  while( !g_quit ) {
    
    // get the time / period
    now = ros::Time::now();
    period = now - last;
    last = now;
    
    // read current robot position
    iiwa_robot.read(period);
    
    // update the controllers
    manager.update(now, period);
    
    // send command position to the robot
    iiwa_robot.write(period);
    
    // wait for some milliseconds defined in controlFrequency
    iiwa_robot.getRate()->sleep();
  }
  
  std::cerr << "Stopping spinner..." << std::endl;
  spinner.stop();
  
  std::cerr << "Bye!" << std::endl;
  
  return 0;
}
开发者ID:cpaxton,项目名称:iiwa_stack,代码行数:55,代码来源:main.cpp


示例17: idle_callback

        void idle_callback(std::size_t /*num_thread*/)
        {
#if defined(HPX_THREAD_BACKOFF_ON_IDLE)
            // Put this thread to sleep for some time, additionally it gets
            // woken up on new work.
#if BOOST_VERSION < 105000
            boost::posix_time::millisec period(++wait_count_);

            boost::mutex::scoped_lock l(mtx_);
            policies::detail::reset_on_exit w(waiting_);
            cond_.timed_wait(l, period);
#else
            boost::chrono::milliseconds period(++wait_count_);

            boost::mutex::scoped_lock l(mtx_);
            policies::detail::reset_on_exit w(waiting_);
            cond_.wait_for(l, period);
#endif
#endif
        }
开发者ID:dailypips,项目名称:hpx,代码行数:20,代码来源:scheduler_base.hpp


示例18: find_generator

/* find a generator for the multiplicative group mod p, where p is prime */
static int find_generator(int p)
{
     int g;

     for (g = 1; g < p; ++g)
	  if (period(g, p) == p - 1)
	       break;
     if (g == p)
	  fftw_die("couldn't find generator for Rader\n");
     return g;
}
开发者ID:Pinkii-,项目名称:PCA,代码行数:12,代码来源:rader.c


示例19: now

bool SubjectBotCommand::invoke(BotCommandInfo *info) const
{
    BotCommandArgs args = info->parseArgs(2);

    if(args.size() < 1 || !this->checkPassword(args[0]))
    {
        info->setResponse("Wrong password");
        return false;
    }

    boost::gregorian::date now(boost::gregorian::day_clock::local_day());

    std::string formatstr = this->getOption("subject", "format");
    if("" == formatstr)
        formatstr = this->_defaultFormat;

    StringFormat format(formatstr);
    std::string datestr = this->getOption("subject", "eventdate");
    if(datestr.length() > 0)
    {
        std::vector<std::string> dates;
        boost::algorithm::split(dates,datestr,boost::algorithm::is_any_of(","));

        for(unsigned int i = 0; i < dates.size(); i++)
        {
            boost::algorithm::trim(dates[i]);
            if(dates[i].length() < 1)
                continue;

            boost::gregorian::date_period period(now, boost::gregorian::from_string(dates[i]));

            format.assign(boost::lexical_cast<std::string>(i+1),period.length());
        }
    }

    if(args.size()<2 && this->_defaultFormat==formatstr)
    {
        info->setResponse("Expecting custom subject");
        return false;
    }

    if(args.size()>=2)
    	format.assign("_", args[1]);
    else // don't display anything if there is nothing to display
        format.assign("_","");

    std::string result = format.produce();

    this->_room->setSubject(result);
    info->setResponse("Subject set to \"" + result + "\".");
    return true;
}
开发者ID:trilader,项目名称:xmppbot,代码行数:52,代码来源:SubjectBotCommand.cpp


示例20: period

	/**
	This function is called whenever the physical boundaries, cutoffs, etc. 
	are changed.
	*/
	void CellList::rebuild()
	{	
		_is_good = true;
		
		std::vector<double> period(3, 0.0);
		for (int i=0; i<3; i++) {
			period[i] = _box_max[i] - _box_min[i];
		}
		
		
		double irx = period[0] / _interaction_range;
		double iry = period[1] / _interaction_range;
		double irz = period[2] / _interaction_range;
			
		if (!(irx >= 3.0 || !_periodic[0]) ||
			!(iry >= 3.0 || !_periodic[1]) ||
			!(irz >= 3.0 || !_periodic[2]) ) {
			_is_good = false;
		}
				
		if (_min_cell_size > 0.0) {
			_ncellx = (int)(period[0]/_min_cell_size);
			_ncelly = (int)(period[1]/_min_cell_size);
			_ncellz = (int)(period[2]/_min_cell_size);
		}
		else {
			_ncellx = (int)(period[0]/_interaction_range);
			_ncelly = (int)(period[1]/_interaction_range);
			_ncellz = (int)(period[2]/_interaction_range);
		}

		_ncellyz = _ncelly*_ncellz;
		
		_cell_size[0] = period[0]/_ncellx;
		_cell_size[1] = period[1]/_ncelly;
		_cell_size[2] = period[2]/_ncellz;

		_inv_cell_size[0] = 1.0/_cell_size[0];
		_inv_cell_size[1] = 1.0/_cell_size[1];
		_inv_cell_size[2] = 1.0/_cell_size[2];

		if (_ncellx*_ncelly*_ncellz != (int)_cell.size()) {
			_force_rebuild = true;
		}
		
		if (_force_rebuild) {
			clear();		
			_cell.resize(_ncellx*_ncelly*_ncellz);
			divideBoxIntoCells();			
			_force_rebuild = false;
		}
	}
开发者ID:askeys,项目名称:smac,代码行数:56,代码来源:CellList.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ peripheral_free_list函数代码示例发布时间:2022-05-30
下一篇:
C++ perform函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap