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


C++ change_speed函数代码示例

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


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

示例1: handle_event_going_down

int handle_event_going_down(int event, int order_table[N_FLOORS][N_BUTTONS]) {
	int next_state = GOING_DOWN;
	switch (event) {

			case EMERGENCY_BUTTON:
				change_speed(S_DOWN, S_STOP);
				activate_emergency(order_table);
				next_state = EMERGENCY;
				break;

			case GO_UP:
				change_speed(S_DOWN, S_UP);
				next_state = GOING_UP;
				break;

			case GO_DOWN:
				next_state = GOING_DOWN;
				break;
			
			case STOP:
				change_speed(S_DOWN, S_STOP);
				next_state = STOP_GOING_DOWN;
				delete_orders_at_current_floor(order_table);
				open_door();
				timer_set();
				break;
			
			case OBSTRUCTION:
				change_speed(S_DOWN, S_STOP);
				activate_emergency(order_table);
				next_state = EMERGENCY;
				break;
		}
	return next_state;
}
开发者ID:aakre,项目名称:gocode,代码行数:35,代码来源:statemachine.c

示例2: handle_event_idle

int handle_event_idle(int event, int order_table[N_FLOORS][N_BUTTONS]) {
	int next_state = IDLE;
	switch (event) {

			case EMERGENCY_BUTTON:
				activate_emergency(order_table);
				next_state = EMERGENCY;
				break;

			case GO_UP:
				close_door();
				change_speed(S_STOP, S_UP);
				next_state = GOING_UP;
				break;

			case GO_DOWN:
				close_door();
				change_speed(S_STOP, S_DOWN);
				next_state = GOING_DOWN;
				break;
			
			case STOP:
				next_state = IDLE;
				break;
			
			case OBSTRUCTION:
				activate_emergency(order_table);
				next_state = EMERGENCY;
				break;
			
		}
	return next_state;
}
开发者ID:aakre,项目名称:gocode,代码行数:33,代码来源:statemachine.c

示例3: handle_event_boot

int handle_event_boot() {
	int next_state = IDLE;
	int floor = elev_get_floor_sensor_signal();
	printf("\nBOOT IN PROGRESS; PLEASE WAIT...\n");
	while(floor == -1){
		change_speed(STOP, S_DOWN);
		floor = elev_get_floor_sensor_signal();
	}
	elev_set_floor_indicator(floor);
	change_speed(S_DOWN, STOP);
	printf("\nELEVATOR READY\n");
	return next_state;
}
开发者ID:aakre,项目名称:gocode,代码行数:13,代码来源:statemachine.c

示例4: startup

static int startup(struct LEON_serial * info)
{
	unsigned long flags;
	
	if (info->flags & S_INITIALIZED)
		return 0;

	if (!info->xmit_buf) {
		info->xmit_buf = (unsigned char *) get_free_page(GFP_KERNEL);
		if (!info->xmit_buf)
			return -ENOMEM;
	}

	save_flags(flags); cli();

	/*
	 * Clear the FIFO buffers and disable them
	 * (they will be reenabled in change_speed())
	 */

	change_speed(info);

	info->xmit_fifo_size = 1;
	leon->uartctrl1 = UCTRL_RE | UCTRL_RI | UCTRL_TE /*| UCTRL_TI*/;
	//leon->uartdata1;

	if (info->tty)
		clear_bit(TTY_IO_ERROR, &info->tty->flags);
	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;

	info->flags |= S_INITIALIZED;
	restore_flags(flags);
	return 0;
}
开发者ID:robacklin,项目名称:uclinux-linux,代码行数:34,代码来源:LEONserial.c

示例5: set_termios

