plc_3

节点模型 aaa_plc

plc_3_第1张图片

进程模型 aaa_beacon

plc_3_第2张图片

SV

plc_3_第3张图片

TV

HB



#define IN_STRM 0

#define OUT_STRM 0


#define BEACON_ON_INIT 0
#define BEACON_OFF_INIT 1

#define INTRPT_BEACON_ON ((op_intrpt_type() == OPC_INTRPT_SELF) && (op_intrpt_code() == BEACON_ON_INIT))
#define INTRPT_BEACON_OFF ((op_intrpt_type() == OPC_INTRPT_SELF) && (op_intrpt_code() == BEACON_OFF_INIT))
#define INTRPT_STRM (op_intrpt_type() == OPC_INTRPT_STRM)

#define STAT_INTRPT (op_intrpt_type() == OPC_INTRPT_STAT)


//extern int beacon;

Init

difs = 1;


beaccon_on_event = op_intrpt_schedule_self (op_sim_time() + 5, BEACON_ON_INIT);

Beacon_on



Packet* beacon_pkt;

beacon_pkt = op_pk_create_fmt ("aaa_packet_beacon_on");

op_pk_nfd_set (beacon_pkt, "on", 1);

op_pk_print (beacon_pkt);

op_pk_send(beacon_pkt,OUT_STRM);




//beaccon_off_event = op_intrpt_schedule_self (op_sim_time() +1.5*difs, BEACON_OFF_INIT);

Beacon_off


Packet* beacon_pkt;

beacon_pkt = op_pk_create_fmt ("aaa_packet_beacon_on");

op_pk_nfd_set (beacon_pkt, "on", 0);

op_pk_print (beacon_pkt);

op_pk_send(beacon_pkt,OUT_STRM);



Strm


Packet* pkptr;
int node_flag;
int node_on;

pkptr = op_pk_get(IN_STRM);
op_pk_nfd_get_int32 (pkptr, "flag", &node_flag);


if (node_flag == 3)

{
    op_pk_print(pkptr);
op_pk_nfd_get_int32 (pkptr, "on", &node_on);

if(node_on == 1)
    {

    beaccon_off_event = op_intrpt_schedule_self (op_sim_time() +1.5*difs, BEACON_OFF_INIT);

    }

}





op_pk_destroy(pkptr);

Stat

if(op_ev_valid(beaccon_off_event) == OPC_TRUE)
    {
        op_ev_cancel(beaccon_off_event);
        printf("beaccon_off_event canceled\n");
    }

你可能感兴趣的:(opnet,最终协议)