Пример #1
0
//====================================
void interruptNow()
//====================================
{
  int ir,ir_1,ir_2,pin,extTrigged = S_NO;

  for(ir=0;ir<=max_irPin;ir++)
    {

      if(attached[ir] == S_YES)
	{
	  pin = inrpt[ir];

	  ir_1 = getDigitalPinValue(pin,g_curStep);
	  ir_2 = getDigitalPinValue(pin,g_curStep-1);

	  
	  if(interruptMode[ir] == RISING && ir_1 == 1 && ir_2 == 0)
	    {
	      doInterrupt(pin,ir,RISING,1);
	    }
	  if(interruptMode[ir] == FALLING && ir_1 == 0 && ir_2 == 1)
	    {
	      doInterrupt(pin,ir,FALLING,0);
	    }
	  if(interruptMode[ir] == CHANGE && ir_1 != ir_2)
	    {
	      doInterrupt(pin,ir,CHANGE,ir_1);
	    }
	  if(interruptMode[ir] == LOW && ir_1 != ir_2)
	    {
	      doInterrupt(pin,ir,LOW,ir_1);
	    }
	}

    } 

}
Пример #2
0
//=============================================================================
// METHOD    : SPELLcontroller::executeCommand()
//=============================================================================
void SPELLcontroller::executeCommand( const ExecutorCommand& cmd )
{
	// If a (repeatable) command is being executed, discard this one
	if (isCommandPending() &&
	    (cmd.id != CMD_ABORT) &&
	    (cmd.id != CMD_FINISH) &&
	    (cmd.id != CMD_INTERRUPT) &&
	    (cmd.id != CMD_PAUSE) &&
	    (cmd.id != CMD_CLOSE))
	{
		LOG_WARN("Discarding command " + cmd.id);
		return;
	}

	LOG_INFO("Now executing command " + cmd.id);

    startCommandProcessing();

    if (cmd.id == CMD_ABORT)
    {
        doAbort();
    }
    else if (cmd.id == CMD_FINISH)
    {
        doFinish();
    }
    else if (cmd.id == CMD_ACTION)
    {
        doUserAction();
    }
    else if (cmd.id == CMD_STEP)
    {
        doStep( false );
    }
    else if (cmd.id == CMD_STEP_OVER)
    {
        doStep( true );
    }
    else if (cmd.id == CMD_RUN)
    {
        doPlay();
    }
    else if (cmd.id == CMD_SKIP)
    {
        doSkip();
    }
    else if (cmd.id == CMD_GOTO)
    {
        if (cmd.earg == "line")
        {
            DEBUG("[C] Processing go-to-line " + cmd.arg);
            try
            {
                int line = STRI(cmd.arg);
                doGoto( line );
            }
            catch(...) {};
        }
        else if (cmd.earg == "label")
        {
            DEBUG("[C] Processing go-to-label " + cmd.arg);
            doGoto( cmd.arg );
        }
        else
        {
        	SPELLexecutor::instance().getCIF().error("Unable to process Go-To command, no target information", LanguageConstants::SCOPE_SYS );
        }
    }
    else if (cmd.id == CMD_PAUSE)
    {
        doPause();
    }
    else if (cmd.id == CMD_INTERRUPT)
    {
        doInterrupt();
    }
    else if (cmd.id == CMD_SCRIPT)
    {
    	/** \todo determine when to override */
        doScript(cmd.arg,false);
    }
    else if (cmd.id == CMD_CLOSE)
    {
        m_recover = false;
        m_reload = false;
        doClose();
    }
    else if (cmd.id == CMD_RELOAD)
    {
        doReload();
    }
    else if (cmd.id == CMD_RECOVER)
    {
        doRecover();
    }
    else
    {
        LOG_ERROR("[C] UNRECOGNISED COMMAND: " + cmd.id)
    }
	m_mailbox.commandProcessed();

	// The command has finished, release the dispatcher
	setCommandFinished();
	DEBUG("[C] Command execution finished " + cmd.id);

	//TEMPORARILY DISABLED: it creates deadlocks.
	// notifyCommandToCore( cmd.id );
}