static int set_termios(struct tty_struct * tty, struct termios * termios,
			int channel)
{
	int i;
	unsigned short old_cflag = tty->termios->c_cflag;

	/* If we try to set the state of terminal and we're not in the
	   foreground, send a SIGTTOU.  If the signal is blocked or
	   ignored, go ahead and perform the operation.  POSIX 7.2) */
	if ((current->tty == channel) &&
	     (tty->pgrp != current->pgrp)) {
		if (is_orphaned_pgrp(current->pgrp))
			return -EIO;
		if (!is_ignored(SIGTTOU)) {
			(void) kill_pg(current->pgrp,SIGTTOU,1);
			return -ERESTARTSYS;
		}
	}
	for (i=0 ; i< (sizeof (*termios)) ; i++)
		((char *)tty->termios)[i]=get_fs_byte(i+(char *)termios);
	if (IS_A_SERIAL(channel) && tty->termios->c_cflag != old_cflag)
		change_speed(channel-64);

	/* puting mpty's into echo mode is very bad, and I think under
	   some situations can cause the kernel to do nothing but
	   copy characters back and forth. -RAB */
	if (IS_A_PTY_MASTER(channel)) tty->termios->c_lflag &= ~ECHO;

	return 0;
}
开发者ID:binsys,项目名称:doc-linux,代码行数:30,代码来源:tty_ioctl.c

示例6: handle_event_stop_going_down

int handle_event_stop_going_down(int event, int order_table[N_FLOORS][N_BUTTONS]) {
	int next_state = STOP_GOING_DOWN;	
	switch (event) {

			case EMERGENCY_BUTTON:
				activate_emergency(order_table);
				next_state = EMERGENCY;
				break;

			case GO_UP:
				if(timer_elapsed() > DOOR_DELAY){
					close_door();
					change_speed(S_STOP, S_UP);
					next_state = GOING_UP;
				}else{
					next_state = STOP_GOING_UP;
				}
				break;

			case GO_DOWN:
				if(timer_elapsed() > DOOR_DELAY){
					close_door();
					change_speed(S_STOP, S_DOWN);
					next_state = GOING_DOWN;
				}else{
					next_state = STOP_GOING_DOWN;
				}
				break;
			
			case STOP:
				if(timer_elapsed() > DOOR_DELAY){
					close_door();
					next_state = IDLE;
				}else{
					next_state = STOP_GOING_DOWN;
				}
				break;
			
			case OBSTRUCTION:
				timer_set();
				next_state = STOP_GOING_DOWN;
				break;
			
		}
		return next_state;
}
开发者ID:aakre,项目名称:gocode,代码行数:46,代码来源:statemachine.c

示例7: printline

bool ldp::pre_change_speed(unsigned int uNumerator, unsigned int uDenominator)
{
	string strMsg;

	// if this is >= 1X
	if (uDenominator == 1)
	{
		m_uFramesToStallPerFrame = 0;	// don't want to stall at all

		// if this isn't 0 ...
		if (uNumerator > 0)
		{
			m_uFramesToSkipPerFrame = uNumerator - 1;	// show 1, skip the rest
		}
		// else it's 0, which is illegal (use pause() instead unless the game driver specifically wants to do this, in which case more coding is needed)
		else
		{
			m_uFramesToSkipPerFrame = 0;
			printline("ERROR : uNumerator of 0 sent to pre_change_speed, this isn't supported, going to 1X");
		}
	}
	// else if this is < 1X
	else if (uNumerator == 1)
	{
		m_uFramesToSkipPerFrame = 0;	// don't want to skip any ...

		// protect against divide by zero
		if (uDenominator > 0)
		{
			m_uFramesToStallPerFrame = uDenominator - 1;	// show 1, stall for the rest
		}
		// divide by zero situation
		else
		{
			m_uFramesToStallPerFrame = 0;
			printline("ERROR : uDenominator of 0 sent to pre_change_speed, this is undefined, going to 1X");
		}
	}
	// else it's a non-standard speed, so do some kind of error
	else
	{
		strMsg = "ERROR : unsupported speed specified (" + numstr::ToStr(uNumerator) +
			"/" + numstr::ToStr(uDenominator) + "), setting to 1X";
		uNumerator = uDenominator = 1;
	}

	bool bResult = change_speed(uNumerator, uDenominator);

	if (bResult) strMsg = "Successfully changed ";
	else strMsg = "Unable to change ";
	strMsg += "speed to " + numstr::ToStr(uNumerator) + "/" + numstr::ToStr(uDenominator) +
		"X";
	printline(strMsg.c_str());
	return bResult;
}
开发者ID:Shmoopty,项目名称:daphne-pi,代码行数:55,代码来源:ldp.cpp

