blob: 000679def9216f3eb368e57f76e735f343575cc4 [file] [log] [blame]
// This C++ source file was generated by the TTCN-3 compiler
// of the TTCN-3 Test Executor version CRL 113 200/6 R6A
// for Lénárd Nagy (elnrnag@elx78355y6x) on Thu Oct 24 10:29:40 2019
// Copyright (c) 2000-2019 Ericsson Telecom AB
// Do not edit this file unless you know what you are doing.
/* Including header files */
#include "Isobus.hh"
namespace Isobus {
/* Prototypes of static functions */
static void pre_init_module();
static void post_init_module();
/* Literal string constants */
static const unsigned char os_19_octets[] = { 0 },
os_23_octets[] = { 0, 0 },
os_16_octets[] = { 0, 0, 0, 255 },
os_15_octets[] = { 0, 0, 255, 0 },
os_14_octets[] = { 0, 255, 0, 0 },
os_13_octets[] = { 1, 0, 0, 0 },
os_12_octets[] = { 2, 0, 0, 0 },
os_11_octets[] = { 28, 0, 0, 0 },
os_0_octets[] = { 199, 0, 0 },
os_1_octets[] = { 200, 0, 0 },
os_18_octets[] = { 216 },
os_2_octets[] = { 230, 0, 0 },
os_3_octets[] = { 231, 0, 0 },
os_4_octets[] = { 234, 0, 0 },
os_5_octets[] = { 235, 0, 0 },
os_6_octets[] = { 236, 0, 0 },
os_7_octets[] = { 237, 0, 0 },
os_20_octets[] = { 238 },
os_9_octets[] = { 238, 255, 0 },
os_8_octets[] = { 238, 255, 254 },
os_17_octets[] = { 254 },
os_10_octets[] = { 254, 216, 0 },
os_21_octets[] = { 255 };
static const OCTETSTRING os_22(0, NULL),
os_19(1, os_19_octets),
os_23(2, os_23_octets),
os_16(4, os_16_octets),
os_15(4, os_15_octets),
os_14(4, os_14_octets),
os_13(4, os_13_octets),
os_12(4, os_12_octets),
os_11(4, os_11_octets),
os_0(3, os_0_octets),
os_1(3, os_1_octets),
os_18(1, os_18_octets),
os_2(3, os_2_octets),
os_3(3, os_3_octets),
os_4(3, os_4_octets),
os_5(3, os_5_octets),
os_6(3, os_6_octets),
os_7(3, os_7_octets),
os_20(1, os_20_octets),
os_9(3, os_9_octets),
os_8(3, os_8_octets),
os_17(1, os_17_octets),
os_10(3, os_10_octets),
os_21(1, os_21_octets);
static const unsigned char module_checksum[] = { 0xf6, 0x9c, 0xa1, 0xef, 0xcb, 0xb0, 0x54, 0x87, 0x7c, 0x99, 0xc2, 0x03, 0x00, 0xfe, 0xf8, 0x32 };
/* Global variable definitions */
static OCTETSTRING const_ISOBUS__PRIORITY__MASK;
const OCTETSTRING& ISOBUS__PRIORITY__MASK = const_ISOBUS__PRIORITY__MASK;
static OCTETSTRING const_ISOBUS__RESERVED__MASK;
const OCTETSTRING& ISOBUS__RESERVED__MASK = const_ISOBUS__RESERVED__MASK;
static OCTETSTRING const_ISOBUS__DATAPAGE__MASK;
const OCTETSTRING& ISOBUS__DATAPAGE__MASK = const_ISOBUS__DATAPAGE__MASK;
static OCTETSTRING const_ISOBUS__PDUFORMAT__MASK;
const OCTETSTRING& ISOBUS__PDUFORMAT__MASK = const_ISOBUS__PDUFORMAT__MASK;
static OCTETSTRING const_ISOBUS__PDUSPECIFIC__MASK;
const OCTETSTRING& ISOBUS__PDUSPECIFIC__MASK = const_ISOBUS__PDUSPECIFIC__MASK;
static OCTETSTRING const_ISOBUS__SOURCEADDRESS__MASK;
const OCTETSTRING& ISOBUS__SOURCEADDRESS__MASK = const_ISOBUS__SOURCEADDRESS__MASK;
const TTCN_RAWdescriptor_t Priority_raw_ = {6,SG_NO,ORDER_LSB,ORDER_MSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,6,CharCoding::UNKNOWN,NULL,false};
const XERdescriptor_t Priority_xer_ = { {"Priority>\n", "Priority>\n"}, {10, 10}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t Priority_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t Priority_descr_ = { "@Isobus.Priority", &BITSTRING_ber_, &Priority_raw_, NULL, &Priority_xer_, &BITSTRING_json_, &Priority_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t J1939_prio_raw_ = {6,SG_NO,ORDER_LSB,ORDER_MSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,6,CharCoding::UNKNOWN,NULL,false};
const XERdescriptor_t J1939_prio_xer_ = { {"prio>\n", "prio>\n"}, {6, 6}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t J1939_prio_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t J1939_prio_descr_ = { "@Isobus.J1939.prio", &BITSTRING_ber_, &J1939_prio_raw_, NULL, &J1939_prio_xer_, &BITSTRING_json_, &J1939_prio_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t J1939_res_raw_ = {1,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,1,CharCoding::UNKNOWN,NULL,false};
const XERdescriptor_t J1939_res_xer_ = { {"res>\n", "res>\n"}, {5, 5}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t J1939_res_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t J1939_res_descr_ = { "@Isobus.J1939.res", &BITSTRING_ber_, &J1939_res_raw_, NULL, &J1939_res_xer_, &BITSTRING_json_, &J1939_res_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t J1939_dp_raw_ = {1,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,1,CharCoding::UNKNOWN,NULL,false};
const XERdescriptor_t J1939_dp_xer_ = { {"dp>\n", "dp>\n"}, {4, 4}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t J1939_dp_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t J1939_dp_descr_ = { "@Isobus.J1939.dp", &BITSTRING_ber_, &J1939_dp_raw_, NULL, &J1939_dp_xer_, &BITSTRING_json_, &J1939_dp_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t J1939_pf_raw_ = {8,SG_NO,ORDER_LSB,ORDER_MSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,1,CharCoding::UNKNOWN,NULL,false};
const XERdescriptor_t J1939_pf_xer_ = { {"pf>\n", "pf>\n"}, {4, 4}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const int J1939_pf_oer_ext_arr_[0] = {};
const int J1939_pf_oer_p_[0] = {};
const TTCN_OERdescriptor_t J1939_pf_oer_ = { -1, TRUE, 1, FALSE, 0, 0, J1939_pf_oer_ext_arr_, 0, J1939_pf_oer_p_};
const TTCN_Typedescriptor_t J1939_pf_descr_ = { "@Isobus.J1939.pf", &OCTETSTRING_ber_, &J1939_pf_raw_, &OCTETSTRING_text_, &J1939_pf_xer_, &OCTETSTRING_json_, &J1939_pf_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t J1939_ps_raw_ = {8,SG_NO,ORDER_LSB,ORDER_MSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,1,CharCoding::UNKNOWN,NULL,false};
const XERdescriptor_t J1939_ps_xer_ = { {"ps>\n", "ps>\n"}, {4, 4}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const int J1939_ps_oer_ext_arr_[0] = {};
const int J1939_ps_oer_p_[0] = {};
const TTCN_OERdescriptor_t J1939_ps_oer_ = { -1, TRUE, 1, FALSE, 0, 0, J1939_ps_oer_ext_arr_, 0, J1939_ps_oer_p_};
const TTCN_Typedescriptor_t J1939_ps_descr_ = { "@Isobus.J1939.ps", &OCTETSTRING_ber_, &J1939_ps_raw_, &OCTETSTRING_text_, &J1939_ps_xer_, &OCTETSTRING_json_, &J1939_ps_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t J1939_sa_raw_ = {8,SG_NO,ORDER_LSB,ORDER_MSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,1,CharCoding::UNKNOWN,NULL,false};
const XERdescriptor_t J1939_sa_xer_ = { {"sa>\n", "sa>\n"}, {4, 4}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const int J1939_sa_oer_ext_arr_[0] = {};
const int J1939_sa_oer_p_[0] = {};
const TTCN_OERdescriptor_t J1939_sa_oer_ = { -1, TRUE, 1, FALSE, 0, 0, J1939_sa_oer_ext_arr_, 0, J1939_sa_oer_p_};
const TTCN_Typedescriptor_t J1939_sa_descr_ = { "@Isobus.J1939.sa", &OCTETSTRING_ber_, &J1939_sa_raw_, &OCTETSTRING_text_, &J1939_sa_xer_, &OCTETSTRING_json_, &J1939_sa_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t J1939_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
// No XER for J1939
const TTCN_Typedescriptor_t J1939_descr_ = { "@Isobus.J1939", NULL, &J1939_raw_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t J1939mod_prio_raw_ = {6,SG_NO,ORDER_LSB,ORDER_MSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,6,CharCoding::UNKNOWN,NULL,false};
const XERdescriptor_t J1939mod_prio_xer_ = { {"prio>\n", "prio>\n"}, {6, 6}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t J1939mod_prio_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t J1939mod_prio_descr_ = { "@Isobus.J1939mod.prio", &BITSTRING_ber_, &J1939mod_prio_raw_, NULL, &J1939mod_prio_xer_, &BITSTRING_json_, &J1939mod_prio_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t J1939mod_res_raw_ = {1,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,1,CharCoding::UNKNOWN,NULL,false};
const XERdescriptor_t J1939mod_res_xer_ = { {"res>\n", "res>\n"}, {5, 5}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t J1939mod_res_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t J1939mod_res_descr_ = { "@Isobus.J1939mod.res", &BITSTRING_ber_, &J1939mod_res_raw_, NULL, &J1939mod_res_xer_, &BITSTRING_json_, &J1939mod_res_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t J1939mod_dp_raw_ = {1,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,1,CharCoding::UNKNOWN,NULL,false};
const XERdescriptor_t J1939mod_dp_xer_ = { {"dp>\n", "dp>\n"}, {4, 4}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t J1939mod_dp_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t J1939mod_dp_descr_ = { "@Isobus.J1939mod.dp", &BITSTRING_ber_, &J1939mod_dp_raw_, NULL, &J1939mod_dp_xer_, &BITSTRING_json_, &J1939mod_dp_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t J1939mod_pf_raw_ = {8,SG_NO,ORDER_LSB,ORDER_MSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,1,CharCoding::UNKNOWN,NULL,false};
const XERdescriptor_t J1939mod_pf_xer_ = { {"pf>\n", "pf>\n"}, {4, 4}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const int J1939mod_pf_oer_ext_arr_[0] = {};
const int J1939mod_pf_oer_p_[0] = {};
const TTCN_OERdescriptor_t J1939mod_pf_oer_ = { -1, TRUE, 1, FALSE, 0, 0, J1939mod_pf_oer_ext_arr_, 0, J1939mod_pf_oer_p_};
const TTCN_Typedescriptor_t J1939mod_pf_descr_ = { "@Isobus.J1939mod.pf", &OCTETSTRING_ber_, &J1939mod_pf_raw_, &OCTETSTRING_text_, &J1939mod_pf_xer_, &OCTETSTRING_json_, &J1939mod_pf_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t J1939mod_ps_raw_ = {8,SG_NO,ORDER_LSB,ORDER_MSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,1,CharCoding::UNKNOWN,NULL,false};
const XERdescriptor_t J1939mod_ps_xer_ = { {"ps>\n", "ps>\n"}, {4, 4}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const int J1939mod_ps_oer_ext_arr_[0] = {};
const int J1939mod_ps_oer_p_[0] = {};
const TTCN_OERdescriptor_t J1939mod_ps_oer_ = { -1, TRUE, 1, FALSE, 0, 0, J1939mod_ps_oer_ext_arr_, 0, J1939mod_ps_oer_p_};
const TTCN_Typedescriptor_t J1939mod_ps_descr_ = { "@Isobus.J1939mod.ps", &OCTETSTRING_ber_, &J1939mod_ps_raw_, &OCTETSTRING_text_, &J1939mod_ps_xer_, &OCTETSTRING_json_, &J1939mod_ps_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t J1939mod_sa_raw_ = {8,SG_NO,ORDER_LSB,ORDER_MSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,1,CharCoding::UNKNOWN,NULL,false};
const XERdescriptor_t J1939mod_sa_xer_ = { {"sa>\n", "sa>\n"}, {4, 4}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const int J1939mod_sa_oer_ext_arr_[0] = {};
const int J1939mod_sa_oer_p_[0] = {};
const TTCN_OERdescriptor_t J1939mod_sa_oer_ = { -1, TRUE, 1, FALSE, 0, 0, J1939mod_sa_oer_ext_arr_, 0, J1939mod_sa_oer_p_};
const TTCN_Typedescriptor_t J1939mod_sa_descr_ = { "@Isobus.J1939mod.sa", &OCTETSTRING_ber_, &J1939mod_sa_raw_, &OCTETSTRING_text_, &J1939mod_sa_xer_, &OCTETSTRING_json_, &J1939mod_sa_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t J1939mod_comp_raw_ = {24,SG_NO,ORDER_LSB,ORDER_MSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,3,CharCoding::UNKNOWN,NULL,false};
const XERdescriptor_t J1939mod_comp_xer_ = { {"comp>\n", "comp>\n"}, {6, 6}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const int J1939mod_comp_oer_ext_arr_[0] = {};
const int J1939mod_comp_oer_p_[0] = {};
const TTCN_OERdescriptor_t J1939mod_comp_oer_ = { -1, TRUE, 3, FALSE, 0, 0, J1939mod_comp_oer_ext_arr_, 0, J1939mod_comp_oer_p_};
const TTCN_Typedescriptor_t J1939mod_comp_descr_ = { "@Isobus.J1939mod.comp", &OCTETSTRING_ber_, &J1939mod_comp_raw_, &OCTETSTRING_text_, &J1939mod_comp_xer_, &OCTETSTRING_json_, &J1939mod_comp_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t J1939mod_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_MSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
// No XER for J1939mod
const TTCN_Typedescriptor_t J1939mod_descr_ = { "@Isobus.J1939mod", NULL, &J1939mod_raw_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t AnyIsoBusPdu_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
// No XER for AnyIsoBusPdu
const TTCN_Typedescriptor_t AnyIsoBusPdu_descr_ = { "@Isobus.AnyIsoBusPdu", NULL, &AnyIsoBusPdu_raw_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t CAN__frame__j1939_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
// No XER for CAN__frame__j1939
const TTCN_Typedescriptor_t CAN__frame__j1939_descr_ = { "@Isobus.CAN_frame_j1939", NULL, &CAN__frame__j1939_raw_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t CAN__frame__j1939mod_can__pdu_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
// No XER for CAN__frame__j1939mod_can__pdu
const TTCN_Typedescriptor_t CAN__frame__j1939mod_can__pdu_descr_ = { "@Isobus.CAN_frame_j1939mod.can_pdu", NULL, &CAN__frame__j1939mod_can__pdu_raw_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t CAN__frame__j1939mod_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
// No XER for CAN__frame__j1939mod
const TTCN_Typedescriptor_t CAN__frame__j1939mod_descr_ = { "@Isobus.CAN_frame_j1939mod", NULL, &CAN__frame__j1939mod_raw_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
TTCN_Module module_object("Isobus", __DATE__, __TIME__, module_checksum, pre_init_module, NULL, 0U, 4294967295U, 4294967295U, 4294967295U, NULL, 0LU, 0, post_init_module, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
static const RuntimeVersionChecker ver_checker( current_runtime_version.requires_major_version_6,
current_runtime_version.requires_minor_version_6,
current_runtime_version.requires_patch_level_0, current_runtime_version.requires_runtime_1);
/* Member functions of C++ classes */
J1939::J1939()
{
}
J1939::J1939(const BITSTRING& par_prio,
const BITSTRING& par_res,
const BITSTRING& par_dp,
const OCTETSTRING& par_pf,
const OCTETSTRING& par_ps,
const OCTETSTRING& par_sa)
: field_prio(par_prio),
field_res(par_res),
field_dp(par_dp),
field_pf(par_pf),
field_ps(par_ps),
field_sa(par_sa)
{
}
J1939::J1939(const J1939& other_value)
{
if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @Isobus.J1939.");
if (other_value.prio().is_bound()) field_prio = other_value.prio();
else field_prio.clean_up();
if (other_value.res().is_bound()) field_res = other_value.res();
else field_res.clean_up();
if (other_value.dp().is_bound()) field_dp = other_value.dp();
else field_dp.clean_up();
if (other_value.pf().is_bound()) field_pf = other_value.pf();
else field_pf.clean_up();
if (other_value.ps().is_bound()) field_ps = other_value.ps();
else field_ps.clean_up();
if (other_value.sa().is_bound()) field_sa = other_value.sa();
else field_sa.clean_up();
}
void J1939::clean_up()
{
field_prio.clean_up();
field_res.clean_up();
field_dp.clean_up();
field_pf.clean_up();
field_ps.clean_up();
field_sa.clean_up();
}
const TTCN_Typedescriptor_t* J1939::get_descriptor() const { return &J1939_descr_; }
J1939& J1939::operator=(const J1939& other_value)
{
if (this != &other_value) {
if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @Isobus.J1939.");
if (other_value.prio().is_bound()) field_prio = other_value.prio();
else field_prio.clean_up();
if (other_value.res().is_bound()) field_res = other_value.res();
else field_res.clean_up();
if (other_value.dp().is_bound()) field_dp = other_value.dp();
else field_dp.clean_up();
if (other_value.pf().is_bound()) field_pf = other_value.pf();
else field_pf.clean_up();
if (other_value.ps().is_bound()) field_ps = other_value.ps();
else field_ps.clean_up();
if (other_value.sa().is_bound()) field_sa = other_value.sa();
else field_sa.clean_up();
}
return *this;
}
boolean J1939::operator==(const J1939& other_value) const
{
return field_prio==other_value.field_prio
&& field_res==other_value.field_res
&& field_dp==other_value.field_dp
&& field_pf==other_value.field_pf
&& field_ps==other_value.field_ps
&& field_sa==other_value.field_sa;
}
boolean J1939::is_bound() const
{
return (field_prio.is_bound())
|| (field_res.is_bound())
|| (field_dp.is_bound())
|| (field_pf.is_bound())
|| (field_ps.is_bound())
|| (field_sa.is_bound());
}
boolean J1939::is_value() const
{
return field_prio.is_value()
&& field_res.is_value()
&& field_dp.is_value()
&& field_pf.is_value()
&& field_ps.is_value()
&& field_sa.is_value();
}
void J1939::log() const
{
if (!is_bound()) {
TTCN_Logger::log_event_unbound();
return;
}
TTCN_Logger::log_event_str("{ prio := ");
field_prio.log();
TTCN_Logger::log_event_str(", res := ");
field_res.log();
TTCN_Logger::log_event_str(", dp := ");
field_dp.log();
TTCN_Logger::log_event_str(", pf := ");
field_pf.log();
TTCN_Logger::log_event_str(", ps := ");
field_ps.log();
TTCN_Logger::log_event_str(", sa := ");
field_sa.log();
TTCN_Logger::log_event_str(" }");
}
void J1939::set_param(Module_Param& param)
{
param.basic_check(Module_Param::BC_VALUE, "record value");
switch (param.get_type()) {
case Module_Param::MP_Value_List:
if (6<param.get_size()) {
param.error("record value of type @Isobus.J1939 has 6 fields but list value has %d fields", (int)param.get_size());
}
if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) prio().set_param(*param.get_elem(0));
if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) res().set_param(*param.get_elem(1));
if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) dp().set_param(*param.get_elem(2));
if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) pf().set_param(*param.get_elem(3));
if (param.get_size()>4 && param.get_elem(4)->get_type()!=Module_Param::MP_NotUsed) ps().set_param(*param.get_elem(4));
if (param.get_size()>5 && param.get_elem(5)->get_type()!=Module_Param::MP_NotUsed) sa().set_param(*param.get_elem(5));
break;
case Module_Param::MP_Assignment_List: {
Vector<bool> value_used(param.get_size());
value_used.resize(param.get_size(), FALSE);
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "prio")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
prio().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "res")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
res().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "dp")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
dp().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "pf")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
pf().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "ps")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
ps().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "sa")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
sa().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
Module_Param* const curr_param = param.get_elem(val_idx);
curr_param->error("Non existent field name in type @Isobus.J1939: %s", curr_param->get_id()->get_name());
break;
}
} break;
default:
param.type_error("record value", "@Isobus.J1939");
}
}
void J1939::set_implicit_omit()
{
if (prio().is_bound()) prio().set_implicit_omit();
if (res().is_bound()) res().set_implicit_omit();
if (dp().is_bound()) dp().set_implicit_omit();
if (pf().is_bound()) pf().set_implicit_omit();
if (ps().is_bound()) ps().set_implicit_omit();
if (sa().is_bound()) sa().set_implicit_omit();
}
void J1939::encode_text(Text_Buf& text_buf) const
{
field_prio.encode_text(text_buf);
field_res.encode_text(text_buf);
field_dp.encode_text(text_buf);
field_pf.encode_text(text_buf);
field_ps.encode_text(text_buf);
field_sa.encode_text(text_buf);
}
void J1939::decode_text(Text_Buf& text_buf)
{
field_prio.decode_text(text_buf);
field_res.decode_text(text_buf);
field_dp.decode_text(text_buf);
field_pf.decode_text(text_buf);
field_ps.decode_text(text_buf);
field_sa.decode_text(text_buf);
}
void J1939::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const
{
va_list pvar;
va_start(pvar, p_coding);
switch(p_coding) {
case TTCN_EncDec::CT_BER: {
TTCN_EncDec_ErrorContext ec("While BER-encoding type '%s': ", p_td.name);
unsigned BER_coding=va_arg(pvar, unsigned);
BER_encode_chk_coding(BER_coding);
ASN_BER_TLV_t *tlv=BER_encode_TLV(p_td, BER_coding);
tlv->put_in_buffer(p_buf);
ASN_BER_TLV_t::destruct(tlv);
break;}
case TTCN_EncDec::CT_RAW: {
TTCN_EncDec_ErrorContext ec("While RAW-encoding type '%s': ", p_td.name);
if(!p_td.raw)
TTCN_EncDec_ErrorContext::error_internal
("No RAW descriptor available for type '%s'.", p_td.name);
RAW_enc_tr_pos rp;
rp.level=0;
rp.pos=NULL;
RAW_enc_tree root(FALSE, NULL, &rp, 1, p_td.raw);
RAW_encode(p_td, root);
root.put_to_buf(p_buf);
break;}
case TTCN_EncDec::CT_TEXT: {
TTCN_EncDec_ErrorContext ec("While TEXT-encoding type '%s': ", p_td.name);
if(!p_td.text)
TTCN_EncDec_ErrorContext::error_internal
("No TEXT descriptor available for type '%s'.", p_td.name);
TEXT_encode(p_td,p_buf);
break;}
case TTCN_EncDec::CT_XER: {
TTCN_EncDec_ErrorContext ec("While XER-encoding type '%s': ", p_td.name);
unsigned XER_coding=va_arg(pvar, unsigned);
XER_encode_chk_coding(XER_coding, p_td);
XER_encode(*(p_td.xer),p_buf, XER_coding, 0, 0, 0);
p_buf.put_c('\n');
break;}
case TTCN_EncDec::CT_JSON: {
TTCN_EncDec_ErrorContext ec("While JSON-encoding type '%s': ", p_td.name);
if(!p_td.json)
TTCN_EncDec_ErrorContext::error_internal
("No JSON descriptor available for type '%s'.", p_td.name);
JSON_Tokenizer tok(va_arg(pvar, int) != 0);
JSON_encode(p_td, tok);
p_buf.put_s(tok.get_buffer_length(), (const unsigned char*)tok.get_buffer());
break;}
case TTCN_EncDec::CT_OER: {
TTCN_EncDec_ErrorContext ec("While OER-encoding type '%s': ", p_td.name);
if(!p_td.oer)
TTCN_EncDec_ErrorContext::error_internal
("No OER descriptor available for type '%s'.", p_td.name);
OER_encode(p_td, p_buf);
break;}
default:
TTCN_error("Unknown coding method requested to encode type '%s'", p_td.name);
}
va_end(pvar);
}
void J1939::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...)
{
va_list pvar;
va_start(pvar, p_coding);
switch(p_coding) {
case TTCN_EncDec::CT_BER: {
TTCN_EncDec_ErrorContext ec("While BER-decoding type '%s': ", p_td.name);
unsigned L_form=va_arg(pvar, unsigned);
ASN_BER_TLV_t tlv;
BER_decode_str2TLV(p_buf, tlv, L_form);
BER_decode_TLV(p_td, tlv, L_form);
if(tlv.isComplete) p_buf.increase_pos(tlv.get_len());
break;}
case TTCN_EncDec::CT_RAW: {
TTCN_EncDec_ErrorContext ec("While RAW-decoding type '%s': ", p_td.name);
if(!p_td.raw)
TTCN_EncDec_ErrorContext::error_internal
("No RAW descriptor available for type '%s'.", p_td.name);
raw_order_t r_order;
switch(p_td.raw->top_bit_order) {
case TOP_BIT_LEFT:
r_order=ORDER_LSB;
break;
case TOP_BIT_RIGHT:
default:
r_order=ORDER_MSB;
}
int rawr = RAW_decode(p_td, p_buf, p_buf.get_len()*8, r_order);
if(rawr<0) switch (-rawr) {
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
ec.error((TTCN_EncDec::error_type_t)-rawr, "Can not decode type '%s', because incomplete message was received", p_td.name);
break;
case 1:
default:
ec.error(TTCN_EncDec::ET_INVAL_MSG, "Can not decode type '%s', because invalid message was received", p_td.name);
break;
}
break;}
case TTCN_EncDec::CT_TEXT: {
Limit_Token_List limit;
TTCN_EncDec_ErrorContext ec("While TEXT-decoding type '%s': ", p_td.name);
if(!p_td.text)
TTCN_EncDec_ErrorContext::error_internal
("No TEXT descriptor available for type '%s'.", p_td.name);
const unsigned char *b_data=p_buf.get_data();
if(b_data[p_buf.get_len()-1]!='\0'){
p_buf.set_pos(p_buf.get_len());
p_buf.put_zero(8,ORDER_LSB);
p_buf.rewind();
}
if(TEXT_decode(p_td,p_buf,limit)<0)
ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
break;}
case TTCN_EncDec::CT_XER: {
TTCN_EncDec_ErrorContext ec("While XER-decoding type '%s': ", p_td.name);
unsigned XER_coding=va_arg(pvar, unsigned);
XER_encode_chk_coding(XER_coding, p_td);
XmlReaderWrap reader(p_buf);
for (int rd_ok=reader.Read(); rd_ok==1; rd_ok=reader.Read()) {
if (reader.NodeType() == XML_READER_TYPE_ELEMENT) break;
}
XER_decode(*(p_td.xer), reader, XER_coding | XER_TOPLEVEL, XER_NONE, 0);
size_t bytes = reader.ByteConsumed();
p_buf.set_pos(bytes);
break;}
case TTCN_EncDec::CT_JSON: {
TTCN_EncDec_ErrorContext ec("While JSON-decoding type '%s': ", p_td.name);
if(!p_td.json)
TTCN_EncDec_ErrorContext::error_internal
("No JSON descriptor available for type '%s'.", p_td.name);
JSON_Tokenizer tok((const char*)p_buf.get_data(), p_buf.get_len());
if(JSON_decode(p_td, tok, FALSE)<0)
ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
p_buf.set_pos(tok.get_buf_pos());
break;}
case TTCN_EncDec::CT_OER: {
TTCN_EncDec_ErrorContext ec("While OER-decoding type '%s': ", p_td.name);
if(!p_td.oer)
TTCN_EncDec_ErrorContext::error_internal
("No OER descriptor available for type '%s'.", p_td.name);
OER_struct p_oer;
OER_decode(p_td, p_buf, p_oer);
break;}
default:
TTCN_error("Unknown coding method requested to decode type '%s'", p_td.name);
}
va_end(pvar);
}
int J1939::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int limit, raw_order_t top_bit_ord, boolean no_err, int, boolean, const RAW_Force_Omit* force_omit)
{ (void)no_err;
int prepaddlength=p_buf.increase_pos_padd(p_td.raw->prepadding);
limit-=prepaddlength;
size_t last_decoded_pos = p_buf.get_pos_bit();
int decoded_length = 0;
int decoded_field_length = 0;
raw_order_t local_top_order;
if(p_td.raw->top_bit_order==TOP_BIT_INHERITED)local_top_order=top_bit_ord;
else if(p_td.raw->top_bit_order==TOP_BIT_RIGHT)local_top_order=ORDER_MSB;
else local_top_order=ORDER_LSB;
RAW_Force_Omit field_0_force_omit(0, force_omit, J1939_prio_descr_.raw->forceomit);
decoded_field_length = field_prio.RAW_decode(J1939_prio_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_0_force_omit);
if (decoded_field_length < 0) return decoded_field_length;
decoded_length+=decoded_field_length;
limit-=decoded_field_length;
last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
RAW_Force_Omit field_1_force_omit(1, force_omit, J1939_res_descr_.raw->forceomit);
decoded_field_length = field_res.RAW_decode(J1939_res_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_1_force_omit);
if (decoded_field_length < 0) return decoded_field_length;
decoded_length+=decoded_field_length;
limit-=decoded_field_length;
last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
RAW_Force_Omit field_2_force_omit(2, force_omit, J1939_dp_descr_.raw->forceomit);
decoded_field_length = field_dp.RAW_decode(J1939_dp_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_2_force_omit);
if (decoded_field_length < 0) return decoded_field_length;
decoded_length+=decoded_field_length;
limit-=decoded_field_length;
last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
RAW_Force_Omit field_3_force_omit(3, force_omit, J1939_pf_descr_.raw->forceomit);
decoded_field_length = field_pf.RAW_decode(J1939_pf_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_3_force_omit);
if (decoded_field_length < 0) return decoded_field_length;
decoded_length+=decoded_field_length;
limit-=decoded_field_length;
last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
RAW_Force_Omit field_4_force_omit(4, force_omit, J1939_ps_descr_.raw->forceomit);
decoded_field_length = field_ps.RAW_decode(J1939_ps_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_4_force_omit);
if (decoded_field_length < 0) return decoded_field_length;
decoded_length+=decoded_field_length;
limit-=decoded_field_length;
last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
RAW_Force_Omit field_5_force_omit(5, force_omit, J1939_sa_descr_.raw->forceomit);
decoded_field_length = field_sa.RAW_decode(J1939_sa_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_5_force_omit);
if (decoded_field_length < 0) return decoded_field_length;
decoded_length+=decoded_field_length;
limit-=decoded_field_length;
last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
p_buf.set_pos_bit(last_decoded_pos);
return decoded_length+prepaddlength+p_buf.increase_pos_padd(p_td.raw->padding);
}
int J1939::RAW_encode(const TTCN_Typedescriptor_t&, RAW_enc_tree& myleaf) const {
if (!is_bound()) TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value.");
int encoded_length = 0;
myleaf.isleaf = FALSE;
myleaf.body.node.num_of_nodes = 6;
myleaf.body.node.nodes = init_nodes_of_enc_tree(6);
myleaf.body.node.nodes[0] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 0, J1939_prio_descr_.raw);
myleaf.body.node.nodes[1] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 1, J1939_res_descr_.raw);
myleaf.body.node.nodes[2] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 2, J1939_dp_descr_.raw);
myleaf.body.node.nodes[3] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 3, J1939_pf_descr_.raw);
myleaf.body.node.nodes[4] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 4, J1939_ps_descr_.raw);
myleaf.body.node.nodes[5] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 5, J1939_sa_descr_.raw);
encoded_length += field_prio.RAW_encode(J1939_prio_descr_, *myleaf.body.node.nodes[0]);
encoded_length += field_res.RAW_encode(J1939_res_descr_, *myleaf.body.node.nodes[1]);
encoded_length += field_dp.RAW_encode(J1939_dp_descr_, *myleaf.body.node.nodes[2]);
encoded_length += field_pf.RAW_encode(J1939_pf_descr_, *myleaf.body.node.nodes[3]);
encoded_length += field_ps.RAW_encode(J1939_ps_descr_, *myleaf.body.node.nodes[4]);
encoded_length += field_sa.RAW_encode(J1939_sa_descr_, *myleaf.body.node.nodes[5]);
return myleaf.length = encoded_length;
}
struct J1939_template::single_value_struct {
BITSTRING_template field_prio;
BITSTRING_template field_res;
BITSTRING_template field_dp;
OCTETSTRING_template field_pf;
OCTETSTRING_template field_ps;
OCTETSTRING_template field_sa;
};
void J1939_template::set_specific()
{
if (template_selection != SPECIFIC_VALUE) {
template_sel old_selection = template_selection;
clean_up();
single_value = new single_value_struct;
set_selection(SPECIFIC_VALUE);
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) {
single_value->field_prio = ANY_VALUE;
single_value->field_res = ANY_VALUE;
single_value->field_dp = ANY_VALUE;
single_value->field_pf = ANY_VALUE;
single_value->field_ps = ANY_VALUE;
single_value->field_sa = ANY_VALUE;
}
}
}
void J1939_template::copy_value(const J1939& other_value)
{
single_value = new single_value_struct;
if (other_value.prio().is_bound()) {
single_value->field_prio = other_value.prio();
} else {
single_value->field_prio.clean_up();
}
if (other_value.res().is_bound()) {
single_value->field_res = other_value.res();
} else {
single_value->field_res.clean_up();
}
if (other_value.dp().is_bound()) {
single_value->field_dp = other_value.dp();
} else {
single_value->field_dp.clean_up();
}
if (other_value.pf().is_bound()) {
single_value->field_pf = other_value.pf();
} else {
single_value->field_pf.clean_up();
}
if (other_value.ps().is_bound()) {
single_value->field_ps = other_value.ps();
} else {
single_value->field_ps.clean_up();
}
if (other_value.sa().is_bound()) {
single_value->field_sa = other_value.sa();
} else {
single_value->field_sa.clean_up();
}
set_selection(SPECIFIC_VALUE);
}
void J1939_template::copy_template(const J1939_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
if (UNINITIALIZED_TEMPLATE != other_value.prio().get_selection()) {
single_value->field_prio = other_value.prio();
} else {
single_value->field_prio.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.res().get_selection()) {
single_value->field_res = other_value.res();
} else {
single_value->field_res.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.dp().get_selection()) {
single_value->field_dp = other_value.dp();
} else {
single_value->field_dp.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.pf().get_selection()) {
single_value->field_pf = other_value.pf();
} else {
single_value->field_pf.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.ps().get_selection()) {
single_value->field_ps = other_value.ps();
} else {
single_value->field_ps.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.sa().get_selection()) {
single_value->field_sa = other_value.sa();
} else {
single_value->field_sa.clean_up();
}
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
value_list.n_values = other_value.value_list.n_values;
value_list.list_value = new J1939_template[value_list.n_values];
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]);
break;
default:
TTCN_error("Copying an uninitialized/unsupported template of type @Isobus.J1939.");
break;
}
set_selection(other_value);
}
J1939_template::J1939_template()
{
}
J1939_template::J1939_template(template_sel other_value)
: Base_Template(other_value)
{
check_single_selection(other_value);
}
J1939_template::J1939_template(const J1939& other_value)
{
copy_value(other_value);
}
J1939_template::J1939_template(const OPTIONAL<J1939>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const J1939&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @Isobus.J1939 from an unbound optional field.");
}
}
J1939_template::J1939_template(const J1939_template& other_value)
: Base_Template()
{
copy_template(other_value);
}
J1939_template::~J1939_template()
{
clean_up();
}
J1939_template& J1939_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}
J1939_template& J1939_template::operator=(const J1939& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}
J1939_template& J1939_template::operator=(const OPTIONAL<J1939>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const J1939&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Assignment of an unbound optional field to a template of type @Isobus.J1939.");
}
return *this;
}
J1939_template& J1939_template::operator=(const J1939_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}
boolean J1939_template::match(const J1939& other_value, boolean legacy) const
{
if (!other_value.is_bound()) return FALSE;
switch (template_selection) {
case ANY_VALUE:
case ANY_OR_OMIT:
return TRUE;
case OMIT_VALUE:
return FALSE;
case SPECIFIC_VALUE:
if(!other_value.prio().is_bound()) return FALSE;
if(!single_value->field_prio.match(other_value.prio(), legacy))return FALSE;
if(!other_value.res().is_bound()) return FALSE;
if(!single_value->field_res.match(other_value.res(), legacy))return FALSE;
if(!other_value.dp().is_bound()) return FALSE;
if(!single_value->field_dp.match(other_value.dp(), legacy))return FALSE;
if(!other_value.pf().is_bound()) return FALSE;
if(!single_value->field_pf.match(other_value.pf(), legacy))return FALSE;
if(!other_value.ps().is_bound()) return FALSE;
if(!single_value->field_ps.match(other_value.ps(), legacy))return FALSE;
if(!other_value.sa().is_bound()) return FALSE;
if(!single_value->field_sa.match(other_value.sa(), legacy))return FALSE;
return TRUE;
case VALUE_LIST:
case COMPLEMENTED_LIST:
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
if (value_list.list_value[list_count].match(other_value, legacy)) return template_selection == VALUE_LIST;
return template_selection == COMPLEMENTED_LIST;
default:
TTCN_error("Matching an uninitialized/unsupported template of type @Isobus.J1939.");
}
return FALSE;
}
boolean J1939_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
if (template_selection != SPECIFIC_VALUE) return TRUE;
return single_value->field_prio.is_bound()
||single_value->field_res.is_bound()
||single_value->field_dp.is_bound()
||single_value->field_pf.is_bound()
||single_value->field_ps.is_bound()
||single_value->field_sa.is_bound()
;
}
boolean J1939_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value->field_prio.is_value()
&&single_value->field_res.is_value()
&&single_value->field_dp.is_value()
&&single_value->field_pf.is_value()
&&single_value->field_ps.is_value()
&&single_value->field_sa.is_value();
}
void J1939_template::clean_up()
{
switch (template_selection) {
case SPECIFIC_VALUE:
delete single_value;
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
delete [] value_list.list_value;
default:
break;
}
template_selection = UNINITIALIZED_TEMPLATE;
}
J1939 J1939_template::valueof() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent)
TTCN_error("Performing a valueof or send operation on a non-specific template of type @Isobus.J1939.");
J1939 ret_val;
if (single_value->field_prio.is_bound()) {
ret_val.prio() = single_value->field_prio.valueof();
}
if (single_value->field_res.is_bound()) {
ret_val.res() = single_value->field_res.valueof();
}
if (single_value->field_dp.is_bound()) {
ret_val.dp() = single_value->field_dp.valueof();
}
if (single_value->field_pf.is_bound()) {
ret_val.pf() = single_value->field_pf.valueof();
}
if (single_value->field_ps.is_bound()) {
ret_val.ps() = single_value->field_ps.valueof();
}
if (single_value->field_sa.is_bound()) {
ret_val.sa() = single_value->field_sa.valueof();
}
return ret_val;
}
void J1939_template::set_type(template_sel template_type, unsigned int list_length)
{
if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST)
TTCN_error("Setting an invalid list for a template of type @Isobus.J1939.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new J1939_template[list_length];
}
J1939_template& J1939_template::list_item(unsigned int list_index) const
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST)
TTCN_error("Accessing a list element of a non-list template of type @Isobus.J1939.");
if (list_index >= value_list.n_values)
TTCN_error("Index overflow in a value list template of type @Isobus.J1939.");
return value_list.list_value[list_index];
}
BITSTRING_template& J1939_template::prio()
{
set_specific();
return single_value->field_prio;
}
const BITSTRING_template& J1939_template::prio() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field prio of a non-specific template of type @Isobus.J1939.");
return single_value->field_prio;
}
BITSTRING_template& J1939_template::res()
{
set_specific();
return single_value->field_res;
}
const BITSTRING_template& J1939_template::res() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field res of a non-specific template of type @Isobus.J1939.");
return single_value->field_res;
}
BITSTRING_template& J1939_template::dp()
{
set_specific();
return single_value->field_dp;
}
const BITSTRING_template& J1939_template::dp() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field dp of a non-specific template of type @Isobus.J1939.");
return single_value->field_dp;
}
OCTETSTRING_template& J1939_template::pf()
{
set_specific();
return single_value->field_pf;
}
const OCTETSTRING_template& J1939_template::pf() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field pf of a non-specific template of type @Isobus.J1939.");
return single_value->field_pf;
}
OCTETSTRING_template& J1939_template::ps()
{
set_specific();
return single_value->field_ps;
}
const OCTETSTRING_template& J1939_template::ps() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field ps of a non-specific template of type @Isobus.J1939.");
return single_value->field_ps;
}
OCTETSTRING_template& J1939_template::sa()
{
set_specific();
return single_value->field_sa;
}
const OCTETSTRING_template& J1939_template::sa() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field sa of a non-specific template of type @Isobus.J1939.");
return single_value->field_sa;
}
int J1939_template::size_of() const
{
if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @Isobus.J1939 which has an ifpresent attribute.");
switch (template_selection)
{
case SPECIFIC_VALUE:
return 6;
case VALUE_LIST:
{
if (value_list.n_values<1)
TTCN_error("Internal error: Performing sizeof() operation on a template of type @Isobus.J1939 containing an empty list.");
int item_size = value_list.list_value[0].size_of();
for (unsigned int l_idx = 1; l_idx < value_list.n_values; l_idx++)
{
if (value_list.list_value[l_idx].size_of()!=item_size)
TTCN_error("Performing sizeof() operation on a template of type @Isobus.J1939 containing a value list with different sizes.");
}
return item_size;
}
case OMIT_VALUE:
TTCN_error("Performing sizeof() operation on a template of type @Isobus.J1939 containing omit value.");
case ANY_VALUE:
case ANY_OR_OMIT:
TTCN_error("Performing sizeof() operation on a template of type @Isobus.J1939 containing */? value.");
case COMPLEMENTED_LIST:
TTCN_error("Performing sizeof() operation on a template of type @Isobus.J1939 containing complemented list.");
default:
TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @Isobus.J1939.");
}
return 0;
}
void J1939_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_str("{ prio := ");
single_value->field_prio.log();
TTCN_Logger::log_event_str(", res := ");
single_value->field_res.log();
TTCN_Logger::log_event_str(", dp := ");
single_value->field_dp.log();
TTCN_Logger::log_event_str(", pf := ");
single_value->field_pf.log();
TTCN_Logger::log_event_str(", ps := ");
single_value->field_ps.log();
TTCN_Logger::log_event_str(", sa := ");
single_value->field_sa.log();
TTCN_Logger::log_event_str(" }");
break;
case COMPLEMENTED_LIST:
TTCN_Logger::log_event_str("complement");
case VALUE_LIST:
TTCN_Logger::log_char('(');
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) {
if (list_count > 0) TTCN_Logger::log_event_str(", ");
value_list.list_value[list_count].log();
}
TTCN_Logger::log_char(')');
break;
default:
log_generic();
}
log_ifpresent();
}
void J1939_template::log_match(const J1939& match_value, boolean legacy) const
{
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
if(match(match_value, legacy)){
TTCN_Logger::print_logmatch_buffer();
TTCN_Logger::log_event_str(" matched");
} else{
if (template_selection == SPECIFIC_VALUE) {
size_t previous_size = TTCN_Logger::get_logmatch_buffer_len();
if(!single_value->field_prio.match(match_value.prio(), legacy)){
TTCN_Logger::log_logmatch_info(".prio");
single_value->field_prio.log_match(match_value.prio(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_res.match(match_value.res(), legacy)){
TTCN_Logger::log_logmatch_info(".res");
single_value->field_res.log_match(match_value.res(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_dp.match(match_value.dp(), legacy)){
TTCN_Logger::log_logmatch_info(".dp");
single_value->field_dp.log_match(match_value.dp(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_pf.match(match_value.pf(), legacy)){
TTCN_Logger::log_logmatch_info(".pf");
single_value->field_pf.log_match(match_value.pf(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_ps.match(match_value.ps(), legacy)){
TTCN_Logger::log_logmatch_info(".ps");
single_value->field_ps.log_match(match_value.ps(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_sa.match(match_value.sa(), legacy)){
TTCN_Logger::log_logmatch_info(".sa");
single_value->field_sa.log_match(match_value.sa(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
}else {
TTCN_Logger::print_logmatch_buffer();
match_value.log();
TTCN_Logger::log_event_str(" with ");
log();
TTCN_Logger::log_event_str(" unmatched");
}
}
return;
}
if (template_selection == SPECIFIC_VALUE) {
TTCN_Logger::log_event_str("{ prio := ");
single_value->field_prio.log_match(match_value.prio(), legacy);
TTCN_Logger::log_event_str(", res := ");
single_value->field_res.log_match(match_value.res(), legacy);
TTCN_Logger::log_event_str(", dp := ");
single_value->field_dp.log_match(match_value.dp(), legacy);
TTCN_Logger::log_event_str(", pf := ");
single_value->field_pf.log_match(match_value.pf(), legacy);
TTCN_Logger::log_event_str(", ps := ");
single_value->field_ps.log_match(match_value.ps(), legacy);
TTCN_Logger::log_event_str(", sa := ");
single_value->field_sa.log_match(match_value.sa(), legacy);
TTCN_Logger::log_event_str(" }");
} else {
match_value.log();
TTCN_Logger::log_event_str(" with ");
log();
if (match(match_value, legacy)) TTCN_Logger::log_event_str(" matched");
else TTCN_Logger::log_event_str(" unmatched");
}
}
void J1939_template::encode_text(Text_Buf& text_buf) const
{
encode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value->field_prio.encode_text(text_buf);
single_value->field_res.encode_text(text_buf);
single_value->field_dp.encode_text(text_buf);
single_value->field_pf.encode_text(text_buf);
single_value->field_ps.encode_text(text_buf);
single_value->field_sa.encode_text(text_buf);
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
text_buf.push_int(value_list.n_values);
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
value_list.list_value[list_count].encode_text(text_buf);
break;
default:
TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type @Isobus.J1939.");
}
}
void J1939_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
single_value->field_prio.decode_text(text_buf);
single_value->field_res.decode_text(text_buf);
single_value->field_dp.decode_text(text_buf);
single_value->field_pf.decode_text(text_buf);
single_value->field_ps.decode_text(text_buf);
single_value->field_sa.decode_text(text_buf);
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
value_list.n_values = text_buf.pull_int().get_val();
value_list.list_value = new J1939_template[value_list.n_values];
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
value_list.list_value[list_count].decode_text(text_buf);
break;
default:
TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type @Isobus.J1939.");
}
}
void J1939_template::set_param(Module_Param& param)
{
param.basic_check(Module_Param::BC_TEMPLATE, "record template");
switch (param.get_type()) {
case Module_Param::MP_Omit:
*this = OMIT_VALUE;
break;
case Module_Param::MP_Any:
*this = ANY_VALUE;
break;
case Module_Param::MP_AnyOrNone:
*this = ANY_OR_OMIT;
break;
case Module_Param::MP_List_Template:
case Module_Param::MP_ComplementList_Template: {
J1939_template new_temp;
new_temp.set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : COMPLEMENTED_LIST, param.get_size());
for (size_t p_i=0; p_i<param.get_size(); p_i++) {
new_temp.list_item(p_i).set_param(*param.get_elem(p_i));
}
*this = new_temp;
break; }
case Module_Param::MP_Value_List:
if (6<param.get_size()) {
param.error("record template of type @Isobus.J1939 has 6 fields but list value has %d fields", (int)param.get_size());
}
if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) prio().set_param(*param.get_elem(0));
if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) res().set_param(*param.get_elem(1));
if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) dp().set_param(*param.get_elem(2));
if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) pf().set_param(*param.get_elem(3));
if (param.get_size()>4 && param.get_elem(4)->get_type()!=Module_Param::MP_NotUsed) ps().set_param(*param.get_elem(4));
if (param.get_size()>5 && param.get_elem(5)->get_type()!=Module_Param::MP_NotUsed) sa().set_param(*param.get_elem(5));
break;
case Module_Param::MP_Assignment_List: {
Vector<bool> value_used(param.get_size());
value_used.resize(param.get_size(), FALSE);
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "prio")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
prio().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "res")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
res().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "dp")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
dp().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "pf")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
pf().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "ps")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
ps().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "sa")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
sa().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
Module_Param* const curr_param = param.get_elem(val_idx);
curr_param->error("Non existent field name in type @Isobus.J1939: %s", curr_param->get_id()->get_name());
break;
}
} break;
default:
param.type_error("record template", "@Isobus.J1939");
}
is_ifpresent = param.get_ifpresent();
}
void J1939_template::check_restriction(template_res t_res, const char* t_name, boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return;
switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) {
case TR_OMIT:
if (template_selection==OMIT_VALUE) return;
case TR_VALUE:
if (template_selection!=SPECIFIC_VALUE || is_ifpresent) break;
single_value->field_prio.check_restriction(t_res, t_name ? t_name : "@Isobus.J1939");
single_value->field_res.check_restriction(t_res, t_name ? t_name : "@Isobus.J1939");
single_value->field_dp.check_restriction(t_res, t_name ? t_name : "@Isobus.J1939");
single_value->field_pf.check_restriction(t_res, t_name ? t_name : "@Isobus.J1939");
single_value->field_ps.check_restriction(t_res, t_name ? t_name : "@Isobus.J1939");
single_value->field_sa.check_restriction(t_res, t_name ? t_name : "@Isobus.J1939");
return;
case TR_PRESENT:
if (!match_omit(legacy)) return;
break;
default:
return;
}
TTCN_error("Restriction `%s' on template of type %s violated.", get_res_name(t_res), t_name ? t_name : "@Isobus.J1939");
}
boolean J1939_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}
boolean J1939_template::match_omit(boolean legacy) const
{
if (is_ifpresent) return TRUE;
switch (template_selection) {
case OMIT_VALUE:
case ANY_OR_OMIT:
return TRUE;
case VALUE_LIST:
case COMPLEMENTED_LIST:
if (legacy) {
for (unsigned int l_idx=0; l_idx<value_list.n_values; l_idx++)
if (value_list.list_value[l_idx].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}
J1939mod::J1939mod()
{
}
J1939mod::J1939mod(const BITSTRING& par_prio,
const BITSTRING& par_res,
const BITSTRING& par_dp,
const OCTETSTRING& par_pf,
const OCTETSTRING& par_ps,
const OCTETSTRING& par_sa,
const OCTETSTRING& par_comp)
: field_prio(par_prio),
field_res(par_res),
field_dp(par_dp),
field_pf(par_pf),
field_ps(par_ps),
field_sa(par_sa),
field_comp(par_comp)
{
}
J1939mod::J1939mod(const J1939mod& other_value)
{
if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @Isobus.J1939mod.");
if (other_value.prio().is_bound()) field_prio = other_value.prio();
else field_prio.clean_up();
if (other_value.res().is_bound()) field_res = other_value.res();
else field_res.clean_up();
if (other_value.dp().is_bound()) field_dp = other_value.dp();
else field_dp.clean_up();
if (other_value.pf().is_bound()) field_pf = other_value.pf();
else field_pf.clean_up();
if (other_value.ps().is_bound()) field_ps = other_value.ps();
else field_ps.clean_up();
if (other_value.sa().is_bound()) field_sa = other_value.sa();
else field_sa.clean_up();
if (other_value.comp().is_bound()) field_comp = other_value.comp();
else field_comp.clean_up();
}
void J1939mod::clean_up()
{
field_prio.clean_up();
field_res.clean_up();
field_dp.clean_up();
field_pf.clean_up();
field_ps.clean_up();
field_sa.clean_up();
field_comp.clean_up();
}
const TTCN_Typedescriptor_t* J1939mod::get_descriptor() const { return &J1939mod_descr_; }
J1939mod& J1939mod::operator=(const J1939mod& other_value)
{
if (this != &other_value) {
if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @Isobus.J1939mod.");
if (other_value.prio().is_bound()) field_prio = other_value.prio();
else field_prio.clean_up();
if (other_value.res().is_bound()) field_res = other_value.res();
else field_res.clean_up();
if (other_value.dp().is_bound()) field_dp = other_value.dp();
else field_dp.clean_up();
if (other_value.pf().is_bound()) field_pf = other_value.pf();
else field_pf.clean_up();
if (other_value.ps().is_bound()) field_ps = other_value.ps();
else field_ps.clean_up();
if (other_value.sa().is_bound()) field_sa = other_value.sa();
else field_sa.clean_up();
if (other_value.comp().is_bound()) field_comp = other_value.comp();
else field_comp.clean_up();
}
return *this;
}
boolean J1939mod::operator==(const J1939mod& other_value) const
{
return field_prio==other_value.field_prio
&& field_res==other_value.field_res
&& field_dp==other_value.field_dp
&& field_pf==other_value.field_pf
&& field_ps==other_value.field_ps
&& field_sa==other_value.field_sa
&& field_comp==other_value.field_comp;
}
boolean J1939mod::is_bound() const
{
return (field_prio.is_bound())
|| (field_res.is_bound())
|| (field_dp.is_bound())
|| (field_pf.is_bound())
|| (field_ps.is_bound())
|| (field_sa.is_bound())
|| (field_comp.is_bound());
}
boolean J1939mod::is_value() const
{
return field_prio.is_value()
&& field_res.is_value()
&& field_dp.is_value()
&& field_pf.is_value()
&& field_ps.is_value()
&& field_sa.is_value()
&& field_comp.is_value();
}
void J1939mod::log() const
{
if (!is_bound()) {
TTCN_Logger::log_event_unbound();
return;
}
TTCN_Logger::log_event_str("{ prio := ");
field_prio.log();
TTCN_Logger::log_event_str(", res := ");
field_res.log();
TTCN_Logger::log_event_str(", dp := ");
field_dp.log();
TTCN_Logger::log_event_str(", pf := ");
field_pf.log();
TTCN_Logger::log_event_str(", ps := ");
field_ps.log();
TTCN_Logger::log_event_str(", sa := ");
field_sa.log();
TTCN_Logger::log_event_str(", comp := ");
field_comp.log();
TTCN_Logger::log_event_str(" }");
}
void J1939mod::set_param(Module_Param& param)
{
param.basic_check(Module_Param::BC_VALUE, "record value");
switch (param.get_type()) {
case Module_Param::MP_Value_List:
if (7<param.get_size()) {
param.error("record value of type @Isobus.J1939mod has 7 fields but list value has %d fields", (int)param.get_size());
}
if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) prio().set_param(*param.get_elem(0));
if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) res().set_param(*param.get_elem(1));
if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) dp().set_param(*param.get_elem(2));
if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) pf().set_param(*param.get_elem(3));
if (param.get_size()>4 && param.get_elem(4)->get_type()!=Module_Param::MP_NotUsed) ps().set_param(*param.get_elem(4));
if (param.get_size()>5 && param.get_elem(5)->get_type()!=Module_Param::MP_NotUsed) sa().set_param(*param.get_elem(5));
if (param.get_size()>6 && param.get_elem(6)->get_type()!=Module_Param::MP_NotUsed) comp().set_param(*param.get_elem(6));
break;
case Module_Param::MP_Assignment_List: {
Vector<bool> value_used(param.get_size());
value_used.resize(param.get_size(), FALSE);
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "prio")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
prio().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "res")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
res().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "dp")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
dp().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "pf")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
pf().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "ps")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
ps().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "sa")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
sa().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
Module_Param* const curr_param = param.get_elem(val_idx);
if (!strcmp(curr_param->get_id()->get_name(), "comp")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
comp().set_param(*curr_param);
}
value_used[val_idx]=TRUE;
}
}
for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
Module_Param* const curr_param = param.get_elem(val_idx);
curr_param->error("Non existent field name in type @Isobus.J1939mod: %s", curr_param->get_id()->get_name());
break;
}
} break;
default:
param.type_error("record value", "@Isobus.J1939mod");
}
}
void J1939mod::set_implicit_omit()
{
if (prio().is_bound()) prio().set_implicit_omit();
if (res().is_bound()) res().set_implicit_omit();
if (dp().is_bound()) dp().set_implicit_omit();
if (pf().is_bound()) pf().set_implicit_omit();
if (ps().is_bound()) ps().set_implicit_omit();
if (sa().is_bound()) sa().set_implicit_omit();
if (comp().is_bound()) comp().set_implicit_omit();
}
void J1939mod::encode_text(Text_Buf& text_buf) const
{
field_prio.encode_text(text_buf);
field_res.encode_text(text_buf);
field_dp.encode_text(text_buf);
field_pf.encode_text(text_buf);
field_ps.encode_text(text_buf);
field_sa.encode_text(text_buf);
field_comp.encode_text(text_buf);
}
void J1939mod::decode_text(Text_Buf& text_buf)
{
field_prio.decode_text(text_buf);
field_res.decode_text(text_buf);
field_dp.decode_text(text_buf);
field_pf.decode_text(text_buf);
field_ps.decode_text(text_buf);
field_sa.decode_text(text_buf);
field_comp.decode_text(text_buf);
}
void J1939mod::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const
{
va_list pvar;
va_start(pvar, p_coding);
switch(p_coding) {
case TTCN_EncDec::CT_BER: {
TTCN_EncDec_ErrorContext ec("While BER-encoding type '%s': ", p_td.name);
unsigned BER_coding=va_arg(pvar, unsigned);
BER_encode_chk_coding(BER_coding);
ASN_BER_TLV_t *tlv=BER_encode_TLV(p_td, BER_coding);
tlv->put_in_buffer(p_buf);
ASN_BER_TLV_t::destruct(tlv);
break;}
case TTCN_EncDec::CT_RAW: {
TTCN_EncDec_ErrorContext ec("While RAW-encoding type '%s': ", p_td.name);
if(!p_td.raw)
TTCN_EncDec_ErrorContext::error_internal
("No RAW descriptor available for type '%s'.", p_td.name);
RAW_enc_tr_pos rp;
rp.level=0;
rp.pos=NULL;
RAW_enc_tree root(FALSE, NULL, &rp, 1, p_td.raw);
RAW_encode(p_td, root);
root.put_to_buf(p_buf);
break;}
case TTCN_EncDec::CT_TEXT: {
TTCN_EncDec_ErrorContext ec("While TEXT-encoding type '%s': ", p_td.name);
if(!p_td.text)
TTCN_EncDec_ErrorContext::error_internal
("No TEXT descriptor available for type '%s'.", p_td.name);
TEXT_encode(p_td,p_buf);
break;}
case TTCN_EncDec::CT_XER: {
TTCN_EncDec_ErrorContext ec("While XER-encoding type '%s': ", p_td.name);
unsigned XER_coding=va_arg(pvar, unsigned);
XER_encode_chk_coding(XER_coding, p_td);
XER_encode(*(p_td.xer),p_buf, XER_coding, 0, 0, 0);
p_buf.put_c('\n');
break;}
case TTCN_EncDec::CT_JSON: {
TTCN_EncDec_ErrorContext ec("While JSON-encoding type '%s': ", p_td.name);
if(!p_td.json)
TTCN_EncDec_ErrorContext::error_internal
("No JSON descriptor available for type '%s'.", p_td.name);
JSON_Tokenizer tok(va_arg(pvar, int) != 0);
JSON_encode(p_td, tok);
p_buf.put_s(tok.get_buffer_length(), (const unsigned char*)tok.get_buffer());
break;}
case TTCN_EncDec::CT_OER: {
TTCN_EncDec_ErrorContext ec("While OER-encoding type '%s': ", p_td.name);
if(!p_td.oer)
TTCN_EncDec_ErrorContext::error_internal
("No OER descriptor available for type '%s'.", p_td.name);
OER_encode(p_td, p_buf);
break;}
default:
TTCN_error("Unknown coding method requested to encode type '%s'", p_td.name);
}
va_end(pvar);
}
void J1939mod::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...)
{
va_list pvar;
va_start(pvar, p_coding);
switch(p_coding) {
case TTCN_EncDec::CT_BER: {
TTCN_EncDec_ErrorContext ec("While BER-decoding type '%s': ", p_td.name);
unsigned L_form=va_arg(pvar, unsigned);
ASN_BER_TLV_t tlv;
BER_decode_str2TLV(p_buf, tlv, L_form);
BER_decode_TLV(p_td, tlv, L_form);
if(tlv.isComplete) p_buf.increase_pos(tlv.get_len());
break;}
case TTCN_EncDec::CT_RAW: {
TTCN_EncDec_ErrorContext ec("While RAW-decoding type '%s': ", p_td.name);
if(!p_td.raw)
TTCN_EncDec_ErrorContext::error_internal
("No RAW descriptor available for type '%s'.", p_td.name);
raw_order_t r_order;
switch(p_td.raw->top_bit_order) {
case TOP_BIT_LEFT:
r_order=ORDER_LSB;
break;
case TOP_BIT_RIGHT:
default:
r_order=ORDER_MSB;
}
int rawr = RAW_decode(p_td, p_buf, p_buf.get_len()*8, r_order);
if(rawr<0) switch (-rawr) {
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
ec.error((TTCN_EncDec::error_type_t)-rawr, "Can not decode type '%s', because incomplete message was received", p_td.name);
break;
case 1:
default:
ec.error(TTCN_EncDec::ET_INVAL_MSG, "Can not decode type '%s', because invalid message was received", p_td.name);
break;
}
break;}
case TTCN_EncDec::CT_TEXT: {
Limit_Token_List limit;
TTCN_EncDec_ErrorContext ec("While TEXT-decoding type '%s': ", p_td.name);
if(!p_td.text)
TTCN_EncDec_ErrorContext::error_internal
("No TEXT descriptor available for type '%s'.", p_td.name);
const unsigned char *b_data=p_buf.get_data();
if(b_data[p_buf.get_len()-1]!='\0'){
p_buf.set_pos(p_buf.get_len());
p_buf.put_zero(8,ORDER_LSB);
p_buf.rewind();
}
if(TEXT_decode(p_td,p_buf,limit)<0)
ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
break;}
case TTCN_EncDec::CT_XER: {
TTCN_EncDec_ErrorContext ec("While XER-decoding type '%s': ", p_td.name);
unsigned XER_coding=va_arg(pvar, unsigned);
XER_encode_chk_coding(XER_coding, p_td);
XmlReaderWrap reader(p_buf);
for (int rd_ok=reader.Read(); rd_ok==1; rd_ok=reader.Read()) {
if (reader.NodeType() == XML_READER_TYPE_ELEMENT) break;
}
XER_decode(*(p_td.xer), reader, XER_coding | XER_TOPLEVEL, XER_NONE, 0);
size_t bytes = reader.ByteConsumed();
p_buf.set_pos(bytes);
break;}
case TTCN_EncDec::CT_JSON: {
TTCN_EncDec_ErrorContext ec("While JSON-decoding type '%s': ", p_td.name);
if(!p_td.json)
TTCN_EncDec_ErrorContext::error_internal
("No JSON descriptor available for type '%s'.", p_td.name);
JSON_Tokenizer tok((const char*)p_buf.get_data(), p_buf.get_len());
if(JSON_decode(p_td, tok, FALSE)<0)
ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
p_buf.set_pos(tok.get_buf_pos());
break;}
case TTCN_EncDec::CT_OER: {
TTCN_EncDec_ErrorContext ec("While OER-decoding type '%s': ", p_td.name);
if(!p_td.oer)
TTCN_EncDec_ErrorContext::error_internal
("No OER descriptor available for type '%s'.", p_td.name);
OER_struct p_oer;
OER_decode(p_td, p_buf, p_oer);
break;}
default:
TTCN_error("Unknown coding method requested to decode type '%s'", p_td.name);
}
va_end(pvar);
}
int J1939mod::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int limit, raw_order_t top_bit_ord, boolean no_err, int, boolean, const RAW_Force_Omit* force_omit)
{ (void)no_err;
int prepaddlength=p_buf.increase_pos_padd(p_td.raw->prepadding);
limit-=prepaddlength;
size_t last_decoded_pos = p_buf.get_pos_bit();
int decoded_length = 0;
int decoded_field_length = 0;
raw_order_t local_top_order;
if(p_td.raw->top_bit_order==TOP_BIT_INHERITED)local_top_order=top_bit_ord;
else if(p_td.raw->top_bit_order==TOP_BIT_RIGHT)local_top_order=ORDER_MSB;
else local_top_order=ORDER_LSB;
RAW_Force_Omit field_0_force_omit(0, force_omit, J1939mod_prio_descr_.raw->forceomit);
decoded_field_length = field_prio.RAW_decode(J1939mod_prio_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_0_force_omit);
if (decoded_field_length < 0) return decoded_field_length;
decoded_length+=decoded_field_length;
limit-=decoded_field_length;
last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
RAW_Force_Omit field_1_force_omit(1, force_omit, J1939mod_res_descr_.raw->forceomit);
decoded_field_length = field_res.RAW_decode(J1939mod_res_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_1_force_omit);
if (decoded_field_length < 0) return decoded_field_length;
decoded_length+=decoded_field_length;
limit-=decoded_field_length;
last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
RAW_Force_Omit field_2_force_omit(2, force_omit, J1939mod_dp_descr_.raw->forceomit);
decoded_field_length = field_dp.RAW_decode(J1939mod_dp_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_2_force_omit);
if (decoded_field_length < 0) return decoded_field_length;
decoded_length+=decoded_field_length;
limit-=decoded_field_length;
last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
RAW_Force_Omit field_3_force_omit(3, force_omit, J1939mod_pf_descr_.raw->forceomit);
decoded_field_length = field_pf.RAW_decode(J1939mod_pf_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_3_force_omit);
if (decoded_field_length < 0) return decoded_field_length;
decoded_length+=decoded_field_length;
limit-=decoded_field_length;
last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
RAW_Force_Omit field_4_force_omit(4, force_omit, J1939mod_ps_descr_.raw->forceomit);
decoded_field_length = field_ps.RAW_decode(J1939mod_ps_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_4_force_omit);
if (decoded_field_length < 0) return decoded_field_length;
decoded_length+=decoded_field_length;
limit-=decoded_field_length;
last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
RAW_Force_Omit field_5_force_omit(5, force_omit, J1939mod_sa_descr_.raw->forceomit);
decoded_field_length = field_sa.RAW_decode(J1939mod_sa_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_5_force_omit);
if (decoded_field_length < 0) return decoded_field_length;
decoded_length+=decoded_field_length;
limit-=decoded_field_length;
last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
RAW_Force_Omit field_6_force_omit(6, force_omit, J1939mod_comp_descr_.raw->forceomit);
decoded_field_length = field_comp.RAW_decode(J1939mod_comp_descr_, p_buf, limit, local_top_order, no_err, -1, TRUE, &field_6_force_omit);
if (decoded_field_length < 0) return decoded_field_length;
decoded_length+=decoded_field_length;
limit-=decoded_field_length;
last_decoded_pos=bigger(last_decoded_pos, p_buf.get_pos_bit());
p_buf.set_pos_bit(last_decoded_pos);
return decoded_length+prepaddlength+p_buf.increase_pos_padd(p_td.raw->padding);
}
int J1939mod::RAW_encode(const TTCN_Typedescriptor_t&, RAW_enc_tree& myleaf) const {
if (!is_bound()) TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value.");
int encoded_length = 0;
myleaf.isleaf = FALSE;
myleaf.body.node.num_of_nodes = 7;
myleaf.body.node.nodes = init_nodes_of_enc_tree(7);
myleaf.body.node.nodes[0] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 0, J1939mod_prio_descr_.raw);
myleaf.body.node.nodes[1] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 1, J1939mod_res_descr_.raw);
myleaf.body.node.nodes[2] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 2, J1939mod_dp_descr_.raw);
myleaf.body.node.nodes[3] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 3, J1939mod_pf_descr_.raw);
myleaf.body.node.nodes[4] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 4, J1939mod_ps_descr_.raw);
myleaf.body.node.nodes[5] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 5, J1939mod_sa_descr_.raw);
myleaf.body.node.nodes[6] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 6, J1939mod_comp_descr_.raw);
encoded_length += field_prio.RAW_encode(J1939mod_prio_descr_, *myleaf.body.node.nodes[0]);
encoded_length += field_res.RAW_encode(J1939mod_res_descr_, *myleaf.body.node.nodes[1]);
encoded_length += field_dp.RAW_encode(J1939mod_dp_descr_, *myleaf.body.node.nodes[2]);
encoded_length += field_pf.RAW_encode(J1939mod_pf_descr_, *myleaf.body.node.nodes[3]);
encoded_length += field_ps.RAW_encode(J1939mod_ps_descr_, *myleaf.body.node.nodes[4]);
encoded_length += field_sa.RAW_encode(J1939mod_sa_descr_, *myleaf.body.node.nodes[5]);
encoded_length += field_comp.RAW_encode(J1939mod_comp_descr_, *myleaf.body.node.nodes[6]);
return myleaf.length = encoded_length;
}
struct J1939mod_template::single_value_struct {
BITSTRING_template field_prio;
BITSTRING_template field_res;
BITSTRING_template field_dp;
OCTETSTRING_template field_pf;
OCTETSTRING_template field_ps;
OCTETSTRING_template field_sa;
OCTETSTRING_template field_comp;
};
void J1939mod_template::set_specific()
{
if (template_selection != SPECIFIC_VALUE) {
template_sel old_selection = template_selection;
clean_up();
single_value = new single_value_struct;
set_selection(SPECIFIC_VALUE);
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) {
single_value->field_prio = ANY_VALUE;
single_value->field_res = ANY_VALUE;
single_value->field_dp = ANY_VALUE;
single_value->field_pf = ANY_VALUE;
single_value->field_ps = ANY_VALUE;
single_value->field_sa = ANY_VALUE;
single_value->field_comp = ANY_VALUE;
}
}
}
void J1939mod_template::copy_value(const J1939mod& other_value)
{
single_value = new single_value_struct;
if (other_value.prio().is_bound()) {
single_value->field_prio = other_value.prio();
} else {
single_value->field_prio.clean_up();
}
if (other_value.res().is_bound()) {
single_value->field_res = other_value.res();
} else {
single_value->field_res.clean_up();
}
if (other_value.dp().is_bound()) {
single_value->field_dp = other_value.dp();
} else {
single_value->field_dp.clean_up();
}
if (other_value.pf().is_bound()) {
single_value->field_pf = other_value.pf();
} else {
single_value->field_pf.clean_up();
}
if (other_value.ps().is_bound()) {
single_value->field_ps = other_value.ps();
} else {
single_value->field_ps.clean_up();
}
if (other_value.sa().is_bound()) {
single_value->field_sa = other_value.sa();
} else {
single_value->field_sa.clean_up();
}
if (other_value.comp().is_bound()) {
single_value->field_comp = other_value.comp();
} else {
single_value->field_comp.clean_up();
}
set_selection(SPECIFIC_VALUE);
}
void J1939mod_template::copy_template(const J1939mod_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
if (UNINITIALIZED_TEMPLATE != other_value.prio().get_selection()) {
single_value->field_prio = other_value.prio();
} else {
single_value->field_prio.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.res().get_selection()) {
single_value->field_res = other_value.res();
} else {
single_value->field_res.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.dp().get_selection()) {
single_value->field_dp = other_value.dp();
} else {
single_value->field_dp.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.pf().get_selection()) {
single_value->field_pf = other_value.pf();
} else {
single_value->field_pf.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.ps().get_selection()) {
single_value->field_ps = other_value.ps();
} else {
single_value->field_ps.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.sa().get_selection()) {
single_value->field_sa = other_value.sa();
} else {
single_value->field_sa.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.comp().get_selection()) {
single_value->field_comp = other_value.comp();
} else {
single_value->field_comp.clean_up();
}
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
value_list.n_values = other_value.value_list.n_values;
value_list.list_value = new J1939mod_template[value_list.n_values];
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]);
break;
default:
TTCN_error("Copying an uninitialized/unsupported template of type @Isobus.J1939mod.");
break;
}
set_selection(other_value);
}
J1939mod_template::J1939mod_template()
{
}
J1939mod_template::J1939mod_template(template_sel other_value)
: Base_Template(other_value)
{
check_single_selection(other_value);
}
J1939mod_template::J1939mod_template(const J1939mod& other_value)
{
copy_value(other_value);
}
J1939mod_template::J1939mod_template(const OPTIONAL<J1939mod>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const J1939mod&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @Isobus.J1939mod from an unbound optional field.");
}
}
J1939mod_template::J1939mod_template(const J1939mod_template& other_value)
: Base_Template()
{
copy_template(other_value);
}
J1939mod_template::~J1939mod_template()
{
clean_up();
}
J1939mod_template& J1939mod_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}
J1939mod_template& J1939mod_template::operator=(const J1939mod& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}
J1939mod_template& J1939mod_template::operator=(const OPTIONAL<J1939mod>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const J1939mod&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Assignment of an unbound optional field to a template of type @Isobus.J1939mod.");
}
return *this;
}
J1939mod_template& J1939mod_template::operator=(const J1939mod_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}
boolean J1939mod_template::match(const J1939mod& other_value, boolean legacy) const
{
if (!other_value.is_bound()) return FALSE;
switch (template_selection) {
case ANY_VALUE:
case ANY_OR_OMIT:
return TRUE;
case OMIT_VALUE:
return FALSE;
case SPECIFIC_VALUE:
if(!other_value.prio().is_bound()) return FALSE;
if(!single_value->field_prio.match(other_value.prio(), legacy))return FALSE;
if(!other_value.res().is_bound()) return FALSE;
if(!single_value->field_res.match(other_value.res(), legacy))return FALSE;
if(!other_value.dp().is_bound()) return FALSE;
if(!single_value->field_dp.match(other_value.dp(), legacy))return FALSE;
if(!other_value.pf().is_bound()) return FALSE;
if(!single_value->field_pf.match(other_value.pf(), legacy))return FALSE;
if(!other_value.ps().is_bound()) return FALSE;
if(!single_value->field_ps.match(other_value.ps(), legacy))return FALSE;
if(!other_value.sa().is_bound()) return FALSE;
if(!single_value->field_sa.match(other_value.sa(), legacy))return FALSE;
if(!other_value.comp().is_bound()) return FALSE;
if(!single_value->field_comp.match(other_value.comp(), legacy))return FALSE;
return TRUE;
case VALUE_LIST:
case COMPLEMENTED_LIST:
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
if (value_list.list_value[list_count].match(other_value, legacy)) return template_selection == VALUE_LIST;
return template_selection == COMPLEMENTED_LIST;
default:
TTCN_error("Matching an uninitialized/unsupported template of type @Isobus.J1939mod.");
}
return FALSE;
}
boolean J1939mod_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
if (template_selection != SPECIFIC_VALUE) return TRUE;
return single_value->field_prio.is_bound()
||single_value->field_res.is_bound()
||single_value->field_dp.is_bound()
||single_value->field_pf.is_bound()
||single_value->field_ps.is_bound()
||single_value->field_sa.is_bound()
||single_value->field_comp.is_bound()
;
}
boolean J1939mod_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value->field_prio.is_value()
&&single_value->field_res.is_value()
&&single_value->field_dp.is_value()
&&single_value->field_pf.is_value()
&&single_value->field_ps.is_value()
&&single_value->field_sa.is_value()
&&single_value->field_comp.is_value();
}
void J1939mod_template::clean_up()
{
switch (template_selection) {
case SPECIFIC_VALUE:
delete single_value;
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
delete [] value_list.list_value;
default:
break;
}
template_selection = UNINITIALIZED_TEMPLATE;
}
J1939mod J1939mod_template::valueof() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent)
TTCN_error("Performing a valueof or send operation on a non-specific template of type @Isobus.J1939mod.");
J1939mod ret_val;
if (single_value->field_prio.is_bound()) {
ret_val.prio() = single_value->field_prio.valueof();
}
if (single_value->field_res.is_bound()) {
ret_val.res() = single_value->field_res.valueof();
}
if (single_value->field_dp.is_bound()) {
ret_val.dp() = single_value->field_dp.valueof();
}
if (single_value->field_pf.is_bound()) {
ret_val.pf() = single_value->field_pf.valueof();
}
if (single_value->field_ps.is_bound()) {
ret_val.ps() = single_value->field_ps.valueof();
}
if (single_value->field_sa.is_bound()) {
ret_val.sa() = single_value->field_sa.valueof();
}
if (single_value->field_comp.is_bound()) {
ret_val.comp() = single_value->field_comp.valueof();
}
return ret_val;
}
void J1939mod_template::set_type(template_sel template_type, unsigned int list_length)
{
if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST)
TTCN_error("Setting an invalid list for a template of type @Isobus.J1939mod.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new J1939mod_template[list_length];
}
J1939mod_template& J1939mod_template::list_item(unsigned int list_index) const
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST)
TTCN_error("Accessing a list element of a non-list template of type @Isobus.J1939mod.");
if (list_index >= value_list.n_values)
TTCN_error("Index overflow in a value list template of type @Isobus.J1939mod.");
return value_list.list_value[list_index];
}
BITSTRING_template& J1939mod_template::prio()
{
set_specific();
return single_value->field_prio;
}
const BITSTRING_template& J1939mod_template::prio() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field prio of a non-specific template of type @Isobus.J1939mod.");
return single_value->field_prio;
}
BITSTRING_template& J1939mod_template::res()
{
set_specific();
return single_value->field_res;
}
const BITSTRING_template& J1939mod_template::res() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field res of a non-specific template of type @Isobus.J1939mod.");
return single_value->field_res;
}
BITSTRING_template& J1939mod_template::dp()
{
set_specific();
return single_value->field_dp;
}
const BITSTRING_template& J1939mod_template::dp() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field dp of a non-specific template of type @Isobus.J1939mod.");
return single_value->field_dp;
}