四 4DIAC IDE forte c++ 模块对应的接口

 

​
DEFINE_FIRMWARE_FB(E_RESTART, g_nStringIdE_RESTART)

const CStringDictionary::TStringId E_RESTART::scm_aunEONameIds[] = {g_nStringIdCOLD, g_nStringIdWARM, g_nStringIdSTOP};

const TEventID E_RESTART::csmCOLDID;
const TEventID E_RESTART::csmWARMID;
const TEventID E_RESTART::csmSTOPID;

const SFBInterfaceSpec E_RESTART::scm_stFBInterfaceSpec = {
  0,
  0,
  0,
  0,
  3,
  scm_aunEONameIds,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0
};

void E_RESTART::executeEvent(int pa_nEIID) {
  if(cg_nExternalEventID == pa_nEIID && cg_nInvalidEventID != mEventToSend) {
    sendOutputEvent(mEventToSend);
    if(csmSTOPID == mEventToSend) {
      //stop event is sent put the FB finally into the stopped state
      CFunctionBlock::changeFBExecutionState(cg_nMGM_CMD_Stop);
      // release semaphore to indicate that the stop event was sent now
      mSuspendSemaphore.inc();
    }
  }
}

EMGMResponse E_RESTART::changeFBExecutionState(EMGMCommandType pa_unCommand){
  EMGMResponse eRetVal = CFunctionBlock::changeFBExecutionState(pa_unCommand);
  if(e_RDY == eRetVal){
    switch(pa_unCommand){
      case cg_nMGM_CMD_Start:
        mEventToSend = (csmSTOPID == mEventToSend) ? csmWARMID : csmCOLDID;
        getResource().getDevice().getDeviceExecution().startNewEventChain(this);
        break;
      case cg_nMGM_CMD_Stop:
        mEventToSend = csmSTOPID;
        CFunctionBlock::changeFBExecutionState(cg_nMGM_CMD_Start);   //keep FB in running state until stop event is delivered.
        getResource().getDevice().getDeviceExecution().startNewEventChain(this);
        // wait until semaphore is released, after STOP eventExecution was completed
        mSuspendSemaphore.waitIndefinitely();
        break;
      default:
        mEventToSend = cg_nInvalidEventID;
        break;
    }
  }
  return eRetVal;
}

​
/*!\ingroup CORE\brief Structure to hold all the data for specifying a function block interface.
 */
struct SFBInterfaceSpec {
    TForteUInt8 m_nNumEIs; //!< Number of event inputs (max 254)
    const CStringDictionary::TStringId *m_aunEINames; //!< List of the event input names
    const TDataIOID *m_anEIWith; //!< Input WITH reference list. This list contains an array of input data ids. For each input event the associated data inputs are listed. The start for each input event is specified in the m_anEIWithIndexes field. The end is defined trough the value 255.
    const TForteInt16 *m_anEIWithIndexes; //!< Index list for each input event. This list gives for each input event an entry in the m_anEIWith. Input events are numbered starting from 0. if the input event has no assciated data inputs -1 is the entry at this event inputs postion.
    TForteUInt8 m_nNumEOs; //!< Number of event outputs (max 254)
    const CStringDictionary::TStringId *m_aunEONames; //!< List of the event output names
    const TDataIOID *m_anEOWith; //!< Output WITH reference list. This list contains an array of output data ids. For each output event the associated data outputs are listed. The start for each output event is specified in the m_anEOWithIndexes field. The end is defined trough the value 255.
    const TForteInt16 *m_anEOWithIndexes; //!< Index list for each output event. This list gives for each output event an entry in the m_anEOWith. Output events are numbered starting from 0. if the output event has no assciated data outputs -1 is the entry at this event outputs postion. Additionally at the postion m_nNumEOs in this list an index to an own list in the m_anEOWith list is stored specifying all output data port that are not associated with any output event. That values will be updated on every FB invocation.
    TForteUInt8 m_nNumDIs; //!< Number of data inputs (max 254)
    const CStringDictionary::TStringId *m_aunDINames; //!< List of the data input names
    const CStringDictionary::TStringId *m_aunDIDataTypeNames; //!< List of the data type names for the data inputs
    TForteUInt8 m_nNumDOs; //!< Number of data outputs (max 254)
    const CStringDictionary::TStringId *m_aunDONames; //!< List of the data output names
    const CStringDictionary::TStringId *m_aunDODataTypeNames; //!< List of the data type names for the data outputs
    TForteUInt8 m_nNumAdapters; //!< Number of Adapters
    const SAdapterInstanceDef *m_pstAdapterInstanceDefinition; //!< List of adapter instances
};

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值