Esempio n. 1
0
void dnp3_p_init_binoutcmd(void)
{
    H_RULE (bit,        h_bits(1, false));

    H_RULE (cs,         bit);
    H_RULE (status,     h_bits(7, false));

    H_ARULE(notime,  h_sequence(status, cs, NULL));
    H_ARULE(abstime, h_sequence(status, cs, dnp3_p_dnp3time, NULL));

    H_RULE (tcc,    h_int_range(h_bits(2, false), 0, 2));
    H_ARULE(crob,   h_sequence(h_bits(4, false),    // op type
                               bit,                 // queue flag (obsolete)
                               bit,                 // clear flag
                               tcc,
                               h_uint8(),           // count
                               h_uint32(),          // on-time [ms]
                               h_uint32(),          // off-time [ms]
                               status,              // 7 bits
                               dnp3_p_reserved(1),
                               NULL));
    H_ARULE(packed, bit);

    // group 12 (binary output commands)...
    dnp3_p_g12v1_binoutcmd_crob_oblock = dnp3_p_oblock(G_V(BINOUTCMD, CROB), crob);
    dnp3_p_g12v2_binoutcmd_pcb_oblock  = dnp3_p_single(G_V(BINOUTCMD, PCB), crob);
    dnp3_p_g12v3_binoutcmd_pcm_oblock  = dnp3_p_oblock_packed(G_V(BINOUTCMD, PCM), packed);
    dnp3_p_g12v3_binoutcmd_pcm_rblock  = dnp3_p_specific_rblock(G_V(BINOUTCMD, PCM));

    dnp3_p_binoutcmd_rblock = dnp3_p_rblock(G(BINOUTCMD),
                                            V(BINOUTCMD, CROB),
                                            V(BINOUTCMD, PCB),
                                            V(BINOUTCMD, PCM), 0);

    // group 13 (binary output command events)...
    H_RULE(oblock_notime,   dnp3_p_oblock(G_V(BINOUTCMDEV, NOTIME),  notime));
    H_RULE(oblock_abstime,  dnp3_p_oblock(G_V(BINOUTCMDEV, ABSTIME), abstime));

    dnp3_p_binoutcmdev_rblock = dnp3_p_rblock(G(BINOUTCMDEV),
                                              V(BINOUTCMDEV, NOTIME),
                                              V(BINOUTCMDEV, ABSTIME), 0);
    dnp3_p_binoutcmdev_oblock = h_choice(oblock_notime,
                                         oblock_abstime, NULL);
}
Esempio n. 2
0
void dnp3_p_init_counter(void)
{
    H_RULE (bit,        h_bits(1,false));
    H_RULE (ignore,     h_ignore(bit));
    H_RULE (reserved,   dnp3_p_reserved(1));

    H_ARULE(flags,      h_sequence(bit,         // ONLINE
                                   bit,         // RESTART
                                   bit,         // COMM_LOST
                                   bit,         // REMOTE_FORCED
                                   bit,         // LOCAL_FORCED
                                   ignore,      // (ROLLOVER - obsolete)
                                   bit,         // DISCONTINUITY
                                   reserved,
                                   NULL));
    H_RULE (val32,      h_uint32());
    H_RULE (val16,      h_uint16());

    H_ARULE(ctr32,          val32);
    H_ARULE(ctr16,          val16);
    H_ARULE(ctr32_flag,     h_sequence(flags, val32, NULL));
    H_ARULE(ctr16_flag,     h_sequence(flags, val16, NULL));
    H_ARULE(ctr32_flag_t,   h_sequence(flags, val32, dnp3_p_dnp3time, NULL));
    H_ARULE(ctr16_flag_t,   h_sequence(flags, val16, dnp3_p_dnp3time, NULL));

    // group 20: counters...
    H_RULE(oblock_32bit_flag,   dnp3_p_oblock(G_V(CTR, 32BIT), ctr32_flag));
    H_RULE(oblock_16bit_flag,   dnp3_p_oblock(G_V(CTR, 16BIT), ctr16_flag));
    H_RULE(oblock_32bit_noflag, dnp3_p_oblock(G_V(CTR, 32BIT_NOFLAG), ctr32));
    H_RULE(oblock_16bit_noflag, dnp3_p_oblock(G_V(CTR, 16BIT_NOFLAG), ctr16));

    dnp3_p_ctr_rblock = dnp3_p_rblock(G(CTR), V(CTR, 32BIT),
                                              V(CTR, 16BIT),
                                              V(CTR, 32BIT_NOFLAG),
                                              V(CTR, 32BIT_NOFLAG), 0);
    dnp3_p_ctr_fblock = dnp3_p_specific_rblock(G(CTR), DNP3_VARIATION_ANY);
    dnp3_p_ctr_oblock = h_choice(oblock_32bit_flag,
                                 oblock_16bit_flag,
                                 oblock_32bit_noflag,
                                 oblock_16bit_noflag,
                                 NULL);

    // group 21: frozen counters...
    H_RULE(oblock_frz32bit_flag,   dnp3_p_oblock(G_V(FROZENCTR, 32BIT), ctr32_flag));
    H_RULE(oblock_frz16bit_flag,   dnp3_p_oblock(G_V(FROZENCTR, 16BIT), ctr16_flag));
    H_RULE(oblock_frz32bit_flag_t, dnp3_p_oblock(G_V(FROZENCTR, 32BIT_TIME), ctr32_flag_t));
    H_RULE(oblock_frz16bit_flag_t, dnp3_p_oblock(G_V(FROZENCTR, 16BIT_TIME), ctr16_flag_t));
    H_RULE(oblock_frz32bit_noflag, dnp3_p_oblock(G_V(FROZENCTR, 32BIT_NOFLAG), ctr32));
    H_RULE(oblock_frz16bit_noflag, dnp3_p_oblock(G_V(FROZENCTR, 16BIT_NOFLAG), ctr16));

    dnp3_p_frozenctr_rblock = dnp3_p_rblock(G(FROZENCTR),
                                            V(FROZENCTR, 32BIT),
                                            V(FROZENCTR, 16BIT),
                                            V(FROZENCTR, 32BIT_TIME),
                                            V(FROZENCTR, 16BIT_TIME),
                                            V(FROZENCTR, 32BIT_NOFLAG),
                                            V(FROZENCTR, 32BIT_NOFLAG), 0);
    dnp3_p_frozenctr_oblock = h_choice(oblock_frz32bit_flag,
                                       oblock_frz16bit_flag,
                                       oblock_frz32bit_flag_t,
                                       oblock_frz16bit_flag_t,
                                       oblock_frz32bit_noflag,
                                       oblock_frz16bit_noflag,
                                       NULL);

    // group 22: counter events...
    H_RULE(oblock_ev32bit_flag,   dnp3_p_oblock(G_V(CTREV, 32BIT), ctr32_flag));
    H_RULE(oblock_ev16bit_flag,   dnp3_p_oblock(G_V(CTREV, 16BIT), ctr16_flag));
    H_RULE(oblock_ev32bit_flag_t, dnp3_p_oblock(G_V(CTREV, 32BIT_TIME), ctr32_flag_t));
    H_RULE(oblock_ev16bit_flag_t, dnp3_p_oblock(G_V(CTREV, 16BIT_TIME), ctr16_flag_t));

    dnp3_p_ctrev_rblock = dnp3_p_rblock(G(CTREV), V(CTREV, 32BIT),
                                                  V(CTREV, 16BIT),
                                                  V(CTREV, 32BIT_TIME),
                                                  V(CTREV, 16BIT_TIME), 0);
    dnp3_p_ctrev_oblock = h_choice(oblock_ev32bit_flag,
                                   oblock_ev16bit_flag,
                                   oblock_ev32bit_flag_t,
                                   oblock_ev16bit_flag_t,
                                   NULL);

    // group 21: frozen counter events...
    H_RULE(oblock_frzev32bit_flag,   dnp3_p_oblock(G_V(FROZENCTREV, 32BIT), ctr32_flag));
    H_RULE(oblock_frzev16bit_flag,   dnp3_p_oblock(G_V(FROZENCTREV, 16BIT), ctr16_flag));
    H_RULE(oblock_frzev32bit_flag_t, dnp3_p_oblock(G_V(FROZENCTREV, 32BIT_TIME), ctr32_flag_t));
    H_RULE(oblock_frzev16bit_flag_t, dnp3_p_oblock(G_V(FROZENCTREV, 16BIT_TIME), ctr16_flag_t));

    dnp3_p_frozenctrev_rblock = dnp3_p_rblock(G(FROZENCTREV),
                                              V(FROZENCTREV, 32BIT),
                                              V(FROZENCTREV, 16BIT),
                                              V(FROZENCTREV, 32BIT_TIME),
                                              V(FROZENCTREV, 16BIT_TIME), 0);
    dnp3_p_frozenctrev_oblock = h_choice(oblock_frzev32bit_flag,
                                         oblock_frzev16bit_flag,
                                         oblock_frzev32bit_flag_t,
                                         oblock_frzev16bit_flag_t,
                                         NULL);
}