void FORTE_iCreateDemo::executeEvent(int pa_nEIID) {
    QO() = QI();
    switch (pa_nEIID) {
    case scm_nEventINITID:
        if(true == QI()) {
            //TODO: add code for INIT event! or delete event
        }
        sendOutputEvent(scm_nEventINITOID);
        break;
    case scm_nEventSpotID:
        if(true == QI()) {
            create_spot();
        }
        sendOutputEvent(scm_nEventSpotOID);
        break;
    case scm_nEventCoverID:
        if(true == QI()) {
            create_cover();
        }
        sendOutputEvent(scm_nEventCoverOID);
        break;
    case scm_nEventDemoID:
        if(true == QI()) {
            create_demo(D());
        }
        sendOutputEvent(scm_nEventDemoOID);
        break;
    case scm_nEventCoverDockID:
        if(true == QI()) {
            create_cover_dock();
        }
        sendOutputEvent(scm_nEventCoverDockOID);
        break;
    case scm_nEventSendScriptID:
        if(true == QI()) {
//TODO: Delete create.h does not support adding code for SendScript event!
        }
        sendOutputEvent(scm_nEventSendScriptOID);
        break;
    }
}
void FORTE_F_ULINT_TO_UINT::executeEvent(int pa_nEIID) {
    if(scm_nEventREQID == pa_nEIID) {
        OUT() = ULINT_TO_UINT(IN());
        sendOutputEvent(scm_nEventCNFID);
    }
}
Beispiel #3
0
void FORTE_F_INSERT::executeEvent(int pa_nEIID){
  if (scm_nEventREQID == pa_nEIID) {
    anyStringFBHelper<FORTE_F_INSERT>(IN1().getDataTypeID(), *this);
    sendOutputEvent(scm_nEventCNFID);
  }
}
void FORTE_F_T_PLC_MS::executeEvent(int pa_nEIID){
  if(scm_nEventREQID == pa_nEIID){
      OUT() = T_PLC_MS();
      sendOutputEvent(scm_nEventCNFID);
  }
}
void FORTE_F_SUB_DATE_DATE::executeEvent(int pa_nEIID){
  if(scm_nEventREQID == pa_nEIID){
    OUT() = SUB_DATE_DATE(IN1(), IN2());
    sendOutputEvent(scm_nEventCNFID);
  }
}
void FORTE_FB_FT_TN64::enterStateINIT(void){
  m_nECCState = scm_nStateINIT;
  alg_INIT();
  sendOutputEvent( scm_nEventINITOID);
}
void FORTE_F_USINT_TO_BCD_BYTE::executeEvent(int pa_nEIID){
  if(scm_nEventREQID == pa_nEIID){
    OUT() = USINT_TO_BCD_BYTE(IN());
    sendOutputEvent(scm_nEventCNFID);
  }
}
void FORTE_F_BOOL_TO_WORD::executeEvent(int pa_nEIID){
  if(scm_nEventREQID == pa_nEIID){
	  OUT() = BOOL_TO_WORD(IN());
	  sendOutputEvent(scm_nEventCNFID);
  }
}
void FORTE_EG_SPLIT_3::enterStateEO(void){
  m_nECCState = scm_nStateEO;
  sendOutputEvent( scm_nEventEO1ID);
  sendOutputEvent( scm_nEventEO2ID);
  sendOutputEvent( scm_nEventEO3ID);
}
Beispiel #10
0
void FORTE_F_MIN::executeEvent(int pa_nEIID) {
    if (scm_nEventREQID == pa_nEIID) {
        anyElementaryFBHelper<FORTE_F_MIN>(IN1().getDataTypeID(), *this);
        sendOutputEvent(scm_nEventCNFID);
    }
}
void FB_ADD_INT::enterStateREQ(void){
  m_nECCState = scm_nStateREQ;
  alg_REQ();
  sendOutputEvent( scm_nEventCNFID);
}
void USINT2USINT::executeEvent(int pa_nEIID){
  if(scm_nEventREQID == pa_nEIID){
    OUT() = IN();
    sendOutputEvent(scm_nEventCNFID);
  }
}
void FORTE_F_ADD_TOD_TIME::executeEvent(int pa_nEIID){
  if(scm_nEventREQID == pa_nEIID){
    OUT() = ADD_TOD_TIME(IN1(), IN2());
    sendOutputEvent(scm_nEventCNFID);
  }
}
void FORTE_F_DEAD_ZONE::executeEvent(int pa_nEIID){
  if(scm_nEventREQID == pa_nEIID){
    OUT() = ::DEAD_ZONE(X(), L());
    sendOutputEvent(scm_nEventCNFID);
  }
}
void FORTE_F_INT_TO_TIME::executeEvent(int pa_nEIID){
  if(scm_nEventREQID == pa_nEIID){
    OUT() = INT_TO_TIME(IN());
    sendOutputEvent(scm_nEventCNFID);
  }
}
Beispiel #16
0
void FORTE_F_ACOS::executeEvent(int pa_nEIID){
  if (scm_nEventREQID == pa_nEIID) {
    anyRealFBHelper<FORTE_F_ACOS>(IN().getDataTypeID(), *this);
    sendOutputEvent(scm_nEventCNFID);
  }
}
void FORTE_F_WSTRING_TO_BOOL::executeEvent(int pa_nEIID){
  if(scm_nEventREQID == pa_nEIID){
    OUT() = WSTRING_TO_BOOL(IN());
    sendOutputEvent(scm_nEventCNFID);
  }
}
Beispiel #18
0
void FORTE_F_MUL::executeEvent(int pa_nEIID){
  if (scm_nEventREQID == pa_nEIID) {
      anyMagnitudeFBHelper<FORTE_F_MUL>(IN1().getDataTypeID(), *this);
      sendOutputEvent(scm_nEventCNFID);
  }
}
void FORTE_F_UDINT_TO_WSTRING::executeEvent(int pa_nEIID){
  if(scm_nEventREQID == pa_nEIID){
    OUT() = UDINT_TO_WSTRING(IN());
    sendOutputEvent(scm_nEventCNFID);
  }
}
void FORTE_F_TIME_TO_LREAL::executeEvent(int pa_nEIID){
  if(scm_nEventREQID == pa_nEIID){
    OUT() = TIME_TO_LREAL(IN());
    sendOutputEvent(scm_nEventCNFID);
  }
}
void DWORD2DWORD::executeEvent(int pa_nEIID){
  if(scm_nEventREQID == pa_nEIID){
    OUT() = IN();
    sendOutputEvent(scm_nEventCNFID);
  }
}
void FORTE_MRX_INFO_LED::executeEvent(int pa_nEIID){
  switch(pa_nEIID){
	case scm_nEventINITID:

		cliCommander = std::make_unique<CliCommanderControl>(factory->getCliCommander());

		if(cliCommander) {
			setInitialised();

			SUCCESS() = cliCommander->isControlStatusOK();
			RESPONSE().fromString(cliCommander->getControlStatusMessage().c_str());
		} else {
			resetInitialised();

			SUCCESS() = false;
			RESPONSE().fromString("ERROR: initialisation failed");
		}

		sendOutputEvent(scm_nEventINITOID);
	  break;
	case scm_nEventREQID:
		if(!QI()) {
			SUCCESS() = false;
			RESPONSE().fromString("QI is false");

			sendOutputEvent(scm_nEventCNFID);

			return;
		}

		if(!isInitialised()) {
    		SUCCESS() = false;
    		RESPONSE().fromString("ERROR: Not initialised");

    		sendOutputEvent(scm_nEventCNFID);

    		return;
		}

		const std::string mode(MODE().getValue());

		if(mode != "on" && mode != "off" && mode != "flash") {
			SUCCESS() = false;
			RESPONSE().fromString("ERROR: Invalid mode");

			sendOutputEvent(scm_nEventCNFID);

			return;
		}

		std::string cliCommand = "help.debug.info_led.info_led=";

		cliCommand.append(MODE().getValue());
		cliCommander->sendCliCommand(cliCommand);

		if(!cliCommander->isControlStatusOK()) {
			SUCCESS() = cliCommander->isControlStatusOK();
			RESPONSE().fromString(cliCommander->getControlStatusMessage().c_str());

			sendOutputEvent(scm_nEventCNFID);
			return;
		}

		cliCommand = "help.debug.info_led.submit";
		cliCommander->sendCliCommand(cliCommand);

		SUCCESS() = cliCommander->isControlStatusOK();
		RESPONSE().fromString(cliCommander->getControlStatusMessage().c_str());

		sendOutputEvent(scm_nEventCNFID);
	  break;
  }
}
void FORTE_FB_FT_TN64::enterStateREQ(void){
  m_nECCState = scm_nStateREQ;
  alg_REQ();
  sendOutputEvent( scm_nEventCNFID);
}
Beispiel #24
0
void FORTE_BL_PWM::executeEvent(int pa_nEIID){
	bool bRet = true;
	switch(pa_nEIID){
    case scm_nEventINITID:
    	if(m_poPWM != NULL){
    		//Fix output before stopping the PWM
    		//TODO:Handle the PWM output level when stopping it
    		m_poPWM->setRunState(BlackLib::stop);
    		delete m_poPWM;
    		m_poPWM = NULL;
    	}
    	if(QI() == true){
    		char * pacBuffer =  new char[PARAMS().length() + 3];
			PARAMS().toString(pacBuffer, sizeof(char)*(PARAMS().length() + 3));
			if (strncmp(pacBuffer, "\'EHRPWM2B\'", 10) == 0) {
				m_poPWM = new BlackLib::BlackPWM(BlackLib::EHRPWM2B);
			} else if (strncmp(pacBuffer, "\'EHRPWM2A\'", 10) == 0) {
				m_poPWM = new BlackLib::BlackPWM(BlackLib::EHRPWM2A);
			} else if (strncmp(pacBuffer, "\'EHRPWM1A\'", 10) == 0) {
				m_poPWM = new BlackLib::BlackPWM(BlackLib::EHRPWM1A);
			} else if (strncmp(pacBuffer, "\'EHRPWM1B\'", 10) == 0) {
				m_poPWM = new BlackLib::BlackPWM(BlackLib::EHRPWM1B);
			} else if (strncmp(pacBuffer, "\'EHRPWM0B\'", 10) == 0) {
				m_poPWM = new BlackLib::BlackPWM(BlackLib::EHRPWM0B);
			} else if (strncmp(pacBuffer, "\'EHRPWM0A\'", 10) == 0) {
				m_poPWM = new BlackLib::BlackPWM(BlackLib::EHRPWM0A);
			} else if (strncmp(pacBuffer, "\'ECAP0\'", 7) == 0) {
				m_poPWM = new BlackLib::BlackPWM(BlackLib::ECAP0);
			} else {
				delete[] pacBuffer;
				DEVLOG_ERROR("Invalid input PARAM in BL_PWM FB\n");
				STATUS() = "Input PARAM error";
				QO() = false;
				sendOutputEvent(scm_nEventINITOID);
				break;
			}
            delete[] pacBuffer;
            bRet = m_poPWM->setRunState(BlackLib::stop);
            bRet = bRet && m_poPWM->setDutyPercent(0.0);
			bRet = bRet && m_poPWM->setPeriodTime(Period().getInMicroSeconds(), BlackLib::microsecond);
			bRet = bRet && m_poPWM->setDutyPercent(Duty());
			if(Polarity() == true){
				bRet = bRet && m_poPWM->setPolarity(BlackLib::straight);
			}else{
				bRet = bRet && m_poPWM->setPolarity(BlackLib::reverse);
			}
			bRet = bRet && m_poPWM->setRunState(BlackLib::run);
			if(bRet == true){
				//PWM configuration OK
				STATUS() ="OK";
				QO() = true;
			}else{
				//PWM configuration Error
				DEVLOG_DEBUG("Invalid configuration parameters in BL_PWM FB\n");
				STATUS() ="Configuration Error";
				QO() = false;
			}
    	}else{
			STATUS() = "INIT- OK";
			QO() = false;
    	}
    	sendOutputEvent(scm_nEventINITOID);
    	break;
    case scm_nEventUpdateID:
    	if (m_poPWM == NULL){
    		//PWM must be initialized before updating configuration
    		DEVLOG_ERROR("Trying to update before initializing PWM\n");
    		STATUS() = "ERROR updating PWM";
    		QO()=false;
    	    sendOutputEvent(scm_nEventCNFID);
    	    break;
    	}
    	bRet = m_poPWM->setDutyPercent(0.0);
    	bRet = bRet && m_poPWM->setPeriodTime(Period().getInMicroSeconds(), BlackLib::microsecond);
    	bRet = bRet && m_poPWM->setDutyPercent(Duty());
    	if(Polarity() == false){
    		//BlackLib polarity seems to be inverse; For us straight is HIGH->LOW
    		bRet = bRet && m_poPWM->setPolarity(BlackLib::straight);
    	}else{
    		bRet = bRet && m_poPWM->setPolarity(BlackLib::reverse);
    	}
    	if(bRet == true){
    		//PWM configuration OK
    		STATUS() ="OK";
    		QO() = true;
    	}else{
    		//PWM configuration Error
    		DEVLOG_DEBUG("Invalid configuration parameters in BL_PWM FB\n");
    		STATUS() ="Configuration Error";
    		QO() = false;
    	}
    	sendOutputEvent(scm_nEventCNFID);
    	break;
    case scm_nEventStartID:
    	if(m_poPWM != NULL){
    		if(m_poPWM->setRunState(BlackLib::run)){
    	    	QI() = true;
    	    	STATUS() = "Running";
    		}else{
				//Could not start PWM
				DEVLOG_ERROR("Unable to run PWM\n");
				STATUS() = "ERROR running PWM";
				QO()=false;
    		}
    	}else{
        	QI() = false;
        	STATUS() = "PWM not initialized";
    	}
    	sendOutputEvent(scm_nEventCNFID);
    	break;
    case scm_nEventStopID:
    	if (m_poPWM != NULL){
    		//TODO:Handle the PWM output level when stopping it
    		if(m_poPWM->setRunState(BlackLib::stop)){
				STATUS() = "PWM Stopped";
				QO()=true;
    		}else{
				//Could not stop PWM
				DEVLOG_ERROR("Unable to stop PWM\n");
				STATUS() = "ERROR stopping PWM";
				QO()=false;
    		}
    	}else{
        	QI() = false;
        	STATUS() = "PWM not initialized";
    	}
    	sendOutputEvent(scm_nEventCNFID);
    	break;
  }
}