示例8: startup

/*
 * -------------------------------------------------------------------
 * startup ()
 *
 * various initialization tasks
 * ------------------------------------------------------------------- 
 */
static int startup(struct dz_serial *info)
{
	unsigned long page, flags;
	unsigned short tmp;

	if (info->is_initialized)
		return 0;

	save_flags(flags);
	cli();

	if (!info->port) {
		if (info->tty)
			set_bit(TTY_IO_ERROR, &info->tty->flags);
		restore_flags(flags);
		return -ENODEV;
	}
	if (!info->xmit_buf) {
		page = get_free_page(GFP_KERNEL);
		if (!page) {
			restore_flags(flags);
			return -ENOMEM;
		}
		info->xmit_buf = (unsigned char *) page;
	}
	if (info->tty)
		clear_bit(TTY_IO_ERROR, &info->tty->flags);

	/* enable the interrupt and the scanning */
	tmp = dz_in(info, DZ_CSR);
	tmp |= (DZ_RIE | DZ_TIE | DZ_MSE);
	dz_out(info, DZ_CSR, tmp);

	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;

	/* set up the speed */
	change_speed(info);

	/* clear the line transmitter buffer 
	   I can't figure out why I need to do this - but
	   its necessary - in order for the console portion
	   and the interrupt portion to live happily side by side.
	 */

	/* clear the line transmitter buffer 
	   I can't figure out why I need to do this - but
	   its necessary - in order for the console portion
	   and the interrupt portion to live happily side by side.
	 */

	info->is_initialized = 1;

	restore_flags(flags);
	return 0;
}
开发者ID:ProjectZeroSlackr,项目名称:linux-2.4.32-ipod,代码行数:62,代码来源:dz.c

示例9: rs_set_termios

static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
{
	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;

	change_speed(info, tty);

	if ((old_termios->c_cflag & CRTSCTS) &&
	    !(tty->termios.c_cflag & CRTSCTS))
		rs_start(tty);
	
}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:11,代码来源:68328serial.c

示例10: startup

static int startup(struct sci_struct * sci)
{
	unsigned long flags;
	unsigned long page;

	page = get_free_page(GFP_KERNEL);
	if (!page)
		return -ENOMEM;

	
	save_flags(flags); cli();

	if (sci->info->flags & ASYNC_INITIALIZED) {
		free_page(page);
		restore_flags(flags);
		return 0;
	}

	if (!sci->info->port || !sci->info->type) {
		if (sci->info->tty)
			set_bit(TTY_IO_ERROR, &sci->info->tty->flags);
		free_page(page);
		restore_flags(flags);
		return 0;
	}
	if (sci->info->xmit_buf)
		free_page(page);
	else
		sci->info->xmit_buf = (unsigned char *) page;

#ifdef SERIAL_DEBUG_OPEN
	printk("starting up ttys%d (irq %d)...", info->line, info->irq);
#endif

	if (sci->info->tty)
		clear_bit(TTY_IO_ERROR, &sci->info->tty->flags);
	sci->info->xmit_cnt = sci->info->xmit_head = sci->info->xmit_tail = 0;

	/*
	 * Set up serial timers...
	 */
	timer_table[RS_TIMER].expires = jiffies + 2*HZ/100;
	timer_active |= 1 << RS_TIMER;

	/*
	 * and set the speed of the serial port
	 */
	change_speed(sci);

	sci->info->flags |= ASYNC_INITIALIZED;
	restore_flags(flags);
	return 0;
}
开发者ID:robacklin,项目名称:uclinux-linux,代码行数:53,代码来源:hitachi-sci.c

示例11: startup

