Пример #1
0
int CEmsInfo::SendProcess(int a_nCmdCode, int a_nFlag, char *a_chMessageBuffer, int a_nMessageBufferLen)
{
    bool blnRet = true;
    char strCmdCode[11];
    int nNodeNo = 0;
    int nProcNo = 0;
    CGlobal *cGlob = NULL;
    CModuleIPC *cIpc = NULL;
    CProtocol cProto;

    DEBUG_LOG("SEND PROCESS\n");

    cGlob = CGlobal::GetInstance();

    nNodeNo = cGlob->GetLocalNodeNo();
    nProcNo =  cGlob->GetLocalProcNo();

    cProto.SetSource(nNodeNo, nProcNo);

    /* TEST */
    cProto.SetDestination(m_nAtomNodeNo, m_nStmNo);

    /* flag setting */
    switch(a_nFlag){
        case CProtocol::FLAG_REQUEST:   cProto.SetFlagRequest();    break;
        case CProtocol::FLAG_RESPONSE:  cProto.SetFlagResponse();   break;
        case CProtocol::FLAG_NOTIFY:    cProto.SetFlagNotify();     break;
        case CProtocol::FLAG_RETRNS:    cProto.SetFlagRetransmit(); break;
        case CProtocol::FLAG_BROAD:     cProto.SetFlagBroadcast();  break;
        case CProtocol::FLAG_ERROR:     cProto.SetFlagError();      break;
        default:
                                        STA_LOG(STA_ERR,"Invalid Message flag(%d)\n",a_nFlag);
                                        return STA_NOK;
    }

    /* PKG CLASS ACTION 
     * 000 003 XXXX
     */
    snprintf(strCmdCode, 11,"00000%d",a_nCmdCode);
    strCmdCode[11] = '\0';
    cProto.SetCommand(strCmdCode);

    cProto.SetPayload(a_chMessageBuffer, a_nMessageBufferLen);

    cIpc = cGlob->GetModuleIPC();

    blnRet = cIpc->SendMesg(cProto);
    if(blnRet != true){
        STA_LOG(STA_ERR,"IPC Send failed(cmdCode=%d, flag=%d)\n", a_nCmdCode, a_nFlag);
        return STA_NOK;
    }

    m_nMessageBufferLen = 0;

    return STA_OK;
}
Пример #2
0
int CEmsInfo::SendHeartBeatRsp()
{
    bool blnRet = true;
    int nNodeNo = 0;
    int nProcNo = 0;
    CGlobal *cGlob = NULL;
    CModuleIPC *cIpc = NULL;
    CProtocol cProto;

    DEBUG_LOG("SEND HEARTBEAT RESPONSE PROCESS\n");

    cGlob = CGlobal::GetInstance();

    nNodeNo = cGlob->GetLocalNodeNo();
    nProcNo =  cGlob->GetLocalProcNo();

    cProto.SetSource(nNodeNo, nProcNo);

    cProto.SetDestination(m_nAtomNodeNo, m_nStmNo);

    /* flag setting */
    cProto.SetFlagResponse();

    /* PKG CLASS ACTION 
     * 000 003 XXXX
     */
    cProto.SetCommand("0000030008");

    cIpc = cGlob->GetModuleIPC();

    blnRet = cIpc->SendMesg(cProto);
    if(blnRet != true){
        STA_LOG(STA_ERR,"IPC Send failed(HEARTBEAT RESPONSE)\n");
        return STA_NOK;
    }

    return STA_OK;
}