Exemplo n.º 1
0
    int  Refer2InviteCore::idle ( Event *e)
    {
        MAND_LOG(DBG_SIP,  "state:idle: event: %s", e->toString());

        switch (e->m_type)
        {
            case EVT_ENTER:
                EWN_NEW(m_uaTable[CLNT2], UAClientCore(this/*, (int)CLNT2*/));
                EWN_NEW(m_uaTable[CLNT3], UAClientCore(this/*, (int)CLNT3*/));
                m_uaTable[CLNT2]->init();
                m_uaTable[CLNT3]->init();
                return 0;

            case EVT_EXIT : return 0;
            default       : return 1;

            case EVT_NEW_REFER:
            {
                if (m_dialogs[CLNT2] == NULL || m_dialogs[CLNT3] == NULL ||
                    m_uaTable[CLNT2] == NULL || m_uaTable[CLNT3] == NULL )
                    return 1;

                Request invite2;
                invite2.create(SIP_REQ_INVITE, m_dialogs[CLNT2]);
                //Transaction::startClient(invite2, m_uaTable[CLNT2]);

                FSM_TRAN(&Refer2InviteCore::getOfferFrom2);
                return 0;
            }
        }
    }
Exemplo n.º 2
0
    int  Refer2InviteCore::getOfferFrom2 ( Event *e)
    {
        MAND_LOG(DBG_SIP,  "state:getOfferFrom2: event: %s", e->toString());
        switch (e->m_type)
        {
            case EVT_ENTER: return 0;
            case EVT_EXIT : return 0;
            default       : return 1;
            case EVT_INT_CALL_ANSWERED:
            {
                // it should be a response from Phone2
                if (e->m_fsm != m_uaTable[CLNT2])
                    return 1;

                // Now we take the sdp from phone2 and send
                // it to phone3
                Response rcvdMsg(e->m_pOsipMsg);
                Request invite3;
                invite3.create(SIP_REQ_INVITE, m_dialogs[CLNT3]);

//                SdpMsg sdp(processSDP(m_dialogs[CLNT2], m_dialogs[CLNT3], rcvdMsg));

//                invite3.AddSdp(sdp);

//                Transaction::startClient(invite3, m_uaTable[CLNT3]);

                FSM_TRAN(&Refer2InviteCore::getAnswerFrom3);
                return 0;
            }
        }
    }
Exemplo n.º 3
0
    int  Refer2InviteCore::completeTransfer ( Event *e)
    {
        MAND_LOG(DBG_SIP,  "state:completeTransfer: event: %s", e->toString());
        switch (e->m_type)
        {
            case EVT_ENTER:
            {
                Request notify;
                notify.create(SIP_REQ_NOTIFY, m_dialogs[SERV2]);
                notify.AddBody("SIP/2.0 200 OK", "message/sipfrag");
                notify.addHeader("Subscription-State", "terminated;reason=noresource");
//                Transaction::startClient(notify, this);
                return 0;
            }
            case EVT_2XX_RCVD:
            {
                //closeDialog(m_dialogs[SERV2]);
                //closeDialog(m_dialogs[SERV3]);
                m_dialogs[SERV2]->close(this);
                m_dialogs[SERV3]->close(this);


                FSM_TRAN(&Refer2InviteCore::idle);
                return 0;
            }

            case EVT_EXIT : return 0;
            default       : return 1;
        }
    }
Exemplo n.º 4
0
    int  Refer2InviteCore::getAnswerFrom3 ( Event *e)
    {
        MAND_LOG(DBG_SIP,  "state:getAnswerFrom3: event: %s", e->toString());
        switch (e->m_type)
        {
            case EVT_ENTER: return 0;
            case EVT_EXIT : return 0;
            default       : return 1;
            case EVT_INT_CALL_ANSWERED:
            {
                // it should be a response from Phone3
                if (e->m_fsm != m_uaTable[CLNT3])
                    return 1;

                // Take the sdp from the response of phone3
                // and send it to phone2
                Response rcvdResp(e->m_pOsipMsg);
                Request ack2;
                ack2.create(SIP_REQ_ACK, m_dialogs[CLNT2]);

//                 SdpMsg sdp(processSDP(m_dialogs[CLNT2], m_dialogs[CLNT3], rcvdResp));
//                 ack2.AddSdp(sdp);

                Transport::send(ack2);

                ackDialog(m_dialogs[CLNT3]);

                FSM_TRAN(&Refer2InviteCore::completeTransfer);
                return 0;
            }
        }
    }
Exemplo n.º 5
0
Arquivo: IV.c Projeto: yanava/blfw
// Operation, getting all points until DAC Full scale or Short Circuit
FSM_State IV_HAND_OPER(IV_TRACER_T *me, FSM_Event *e)
{
    switch (e->signal)
    {
        case FSM_ENTRY_SIGNAL:
            // Sets the point delay for first time
            me->last_point.i = IV_MINIMUM_CURRENT;
            DL_SetCurrent(me->last_point.i);
            me->point_delay_counter = me->point_delay_ms;
            return FSM_HANDLED();
        case IV_POINT_DELAY_TIMEOUT:
            // Gets Panel Voltage
            me->last_point.v = IV_Get_Panel_Voltage();
            me->last_point.correct_i = IV_Get_Panel_Current();
            // Puts point on curve FIFO
            FIFO_Post(&me->curve.super, &me->last_point);
            // Increments current by a step
            me->last_point.i += IV_CURRENT_CURVE_STEP;
            DL_SetCurrent(me->last_point.i);
            // Sets the point delay
            me->point_delay_counter = me->point_delay_ms;
            return FSM_HANDLED();
        case IV_SHORT_CIRCUIT:
            // Curve done
            IV_ExportCurve("CURVE.TXT",&me->curve,&me->filesystem);
            return FSM_TRAN(me,IV_HAND_IDLE);
        case FSM_EXIT_SIGNAL:
            // Set DAC to zero here, to reduce temperature
            me->last_point.i = IV_MINIMUM_CURRENT;
            DL_SetCurrent(me->last_point.i);
            return FSM_HANDLED();   
    }
    // Default: Handled
    return FSM_HANDLED();
}
Exemplo n.º 6
0
Arquivo: IV.c Projeto: yanava/blfw
// Idle, waiting timeout to get the next IV Curve
FSM_State IV_HAND_IDLE(IV_TRACER_T *me, FSM_Event *e)
{
    switch (e->signal)
    {
        case FSM_ENTRY_SIGNAL:
            return FSM_HANDLED();
        case IV_START_NEW_CURVE:
            return FSM_TRAN(me,IV_HAND_OPER);
        case FSM_EXIT_SIGNAL:
            // Inits Curve FIFO
            FIFO_Init(&me->curve.super, &me->curve.points, IV_CURVE_SIZE, sizeof(IV_POINT_T));
            return FSM_HANDLED();   
    }
    
    // Default: Handled
    return FSM_HANDLED();
}
Exemplo n.º 7
0
Arquivo: IV.c Projeto: yanava/blfw
// Initial state. Just performs the initial transition
FSM_State IV_HAND_INITIAL(IV_TRACER_T *me, FSM_Event *e)
{
    // Goes to IDLE mode
    return FSM_TRAN(me,IV_HAND_IDLE);
}