static int startup(struct cnxt_serial * info)
{
	unsigned long flags;
	
	if (info->flags & S_INITIALIZED)
		return 0;

	if (!info->xmit_buf) {
		info->xmit_buf = (unsigned char *) get_free_page(GFP_KERNEL);
		if (!info->xmit_buf)
			return -ENOMEM;
	}

	save_flags(flags); cli();

#if 0
	/*
	 * Clear the FIFO buffers and disable them
	 * (they will be reenabled in change_speed())
	 */

	USTCNT = USTCNT_UEN;
	info->xmit_fifo_size = 1;
	USTCNT = USTCNT_UEN | USTCNT_RXEN | USTCNT_TXEN;
	(void)URX;

	/*
	 * Finally, enable sequencing and interrupts
	 */

#ifdef USE_INTS
	USTCNT = USTCNT_UEN | USTCNT_RXEN | 
                 USTCNT_RX_INTR_MASK | USTCNT_TX_INTR_MASK;
#else
	USTCNT = USTCNT_UEN | USTCNT_RXEN | USTCNT_RX_INTR_MASK;
#endif
#endif

	if (info->tty)
		clear_bit(TTY_IO_ERROR, &info->tty->flags);
	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;

	/*
	 * and set the speed of the serial port
	 */
#if 0
	change_speed(info);
#endif
	info->flags |= S_INITIALIZED;
	restore_flags(flags);
	return 0;
}
开发者ID:ProjectZeroSlackr,项目名称:linux-2.4.32-ipod,代码行数:52,代码来源:cnxtserial.c

示例12: handle_event_emergency

int handle_event_emergency(int event, int order_table[N_FLOORS][N_BUTTONS]) {
	int next_state = EMERGENCY;	
		switch (event) {

			case EMERGENCY_BUTTON:
				activate_emergency(order_table);
				next_state = EMERGENCY;
				break;

			case GO_UP:
				if(elev_get_floor_sensor_signal() != -1 && timer_elapsed() < DOOR_DELAY){	//Elevator will wait for # seconds defined by DOOR_DELAY before continuing when at a floor
					return EMERGENCY;
				}
				deactivate_emergency();
				change_speed(S_STOP, S_UP);
				next_state = GOING_UP;
				break;

			case GO_DOWN:
				if(elev_get_floor_sensor_signal() != -1 && timer_elapsed() < DOOR_DELAY){	//Elevator will wait for # seconds defined by DOOR_DELAY before continuing when at a floor
					return EMERGENCY;
				}
				deactivate_emergency();
				change_speed(S_STOP, S_DOWN);
				next_state = GOING_DOWN;
				break;
			
			case STOP:
				next_state = EMERGENCY;
				break;
			
			case OBSTRUCTION:
				timer_set();
				next_state = EMERGENCY;
				break;
			
		}
		return next_state;
}
开发者ID:aakre,项目名称:gocode,代码行数:39,代码来源:statemachine.c

示例13: rs_open

/*
 * This routine is called whenever a serial port is opened.  It
 * enables interrupts for a serial port, linking in its S structure into
 * the IRQ chain.   It also performs the serial-specific
 * initialization for the tty structure.
 */
int rs_open(struct tty_struct *tty, struct file * filp)
{
	int 		  retval, line;
	struct cnxt_serial *info;

	line = MINOR(tty->device) - tty->driver.minor_start;

	
	if (line != 0) /* we have exactly one */
		return -ENODEV;

	info = &uart_info;

	if (serial_paranoia_check(info, tty->device, "rs_open"))
		return -ENODEV;

	info->count++;
	tty->driver_data = info;
	info->tty = tty;

	/*
	 * Start up serial port
	 */
	retval = startup(info);
	if (retval)
		return retval;
	
	retval = block_til_ready(tty, filp, info);
	if (retval) {

		printk("rs_open returning after block_til_ready with %d\n",
		       retval);
		return retval;
	}

	if ((info->count == 1) && (info->flags & S_SPLIT_TERMIOS)) {
		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
			*tty->termios = info->normal_termios;
		else 
			*tty->termios = info->callout_termios;
		change_speed(info);
	}

	info->session = current->session;
	info->pgrp = current->pgrp;

	// Enable GPIO interrupt line for console uart 
	SetGPIOIntEnable(GPIOINT_UART1, IRQ_ON);
	return 0;
}
开发者ID:ProjectZeroSlackr,项目名称:linux-2.4.32-ipod,代码行数:56,代码来源:cnxtserial.c

示例14: rs_set_termios

static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
{
	struct serial_state *info = tty->driver_data;
	unsigned long flags;
	unsigned int cflag = tty->termios->c_cflag;

	change_speed(tty, info, old_termios);

	/* Handle transition to B0 status */
	if ((old_termios->c_cflag & CBAUD) &&
	    !(cflag & CBAUD)) {
		info->MCR &= ~(SER_DTR|SER_RTS);
		local_irq_save(flags);
		rtsdtr_ctrl(info->MCR);
		local_irq_restore(flags);
	}

	/* Handle transition away from B0 status */
	if (!(old_termios->c_cflag & CBAUD) &&
	    (cflag & CBAUD)) {
		info->MCR |= SER_DTR;
		if (!(tty->termios->c_cflag & CRTSCTS) || 
		    !test_bit(TTY_THROTTLED, &tty->flags)) {
			info->MCR |= SER_RTS;
		}
		local_irq_save(flags);
		rtsdtr_ctrl(info->MCR);
		local_irq_restore(flags);
	}

	/* Handle turning off CRTSCTS */
	if ((old_termios->c_cflag & CRTSCTS) &&
	    !(tty->termios->c_cflag & CRTSCTS)) {
		tty->hw_stopped = 0;
		rs_start(tty);
	}

#if 0
	/*
	 * No need to wake up processes in open wait, since they
	 * sample the CLOCAL flag once, and don't recheck it.
	 * XXX  It's not clear whether the current behavior is correct
	 * or not.  Hence, this may change.....
	 */
	if (!(old_termios->c_cflag & CLOCAL) &&
	    (tty->termios->c_cflag & CLOCAL))
		wake_up_interruptible(&info->open_wait);
#endif
}
开发者ID:kprog,项目名称:linux,代码行数:49,代码来源:amiserial.c

示例15: rs_360_set_termios

/* FIX UP modem control here someday......
*/
static void rs_360_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
{
	ser_info_t *info = (ser_info_t *)tty->driver_data;

	change_speed(info);

#ifdef modem_control
	/* Handle transition to B0 status */
	if ((old_termios->c_cflag & CBAUD) &&
	    !(tty->termios->c_cflag & CBAUD)) {
		info->MCR &= ~(UART_MCR_DTR|UART_MCR_RTS);
		local_irq_disable();
		serial_out(info, UART_MCR, info->MCR);
		local_irq_enable();
	}
	
	/* Handle transition away from B0 status */
	if (!(old_termios->c_cflag & CBAUD) &&
	    (tty->termios->c_cflag & CBAUD)) {
		info->MCR |= UART_MCR_DTR;
		if (!tty->hw_stopped ||
		    !(tty->termios->c_cflag & CRTSCTS)) {
			info->MCR |= UART_MCR_RTS;
		}
		local_irq_disable();
		serial_out(info, UART_MCR, info->MCR);
		local_irq_enable();
	}
	
	/* Handle turning off CRTSCTS */
	if ((old_termios->c_cflag & CRTSCTS) &&
	    !(tty->termios->c_cflag & CRTSCTS)) {
		tty->hw_stopped = 0;
		rs_360_start(tty);
	}
#endif

#if 0
	/*
	 * No need to wake up processes in open wait, since they
	 * sample the CLOCAL flag once, and don't recheck it.
	 * XXX  It's not clear whether the current behavior is correct
	 * or not.  Hence, this may change.....
	 */
	if (!(old_termios->c_cflag & CLOCAL) &&
	    (tty->termios->c_cflag & CLOCAL))
		wake_up_interruptible(&info->open_wait);
#endif
}
开发者ID:joka90,项目名称:htc-kernel-msm7227,代码行数:51,代码来源:68360serial.c


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