blob: f5f04d4771d0c0b07fefd760f05b399d6a2d8d9e [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 "Isobustest.hh"
namespace Isobustest {
/* Prototypes of static functions */
static void pre_init_module();
static void post_init_module();
static boolean init_comp_type(const char *component_type, boolean init_base_comps);
static boolean init_system_port(const char* component_type, const char* port_name);
static boolean start_ptc_function(const char *function_name, Text_Buf& function_arguments);
static void module_control_part();
/* Literal string constants */
static const unsigned char bs_1_bits[] = { 0 },
bs_11_bits[] = { 0 },
bs_5_bits[] = { 64 },
bs_6_bits[] = { 192 },
bs_12_bits[] = { 32 },
bs_4_bits[] = { 8 },
bs_0_bits[] = { 24 },
bs_7_bits[] = { 20 },
bs_3_bits[] = { 6 },
bs_2_bits[] = { 1 },
bs_9_bits[] = { 1, 0 },
bs_10_bits[] = { 133, 80, 0 },
bs_8_bits[] = { 3 };
static const BITSTRING bs_1(1, bs_1_bits),
bs_11(6, bs_11_bits),
bs_5(7, bs_5_bits),
bs_6(8, bs_6_bits),
bs_12(6, bs_12_bits),
bs_4(4, bs_4_bits),
bs_0(6, bs_0_bits),
bs_7(5, bs_7_bits),
bs_3(3, bs_3_bits),
bs_2(1, bs_2_bits),
bs_9(11, bs_9_bits),
bs_10(21, bs_10_bits),
bs_8(3, bs_8_bits);
static const unsigned char os_7_octets[] = { 0 },
os_2_octets[] = { 0, 255, 0 },
os_17_octets[] = { 1 },
os_18_octets[] = { 2 },
os_19_octets[] = { 3 },
os_3_octets[] = { 3, 255, 255 },
os_20_octets[] = { 4 },
os_21_octets[] = { 5 },
os_22_octets[] = { 6 },
os_23_octets[] = { 7 },
os_14_octets[] = { 10 },
os_15_octets[] = { 11 },
os_16_octets[] = { 12 },
os_1_octets[] = { 17 },
os_28_octets[] = { 24, 236, 248, 248, 16, 22, 0, 4, 255, 235, 254, 0 },
os_10_octets[] = { 34, 51 },
os_11_octets[] = { 68, 85 },
os_12_octets[] = { 102 },
os_26_octets[] = { 108, 101, 32, 115, 101, 114, 118 },
os_27_octets[] = { 152, 234, 255, 254, 0, 238, 0 },
os_9_octets[] = { 170 },
os_8_octets[] = { 192 },
os_6_octets[] = { 230 },
os_4_octets[] = { 233 },
os_25_octets[] = { 248 },
os_5_octets[] = { 253 },
os_24_octets[] = { 254 },
os_13_octets[] = { 255 };
static const OCTETSTRING os_0(0, NULL),
os_7(1, os_7_octets),
os_2(3, os_2_octets),
os_17(1, os_17_octets),
os_18(1, os_18_octets),
os_19(1, os_19_octets),
os_3(3, os_3_octets),
os_20(1, os_20_octets),
os_21(1, os_21_octets),
os_22(1, os_22_octets),
os_23(1, os_23_octets),
os_14(1, os_14_octets),
os_15(1, os_15_octets),
os_16(1, os_16_octets),
os_1(1, os_1_octets),
os_28(12, os_28_octets),
os_10(2, os_10_octets),
os_11(2, os_11_octets),
os_12(1, os_12_octets),
os_26(7, os_26_octets),
os_27(7, os_27_octets),
os_9(1, os_9_octets),
os_8(1, os_8_octets),
os_6(1, os_6_octets),
os_4(1, os_4_octets),
os_25(1, os_25_octets),
os_5(1, os_5_octets),
os_24(1, os_24_octets),
os_13(1, os_13_octets);
static const unsigned char module_checksum[] = { 0x05, 0x4a, 0xb3, 0x61, 0xd4, 0x66, 0xd1, 0x06, 0xe1, 0x15, 0x44, 0x5f, 0x26, 0xc8, 0x14, 0x9d };
/* Global variable definitions */
// No XER for CAN__ID
const TTCN_Typedescriptor_t CAN__ID_descr_ = { "@Isobustest.CAN_ID", NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t CAN__ID_can__eff_xer_ = { {"can_eff>\n", "can_eff>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const int CAN__ID_can__eff_oer_ext_arr_[0] = {};
const int CAN__ID_can__eff_oer_p_[0] = {};
const TTCN_OERdescriptor_t CAN__ID_can__eff_oer_ = { -1, TRUE, 4, FALSE, 0, 0, CAN__ID_can__eff_oer_ext_arr_, 0, CAN__ID_can__eff_oer_p_};
const TTCN_Typedescriptor_t CAN__ID_can__eff_descr_ = { "@Isobustest.CAN_ID.can_eff", &OCTETSTRING_ber_, &General__Types::OCT4_raw_, &OCTETSTRING_text_, &CAN__ID_can__eff_xer_, &OCTETSTRING_json_, &CAN__ID_can__eff_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t CAN__ID_can__sff_xer_ = { {"can_sff>\n", "can_sff>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const int CAN__ID_can__sff_oer_ext_arr_[0] = {};
const int CAN__ID_can__sff_oer_p_[0] = {};
const TTCN_OERdescriptor_t CAN__ID_can__sff_oer_ = { -1, TRUE, 2, FALSE, 0, 0, CAN__ID_can__sff_oer_ext_arr_, 0, CAN__ID_can__sff_oer_p_};
const TTCN_Typedescriptor_t CAN__ID_can__sff_descr_ = { "@Isobustest.CAN_ID.can_sff", &OCTETSTRING_ber_, &General__Types::OCT2_raw_, &OCTETSTRING_text_, &CAN__ID_can__sff_xer_, &OCTETSTRING_json_, &CAN__ID_can__sff_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t RTR_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 RTR
const TTCN_Typedescriptor_t RTR_descr_ = { "@Isobustest.RTR", NULL, &RTR_raw_, NULL, NULL, &ENUMERATED_json_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t BIT29_raw_ = {29,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};
const XERdescriptor_t BIT29_xer_ = { {"BIT29>\n", "BIT29>\n"}, {7, 7}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t BIT29_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t BIT29_descr_ = { "@Isobustest.BIT29", &BITSTRING_ber_, &BIT29_raw_, NULL, &BIT29_xer_, &BITSTRING_json_, &BIT29_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t CAN__ID_can__err_xer_ = { {"can_err>\n", "can_err>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t CAN__ID_can__err_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t CAN__ID_can__err_descr_ = { "@Isobustest.CAN_ID.can_err", &BITSTRING_ber_, &BIT29_raw_, NULL, &CAN__ID_can__err_xer_, &BITSTRING_json_, &CAN__ID_can__err_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t Can__IDs_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__IDs
const TTCN_Typedescriptor_t Can__IDs_descr_ = { "@Isobustest.Can_IDs", NULL, &Can__IDs_raw_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t Can__IDs_can__eff_xer_ = { {"can_eff>\n", "can_eff>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t Can__IDs_can__eff_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t Can__IDs_can__eff_descr_ = { "@Isobustest.Can_IDs.can_eff", &BITSTRING_ber_, &BIT29_raw_, NULL, &Can__IDs_can__eff_xer_, &BITSTRING_json_, &Can__IDs_can__eff_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t Can__IDs_can__sff_xer_ = { {"can_sff>\n", "can_sff>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t Can__IDs_can__sff_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t Can__IDs_can__sff_descr_ = { "@Isobustest.Can_IDs.can_sff", &BITSTRING_ber_, &General__Types::BIT11_raw_, NULL, &Can__IDs_can__sff_xer_, &BITSTRING_json_, &Can__IDs_can__sff_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t Can__IDs_can__err_xer_ = { {"can_err>\n", "can_err>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t Can__IDs_can__err_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t Can__IDs_can__err_descr_ = { "@Isobustest.Can_IDs.can_err", &BITSTRING_ber_, &BIT29_raw_, NULL, &Can__IDs_can__err_xer_, &BITSTRING_json_, &Can__IDs_can__err_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t Can__IDwithType_cantype_xer_ = { {"cantype>\n", "cantype>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t Can__IDwithType_cantype_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t Can__IDwithType_cantype_descr_ = { "@Isobustest.Can_IDwithType.cantype", &INTEGER_ber_, &General__Types::INT1_raw_, &INTEGER_text_, &Can__IDwithType_cantype_xer_, &INTEGER_json_, &Can__IDwithType_cantype_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t Can__IDwithType_can__ids_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__IDwithType_can__ids
const TTCN_Typedescriptor_t Can__IDwithType_can__ids_descr_ = { "@Isobustest.Can_IDwithType.can_ids", NULL, &Can__IDwithType_can__ids_raw_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t Can__IDwithType_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__IDwithType
const TTCN_Typedescriptor_t Can__IDwithType_descr_ = { "@Isobustest.Can_IDwithType", NULL, &Can__IDwithType_raw_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_Typedescriptor_t& MTC__CT_descr_ = COMPONENT_descr_;
const TTCN_Typedescriptor_t& PTC__isobus__CT_descr_ = COMPONENT_descr_;
SocketCAN__PortType::SocketCAN__PT PTC__isobus__CT_component_pt__socketCAN("pt_socketCAN");
Isobus__PT PTC__isobus__CT_component_pt__isobus("pt_isobus");
TIMER PTC__isobus__CT_component_T0("T0", 2.0e-1);
static INTEGER const_MAX__CONNECTIONS;
const INTEGER& MAX__CONNECTIONS = const_MAX__CONNECTIONS;
// No XER for OpenConnections
const TTCN_Typedescriptor_t OpenConnections_descr_ = { "@Isobustest.OpenConnections", NULL, NULL, NULL, NULL, NULL, NULL, &COMPONENT_descr_, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_Typedescriptor_t& PTC2__CT_descr_ = COMPONENT_descr_;
// No XER for OpenConnectionsFlags
const TTCN_Typedescriptor_t OpenConnectionsFlags_descr_ = { "@Isobustest.OpenConnectionsFlags", NULL, NULL, NULL, NULL, NULL, NULL, &BOOLEAN_descr_, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t OpenConnectionsFlags_0_xer_ = { {"BOOLEAN>\n", "BOOLEAN>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const int OpenConnectionsFlags_0_oer_ext_arr_[0] = {};
const int OpenConnectionsFlags_0_oer_p_[0] = {};
const TTCN_OERdescriptor_t OpenConnectionsFlags_0_oer_ = { -1, TRUE, -1, FALSE, 0, 0, OpenConnectionsFlags_0_oer_ext_arr_, 0, OpenConnectionsFlags_0_oer_p_};
const TTCN_Typedescriptor_t OpenConnectionsFlags_0_descr_ = { "@Isobustest.OpenConnectionsFlags.BOOLEAN", &BOOLEAN_ber_, &BOOLEAN_raw_, &BOOLEAN_text_, &OpenConnectionsFlags_0_xer_, &BOOLEAN_json_, &OpenConnectionsFlags_0_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_Typedescriptor_t& PTC1__CT_descr_ = COMPONENT_descr_;
Isobus__PT PTC1__CT_component_pt__isobus("pt_isobus");
OpenConnections PTC1__CT_component_openConnections;
OpenConnectionsFlags PTC1__CT_component_openConnectionsFlags;
TIMER PTC1__CT_component_T1("T1", 2.0e-1);
Isobus__PT PTC2__CT_component_pt__isobus("pt_isobus");
OCTETSTRING PTC2__CT_component_receivedUnacknowledgedData;
INTEGER PTC2__CT_component_msgSizeInBytes;
INTEGER PTC2__CT_component_receivedUnacknowledgedMsgSizeInBytes;
INTEGER PTC2__CT_component_nextExpectedPacketNumber;
INTEGER PTC2__CT_component_pgnOfMultiPacketMessage;
const XERdescriptor_t _T_PTC2__CT_component_ps_xer_ = { {"OCT1>\n", "OCT1>\n"}, {6, 6}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const int _T_PTC2__CT_component_ps_oer_ext_arr_[0] = {};
const int _T_PTC2__CT_component_ps_oer_p_[0] = {};
const TTCN_OERdescriptor_t _T_PTC2__CT_component_ps_oer_ = { -1, TRUE, 1, FALSE, 0, 0, _T_PTC2__CT_component_ps_oer_ext_arr_, 0, _T_PTC2__CT_component_ps_oer_p_};
const TTCN_Typedescriptor_t _T_PTC2__CT_component_ps_descr_ = { "@Isobustest.PTC2_CT.ps.<type>", &OCTETSTRING_ber_, &General__Types::OCT1_raw_, &OCTETSTRING_text_, &_T_PTC2__CT_component_ps_xer_, &OCTETSTRING_json_, &_T_PTC2__CT_component_ps_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
OCTETSTRING PTC2__CT_component_ps;
OCTETSTRING PTC2__CT_component_sa;
OCTETSTRING PTC2__CT_component_tp__dt__can__id;
TIMER PTC2__CT_component_T2("T2", 2.0e-1);
// No XER for PTCSet
const TTCN_Typedescriptor_t PTCSet_descr_ = { "@Isobustest.PTCSet", NULL, NULL, NULL, NULL, NULL, NULL, &COMPONENT_descr_, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_Typedescriptor_t& PTC_descr_ = COMPONENT_descr_;
SyncSlavePort PTC_component_pt__sync("pt_sync");
SocketCAN__PortType::SocketCAN__PT PTC_component_pt__socketCAN("pt_socketCAN");
SocketCANtest::e__Phase PTC_component_v__phase;
TTCN_Module module_object("Isobustest", __DATE__, __TIME__, module_checksum, pre_init_module, NULL, 0U, 4294967295U, 4294967295U, 4294967295U, NULL, 0LU, 0, post_init_module, NULL, NULL, NULL, init_comp_type, init_system_port, start_ptc_function, module_control_part);
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 */
void CAN__ID::copy_value(const CAN__ID& other_value)
{
switch (other_value.union_selection) {
case ALT_can__eff:
field_can__eff = new OCTETSTRING(*other_value.field_can__eff);
break;
case ALT_can__sff:
field_can__sff = new OCTETSTRING(*other_value.field_can__sff);
break;
case ALT_can__rtr:
field_can__rtr = new RTR(*other_value.field_can__rtr);
break;
case ALT_can__err:
field_can__err = new BITSTRING(*other_value.field_can__err);
break;
default:
TTCN_error("Assignment of an unbound union value of type @Isobustest.CAN_ID.");
}
union_selection = other_value.union_selection;
}
CAN__ID::CAN__ID()
{
union_selection = UNBOUND_VALUE;
}
CAN__ID::CAN__ID(const CAN__ID& other_value)
: Base_Type(){
copy_value(other_value);
}
CAN__ID::~CAN__ID()
{
clean_up();
}
CAN__ID& CAN__ID::operator=(const CAN__ID& other_value)
{
if (this != &other_value) {
clean_up();
copy_value(other_value);
}
return *this;
}
boolean CAN__ID::operator==(const CAN__ID& other_value) const
{
if (union_selection == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of union type @Isobustest.CAN_ID.");
if (other_value.union_selection == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of union type @Isobustest.CAN_ID.");
if (union_selection != other_value.union_selection) return FALSE;
switch (union_selection) {
case ALT_can__eff:
return *field_can__eff == *other_value.field_can__eff;
case ALT_can__sff:
return *field_can__sff == *other_value.field_can__sff;
case ALT_can__rtr:
return *field_can__rtr == *other_value.field_can__rtr;
case ALT_can__err:
return *field_can__err == *other_value.field_can__err;
default:
return FALSE;
}
}
OCTETSTRING& CAN__ID::can__eff()
{
if (union_selection != ALT_can__eff) {
clean_up();
field_can__eff = new OCTETSTRING;
union_selection = ALT_can__eff;
}
return *field_can__eff;
}
const OCTETSTRING& CAN__ID::can__eff() const
{
if (union_selection != ALT_can__eff) TTCN_error("Using non-selected field can_eff in a value of union type @Isobustest.CAN_ID.");
return *field_can__eff;
}
OCTETSTRING& CAN__ID::can__sff()
{
if (union_selection != ALT_can__sff) {
clean_up();
field_can__sff = new OCTETSTRING;
union_selection = ALT_can__sff;
}
return *field_can__sff;
}
const OCTETSTRING& CAN__ID::can__sff() const
{
if (union_selection != ALT_can__sff) TTCN_error("Using non-selected field can_sff in a value of union type @Isobustest.CAN_ID.");
return *field_can__sff;
}
RTR& CAN__ID::can__rtr()
{
if (union_selection != ALT_can__rtr) {
clean_up();
field_can__rtr = new RTR;
union_selection = ALT_can__rtr;
}
return *field_can__rtr;
}
const RTR& CAN__ID::can__rtr() const
{
if (union_selection != ALT_can__rtr) TTCN_error("Using non-selected field can_rtr in a value of union type @Isobustest.CAN_ID.");
return *field_can__rtr;
}
BITSTRING& CAN__ID::can__err()
{
if (union_selection != ALT_can__err) {
clean_up();
field_can__err = new BITSTRING;
union_selection = ALT_can__err;
}
return *field_can__err;
}
const BITSTRING& CAN__ID::can__err() const
{
if (union_selection != ALT_can__err) TTCN_error("Using non-selected field can_err in a value of union type @Isobustest.CAN_ID.");
return *field_can__err;
}
boolean CAN__ID::ischosen(union_selection_type checked_selection) const
{
if (checked_selection == UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type @Isobustest.CAN_ID.");
return union_selection == checked_selection;
}
boolean CAN__ID::is_bound() const
{
return union_selection != UNBOUND_VALUE;
}
boolean CAN__ID::is_value() const
{
switch (union_selection) {
case UNBOUND_VALUE: return FALSE;
case ALT_can__eff: return field_can__eff->is_value();
case ALT_can__sff: return field_can__sff->is_value();
case ALT_can__rtr: return field_can__rtr->is_value();
case ALT_can__err: return field_can__err->is_value();
default: TTCN_error("Invalid selection in union is_bound");}
}
void CAN__ID::clean_up()
{
switch (union_selection) {
case ALT_can__eff:
delete field_can__eff;
break;
case ALT_can__sff:
delete field_can__sff;
break;
case ALT_can__rtr:
delete field_can__rtr;
break;
case ALT_can__err:
delete field_can__err;
break;
default:
break;
}
union_selection = UNBOUND_VALUE;
}
void CAN__ID::log() const
{
switch (union_selection) {
case ALT_can__eff:
TTCN_Logger::log_event_str("{ can_eff := ");
field_can__eff->log();
TTCN_Logger::log_event_str(" }");
break;
case ALT_can__sff:
TTCN_Logger::log_event_str("{ can_sff := ");
field_can__sff->log();
TTCN_Logger::log_event_str(" }");
break;
case ALT_can__rtr:
TTCN_Logger::log_event_str("{ can_rtr := ");
field_can__rtr->log();
TTCN_Logger::log_event_str(" }");
break;
case ALT_can__err:
TTCN_Logger::log_event_str("{ can_err := ");
field_can__err->log();
TTCN_Logger::log_event_str(" }");
break;
default:
TTCN_Logger::log_event_unbound();
}
}
void CAN__ID::set_param(Module_Param& param)
{
param.basic_check(Module_Param::BC_VALUE, "union value");
Module_Param_Ptr m_p = &param;
if (m_p->get_type()==Module_Param::MP_Value_List && m_p->get_size()==0) return;
if (m_p->get_type()!=Module_Param::MP_Assignment_List) {
param.error("union value with field name was expected");
}
Module_Param* mp_last = m_p->get_elem(m_p->get_size()-1);
char* last_name = mp_last->get_id()->get_name();
if (!strcmp(last_name, "can_eff")) {
can__eff().set_param(*mp_last);
if (!can__eff().is_bound()) clean_up();
return;
}
if (!strcmp(last_name, "can_sff")) {
can__sff().set_param(*mp_last);
if (!can__sff().is_bound()) clean_up();
return;
}
if (!strcmp(last_name, "can_rtr")) {
can__rtr().set_param(*mp_last);
if (!can__rtr().is_bound()) clean_up();
return;
}
if (!strcmp(last_name, "can_err")) {
can__err().set_param(*mp_last);
if (!can__err().is_bound()) clean_up();
return;
}
mp_last->error("Field %s does not exist in type @Isobustest.CAN_ID.", last_name);
}
void CAN__ID::set_implicit_omit()
{
switch (union_selection) {
case ALT_can__eff:
field_can__eff->set_implicit_omit(); break;
case ALT_can__sff:
field_can__sff->set_implicit_omit(); break;
case ALT_can__rtr:
field_can__rtr->set_implicit_omit(); break;
case ALT_can__err:
field_can__err->set_implicit_omit(); break;
default: break;
}
}
void CAN__ID::encode_text(Text_Buf& text_buf) const
{
text_buf.push_int(union_selection);
switch (union_selection) {
case ALT_can__eff:
field_can__eff->encode_text(text_buf);
break;
case ALT_can__sff:
field_can__sff->encode_text(text_buf);
break;
case ALT_can__rtr:
field_can__rtr->encode_text(text_buf);
break;
case ALT_can__err:
field_can__err->encode_text(text_buf);
break;
default:
TTCN_error("Text encoder: Encoding an unbound value of union type @Isobustest.CAN_ID.");
}
}
void CAN__ID::decode_text(Text_Buf& text_buf)
{
switch ((union_selection_type)text_buf.pull_int().get_val()) {
case ALT_can__eff:
can__eff().decode_text(text_buf);
break;
case ALT_can__sff:
can__sff().decode_text(text_buf);
break;
case ALT_can__rtr:
can__rtr().decode_text(text_buf);
break;
case ALT_can__err:
can__err().decode_text(text_buf);
break;
default:
TTCN_error("Text decoder: Unrecognized union selector was received for type @Isobustest.CAN_ID.");
}
}
void CAN__ID_template::copy_value(const CAN__ID& other_value)
{
single_value.union_selection = other_value.get_selection();
switch (single_value.union_selection) {
case CAN__ID::ALT_can__eff:
single_value.field_can__eff = new OCTETSTRING_template(other_value.can__eff());
break;
case CAN__ID::ALT_can__sff:
single_value.field_can__sff = new OCTETSTRING_template(other_value.can__sff());
break;
case CAN__ID::ALT_can__rtr:
single_value.field_can__rtr = new RTR_template(other_value.can__rtr());
break;
case CAN__ID::ALT_can__err:
single_value.field_can__err = new BITSTRING_template(other_value.can__err());
break;
default:
TTCN_error("Initializing a template with an unbound value of type @Isobustest.CAN_ID.");
}
set_selection(SPECIFIC_VALUE);
}
void CAN__ID_template::copy_template(const CAN__ID_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value.union_selection = other_value.single_value.union_selection;
switch (single_value.union_selection) {
case CAN__ID::ALT_can__eff:
single_value.field_can__eff = new OCTETSTRING_template(*other_value.single_value.field_can__eff);
break;
case CAN__ID::ALT_can__sff:
single_value.field_can__sff = new OCTETSTRING_template(*other_value.single_value.field_can__sff);
break;
case CAN__ID::ALT_can__rtr:
single_value.field_can__rtr = new RTR_template(*other_value.single_value.field_can__rtr);
break;
case CAN__ID::ALT_can__err:
single_value.field_can__err = new BITSTRING_template(*other_value.single_value.field_can__err);
break;
default:
TTCN_error("Internal error: Invalid union selector in a specific value when copying a template of type @Isobustest.CAN_ID.");
}
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 CAN__ID_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 template of union type @Isobustest.CAN_ID.");
}
set_selection(other_value);
}
CAN__ID_template::CAN__ID_template()
{
}
CAN__ID_template::CAN__ID_template(template_sel other_value)
: Base_Template(other_value)
{
check_single_selection(other_value);
}
CAN__ID_template::CAN__ID_template(const CAN__ID& other_value)
{
copy_value(other_value);
}
CAN__ID_template::CAN__ID_template(const OPTIONAL<CAN__ID>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const CAN__ID&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of union type @Isobustest.CAN_ID from an unbound optional field.");
}
}
CAN__ID_template::CAN__ID_template(const CAN__ID_template& other_value)
: Base_Template(){
copy_template(other_value);
}
CAN__ID_template::~CAN__ID_template()
{
clean_up();
}
void CAN__ID_template::clean_up()
{
switch (template_selection) {
case SPECIFIC_VALUE:
switch (single_value.union_selection) {
case CAN__ID::ALT_can__eff:
delete single_value.field_can__eff;
break;
case CAN__ID::ALT_can__sff:
delete single_value.field_can__sff;
break;
case CAN__ID::ALT_can__rtr:
delete single_value.field_can__rtr;
break;
case CAN__ID::ALT_can__err:
delete single_value.field_can__err;
default:
break;
}
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
delete [] value_list.list_value;
default:
break;
}
template_selection = UNINITIALIZED_TEMPLATE;
}
CAN__ID_template& CAN__ID_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}
CAN__ID_template& CAN__ID_template::operator=(const CAN__ID& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}
CAN__ID_template& CAN__ID_template::operator=(const OPTIONAL<CAN__ID>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const CAN__ID&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Assignment of an unbound optional field to a template of union type @Isobustest.CAN_ID.");
}
return *this;
}
CAN__ID_template& CAN__ID_template::operator=(const CAN__ID_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}
boolean CAN__ID_template::match(const CAN__ID& 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:
{
CAN__ID::union_selection_type value_selection = other_value.get_selection();
if (value_selection == CAN__ID::UNBOUND_VALUE) return FALSE;
if (value_selection != single_value.union_selection) return FALSE;
switch (value_selection) {
case CAN__ID::ALT_can__eff:
return single_value.field_can__eff->match(other_value.can__eff(), legacy);
case CAN__ID::ALT_can__sff:
return single_value.field_can__sff->match(other_value.can__sff(), legacy);
case CAN__ID::ALT_can__rtr:
return single_value.field_can__rtr->match(other_value.can__rtr(), legacy);
case CAN__ID::ALT_can__err:
return single_value.field_can__err->match(other_value.can__err(), legacy);
default:
TTCN_error("Internal error: Invalid selector in a specific value when matching a template of union type @Isobustest.CAN_ID.");
}
}
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 template of union type @Isobustest.CAN_ID.");
}
return FALSE;
}
boolean CAN__ID_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
switch (single_value.union_selection) {
case CAN__ID::ALT_can__eff:
return single_value.field_can__eff->is_value();
case CAN__ID::ALT_can__sff:
return single_value.field_can__sff->is_value();
case CAN__ID::ALT_can__rtr:
return single_value.field_can__rtr->is_value();
case CAN__ID::ALT_can__err:
return single_value.field_can__err->is_value();
default:
TTCN_error("Internal error: Invalid selector in a specific value when performing is_value operation on a template of union type @Isobustest.CAN_ID.");
}
}
CAN__ID CAN__ID_template::valueof() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent)
TTCN_error("Performing a valueof or send operation on a non-specific template of union type @Isobustest.CAN_ID.");
CAN__ID ret_val;
switch (single_value.union_selection) {
case CAN__ID::ALT_can__eff:
ret_val.can__eff() = single_value.field_can__eff->valueof();
break;
case CAN__ID::ALT_can__sff:
ret_val.can__sff() = single_value.field_can__sff->valueof();
break;
case CAN__ID::ALT_can__rtr:
ret_val.can__rtr() = single_value.field_can__rtr->valueof();
break;
case CAN__ID::ALT_can__err:
ret_val.can__err() = single_value.field_can__err->valueof();
break;
default:
TTCN_error("Internal error: Invalid selector in a specific value when performing valueof operation on a template of union type @Isobustest.CAN_ID.");
}
return ret_val;
}
CAN__ID_template& CAN__ID_template::list_item(unsigned int list_index) const
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) TTCN_error("Internal error: Accessing a list element of a non-list template of union type @Isobustest.CAN_ID.");
if (list_index >= value_list.n_values) TTCN_error("Internal error: Index overflow in a value list template of union type @Isobustest.CAN_ID.");
return value_list.list_value[list_index];
}
void CAN__ID_template::set_type(template_sel template_type, unsigned int list_length)
{
if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST) TTCN_error ("Internal error: Setting an invalid list for a template of union type @Isobustest.CAN_ID.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new CAN__ID_template[list_length];
}
OCTETSTRING_template& CAN__ID_template::can__eff()
{
if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CAN__ID::ALT_can__eff) {
template_sel old_selection = template_selection;
clean_up();
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_can__eff = new OCTETSTRING_template(ANY_VALUE);
else single_value.field_can__eff = new OCTETSTRING_template;
single_value.union_selection = CAN__ID::ALT_can__eff;
set_selection(SPECIFIC_VALUE);
}
return *single_value.field_can__eff;
}
const OCTETSTRING_template& CAN__ID_template::can__eff() const
{
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field can_eff in a non-specific template of union type @Isobustest.CAN_ID.");
if (single_value.union_selection != CAN__ID::ALT_can__eff) TTCN_error("Accessing non-selected field can_eff in a template of union type @Isobustest.CAN_ID.");
return *single_value.field_can__eff;
}
OCTETSTRING_template& CAN__ID_template::can__sff()
{
if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CAN__ID::ALT_can__sff) {
template_sel old_selection = template_selection;
clean_up();
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_can__sff = new OCTETSTRING_template(ANY_VALUE);
else single_value.field_can__sff = new OCTETSTRING_template;
single_value.union_selection = CAN__ID::ALT_can__sff;
set_selection(SPECIFIC_VALUE);
}
return *single_value.field_can__sff;
}
const OCTETSTRING_template& CAN__ID_template::can__sff() const
{
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field can_sff in a non-specific template of union type @Isobustest.CAN_ID.");
if (single_value.union_selection != CAN__ID::ALT_can__sff) TTCN_error("Accessing non-selected field can_sff in a template of union type @Isobustest.CAN_ID.");
return *single_value.field_can__sff;
}
RTR_template& CAN__ID_template::can__rtr()
{
if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CAN__ID::ALT_can__rtr) {
template_sel old_selection = template_selection;
clean_up();
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_can__rtr = new RTR_template(ANY_VALUE);
else single_value.field_can__rtr = new RTR_template;
single_value.union_selection = CAN__ID::ALT_can__rtr;
set_selection(SPECIFIC_VALUE);
}
return *single_value.field_can__rtr;
}
const RTR_template& CAN__ID_template::can__rtr() const
{
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field can_rtr in a non-specific template of union type @Isobustest.CAN_ID.");
if (single_value.union_selection != CAN__ID::ALT_can__rtr) TTCN_error("Accessing non-selected field can_rtr in a template of union type @Isobustest.CAN_ID.");
return *single_value.field_can__rtr;
}
BITSTRING_template& CAN__ID_template::can__err()
{
if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CAN__ID::ALT_can__err) {
template_sel old_selection = template_selection;
clean_up();
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_can__err = new BITSTRING_template(ANY_VALUE);
else single_value.field_can__err = new BITSTRING_template;
single_value.union_selection = CAN__ID::ALT_can__err;
set_selection(SPECIFIC_VALUE);
}
return *single_value.field_can__err;
}
const BITSTRING_template& CAN__ID_template::can__err() const
{
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field can_err in a non-specific template of union type @Isobustest.CAN_ID.");
if (single_value.union_selection != CAN__ID::ALT_can__err) TTCN_error("Accessing non-selected field can_err in a template of union type @Isobustest.CAN_ID.");
return *single_value.field_can__err;
}
boolean CAN__ID_template::ischosen(CAN__ID::union_selection_type checked_selection) const
{
if (checked_selection == CAN__ID::UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type @Isobustest.CAN_ID.");
switch (template_selection) {
case SPECIFIC_VALUE:
if (single_value.union_selection == CAN__ID::UNBOUND_VALUE) TTCN_error("Internal error: Invalid selector in a specific value when performing ischosen() operation on a template of union type @Isobustest.CAN_ID.");
return single_value.union_selection == checked_selection;
case VALUE_LIST:
{
if (value_list.n_values < 1)
TTCN_error("Internal error: Performing ischosen() operation on a template of union type @Isobustest.CAN_ID containing an empty list.");
boolean ret_val = value_list.list_value[0].ischosen(checked_selection);
for (unsigned int list_count = 1; ret_val == TRUE && list_count < value_list.n_values; list_count++) {
ret_val = value_list.list_value[list_count].ischosen(checked_selection);
}
return ret_val;
}
default:
return FALSE;
}
return FALSE;
}
void CAN__ID_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
switch (single_value.union_selection) {
case CAN__ID::ALT_can__eff:
TTCN_Logger::log_event_str("{ can_eff := ");
single_value.field_can__eff->log();
TTCN_Logger::log_event_str(" }");
break;
case CAN__ID::ALT_can__sff:
TTCN_Logger::log_event_str("{ can_sff := ");
single_value.field_can__sff->log();
TTCN_Logger::log_event_str(" }");
break;
case CAN__ID::ALT_can__rtr:
TTCN_Logger::log_event_str("{ can_rtr := ");
single_value.field_can__rtr->log();
TTCN_Logger::log_event_str(" }");
break;
case CAN__ID::ALT_can__err:
TTCN_Logger::log_event_str("{ can_err := ");
single_value.field_can__err->log();
TTCN_Logger::log_event_str(" }");
break;
default:
TTCN_Logger::log_event_str("<invalid selector>");
}
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 CAN__ID_template::log_match(const CAN__ID& match_value, boolean legacy) const
{
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity() && match(match_value, legacy)){
TTCN_Logger::print_logmatch_buffer();
TTCN_Logger::log_event_str(" matched");
return;
}
if (template_selection == SPECIFIC_VALUE && single_value.union_selection == match_value.get_selection()) {
switch (single_value.union_selection) {
case CAN__ID::ALT_can__eff:
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
TTCN_Logger::log_logmatch_info(".can_eff");
single_value.field_can__eff->log_match(match_value.can__eff(), legacy);
} else {
TTCN_Logger::log_event_str("{ can_eff := ");
single_value.field_can__eff->log_match(match_value.can__eff(), legacy);
TTCN_Logger::log_event_str(" }");
}
break;
case CAN__ID::ALT_can__sff:
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
TTCN_Logger::log_logmatch_info(".can_sff");
single_value.field_can__sff->log_match(match_value.can__sff(), legacy);
} else {
TTCN_Logger::log_event_str("{ can_sff := ");
single_value.field_can__sff->log_match(match_value.can__sff(), legacy);
TTCN_Logger::log_event_str(" }");
}
break;
case CAN__ID::ALT_can__rtr:
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
TTCN_Logger::log_logmatch_info(".can_rtr");
single_value.field_can__rtr->log_match(match_value.can__rtr(), legacy);
} else {
TTCN_Logger::log_event_str("{ can_rtr := ");
single_value.field_can__rtr->log_match(match_value.can__rtr(), legacy);
TTCN_Logger::log_event_str(" }");
}
break;
case CAN__ID::ALT_can__err:
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
TTCN_Logger::log_logmatch_info(".can_err");
single_value.field_can__err->log_match(match_value.can__err(), legacy);
} else {
TTCN_Logger::log_event_str("{ can_err := ");
single_value.field_can__err->log_match(match_value.can__err(), legacy);
TTCN_Logger::log_event_str(" }");
}
break;
default:
TTCN_Logger::print_logmatch_buffer();
TTCN_Logger::log_event_str("<invalid selector>");
}
} else {
TTCN_Logger::print_logmatch_buffer();
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 CAN__ID_template::encode_text(Text_Buf& text_buf) const
{
encode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
text_buf.push_int(single_value.union_selection);
switch (single_value.union_selection) {
case CAN__ID::ALT_can__eff:
single_value.field_can__eff->encode_text(text_buf);
break;
case CAN__ID::ALT_can__sff:
single_value.field_can__sff->encode_text(text_buf);
break;
case CAN__ID::ALT_can__rtr:
single_value.field_can__rtr->encode_text(text_buf);
break;
case CAN__ID::ALT_can__err:
single_value.field_can__err->encode_text(text_buf);
break;
default:
TTCN_error("Internal error: Invalid selector in a specific value when encoding a template of union type @Isobustest.CAN_ID.");
}
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 template of type @Isobustest.CAN_ID.");
}
}
void CAN__ID_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
{
single_value.union_selection = CAN__ID::UNBOUND_VALUE;
CAN__ID::union_selection_type new_selection = (CAN__ID::union_selection_type)text_buf.pull_int().get_val();
switch (new_selection) {
case CAN__ID::ALT_can__eff:
single_value.field_can__eff = new OCTETSTRING_template;
single_value.field_can__eff->decode_text(text_buf);
break;
case CAN__ID::ALT_can__sff:
single_value.field_can__sff = new OCTETSTRING_template;
single_value.field_can__sff->decode_text(text_buf);
break;
case CAN__ID::ALT_can__rtr:
single_value.field_can__rtr = new RTR_template;
single_value.field_can__rtr->decode_text(text_buf);
break;
case CAN__ID::ALT_can__err:
single_value.field_can__err = new BITSTRING_template;
single_value.field_can__err->decode_text(text_buf);
break;
default:
TTCN_error("Text decoder: Unrecognized union selector was received for a template of type @Isobustest.CAN_ID.");
}
single_value.union_selection = new_selection;
}
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 CAN__ID_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: Unrecognized selector was received in a template of type @Isobustest.CAN_ID.");
}
}
boolean CAN__ID_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}
boolean CAN__ID_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 v_idx=0; v_idx<value_list.n_values; v_idx++)
if (value_list.list_value[v_idx].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}
void CAN__ID_template::set_param(Module_Param& param)
{
if (dynamic_cast<Module_Param_Name*>(param.get_id()) != NULL &&
param.get_id()->next_name()) {
char* param_field = param.get_id()->get_current_name();
if (param_field[0] >= '0' && param_field[0] <= '9') {
param.error("Unexpected array index in module parameter, expected a valid field"
" name for union template type `@Isobustest.CAN_ID'");
}
if (strcmp("can_eff", param_field) == 0) {
can__eff().set_param(param);
return;
} else if (strcmp("can_sff", param_field) == 0) {
can__sff().set_param(param);
return;
} else if (strcmp("can_rtr", param_field) == 0) {
can__rtr().set_param(param);
return;
} else if (strcmp("can_err", param_field) == 0) {
can__err().set_param(param);
return;
} else param.error("Field `%s' not found in union template type `@Isobustest.CAN_ID'", param_field);
}
param.basic_check(Module_Param::BC_TEMPLATE, "union template");
Module_Param_Ptr m_p = &param;
switch (m_p->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: {
CAN__ID_template new_temp;
new_temp.set_type(m_p->get_type()==Module_Param::MP_List_Template ? VALUE_LIST : COMPLEMENTED_LIST, m_p->get_size());
for (size_t p_i=0; p_i<m_p->get_size(); p_i++) {
new_temp.list_item(p_i).set_param(*m_p->get_elem(p_i));
}
*this = new_temp;
break; }
case Module_Param::MP_Value_List:
if (m_p->get_size()==0) break;
param.type_error("union template", "@Isobustest.CAN_ID");
break;
case Module_Param::MP_Assignment_List: {
Module_Param* mp_last = m_p->get_elem(m_p->get_size()-1);
char* last_name = mp_last->get_id()->get_name();
if (!strcmp(last_name, "can_eff")) {
can__eff().set_param(*mp_last);
break;
}
if (!strcmp(last_name, "can_sff")) {
can__sff().set_param(*mp_last);
break;
}
if (!strcmp(last_name, "can_rtr")) {
can__rtr().set_param(*mp_last);
break;
}
if (!strcmp(last_name, "can_err")) {
can__err().set_param(*mp_last);
break;
}
mp_last->error("Field %s does not exist in type @Isobustest.CAN_ID.", last_name);
} break;
default:
param.type_error("union template", "@Isobustest.CAN_ID");
}
is_ifpresent = param.get_ifpresent();
}
void CAN__ID_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;
switch (single_value.union_selection) {
case CAN__ID::ALT_can__eff:
single_value.field_can__eff->check_restriction(t_res, t_name ? t_name : "@Isobustest.CAN_ID");
return;
case CAN__ID::ALT_can__sff:
single_value.field_can__sff->check_restriction(t_res, t_name ? t_name : "@Isobustest.CAN_ID");
return;
case CAN__ID::ALT_can__rtr:
single_value.field_can__rtr->check_restriction(t_res, t_name ? t_name : "@Isobustest.CAN_ID");
return;
case CAN__ID::ALT_can__err:
single_value.field_can__err->check_restriction(t_res, t_name ? t_name : "@Isobustest.CAN_ID");
return;
default:
TTCN_error("Internal error: Invalid selector in a specific value when performing check_restriction operation on a template of union type @Isobustest.CAN_ID.");
}
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 : "@Isobustest.CAN_ID");
}
RTR::RTR()
{
enum_value = UNBOUND_VALUE;
}
RTR::RTR(int other_value)
{
if (!is_valid_enum(other_value)) TTCN_error("Initializing a variable of enumerated type @Isobustest.RTR with invalid numeric value %d.", other_value);
enum_value = (enum_type)other_value;
}
RTR::RTR(enum_type other_value)
{
enum_value = other_value;
}
RTR::RTR(const RTR& other_value)
: Base_Type()
{
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Copying an unbound value of enumerated type @Isobustest.RTR.");
enum_value = other_value.enum_value;
}
RTR& RTR::operator=(int other_value)
{
if (!is_valid_enum(other_value)) TTCN_error("Assigning unknown numeric value %d to a variable of enumerated type @Isobustest.RTR.", other_value);
enum_value = (enum_type)other_value;
return *this;
}
RTR& RTR::operator=(enum_type other_value)
{
enum_value = other_value;
return *this;
}
RTR& RTR::operator=(const RTR& other_value)
{
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @Isobustest.RTR.");
enum_value = other_value.enum_value;
return *this;
}
boolean RTR::operator==(enum_type other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Isobustest.RTR.");
return enum_value == other_value;
}
boolean RTR::operator==(const RTR& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Isobustest.RTR.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @Isobustest.RTR.");
return enum_value == other_value.enum_value;
}
boolean RTR::operator<(enum_type other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Isobustest.RTR.");
return enum_value < other_value;
}
boolean RTR::operator<(const RTR& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Isobustest.RTR.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @Isobustest.RTR.");
return enum_value < other_value.enum_value;
}
boolean RTR::operator>(enum_type other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Isobustest.RTR.");
return enum_value > other_value;
}
boolean RTR::operator>(const RTR& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Isobustest.RTR.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @Isobustest.RTR.");
return enum_value > other_value.enum_value;
}
const char *RTR::enum_to_str(enum_type enum_par)
{
switch (enum_par) {
case RTRNULL: return "RTRNULL";
default: return "<unknown>";
}
}
RTR::enum_type RTR::str_to_enum(const char *str_par)
{
if (!strcmp(str_par, "RTRNULL")) return RTRNULL;
else return UNKNOWN_VALUE;
}
boolean RTR::is_valid_enum(int int_par)
{
switch (int_par) {
case 0:
return TRUE;
default:
return FALSE;
}
}
int RTR::enum2int(enum_type enum_par)
{
if (enum_par==UNBOUND_VALUE || enum_par==UNKNOWN_VALUE) TTCN_error("The argument of function enum2int() is an %s value of enumerated type @Isobustest.RTR.", enum_par==UNBOUND_VALUE?"unbound":"invalid");
return enum_par;
}
int RTR::enum2int(const RTR& enum_par)
{
if (enum_par.enum_value==UNBOUND_VALUE || enum_par.enum_value==UNKNOWN_VALUE) TTCN_error("The argument of function enum2int() is an %s value of enumerated type @Isobustest.RTR.", enum_par==UNBOUND_VALUE?"unbound":"invalid");
return enum_par.enum_value;
}
void RTR::int2enum(int int_val)
{
if (!is_valid_enum(int_val)) TTCN_error("Assigning invalid numeric value %d to a variable of enumerated type @Isobustest.RTR.", int_val);
enum_value = (enum_type)int_val;
}
RTR::operator RTR::enum_type() const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("Using the value of an unbound variable of enumerated type @Isobustest.RTR.");
return enum_value;
}
void RTR::log() const
{
if (enum_value != UNBOUND_VALUE) TTCN_Logger::log_event_enum(enum_to_str(enum_value), enum_value);
else TTCN_Logger::log_event_unbound();
}
void RTR::set_param(Module_Param& param)
{
param.basic_check(Module_Param::BC_VALUE, "enumerated value");
if (param.get_type()!=Module_Param::MP_Enumerated) param.type_error("enumerated value", "@Isobustest.RTR");
enum_value = str_to_enum(param.get_enumerated());
if (!is_valid_enum(enum_value)) {
param.error("Invalid enumerated value for type @Isobustest.RTR.");
}
}
void RTR::encode_text(Text_Buf& text_buf) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("Text encoder: Encoding an unbound value of enumerated type @Isobustest.RTR.");
text_buf.push_int(enum_value);
}
void RTR::decode_text(Text_Buf& text_buf)
{
enum_value = (enum_type)text_buf.pull_int().get_val();
if (!is_valid_enum(enum_value)) TTCN_error("Text decoder: Unknown numeric value %d was received for enumerated type @Isobustest.RTR.", enum_value);
}
void RTR::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(TRUE, 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 RTR::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 RTR::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*)
{
int decoded_value = 0;
int decoded_length = RAW_decode_enum_type(p_td, p_buf, limit, top_bit_ord, decoded_value, 1, no_err);
if (decoded_length < 0) return decoded_length;
if (is_valid_enum(decoded_value)) enum_value = (enum_type)decoded_value;
else {
if(no_err){
return -1;
} else {
TTCN_EncDec_ErrorContext::error
(TTCN_EncDec::ET_ENC_ENUM, "Invalid enum value '%d' for '%s': ",decoded_value, p_td.name);
enum_value = UNKNOWN_VALUE;
}
}
return decoded_length;
}
int RTR::RAW_encode(const TTCN_Typedescriptor_t& p_td, RAW_enc_tree& myleaf) const
{
return RAW_encode_enum_type(p_td, myleaf, (int)enum_value, 1);
}
void RTR_template::copy_template(const RTR_template& other_value)
{
set_selection(other_value);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value = other_value.single_value;
break;
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 RTR_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 enumerated type @Isobustest.RTR.");
}
}
RTR_template::RTR_template()
{
}
RTR_template::RTR_template(template_sel other_value)
: Base_Template(other_value)
{
check_single_selection(other_value);
}
RTR_template::RTR_template(int other_value)
: Base_Template(SPECIFIC_VALUE)
{
if (!RTR::is_valid_enum(other_value)) TTCN_error("Initializing a template of enumerated type @Isobustest.RTR with unknown numeric value %d.", other_value);
single_value = (RTR::enum_type)other_value;
}
RTR_template::RTR_template(RTR::enum_type other_value)
: Base_Template(SPECIFIC_VALUE)
{
single_value = other_value;
}
RTR_template::RTR_template(const RTR& other_value)
: Base_Template(SPECIFIC_VALUE)
{
if (other_value.enum_value == RTR::UNBOUND_VALUE) TTCN_error("Creating a template from an unbound value of enumerated type @Isobustest.RTR.");
single_value = other_value.enum_value;
}
RTR_template::RTR_template(const OPTIONAL<RTR>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
set_selection(SPECIFIC_VALUE);
single_value = (RTR::enum_type)(const RTR&)other_value;
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of enumerated type @Isobustest.RTR from an unbound optional field.");
}
}
RTR_template::RTR_template(const RTR_template& other_value)
: Base_Template()
{
copy_template(other_value);
}
RTR_template::~RTR_template()
{
clean_up();
}
boolean RTR_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
return TRUE;
}
boolean RTR_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value != RTR::UNBOUND_VALUE;
}
void RTR_template::clean_up()
{
if (template_selection == VALUE_LIST || template_selection == COMPLEMENTED_LIST) delete [] value_list.list_value;
template_selection = UNINITIALIZED_TEMPLATE;
}
RTR_template& RTR_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}
RTR_template& RTR_template::operator=(int other_value)
{
if (!RTR::is_valid_enum(other_value)) TTCN_warning("Assigning unknown numeric value %d to a template of enumerated type @Isobustest.RTR.", other_value);
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = (RTR::enum_type)other_value;
return *this;
}
RTR_template& RTR_template::operator=(RTR::enum_type other_value)
{
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = other_value;
return *this;
}
RTR_template& RTR_template::operator=(const RTR& other_value)
{
if (other_value.enum_value == RTR::UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @Isobustest.RTR to a template.");
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = other_value.enum_value;
return *this;
}
RTR_template& RTR_template::operator=(const OPTIONAL<RTR>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
set_selection(SPECIFIC_VALUE);
single_value = (RTR::enum_type)(const RTR&)other_value;
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Assignment of an unbound optional field to a template of enumerated type @Isobustest.RTR.");
}
return *this;
}
RTR_template& RTR_template::operator=(const RTR_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}
boolean RTR_template::match(RTR::enum_type other_value, boolean) const
{
switch (template_selection) {
case SPECIFIC_VALUE:
return single_value == other_value;
case OMIT_VALUE:
return FALSE;
case ANY_VALUE:
case ANY_OR_OMIT:
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)) return template_selection == VALUE_LIST;
return template_selection == COMPLEMENTED_LIST;
default:
TTCN_error("Matching an uninitialized/unsupported template of enumerated type @Isobustest.RTR.");
}
return FALSE;
}
boolean RTR_template::match(const RTR& other_value, boolean) const
{
if (other_value.enum_value == RTR::UNBOUND_VALUE) TTCN_error("Matching a template of enumerated type @Isobustest.RTR with an unbound value.");
return match(other_value.enum_value);
}
RTR::enum_type RTR_template::valueof() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) TTCN_error("Performing a valueof or send operation on a non-specific template of enumerated type @Isobustest.RTR.");
return single_value;
}
void RTR_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 type for a template of enumerated type @Isobustest.RTR.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new RTR_template[list_length];
}
RTR_template& RTR_template::list_item(unsigned int list_index)
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) TTCN_error("Accessing a list element in a non-list template of enumerated type @Isobustest.RTR.");
if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of enumerated type @Isobustest.RTR.");
return value_list.list_value[list_index];
}
void RTR_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_enum(RTR::enum_to_str(single_value), single_value);
break;
case COMPLEMENTED_LIST:
TTCN_Logger::log_event_str("complement");
case VALUE_LIST:
TTCN_Logger::log_char('(');
for (unsigned int elem_count = 0; elem_count < value_list.n_values; elem_count++) {
if (elem_count > 0) TTCN_Logger::log_event_str(", ");
value_list.list_value[elem_count].log();
}
TTCN_Logger::log_char(')');
break;
default:
log_generic();
}
log_ifpresent();
}
void RTR_template::log_match(const RTR& match_value, boolean) const
{
match_value.log();
TTCN_Logger::log_event_str(" with ");
log();
if (match(match_value)) TTCN_Logger::log_event_str(" matched");
else TTCN_Logger::log_event_str(" unmatched");
}
void RTR_template::encode_text(Text_Buf& text_buf) const
{
encode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
text_buf.push_int(single_value);
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 elem_count = 0; elem_count < value_list.n_values; elem_count++)
value_list.list_value[elem_count].encode_text(text_buf);
break;
default:
TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of enumerated type @Isobustest.RTR.");
}
}
void RTR_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value = (RTR::enum_type)text_buf.pull_int().get_val();
if (!RTR::is_valid_enum(single_value)) TTCN_error("Text decoder: Unknown numeric value %d was received for a template of enumerated type @Isobustest.RTR.", single_value);
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 RTR_template[value_list.n_values];
for (unsigned int elem_count = 0; elem_count < value_list.n_values; elem_count++)
value_list.list_value[elem_count].decode_text(text_buf);
break;
default:
TTCN_error("Text decoder: An unknown/unsupported selection was received for a template of enumerated type @Isobustest.RTR.");
}
}
boolean RTR_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}
boolean RTR_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 i=0; i<value_list.n_values; i++)
if (value_list.list_value[i].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}
void RTR_template::set_param(Module_Param& param)
{
param.basic_check(Module_Param::BC_TEMPLATE, "enumerated template");
Module_Param_Ptr m_p = &param;
switch (m_p->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: {
RTR_template new_temp;
new_temp.set_type(m_p->get_type()==Module_Param::MP_List_Template ? VALUE_LIST : COMPLEMENTED_LIST, m_p->get_size());
for (size_t p_i=0; p_i<m_p->get_size(); p_i++) {
new_temp.list_item(p_i).set_param(*m_p->get_elem(p_i));
}
*this = new_temp;
break; }
case Module_Param::MP_Enumerated: {
RTR::enum_type enum_val = RTR::str_to_enum(m_p->get_enumerated());
if (!RTR::is_valid_enum(enum_val)) {
param.error("Invalid enumerated value for type @Isobustest.RTR.");
}
*this = enum_val;
} break;
default:
param.type_error("enumerated template", "@Isobustest.RTR");
}
is_ifpresent = param.get_ifpresent();
}
void RTR_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_VALUE:
if (!is_ifpresent && template_selection==SPECIFIC_VALUE) return;
break;
case TR_OMIT:
if (!is_ifpresent && (template_selection==OMIT_VALUE || template_selection==SPECIFIC_VALUE)) return;
break;
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 : "@Isobustest.RTR");
}
void Can__IDs::copy_value(const Can__IDs& other_value)
{
switch (other_value.union_selection) {
case ALT_can__eff:
field_can__eff = new BITSTRING(*other_value.field_can__eff);
break;
case ALT_can__sff:
field_can__sff = new BITSTRING(*other_value.field_can__sff);
break;
case ALT_can__rtr:
field_can__rtr = new RTR(*other_value.field_can__rtr);
break;
case ALT_can__err:
field_can__err = new BITSTRING(*other_value.field_can__err);
break;
default:
TTCN_error("Assignment of an unbound union value of type @Isobustest.Can_IDs.");
}
union_selection = other_value.union_selection;
}
Can__IDs::Can__IDs()
{
union_selection = UNBOUND_VALUE;
}
Can__IDs::Can__IDs(const Can__IDs& other_value)
: Base_Type(){
copy_value(other_value);
}
Can__IDs::~Can__IDs()
{
clean_up();
}
Can__IDs& Can__IDs::operator=(const Can__IDs& other_value)
{
if (this != &other_value) {
clean_up();
copy_value(other_value);
}
return *this;
}
boolean Can__IDs::operator==(const Can__IDs& other_value) const
{
if (union_selection == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of union type @Isobustest.Can_IDs.");
if (other_value.union_selection == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of union type @Isobustest.Can_IDs.");
if (union_selection != other_value.union_selection) return FALSE;
switch (union_selection) {
case ALT_can__eff:
return *field_can__eff == *other_value.field_can__eff;
case ALT_can__sff:
return *field_can__sff == *other_value.field_can__sff;
case ALT_can__rtr:
return *field_can__rtr == *other_value.field_can__rtr;
case ALT_can__err:
return *field_can__err == *other_value.field_can__err;
default:
return FALSE;
}
}
BITSTRING& Can__IDs::can__eff()
{
if (union_selection != ALT_can__eff) {
clean_up();
field_can__eff = new BITSTRING;
union_selection = ALT_can__eff;
}
return *field_can__eff;
}
const BITSTRING& Can__IDs::can__eff() const
{
if (union_selection != ALT_can__eff) TTCN_error("Using non-selected field can_eff in a value of union type @Isobustest.Can_IDs.");
return *field_can__eff;
}
BITSTRING& Can__IDs::can__sff()
{
if (union_selection != ALT_can__sff) {
clean_up();
field_can__sff = new BITSTRING;
union_selection = ALT_can__sff;
}
return *field_can__sff;
}
const BITSTRING& Can__IDs::can__sff() const
{
if (union_selection != ALT_can__sff) TTCN_error("Using non-selected field can_sff in a value of union type @Isobustest.Can_IDs.");
return *field_can__sff;
}
RTR& Can__IDs::can__rtr()
{
if (union_selection != ALT_can__rtr) {
clean_up();
field_can__rtr = new RTR;
union_selection = ALT_can__rtr;
}
return *field_can__rtr;
}
const RTR& Can__IDs::can__rtr() const
{
if (union_selection != ALT_can__rtr) TTCN_error("Using non-selected field can_rtr in a value of union type @Isobustest.Can_IDs.");
return *field_can__rtr;
}
BITSTRING& Can__IDs::can__err()
{
if (union_selection != ALT_can__err) {
clean_up();
field_can__err = new BITSTRING;
union_selection = ALT_can__err;
}
return *field_can__err;
}
const BITSTRING& Can__IDs::can__err() const
{
if (union_selection != ALT_can__err) TTCN_error("Using non-selected field can_err in a value of union type @Isobustest.Can_IDs.");
return *field_can__err;
}
boolean Can__IDs::ischosen(union_selection_type checked_selection) const
{
if (checked_selection == UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type @Isobustest.Can_IDs.");
return union_selection == checked_selection;
}
boolean Can__IDs::is_bound() const
{
return union_selection != UNBOUND_VALUE;
}
boolean Can__IDs::is_value() const
{
switch (union_selection) {
case UNBOUND_VALUE: return FALSE;
case ALT_can__eff: return field_can__eff->is_value();
case ALT_can__sff: return field_can__sff->is_value();
case ALT_can__rtr: return field_can__rtr->is_value();
case ALT_can__err: return field_can__err->is_value();
default: TTCN_error("Invalid selection in union is_bound");}
}
void Can__IDs::clean_up()
{
switch (union_selection) {
case ALT_can__eff:
delete field_can__eff;
break;
case ALT_can__sff:
delete field_can__sff;
break;
case ALT_can__rtr:
delete field_can__rtr;
break;
case ALT_can__err:
delete field_can__err;
break;
default:
break;
}
union_selection = UNBOUND_VALUE;
}
void Can__IDs::log() const
{
switch (union_selection) {
case ALT_can__eff:
TTCN_Logger::log_event_str("{ can_eff := ");
field_can__eff->log();
TTCN_Logger::log_event_str(" }");
break;
case ALT_can__sff:
TTCN_Logger::log_event_str("{ can_sff := ");
field_can__sff->log();
TTCN_Logger::log_event_str(" }");
break;
case ALT_can__rtr:
TTCN_Logger::log_event_str("{ can_rtr := ");
field_can__rtr->log();
TTCN_Logger::log_event_str(" }");
break;
case ALT_can__err:
TTCN_Logger::log_event_str("{ can_err := ");
field_can__err->log();
TTCN_Logger::log_event_str(" }");
break;
default:
TTCN_Logger::log_event_unbound();
}
}
void Can__IDs::set_param(Module_Param& param)
{
param.basic_check(Module_Param::BC_VALUE, "union value");
Module_Param_Ptr m_p = &param;
if (m_p->get_type()==Module_Param::MP_Value_List && m_p->get_size()==0) return;
if (m_p->get_type()!=Module_Param::MP_Assignment_List) {
param.error("union value with field name was expected");
}
Module_Param* mp_last = m_p->get_elem(m_p->get_size()-1);
char* last_name = mp_last->get_id()->get_name();
if (!strcmp(last_name, "can_eff")) {
can__eff().set_param(*mp_last);
if (!can__eff().is_bound()) clean_up();
return;
}
if (!strcmp(last_name, "can_sff")) {
can__sff().set_param(*mp_last);
if (!can__sff().is_bound()) clean_up();
return;
}
if (!strcmp(last_name, "can_rtr")) {
can__rtr().set_param(*mp_last);
if (!can__rtr().is_bound()) clean_up();
return;
}
if (!strcmp(last_name, "can_err")) {
can__err().set_param(*mp_last);
if (!can__err().is_bound()) clean_up();
return;
}
mp_last->error("Field %s does not exist in type @Isobustest.Can_IDs.", last_name);
}
void Can__IDs::set_implicit_omit()
{
switch (union_selection) {
case ALT_can__eff:
field_can__eff->set_implicit_omit(); break;
case ALT_can__sff:
field_can__sff->set_implicit_omit(); break;
case ALT_can__rtr:
field_can__rtr->set_implicit_omit(); break;
case ALT_can__err:
field_can__err->set_implicit_omit(); break;
default: break;
}
}
void Can__IDs::encode_text(Text_Buf& text_buf) const
{
text_buf.push_int(union_selection);
switch (union_selection) {
case ALT_can__eff:
field_can__eff->encode_text(text_buf);
break;
case ALT_can__sff:
field_can__sff->encode_text(text_buf);
break;
case ALT_can__rtr:
field_can__rtr->encode_text(text_buf);
break;
case ALT_can__err:
field_can__err->encode_text(text_buf);
break;
default:
TTCN_error("Text encoder: Encoding an unbound value of union type @Isobustest.Can_IDs.");
}
}
void Can__IDs::decode_text(Text_Buf& text_buf)
{
switch ((union_selection_type)text_buf.pull_int().get_val()) {
case ALT_can__eff:
can__eff().decode_text(text_buf);
break;
case ALT_can__sff:
can__sff().decode_text(text_buf);
break;
case ALT_can__rtr:
can__rtr().decode_text(text_buf);
break;
case ALT_can__err:
can__err().decode_text(text_buf);
break;
default:
TTCN_error("Text decoder: Unrecognized union selector was received for type @Isobustest.Can_IDs.");
}
}
void Can__IDs::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(TRUE, 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 Can__IDs::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 Can__IDs::RAW_decode(
const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int limit,
raw_order_t top_bit_ord, boolean no_err, int sel_field, boolean, const RAW_Force_Omit* force_omit)
{
int prepaddlength=p_buf.increase_pos_padd(p_td.raw->prepadding);
limit-=prepaddlength;
int decoded_length=0;
int starting_pos=p_buf.get_pos_bit();
if(sel_field!=-1){
switch(sel_field){
case 0: {
RAW_Force_Omit field_force_omit(0, force_omit, BIT29_descr_.raw->forceomit);
decoded_length = can__eff().RAW_decode(BIT29_descr_, p_buf, limit, top_bit_ord, no_err, -1, TRUE, &field_force_omit);
break; }
case 1: {
RAW_Force_Omit field_force_omit(1, force_omit, General__Types::BIT11_descr_.raw->forceomit);
decoded_length = can__sff().RAW_decode(General__Types::BIT11_descr_, p_buf, limit, top_bit_ord, no_err, -1, TRUE, &field_force_omit);
break; }
case 2: {
RAW_Force_Omit field_force_omit(2, force_omit, RTR_descr_.raw->forceomit);
decoded_length = can__rtr().RAW_decode(RTR_descr_, p_buf, limit, top_bit_ord, no_err, -1, TRUE, &field_force_omit);
break; }
case 3: {
RAW_Force_Omit field_force_omit(3, force_omit, BIT29_descr_.raw->forceomit);
decoded_length = can__err().RAW_decode(BIT29_descr_, p_buf, limit, top_bit_ord, no_err, -1, TRUE, &field_force_omit);
break; }
default: break;
}
return decoded_length + p_buf.increase_pos_padd(p_td.raw->padding) + prepaddlength;
} else {
p_buf.set_pos_bit(starting_pos);
RAW_Force_Omit field_0_force_omit(0, force_omit, BIT29_descr_.raw->forceomit);
decoded_length = can__eff().RAW_decode(BIT29_descr_, p_buf, limit, top_bit_ord, TRUE, -1, TRUE, &field_0_force_omit);
if (decoded_length >= 0) {
return decoded_length + p_buf.increase_pos_padd(p_td.raw->padding) + prepaddlength;
}
p_buf.set_pos_bit(starting_pos);
RAW_Force_Omit field_1_force_omit(1, force_omit, General__Types::BIT11_descr_.raw->forceomit);
decoded_length = can__sff().RAW_decode(General__Types::BIT11_descr_, p_buf, limit, top_bit_ord, TRUE, -1, TRUE, &field_1_force_omit);
if (decoded_length >= 0) {
return decoded_length + p_buf.increase_pos_padd(p_td.raw->padding) + prepaddlength;
}
p_buf.set_pos_bit(starting_pos);
RAW_Force_Omit field_2_force_omit(2, force_omit, RTR_descr_.raw->forceomit);
decoded_length = can__rtr().RAW_decode(RTR_descr_, p_buf, limit, top_bit_ord, TRUE, -1, TRUE, &field_2_force_omit);
if (decoded_length >= 0) {
return decoded_length + p_buf.increase_pos_padd(p_td.raw->padding) + prepaddlength;
}
p_buf.set_pos_bit(starting_pos);
RAW_Force_Omit field_3_force_omit(3, force_omit, BIT29_descr_.raw->forceomit);
decoded_length = can__err().RAW_decode(BIT29_descr_, p_buf, limit, top_bit_ord, TRUE, -1, TRUE, &field_3_force_omit);
if (decoded_length >= 0) {
return decoded_length + p_buf.increase_pos_padd(p_td.raw->padding) + prepaddlength;
}
}
clean_up();
return -1;
}
int Can__IDs::RAW_encode(const TTCN_Typedescriptor_t&, RAW_enc_tree& myleaf) const
{
int encoded_length = 0;
myleaf.isleaf = FALSE;
myleaf.body.node.num_of_nodes = 4; myleaf.body.node.nodes = init_nodes_of_enc_tree(4);
memset(myleaf.body.node.nodes, 0, 4 * sizeof(RAW_enc_tree *));
switch (union_selection) {
case ALT_can__eff:
myleaf.body.node.nodes[0] = new RAW_enc_tree(TRUE, &myleaf, &myleaf.curr_pos, 0, BIT29_descr_.raw);
encoded_length = field_can__eff->RAW_encode(BIT29_descr_, *myleaf.body.node.nodes[0]);
myleaf.body.node.nodes[0]->coding_descr = &BIT29_descr_;
break;
case ALT_can__sff:
myleaf.body.node.nodes[1] = new RAW_enc_tree(TRUE, &myleaf, &myleaf.curr_pos, 1, General__Types::BIT11_descr_.raw);
encoded_length = field_can__sff->RAW_encode(General__Types::BIT11_descr_, *myleaf.body.node.nodes[1]);
myleaf.body.node.nodes[1]->coding_descr = &General__Types::BIT11_descr_;
break;
case ALT_can__rtr:
myleaf.body.node.nodes[2] = new RAW_enc_tree(TRUE, &myleaf, &myleaf.curr_pos, 2, RTR_descr_.raw);
encoded_length = field_can__rtr->RAW_encode(RTR_descr_, *myleaf.body.node.nodes[2]);
myleaf.body.node.nodes[2]->coding_descr = &RTR_descr_;
break;
case ALT_can__err:
myleaf.body.node.nodes[3] = new RAW_enc_tree(TRUE, &myleaf, &myleaf.curr_pos, 3, BIT29_descr_.raw);
encoded_length = field_can__err->RAW_encode(BIT29_descr_, *myleaf.body.node.nodes[3]);
myleaf.body.node.nodes[3]->coding_descr = &BIT29_descr_;
break;
default:
TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value.");
}
return encoded_length;
}
void Can__IDs_template::copy_value(const Can__IDs& other_value)
{
single_value.union_selection = other_value.get_selection();
switch (single_value.union_selection) {
case Can__IDs::ALT_can__eff:
single_value.field_can__eff = new BITSTRING_template(other_value.can__eff());
break;
case Can__IDs::ALT_can__sff:
single_value.field_can__sff = new BITSTRING_template(other_value.can__sff());
break;
case Can__IDs::ALT_can__rtr:
single_value.field_can__rtr = new RTR_template(other_value.can__rtr());
break;
case Can__IDs::ALT_can__err:
single_value.field_can__err = new BITSTRING_template(other_value.can__err());
break;
default:
TTCN_error("Initializing a template with an unbound value of type @Isobustest.Can_IDs.");
}
set_selection(SPECIFIC_VALUE);
}
void Can__IDs_template::copy_template(const Can__IDs_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value.union_selection = other_value.single_value.union_selection;
switch (single_value.union_selection) {
case Can__IDs::ALT_can__eff:
single_value.field_can__eff = new BITSTRING_template(*other_value.single_value.field_can__eff);
break;
case Can__IDs::ALT_can__sff:
single_value.field_can__sff = new BITSTRING_template(*other_value.single_value.field_can__sff);
break;
case Can__IDs::ALT_can__rtr:
single_value.field_can__rtr = new RTR_template(*other_value.single_value.field_can__rtr);
break;
case Can__IDs::ALT_can__err:
single_value.field_can__err = new BITSTRING_template(*other_value.single_value.field_can__err);
break;
default:
TTCN_error("Internal error: Invalid union selector in a specific value when copying a template of type @Isobustest.Can_IDs.");
}
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 Can__IDs_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 template of union type @Isobustest.Can_IDs.");
}
set_selection(other_value);
}
Can__IDs_template::Can__IDs_template()
{
}
Can__IDs_template::Can__IDs_template(template_sel other_value)
: Base_Template(other_value)
{
check_single_selection(other_value);
}
Can__IDs_template::Can__IDs_template(const Can__IDs& other_value)
{
copy_value(other_value);
}
Can__IDs_template::Can__IDs_template(const OPTIONAL<Can__IDs>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const Can__IDs&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of union type @Isobustest.Can_IDs from an unbound optional field.");
}
}
Can__IDs_template::Can__IDs_template(const Can__IDs_template& other_value)
: Base_Template(){
copy_template(other_value);
}
Can__IDs_template::~Can__IDs_template()
{
clean_up();
}
void Can__IDs_template::clean_up()
{
switch (template_selection) {
case SPECIFIC_VALUE:
switch (single_value.union_selection) {
case Can__IDs::ALT_can__eff:
delete single_value.field_can__eff;
break;
case Can__IDs::ALT_can__sff:
delete single_value.field_can__sff;
break;
case Can__IDs::ALT_can__rtr:
delete single_value.field_can__rtr;
break;
case Can__IDs::ALT_can__err:
delete single_value.field_can__err;
default:
break;
}
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
delete [] value_list.list_value;
default:
break;
}
template_selection = UNINITIALIZED_TEMPLATE;
}
Can__IDs_template& Can__IDs_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}
Can__IDs_template& Can__IDs_template::operator=(const Can__IDs& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}
Can__IDs_template& Can__IDs_template::operator=(const OPTIONAL<Can__IDs>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const Can__IDs&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Assignment of an unbound optional field to a template of union type @Isobustest.Can_IDs.");
}
return *this;
}
Can__IDs_template& Can__IDs_template::operator=(const Can__IDs_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}
boolean Can__IDs_template::match(const Can__IDs& 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:
{
Can__IDs::union_selection_type value_selection = other_value.get_selection();
if (value_selection == Can__IDs::UNBOUND_VALUE) return FALSE;
if (value_selection != single_value.union_selection) return FALSE;
switch (value_selection) {
case Can__IDs::ALT_can__eff:
return single_value.field_can__eff->match(other_value.can__eff(), legacy);
case Can__IDs::ALT_can__sff:
return single_value.field_can__sff->match(other_value.can__sff(), legacy);
case Can__IDs::ALT_can__rtr:
return single_value.field_can__rtr->match(other_value.can__rtr(), legacy);
case Can__IDs::ALT_can__err:
return single_value.field_can__err->match(other_value.can__err(), legacy);
default:
TTCN_error("Internal error: Invalid selector in a specific value when matching a template of union type @Isobustest.Can_IDs.");
}
}
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 template of union type @Isobustest.Can_IDs.");
}
return FALSE;
}
boolean Can__IDs_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
switch (single_value.union_selection) {
case Can__IDs::ALT_can__eff:
return single_value.field_can__eff->is_value();
case Can__IDs::ALT_can__sff:
return single_value.field_can__sff->is_value();
case Can__IDs::ALT_can__rtr:
return single_value.field_can__rtr->is_value();
case Can__IDs::ALT_can__err:
return single_value.field_can__err->is_value();
default:
TTCN_error("Internal error: Invalid selector in a specific value when performing is_value operation on a template of union type @Isobustest.Can_IDs.");
}
}
Can__IDs Can__IDs_template::valueof() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent)
TTCN_error("Performing a valueof or send operation on a non-specific template of union type @Isobustest.Can_IDs.");
Can__IDs ret_val;
switch (single_value.union_selection) {
case Can__IDs::ALT_can__eff:
ret_val.can__eff() = single_value.field_can__eff->valueof();
break;
case Can__IDs::ALT_can__sff:
ret_val.can__sff() = single_value.field_can__sff->valueof();
break;
case Can__IDs::ALT_can__rtr:
ret_val.can__rtr() = single_value.field_can__rtr->valueof();
break;
case Can__IDs::ALT_can__err:
ret_val.can__err() = single_value.field_can__err->valueof();
break;
default:
TTCN_error("Internal error: Invalid selector in a specific value when performing valueof operation on a template of union type @Isobustest.Can_IDs.");
}
return ret_val;
}
Can__IDs_template& Can__IDs_template::list_item(unsigned int list_index) const
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) TTCN_error("Internal error: Accessing a list element of a non-list template of union type @Isobustest.Can_IDs.");
if (list_index >= value_list.n_values) TTCN_error("Internal error: Index overflow in a value list template of union type @Isobustest.Can_IDs.");
return value_list.list_value[list_index];
}
void Can__IDs_template::set_type(template_sel template_type, unsigned int list_length)
{
if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST) TTCN_error ("Internal error: Setting an invalid list for a template of union type @Isobustest.Can_IDs.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new Can__IDs_template[list_length];
}
BITSTRING_template& Can__IDs_template::can__eff()
{
if (template_selection != SPECIFIC_VALUE || single_value.union_selection != Can__IDs::ALT_can__eff) {
template_sel old_selection = template_selection;
clean_up();
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_can__eff = new BITSTRING_template(ANY_VALUE);
else single_value.field_can__eff = new BITSTRING_template;
single_value.union_selection = Can__IDs::ALT_can__eff;
set_selection(SPECIFIC_VALUE);
}
return *single_value.field_can__eff;
}
const BITSTRING_template& Can__IDs_template::can__eff() const
{
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field can_eff in a non-specific template of union type @Isobustest.Can_IDs.");
if (single_value.union_selection != Can__IDs::ALT_can__eff) TTCN_error("Accessing non-selected field can_eff in a template of union type @Isobustest.Can_IDs.");
return *single_value.field_can__eff;
}
BITSTRING_template& Can__IDs_template::can__sff()
{
if (template_selection != SPECIFIC_VALUE || single_value.union_selection != Can__IDs::ALT_can__sff) {
template_sel old_selection = template_selection;
clean_up();
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_can__sff = new BITSTRING_template(ANY_VALUE);
else single_value.field_can__sff = new BITSTRING_template;
single_value.union_selection = Can__IDs::ALT_can__sff;
set_selection(SPECIFIC_VALUE);
}
return *single_value.field_can__sff;
}
const BITSTRING_template& Can__IDs_template::can__sff() const
{
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field can_sff in a non-specific template of union type @Isobustest.Can_IDs.");
if (single_value.union_selection != Can__IDs::ALT_can__sff) TTCN_error("Accessing non-selected field can_sff in a template of union type @Isobustest.Can_IDs.");
return *single_value.field_can__sff;
}
RTR_template& Can__IDs_template::can__rtr()
{
if (template_selection != SPECIFIC_VALUE || single_value.union_selection != Can__IDs::ALT_can__rtr) {
template_sel old_selection = template_selection;
clean_up();
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_can__rtr = new RTR_template(ANY_VALUE);
else single_value.field_can__rtr = new RTR_template;
single_value.union_selection = Can__IDs::ALT_can__rtr;
set_selection(SPECIFIC_VALUE);
}
return *single_value.field_can__rtr;
}
const RTR_template& Can__IDs_template::can__rtr() const
{
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field can_rtr in a non-specific template of union type @Isobustest.Can_IDs.");
if (single_value.union_selection != Can__IDs::ALT_can__rtr) TTCN_error("Accessing non-selected field can_rtr in a template of union type @Isobustest.Can_IDs.");
return *single_value.field_can__rtr;
}
BITSTRING_template& Can__IDs_template::can__err()
{
if (template_selection != SPECIFIC_VALUE || single_value.union_selection != Can__IDs::ALT_can__err) {
template_sel old_selection = template_selection;
clean_up();
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_can__err = new BITSTRING_template(ANY_VALUE);
else single_value.field_can__err = new BITSTRING_template;
single_value.union_selection = Can__IDs::ALT_can__err;
set_selection(SPECIFIC_VALUE);
}
return *single_value.field_can__err;
}
const BITSTRING_template& Can__IDs_template::can__err() const
{
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field can_err in a non-specific template of union type @Isobustest.Can_IDs.");
if (single_value.union_selection != Can__IDs::ALT_can__err) TTCN_error("Accessing non-selected field can_err in a template of union type @Isobustest.Can_IDs.");
return *single_value.field_can__err;
}
boolean Can__IDs_template::ischosen(Can__IDs::union_selection_type checked_selection) const
{
if (checked_selection == Can__IDs::UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type @Isobustest.Can_IDs.");
switch (template_selection) {
case SPECIFIC_VALUE:
if (single_value.union_selection == Can__IDs::UNBOUND_VALUE) TTCN_error("Internal error: Invalid selector in a specific value when performing ischosen() operation on a template of union type @Isobustest.Can_IDs.");
return single_value.union_selection == checked_selection;
case VALUE_LIST:
{
if (value_list.n_values < 1)
TTCN_error("Internal error: Performing ischosen() operation on a template of union type @Isobustest.Can_IDs containing an empty list.");
boolean ret_val = value_list.list_value[0].ischosen(checked_selection);
for (unsigned int list_count = 1; ret_val == TRUE && list_count < value_list.n_values; list_count++) {
ret_val = value_list.list_value[list_count].ischosen(checked_selection);
}
return ret_val;
}
default:
return FALSE;
}
return FALSE;
}
void Can__IDs_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
switch (single_value.union_selection) {
case Can__IDs::ALT_can__eff:
TTCN_Logger::log_event_str("{ can_eff := ");
single_value.field_can__eff->log();
TTCN_Logger::log_event_str(" }");
break;
case Can__IDs::ALT_can__sff:
TTCN_Logger::log_event_str("{ can_sff := ");
single_value.field_can__sff->log();
TTCN_Logger::log_event_str(" }");
break;
case Can__IDs::ALT_can__rtr:
TTCN_Logger::log_event_str("{ can_rtr := ");
single_value.field_can__rtr->log();
TTCN_Logger::log_event_str(" }");
break;
case Can__IDs::ALT_can__err:
TTCN_Logger::log_event_str("{ can_err := ");
single_value.field_can__err->log();
TTCN_Logger::log_event_str(" }");
break;
default:
TTCN_Logger::log_event_str("<invalid selector>");
}
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 Can__IDs_template::log_match(const Can__IDs& match_value, boolean legacy) const
{
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity() && match(match_value, legacy)){
TTCN_Logger::print_logmatch_buffer();
TTCN_Logger::log_event_str(" matched");
return;
}
if (template_selection == SPECIFIC_VALUE && single_value.union_selection == match_value.get_selection()) {
switch (single_value.union_selection) {
case Can__IDs::ALT_can__eff:
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
TTCN_Logger::log_logmatch_info(".can_eff");
single_value.field_can__eff->log_match(match_value.can__eff(), legacy);
} else {
TTCN_Logger::log_event_str("{ can_eff := ");
single_value.field_can__eff->log_match(match_value.can__eff(), legacy);
TTCN_Logger::log_event_str(" }");
}
break;
case Can__IDs::ALT_can__sff:
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
TTCN_Logger::log_logmatch_info(".can_sff");
single_value.field_can__sff->log_match(match_value.can__sff(), legacy);
} else {
TTCN_Logger::log_event_str("{ can_sff := ");
single_value.field_can__sff->log_match(match_value.can__sff(), legacy);
TTCN_Logger::log_event_str(" }");
}
break;
case Can__IDs::ALT_can__rtr:
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
TTCN_Logger::log_logmatch_info(".can_rtr");
single_value.field_can__rtr->log_match(match_value.can__rtr(), legacy);
} else {
TTCN_Logger::log_event_str("{ can_rtr := ");
single_value.field_can__rtr->log_match(match_value.can__rtr(), legacy);
TTCN_Logger::log_event_str(" }");
}
break;
case Can__IDs::ALT_can__err:
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
TTCN_Logger::log_logmatch_info(".can_err");
single_value.field_can__err->log_match(match_value.can__err(), legacy);
} else {
TTCN_Logger::log_event_str("{ can_err := ");
single_value.field_can__err->log_match(match_value.can__err(), legacy);
TTCN_Logger::log_event_str(" }");
}
break;
default:
TTCN_Logger::print_logmatch_buffer();
TTCN_Logger::log_event_str("<invalid selector>");
}
} else {
TTCN_Logger::print_logmatch_buffer();
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 Can__IDs_template::encode_text(Text_Buf& text_buf) const
{
encode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
text_buf.push_int(single_value.union_selection);
switch (single_value.union_selection) {
case Can__IDs::ALT_can__eff:
single_value.field_can__eff->encode_text(text_buf);
break;
case Can__IDs::ALT_can__sff:
single_value.field_can__sff->encode_text(text_buf);
break;
case Can__IDs::ALT_can__rtr:
single_value.field_can__rtr->encode_text(text_buf);
break;
case Can__IDs::ALT_can__err:
single_value.field_can__err->encode_text(text_buf);
break;
default:
TTCN_error("Internal error: Invalid selector in a specific value when encoding a template of union type @Isobustest.Can_IDs.");
}
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 template of type @Isobustest.Can_IDs.");
}
}
void Can__IDs_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
{
single_value.union_selection = Can__IDs::UNBOUND_VALUE;
Can__IDs::union_selection_type new_selection = (Can__IDs::union_selection_type)text_buf.pull_int().get_val();
switch (new_selection) {
case Can__IDs::ALT_can__eff:
single_value.field_can__eff = new BITSTRING_template;
single_value.field_can__eff->decode_text(text_buf);
break;
case Can__IDs::ALT_can__sff:
single_value.field_can__sff = new BITSTRING_template;
single_value.field_can__sff->decode_text(text_buf);
break;
case Can__IDs::ALT_can__rtr:
single_value.field_can__rtr = new RTR_template;
single_value.field_can__rtr->decode_text(text_buf);
break;
case Can__IDs::ALT_can__err:
single_value.field_can__err = new BITSTRING_template;
single_value.field_can__err->decode_text(text_buf);
break;
default:
TTCN_error("Text decoder: Unrecognized union selector was received for a template of type @Isobustest.Can_IDs.");
}
single_value.union_selection = new_selection;
}
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 Can__IDs_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: Unrecognized selector was received in a template of type @Isobustest.Can_IDs.");
}
}
boolean Can__IDs_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}
boolean Can__IDs_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 v_idx=0; v_idx<value_list.n_values; v_idx++)
if (value_list.list_value[v_idx].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}
void Can__IDs_template::set_param(Module_Param& param)
{
if (dynamic_cast<Module_Param_Name*>(param.get_id()) != NULL &&
param.get_id()->next_name()) {
char* param_field = param.get_id()->get_current_name();
if (param_field[0] >= '0' && param_field[0] <= '9') {
param.error("Unexpected array index in module parameter, expected a valid field"
" name for union template type `@Isobustest.Can_IDs'");
}
if (strcmp("can_eff", param_field) == 0) {
can__eff().set_param(param);
return;
} else if (strcmp("can_sff", param_field) == 0) {
can__sff().set_param(param);
return;
} else if (strcmp("can_rtr", param_field) == 0) {
can__rtr().set_param(param);
return;
} else if (strcmp("can_err", param_field) == 0) {
can__err().set_param(param);
return;
} else param.error("Field `%s' not found in union template type `@Isobustest.Can_IDs'", param_field);
}
param.basic_check(Module_Param::BC_TEMPLATE, "union template");
Module_Param_Ptr m_p = &param;
switch (m_p->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: {
Can__IDs_template new_temp;
new_temp.set_type(m_p->get_type()==Module_Param::MP_List_Template ? VALUE_LIST : COMPLEMENTED_LIST, m_p->get_size());
for (size_t p_i=0; p_i<m_p->get_size(); p_i++) {
new_temp.list_item(p_i).set_param(*m_p->get_elem(p_i));
}
*this = new_temp;
break; }
case Module_Param::MP_Value_List:
if (m_p->get_size()==0) break;
param.type_error("union template", "@Isobustest.Can_IDs");
break;
case Module_Param::MP_Assignment_List: {
Module_Param* mp_last = m_p->get_elem(m_p->get_size()-1);
char* last_name = mp_last->get_id()->get_name();
if (!strcmp(last_name, "can_eff")) {
can__eff().set_param(*mp_last);
break;
}
if (!strcmp(last_name, "can_sff")) {
can__sff().set_param(*mp_last);
break;
}
if (!strcmp(last_name, "can_rtr")) {
can__rtr().set_param(*mp_last);
break;
}
if (!strcmp(last_name, "can_err")) {
can__err().set_param(*mp_last);
break;
}
mp_last->error("Field %s does not exist in type @Isobustest.Can_IDs.", last_name);
} break;
default:
param.type_error("union template", "@Isobustest.Can_IDs");
}
is_ifpresent = param.get_ifpresent();
}
void Can__IDs_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;
switch (single_value.union_selection) {
case Can__IDs::ALT_can__eff:
single_value.field_can__eff->check_restriction(t_res, t_name ? t_name : "@Isobustest.Can_IDs");
return;
case Can__IDs::ALT_can__sff:
single_value.field_can__sff->check_restriction(t_res, t_name ? t_name : "@Isobustest.Can_IDs");
return;
case Can__IDs::ALT_can__rtr:
single_value.field_can__rtr->check_restriction(t_res, t_name ? t_name : "@Isobustest.Can_IDs");
return;
case Can__IDs::ALT_can__err:
single_value.field_can__err->check_restriction(t_res, t_name ? t_name : "@Isobustest.Can_IDs");
return;
default:
TTCN_error("Internal error: Invalid selector in a specific value when performing check_restriction operation on a template of union type @Isobustest.Can_IDs.");
}
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 : "@Isobustest.Can_IDs");
}
Can__IDwithType::Can__IDwithType()
{
}
Can__IDwithType::Can__IDwithType(const INTEGER& par_cantype,
const Can__IDs& par_can__ids)
: field_cantype(par_cantype),
field_can__ids(par_can__ids)
{
}
Can__IDwithType::Can__IDwithType(const Can__IDwithType& other_value)
{
if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @Isobustest.Can_IDwithType.");
if (other_value.cantype().is_bound()) field_cantype = other_value.cantype();
else field_cantype.clean_up();
if (other_value.can__ids().is_bound()) field_can__ids = other_value.can__ids();
else field_can__ids.clean_up();
}
void Can__IDwithType::clean_up()
{
field_cantype.clean_up();
field_can__ids.clean_up();
}
const TTCN_Typedescriptor_t* Can__IDwithType::get_descriptor() const { return &Can__IDwithType_descr_; }
Can__IDwithType& Can__IDwithType::operator=(const Can__IDwithType& other_value)
{
if (this != &other_value) {
if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @Isobustest.Can_IDwithType.");
if (other_value.cantype().is_bound()) field_cantype = other_value.cantype();
else field_cantype.clean_up();
if (other_value.can__ids().is_bound()) field_can__ids = other_value.can__ids();
else field_can__ids.clean_up();
}
return *this;
}
boolean Can__IDwithType::operator==(const Can__IDwithType& other_value) const
{
return field_cantype==other_value.field_cantype
&& field_can__ids==other_value.field_can__ids;
}
boolean Can__IDwithType::is_bound() const
{
return (field_cantype.is_bound())
|| (field_can__ids.is_bound());
}
boolean Can__IDwithType::is_value() const
{
return field_cantype.is_value()
&& field_can__ids.is_value();
}
void Can__IDwithType::log() const
{
if (!is_bound()) {
TTCN_Logger::log_event_unbound();
return;
}
TTCN_Logger::log_event_str("{ cantype := ");
field_cantype.log();
TTCN_Logger::log_event_str(", can_ids := ");
field_can__ids.log();
TTCN_Logger::log_event_str(" }");
}
void Can__IDwithType::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 (2<param.get_size()) {
param.error("record value of type @Isobustest.Can_IDwithType has 2 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) cantype().set_param(*param.get_elem(0));
if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) can__ids().set_param(*param.get_elem(1));
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(), "cantype")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
cantype().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(), "can_ids")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
can__ids().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 @Isobustest.Can_IDwithType: %s", curr_param->get_id()->get_name());
break;
}
} break;
default:
param.type_error("record value", "@Isobustest.Can_IDwithType");
}
}
void Can__IDwithType::set_implicit_omit()
{
if (cantype().is_bound()) cantype().set_implicit_omit();
if (can__ids().is_bound()) can__ids().set_implicit_omit();
}
void Can__IDwithType::encode_text(Text_Buf& text_buf) const
{
field_cantype.encode_text(text_buf);
field_can__ids.encode_text(text_buf);
}
void Can__IDwithType::decode_text(Text_Buf& text_buf)
{
field_cantype.decode_text(text_buf);
field_can__ids.decode_text(text_buf);
}
void Can__IDwithType::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 Can__IDwithType::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 Can__IDwithType::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;
int selected_field = -1;
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, General__Types::INT1_descr_.raw->forceomit);
decoded_field_length = field_cantype.RAW_decode(General__Types::INT1_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());
if (field_cantype == 4) selected_field = 0;
else if (field_cantype == 2) selected_field = 2;
else if (field_cantype == 1) selected_field = 3;
else if (field_cantype == 0) selected_field = 1;
else selected_field = -1;
RAW_Force_Omit field_1_force_omit(1, force_omit, Can__IDwithType_can__ids_descr_.raw->forceomit);
decoded_field_length = field_can__ids.RAW_decode(Can__IDwithType_can__ids_descr_, p_buf, limit, local_top_order, no_err, selected_field, 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());
p_buf.set_pos_bit(last_decoded_pos);
return decoded_length+prepaddlength+p_buf.increase_pos_padd(p_td.raw->padding);
}
int Can__IDwithType::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 = 2;
myleaf.body.node.nodes = init_nodes_of_enc_tree(2);
myleaf.body.node.nodes[0] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 0, General__Types::INT1_descr_.raw);
myleaf.body.node.nodes[1] = new RAW_enc_tree(TRUE, &myleaf, &(myleaf.curr_pos), 1, Can__IDwithType_can__ids_descr_.raw);
encoded_length += field_cantype.RAW_encode(General__Types::INT1_descr_, *myleaf.body.node.nodes[0]);
encoded_length += field_can__ids.RAW_encode(Can__IDwithType_can__ids_descr_, *myleaf.body.node.nodes[1]);
switch (field_can__ids.get_selection()) {
case Can__IDs::ALT_can__eff:
if (field_cantype != 4) {
RAW_enc_tr_pos pr_pos;
pr_pos.level = myleaf.curr_pos.level + 1;
int new_pos[] = { 0 };
pr_pos.pos = init_new_tree_pos(myleaf.curr_pos, 1, new_pos);
INTEGER new_val(4);
RAW_enc_tree* temp_leaf = myleaf.get_node(pr_pos);
if (temp_leaf != NULL)
new_val.RAW_encode(General__Types::INT1_descr_,*temp_leaf);
else
TTCN_EncDec_ErrorContext::error
(TTCN_EncDec::ET_OMITTED_TAG, "Encoding a tagged, but omitted value.");
free_tree_pos(pr_pos.pos);
}
break;
case Can__IDs::ALT_can__rtr:
if (field_cantype != 2) {
RAW_enc_tr_pos pr_pos;
pr_pos.level = myleaf.curr_pos.level + 1;
int new_pos[] = { 0 };
pr_pos.pos = init_new_tree_pos(myleaf.curr_pos, 1, new_pos);
INTEGER new_val(2);
RAW_enc_tree* temp_leaf = myleaf.get_node(pr_pos);
if (temp_leaf != NULL)
new_val.RAW_encode(General__Types::INT1_descr_,*temp_leaf);
else
TTCN_EncDec_ErrorContext::error
(TTCN_EncDec::ET_OMITTED_TAG, "Encoding a tagged, but omitted value.");
free_tree_pos(pr_pos.pos);
}
break;
case Can__IDs::ALT_can__err:
if (field_cantype != 1) {
RAW_enc_tr_pos pr_pos;
pr_pos.level = myleaf.curr_pos.level + 1;
int new_pos[] = { 0 };
pr_pos.pos = init_new_tree_pos(myleaf.curr_pos, 1, new_pos);
INTEGER new_val(1);
RAW_enc_tree* temp_leaf = myleaf.get_node(pr_pos);
if (temp_leaf != NULL)
new_val.RAW_encode(General__Types::INT1_descr_,*temp_leaf);
else
TTCN_EncDec_ErrorContext::error
(TTCN_EncDec::ET_OMITTED_TAG, "Encoding a tagged, but omitted value.");
free_tree_pos(pr_pos.pos);
}
break;
case Can__IDs::ALT_can__sff:
if (field_cantype != 0) {
RAW_enc_tr_pos pr_pos;
pr_pos.level = myleaf.curr_pos.level + 1;
int new_pos[] = { 0 };
pr_pos.pos = init_new_tree_pos(myleaf.curr_pos, 1, new_pos);
INTEGER new_val(0);
RAW_enc_tree* temp_leaf = myleaf.get_node(pr_pos);
if (temp_leaf != NULL)
new_val.RAW_encode(General__Types::INT1_descr_,*temp_leaf);
else
TTCN_EncDec_ErrorContext::error
(TTCN_EncDec::ET_OMITTED_TAG, "Encoding a tagged, but omitted value.");
free_tree_pos(pr_pos.pos);
}
break;
default:;
}
return myleaf.length = encoded_length;
}
struct Can__IDwithType_template::single_value_struct {
INTEGER_template field_cantype;
Can__IDs_template field_can__ids;
};
void Can__IDwithType_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_cantype = ANY_VALUE;
single_value->field_can__ids = ANY_VALUE;
}
}
}
void Can__IDwithType_template::copy_value(const Can__IDwithType& other_value)
{
single_value = new single_value_struct;
if (other_value.cantype().is_bound()) {
single_value->field_cantype = other_value.cantype();
} else {
single_value->field_cantype.clean_up();
}
if (other_value.can__ids().is_bound()) {
single_value->field_can__ids = other_value.can__ids();
} else {
single_value->field_can__ids.clean_up();
}
set_selection(SPECIFIC_VALUE);
}
void Can__IDwithType_template::copy_template(const Can__IDwithType_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
if (UNINITIALIZED_TEMPLATE != other_value.cantype().get_selection()) {
single_value->field_cantype = other_value.cantype();
} else {
single_value->field_cantype.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.can__ids().get_selection()) {
single_value->field_can__ids = other_value.can__ids();
} else {
single_value->field_can__ids.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 Can__IDwithType_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 @Isobustest.Can_IDwithType.");
break;
}
set_selection(other_value);
}
Can__IDwithType_template::Can__IDwithType_template()
{
}
Can__IDwithType_template::Can__IDwithType_template(template_sel other_value)
: Base_Template(other_value)
{
check_single_selection(other_value);
}
Can__IDwithType_template::Can__IDwithType_template(const Can__IDwithType& other_value)
{
copy_value(other_value);
}
Can__IDwithType_template::Can__IDwithType_template(const OPTIONAL<Can__IDwithType>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const Can__IDwithType&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @Isobustest.Can_IDwithType from an unbound optional field.");
}
}
Can__IDwithType_template::Can__IDwithType_template(const Can__IDwithType_template& other_value)
: Base_Template()
{
copy_template(other_value);
}
Can__IDwithType_template::~Can__IDwithType_template()
{
clean_up();
}
Can__IDwithType_template& Can__IDwithType_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}
Can__IDwithType_template& Can__IDwithType_template::operator=(const Can__IDwithType& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}
Can__IDwithType_template& Can__IDwithType_template::operator=(const OPTIONAL<Can__IDwithType>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const Can__IDwithType&)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 @Isobustest.Can_IDwithType.");
}
return *this;
}
Can__IDwithType_template& Can__IDwithType_template::operator=(const Can__IDwithType_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}
boolean Can__IDwithType_template::match(const Can__IDwithType& 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.cantype().is_bound()) return FALSE;
if(!single_value->field_cantype.match(other_value.cantype(), legacy))return FALSE;
if(!other_value.can__ids().is_bound()) return FALSE;
if(!single_value->field_can__ids.match(other_value.can__ids(), 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 @Isobustest.Can_IDwithType.");
}
return FALSE;
}
boolean Can__IDwithType_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
if (template_selection != SPECIFIC_VALUE) return TRUE;
return single_value->field_cantype.is_bound()
||single_value->field_can__ids.is_bound()
;
}
boolean Can__IDwithType_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value->field_cantype.is_value()
&&single_value->field_can__ids.is_value();
}
void Can__IDwithType_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;
}
Can__IDwithType Can__IDwithType_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 @Isobustest.Can_IDwithType.");
Can__IDwithType ret_val;
if (single_value->field_cantype.is_bound()) {
ret_val.cantype() = single_value->field_cantype.valueof();
}
if (single_value->field_can__ids.is_bound()) {
ret_val.can__ids() = single_value->field_can__ids.valueof();
}
return ret_val;
}
void Can__IDwithType_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 @Isobustest.Can_IDwithType.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new Can__IDwithType_template[list_length];
}
Can__IDwithType_template& Can__IDwithType_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 @Isobustest.Can_IDwithType.");
if (list_index >= value_list.n_values)
TTCN_error("Index overflow in a value list template of type @Isobustest.Can_IDwithType.");
return value_list.list_value[list_index];
}
INTEGER_template& Can__IDwithType_template::cantype()
{
set_specific();
return single_value->field_cantype;
}
const INTEGER_template& Can__IDwithType_template::cantype() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field cantype of a non-specific template of type @Isobustest.Can_IDwithType.");
return single_value->field_cantype;
}
Can__IDs_template& Can__IDwithType_template::can__ids()
{
set_specific();
return single_value->field_can__ids;
}
const Can__IDs_template& Can__IDwithType_template::can__ids() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field can_ids of a non-specific template of type @Isobustest.Can_IDwithType.");
return single_value->field_can__ids;
}
int Can__IDwithType_template::size_of() const
{
if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @Isobustest.Can_IDwithType which has an ifpresent attribute.");
switch (template_selection)
{
case SPECIFIC_VALUE:
return 2;
case VALUE_LIST:
{
if (value_list.n_values<1)
TTCN_error("Internal error: Performing sizeof() operation on a template of type @Isobustest.Can_IDwithType 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 @Isobustest.Can_IDwithType containing a value list with different sizes.");
}
return item_size;
}
case OMIT_VALUE:
TTCN_error("Performing sizeof() operation on a template of type @Isobustest.Can_IDwithType containing omit value.");
case ANY_VALUE:
case ANY_OR_OMIT:
TTCN_error("Performing sizeof() operation on a template of type @Isobustest.Can_IDwithType containing */? value.");
case COMPLEMENTED_LIST:
TTCN_error("Performing sizeof() operation on a template of type @Isobustest.Can_IDwithType containing complemented list.");
default:
TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @Isobustest.Can_IDwithType.");
}
return 0;
}
void Can__IDwithType_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_str("{ cantype := ");
single_value->field_cantype.log();
TTCN_Logger::log_event_str(", can_ids := ");
single_value->field_can__ids.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 Can__IDwithType_template::log_match(const Can__IDwithType& 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_cantype.match(match_value.cantype(), legacy)){
TTCN_Logger::log_logmatch_info(".cantype");
single_value->field_cantype.log_match(match_value.cantype(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_can__ids.match(match_value.can__ids(), legacy)){
TTCN_Logger::log_logmatch_info(".can_ids");
single_value->field_can__ids.log_match(match_value.can__ids(), 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("{ cantype := ");
single_value->field_cantype.log_match(match_value.cantype(), legacy);
TTCN_Logger::log_event_str(", can_ids := ");
single_value->field_can__ids.log_match(match_value.can__ids(), 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 Can__IDwithType_template::encode_text(Text_Buf& text_buf) const
{
encode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value->field_cantype.encode_text(text_buf);
single_value->field_can__ids.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 @Isobustest.Can_IDwithType.");
}
}
void Can__IDwithType_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_cantype.decode_text(text_buf);
single_value->field_can__ids.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 Can__IDwithType_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 @Isobustest.Can_IDwithType.");
}
}
void Can__IDwithType_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: {
Can__IDwithType_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 (2<param.get_size()) {
param.error("record template of type @Isobustest.Can_IDwithType has 2 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) cantype().set_param(*param.get_elem(0));
if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) can__ids().set_param(*param.get_elem(1));
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(), "cantype")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
cantype().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(), "can_ids")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
can__ids().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 @Isobustest.Can_IDwithType: %s", curr_param->get_id()->get_name());
break;
}
} break;
default:
param.type_error("record template", "@Isobustest.Can_IDwithType");
}
is_ifpresent = param.get_ifpresent();
}
void Can__IDwithType_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_cantype.check_restriction(t_res, t_name ? t_name : "@Isobustest.Can_IDwithType");
single_value->field_can__ids.check_restriction(t_res, t_name ? t_name : "@Isobustest.Can_IDwithType");
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 : "@Isobustest.Can_IDwithType");
}
boolean Can__IDwithType_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}
boolean Can__IDwithType_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;
}
const COMPONENT OpenConnections::UNBOUND_ELEM;
OpenConnections::OpenConnections()
{
val_ptr = NULL;
}
OpenConnections::OpenConnections(null_type)
{
val_ptr = new recordof_setof_struct;
val_ptr->ref_count = 1;
val_ptr->n_elements = 0;
val_ptr->value_elements = NULL;
}
OpenConnections::OpenConnections(const OpenConnections& other_value)
{
if (!other_value.is_bound()) TTCN_error("Copying an unbound value of type @Isobustest.OpenConnections.");
val_ptr = other_value.val_ptr;
val_ptr->ref_count++;
}
OpenConnections::~OpenConnections()
{
clean_up();
if (val_ptr != NULL) val_ptr = NULL;
}
void OpenConnections::clean_up()
{
if (val_ptr != NULL) {
if (val_ptr->ref_count > 1) {
val_ptr->ref_count--;
val_ptr = NULL;
}
else if (val_ptr->ref_count == 1) {
for (int elem_count = 0; elem_count < val_ptr->n_elements;
elem_count++)
if (val_ptr->value_elements[elem_count] != NULL)
delete val_ptr->value_elements[elem_count];
free_pointers((void**)val_ptr->value_elements);
delete val_ptr;
val_ptr = NULL;
}
else
TTCN_error("Internal error: Invalid reference counter in a record of/set of value.");
}
}
OpenConnections& OpenConnections::operator=(null_type)
{
clean_up();
val_ptr = new recordof_setof_struct;
val_ptr->ref_count = 1;
val_ptr->n_elements = 0;
val_ptr->value_elements = NULL;
return *this;
}
OpenConnections& OpenConnections::operator=(const OpenConnections& other_value)
{
if (other_value.val_ptr == NULL) TTCN_error("Assigning an unbound value of type @Isobustest.OpenConnections.");
if (this != &other_value) {
clean_up();
val_ptr = other_value.val_ptr;
val_ptr->ref_count++;
}
return *this;
}
boolean OpenConnections::operator==(null_type) const
{
if (val_ptr == NULL)
TTCN_error("The left operand of comparison is an unbound value of type @Isobustest.OpenConnections.");
return val_ptr->n_elements == 0 ;
}
boolean OpenConnections::operator==(const OpenConnections& other_value) const
{
if (val_ptr == NULL) TTCN_error("The left operand of comparison is an unbound value of type @Isobustest.OpenConnections.");
if (other_value.val_ptr == NULL) TTCN_error("The right operand of comparison is an unbound value of type @Isobustest.OpenConnections.");
if (val_ptr == other_value.val_ptr) return TRUE;
if (val_ptr->n_elements != (other_value.val_ptr)->n_elements)
return FALSE;
for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++){
if (val_ptr->value_elements[elem_count] != NULL){
if ((other_value.val_ptr)->value_elements[elem_count] != NULL){
if (*val_ptr->value_elements[elem_count] != *(other_value.val_ptr)->value_elements[elem_count]) return FALSE;
} else return FALSE;
} else {
if ((other_value.val_ptr)->value_elements[elem_count] != NULL) return FALSE;
}
}
return TRUE;
}
COMPONENT& OpenConnections::operator[](int index_value)
{
if (index_value < 0) TTCN_error("Accessing an element of type @Isobustest.OpenConnections using a negative index: %d.", index_value);
if (val_ptr == NULL) {
val_ptr = new recordof_setof_struct;
val_ptr->ref_count = 1;
val_ptr->n_elements = 0;
val_ptr->value_elements = NULL;
} else if (val_ptr->ref_count > 1) {
struct recordof_setof_struct *new_val_ptr = new recordof_setof_struct;
new_val_ptr->ref_count = 1;
new_val_ptr->n_elements = (index_value >= val_ptr->n_elements) ? index_value + 1 : val_ptr->n_elements;
new_val_ptr->value_elements = (COMPONENT**)allocate_pointers(new_val_ptr->n_elements);
for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++){
if (val_ptr->value_elements[elem_count] != NULL){
new_val_ptr->value_elements[elem_count] = new COMPONENT(*(val_ptr->value_elements[elem_count]));
}
}
clean_up();
val_ptr = new_val_ptr;
}
if (index_value >= val_ptr->n_elements) set_size(index_value + 1);
if (val_ptr->value_elements[index_value] == NULL) {
val_ptr->value_elements[index_value] = new COMPONENT;
}
return *val_ptr->value_elements[index_value];
}
COMPONENT& OpenConnections::operator[](const INTEGER& index_value)
{
index_value.must_bound("Using an unbound integer value for indexing a value of type @Isobustest.OpenConnections.");
return (*this)[(int)index_value];
}
const COMPONENT& OpenConnections::operator[](int index_value) const
{
if (val_ptr == NULL)
TTCN_error("Accessing an element in an unbound value of type @Isobustest.OpenConnections.");
if (index_value < 0) TTCN_error("Accessing an element of type @Isobustest.OpenConnections using a negative index: %d.", index_value);
if (index_value >= val_ptr->n_elements) TTCN_error("Index overflow in a value of type @Isobustest.OpenConnections: The index is %d, but the value has only %d elements.", index_value, val_ptr->n_elements);
return (val_ptr->value_elements[index_value] == NULL) ?
UNBOUND_ELEM : *val_ptr->value_elements[index_value];
}
const COMPONENT& OpenConnections::operator[](const INTEGER& index_value) const
{
index_value.must_bound("Using an unbound integer value for indexing a value of type @Isobustest.OpenConnections.");
return (*this)[(int)index_value];
}
OpenConnections OpenConnections::operator<<=(int rotate_count) const
{
return *this >>= (-rotate_count);
}
OpenConnections OpenConnections::operator<<=(const INTEGER& rotate_count) const
{
rotate_count.must_bound("Unbound integer operand of rotate left operator.");
return *this >>= (int)(-rotate_count);
}
OpenConnections OpenConnections::operator>>=(const INTEGER& rotate_count) const
{
rotate_count.must_bound("Unbound integer operand of rotate right operator.");
return *this >>= (int)rotate_count;
}
OpenConnections OpenConnections::operator>>=(int rotate_count) const
{
if (val_ptr == NULL) TTCN_error("Performing rotation operation on an unbound value of type @Isobustest.OpenConnections.");
if (val_ptr->n_elements == 0) return *this;
int rc;
if (rotate_count>=0) rc = rotate_count % val_ptr->n_elements;
else rc = val_ptr->n_elements - ((-rotate_count) % val_ptr->n_elements);
if (rc == 0) return *this;
OpenConnections ret_val;
ret_val.set_size(val_ptr->n_elements);
for (int i=0; i<val_ptr->n_elements; i++) {
if (val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[(i+rc)%val_ptr->n_elements] =new COMPONENT(*val_ptr->value_elements[i]);
}
}
return ret_val;
}
OpenConnections OpenConnections::operator+(const OpenConnections& other_value) const
{
if (val_ptr == NULL || other_value.val_ptr == NULL) TTCN_error("Unbound operand of @Isobustest.OpenConnections concatenation.");
if (val_ptr->n_elements == 0) return other_value;
if (other_value.val_ptr->n_elements == 0) return *this;
OpenConnections ret_val;
ret_val.set_size(val_ptr->n_elements+other_value.val_ptr->n_elements);
for (int i=0; i<val_ptr->n_elements; i++) {
if (val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[i] = new COMPONENT(*val_ptr->value_elements[i]);
}
}
for (int i=0; i<other_value.val_ptr->n_elements; i++) {
if (other_value.val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[i+val_ptr->n_elements] = new COMPONENT(*other_value.val_ptr->value_elements[i]);
}
}
return ret_val;
}
OpenConnections OpenConnections::substr(int index, int returncount) const
{
if (val_ptr == NULL) TTCN_error("The first argument of substr() is an unbound value of type @Isobustest.OpenConnections.");
check_substr_arguments(val_ptr->n_elements, index, returncount, "@Isobustest.OpenConnections","element");
OpenConnections ret_val;
ret_val.set_size(returncount);
for (int i=0; i<returncount; i++) {
if (val_ptr->value_elements[i+index] != NULL) {
ret_val.val_ptr->value_elements[i] = new COMPONENT(*val_ptr->value_elements[i+index]);
}
}
return ret_val;
}
OpenConnections OpenConnections::replace(int index, int len, const OpenConnections& repl) const
{
if (val_ptr == NULL) TTCN_error("The first argument of replace() is an unbound value of type @Isobustest.OpenConnections.");
if (repl.val_ptr == NULL) TTCN_error("The fourth argument of replace() is an unbound value of type @Isobustest.OpenConnections.");
check_replace_arguments(val_ptr->n_elements, index, len, "@Isobustest.OpenConnections","element");
OpenConnections ret_val;
ret_val.set_size(val_ptr->n_elements + repl.val_ptr->n_elements - len);
for (int i = 0; i < index; i++) {
if (val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[i] = new COMPONENT(*val_ptr->value_elements[i]);
}
}
for (int i = 0; i < repl.val_ptr->n_elements; i++) {
if (repl.val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[i+index] = new COMPONENT(*repl.val_ptr->value_elements[i]);
}
}
for (int i = 0; i < val_ptr->n_elements - index - len; i++) {
if (val_ptr->value_elements[index+i+len] != NULL) {
ret_val.val_ptr->value_elements[index+i+repl.val_ptr->n_elements] = new COMPONENT(*val_ptr->value_elements[index+i+len]);
}
}
return ret_val;
}
OpenConnections OpenConnections::replace(int index, int len, const OpenConnections_template& repl) const
{
if (!repl.is_value()) TTCN_error("The fourth argument of function replace() is a template with non-specific value.");
return replace(index, len, repl.valueof());
}
void OpenConnections::set_size(int new_size)
{
if (new_size < 0) TTCN_error("Internal error: Setting a negative size for a value of type @Isobustest.OpenConnections.");
if (val_ptr == NULL) {
val_ptr = new recordof_setof_struct;
val_ptr->ref_count = 1;
val_ptr->n_elements = 0;
val_ptr->value_elements = NULL;
} else if (val_ptr->ref_count > 1) {
struct recordof_setof_struct *new_val_ptr = new recordof_setof_struct;
new_val_ptr->ref_count = 1;
new_val_ptr->n_elements = (new_size < val_ptr->n_elements) ? new_size : val_ptr->n_elements;
new_val_ptr->value_elements = (COMPONENT**)allocate_pointers(new_val_ptr->n_elements);
for (int elem_count = 0; elem_count < new_val_ptr->n_elements; elem_count++) {
if (val_ptr->value_elements[elem_count] != NULL){
new_val_ptr->value_elements[elem_count] = new COMPONENT(*(val_ptr->value_elements[elem_count]));
}
}
clean_up();
val_ptr = new_val_ptr;
}
if (new_size > val_ptr->n_elements) {
val_ptr->value_elements = (COMPONENT**)reallocate_pointers((void**)val_ptr->value_elements, val_ptr->n_elements, new_size);
#ifdef TITAN_MEMORY_DEBUG_SET_RECORD_OF
if((val_ptr->n_elements/1000)!=(new_size/1000)) TTCN_warning("New size of type @Isobustest.OpenConnections: %d",new_size);
#endif
val_ptr->n_elements = new_size;
} else if (new_size < val_ptr->n_elements) {
for (int elem_count = new_size; elem_count < val_ptr->n_elements; elem_count++)
if (val_ptr->value_elements[elem_count] != NULL)delete val_ptr->value_elements[elem_count];
val_ptr->value_elements = (COMPONENT**)reallocate_pointers((void**)val_ptr->value_elements, val_ptr->n_elements, new_size);
val_ptr->n_elements = new_size;
}
}
boolean OpenConnections::is_value() const
{
if (val_ptr == NULL) return FALSE;
for(int i = 0; i < val_ptr->n_elements; ++i) {
if (val_ptr->value_elements[i] == NULL || !val_ptr->value_elements[i]->is_value()) return FALSE;
}
return TRUE;
}
int OpenConnections::size_of() const
{
if (val_ptr == NULL) TTCN_error("Performing sizeof operation on an unbound value of type @Isobustest.OpenConnections.");
return val_ptr->n_elements;
}
int OpenConnections::lengthof() const
{
if (val_ptr == NULL) TTCN_error("Performing lengthof operation on an unbound value of type @Isobustest.OpenConnections.");
for (int my_length=val_ptr->n_elements; my_length>0; my_length--) if (val_ptr->value_elements[my_length-1] != NULL) return my_length;
return 0;
}
void OpenConnections::log() const
{
if (val_ptr == NULL) {;
TTCN_Logger::log_event_unbound();
return;
}
switch (val_ptr->n_elements) {
case 0:
TTCN_Logger::log_event_str("{ }");
break;
default:
TTCN_Logger::log_event_str("{ ");
for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++) {
if (elem_count > 0) TTCN_Logger::log_event_str(", ");
(*this)[elem_count].log();
}
TTCN_Logger::log_event_str(" }");
}
}
void OpenConnections::set_param(Module_Param& param)
{
param.basic_check(Module_Param::BC_VALUE|Module_Param::BC_LIST, "record of value");
switch (param.get_operation_type()) {
case Module_Param::OT_ASSIGN:
if (param.get_type()==Module_Param::MP_Value_List && param.get_size()==0) {
*this = NULL_VALUE;
return;
}
switch (param.get_type()) {
case Module_Param::MP_Value_List:
set_size(param.get_size());
for (size_t i=0; i<param.get_size(); ++i) {
Module_Param* const curr = param.get_elem(i);
if (curr->get_type()!=Module_Param::MP_NotUsed) {
(*this)[i].set_param(*curr);
if (!(*this)[i].is_bound()) {
delete val_ptr->value_elements[i];
val_ptr->value_elements[i] = NULL;
}
}
}
break;
case Module_Param::MP_Indexed_List:
for (size_t i=0; i<param.get_size(); ++i) {
Module_Param* const curr = param.get_elem(i);
(*this)[curr->get_id()->get_index()].set_param(*curr);
if (!(*this)[curr->get_id()->get_index()].is_bound()) {
delete val_ptr->value_elements[curr->get_id()->get_index()];
val_ptr->value_elements[curr->get_id()->get_index()] = NULL;
}
}
break;
default:
param.type_error("record of value", "@Isobustest.OpenConnections");
}
break;
case Module_Param::OT_CONCAT:
switch (param.get_type()) {
case Module_Param::MP_Value_List: {
if (!is_bound()) *this = NULL_VALUE;
int start_idx = lengthof();
for (size_t i=0; i<param.get_size(); ++i) {
Module_Param* const curr = param.get_elem(i);
if ((curr->get_type()!=Module_Param::MP_NotUsed)) {
(*this)[start_idx+(int)i].set_param(*curr);
}
}
} break;
case Module_Param::MP_Indexed_List:
param.error("Cannot concatenate an indexed value list");
break;
default:
param.type_error("record of value", "@Isobustest.OpenConnections");
}
break;
default:
TTCN_error("Internal error: Unknown operation type.");
}
}
void OpenConnections::set_implicit_omit()
{
if (val_ptr == NULL) return;
for (int i = 0; i < val_ptr->n_elements; i++) {
if (val_ptr->value_elements[i] != NULL) val_ptr->value_elements[i]->set_implicit_omit();
}
}
void OpenConnections::encode_text(Text_Buf& text_buf) const
{
if (val_ptr == NULL) TTCN_error("Text encoder: Encoding an unbound value of type @Isobustest.OpenConnections.");
text_buf.push_int(val_ptr->n_elements);
for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++)
(*this)[elem_count].encode_text(text_buf);
}
void OpenConnections::decode_text(Text_Buf& text_buf)
{
clean_up();
val_ptr = new recordof_setof_struct;
val_ptr->ref_count = 1;
val_ptr->n_elements = text_buf.pull_int().get_val();
if (val_ptr->n_elements < 0) TTCN_error("Text decoder: Negative size was received for a value of type @Isobustest.OpenConnections.");
val_ptr->value_elements = (COMPONENT**)allocate_pointers(val_ptr->n_elements);
for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++) {
val_ptr->value_elements[elem_count] = new COMPONENT;
val_ptr->value_elements[elem_count]->decode_text(text_buf);
}
}
void OpenConnections_template::copy_value(const OpenConnections& other_value)
{
if (!other_value.is_bound()) TTCN_error("Initialization of a template of type @Isobustest.OpenConnections with an unbound value.");
single_value.n_elements = other_value.size_of();
single_value.value_elements = (COMPONENT_template**)allocate_pointers(single_value.n_elements);
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) {
if (other_value[elem_count].is_bound()) {
single_value.value_elements[elem_count] = new COMPONENT_template(other_value[elem_count]);
} else {
single_value.value_elements[elem_count] = new COMPONENT_template;
}
}
set_selection(SPECIFIC_VALUE);
}
void OpenConnections_template::copy_template(const OpenConnections_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value.n_elements = other_value.single_value.n_elements;
single_value.value_elements = (COMPONENT_template**)allocate_pointers(single_value.n_elements);
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) {
if (UNINITIALIZED_TEMPLATE != other_value.single_value.value_elements[elem_count]->get_selection()) {
single_value.value_elements[elem_count] = new COMPONENT_template(*other_value.single_value.value_elements[elem_count]);
} else {
single_value.value_elements[elem_count] = new COMPONENT_template;
}
}
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 OpenConnections_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 @Isobustest.OpenConnections.");
break;
}
set_selection(other_value);
}
boolean OpenConnections_template::match_function_specific(const Base_Type *value_ptr, int value_index, const Restricted_Length_Template *template_ptr, int template_index, boolean legacy)
{
if (value_index >= 0) return ((const OpenConnections_template*)template_ptr)->single_value.value_elements[template_index]->match((*(const OpenConnections*)value_ptr)[value_index], legacy);
else return ((const OpenConnections_template*)template_ptr)->single_value.value_elements[template_index]->is_any_or_omit();
}
OpenConnections_template::OpenConnections_template()
{
}
OpenConnections_template::OpenConnections_template(template_sel other_value)
: Record_Of_Template(other_value)
{
check_single_selection(other_value);
}
OpenConnections_template::OpenConnections_template(null_type)
: Record_Of_Template(SPECIFIC_VALUE)
{
single_value.n_elements = 0;
single_value.value_elements = NULL;
}
OpenConnections_template::OpenConnections_template(const OpenConnections& other_value)
{
copy_value(other_value);
}
OpenConnections_template::OpenConnections_template(const OPTIONAL<OpenConnections>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const OpenConnections&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @Isobustest.OpenConnections from an unbound optional field.");
}
}
OpenConnections_template::OpenConnections_template(const OpenConnections_template& other_value)
: Record_Of_Template()
{
copy_template(other_value);
}
OpenConnections_template::~OpenConnections_template()
{
clean_up();
}
void OpenConnections_template::clean_up()
{
switch (template_selection) {
case SPECIFIC_VALUE:
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++)
delete single_value.value_elements[elem_count];
free_pointers((void**)single_value.value_elements);
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
delete [] value_list.list_value;
default:
break;
}
template_selection = UNINITIALIZED_TEMPLATE;
}
OpenConnections_template& OpenConnections_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}
OpenConnections_template& OpenConnections_template::operator=(null_type)
{
clean_up();
set_selection(SPECIFIC_VALUE);
single_value.n_elements = 0;
single_value.value_elements = NULL;
return *this;
}
OpenConnections_template& OpenConnections_template::operator=(const OpenConnections& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}
OpenConnections_template& OpenConnections_template::operator=(const OPTIONAL<OpenConnections>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const OpenConnections&)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 @Isobustest.OpenConnections.");
}
return *this;
}
OpenConnections_template& OpenConnections_template::operator=(const OpenConnections_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}
COMPONENT_template& OpenConnections_template::operator[](int index_value)
{
if (index_value < 0) TTCN_error("Accessing an element of a template for type @Isobustest.OpenConnections using a negative index: %d.", index_value);
switch (template_selection)
{
case SPECIFIC_VALUE:
if(index_value < single_value.n_elements) break;
// no break
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
case UNINITIALIZED_TEMPLATE:
set_size(index_value + 1);
break;
default:
TTCN_error("Accessing an element of a non-specific template for type @Isobustest.OpenConnections.");
break;
}
return *single_value.value_elements[index_value];
}
COMPONENT_template& OpenConnections_template::operator[](const INTEGER& index_value)
{
index_value.must_bound("Using an unbound integer value for indexing a template of type @Isobustest.OpenConnections.");
return (*this)[(int)index_value];
}
const COMPONENT_template& OpenConnections_template::operator[](int index_value) const
{
if (index_value < 0) TTCN_error("Accessing an element of a template for type @Isobustest.OpenConnections using a negative index: %d.", index_value);
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing an element of a non-specific template for type @Isobustest.OpenConnections.");
if (index_value >= single_value.n_elements) TTCN_error("Index overflow in a template of type @Isobustest.OpenConnections: The index is %d, but the template has only %d elements.", index_value, single_value.n_elements);
return *single_value.value_elements[index_value];
}
const COMPONENT_template& OpenConnections_template::operator[](const INTEGER& index_value) const
{
index_value.must_bound("Using an unbound integer value for indexing a template of type @Isobustest.OpenConnections.");
return (*this)[(int)index_value];
}
void OpenConnections_template::set_size(int new_size)
{
if (new_size < 0) TTCN_error("Internal error: Setting a negative size for a template of type @Isobustest.OpenConnections.");
template_sel old_selection = template_selection;
if (old_selection != SPECIFIC_VALUE) {
clean_up();
set_selection(SPECIFIC_VALUE);
single_value.n_elements = 0;
single_value.value_elements = NULL;
}
if (new_size > single_value.n_elements) {
single_value.value_elements = (COMPONENT_template**)reallocate_pointers((void**)single_value.value_elements, single_value.n_elements, new_size);
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) {
for (int elem_count = single_value.n_elements; elem_count < new_size; elem_count++)
single_value.value_elements[elem_count] = new COMPONENT_template(ANY_VALUE);
} else {
for (int elem_count = single_value.n_elements; elem_count < new_size; elem_count++)
single_value.value_elements[elem_count] = new COMPONENT_template;
}
single_value.n_elements = new_size;
} else if (new_size < single_value.n_elements) {
for (int elem_count = new_size; elem_count < single_value.n_elements; elem_count++)
delete single_value.value_elements[elem_count];
single_value.value_elements = (COMPONENT_template**)reallocate_pointers((void**)single_value.value_elements, single_value.n_elements, new_size);
single_value.n_elements = new_size;
}
}
int OpenConnections_template::n_elem() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
return single_value.n_elements;
break;
case VALUE_LIST:
return value_list.n_values;
break;
default:
TTCN_error("Performing n_elem");
}
}
int OpenConnections_template::size_of(boolean is_size) const
{
const char* op_name = is_size ? "size" : "length";
int min_size;
boolean has_any_or_none;
if (is_ifpresent) TTCN_error("Performing %sof() operation on a template of type @Isobustest.OpenConnections which has an ifpresent attribute.", op_name);
switch (template_selection)
{
case SPECIFIC_VALUE: {
min_size = 0;
has_any_or_none = FALSE;
int elem_count = single_value.n_elements;
if (!is_size) { while (elem_count>0 && !single_value.value_elements[elem_count-1]->is_bound()) elem_count--; }
for (int i=0; i<elem_count; i++) {
switch (single_value.value_elements[i]->get_selection()) {
case OMIT_VALUE:
TTCN_error("Performing %sof() operation on a template of type @Isobustest.OpenConnections containing omit element.", op_name);
case ANY_OR_OMIT:
has_any_or_none = TRUE;
break;
default:
min_size++;
break;
}
}
} break;
case OMIT_VALUE:
TTCN_error("Performing %sof() operation on a template of type @Isobustest.OpenConnections containing omit value.", op_name);
case ANY_VALUE:
case ANY_OR_OMIT:
min_size = 0;
has_any_or_none = TRUE;
break;
case VALUE_LIST:
{
if (value_list.n_values<1)
TTCN_error("Performing %sof() operation on a template of type @Isobustest.OpenConnections containing an empty list.", op_name);
int item_size = value_list.list_value[0].size_of(is_size);
for (unsigned int i = 1; i < value_list.n_values; i++) {
if (value_list.list_value[i].size_of(is_size)!=item_size)
TTCN_error("Performing %sof() operation on a template of type @Isobustest.OpenConnections containing a value list with different sizes.", op_name);
}
min_size = item_size;
has_any_or_none = FALSE;
break;
}
case COMPLEMENTED_LIST:
TTCN_error("Performing %sof() operation on a template of type @Isobustest.OpenConnections containing complemented list.", op_name);
default:
TTCN_error("Performing %sof() operation on an uninitialized/unsupported template of type @Isobustest.OpenConnections.", op_name);
}
return check_section_is_single(min_size, has_any_or_none, op_name, "a", "template of type @Isobustest.OpenConnections");
}
boolean OpenConnections_template::match(const OpenConnections& other_value, boolean legacy) const
{
if (!other_value.is_bound()) return FALSE;
int value_length = other_value.size_of();
if (!match_length(value_length)) return FALSE;
switch (template_selection) {
case SPECIFIC_VALUE:
return match_record_of(&other_value, value_length, this, single_value.n_elements, match_function_specific, legacy);
case OMIT_VALUE:
return FALSE;
case ANY_VALUE:
case ANY_OR_OMIT:
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 with an uninitialized/unsupported template of type @Isobustest.OpenConnections.");
}
return FALSE;
}
boolean OpenConnections_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++)
if (!single_value.value_elements[elem_count]->is_value()) return FALSE;
return TRUE;
}
OpenConnections OpenConnections_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 @Isobustest.OpenConnections.");
OpenConnections ret_val;
ret_val.set_size(single_value.n_elements);
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++)
if (single_value.value_elements[elem_count]->is_bound()) {
ret_val[elem_count] = single_value.value_elements[elem_count]->valueof();
}
return ret_val;
}
OpenConnections OpenConnections_template::substr(int index, int returncount) const
{
if (!is_value()) TTCN_error("The first argument of function substr() is a template with non-specific value.");
return valueof().substr(index, returncount);
}
OpenConnections OpenConnections_template::replace(int index, int len, const OpenConnections_template& repl) const
{
if (!is_value()) TTCN_error("The first argument of function replace() is a template with non-specific value.");
if (!repl.is_value()) TTCN_error("The fourth argument of function replace() is a template with non-specific value.");
return valueof().replace(index, len, repl.valueof());
}
OpenConnections OpenConnections_template::replace(int index, int len, const OpenConnections& repl) const
{
if (!is_value()) TTCN_error("The first argument of function replace() is a template with non-specific value.");
return valueof().replace(index, len, repl);
}
void OpenConnections_template::set_type(template_sel template_type, unsigned int list_length)
{
clean_up();
switch (template_type) {
case VALUE_LIST:
case COMPLEMENTED_LIST:
value_list.n_values = list_length;
value_list.list_value = new OpenConnections_template[list_length];
break;
default:
TTCN_error("Internal error: Setting an invalid type for a template of type @Isobustest.OpenConnections.");
}
set_selection(template_type);
}
OpenConnections_template& OpenConnections_template::list_item(unsigned int list_index)
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) TTCN_error("Internal error: Accessing a list element of a non-list template of type @Isobustest.OpenConnections.");
if (list_index >= value_list.n_values) TTCN_error("Internal error: Index overflow in a value list template of type @Isobustest.OpenConnections.");
return value_list.list_value[list_index];
}
void OpenConnections_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
if (single_value.n_elements > 0) {
TTCN_Logger::log_event_str("{ ");
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) {
if (elem_count > 0) TTCN_Logger::log_event_str(", ");
if (permutation_starts_at(elem_count)) TTCN_Logger::log_event_str("permutation(");
single_value.value_elements[elem_count]->log();
if (permutation_ends_at(elem_count)) TTCN_Logger::log_char(')');
}
TTCN_Logger::log_event_str(" }");
} else 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_restricted();
log_ifpresent();
}
void OpenConnections_template::log_match(const OpenConnections& 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 && single_value.n_elements > 0 && get_number_of_permutations() == 0 && single_value.n_elements == match_value.size_of()) {
size_t previous_size = TTCN_Logger::get_logmatch_buffer_len();
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) {
if(!single_value.value_elements[elem_count]->match(match_value[elem_count], legacy)){
TTCN_Logger::log_logmatch_info("[%d]", elem_count);
single_value.value_elements[elem_count]->log_match(match_value[elem_count], legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
}
log_match_length(single_value.n_elements);
} 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 && single_value.n_elements > 0 && get_number_of_permutations() == 0 && single_value.n_elements == match_value.size_of()) {
TTCN_Logger::log_event_str("{ ");
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) {
if (elem_count > 0) TTCN_Logger::log_event_str(", ");
single_value.value_elements[elem_count]->log_match(match_value[elem_count], legacy);
}
TTCN_Logger::log_event_str(" }");
log_match_length(single_value.n_elements);
} 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 OpenConnections_template::encode_text(Text_Buf& text_buf) const
{
encode_text_permutation(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
text_buf.push_int(single_value.n_elements);
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++)
single_value.value_elements[elem_count]->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 @Isobustest.OpenConnections.");
}
}
void OpenConnections_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_permutation(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value.n_elements = text_buf.pull_int().get_val();
if (single_value.n_elements < 0) TTCN_error("Text decoder: Negative size was received for a template of type @Isobustest.OpenConnections.");
single_value.value_elements = (COMPONENT_template**)allocate_pointers(single_value.n_elements);
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) {
single_value.value_elements[elem_count] = new COMPONENT_template;
single_value.value_elements[elem_count]->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 OpenConnections_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 for a template of type @Isobustest.OpenConnections.");
}
}
boolean OpenConnections_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}
boolean OpenConnections_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 i=0; i<value_list.n_values; i++)
if (value_list.list_value[i].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}
void OpenConnections_template::set_param(Module_Param& param)
{
param.basic_check(Module_Param::BC_TEMPLATE|Module_Param::BC_LIST, "record of 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: {
OpenConnections_template temp;
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++) {
temp.list_item(p_i).set_param(*param.get_elem(p_i));
}
*this = temp;
break; }
case Module_Param::MP_Indexed_List:
if (template_selection!=SPECIFIC_VALUE) set_size(0);
for (size_t p_i=0; p_i<param.get_size(); ++p_i) {
(*this)[(int)(param.get_elem(p_i)->get_id()->get_index())].set_param(*param.get_elem(p_i));
}
break;
case Module_Param::MP_Value_List: {
set_size(param.get_size());
int curr_idx = 0;
for (size_t p_i=0; p_i<param.get_size(); ++p_i) {
switch (param.get_elem(p_i)->get_type()) {
case Module_Param::MP_NotUsed:
curr_idx++;
break;
case Module_Param::MP_Permutation_Template: {
int perm_start_idx = curr_idx;
Module_Param* param_i = param.get_elem(p_i);
for (size_t perm_i=0; perm_i<param_i->get_size(); perm_i++) {
(*this)[curr_idx].set_param(*(param_i->get_elem(perm_i)));
curr_idx++;
}
int perm_end_idx = curr_idx - 1;
add_permutation(perm_start_idx, perm_end_idx);
} break;
default:
(*this)[curr_idx].set_param(*param.get_elem(p_i));
curr_idx++;
}
}
} break;
default:
param.type_error("record of template", "@Isobustest.OpenConnections");
}
is_ifpresent = param.get_ifpresent();
set_length_range(param);
}
void OpenConnections_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;
for (int i=0; i<single_value.n_elements; i++) single_value.value_elements[i]->check_restriction(t_res, t_name ? t_name : "@Isobustest.OpenConnections");
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 : "@Isobustest.OpenConnections");
}
boolean OpenConnections_template::get_istemplate_kind(const char* type) const {
if (!strcmp(type, "AnyElement")) {
if (template_selection != SPECIFIC_VALUE) {
return FALSE;
}
for (int i = 0; i < single_value.n_elements; i++) {
if (single_value.value_elements[i]->get_selection() == ANY_VALUE) {
return TRUE;
}
}
return FALSE;
} else if (!strcmp(type, "AnyElementsOrNone")) {
if (template_selection != SPECIFIC_VALUE) {
return FALSE;
}
for (int i = 0; i < single_value.n_elements; i++) {
if (single_value.value_elements[i]->get_selection() == ANY_OR_OMIT) {
return TRUE;
}
}
return FALSE;
} else if (!strcmp(type, "permutation")) {
return number_of_permutations;
} else if (!strcmp(type, "length")) {
return length_restriction_type != NO_LENGTH_RESTRICTION;
} else {
return Base_Template::get_istemplate_kind(type);
}
}
void Isobus__PT::remove_msg_queue_head()
{
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
switch (my_head->item_selection) {
case MESSAGE_0:
delete (my_head)->message_0;
break;
default:
TTCN_error("Internal error: Invalid message selector in the queue of port %s.", port_name);
}
msg_queue_item_base *next_item = msg_queue_head->next_item;
delete (msg_queue_item*)msg_queue_head;
msg_queue_head = next_item;
if (next_item == NULL) msg_queue_tail = NULL;
TTCN_Logger::log_port_queue(TitanLoggerApiSimple::Port__Queue_operation::extract__msg, port_name, 0, ++msg_head_count, CHARSTRING(0,NULL), CHARSTRING(0,NULL));}
void Isobus__PT::clear_queue()
{
while (msg_queue_head != NULL) remove_msg_queue_head();
}
Isobus__PT::Isobus__PT(const char *par_port_name)
: PORT(par_port_name)
{
msg_queue_head = NULL;
msg_queue_tail = NULL;
}
Isobus__PT::~Isobus__PT()
{
clear_queue();
}
void Isobus__PT::send(const Isobus::CAN__frame__j1939& send_par, const COMPONENT& destination_component, FLOAT* timestamp_redirect)
{
if (!is_started) TTCN_error("Sending a message on port %s, which is not started.", port_name);
if (!destination_component.is_bound()) TTCN_error("Unbound component reference in the to clause of send operation.");
const TTCN_Logger::Severity log_sev = destination_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMSEND:TTCN_Logger::PORTEVENT_MCSEND;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_msgport_send(port_name, destination_component,
(TTCN_Logger::begin_event(log_sev, TRUE), TTCN_Logger::log_event_str(" @Isobus.CAN_frame_j1939 : "),
send_par.log(), TTCN_Logger::end_event_log2str()));
}
if (destination_component == SYSTEM_COMPREF) TTCN_error("Message cannot be sent to system on internal port %s.", port_name);
else {
Text_Buf text_buf;
prepare_message(text_buf, "@Isobus.CAN_frame_j1939");
send_par.encode_text(text_buf);
send_data(text_buf, destination_component);
}
}
void Isobus__PT::send(const Isobus::CAN__frame__j1939& send_par, FLOAT* timestamp_redirect)
{
send(send_par, COMPONENT(get_default_destination()), timestamp_redirect);
}
void Isobus__PT::send(const Isobus::CAN__frame__j1939_template& send_par, const COMPONENT& destination_component, FLOAT* timestamp_redirect)
{
const Isobus::CAN__frame__j1939& send_par_value = Isobus::CAN__frame__j1939(send_par.valueof());
send(send_par_value, destination_component, timestamp_redirect);
}
void Isobus__PT::send(const Isobus::CAN__frame__j1939_template& send_par, FLOAT* timestamp_redirect)
{
const Isobus::CAN__frame__j1939& send_par_value = Isobus::CAN__frame__j1939(send_par.valueof());
send(send_par_value, COMPONENT(get_default_destination()), timestamp_redirect);
}
alt_status Isobus__PT::receive(const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*)
{
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
if (msg_queue_head == NULL) {
if (is_started) return ALT_MAYBE;
else {
TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name);
return ALT_NO;
}
} else if (!sender_template.match(my_head->sender_component)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::begin_event(log_sev);
TTCN_Logger::log_event("Matching on port %s failed: Sender of the first message in the queue does not match the from clause: ", port_name);
sender_template.log_match(my_head->sender_component);
TTCN_Logger::end_event();
}
return ALT_NO;
} else {
if (sender_ptr != NULL) *sender_ptr = my_head->sender_component;
TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS, "Matching on port %s succeeded.", port_name);
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV;
if (TTCN_Logger::log_this_event(log_sev)) {
switch (my_head->item_selection) {
case MESSAGE_0:
TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::receive__op,
my_head->sender_component, CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @Isobus.CAN_frame_j1939: "),
my_head->message_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1);
break;
default:
TTCN_error("Internal error: unknown message");
}
}
remove_msg_queue_head();
return ALT_YES;
}
}
alt_status Isobus__PT::check_receive(const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*)
{
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
if (msg_queue_head == NULL) {
if (is_started) return ALT_MAYBE;
else {
TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name);
return ALT_NO;
}
} else if (!sender_template.match(my_head->sender_component)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::begin_event(log_sev);
TTCN_Logger::log_event("Matching on port %s failed: Sender of the first message in the queue does not match the from clause: ", port_name);
sender_template.log_match(my_head->sender_component);
TTCN_Logger::end_event();
}
return ALT_NO;
} else {
if (sender_ptr != NULL) *sender_ptr = my_head->sender_component;
TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS, "Matching on port %s succeeded.", port_name);
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV;
if (TTCN_Logger::log_this_event(log_sev)) {
switch (my_head->item_selection) {
case MESSAGE_0:
TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::check__receive__op,
my_head->sender_component, CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @Isobus.CAN_frame_j1939: "),
my_head->message_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1);
break;
default:
TTCN_error("Internal error: unknown message");
}
}
return ALT_YES;
}
}
alt_status Isobus__PT::trigger(const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*)
{
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
if (msg_queue_head == NULL) {
if (is_started) return ALT_MAYBE;
else {
TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name);
return ALT_NO;
}
} else if (!sender_template.match(my_head->sender_component)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::begin_event(log_sev);
TTCN_Logger::log_event("Matching on port %s will drop a message: Sender of the first message in the queue does not match the from clause: ", port_name);
sender_template.log_match(my_head->sender_component);
TTCN_Logger::end_event();
}
remove_msg_queue_head();
return ALT_REPEAT;
} else {
if (sender_ptr != NULL) *sender_ptr = my_head->sender_component;
TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS, "Matching on port %s succeeded.", port_name);
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV;
if (TTCN_Logger::log_this_event(log_sev)) {
switch (my_head->item_selection) {
case MESSAGE_0:
TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::trigger__op,
my_head->sender_component, CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @Isobus.CAN_frame_j1939: "),
my_head->message_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1);
break;
default:
TTCN_error("Internal error: unknown message");
}
}
remove_msg_queue_head();
return ALT_YES;
}
}
alt_status Isobus__PT::receive(const Isobus::CAN__frame__j1939_template& value_template, Isobus::CAN__frame__j1939 *value_redirect, const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*)
{
if (value_template.get_selection() == ANY_OR_OMIT) TTCN_error("Receive operation using '*' as matching template");
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
if (msg_queue_head == NULL) {
if (is_started) return ALT_MAYBE;
else {
TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name);
return ALT_NO;
}
} else if (!sender_template.match(my_head->sender_component)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::begin_event(log_sev);
TTCN_Logger::log_event("Matching on port %s failed: Sender of the first message in the queue does not match the from clause: ", port_name);
sender_template.log_match(my_head->sender_component);
TTCN_Logger::end_event();
}
return ALT_NO;
} else if (my_head->item_selection != MESSAGE_0) {
TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC, "Matching on port %s failed: Type of the first message in the queue is not @Isobus.CAN_frame_j1939.", port_name);
return ALT_NO;
} else if (!value_template.match(*my_head->message_0)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_MMUNSUCC : TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::message__,
port_name, my_head->sender_component,
TitanLoggerApiSimple::MatchingFailureType_reason::message__does__not__match__template,
(TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0),
TTCN_Logger::end_event_log2str()));
}
return ALT_NO;
} else {
if (value_redirect != NULL) {
*value_redirect = *my_head->message_0;
}
if (sender_ptr != NULL) *sender_ptr = my_head->sender_component;
TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_matching_success(TitanLoggerApiSimple::PortType::message__,
port_name, my_head->sender_component,
(TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0),
TTCN_Logger::end_event_log2str()));
}
log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::receive__op,
my_head->sender_component, CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @Isobus.CAN_frame_j1939 : "),
my_head->message_0->log(), TTCN_Logger::end_event_log2str()),
msg_head_count+1);
}
remove_msg_queue_head();
return ALT_YES;
}
}
alt_status Isobus__PT::check_receive(const Isobus::CAN__frame__j1939_template& value_template, Isobus::CAN__frame__j1939 *value_redirect, const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*)
{
if (value_template.get_selection() == ANY_OR_OMIT) TTCN_error("Check-receive operation using '*' as matching template");
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
if (msg_queue_head == NULL) {
if (is_started) return ALT_MAYBE;
else {
TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name);
return ALT_NO;
}
} else if (!sender_template.match(my_head->sender_component)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::begin_event(log_sev);
TTCN_Logger::log_event("Matching on port %s failed: Sender of the first message in the queue does not match the from clause: ", port_name);
sender_template.log_match(my_head->sender_component);
TTCN_Logger::end_event();
}
return ALT_NO;
} else if (my_head->item_selection != MESSAGE_0) {
TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC, "Matching on port %s failed: Type of the first message in the queue is not @Isobus.CAN_frame_j1939.", port_name);
return ALT_NO;
} else if (!value_template.match(*my_head->message_0)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_MMUNSUCC : TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::message__,
port_name, my_head->sender_component,
TitanLoggerApiSimple::MatchingFailureType_reason::message__does__not__match__template,
(TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0),
TTCN_Logger::end_event_log2str()));
}
return ALT_NO;
} else {
if (value_redirect != NULL) {
*value_redirect = *my_head->message_0;
}
if (sender_ptr != NULL) *sender_ptr = my_head->sender_component;
TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_matching_success(TitanLoggerApiSimple::PortType::message__,
port_name, my_head->sender_component,
(TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0),
TTCN_Logger::end_event_log2str()));
}
log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::check__receive__op,
my_head->sender_component, CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @Isobus.CAN_frame_j1939 : "),
my_head->message_0->log(), TTCN_Logger::end_event_log2str()),
msg_head_count+1);
}
return ALT_YES;
}
}
alt_status Isobus__PT::trigger(const Isobus::CAN__frame__j1939_template& value_template, Isobus::CAN__frame__j1939 *value_redirect, const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*)
{
if (value_template.get_selection() == ANY_OR_OMIT) TTCN_error("Trigger operation using '*' as matching template");
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
if (msg_queue_head == NULL) {
if (is_started) return ALT_MAYBE;
else {
TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name);
return ALT_NO;
}
} else if (!sender_template.match(my_head->sender_component)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::begin_event(log_sev);
TTCN_Logger::log_event("Matching on port %s will drop a message: Sender of the first message in the queue does not match the from clause: ", port_name);
sender_template.log_match(my_head->sender_component);
TTCN_Logger::end_event();
}
remove_msg_queue_head();
return ALT_REPEAT;
} else if (my_head->item_selection != MESSAGE_0) {
TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC, "Matching on port %s will drop a message: Type of the first message in the queue is not @Isobus.CAN_frame_j1939.", port_name);
remove_msg_queue_head();
return ALT_REPEAT;
} else if (!value_template.match(*my_head->message_0)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_MMUNSUCC : TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::message__,
port_name, my_head->sender_component,
TitanLoggerApiSimple::MatchingFailureType_reason::message__does__not__match__template,
(TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0),
TTCN_Logger::end_event_log2str()));
}
remove_msg_queue_head();
return ALT_REPEAT;
} else {
if (value_redirect != NULL) {
*value_redirect = *my_head->message_0;
}
if (sender_ptr != NULL) *sender_ptr = my_head->sender_component;
TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_matching_success(TitanLoggerApiSimple::PortType::message__,
port_name, my_head->sender_component,
(TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0),
TTCN_Logger::end_event_log2str()));
}
log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::trigger__op,
my_head->sender_component, CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @Isobus.CAN_frame_j1939 : "),
my_head->message_0->log(), TTCN_Logger::end_event_log2str()),
msg_head_count+1);
}
remove_msg_queue_head();
return ALT_YES;
}
}
void Isobus__PT::incoming_message(const Isobus::CAN__frame__j1939& incoming_par, component sender_component)
{
if (!is_started) TTCN_error("Port %s is not started but a message has arrived on it.", port_name);
msg_tail_count++;
if (TTCN_Logger::log_this_event(TTCN_Logger::PORTEVENT_MQUEUE)) {
TTCN_Logger::log_port_queue(TitanLoggerApiSimple::Port__Queue_operation::enqueue__msg, port_name, sender_component, msg_tail_count,
CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_MQUEUE, TRUE), TTCN_Logger::log_event_str(" @Isobus.CAN_frame_j1939 : "), incoming_par.log(), TTCN_Logger::end_event_log2str()));
}
msg_queue_item *new_item = new msg_queue_item;
new_item->item_selection = MESSAGE_0;
new_item->message_0 = new Isobus::CAN__frame__j1939(incoming_par);
new_item->sender_component = sender_component;
append_to_msg_queue(new_item);
}
boolean Isobus__PT::process_message(const char *message_type, Text_Buf& incoming_buf, component sender_component, OCTETSTRING&)
{
if (!strcmp(message_type, "@Isobus.CAN_frame_j1939")) {
Isobus::CAN__frame__j1939 incoming_par;
incoming_par.decode_text(incoming_buf);
incoming_message(incoming_par, sender_component);
return TRUE;
} else return FALSE;
}
void SyncMasterPort::remove_msg_queue_head()
{
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
switch (my_head->item_selection) {
case MESSAGE_0:
delete (my_head)->message_0;
break;
default:
TTCN_error("Internal error: Invalid message selector in the queue of port %s.", port_name);
}
msg_queue_item_base *next_item = msg_queue_head->next_item;
delete (msg_queue_item*)msg_queue_head;
msg_queue_head = next_item;
if (next_item == NULL) msg_queue_tail = NULL;
TTCN_Logger::log_port_queue(TitanLoggerApiSimple::Port__Queue_operation::extract__msg, port_name, 0, ++msg_head_count, CHARSTRING(0,NULL), CHARSTRING(0,NULL));}
void SyncMasterPort::clear_queue()
{
while (msg_queue_head != NULL) remove_msg_queue_head();
}
SyncMasterPort::SyncMasterPort(const char *par_port_name)
: PORT(par_port_name)
{
msg_queue_head = NULL;
msg_queue_tail = NULL;
}
SyncMasterPort::~SyncMasterPort()
{
clear_queue();
}
void SyncMasterPort::send(const SocketCANtest::PhaseStartReq& send_par, const COMPONENT& destination_component, FLOAT* timestamp_redirect)
{
if (!is_started) TTCN_error("Sending a message on port %s, which is not started.", port_name);
if (!destination_component.is_bound()) TTCN_error("Unbound component reference in the to clause of send operation.");
const TTCN_Logger::Severity log_sev = destination_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMSEND:TTCN_Logger::PORTEVENT_MCSEND;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_msgport_send(port_name, destination_component,
(TTCN_Logger::begin_event(log_sev, TRUE), TTCN_Logger::log_event_str(" @SocketCANtest.PhaseStartReq : "),
send_par.log(), TTCN_Logger::end_event_log2str()));
}
if (destination_component == SYSTEM_COMPREF) TTCN_error("Message cannot be sent to system on internal port %s.", port_name);
else {
Text_Buf text_buf;
prepare_message(text_buf, "@SocketCANtest.PhaseStartReq");
send_par.encode_text(text_buf);
send_data(text_buf, destination_component);
}
}
void SyncMasterPort::send(const SocketCANtest::PhaseStartReq& send_par, FLOAT* timestamp_redirect)
{
send(send_par, COMPONENT(get_default_destination()), timestamp_redirect);
}
void SyncMasterPort::send(const SocketCANtest::PhaseStartReq_template& send_par, const COMPONENT& destination_component, FLOAT* timestamp_redirect)
{
const SocketCANtest::PhaseStartReq& send_par_value = SocketCANtest::PhaseStartReq(send_par.valueof());
send(send_par_value, destination_component, timestamp_redirect);
}
void SyncMasterPort::send(const SocketCANtest::PhaseStartReq_template& send_par, FLOAT* timestamp_redirect)
{
const SocketCANtest::PhaseStartReq& send_par_value = SocketCANtest::PhaseStartReq(send_par.valueof());
send(send_par_value, COMPONENT(get_default_destination()), timestamp_redirect);
}
alt_status SyncMasterPort::receive(const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*)
{
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
if (msg_queue_head == NULL) {
if (is_started) return ALT_MAYBE;
else {
TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name);
return ALT_NO;
}
} else if (!sender_template.match(my_head->sender_component)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::begin_event(log_sev);
TTCN_Logger::log_event("Matching on port %s failed: Sender of the first message in the queue does not match the from clause: ", port_name);
sender_template.log_match(my_head->sender_component);
TTCN_Logger::end_event();
}
return ALT_NO;
} else {
if (sender_ptr != NULL) *sender_ptr = my_head->sender_component;
TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS, "Matching on port %s succeeded.", port_name);
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV;
if (TTCN_Logger::log_this_event(log_sev)) {
switch (my_head->item_selection) {
case MESSAGE_0:
TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::receive__op,
my_head->sender_component, CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @SocketCANtest.PhaseEndInd: "),
my_head->message_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1);
break;
default:
TTCN_error("Internal error: unknown message");
}
}
remove_msg_queue_head();
return ALT_YES;
}
}
alt_status SyncMasterPort::check_receive(const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*)
{
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
if (msg_queue_head == NULL) {
if (is_started) return ALT_MAYBE;
else {
TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name);
return ALT_NO;
}
} else if (!sender_template.match(my_head->sender_component)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::begin_event(log_sev);
TTCN_Logger::log_event("Matching on port %s failed: Sender of the first message in the queue does not match the from clause: ", port_name);
sender_template.log_match(my_head->sender_component);
TTCN_Logger::end_event();
}
return ALT_NO;
} else {
if (sender_ptr != NULL) *sender_ptr = my_head->sender_component;
TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS, "Matching on port %s succeeded.", port_name);
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV;
if (TTCN_Logger::log_this_event(log_sev)) {
switch (my_head->item_selection) {
case MESSAGE_0:
TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::check__receive__op,
my_head->sender_component, CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @SocketCANtest.PhaseEndInd: "),
my_head->message_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1);
break;
default:
TTCN_error("Internal error: unknown message");
}
}
return ALT_YES;
}
}
alt_status SyncMasterPort::trigger(const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*)
{
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
if (msg_queue_head == NULL) {
if (is_started) return ALT_MAYBE;
else {
TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name);
return ALT_NO;
}
} else if (!sender_template.match(my_head->sender_component)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::begin_event(log_sev);
TTCN_Logger::log_event("Matching on port %s will drop a message: Sender of the first message in the queue does not match the from clause: ", port_name);
sender_template.log_match(my_head->sender_component);
TTCN_Logger::end_event();
}
remove_msg_queue_head();
return ALT_REPEAT;
} else {
if (sender_ptr != NULL) *sender_ptr = my_head->sender_component;
TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS, "Matching on port %s succeeded.", port_name);
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV;
if (TTCN_Logger::log_this_event(log_sev)) {
switch (my_head->item_selection) {
case MESSAGE_0:
TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::trigger__op,
my_head->sender_component, CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @SocketCANtest.PhaseEndInd: "),
my_head->message_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1);
break;
default:
TTCN_error("Internal error: unknown message");
}
}
remove_msg_queue_head();
return ALT_YES;
}
}
alt_status SyncMasterPort::receive(const SocketCANtest::PhaseEndInd_template& value_template, SocketCANtest::PhaseEndInd *value_redirect, const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*)
{
if (value_template.get_selection() == ANY_OR_OMIT) TTCN_error("Receive operation using '*' as matching template");
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
if (msg_queue_head == NULL) {
if (is_started) return ALT_MAYBE;
else {
TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name);
return ALT_NO;
}
} else if (!sender_template.match(my_head->sender_component)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::begin_event(log_sev);
TTCN_Logger::log_event("Matching on port %s failed: Sender of the first message in the queue does not match the from clause: ", port_name);
sender_template.log_match(my_head->sender_component);
TTCN_Logger::end_event();
}
return ALT_NO;
} else if (my_head->item_selection != MESSAGE_0) {
TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC, "Matching on port %s failed: Type of the first message in the queue is not @SocketCANtest.PhaseEndInd.", port_name);
return ALT_NO;
} else if (!value_template.match(*my_head->message_0)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_MMUNSUCC : TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::message__,
port_name, my_head->sender_component,
TitanLoggerApiSimple::MatchingFailureType_reason::message__does__not__match__template,
(TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0),
TTCN_Logger::end_event_log2str()));
}
return ALT_NO;
} else {
if (value_redirect != NULL) {
*value_redirect = *my_head->message_0;
}
if (sender_ptr != NULL) *sender_ptr = my_head->sender_component;
TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_matching_success(TitanLoggerApiSimple::PortType::message__,
port_name, my_head->sender_component,
(TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0),
TTCN_Logger::end_event_log2str()));
}
log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::receive__op,
my_head->sender_component, CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @SocketCANtest.PhaseEndInd : "),
my_head->message_0->log(), TTCN_Logger::end_event_log2str()),
msg_head_count+1);
}
remove_msg_queue_head();
return ALT_YES;
}
}
alt_status SyncMasterPort::check_receive(const SocketCANtest::PhaseEndInd_template& value_template, SocketCANtest::PhaseEndInd *value_redirect, const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*)
{
if (value_template.get_selection() == ANY_OR_OMIT) TTCN_error("Check-receive operation using '*' as matching template");
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
if (msg_queue_head == NULL) {
if (is_started) return ALT_MAYBE;
else {
TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name);
return ALT_NO;
}
} else if (!sender_template.match(my_head->sender_component)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::begin_event(log_sev);
TTCN_Logger::log_event("Matching on port %s failed: Sender of the first message in the queue does not match the from clause: ", port_name);
sender_template.log_match(my_head->sender_component);
TTCN_Logger::end_event();
}
return ALT_NO;
} else if (my_head->item_selection != MESSAGE_0) {
TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC, "Matching on port %s failed: Type of the first message in the queue is not @SocketCANtest.PhaseEndInd.", port_name);
return ALT_NO;
} else if (!value_template.match(*my_head->message_0)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_MMUNSUCC : TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::message__,
port_name, my_head->sender_component,
TitanLoggerApiSimple::MatchingFailureType_reason::message__does__not__match__template,
(TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0),
TTCN_Logger::end_event_log2str()));
}
return ALT_NO;
} else {
if (value_redirect != NULL) {
*value_redirect = *my_head->message_0;
}
if (sender_ptr != NULL) *sender_ptr = my_head->sender_component;
TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_matching_success(TitanLoggerApiSimple::PortType::message__,
port_name, my_head->sender_component,
(TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0),
TTCN_Logger::end_event_log2str()));
}
log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::check__receive__op,
my_head->sender_component, CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @SocketCANtest.PhaseEndInd : "),
my_head->message_0->log(), TTCN_Logger::end_event_log2str()),
msg_head_count+1);
}
return ALT_YES;
}
}
alt_status SyncMasterPort::trigger(const SocketCANtest::PhaseEndInd_template& value_template, SocketCANtest::PhaseEndInd *value_redirect, const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*)
{
if (value_template.get_selection() == ANY_OR_OMIT) TTCN_error("Trigger operation using '*' as matching template");
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
if (msg_queue_head == NULL) {
if (is_started) return ALT_MAYBE;
else {
TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name);
return ALT_NO;
}
} else if (!sender_template.match(my_head->sender_component)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::begin_event(log_sev);
TTCN_Logger::log_event("Matching on port %s will drop a message: Sender of the first message in the queue does not match the from clause: ", port_name);
sender_template.log_match(my_head->sender_component);
TTCN_Logger::end_event();
}
remove_msg_queue_head();
return ALT_REPEAT;
} else if (my_head->item_selection != MESSAGE_0) {
TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC, "Matching on port %s will drop a message: Type of the first message in the queue is not @SocketCANtest.PhaseEndInd.", port_name);
remove_msg_queue_head();
return ALT_REPEAT;
} else if (!value_template.match(*my_head->message_0)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_MMUNSUCC : TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::message__,
port_name, my_head->sender_component,
TitanLoggerApiSimple::MatchingFailureType_reason::message__does__not__match__template,
(TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0),
TTCN_Logger::end_event_log2str()));
}
remove_msg_queue_head();
return ALT_REPEAT;
} else {
if (value_redirect != NULL) {
*value_redirect = *my_head->message_0;
}
if (sender_ptr != NULL) *sender_ptr = my_head->sender_component;
TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_matching_success(TitanLoggerApiSimple::PortType::message__,
port_name, my_head->sender_component,
(TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0),
TTCN_Logger::end_event_log2str()));
}
log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::trigger__op,
my_head->sender_component, CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @SocketCANtest.PhaseEndInd : "),
my_head->message_0->log(), TTCN_Logger::end_event_log2str()),
msg_head_count+1);
}
remove_msg_queue_head();
return ALT_YES;
}
}
void SyncMasterPort::incoming_message(const SocketCANtest::PhaseEndInd& incoming_par, component sender_component)
{
if (!is_started) TTCN_error("Port %s is not started but a message has arrived on it.", port_name);
msg_tail_count++;
if (TTCN_Logger::log_this_event(TTCN_Logger::PORTEVENT_MQUEUE)) {
TTCN_Logger::log_port_queue(TitanLoggerApiSimple::Port__Queue_operation::enqueue__msg, port_name, sender_component, msg_tail_count,
CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_MQUEUE, TRUE), TTCN_Logger::log_event_str(" @SocketCANtest.PhaseEndInd : "), incoming_par.log(), TTCN_Logger::end_event_log2str()));
}
msg_queue_item *new_item = new msg_queue_item;
new_item->item_selection = MESSAGE_0;
new_item->message_0 = new SocketCANtest::PhaseEndInd(incoming_par);
new_item->sender_component = sender_component;
append_to_msg_queue(new_item);
}
boolean SyncMasterPort::process_message(const char *message_type, Text_Buf& incoming_buf, component sender_component, OCTETSTRING&)
{
if (!strcmp(message_type, "@SocketCANtest.PhaseEndInd")) {
SocketCANtest::PhaseEndInd incoming_par;
incoming_par.decode_text(incoming_buf);
incoming_message(incoming_par, sender_component);
return TRUE;
} else return FALSE;
}
void SyncSlavePort::remove_msg_queue_head()
{
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
switch (my_head->item_selection) {
case MESSAGE_0:
delete (my_head)->message_0;
break;
default:
TTCN_error("Internal error: Invalid message selector in the queue of port %s.", port_name);
}
msg_queue_item_base *next_item = msg_queue_head->next_item;
delete (msg_queue_item*)msg_queue_head;
msg_queue_head = next_item;
if (next_item == NULL) msg_queue_tail = NULL;
TTCN_Logger::log_port_queue(TitanLoggerApiSimple::Port__Queue_operation::extract__msg, port_name, 0, ++msg_head_count, CHARSTRING(0,NULL), CHARSTRING(0,NULL));}
void SyncSlavePort::clear_queue()
{
while (msg_queue_head != NULL) remove_msg_queue_head();
}
SyncSlavePort::SyncSlavePort(const char *par_port_name)
: PORT(par_port_name)
{
msg_queue_head = NULL;
msg_queue_tail = NULL;
}
SyncSlavePort::~SyncSlavePort()
{
clear_queue();
}
void SyncSlavePort::send(const SocketCANtest::PhaseEndInd& send_par, const COMPONENT& destination_component, FLOAT* timestamp_redirect)
{
if (!is_started) TTCN_error("Sending a message on port %s, which is not started.", port_name);
if (!destination_component.is_bound()) TTCN_error("Unbound component reference in the to clause of send operation.");
const TTCN_Logger::Severity log_sev = destination_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMSEND:TTCN_Logger::PORTEVENT_MCSEND;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_msgport_send(port_name, destination_component,
(TTCN_Logger::begin_event(log_sev, TRUE), TTCN_Logger::log_event_str(" @SocketCANtest.PhaseEndInd : "),
send_par.log(), TTCN_Logger::end_event_log2str()));
}
if (destination_component == SYSTEM_COMPREF) TTCN_error("Message cannot be sent to system on internal port %s.", port_name);
else {
Text_Buf text_buf;
prepare_message(text_buf, "@SocketCANtest.PhaseEndInd");
send_par.encode_text(text_buf);
send_data(text_buf, destination_component);
}
}
void SyncSlavePort::send(const SocketCANtest::PhaseEndInd& send_par, FLOAT* timestamp_redirect)
{
send(send_par, COMPONENT(get_default_destination()), timestamp_redirect);
}
void SyncSlavePort::send(const SocketCANtest::PhaseEndInd_template& send_par, const COMPONENT& destination_component, FLOAT* timestamp_redirect)
{
const SocketCANtest::PhaseEndInd& send_par_value = SocketCANtest::PhaseEndInd(send_par.valueof());
send(send_par_value, destination_component, timestamp_redirect);
}
void SyncSlavePort::send(const SocketCANtest::PhaseEndInd_template& send_par, FLOAT* timestamp_redirect)
{
const SocketCANtest::PhaseEndInd& send_par_value = SocketCANtest::PhaseEndInd(send_par.valueof());
send(send_par_value, COMPONENT(get_default_destination()), timestamp_redirect);
}
alt_status SyncSlavePort::receive(const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*)
{
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
if (msg_queue_head == NULL) {
if (is_started) return ALT_MAYBE;
else {
TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name);
return ALT_NO;
}
} else if (!sender_template.match(my_head->sender_component)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::begin_event(log_sev);
TTCN_Logger::log_event("Matching on port %s failed: Sender of the first message in the queue does not match the from clause: ", port_name);
sender_template.log_match(my_head->sender_component);
TTCN_Logger::end_event();
}
return ALT_NO;
} else {
if (sender_ptr != NULL) *sender_ptr = my_head->sender_component;
TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS, "Matching on port %s succeeded.", port_name);
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV;
if (TTCN_Logger::log_this_event(log_sev)) {
switch (my_head->item_selection) {
case MESSAGE_0:
TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::receive__op,
my_head->sender_component, CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @SocketCANtest.PhaseStartReq: "),
my_head->message_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1);
break;
default:
TTCN_error("Internal error: unknown message");
}
}
remove_msg_queue_head();
return ALT_YES;
}
}
alt_status SyncSlavePort::check_receive(const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*)
{
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
if (msg_queue_head == NULL) {
if (is_started) return ALT_MAYBE;
else {
TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name);
return ALT_NO;
}
} else if (!sender_template.match(my_head->sender_component)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::begin_event(log_sev);
TTCN_Logger::log_event("Matching on port %s failed: Sender of the first message in the queue does not match the from clause: ", port_name);
sender_template.log_match(my_head->sender_component);
TTCN_Logger::end_event();
}
return ALT_NO;
} else {
if (sender_ptr != NULL) *sender_ptr = my_head->sender_component;
TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS, "Matching on port %s succeeded.", port_name);
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV;
if (TTCN_Logger::log_this_event(log_sev)) {
switch (my_head->item_selection) {
case MESSAGE_0:
TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::check__receive__op,
my_head->sender_component, CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @SocketCANtest.PhaseStartReq: "),
my_head->message_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1);
break;
default:
TTCN_error("Internal error: unknown message");
}
}
return ALT_YES;
}
}
alt_status SyncSlavePort::trigger(const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*)
{
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
if (msg_queue_head == NULL) {
if (is_started) return ALT_MAYBE;
else {
TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name);
return ALT_NO;
}
} else if (!sender_template.match(my_head->sender_component)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::begin_event(log_sev);
TTCN_Logger::log_event("Matching on port %s will drop a message: Sender of the first message in the queue does not match the from clause: ", port_name);
sender_template.log_match(my_head->sender_component);
TTCN_Logger::end_event();
}
remove_msg_queue_head();
return ALT_REPEAT;
} else {
if (sender_ptr != NULL) *sender_ptr = my_head->sender_component;
TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS, "Matching on port %s succeeded.", port_name);
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV;
if (TTCN_Logger::log_this_event(log_sev)) {
switch (my_head->item_selection) {
case MESSAGE_0:
TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::trigger__op,
my_head->sender_component, CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @SocketCANtest.PhaseStartReq: "),
my_head->message_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1);
break;
default:
TTCN_error("Internal error: unknown message");
}
}
remove_msg_queue_head();
return ALT_YES;
}
}
alt_status SyncSlavePort::receive(const SocketCANtest::PhaseStartReq_template& value_template, SocketCANtest::PhaseStartReq *value_redirect, const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*)
{
if (value_template.get_selection() == ANY_OR_OMIT) TTCN_error("Receive operation using '*' as matching template");
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
if (msg_queue_head == NULL) {
if (is_started) return ALT_MAYBE;
else {
TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name);
return ALT_NO;
}
} else if (!sender_template.match(my_head->sender_component)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::begin_event(log_sev);
TTCN_Logger::log_event("Matching on port %s failed: Sender of the first message in the queue does not match the from clause: ", port_name);
sender_template.log_match(my_head->sender_component);
TTCN_Logger::end_event();
}
return ALT_NO;
} else if (my_head->item_selection != MESSAGE_0) {
TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC, "Matching on port %s failed: Type of the first message in the queue is not @SocketCANtest.PhaseStartReq.", port_name);
return ALT_NO;
} else if (!value_template.match(*my_head->message_0)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_MMUNSUCC : TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::message__,
port_name, my_head->sender_component,
TitanLoggerApiSimple::MatchingFailureType_reason::message__does__not__match__template,
(TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0),
TTCN_Logger::end_event_log2str()));
}
return ALT_NO;
} else {
if (value_redirect != NULL) {
*value_redirect = *my_head->message_0;
}
if (sender_ptr != NULL) *sender_ptr = my_head->sender_component;
TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_matching_success(TitanLoggerApiSimple::PortType::message__,
port_name, my_head->sender_component,
(TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0),
TTCN_Logger::end_event_log2str()));
}
log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::receive__op,
my_head->sender_component, CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @SocketCANtest.PhaseStartReq : "),
my_head->message_0->log(), TTCN_Logger::end_event_log2str()),
msg_head_count+1);
}
remove_msg_queue_head();
return ALT_YES;
}
}
alt_status SyncSlavePort::check_receive(const SocketCANtest::PhaseStartReq_template& value_template, SocketCANtest::PhaseStartReq *value_redirect, const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*)
{
if (value_template.get_selection() == ANY_OR_OMIT) TTCN_error("Check-receive operation using '*' as matching template");
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
if (msg_queue_head == NULL) {
if (is_started) return ALT_MAYBE;
else {
TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name);
return ALT_NO;
}
} else if (!sender_template.match(my_head->sender_component)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::begin_event(log_sev);
TTCN_Logger::log_event("Matching on port %s failed: Sender of the first message in the queue does not match the from clause: ", port_name);
sender_template.log_match(my_head->sender_component);
TTCN_Logger::end_event();
}
return ALT_NO;
} else if (my_head->item_selection != MESSAGE_0) {
TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC, "Matching on port %s failed: Type of the first message in the queue is not @SocketCANtest.PhaseStartReq.", port_name);
return ALT_NO;
} else if (!value_template.match(*my_head->message_0)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_MMUNSUCC : TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::message__,
port_name, my_head->sender_component,
TitanLoggerApiSimple::MatchingFailureType_reason::message__does__not__match__template,
(TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0),
TTCN_Logger::end_event_log2str()));
}
return ALT_NO;
} else {
if (value_redirect != NULL) {
*value_redirect = *my_head->message_0;
}
if (sender_ptr != NULL) *sender_ptr = my_head->sender_component;
TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_matching_success(TitanLoggerApiSimple::PortType::message__,
port_name, my_head->sender_component,
(TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0),
TTCN_Logger::end_event_log2str()));
}
log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::check__receive__op,
my_head->sender_component, CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @SocketCANtest.PhaseStartReq : "),
my_head->message_0->log(), TTCN_Logger::end_event_log2str()),
msg_head_count+1);
}
return ALT_YES;
}
}
alt_status SyncSlavePort::trigger(const SocketCANtest::PhaseStartReq_template& value_template, SocketCANtest::PhaseStartReq *value_redirect, const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*)
{
if (value_template.get_selection() == ANY_OR_OMIT) TTCN_error("Trigger operation using '*' as matching template");
msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;
if (msg_queue_head == NULL) {
if (is_started) return ALT_MAYBE;
else {
TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name);
return ALT_NO;
}
} else if (!sender_template.match(my_head->sender_component)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::begin_event(log_sev);
TTCN_Logger::log_event("Matching on port %s will drop a message: Sender of the first message in the queue does not match the from clause: ", port_name);
sender_template.log_match(my_head->sender_component);
TTCN_Logger::end_event();
}
remove_msg_queue_head();
return ALT_REPEAT;
} else if (my_head->item_selection != MESSAGE_0) {
TTCN_Logger::log(my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMUNSUCC:TTCN_Logger::MATCHING_MCUNSUCC, "Matching on port %s will drop a message: Type of the first message in the queue is not @SocketCANtest.PhaseStartReq.", port_name);
remove_msg_queue_head();
return ALT_REPEAT;
} else if (!value_template.match(*my_head->message_0)) {
const TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_MMUNSUCC : TTCN_Logger::MATCHING_MCUNSUCC;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::message__,
port_name, my_head->sender_component,
TitanLoggerApiSimple::MatchingFailureType_reason::message__does__not__match__template,
(TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0),
TTCN_Logger::end_event_log2str()));
}
remove_msg_queue_head();
return ALT_REPEAT;
} else {
if (value_redirect != NULL) {
*value_redirect = *my_head->message_0;
}
if (sender_ptr != NULL) *sender_ptr = my_head->sender_component;
TTCN_Logger::Severity log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_MMSUCCESS:TTCN_Logger::MATCHING_MCSUCCESS;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_matching_success(TitanLoggerApiSimple::PortType::message__,
port_name, my_head->sender_component,
(TTCN_Logger::begin_event(log_sev, TRUE), value_template.log_match(*my_head->message_0),
TTCN_Logger::end_event_log2str()));
}
log_sev = my_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_MMRECV:TTCN_Logger::PORTEVENT_MCRECV;
if (TTCN_Logger::log_this_event(log_sev)) {
TTCN_Logger::log_msgport_recv(port_name, TitanLoggerApiSimple::Msg__port__recv_operation::trigger__op,
my_head->sender_component, CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(log_sev,TRUE), TTCN_Logger::log_event_str(": @SocketCANtest.PhaseStartReq : "),
my_head->message_0->log(), TTCN_Logger::end_event_log2str()),
msg_head_count+1);
}
remove_msg_queue_head();
return ALT_YES;
}
}
void SyncSlavePort::incoming_message(const SocketCANtest::PhaseStartReq& incoming_par, component sender_component)
{
if (!is_started) TTCN_error("Port %s is not started but a message has arrived on it.", port_name);
msg_tail_count++;
if (TTCN_Logger::log_this_event(TTCN_Logger::PORTEVENT_MQUEUE)) {
TTCN_Logger::log_port_queue(TitanLoggerApiSimple::Port__Queue_operation::enqueue__msg, port_name, sender_component, msg_tail_count,
CHARSTRING(0, NULL),
(TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_MQUEUE, TRUE), TTCN_Logger::log_event_str(" @SocketCANtest.PhaseStartReq : "), incoming_par.log(), TTCN_Logger::end_event_log2str()));
}
msg_queue_item *new_item = new msg_queue_item;
new_item->item_selection = MESSAGE_0;
new_item->message_0 = new SocketCANtest::PhaseStartReq(incoming_par);
new_item->sender_component = sender_component;
append_to_msg_queue(new_item);
}
boolean SyncSlavePort::process_message(const char *message_type, Text_Buf& incoming_buf, component sender_component, OCTETSTRING&)
{
if (!strcmp(message_type, "@SocketCANtest.PhaseStartReq")) {
SocketCANtest::PhaseStartReq incoming_par;
incoming_par.decode_text(incoming_buf);
incoming_message(incoming_par, sender_component);
return TRUE;
} else return FALSE;
}
const COMPONENT PTCSet::UNBOUND_ELEM;
PTCSet::PTCSet()
{
val_ptr = NULL;
}
PTCSet::PTCSet(null_type)
{
val_ptr = new recordof_setof_struct;
val_ptr->ref_count = 1;
val_ptr->n_elements = 0;
val_ptr->value_elements = NULL;
}
PTCSet::PTCSet(const PTCSet& other_value)
{
if (!other_value.is_bound()) TTCN_error("Copying an unbound value of type @Isobustest.PTCSet.");
val_ptr = other_value.val_ptr;
val_ptr->ref_count++;
}
PTCSet::~PTCSet()
{
clean_up();
if (val_ptr != NULL) val_ptr = NULL;
}
void PTCSet::clean_up()
{
if (val_ptr != NULL) {
if (val_ptr->ref_count > 1) {
val_ptr->ref_count--;
val_ptr = NULL;
}
else if (val_ptr->ref_count == 1) {
for (int elem_count = 0; elem_count < val_ptr->n_elements;
elem_count++)
if (val_ptr->value_elements[elem_count] != NULL)
delete val_ptr->value_elements[elem_count];
free_pointers((void**)val_ptr->value_elements);
delete val_ptr;
val_ptr = NULL;
}
else
TTCN_error("Internal error: Invalid reference counter in a record of/set of value.");
}
}
PTCSet& PTCSet::operator=(null_type)
{
clean_up();
val_ptr = new recordof_setof_struct;
val_ptr->ref_count = 1;
val_ptr->n_elements = 0;
val_ptr->value_elements = NULL;
return *this;
}
PTCSet& PTCSet::operator=(const PTCSet& other_value)
{
if (other_value.val_ptr == NULL) TTCN_error("Assigning an unbound value of type @Isobustest.PTCSet.");
if (this != &other_value) {
clean_up();
val_ptr = other_value.val_ptr;
val_ptr->ref_count++;
}
return *this;
}
boolean PTCSet::operator==(null_type) const
{
if (val_ptr == NULL)
TTCN_error("The left operand of comparison is an unbound value of type @Isobustest.PTCSet.");
return val_ptr->n_elements == 0 ;
}
boolean PTCSet::operator==(const PTCSet& other_value) const
{
if (val_ptr == NULL) TTCN_error("The left operand of comparison is an unbound value of type @Isobustest.PTCSet.");
if (other_value.val_ptr == NULL) TTCN_error("The right operand of comparison is an unbound value of type @Isobustest.PTCSet.");
if (val_ptr == other_value.val_ptr) return TRUE;
if (val_ptr->n_elements != (other_value.val_ptr)->n_elements)
return FALSE;
for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++){
if (val_ptr->value_elements[elem_count] != NULL){
if ((other_value.val_ptr)->value_elements[elem_count] != NULL){
if (*val_ptr->value_elements[elem_count] != *(other_value.val_ptr)->value_elements[elem_count]) return FALSE;
} else return FALSE;
} else {
if ((other_value.val_ptr)->value_elements[elem_count] != NULL) return FALSE;
}
}
return TRUE;
}
COMPONENT& PTCSet::operator[](int index_value)
{
if (index_value < 0) TTCN_error("Accessing an element of type @Isobustest.PTCSet using a negative index: %d.", index_value);
if (val_ptr == NULL) {
val_ptr = new recordof_setof_struct;
val_ptr->ref_count = 1;
val_ptr->n_elements = 0;
val_ptr->value_elements = NULL;
} else if (val_ptr->ref_count > 1) {
struct recordof_setof_struct *new_val_ptr = new recordof_setof_struct;
new_val_ptr->ref_count = 1;
new_val_ptr->n_elements = (index_value >= val_ptr->n_elements) ? index_value + 1 : val_ptr->n_elements;
new_val_ptr->value_elements = (COMPONENT**)allocate_pointers(new_val_ptr->n_elements);
for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++){
if (val_ptr->value_elements[elem_count] != NULL){
new_val_ptr->value_elements[elem_count] = new COMPONENT(*(val_ptr->value_elements[elem_count]));
}
}
clean_up();
val_ptr = new_val_ptr;
}
if (index_value >= val_ptr->n_elements) set_size(index_value + 1);
if (val_ptr->value_elements[index_value] == NULL) {
val_ptr->value_elements[index_value] = new COMPONENT;
}
return *val_ptr->value_elements[index_value];
}
COMPONENT& PTCSet::operator[](const INTEGER& index_value)
{
index_value.must_bound("Using an unbound integer value for indexing a value of type @Isobustest.PTCSet.");
return (*this)[(int)index_value];
}
const COMPONENT& PTCSet::operator[](int index_value) const
{
if (val_ptr == NULL)
TTCN_error("Accessing an element in an unbound value of type @Isobustest.PTCSet.");
if (index_value < 0) TTCN_error("Accessing an element of type @Isobustest.PTCSet using a negative index: %d.", index_value);
if (index_value >= val_ptr->n_elements) TTCN_error("Index overflow in a value of type @Isobustest.PTCSet: The index is %d, but the value has only %d elements.", index_value, val_ptr->n_elements);
return (val_ptr->value_elements[index_value] == NULL) ?
UNBOUND_ELEM : *val_ptr->value_elements[index_value];
}
const COMPONENT& PTCSet::operator[](const INTEGER& index_value) const
{
index_value.must_bound("Using an unbound integer value for indexing a value of type @Isobustest.PTCSet.");
return (*this)[(int)index_value];
}
PTCSet PTCSet::operator<<=(int rotate_count) const
{
return *this >>= (-rotate_count);
}
PTCSet PTCSet::operator<<=(const INTEGER& rotate_count) const
{
rotate_count.must_bound("Unbound integer operand of rotate left operator.");
return *this >>= (int)(-rotate_count);
}
PTCSet PTCSet::operator>>=(const INTEGER& rotate_count) const
{
rotate_count.must_bound("Unbound integer operand of rotate right operator.");
return *this >>= (int)rotate_count;
}
PTCSet PTCSet::operator>>=(int rotate_count) const
{
if (val_ptr == NULL) TTCN_error("Performing rotation operation on an unbound value of type @Isobustest.PTCSet.");
if (val_ptr->n_elements == 0) return *this;
int rc;
if (rotate_count>=0) rc = rotate_count % val_ptr->n_elements;
else rc = val_ptr->n_elements - ((-rotate_count) % val_ptr->n_elements);
if (rc == 0) return *this;
PTCSet ret_val;
ret_val.set_size(val_ptr->n_elements);
for (int i=0; i<val_ptr->n_elements; i++) {
if (val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[(i+rc)%val_ptr->n_elements] =new COMPONENT(*val_ptr->value_elements[i]);
}
}
return ret_val;
}
PTCSet PTCSet::operator+(const PTCSet& other_value) const
{
if (val_ptr == NULL || other_value.val_ptr == NULL) TTCN_error("Unbound operand of @Isobustest.PTCSet concatenation.");
if (val_ptr->n_elements == 0) return other_value;
if (other_value.val_ptr->n_elements == 0) return *this;
PTCSet ret_val;
ret_val.set_size(val_ptr->n_elements+other_value.val_ptr->n_elements);
for (int i=0; i<val_ptr->n_elements; i++) {
if (val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[i] = new COMPONENT(*val_ptr->value_elements[i]);
}
}
for (int i=0; i<other_value.val_ptr->n_elements; i++) {
if (other_value.val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[i+val_ptr->n_elements] = new COMPONENT(*other_value.val_ptr->value_elements[i]);
}
}
return ret_val;
}
PTCSet PTCSet::substr(int index, int returncount) const
{
if (val_ptr == NULL) TTCN_error("The first argument of substr() is an unbound value of type @Isobustest.PTCSet.");
check_substr_arguments(val_ptr->n_elements, index, returncount, "@Isobustest.PTCSet","element");
PTCSet ret_val;
ret_val.set_size(returncount);
for (int i=0; i<returncount; i++) {
if (val_ptr->value_elements[i+index] != NULL) {
ret_val.val_ptr->value_elements[i] = new COMPONENT(*val_ptr->value_elements[i+index]);
}
}
return ret_val;
}
PTCSet PTCSet::replace(int index, int len, const PTCSet& repl) const
{
if (val_ptr == NULL) TTCN_error("The first argument of replace() is an unbound value of type @Isobustest.PTCSet.");
if (repl.val_ptr == NULL) TTCN_error("The fourth argument of replace() is an unbound value of type @Isobustest.PTCSet.");
check_replace_arguments(val_ptr->n_elements, index, len, "@Isobustest.PTCSet","element");
PTCSet ret_val;
ret_val.set_size(val_ptr->n_elements + repl.val_ptr->n_elements - len);
for (int i = 0; i < index; i++) {
if (val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[i] = new COMPONENT(*val_ptr->value_elements[i]);
}
}
for (int i = 0; i < repl.val_ptr->n_elements; i++) {
if (repl.val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[i+index] = new COMPONENT(*repl.val_ptr->value_elements[i]);
}
}
for (int i = 0; i < val_ptr->n_elements - index - len; i++) {
if (val_ptr->value_elements[index+i+len] != NULL) {
ret_val.val_ptr->value_elements[index+i+repl.val_ptr->n_elements] = new COMPONENT(*val_ptr->value_elements[index+i+len]);
}
}
return ret_val;
}
PTCSet PTCSet::replace(int index, int len, const PTCSet_template& repl) const
{
if (!repl.is_value()) TTCN_error("The fourth argument of function replace() is a template with non-specific value.");
return replace(index, len, repl.valueof());
}
void PTCSet::set_size(int new_size)
{
if (new_size < 0) TTCN_error("Internal error: Setting a negative size for a value of type @Isobustest.PTCSet.");
if (val_ptr == NULL) {
val_ptr = new recordof_setof_struct;
val_ptr->ref_count = 1;
val_ptr->n_elements = 0;
val_ptr->value_elements = NULL;
} else if (val_ptr->ref_count > 1) {
struct recordof_setof_struct *new_val_ptr = new recordof_setof_struct;
new_val_ptr->ref_count = 1;
new_val_ptr->n_elements = (new_size < val_ptr->n_elements) ? new_size : val_ptr->n_elements;
new_val_ptr->value_elements = (COMPONENT**)allocate_pointers(new_val_ptr->n_elements);
for (int elem_count = 0; elem_count < new_val_ptr->n_elements; elem_count++) {
if (val_ptr->value_elements[elem_count] != NULL){
new_val_ptr->value_elements[elem_count] = new COMPONENT(*(val_ptr->value_elements[elem_count]));
}
}
clean_up();
val_ptr = new_val_ptr;
}
if (new_size > val_ptr->n_elements) {
val_ptr->value_elements = (COMPONENT**)reallocate_pointers((void**)val_ptr->value_elements, val_ptr->n_elements, new_size);
#ifdef TITAN_MEMORY_DEBUG_SET_RECORD_OF
if((val_ptr->n_elements/1000)!=(new_size/1000)) TTCN_warning("New size of type @Isobustest.PTCSet: %d",new_size);
#endif
val_ptr->n_elements = new_size;
} else if (new_size < val_ptr->n_elements) {
for (int elem_count = new_size; elem_count < val_ptr->n_elements; elem_count++)
if (val_ptr->value_elements[elem_count] != NULL)delete val_ptr->value_elements[elem_count];
val_ptr->value_elements = (COMPONENT**)reallocate_pointers((void**)val_ptr->value_elements, val_ptr->n_elements, new_size);
val_ptr->n_elements = new_size;
}
}
boolean PTCSet::is_value() const
{
if (val_ptr == NULL) return FALSE;
for(int i = 0; i < val_ptr->n_elements; ++i) {
if (val_ptr->value_elements[i] == NULL || !val_ptr->value_elements[i]->is_value()) return FALSE;
}
return TRUE;
}
int PTCSet::size_of() const
{
if (val_ptr == NULL) TTCN_error("Performing sizeof operation on an unbound value of type @Isobustest.PTCSet.");
return val_ptr->n_elements;
}
int PTCSet::lengthof() const
{
if (val_ptr == NULL) TTCN_error("Performing lengthof operation on an unbound value of type @Isobustest.PTCSet.");
for (int my_length=val_ptr->n_elements; my_length>0; my_length--) if (val_ptr->value_elements[my_length-1] != NULL) return my_length;
return 0;
}
void PTCSet::log() const
{
if (val_ptr == NULL) {;
TTCN_Logger::log_event_unbound();
return;
}
switch (val_ptr->n_elements) {
case 0:
TTCN_Logger::log_event_str("{ }");
break;
default:
TTCN_Logger::log_event_str("{ ");
for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++) {
if (elem_count > 0) TTCN_Logger::log_event_str(", ");
(*this)[elem_count].log();
}
TTCN_Logger::log_event_str(" }");
}
}
void PTCSet::set_param(Module_Param& param)
{
param.basic_check(Module_Param::BC_VALUE|Module_Param::BC_LIST, "record of value");
switch (param.get_operation_type()) {
case Module_Param::OT_ASSIGN:
if (param.get_type()==Module_Param::MP_Value_List && param.get_size()==0) {
*this = NULL_VALUE;
return;
}
switch (param.get_type()) {
case Module_Param::MP_Value_List:
set_size(param.get_size());
for (size_t i=0; i<param.get_size(); ++i) {
Module_Param* const curr = param.get_elem(i);
if (curr->get_type()!=Module_Param::MP_NotUsed) {
(*this)[i].set_param(*curr);
if (!(*this)[i].is_bound()) {
delete val_ptr->value_elements[i];
val_ptr->value_elements[i] = NULL;
}
}
}
break;
case Module_Param::MP_Indexed_List:
for (size_t i=0; i<param.get_size(); ++i) {
Module_Param* const curr = param.get_elem(i);
(*this)[curr->get_id()->get_index()].set_param(*curr);
if (!(*this)[curr->get_id()->get_index()].is_bound()) {
delete val_ptr->value_elements[curr->get_id()->get_index()];
val_ptr->value_elements[curr->get_id()->get_index()] = NULL;
}
}
break;
default:
param.type_error("record of value", "@Isobustest.PTCSet");
}
break;
case Module_Param::OT_CONCAT:
switch (param.get_type()) {
case Module_Param::MP_Value_List: {
if (!is_bound()) *this = NULL_VALUE;
int start_idx = lengthof();
for (size_t i=0; i<param.get_size(); ++i) {
Module_Param* const curr = param.get_elem(i);
if ((curr->get_type()!=Module_Param::MP_NotUsed)) {
(*this)[start_idx+(int)i].set_param(*curr);
}
}
} break;
case Module_Param::MP_Indexed_List:
param.error("Cannot concatenate an indexed value list");
break;
default:
param.type_error("record of value", "@Isobustest.PTCSet");
}
break;
default:
TTCN_error("Internal error: Unknown operation type.");
}
}
void PTCSet::set_implicit_omit()
{
if (val_ptr == NULL) return;
for (int i = 0; i < val_ptr->n_elements; i++) {
if (val_ptr->value_elements[i] != NULL) val_ptr->value_elements[i]->set_implicit_omit();
}
}
void PTCSet::encode_text(Text_Buf& text_buf) const
{
if (val_ptr == NULL) TTCN_error("Text encoder: Encoding an unbound value of type @Isobustest.PTCSet.");
text_buf.push_int(val_ptr->n_elements);
for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++)
(*this)[elem_count].encode_text(text_buf);
}
void PTCSet::decode_text(Text_Buf& text_buf)
{
clean_up();
val_ptr = new recordof_setof_struct;
val_ptr->ref_count = 1;
val_ptr->n_elements = text_buf.pull_int().get_val();
if (val_ptr->n_elements < 0) TTCN_error("Text decoder: Negative size was received for a value of type @Isobustest.PTCSet.");
val_ptr->value_elements = (COMPONENT**)allocate_pointers(val_ptr->n_elements);
for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++) {
val_ptr->value_elements[elem_count] = new COMPONENT;
val_ptr->value_elements[elem_count]->decode_text(text_buf);
}
}
void PTCSet_template::copy_value(const PTCSet& other_value)
{
if (!other_value.is_bound()) TTCN_error("Initialization of a template of type @Isobustest.PTCSet with an unbound value.");
single_value.n_elements = other_value.size_of();
single_value.value_elements = (COMPONENT_template**)allocate_pointers(single_value.n_elements);
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) {
if (other_value[elem_count].is_bound()) {
single_value.value_elements[elem_count] = new COMPONENT_template(other_value[elem_count]);
} else {
single_value.value_elements[elem_count] = new COMPONENT_template;
}
}
set_selection(SPECIFIC_VALUE);
}
void PTCSet_template::copy_template(const PTCSet_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value.n_elements = other_value.single_value.n_elements;
single_value.value_elements = (COMPONENT_template**)allocate_pointers(single_value.n_elements);
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) {
if (UNINITIALIZED_TEMPLATE != other_value.single_value.value_elements[elem_count]->get_selection()) {
single_value.value_elements[elem_count] = new COMPONENT_template(*other_value.single_value.value_elements[elem_count]);
} else {
single_value.value_elements[elem_count] = new COMPONENT_template;
}
}
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 PTCSet_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 @Isobustest.PTCSet.");
break;
}
set_selection(other_value);
}
boolean PTCSet_template::match_function_specific(const Base_Type *value_ptr, int value_index, const Restricted_Length_Template *template_ptr, int template_index, boolean legacy)
{
if (value_index >= 0) return ((const PTCSet_template*)template_ptr)->single_value.value_elements[template_index]->match((*(const PTCSet*)value_ptr)[value_index], legacy);
else return ((const PTCSet_template*)template_ptr)->single_value.value_elements[template_index]->is_any_or_omit();
}
PTCSet_template::PTCSet_template()
{
}
PTCSet_template::PTCSet_template(template_sel other_value)
: Record_Of_Template(other_value)
{
check_single_selection(other_value);
}
PTCSet_template::PTCSet_template(null_type)
: Record_Of_Template(SPECIFIC_VALUE)
{
single_value.n_elements = 0;
single_value.value_elements = NULL;
}
PTCSet_template::PTCSet_template(const PTCSet& other_value)
{
copy_value(other_value);
}
PTCSet_template::PTCSet_template(const OPTIONAL<PTCSet>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const PTCSet&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @Isobustest.PTCSet from an unbound optional field.");
}
}
PTCSet_template::PTCSet_template(const PTCSet_template& other_value)
: Record_Of_Template()
{
copy_template(other_value);
}
PTCSet_template::~PTCSet_template()
{
clean_up();
}
void PTCSet_template::clean_up()
{
switch (template_selection) {
case SPECIFIC_VALUE:
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++)
delete single_value.value_elements[elem_count];
free_pointers((void**)single_value.value_elements);
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
delete [] value_list.list_value;
default:
break;
}
template_selection = UNINITIALIZED_TEMPLATE;
}
PTCSet_template& PTCSet_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}
PTCSet_template& PTCSet_template::operator=(null_type)
{
clean_up();
set_selection(SPECIFIC_VALUE);
single_value.n_elements = 0;
single_value.value_elements = NULL;
return *this;
}
PTCSet_template& PTCSet_template::operator=(const PTCSet& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}
PTCSet_template& PTCSet_template::operator=(const OPTIONAL<PTCSet>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const PTCSet&)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 @Isobustest.PTCSet.");
}
return *this;
}
PTCSet_template& PTCSet_template::operator=(const PTCSet_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}
COMPONENT_template& PTCSet_template::operator[](int index_value)
{
if (index_value < 0) TTCN_error("Accessing an element of a template for type @Isobustest.PTCSet using a negative index: %d.", index_value);
switch (template_selection)
{
case SPECIFIC_VALUE:
if(index_value < single_value.n_elements) break;
// no break
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
case UNINITIALIZED_TEMPLATE:
set_size(index_value + 1);
break;
default:
TTCN_error("Accessing an element of a non-specific template for type @Isobustest.PTCSet.");
break;
}
return *single_value.value_elements[index_value];
}
COMPONENT_template& PTCSet_template::operator[](const INTEGER& index_value)
{
index_value.must_bound("Using an unbound integer value for indexing a template of type @Isobustest.PTCSet.");
return (*this)[(int)index_value];
}
const COMPONENT_template& PTCSet_template::operator[](int index_value) const
{
if (index_value < 0) TTCN_error("Accessing an element of a template for type @Isobustest.PTCSet using a negative index: %d.", index_value);
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing an element of a non-specific template for type @Isobustest.PTCSet.");
if (index_value >= single_value.n_elements) TTCN_error("Index overflow in a template of type @Isobustest.PTCSet: The index is %d, but the template has only %d elements.", index_value, single_value.n_elements);
return *single_value.value_elements[index_value];
}
const COMPONENT_template& PTCSet_template::operator[](const INTEGER& index_value) const
{
index_value.must_bound("Using an unbound integer value for indexing a template of type @Isobustest.PTCSet.");
return (*this)[(int)index_value];
}
void PTCSet_template::set_size(int new_size)
{
if (new_size < 0) TTCN_error("Internal error: Setting a negative size for a template of type @Isobustest.PTCSet.");
template_sel old_selection = template_selection;
if (old_selection != SPECIFIC_VALUE) {
clean_up();
set_selection(SPECIFIC_VALUE);
single_value.n_elements = 0;
single_value.value_elements = NULL;
}
if (new_size > single_value.n_elements) {
single_value.value_elements = (COMPONENT_template**)reallocate_pointers((void**)single_value.value_elements, single_value.n_elements, new_size);
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) {
for (int elem_count = single_value.n_elements; elem_count < new_size; elem_count++)
single_value.value_elements[elem_count] = new COMPONENT_template(ANY_VALUE);
} else {
for (int elem_count = single_value.n_elements; elem_count < new_size; elem_count++)
single_value.value_elements[elem_count] = new COMPONENT_template;
}
single_value.n_elements = new_size;
} else if (new_size < single_value.n_elements) {
for (int elem_count = new_size; elem_count < single_value.n_elements; elem_count++)
delete single_value.value_elements[elem_count];
single_value.value_elements = (COMPONENT_template**)reallocate_pointers((void**)single_value.value_elements, single_value.n_elements, new_size);
single_value.n_elements = new_size;
}
}
int PTCSet_template::n_elem() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
return single_value.n_elements;
break;
case VALUE_LIST:
return value_list.n_values;
break;
default:
TTCN_error("Performing n_elem");
}
}
int PTCSet_template::size_of(boolean is_size) const
{
const char* op_name = is_size ? "size" : "length";
int min_size;
boolean has_any_or_none;
if (is_ifpresent) TTCN_error("Performing %sof() operation on a template of type @Isobustest.PTCSet which has an ifpresent attribute.", op_name);
switch (template_selection)
{
case SPECIFIC_VALUE: {
min_size = 0;
has_any_or_none = FALSE;
int elem_count = single_value.n_elements;
if (!is_size) { while (elem_count>0 && !single_value.value_elements[elem_count-1]->is_bound()) elem_count--; }
for (int i=0; i<elem_count; i++) {
switch (single_value.value_elements[i]->get_selection()) {
case OMIT_VALUE:
TTCN_error("Performing %sof() operation on a template of type @Isobustest.PTCSet containing omit element.", op_name);
case ANY_OR_OMIT:
has_any_or_none = TRUE;
break;
default:
min_size++;
break;
}
}
} break;
case OMIT_VALUE:
TTCN_error("Performing %sof() operation on a template of type @Isobustest.PTCSet containing omit value.", op_name);
case ANY_VALUE:
case ANY_OR_OMIT:
min_size = 0;
has_any_or_none = TRUE;
break;
case VALUE_LIST:
{
if (value_list.n_values<1)
TTCN_error("Performing %sof() operation on a template of type @Isobustest.PTCSet containing an empty list.", op_name);
int item_size = value_list.list_value[0].size_of(is_size);
for (unsigned int i = 1; i < value_list.n_values; i++) {
if (value_list.list_value[i].size_of(is_size)!=item_size)
TTCN_error("Performing %sof() operation on a template of type @Isobustest.PTCSet containing a value list with different sizes.", op_name);
}
min_size = item_size;
has_any_or_none = FALSE;
break;
}
case COMPLEMENTED_LIST:
TTCN_error("Performing %sof() operation on a template of type @Isobustest.PTCSet containing complemented list.", op_name);
default:
TTCN_error("Performing %sof() operation on an uninitialized/unsupported template of type @Isobustest.PTCSet.", op_name);
}
return check_section_is_single(min_size, has_any_or_none, op_name, "a", "template of type @Isobustest.PTCSet");
}
boolean PTCSet_template::match(const PTCSet& other_value, boolean legacy) const
{
if (!other_value.is_bound()) return FALSE;
int value_length = other_value.size_of();
if (!match_length(value_length)) return FALSE;
switch (template_selection) {
case SPECIFIC_VALUE:
return match_record_of(&other_value, value_length, this, single_value.n_elements, match_function_specific, legacy);
case OMIT_VALUE:
return FALSE;
case ANY_VALUE:
case ANY_OR_OMIT:
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 with an uninitialized/unsupported template of type @Isobustest.PTCSet.");
}
return FALSE;
}
boolean PTCSet_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++)
if (!single_value.value_elements[elem_count]->is_value()) return FALSE;
return TRUE;
}
PTCSet PTCSet_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 @Isobustest.PTCSet.");
PTCSet ret_val;
ret_val.set_size(single_value.n_elements);
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++)
if (single_value.value_elements[elem_count]->is_bound()) {
ret_val[elem_count] = single_value.value_elements[elem_count]->valueof();
}
return ret_val;
}
PTCSet PTCSet_template::substr(int index, int returncount) const
{
if (!is_value()) TTCN_error("The first argument of function substr() is a template with non-specific value.");
return valueof().substr(index, returncount);
}
PTCSet PTCSet_template::replace(int index, int len, const PTCSet_template& repl) const
{
if (!is_value()) TTCN_error("The first argument of function replace() is a template with non-specific value.");
if (!repl.is_value()) TTCN_error("The fourth argument of function replace() is a template with non-specific value.");
return valueof().replace(index, len, repl.valueof());
}
PTCSet PTCSet_template::replace(int index, int len, const PTCSet& repl) const
{
if (!is_value()) TTCN_error("The first argument of function replace() is a template with non-specific value.");
return valueof().replace(index, len, repl);
}
void PTCSet_template::set_type(template_sel template_type, unsigned int list_length)
{
clean_up();
switch (template_type) {
case VALUE_LIST:
case COMPLEMENTED_LIST:
value_list.n_values = list_length;
value_list.list_value = new PTCSet_template[list_length];
break;
default:
TTCN_error("Internal error: Setting an invalid type for a template of type @Isobustest.PTCSet.");
}
set_selection(template_type);
}
PTCSet_template& PTCSet_template::list_item(unsigned int list_index)
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) TTCN_error("Internal error: Accessing a list element of a non-list template of type @Isobustest.PTCSet.");
if (list_index >= value_list.n_values) TTCN_error("Internal error: Index overflow in a value list template of type @Isobustest.PTCSet.");
return value_list.list_value[list_index];
}
void PTCSet_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
if (single_value.n_elements > 0) {
TTCN_Logger::log_event_str("{ ");
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) {
if (elem_count > 0) TTCN_Logger::log_event_str(", ");
if (permutation_starts_at(elem_count)) TTCN_Logger::log_event_str("permutation(");
single_value.value_elements[elem_count]->log();
if (permutation_ends_at(elem_count)) TTCN_Logger::log_char(')');
}
TTCN_Logger::log_event_str(" }");
} else 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_restricted();
log_ifpresent();
}
void PTCSet_template::log_match(const PTCSet& 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 && single_value.n_elements > 0 && get_number_of_permutations() == 0 && single_value.n_elements == match_value.size_of()) {
size_t previous_size = TTCN_Logger::get_logmatch_buffer_len();
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) {
if(!single_value.value_elements[elem_count]->match(match_value[elem_count], legacy)){
TTCN_Logger::log_logmatch_info("[%d]", elem_count);
single_value.value_elements[elem_count]->log_match(match_value[elem_count], legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
}
log_match_length(single_value.n_elements);
} 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 && single_value.n_elements > 0 && get_number_of_permutations() == 0 && single_value.n_elements == match_value.size_of()) {
TTCN_Logger::log_event_str("{ ");
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) {
if (elem_count > 0) TTCN_Logger::log_event_str(", ");
single_value.value_elements[elem_count]->log_match(match_value[elem_count], legacy);
}
TTCN_Logger::log_event_str(" }");
log_match_length(single_value.n_elements);
} 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 PTCSet_template::encode_text(Text_Buf& text_buf) const
{
encode_text_permutation(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
text_buf.push_int(single_value.n_elements);
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++)
single_value.value_elements[elem_count]->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 @Isobustest.PTCSet.");
}
}
void PTCSet_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_permutation(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value.n_elements = text_buf.pull_int().get_val();
if (single_value.n_elements < 0) TTCN_error("Text decoder: Negative size was received for a template of type @Isobustest.PTCSet.");
single_value.value_elements = (COMPONENT_template**)allocate_pointers(single_value.n_elements);
for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) {
single_value.value_elements[elem_count] = new COMPONENT_template;
single_value.value_elements[elem_count]->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 PTCSet_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 for a template of type @Isobustest.PTCSet.");
}
}
boolean PTCSet_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}
boolean PTCSet_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 i=0; i<value_list.n_values; i++)
if (value_list.list_value[i].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}
void PTCSet_template::set_param(Module_Param& param)
{
param.basic_check(Module_Param::BC_TEMPLATE|Module_Param::BC_LIST, "record of 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: {
PTCSet_template temp;
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++) {
temp.list_item(p_i).set_param(*param.get_elem(p_i));
}
*this = temp;
break; }
case Module_Param::MP_Indexed_List:
if (template_selection!=SPECIFIC_VALUE) set_size(0);
for (size_t p_i=0; p_i<param.get_size(); ++p_i) {
(*this)[(int)(param.get_elem(p_i)->get_id()->get_index())].set_param(*param.get_elem(p_i));
}
break;
case Module_Param::MP_Value_List: {
set_size(param.get_size());
int curr_idx = 0;
for (size_t p_i=0; p_i<param.get_size(); ++p_i) {
switch (param.get_elem(p_i)->get_type()) {
case Module_Param::MP_NotUsed:
curr_idx++;
break;
case Module_Param::MP_Permutation_Template: {
int perm_start_idx = curr_idx;
Module_Param* param_i = param.get_elem(p_i);
for (size_t perm_i=0; perm_i<param_i->get_size(); perm_i++) {
(*this)[curr_idx].set_param(*(param_i->get_elem(perm_i)));
curr_idx++;
}
int perm_end_idx = curr_idx - 1;
add_permutation(perm_start_idx, perm_end_idx);
} break;
default:
(*this)[curr_idx].set_param(*param.get_elem(p_i));
curr_idx++;
}
}
} break;
default:
param.type_error("record of template", "@Isobustest.PTCSet");
}
is_ifpresent = param.get_ifpresent();
set_length_range(param);
}
void PTCSet_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;
for (int i=0; i<single_value.n_elements; i++) single_value.value_elements[i]->check_restriction(t_res, t_name ? t_name : "@Isobustest.PTCSet");
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 : "@Isobustest.PTCSet");
}
boolean PTCSet_template::get_istemplate_kind(const char* type) const {
if (!strcmp(type, "AnyElement")) {
if (template_selection != SPECIFIC_VALUE) {
return FALSE;
}
for (int i = 0; i < single_value.n_elements; i++) {
if (single_value.value_elements[i]->get_selection() == ANY_VALUE) {
return TRUE;
}
}
return FALSE;
} else if (!strcmp(type, "AnyElementsOrNone")) {
if (template_selection != SPECIFIC_VALUE) {
return FALSE;
}
for (int i = 0; i < single_value.n_elements; i++) {
if (single_value.value_elements[i]->get_selection() == ANY_OR_OMIT) {
return TRUE;
}
}
return FALSE;
} else if (!strcmp(type, "permutation")) {
return number_of_permutations;
} else if (!strcmp(type, "length")) {
return length_restriction_type != NO_LENGTH_RESTRICTION;
} else {
return Base_Template::get_istemplate_kind(type);
}
}
/* Bodies of functions, altsteps and testcases */
boolean operator==(null_type, const OpenConnections& other_value)
{
if (other_value.val_ptr == NULL)
TTCN_error("The right operand of comparison is an unbound value of type @Isobustest.OpenConnections.");
return other_value.val_ptr->n_elements == 0;
}
boolean operator==(null_type, const PTCSet& other_value)
{
if (other_value.val_ptr == NULL)
TTCN_error("The right operand of comparison is an unbound value of type @Isobustest.PTCSet.");
return other_value.val_ptr->n_elements == 0;
}
SocketCAN__Types::SocketCAN__socket__result f__open__socket2(const SocketCANtest::SocketCAN__open__socket__type& v__socket__type)
{
TTCN_Location current_location("Isobustest.ttcn", 130, TTCN_Location::LOCATION_FUNCTION, "f_open_socket2");
current_location.update_lineno(134);
#line 134 "Isobustest.ttcn"
SocketCAN__Types::SocketCAN__socket__result v__result;
current_location.update_lineno(135);
#line 135 "Isobustest.ttcn"
TIMER t__guard("t_guard");
current_location.update_lineno(136);
#line 136 "Isobustest.ttcn"
t__guard.start(SocketCANtest::c__guard);
current_location.update_lineno(138);
#line 138 "Isobustest.ttcn"
SocketCAN__Types::SocketCAN__socket socket;
current_location.update_lineno(140);
#line 140 "Isobustest.ttcn"
if ((v__socket__type == SocketCANtest::SocketCAN__open__socket__type::OPEN__CAN__RAW)) {
current_location.update_lineno(141);
#line 141 "Isobustest.ttcn"
socket.domain() = Can::AdresseFamily__enum::PF__CAN;
socket.ptype() = Can::ProtocolFamily__enum::SOCK__RAW;
socket.protocol() = Can::PF__CAN__protocols__enum::CAN__RAW;
}
else {
current_location.update_lineno(142);
#line 142 "Isobustest.ttcn"
if ((v__socket__type == SocketCANtest::SocketCAN__open__socket__type::OPEN__CAN__BCM)) {
current_location.update_lineno(143);
#line 143 "Isobustest.ttcn"
socket.domain() = Can::AdresseFamily__enum::PF__CAN;
socket.ptype() = Can::ProtocolFamily__enum::SOCK__DGRAM;
socket.protocol() = Can::PF__CAN__protocols__enum::CAN__BCM;
}
}
current_location.update_lineno(145);
#line 145 "Isobustest.ttcn"
PTC__isobus__CT_component_pt__socketCAN.send(socket, NULL);
current_location.update_lineno(148);
#line 148 "Isobustest.ttcn"
{
tmp_2:
alt_status tmp_2_alt_flag_0 = ALT_MAYBE;
alt_status tmp_2_alt_flag_1 = ALT_MAYBE;
alt_status tmp_2_alt_flag_2 = ALT_MAYBE;
alt_status tmp_2_alt_flag_3 = ALT_MAYBE;
alt_status tmp_2_default_flag = ALT_MAYBE;
TTCN_Snapshot::take_new(FALSE);
for ( ; ; ) {
if (tmp_2_alt_flag_0 == ALT_MAYBE) {
current_location.update_lineno(149);
#line 149 "Isobustest.ttcn"
tmp_2_alt_flag_0 = PTC__isobus__CT_component_pt__socketCAN.receive(SocketCAN__Templates::a__SocketCAN__socket__result(SocketCAN__Templates::a__result(SocketCAN__Types::SocketCAN__Result__code::SocketCAN__SUCCESS)), &(v__result), any_compref, NULL, NULL, NULL);
if (tmp_2_alt_flag_0 == ALT_YES) {
current_location.update_lineno(151);
#line 151 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("SocketCan:Socket opened: ");
const_cast< const SocketCAN__Types::SocketCAN__socket__result&>(v__result).id().log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
break;
}
}
if (tmp_2_alt_flag_1 == ALT_MAYBE) {
current_location.update_lineno(152);
#line 152 "Isobustest.ttcn"
tmp_2_alt_flag_1 = PTC__isobus__CT_component_pt__socketCAN.receive(SocketCAN__Templates::a__SocketCAN__socket__result(SocketCAN__Templates::a__result(SocketCAN__Types::SocketCAN__Result__code::SocketCAN__ERROR)), NULL, any_compref, NULL, NULL, NULL);
if (tmp_2_alt_flag_1 == ALT_YES) {
current_location.update_lineno(153);
#line 153 "Isobustest.ttcn"
TTCN_Logger::log_str(TTCN_USER, "Received Opening Socket failed");
current_location.update_lineno(153);
#line 153 "Isobustest.ttcn"
TTCN_Runtime::setverdict(FAIL);
break;
}
}
if (tmp_2_alt_flag_2 == ALT_MAYBE) {
current_location.update_lineno(154);
#line 154 "Isobustest.ttcn"
tmp_2_alt_flag_2 = t__guard.timeout(NULL);
if (tmp_2_alt_flag_2 == ALT_YES) {
current_location.update_lineno(155);
#line 155 "Isobustest.ttcn"
TTCN_Logger::log_str(TTCN_USER, "timeout!");
current_location.update_lineno(156);
#line 156 "Isobustest.ttcn"
TTCN_Runtime::setverdict(FAIL);
break;
}
}
if (tmp_2_alt_flag_3 == ALT_MAYBE) {
current_location.update_lineno(157);
#line 157 "Isobustest.ttcn"
tmp_2_alt_flag_3 = t__guard.timeout(NULL);
if (tmp_2_alt_flag_3 == ALT_YES) {
current_location.update_lineno(158);
#line 158 "Isobustest.ttcn"
TTCN_Logger::log_str(TTCN_USER, "timeout!");
current_location.update_lineno(159);
#line 159 "Isobustest.ttcn"
TTCN_Runtime::setverdict(FAIL);
break;
}
}
if (tmp_2_default_flag == ALT_MAYBE) {
tmp_2_default_flag = TTCN_Default::try_altsteps();
if (tmp_2_default_flag == ALT_YES || tmp_2_default_flag == ALT_BREAK) break;
else if (tmp_2_default_flag == ALT_REPEAT) goto tmp_2;
}
current_location.update_lineno(148);
#line 148 "Isobustest.ttcn"
if (tmp_2_alt_flag_0 == ALT_NO && tmp_2_alt_flag_1 == ALT_NO && tmp_2_alt_flag_2 == ALT_NO && tmp_2_alt_flag_3 == ALT_NO && tmp_2_default_flag == ALT_NO) TTCN_error("None of the branches can be chosen in the alt statement in file Isobustest.ttcn between lines 148 and 160.");
TTCN_Snapshot::take_new(TRUE);
}
}
current_location.update_lineno(161);
#line 161 "Isobustest.ttcn"
t__guard.stop();
current_location.update_lineno(162);
#line 162 "Isobustest.ttcn"
return v__result;
}
void start_f__open__socket2(const COMPONENT& component_reference, const SocketCANtest::SocketCAN__open__socket__type& v__socket__type)
{
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_open_socket2(");
v__socket__type.log();
TTCN_Logger::log_event_str(") on component ");
component_reference.log();
TTCN_Logger::log_char('.');
TTCN_Logger::end_event();
Text_Buf text_buf;
TTCN_Runtime::prepare_start_component(component_reference, "Isobustest", "f_open_socket2", text_buf);
v__socket__type.encode_text(text_buf);
TTCN_Runtime::send_start_component(text_buf);
}
SocketCANtest::SocketCAN__open__raw__result f__open__raw2()
{
TTCN_Location current_location("Isobustest.ttcn", 165, TTCN_Location::LOCATION_FUNCTION, "f_open_raw2");
current_location.update_lineno(168);
#line 168 "Isobustest.ttcn"
INTEGER v__socket__id;
current_location.update_lineno(169);
#line 169 "Isobustest.ttcn"
v__socket__id = f__open__socket2(SocketCANtest::SocketCAN__open__socket__type::OPEN__CAN__RAW).id();
current_location.update_lineno(170);
#line 170 "Isobustest.ttcn"
SocketCAN__Types::SocketCAN__ifr v__ifr;
current_location.update_lineno(171);
#line 171 "Isobustest.ttcn"
v__ifr = f__ioctl__get__if__index2(v__socket__id).ifr();
current_location.update_lineno(172);
#line 172 "Isobustest.ttcn"
SocketCAN__Types::SocketCAN__bind__result v__bind__result;
current_location.update_lineno(173);
#line 173 "Isobustest.ttcn"
v__bind__result = f__bind2(v__socket__id, const_cast< const SocketCAN__Types::SocketCAN__ifr&>(v__ifr).if__index());
current_location.update_lineno(175);
#line 175 "Isobustest.ttcn"
SocketCANtest::SocketCAN__open__raw__result v__result;
current_location.update_lineno(176);
#line 176 "Isobustest.ttcn"
v__result.ifr() = v__ifr;
v__result.socket__id() = v__socket__id;
current_location.update_lineno(178);
#line 178 "Isobustest.ttcn"
return v__result;
}
void start_f__open__raw2(const COMPONENT& component_reference)
{
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_open_raw2(");
TTCN_Logger::log_event_str(") on component ");
component_reference.log();
TTCN_Logger::log_char('.');
TTCN_Logger::end_event();
Text_Buf text_buf;
TTCN_Runtime::prepare_start_component(component_reference, "Isobustest", "f_open_raw2", text_buf);
TTCN_Runtime::send_start_component(text_buf);
}
SocketCAN__Types::SocketCAN__ioctl__result f__ioctl__get__if__index2(const INTEGER& p__socket__id)
{
TTCN_Location current_location("Isobustest.ttcn", 181, TTCN_Location::LOCATION_FUNCTION, "f_ioctl_get_if_index2");
current_location.update_lineno(184);
#line 184 "Isobustest.ttcn"
SocketCAN__Types::SocketCAN__ioctl__result v__result;
current_location.update_lineno(185);
#line 185 "Isobustest.ttcn"
TIMER t__guard("t_guard");
current_location.update_lineno(186);
#line 186 "Isobustest.ttcn"
t__guard.start(SocketCANtest::c__guard);
current_location.update_lineno(188);
#line 188 "Isobustest.ttcn"
{
SocketCAN__Types::SocketCAN__ioctl_template tmp_7;
tmp_7.id() = p__socket__id;
tmp_7.ifu() = OMIT_VALUE;
PTC__isobus__CT_component_pt__socketCAN.send(tmp_7, NULL);
}
current_location.update_lineno(190);
#line 190 "Isobustest.ttcn"
{
tmp_8:
alt_status tmp_8_alt_flag_0 = ALT_MAYBE;
alt_status tmp_8_alt_flag_1 = ALT_MAYBE;
alt_status tmp_8_alt_flag_2 = ALT_MAYBE;
alt_status tmp_8_default_flag = ALT_MAYBE;
TTCN_Snapshot::take_new(FALSE);
for ( ; ; ) {
if (tmp_8_alt_flag_0 == ALT_MAYBE) {
current_location.update_lineno(191);
#line 191 "Isobustest.ttcn"
tmp_8_alt_flag_0 = PTC__isobus__CT_component_pt__socketCAN.receive(SocketCAN__Templates::a__SocketCAN__ioctl__result(SocketCAN__Templates::a__result(SocketCAN__Types::SocketCAN__Result__code::SocketCAN__SUCCESS)), &(v__result), any_compref, NULL, NULL, NULL);
if (tmp_8_alt_flag_0 == ALT_YES) {
current_location.update_lineno(192);
#line 192 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("Retrieved interface index");
const_cast< const SocketCAN__Types::SocketCAN__ioctl__result&>(v__result).ifr().if__index().log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
break;
}
}
if (tmp_8_alt_flag_1 == ALT_MAYBE) {
current_location.update_lineno(193);
#line 193 "Isobustest.ttcn"
tmp_8_alt_flag_1 = PTC__isobus__CT_component_pt__socketCAN.receive(SocketCAN__Templates::a__SocketCAN__ioctl__result(SocketCAN__Templates::a__result(SocketCAN__Types::SocketCAN__Result__code::SocketCAN__ERROR)), NULL, any_compref, NULL, NULL, NULL);
if (tmp_8_alt_flag_1 == ALT_YES) {
current_location.update_lineno(194);
#line 194 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("Retrieving interface index failed");
p__socket__id.log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(194);
#line 194 "Isobustest.ttcn"
TTCN_Runtime::setverdict(FAIL);
break;
}
}
if (tmp_8_alt_flag_2 == ALT_MAYBE) {
current_location.update_lineno(195);
#line 195 "Isobustest.ttcn"
tmp_8_alt_flag_2 = t__guard.timeout(NULL);
if (tmp_8_alt_flag_2 == ALT_YES) {
current_location.update_lineno(196);
#line 196 "Isobustest.ttcn"
TTCN_Logger::log_str(TTCN_USER, "timeout!");
current_location.update_lineno(197);
#line 197 "Isobustest.ttcn"
TTCN_Runtime::setverdict(FAIL);
break;
}
}
if (tmp_8_default_flag == ALT_MAYBE) {
tmp_8_default_flag = TTCN_Default::try_altsteps();
if (tmp_8_default_flag == ALT_YES || tmp_8_default_flag == ALT_BREAK) break;
else if (tmp_8_default_flag == ALT_REPEAT) goto tmp_8;
}
current_location.update_lineno(190);
#line 190 "Isobustest.ttcn"
if (tmp_8_alt_flag_0 == ALT_NO && tmp_8_alt_flag_1 == ALT_NO && tmp_8_alt_flag_2 == ALT_NO && tmp_8_default_flag == ALT_NO) TTCN_error("None of the branches can be chosen in the alt statement in file Isobustest.ttcn between lines 190 and 199.");
TTCN_Snapshot::take_new(TRUE);
}
}
current_location.update_lineno(200);
#line 200 "Isobustest.ttcn"
return v__result;
}
void start_f__ioctl__get__if__index2(const COMPONENT& component_reference, const INTEGER& p__socket__id)
{
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_ioctl_get_if_index2(");
p__socket__id.log();
TTCN_Logger::log_event_str(") on component ");
component_reference.log();
TTCN_Logger::log_char('.');
TTCN_Logger::end_event();
Text_Buf text_buf;
TTCN_Runtime::prepare_start_component(component_reference, "Isobustest", "f_ioctl_get_if_index2", text_buf);
p__socket__id.encode_text(text_buf);
TTCN_Runtime::send_start_component(text_buf);
}
SocketCAN__Types::SocketCAN__bind__result f__bind2(const INTEGER& p__socket__id, const INTEGER& p__if__index)
{
TTCN_Location current_location("Isobustest.ttcn", 203, TTCN_Location::LOCATION_FUNCTION, "f_bind2");
current_location.update_lineno(207);
#line 207 "Isobustest.ttcn"
SocketCAN__Types::SocketCAN__bind__result v__result;
current_location.update_lineno(208);
#line 208 "Isobustest.ttcn"
TIMER t__guard("t_guard");
current_location.update_lineno(209);
#line 209 "Isobustest.ttcn"
t__guard.start(SocketCANtest::c__guard);
current_location.update_lineno(211);
#line 211 "Isobustest.ttcn"
{
SocketCAN__Types::SocketCAN__bind_template tmp_9;
tmp_9.id() = p__socket__id;
tmp_9.bindu().raw().if__index() = p__if__index;
PTC__isobus__CT_component_pt__socketCAN.send(tmp_9, NULL);
}
current_location.update_lineno(212);
#line 212 "Isobustest.ttcn"
{
tmp_10:
alt_status tmp_10_alt_flag_0 = ALT_MAYBE;
alt_status tmp_10_alt_flag_1 = ALT_MAYBE;
alt_status tmp_10_alt_flag_2 = ALT_MAYBE;
alt_status tmp_10_default_flag = ALT_MAYBE;
TTCN_Snapshot::take_new(FALSE);
for ( ; ; ) {
if (tmp_10_alt_flag_0 == ALT_MAYBE) {
current_location.update_lineno(213);
#line 213 "Isobustest.ttcn"
tmp_10_alt_flag_0 = PTC__isobus__CT_component_pt__socketCAN.receive(SocketCAN__Templates::a__SocketCAN__bind__result(SocketCAN__Templates::a__result(SocketCAN__Types::SocketCAN__Result__code::SocketCAN__SUCCESS)), &(v__result), any_compref, NULL, NULL, NULL);
if (tmp_10_alt_flag_0 == ALT_YES) {
current_location.update_lineno(214);
#line 214 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("Binding socket");
p__socket__id.log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
break;
}
}
if (tmp_10_alt_flag_1 == ALT_MAYBE) {
current_location.update_lineno(215);
#line 215 "Isobustest.ttcn"
tmp_10_alt_flag_1 = PTC__isobus__CT_component_pt__socketCAN.receive(SocketCAN__Templates::a__SocketCAN__bind__result(SocketCAN__Templates::a__result(SocketCAN__Types::SocketCAN__Result__code::SocketCAN__ERROR)), NULL, any_compref, NULL, NULL, NULL);
if (tmp_10_alt_flag_1 == ALT_YES) break;
}
if (tmp_10_alt_flag_2 == ALT_MAYBE) {
current_location.update_lineno(216);
#line 216 "Isobustest.ttcn"
tmp_10_alt_flag_2 = t__guard.timeout(NULL);
if (tmp_10_alt_flag_2 == ALT_YES) {
current_location.update_lineno(217);
#line 217 "Isobustest.ttcn"
TTCN_Logger::log_str(TTCN_USER, "timeout!");
current_location.update_lineno(218);
#line 218 "Isobustest.ttcn"
TTCN_Runtime::setverdict(FAIL);
break;
}
}
if (tmp_10_default_flag == ALT_MAYBE) {
tmp_10_default_flag = TTCN_Default::try_altsteps();
if (tmp_10_default_flag == ALT_YES || tmp_10_default_flag == ALT_BREAK) break;
else if (tmp_10_default_flag == ALT_REPEAT) goto tmp_10;
}
current_location.update_lineno(212);
#line 212 "Isobustest.ttcn"
if (tmp_10_alt_flag_0 == ALT_NO && tmp_10_alt_flag_1 == ALT_NO && tmp_10_alt_flag_2 == ALT_NO && tmp_10_default_flag == ALT_NO) TTCN_error("None of the branches can be chosen in the alt statement in file Isobustest.ttcn between lines 212 and 220.");
TTCN_Snapshot::take_new(TRUE);
}
}
current_location.update_lineno(221);
#line 221 "Isobustest.ttcn"
return v__result;
}
void start_f__bind2(const COMPONENT& component_reference, const INTEGER& p__socket__id, const INTEGER& p__if__index)
{
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_bind2(");
p__socket__id.log();
TTCN_Logger::log_event_str(", ");
p__if__index.log();
TTCN_Logger::log_event_str(") on component ");
component_reference.log();
TTCN_Logger::log_char('.');
TTCN_Logger::end_event();
Text_Buf text_buf;
TTCN_Runtime::prepare_start_component(component_reference, "Isobustest", "f_bind2", text_buf);
p__socket__id.encode_text(text_buf);
p__if__index.encode_text(text_buf);
TTCN_Runtime::send_start_component(text_buf);
}
void f__close__socket2(const INTEGER& p__socket__id)
{
TTCN_Location current_location("Isobustest.ttcn", 224, TTCN_Location::LOCATION_FUNCTION, "f_close_socket2");
current_location.update_lineno(226);
#line 226 "Isobustest.ttcn"
{
SocketCAN__Types::SocketCAN__close_template tmp_11;
tmp_11.id() = p__socket__id;
PTC__isobus__CT_component_pt__socketCAN.send(tmp_11, NULL);
}
}
void start_f__close__socket2(const COMPONENT& component_reference, const INTEGER& p__socket__id)
{
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_close_socket2(");
p__socket__id.log();
TTCN_Logger::log_event_str(") on component ");
component_reference.log();
TTCN_Logger::log_char('.');
TTCN_Logger::end_event();
Text_Buf text_buf;
TTCN_Runtime::prepare_start_component(component_reference, "Isobustest", "f_close_socket2", text_buf);
p__socket__id.encode_text(text_buf);
TTCN_Runtime::send_start_component(text_buf);
}
void f__behaviour__isobus(const COMPONENT& v__ptc1)
{
TTCN_Location current_location("Isobustest.ttcn", 229, TTCN_Location::LOCATION_FUNCTION, "f_behaviour_isobus");
current_location.update_lineno(232);
#line 232 "Isobustest.ttcn"
{
Map_Params tmp_12(0);
TTCN_Runtime::map_port(self, PTC__isobus__CT_component_pt__socketCAN.get_name(), SYSTEM_COMPREF, "pt_socketCAN", tmp_12);
}
current_location.update_lineno(233);
#line 233 "Isobustest.ttcn"
TTCN_Runtime::connect_port(v__ptc1, PTC1__CT_component_pt__isobus.get_name(), self, PTC__isobus__CT_component_pt__isobus.get_name());
current_location.update_lineno(235);
#line 235 "Isobustest.ttcn"
INTEGER v__socket__id;
current_location.update_lineno(236);
#line 236 "Isobustest.ttcn"
SocketCAN__Types::SocketCAN__ifr v__ifr;
current_location.update_lineno(237);
#line 237 "Isobustest.ttcn"
SocketCAN__Types::SocketCAN__send__data__ifu v__ifu;
current_location.update_lineno(239);
#line 239 "Isobustest.ttcn"
SocketCANtest::SocketCAN__open__raw__result res;
current_location.update_lineno(240);
#line 240 "Isobustest.ttcn"
res = f__open__raw2();
current_location.update_lineno(241);
#line 241 "Isobustest.ttcn"
v__socket__id = const_cast< const SocketCANtest::SocketCAN__open__raw__result&>(res).socket__id();
current_location.update_lineno(242);
#line 242 "Isobustest.ttcn"
v__ifr = const_cast< const SocketCANtest::SocketCAN__open__raw__result&>(res).ifr();
current_location.update_lineno(243);
#line 243 "Isobustest.ttcn"
v__ifu.if__name() = const_cast< const SocketCAN__Types::SocketCAN__ifr&>(v__ifr).if__name();
current_location.update_lineno(245);
#line 245 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("socket open(): ");
res.log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(247);
#line 247 "Isobustest.ttcn"
BOOLEAN condition3(TRUE);
for ( ; ; ) {
current_location.update_lineno(250);
#line 250 "Isobustest.ttcn"
if (!condition3) break;
current_location.update_lineno(253);
#line 253 "Isobustest.ttcn"
SocketCAN__Types::SocketCAN__receive__CAN__or__CAN__FD__frame v__result__socketcan;
current_location.update_lineno(256);
#line 256 "Isobustest.ttcn"
{
tmp_17:
alt_status tmp_17_alt_flag_0 = ALT_MAYBE;
alt_status tmp_17_default_flag = ALT_MAYBE;
TTCN_Snapshot::take_new(FALSE);
for ( ; ; ) {
if (tmp_17_alt_flag_0 == ALT_MAYBE) {
current_location.update_lineno(258);
#line 258 "Isobustest.ttcn"
tmp_17_alt_flag_0 = PTC__isobus__CT_component_pt__socketCAN.receive(SocketCAN__Templates::a__SocketCAN__receive__CAN__frame(INTEGER_template(v__socket__id), Can::t__CAN__EFF__FLAG, OCTETSTRING_template(ANY_VALUE)), &(v__result__socketcan), any_compref, NULL, NULL, NULL);
if (tmp_17_alt_flag_0 == ALT_YES) {
current_location.update_lineno(262);
#line 262 "Isobustest.ttcn"
{
boolean tmp_21;
{
boolean tmp_18 = v__result__socketcan.is_bound();
if(tmp_18) {
const SocketCAN__Types::SocketCAN__receive__CAN__or__CAN__FD__frame& tmp_19 = v__result__socketcan;
const SocketCAN__Types::SocketCAN__CAN__or__CAN__FD__frame& tmp_20 = tmp_19.frame();
tmp_18 = tmp_20.is_bound();
if (tmp_18) {
tmp_18 = tmp_20.ischosen(SocketCAN__Types::SocketCAN__CAN__or__CAN__FD__frame::ALT_can__frame);
}
}
tmp_21 = tmp_18;
}
if (tmp_21) {
current_location.update_lineno(263);
#line 263 "Isobustest.ttcn"
Isobus::CAN__frame__j1939 v__CAN__frame__j1939(Isobus::can2j1939frame(const_cast< const SocketCAN__Types::SocketCAN__receive__CAN__or__CAN__FD__frame&>(v__result__socketcan).frame().can__frame()));
current_location.update_lineno(264);
#line 264 "Isobustest.ttcn"
PTC__isobus__CT_component_pt__isobus.send(v__CAN__frame__j1939, v__ptc1, NULL);
}
else {
current_location.update_lineno(266);
#line 266 "Isobustest.ttcn"
TTCN_Runtime::setverdict(INCONC,(TTCN_Logger::begin_event_log2str(),TTCN_Logger::log_event_str("reception of canfd frame not expected"),TTCN_Logger::end_event_log2str()));
}
}
break;
}
}
if (tmp_17_default_flag == ALT_MAYBE) {
tmp_17_default_flag = TTCN_Default::try_altsteps();
if (tmp_17_default_flag == ALT_YES || tmp_17_default_flag == ALT_BREAK) break;
else if (tmp_17_default_flag == ALT_REPEAT) goto tmp_17;
}
current_location.update_lineno(256);
#line 256 "Isobustest.ttcn"
if (tmp_17_alt_flag_0 == ALT_NO && tmp_17_default_flag == ALT_NO) TTCN_error("None of the branches can be chosen in the alt statement in file Isobustest.ttcn between lines 256 and 269.");
TTCN_Snapshot::take_new(TRUE);
}
}
}
current_location.update_lineno(271);
#line 271 "Isobustest.ttcn"
f__close__socket2(v__socket__id);
current_location.update_lineno(272);
#line 272 "Isobustest.ttcn"
TTCN_Runtime::disconnect_port(self, PTC__isobus__CT_component_pt__isobus.get_name(), v__ptc1, PTC1__CT_component_pt__isobus.get_name());
current_location.update_lineno(273);
#line 273 "Isobustest.ttcn"
{
Map_Params tmp_22(0);
TTCN_Runtime::unmap_port(self, PTC__isobus__CT_component_pt__socketCAN.get_name(), SYSTEM_COMPREF, "pt_socketCAN", tmp_22);
}
current_location.update_lineno(274);
#line 274 "Isobustest.ttcn"
TTCN_Runtime::setverdict(PASS);
}
void start_f__behaviour__isobus(const COMPONENT& component_reference, const COMPONENT& v__ptc1)
{
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_behaviour_isobus(");
v__ptc1.log();
TTCN_Logger::log_event_str(") on component ");
component_reference.log();
TTCN_Logger::log_char('.');
TTCN_Logger::end_event();
Text_Buf text_buf;
TTCN_Runtime::prepare_start_component(component_reference, "Isobustest", "f_behaviour_isobus", text_buf);
v__ptc1.encode_text(text_buf);
TTCN_Runtime::send_start_component(text_buf);
}
void f__behaviour1__sync()
{
TTCN_Location current_location("Isobustest.ttcn", 278, TTCN_Location::LOCATION_FUNCTION, "f_behaviour1_sync");
current_location.update_lineno(281);
#line 281 "Isobustest.ttcn"
BOOLEAN condition1(TRUE);
current_location.update_lineno(282);
#line 282 "Isobustest.ttcn"
Isobus::CAN__frame__j1939 v__can__frame__j1939;
for ( ; ; ) {
current_location.update_lineno(285);
#line 285 "Isobustest.ttcn"
if (!condition1) break;
current_location.update_lineno(289);
#line 289 "Isobustest.ttcn"
{
tmp_23:
alt_status tmp_23_alt_flag_0 = ALT_MAYBE;
alt_status tmp_23_default_flag = ALT_MAYBE;
TTCN_Snapshot::take_new(FALSE);
for ( ; ; ) {
if (tmp_23_alt_flag_0 == ALT_MAYBE) {
current_location.update_lineno(295);
#line 295 "Isobustest.ttcn"
tmp_23_alt_flag_0 = PTC1__CT_component_pt__isobus.receive(Isobus::CAN__frame__j1939_template(ANY_VALUE), &(v__can__frame__j1939), any_compref, NULL, NULL, NULL);
if (tmp_23_alt_flag_0 == ALT_YES) break;
}
if (tmp_23_default_flag == ALT_MAYBE) {
tmp_23_default_flag = TTCN_Default::try_altsteps();
if (tmp_23_default_flag == ALT_YES || tmp_23_default_flag == ALT_BREAK) break;
else if (tmp_23_default_flag == ALT_REPEAT) goto tmp_23;
}
current_location.update_lineno(289);
#line 289 "Isobustest.ttcn"
if (tmp_23_alt_flag_0 == ALT_NO && tmp_23_default_flag == ALT_NO) TTCN_error("None of the branches can be chosen in the alt statement in file Isobustest.ttcn between lines 289 and 303.");
TTCN_Snapshot::take_new(TRUE);
}
}
}
}
void start_f__behaviour1__sync(const COMPONENT& component_reference)
{
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_behaviour1_sync(");
TTCN_Logger::log_event_str(") on component ");
component_reference.log();
TTCN_Logger::log_char('.');
TTCN_Logger::end_event();
Text_Buf text_buf;
TTCN_Runtime::prepare_start_component(component_reference, "Isobustest", "f_behaviour1_sync", text_buf);
TTCN_Runtime::send_start_component(text_buf);
}
COMPONENT f__get__component(const OCTETSTRING& connectioninitiator, const OCTETSTRING& connectionresponder)
{
TTCN_Location current_location("Isobustest.ttcn", 307, TTCN_Location::LOCATION_FUNCTION, "f_get_component");
current_location.update_lineno(309);
#line 309 "Isobustest.ttcn"
COMPONENT v__PTC2;
current_location.update_lineno(311);
#line 311 "Isobustest.ttcn"
INTEGER index;
current_location.update_lineno(312);
#line 312 "Isobustest.ttcn"
index = (oct2int(connectioninitiator) + (256 * oct2int(connectionresponder)));
current_location.update_lineno(314);
#line 314 "Isobustest.ttcn"
if ((const_cast< const OpenConnectionsFlags&>(PTC1__CT_component_openConnectionsFlags)[index] == FALSE)) {
current_location.update_lineno(316);
#line 316 "Isobustest.ttcn"
v__PTC2 = TTCN_Runtime::create_component("Isobustest", "PTC2_CT", NULL, NULL, FALSE);
current_location.update_lineno(317);
#line 317 "Isobustest.ttcn"
start_f__behaviour__connections(v__PTC2);
current_location.update_lineno(318);
#line 318 "Isobustest.ttcn"
PTC1__CT_component_openConnectionsFlags[index] = TRUE;
current_location.update_lineno(319);
#line 319 "Isobustest.ttcn"
PTC1__CT_component_openConnections[index] = v__PTC2;
current_location.update_lineno(320);
#line 320 "Isobustest.ttcn"
TTCN_Runtime::connect_port(v__PTC2, PTC2__CT_component_pt__isobus.get_name(), self, PTC1__CT_component_pt__isobus.get_name());
}
else {
current_location.update_lineno(322);
#line 322 "Isobustest.ttcn"
v__PTC2 = const_cast< const OpenConnections&>(PTC1__CT_component_openConnections)[index];
}
current_location.update_lineno(324);
#line 324 "Isobustest.ttcn"
return v__PTC2;
}
void start_f__get__component(const COMPONENT& component_reference, const OCTETSTRING& connectioninitiator, const OCTETSTRING& connectionresponder)
{
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_get_component(");
connectioninitiator.log();
TTCN_Logger::log_event_str(", ");
connectionresponder.log();
TTCN_Logger::log_event_str(") on component ");
component_reference.log();
TTCN_Logger::log_char('.');
TTCN_Logger::end_event();
Text_Buf text_buf;
TTCN_Runtime::prepare_start_component(component_reference, "Isobustest", "f_get_component", text_buf);
connectioninitiator.encode_text(text_buf);
connectionresponder.encode_text(text_buf);
TTCN_Runtime::send_start_component(text_buf);
}
void f__behaviour2__sync()
{
TTCN_Location current_location("Isobustest.ttcn", 329, TTCN_Location::LOCATION_FUNCTION, "f_behaviour2_sync");
current_location.update_lineno(332);
#line 332 "Isobustest.ttcn"
BOOLEAN condition1(TRUE);
current_location.update_lineno(333);
#line 333 "Isobustest.ttcn"
Isobus::CAN__frame__j1939 v__can__frame__j1939;
current_location.update_lineno(337);
#line 337 "Isobustest.ttcn"
INTEGER i;
current_location.update_lineno(338);
#line 338 "Isobustest.ttcn"
i = 1;
current_location.update_lineno(338);
#line 338 "Isobustest.ttcn"
for ( ; ; ) {
current_location.update_lineno(338);
#line 338 "Isobustest.ttcn"
if (!(i <= 65535)) break;
current_location.update_lineno(339);
#line 339 "Isobustest.ttcn"
PTC1__CT_component_openConnectionsFlags[i] = FALSE;
current_location.update_lineno(338);
#line 338 "Isobustest.ttcn"
{
INTEGER tmp_31;
++i;
}
}
for ( ; ; ) {
current_location.update_lineno(347);
#line 347 "Isobustest.ttcn"
if (!condition1) break;
current_location.update_lineno(351);
#line 351 "Isobustest.ttcn"
{
tmp_32:
alt_status tmp_32_alt_flag_0 = ALT_MAYBE;
alt_status tmp_32_alt_flag_1 = ALT_MAYBE;
alt_status tmp_32_alt_flag_2 = ALT_MAYBE;
alt_status tmp_32_alt_flag_3 = ALT_MAYBE;
alt_status tmp_32_alt_flag_4 = ALT_MAYBE;
alt_status tmp_32_alt_flag_5 = ALT_MAYBE;
alt_status tmp_32_alt_flag_6 = ALT_MAYBE;
alt_status tmp_32_default_flag = ALT_MAYBE;
TTCN_Snapshot::take_new(FALSE);
for ( ; ; ) {
if (tmp_32_alt_flag_0 == ALT_MAYBE) {
current_location.update_lineno(356);
#line 356 "Isobustest.ttcn"
{
Isobus::CAN__frame__j1939_template tmp_33;
tmp_33.can__j1939() = ANY_VALUE;
tmp_33.can__pdu().tp__cm().requestToSend() = ANY_VALUE;
tmp_32_alt_flag_0 = PTC1__CT_component_pt__isobus.receive(tmp_33, &(v__can__frame__j1939), any_compref, NULL, NULL, NULL);
}
if (tmp_32_alt_flag_0 == ALT_YES) {
current_location.update_lineno(361);
#line 361 "Isobustest.ttcn"
COMPONENT v__PTC2;
current_location.update_lineno(362);
#line 362 "Isobustest.ttcn"
v__PTC2 = f__get__component(const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().sa(), const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().ps());
current_location.update_lineno(363);
#line 363 "Isobustest.ttcn"
PTC1__CT_component_pt__isobus.send(v__can__frame__j1939, v__PTC2, NULL);
break;
}
}
if (tmp_32_alt_flag_1 == ALT_MAYBE) {
current_location.update_lineno(365);
#line 365 "Isobustest.ttcn"
{
Isobus::CAN__frame__j1939_template tmp_35;
tmp_35.can__j1939() = ANY_VALUE;
tmp_35.can__pdu().tp__cm().clearToSend() = ANY_VALUE;
tmp_32_alt_flag_1 = PTC1__CT_component_pt__isobus.receive(tmp_35, &(v__can__frame__j1939), any_compref, NULL, NULL, NULL);
}
if (tmp_32_alt_flag_1 == ALT_YES) {
current_location.update_lineno(370);
#line 370 "Isobustest.ttcn"
COMPONENT v__PTC2;
current_location.update_lineno(371);
#line 371 "Isobustest.ttcn"
v__PTC2 = f__get__component(const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().ps(), const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().sa());
current_location.update_lineno(372);
#line 372 "Isobustest.ttcn"
PTC1__CT_component_pt__isobus.send(v__can__frame__j1939, v__PTC2, NULL);
break;
}
}
if (tmp_32_alt_flag_2 == ALT_MAYBE) {
current_location.update_lineno(374);
#line 374 "Isobustest.ttcn"
{
Isobus::CAN__frame__j1939_template tmp_37;
tmp_37.can__j1939() = ANY_VALUE;
tmp_37.can__pdu().tp__cm().endOfMessageAcknowledgement() = ANY_VALUE;
tmp_32_alt_flag_2 = PTC1__CT_component_pt__isobus.receive(tmp_37, &(v__can__frame__j1939), any_compref, NULL, NULL, NULL);
}
if (tmp_32_alt_flag_2 == ALT_YES) {
current_location.update_lineno(379);
#line 379 "Isobustest.ttcn"
COMPONENT v__PTC2;
current_location.update_lineno(380);
#line 380 "Isobustest.ttcn"
v__PTC2 = f__get__component(const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().ps(), const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().sa());
current_location.update_lineno(381);
#line 381 "Isobustest.ttcn"
PTC1__CT_component_pt__isobus.send(v__can__frame__j1939, v__PTC2, NULL);
break;
}
}
if (tmp_32_alt_flag_3 == ALT_MAYBE) {
current_location.update_lineno(383);
#line 383 "Isobustest.ttcn"
{
Isobus::CAN__frame__j1939_template tmp_39;
tmp_39.can__j1939() = ANY_VALUE;
tmp_39.can__pdu().tp__cm().connectionAbort() = ANY_VALUE;
tmp_32_alt_flag_3 = PTC1__CT_component_pt__isobus.receive(tmp_39, &(v__can__frame__j1939), any_compref, NULL, NULL, NULL);
}
if (tmp_32_alt_flag_3 == ALT_YES) {
current_location.update_lineno(388);
#line 388 "Isobustest.ttcn"
COMPONENT v__PTC2;
current_location.update_lineno(389);
#line 389 "Isobustest.ttcn"
v__PTC2 = f__get__component(const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().ps(), const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().sa());
current_location.update_lineno(390);
#line 390 "Isobustest.ttcn"
PTC1__CT_component_pt__isobus.send(v__can__frame__j1939, v__PTC2, NULL);
break;
}
}
if (tmp_32_alt_flag_4 == ALT_MAYBE) {
current_location.update_lineno(392);
#line 392 "Isobustest.ttcn"
{
Isobus::CAN__frame__j1939_template tmp_41;
tmp_41.can__j1939() = ANY_VALUE;
tmp_41.can__pdu().tp__cm().broadcastAnnounce() = ANY_VALUE;
tmp_32_alt_flag_4 = PTC1__CT_component_pt__isobus.receive(tmp_41, &(v__can__frame__j1939), any_compref, NULL, NULL, NULL);
}
if (tmp_32_alt_flag_4 == ALT_YES) {
current_location.update_lineno(397);
#line 397 "Isobustest.ttcn"
COMPONENT v__PTC2;
current_location.update_lineno(398);
#line 398 "Isobustest.ttcn"
v__PTC2 = f__get__component(const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().sa(), const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().ps());
current_location.update_lineno(399);
#line 399 "Isobustest.ttcn"
PTC1__CT_component_pt__isobus.send(v__can__frame__j1939, v__PTC2, NULL);
break;
}
}
if (tmp_32_alt_flag_5 == ALT_MAYBE) {
current_location.update_lineno(401);
#line 401 "Isobustest.ttcn"
{
Isobus::CAN__frame__j1939_template tmp_43;
tmp_43.can__j1939() = ANY_VALUE;
tmp_43.can__pdu().tp__dt() = ANY_VALUE;
tmp_32_alt_flag_5 = PTC1__CT_component_pt__isobus.receive(tmp_43, &(v__can__frame__j1939), any_compref, NULL, NULL, NULL);
}
if (tmp_32_alt_flag_5 == ALT_YES) {
current_location.update_lineno(406);
#line 406 "Isobustest.ttcn"
COMPONENT v__PTC2;
current_location.update_lineno(407);
#line 407 "Isobustest.ttcn"
v__PTC2 = f__get__component(const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().sa(), const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().ps());
current_location.update_lineno(408);
#line 408 "Isobustest.ttcn"
PTC1__CT_component_pt__isobus.send(v__can__frame__j1939, v__PTC2, NULL);
break;
}
}
if (tmp_32_alt_flag_6 == ALT_MAYBE) {
current_location.update_lineno(410);
#line 410 "Isobustest.ttcn"
tmp_32_alt_flag_6 = PTC1__CT_component_pt__isobus.receive(Isobus::CAN__frame__j1939_template(ANY_VALUE), &(v__can__frame__j1939), any_compref, NULL, NULL, NULL);
if (tmp_32_alt_flag_6 == ALT_YES) break;
}
if (tmp_32_default_flag == ALT_MAYBE) {
tmp_32_default_flag = TTCN_Default::try_altsteps();
if (tmp_32_default_flag == ALT_YES || tmp_32_default_flag == ALT_BREAK) break;
else if (tmp_32_default_flag == ALT_REPEAT) goto tmp_32;
}
current_location.update_lineno(351);
#line 351 "Isobustest.ttcn"
if (tmp_32_alt_flag_0 == ALT_NO && tmp_32_alt_flag_1 == ALT_NO && tmp_32_alt_flag_2 == ALT_NO && tmp_32_alt_flag_3 == ALT_NO && tmp_32_alt_flag_4 == ALT_NO && tmp_32_alt_flag_5 == ALT_NO && tmp_32_alt_flag_6 == ALT_NO && tmp_32_default_flag == ALT_NO) TTCN_error("None of the branches can be chosen in the alt statement in file Isobustest.ttcn between lines 351 and 418.");
TTCN_Snapshot::take_new(TRUE);
}
}
}
}
void start_f__behaviour2__sync(const COMPONENT& component_reference)
{
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_behaviour2_sync(");
TTCN_Logger::log_event_str(") on component ");
component_reference.log();
TTCN_Logger::log_char('.');
TTCN_Logger::end_event();
Text_Buf text_buf;
TTCN_Runtime::prepare_start_component(component_reference, "Isobustest", "f_behaviour2_sync", text_buf);
TTCN_Runtime::send_start_component(text_buf);
}
void f__behaviour__connections()
{
TTCN_Location current_location("Isobustest.ttcn", 421, TTCN_Location::LOCATION_FUNCTION, "f_behaviour_connections");
current_location.update_lineno(424);
#line 424 "Isobustest.ttcn"
BOOLEAN condition1(TRUE);
current_location.update_lineno(425);
#line 425 "Isobustest.ttcn"
Isobus::CAN__frame__j1939 v__can__frame__j1939;
for ( ; ; ) {
current_location.update_lineno(434);
#line 434 "Isobustest.ttcn"
if (!condition1) break;
current_location.update_lineno(438);
#line 438 "Isobustest.ttcn"
{
tmp_45:
alt_status tmp_45_alt_flag_0 = ALT_MAYBE;
alt_status tmp_45_alt_flag_1 = ALT_MAYBE;
alt_status tmp_45_default_flag = ALT_MAYBE;
TTCN_Snapshot::take_new(FALSE);
for ( ; ; ) {
if (tmp_45_alt_flag_0 == ALT_MAYBE) {
current_location.update_lineno(443);
#line 443 "Isobustest.ttcn"
{
Isobus::CAN__frame__j1939_template tmp_46;
tmp_46.can__j1939() = ANY_VALUE;
tmp_46.can__pdu().tp__cm().requestToSend() = ANY_VALUE;
tmp_45_alt_flag_0 = PTC2__CT_component_pt__isobus.receive(tmp_46, &(v__can__frame__j1939), any_compref, NULL, NULL, NULL);
}
if (tmp_45_alt_flag_0 == ALT_YES) {
current_location.update_lineno(445);
#line 445 "Isobustest.ttcn"
PTC2__CT_component_msgSizeInBytes = const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__pdu().tp__cm().requestToSend().msgSizeInBytes();
current_location.update_lineno(446);
#line 446 "Isobustest.ttcn"
PTC2__CT_component_receivedUnacknowledgedData = os_0;
current_location.update_lineno(447);
#line 447 "Isobustest.ttcn"
PTC2__CT_component_receivedUnacknowledgedMsgSizeInBytes = 0;
current_location.update_lineno(448);
#line 448 "Isobustest.ttcn"
PTC2__CT_component_pgnOfMultiPacketMessage = const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__pdu().tp__cm().requestToSend().pgnOfMultiPacketMessage();
current_location.update_lineno(449);
#line 449 "Isobustest.ttcn"
PTC2__CT_component_ps = const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().ps();
current_location.update_lineno(450);
#line 450 "Isobustest.ttcn"
PTC2__CT_component_sa = const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().sa();
current_location.update_lineno(452);
#line 452 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("received requestToSend: ");
v__can__frame__j1939.log();
const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().sa().log();
const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().ps().log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(453);
#line 453 "Isobustest.ttcn"
{
tmp_53:
alt_status tmp_53_alt_flag_0 = ALT_MAYBE;
alt_status tmp_53_alt_flag_1 = ALT_MAYBE;
alt_status tmp_53_default_flag = ALT_MAYBE;
TTCN_Snapshot::take_new(FALSE);
for ( ; ; ) {
if (tmp_53_alt_flag_0 == ALT_MAYBE) {
current_location.update_lineno(455);
#line 455 "Isobustest.ttcn"
{
Isobus::CAN__frame__j1939_template tmp_54;
tmp_54.can__j1939() = ANY_VALUE;
{
IsobusCMMessageTypes::ClearToSend_template& tmp_55 = tmp_54.can__pdu().tp__cm().clearToSend();
tmp_55.ctrl() = os_1;
tmp_55.totalNumberOfPackets() = ANY_VALUE;
tmp_55.nextPacketNumber() = 1;
tmp_55.reserved4() = ANY_VALUE;
tmp_55.reserved5() = ANY_VALUE;
tmp_55.pgnOfMultiPacketMessage() = ANY_VALUE;
}
tmp_53_alt_flag_0 = PTC2__CT_component_pt__isobus.receive(tmp_54, &(v__can__frame__j1939), any_compref, NULL, NULL, NULL);
}
if (tmp_53_alt_flag_0 == ALT_YES) {
current_location.update_lineno(462);
#line 462 "Isobustest.ttcn"
PTC2__CT_component_nextExpectedPacketNumber = const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__pdu().tp__cm().clearToSend().nextPacketNumber();
current_location.update_lineno(464);
#line 464 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("received clearToSend: ");
v__can__frame__j1939.log();
const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().sa().log();
const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().ps().log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(465);
#line 465 "Isobustest.ttcn"
{
tmp_57:
alt_status tmp_57_alt_flag_0 = ALT_MAYBE;
alt_status tmp_57_alt_flag_1 = ALT_MAYBE;
alt_status tmp_57_alt_flag_2 = ALT_MAYBE;
alt_status tmp_57_default_flag = ALT_MAYBE;
TTCN_Snapshot::take_new(FALSE);
for ( ; ; ) {
if (tmp_57_alt_flag_0 == ALT_MAYBE) {
current_location.update_lineno(467);
#line 467 "Isobustest.ttcn"
{
Isobus::CAN__frame__j1939_template tmp_58;
tmp_58.can__j1939() = ANY_VALUE;
tmp_58.can__pdu().tp__dt() = ANY_VALUE;
tmp_57_alt_flag_0 = PTC2__CT_component_pt__isobus.receive(tmp_58, &(v__can__frame__j1939), any_compref, NULL, NULL, NULL);
}
if (tmp_57_alt_flag_0 == ALT_YES) {
current_location.update_lineno(469);
#line 469 "Isobustest.ttcn"
if (((PTC2__CT_component_msgSizeInBytes - PTC2__CT_component_receivedUnacknowledgedMsgSizeInBytes) > 7)) {
current_location.update_lineno(470);
#line 470 "Isobustest.ttcn"
PTC2__CT_component_tp__dt__can__id = Isobus::j1939id2canid(const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939());
current_location.update_lineno(471);
#line 471 "Isobustest.ttcn"
{
OCTETSTRING tmp_60;
tmp_60 = (PTC2__CT_component_receivedUnacknowledgedData + const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__pdu().tp__dt().data());
PTC2__CT_component_receivedUnacknowledgedData = tmp_60;
}
current_location.update_lineno(472);
#line 472 "Isobustest.ttcn"
{
INTEGER tmp_61;
tmp_61 = (PTC2__CT_component_receivedUnacknowledgedMsgSizeInBytes + 7);
PTC2__CT_component_receivedUnacknowledgedMsgSizeInBytes = tmp_61;
}
current_location.update_lineno(473);
#line 473 "Isobustest.ttcn"
{
INTEGER tmp_62;
++PTC2__CT_component_nextExpectedPacketNumber;
}
}
else {
current_location.update_lineno(475);
#line 475 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("v_can_frame_j1939.can_j1939: ");
const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(476);
#line 476 "Isobustest.ttcn"
PTC2__CT_component_tp__dt__can__id = Isobus::j1939id2canid(const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939());
current_location.update_lineno(477);
#line 477 "Isobustest.ttcn"
{
OCTETSTRING tmp_64;
tmp_64 = (PTC2__CT_component_receivedUnacknowledgedData + substr(const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__pdu().tp__dt().data(), 0, (PTC2__CT_component_msgSizeInBytes - PTC2__CT_component_receivedUnacknowledgedMsgSizeInBytes)));
PTC2__CT_component_receivedUnacknowledgedData = tmp_64;
}
current_location.update_lineno(479);
#line 479 "Isobustest.ttcn"
PTC2__CT_component_nextExpectedPacketNumber = 0;
current_location.update_lineno(480);
#line 480 "Isobustest.ttcn"
PTC2__CT_component_receivedUnacknowledgedMsgSizeInBytes = PTC2__CT_component_msgSizeInBytes;
}
current_location.update_lineno(483);
#line 483 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("received tp_dt: ");
v__can__frame__j1939.log();
const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().sa().log();
const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().ps().log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(484);
#line 484 "Isobustest.ttcn"
goto tmp_57;
}
}
if (tmp_57_alt_flag_1 == ALT_MAYBE) {
current_location.update_lineno(486);
#line 486 "Isobustest.ttcn"
{
Isobus::CAN__frame__j1939_template tmp_67;
tmp_67.can__j1939() = ANY_VALUE;
tmp_67.can__pdu().tp__cm().clearToSend() = ANY_VALUE;
tmp_57_alt_flag_1 = PTC2__CT_component_pt__isobus.receive(tmp_67, &(v__can__frame__j1939), any_compref, NULL, NULL, NULL);
}
if (tmp_57_alt_flag_1 == ALT_YES) {
current_location.update_lineno(489);
#line 489 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("received clearToSend: ");
v__can__frame__j1939.log();
const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().sa().log();
const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().ps().log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(490);
#line 490 "Isobustest.ttcn"
goto tmp_57;
}
}
if (tmp_57_alt_flag_2 == ALT_MAYBE) {
current_location.update_lineno(492);
#line 492 "Isobustest.ttcn"
{
Isobus::CAN__frame__j1939_template tmp_68;
tmp_68.can__j1939() = ANY_VALUE;
tmp_68.can__pdu().tp__cm().endOfMessageAcknowledgement() = ANY_VALUE;
tmp_57_alt_flag_2 = PTC2__CT_component_pt__isobus.receive(tmp_68, &(v__can__frame__j1939), any_compref, NULL, NULL, NULL);
}
if (tmp_57_alt_flag_2 == ALT_YES) {
current_location.update_lineno(495);
#line 495 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("received endOfMessageAcknowledgement: ");
v__can__frame__j1939.log();
const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().sa().log();
const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().ps().log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(496);
#line 496 "Isobustest.ttcn"
if ((PTC2__CT_component_receivedUnacknowledgedMsgSizeInBytes == PTC2__CT_component_msgSizeInBytes)) {
current_location.update_lineno(497);
#line 497 "Isobustest.ttcn"
OCTETSTRING receivedData;
current_location.update_lineno(499);
#line 499 "Isobustest.ttcn"
if ((oct2int(((int2oct(PTC2__CT_component_pgnOfMultiPacketMessage, 3) & os_2) >> 1)) < 240)) {
current_location.update_lineno(500);
#line 500 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("pgnOfMultiPacketMessage: ");
PTC2__CT_component_pgnOfMultiPacketMessage.log();
TTCN_Logger::log_event_str(", ");
int2oct(PTC2__CT_component_pgnOfMultiPacketMessage, 3).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(501);
#line 501 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("ps: ");
PTC2__CT_component_ps.log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(502);
#line 502 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("sa: ");
PTC2__CT_component_sa.log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(503);
#line 503 "Isobustest.ttcn"
receivedData = (((int2oct(oct2int(((int2oct(PTC2__CT_component_pgnOfMultiPacketMessage, 3) & os_3) >> 1)), 2) + PTC2__CT_component_ps) + PTC2__CT_component_sa) + PTC2__CT_component_receivedUnacknowledgedData);
}
else {
current_location.update_lineno(507);
#line 507 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("pgnOfMultiPacketMessage: ");
PTC2__CT_component_pgnOfMultiPacketMessage.log();
TTCN_Logger::log_event_str(", ");
int2oct(PTC2__CT_component_pgnOfMultiPacketMessage, 3).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(508);
#line 508 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("sa: ");
PTC2__CT_component_sa.log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(509);
#line 509 "Isobustest.ttcn"
receivedData = (((int2oct(PTC2__CT_component_pgnOfMultiPacketMessage, 3) & os_3) + PTC2__CT_component_sa) + PTC2__CT_component_receivedUnacknowledgedData);
}
current_location.update_lineno(512);
#line 512 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("tp_dt_can_id: ");
PTC2__CT_component_tp__dt__can__id.log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(519);
#line 519 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("received multipart frame");
receivedData.log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(520);
#line 520 "Isobustest.ttcn"
v__can__frame__j1939 = Isobus::f__decode__CAN__frame__j1939(receivedData);
current_location.update_lineno(521);
#line 521 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("received tp_dt frame j1939: ");
v__can__frame__j1939.log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
}
else {
current_location.update_lineno(524);
#line 524 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("received incomplete message frame: ");
PTC2__CT_component_receivedUnacknowledgedData.log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
}
break;
}
}
if (tmp_57_default_flag == ALT_MAYBE) {
tmp_57_default_flag = TTCN_Default::try_altsteps();
if (tmp_57_default_flag == ALT_YES || tmp_57_default_flag == ALT_BREAK) break;
else if (tmp_57_default_flag == ALT_REPEAT) goto tmp_57;
}
current_location.update_lineno(465);
#line 465 "Isobustest.ttcn"
if (tmp_57_alt_flag_0 == ALT_NO && tmp_57_alt_flag_1 == ALT_NO && tmp_57_alt_flag_2 == ALT_NO && tmp_57_default_flag == ALT_NO) TTCN_error("None of the branches can be chosen in the alt statement in file Isobustest.ttcn between lines 465 and 527.");
TTCN_Snapshot::take_new(TRUE);
}
}
break;
}
}
if (tmp_53_alt_flag_1 == ALT_MAYBE) {
current_location.update_lineno(529);
#line 529 "Isobustest.ttcn"
{
Isobus::CAN__frame__j1939_template tmp_72;
tmp_72.can__j1939() = ANY_VALUE;
tmp_72.can__pdu().tp__cm().connectionAbort() = ANY_VALUE;
tmp_53_alt_flag_1 = PTC2__CT_component_pt__isobus.receive(tmp_72, &(v__can__frame__j1939), any_compref, NULL, NULL, NULL);
}
if (tmp_53_alt_flag_1 == ALT_YES) {
current_location.update_lineno(532);
#line 532 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("received connectionAbort: ");
v__can__frame__j1939.log();
const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().sa().log();
const_cast< const Isobus::CAN__frame__j1939&>(v__can__frame__j1939).can__j1939().ps().log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
break;
}
}
if (tmp_53_default_flag == ALT_MAYBE) {
tmp_53_default_flag = TTCN_Default::try_altsteps();
if (tmp_53_default_flag == ALT_YES || tmp_53_default_flag == ALT_BREAK) break;
else if (tmp_53_default_flag == ALT_REPEAT) goto tmp_53;
}
current_location.update_lineno(453);
#line 453 "Isobustest.ttcn"
if (tmp_53_alt_flag_0 == ALT_NO && tmp_53_alt_flag_1 == ALT_NO && tmp_53_default_flag == ALT_NO) TTCN_error("None of the branches can be chosen in the alt statement in file Isobustest.ttcn between lines 453 and 534.");
TTCN_Snapshot::take_new(TRUE);
}
}
break;
}
}
if (tmp_45_alt_flag_1 == ALT_MAYBE) {
current_location.update_lineno(538);
#line 538 "Isobustest.ttcn"
tmp_45_alt_flag_1 = PTC2__CT_component_pt__isobus.receive(Isobus::CAN__frame__j1939_template(ANY_VALUE), &(v__can__frame__j1939), any_compref, NULL, NULL, NULL);
if (tmp_45_alt_flag_1 == ALT_YES) break;
}
if (tmp_45_default_flag == ALT_MAYBE) {
tmp_45_default_flag = TTCN_Default::try_altsteps();
if (tmp_45_default_flag == ALT_YES || tmp_45_default_flag == ALT_BREAK) break;
else if (tmp_45_default_flag == ALT_REPEAT) goto tmp_45;
}
current_location.update_lineno(438);
#line 438 "Isobustest.ttcn"
if (tmp_45_alt_flag_0 == ALT_NO && tmp_45_alt_flag_1 == ALT_NO && tmp_45_default_flag == ALT_NO) TTCN_error("None of the branches can be chosen in the alt statement in file Isobustest.ttcn between lines 438 and 546.");
TTCN_Snapshot::take_new(TRUE);
}
}
}
}
void start_f__behaviour__connections(const COMPONENT& component_reference)
{
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_behaviour_connections(");
TTCN_Logger::log_event_str(") on component ");
component_reference.log();
TTCN_Logger::log_char('.');
TTCN_Logger::end_event();
Text_Buf text_buf;
TTCN_Runtime::prepare_start_component(component_reference, "Isobustest", "f_behaviour_connections", text_buf);
TTCN_Runtime::send_start_component(text_buf);
}
verdicttype testcase_tc__encdec(boolean has_timer, double timer_value)
{
TTCN_Runtime::check_begin_testcase(has_timer, timer_value);
TTCN_Location current_location("Isobustest.ttcn", 551, TTCN_Location::LOCATION_TESTCASE, "tc_encdec");
try {
TTCN_Runtime::begin_testcase("Isobustest", "tc_encdec", "Isobustest", "MTC_CT", "Isobustest", "MTC_CT", has_timer, timer_value);
current_location.update_lineno(555);
#line 555 "Isobustest.ttcn"
Isobus::CAN__frame__j1939_template t__CAN__frame__j1939;
{
Isobus::J1939_template& tmp_73 = t__CAN__frame__j1939.can__j1939();
tmp_73.prio() = bs_0;
tmp_73.res() = bs_1;
tmp_73.dp() = bs_2;
tmp_73.pf() = os_4;
tmp_73.ps() = os_5;
tmp_73.sa() = os_6;
}
{
IsobusNMMessageTypes::NAME_template& tmp_74 = t__CAN__frame__j1939.can__pdu().addressClaimed().name();
tmp_74.selfConfigurableAddressValue() = bs_1;
tmp_74.industryGroupValue() = bs_3;
tmp_74.deviceClassInstanceValue() = bs_4;
tmp_74.deviceClassValue() = bs_5;
tmp_74.reserveValued() = bs_1;
tmp_74.functionValue() = bs_6;
tmp_74.functionInstanceValue() = bs_7;
tmp_74.ecuInstancceValue() = bs_8;
tmp_74.manufacturerCodeValue() = bs_9;
tmp_74.identityNumberBits() = bs_10;
}
current_location.update_lineno(557);
#line 557 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof()).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(558);
#line 558 "Isobustest.ttcn"
TTCN_Logger::log_str(TTCN_USER, "--------------------------------------------");
current_location.update_lineno(559);
#line 559 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__decode__CAN__frame__j1939(Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof())).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(560);
#line 560 "Isobustest.ttcn"
TTCN_Logger::log_str(TTCN_USER, "--------------------------------------------");
current_location.update_lineno(562);
#line 562 "Isobustest.ttcn"
Isobus::CAN__frame__j1939_template t__CAN__frame__j1939__2;
{
Isobus::J1939_template& tmp_75 = t__CAN__frame__j1939__2.can__j1939();
tmp_75.prio() = bs_11;
tmp_75.res() = bs_1;
tmp_75.dp() = bs_1;
tmp_75.pf() = os_7;
tmp_75.ps() = os_5;
tmp_75.sa() = os_8;
}
t__CAN__frame__j1939__2.can__pdu().requestForAddressClaimed().pgn() = 123;
current_location.update_lineno(563);
#line 563 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939__2.valueof()).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(564);
#line 564 "Isobustest.ttcn"
TTCN_Logger::log_str(TTCN_USER, "--------------------------------------------");
current_location.update_lineno(565);
#line 565 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__decode__CAN__frame__j1939(Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939__2.valueof())).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(566);
#line 566 "Isobustest.ttcn"
TTCN_Logger::log_str(TTCN_USER, "--------------------------------------------");
current_location.update_lineno(568);
#line 568 "Isobustest.ttcn"
Isobus::CAN__frame__j1939_template t__CAN__frame__j1939__3;
{
Isobus::J1939_template& tmp_76 = t__CAN__frame__j1939__3.can__j1939();
tmp_76.prio() = bs_11;
tmp_76.res() = bs_1;
tmp_76.dp() = bs_1;
tmp_76.pf() = os_7;
tmp_76.ps() = os_5;
tmp_76.sa() = os_8;
}
{
IsobusNMMessageTypes::NAME_template& tmp_77 = t__CAN__frame__j1939__3.can__pdu().cannotClaimSourceAddress().name();
tmp_77.selfConfigurableAddressValue() = bs_1;
tmp_77.industryGroupValue() = bs_3;
tmp_77.deviceClassInstanceValue() = bs_4;
tmp_77.deviceClassValue() = bs_5;
tmp_77.reserveValued() = bs_1;
tmp_77.functionValue() = bs_6;
tmp_77.functionInstanceValue() = bs_7;
tmp_77.ecuInstancceValue() = bs_8;
tmp_77.manufacturerCodeValue() = bs_9;
tmp_77.identityNumberBits() = bs_10;
}
current_location.update_lineno(569);
#line 569 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939__3.valueof()).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(570);
#line 570 "Isobustest.ttcn"
TTCN_Logger::log_str(TTCN_USER, "--------------------------------------------");
current_location.update_lineno(571);
#line 571 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__decode__CAN__frame__j1939(Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939__3.valueof())).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(572);
#line 572 "Isobustest.ttcn"
TTCN_Logger::log_str(TTCN_USER, "--------------------------------------------");
current_location.update_lineno(574);
#line 574 "Isobustest.ttcn"
Isobus::CAN__frame__j1939_template t__CAN__frame__j1939__6;
{
Isobus::J1939_template& tmp_78 = t__CAN__frame__j1939__6.can__j1939();
tmp_78.prio() = bs_0;
tmp_78.res() = bs_1;
tmp_78.dp() = bs_2;
tmp_78.pf() = os_6;
tmp_78.ps() = os_5;
tmp_78.sa() = os_7;
}
{
IsobusNMMessageTypes::CommandedAddress_template& tmp_79 = t__CAN__frame__j1939__6.can__pdu().commandedAddress();
{
IsobusNMMessageTypes::NAME_template& tmp_80 = tmp_79.name();
tmp_80.selfConfigurableAddressValue() = bs_1;
tmp_80.industryGroupValue() = bs_3;
tmp_80.deviceClassInstanceValue() = bs_4;
tmp_80.deviceClassValue() = bs_5;
tmp_80.reserveValued() = bs_1;
tmp_80.functionValue() = bs_6;
tmp_80.functionInstanceValue() = bs_7;
tmp_80.ecuInstancceValue() = bs_8;
tmp_80.manufacturerCodeValue() = bs_9;
tmp_80.identityNumberBits() = bs_10;
}
tmp_79.newSourceAddress() = os_9;
}
current_location.update_lineno(578);
#line 578 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939__6.valueof()).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(579);
#line 579 "Isobustest.ttcn"
TTCN_Logger::log_str(TTCN_USER, "--------------------------------------------");
current_location.update_lineno(580);
#line 580 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__decode__CAN__frame__j1939(Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939__6.valueof())).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(581);
#line 581 "Isobustest.ttcn"
TTCN_Logger::log_str(TTCN_USER, "--------------------------------------------");
} catch (const TC_Error& tc_error) {
} catch (const TC_End& tc_end) {
TTCN_Logger::log_str(TTCN_FUNCTION, "Test case tc_encdec was stopped.");
}
return TTCN_Runtime::end_testcase();
}
verdicttype testcase_tc__encdec__vt2ecu__vtStatusReq(boolean has_timer, double timer_value)
{
TTCN_Runtime::check_begin_testcase(has_timer, timer_value);
TTCN_Location current_location("Isobustest.ttcn", 584, TTCN_Location::LOCATION_TESTCASE, "tc_encdec_vt2ecu_vtStatusReq");
try {
TTCN_Runtime::begin_testcase("Isobustest", "tc_encdec_vt2ecu_vtStatusReq", "Isobustest", "MTC_CT", "Isobustest", "MTC_CT", has_timer, timer_value);
current_location.update_lineno(586);
#line 586 "Isobustest.ttcn"
Isobus::CAN__frame__j1939_template t__CAN__frame__j1939;
{
Isobus::J1939_template& tmp_81 = t__CAN__frame__j1939.can__j1939();
tmp_81.prio() = bs_11;
tmp_81.res() = bs_1;
tmp_81.dp() = bs_1;
tmp_81.pf() = os_7;
tmp_81.ps() = os_7;
tmp_81.sa() = os_7;
}
{
IsobusVTMessageTypes::VTStatusReq_template& tmp_82 = t__CAN__frame__j1939.can__pdu().vt2ecu().vtStatusReq();
tmp_82.vtfunction() = 254;
tmp_82.sourceAddressOfActiveWorkingSetMaster() = os_1;
tmp_82.objectIDOfTheVisibleDataAlarmMaskOfTheActiveWorkingSet() = os_10;
tmp_82.objectIDOfTheVisibleSoftKeyMaskOfTheActiveWorkingSet() = os_11;
tmp_82.vtBusyCodes() = IsobusVTMessageTypes::e__BusyCodes::vtIsBusyExecutingACommand;
tmp_82.vtFunctionCode() = os_12;
}
current_location.update_lineno(594);
#line 594 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof()).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(595);
#line 595 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__decode__CAN__frame__j1939(Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof())).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
} catch (const TC_Error& tc_error) {
} catch (const TC_End& tc_end) {
TTCN_Logger::log_str(TTCN_FUNCTION, "Test case tc_encdec_vt2ecu_vtStatusReq was stopped.");
}
return TTCN_Runtime::end_testcase();
}
verdicttype testcase_tc__encdec__ecu2vt__getMemoryReq(boolean has_timer, double timer_value)
{
TTCN_Runtime::check_begin_testcase(has_timer, timer_value);
TTCN_Location current_location("Isobustest.ttcn", 598, TTCN_Location::LOCATION_TESTCASE, "tc_encdec_ecu2vt_getMemoryReq");
try {
TTCN_Runtime::begin_testcase("Isobustest", "tc_encdec_ecu2vt_getMemoryReq", "Isobustest", "MTC_CT", "Isobustest", "MTC_CT", has_timer, timer_value);
current_location.update_lineno(600);
#line 600 "Isobustest.ttcn"
Isobus::CAN__frame__j1939_template t__CAN__frame__j1939;
{
Isobus::J1939_template& tmp_83 = t__CAN__frame__j1939.can__j1939();
tmp_83.prio() = bs_11;
tmp_83.res() = bs_1;
tmp_83.dp() = bs_1;
tmp_83.pf() = os_7;
tmp_83.ps() = os_7;
tmp_83.sa() = os_7;
}
{
IsobusVTMessageTypes::GetMemoryReq_template& tmp_84 = t__CAN__frame__j1939.can__pdu().ecu2vt().getMemoryReq();
tmp_84.vtfunction() = 194;
tmp_84.reserved2() = os_13;
tmp_84.memoryRequired() = 1234567;
tmp_84.reserved7() = os_13;
tmp_84.reserved8() = os_13;
}
current_location.update_lineno(607);
#line 607 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof()).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(608);
#line 608 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__decode__CAN__frame__j1939(Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof())).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
} catch (const TC_Error& tc_error) {
} catch (const TC_End& tc_end) {
TTCN_Logger::log_str(TTCN_FUNCTION, "Test case tc_encdec_ecu2vt_getMemoryReq was stopped.");
}
return TTCN_Runtime::end_testcase();
}
verdicttype testcase_tc__encdec__ecu2vt__getMemoryReq__with__templateI(boolean has_timer, double timer_value)
{
TTCN_Runtime::check_begin_testcase(has_timer, timer_value);
TTCN_Location current_location("Isobustest.ttcn", 611, TTCN_Location::LOCATION_TESTCASE, "tc_encdec_ecu2vt_getMemoryReq_with_templateI");
try {
TTCN_Runtime::begin_testcase("Isobustest", "tc_encdec_ecu2vt_getMemoryReq_with_templateI", "Isobustest", "MTC_CT", "Isobustest", "MTC_CT", has_timer, timer_value);
current_location.update_lineno(613);
#line 613 "Isobustest.ttcn"
Isobus::CAN__frame__j1939_template t__CAN__frame__j1939;
{
Isobus::J1939_template& tmp_85 = t__CAN__frame__j1939.can__j1939();
tmp_85.prio() = bs_11;
tmp_85.res() = bs_1;
tmp_85.dp() = bs_1;
tmp_85.pf() = os_7;
tmp_85.ps() = os_7;
tmp_85.sa() = os_7;
}
t__CAN__frame__j1939.can__pdu().ecu2vt().getMemoryReq() = Isobus__Templates::t__GetMemoryReq(1234567);
current_location.update_lineno(615);
#line 615 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof()).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(616);
#line 616 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__decode__CAN__frame__j1939(Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof())).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
} catch (const TC_Error& tc_error) {
} catch (const TC_End& tc_end) {
TTCN_Logger::log_str(TTCN_FUNCTION, "Test case tc_encdec_ecu2vt_getMemoryReq_with_templateI was stopped.");
}
return TTCN_Runtime::end_testcase();
}
verdicttype testcase_tc__encdec__ecu2vt__getMemoryReq__with__template__II(boolean has_timer, double timer_value)
{
TTCN_Runtime::check_begin_testcase(has_timer, timer_value);
TTCN_Location current_location("Isobustest.ttcn", 619, TTCN_Location::LOCATION_TESTCASE, "tc_encdec_ecu2vt_getMemoryReq_with_template_II");
try {
TTCN_Runtime::begin_testcase("Isobustest", "tc_encdec_ecu2vt_getMemoryReq_with_template_II", "Isobustest", "MTC_CT", "Isobustest", "MTC_CT", has_timer, timer_value);
current_location.update_lineno(621);
#line 621 "Isobustest.ttcn"
Isobus::CAN__frame__j1939_template t__CAN__frame__j1939;
{
Isobus::J1939_template& tmp_86 = t__CAN__frame__j1939.can__j1939();
tmp_86.prio() = bs_11;
tmp_86.res() = bs_1;
tmp_86.dp() = bs_1;
tmp_86.pf() = os_7;
tmp_86.ps() = os_7;
tmp_86.sa() = os_7;
}
t__CAN__frame__j1939.can__pdu() = Isobus__Templates::t__GetMemoryReq__pdu(1234567);
current_location.update_lineno(623);
#line 623 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof()).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(624);
#line 624 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__decode__CAN__frame__j1939(Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof())).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
} catch (const TC_Error& tc_error) {
} catch (const TC_End& tc_end) {
TTCN_Logger::log_str(TTCN_FUNCTION, "Test case tc_encdec_ecu2vt_getMemoryReq_with_template_II was stopped.");
}
return TTCN_Runtime::end_testcase();
}
verdicttype testcase_tc__encdec__networkMessage__N__SP__Response__pdu__with__template(boolean has_timer, double timer_value)
{
TTCN_Runtime::check_begin_testcase(has_timer, timer_value);
TTCN_Location current_location("Isobustest.ttcn", 627, TTCN_Location::LOCATION_TESTCASE, "tc_encdec_networkMessage_N_SP_Response_pdu_with_template");
try {
TTCN_Runtime::begin_testcase("Isobustest", "tc_encdec_networkMessage_N_SP_Response_pdu_with_template", "Isobustest", "MTC_CT", "Isobustest", "MTC_CT", has_timer, timer_value);
current_location.update_lineno(629);
#line 629 "Isobustest.ttcn"
Isobus::CAN__frame__j1939_template t__CAN__frame__j1939;
{
IsobusNMMessageTypes::N__SP__Response_requestedParametrics_template tmp_87;
tmp_87.set_size(7);
tmp_87[0] = os_17;
tmp_87[1] = os_18;
tmp_87[2] = os_19;
tmp_87[3] = os_20;
tmp_87[4] = os_21;
tmp_87[5] = os_22;
tmp_87[6] = os_23;
t__CAN__frame__j1939 = Isobus__Templates::t__message(bs_12, bs_2, bs_1, os_14, os_15, os_16, Isobus__Templates::t__N__SP__Response__pdu(IsobusNMMessageTypes::e__PortNumber_template(IsobusNMMessageTypes::e__PortNumber::port__3), IsobusNMMessageTypes::e__PortNumber_template(IsobusNMMessageTypes::e__PortNumber::port__4), tmp_87));
}
current_location.update_lineno(631);
#line 631 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof()).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(632);
#line 632 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__decode__CAN__frame__j1939(Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof())).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
} catch (const TC_Error& tc_error) {
} catch (const TC_End& tc_end) {
TTCN_Logger::log_str(TTCN_FUNCTION, "Test case tc_encdec_networkMessage_N_SP_Response_pdu_with_template was stopped.");
}
return TTCN_Runtime::end_testcase();
}
verdicttype testcase_tc__encdec__networkMessage__N__SP__Response__with__template(boolean has_timer, double timer_value)
{
TTCN_Runtime::check_begin_testcase(has_timer, timer_value);
TTCN_Location current_location("Isobustest.ttcn", 635, TTCN_Location::LOCATION_TESTCASE, "tc_encdec_networkMessage_N_SP_Response_with_template");
try {
TTCN_Runtime::begin_testcase("Isobustest", "tc_encdec_networkMessage_N_SP_Response_with_template", "Isobustest", "MTC_CT", "Isobustest", "MTC_CT", has_timer, timer_value);
current_location.update_lineno(637);
#line 637 "Isobustest.ttcn"
Isobus::CAN__frame__j1939_template t__CAN__frame__j1939;
{
IsobusNMMessageTypes::NetworkMessage_template tmp_88;
{
IsobusNMMessageTypes::N__SP__Response_requestedParametrics_template tmp_89;
tmp_89.set_size(7);
tmp_89[0] = os_17;
tmp_89[1] = os_18;
tmp_89[2] = os_19;
tmp_89[3] = os_20;
tmp_89[4] = os_21;
tmp_89[5] = os_22;
tmp_89[6] = os_23;
tmp_88.n__SP__Response() = Isobus__Templates::t__N__SP__Response(IsobusNMMessageTypes::e__PortNumber_template(IsobusNMMessageTypes::e__PortNumber::port__3), IsobusNMMessageTypes::e__PortNumber_template(IsobusNMMessageTypes::e__PortNumber::port__4), tmp_89);
}
t__CAN__frame__j1939 = Isobus__Templates::t__network__message(bs_12, bs_2, bs_1, os_14, os_15, os_16, tmp_88);
}
current_location.update_lineno(639);
#line 639 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof()).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(640);
#line 640 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__decode__CAN__frame__j1939(Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof())).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
} catch (const TC_Error& tc_error) {
} catch (const TC_End& tc_end) {
TTCN_Logger::log_str(TTCN_FUNCTION, "Test case tc_encdec_networkMessage_N_SP_Response_with_template was stopped.");
}
return TTCN_Runtime::end_testcase();
}
verdicttype testcase_tc__encdec__N__SP__Response__with__template(boolean has_timer, double timer_value)
{
TTCN_Runtime::check_begin_testcase(has_timer, timer_value);
TTCN_Location current_location("Isobustest.ttcn", 643, TTCN_Location::LOCATION_TESTCASE, "tc_encdec_N_SP_Response_with_template");
try {
TTCN_Runtime::begin_testcase("Isobustest", "tc_encdec_N_SP_Response_with_template", "Isobustest", "MTC_CT", "Isobustest", "MTC_CT", has_timer, timer_value);
current_location.update_lineno(645);
#line 645 "Isobustest.ttcn"
Isobus::CAN__frame__j1939_template t__CAN__frame__j1939;
{
Isobus::AnyIsoBusPdu_template tmp_90;
{
IsobusNMMessageTypes::N__SP__Response_requestedParametrics_template tmp_91;
tmp_91.set_size(7);
tmp_91[0] = os_17;
tmp_91[1] = os_18;
tmp_91[2] = os_19;
tmp_91[3] = os_20;
tmp_91[4] = os_21;
tmp_91[5] = os_22;
tmp_91[6] = os_23;
tmp_90.networkMessage().n__SP__Response() = Isobus__Templates::t__N__SP__Response(IsobusNMMessageTypes::e__PortNumber_template(IsobusNMMessageTypes::e__PortNumber::port__3), IsobusNMMessageTypes::e__PortNumber_template(IsobusNMMessageTypes::e__PortNumber::port__4), tmp_91);
}
t__CAN__frame__j1939 = Isobus__Templates::t__message(bs_12, bs_2, bs_1, os_14, os_15, os_16, tmp_90);
}
current_location.update_lineno(647);
#line 647 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof()).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(648);
#line 648 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__decode__CAN__frame__j1939(Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof())).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
} catch (const TC_Error& tc_error) {
} catch (const TC_End& tc_end) {
TTCN_Logger::log_str(TTCN_FUNCTION, "Test case tc_encdec_N_SP_Response_with_template was stopped.");
}
return TTCN_Runtime::end_testcase();
}
verdicttype testcase_tc__encdec__ecu2vt__workingSetMaintenanceReq(boolean has_timer, double timer_value)
{
TTCN_Runtime::check_begin_testcase(has_timer, timer_value);
TTCN_Location current_location("Isobustest.ttcn", 651, TTCN_Location::LOCATION_TESTCASE, "tc_encdec_ecu2vt_workingSetMaintenanceReq");
try {
TTCN_Runtime::begin_testcase("Isobustest", "tc_encdec_ecu2vt_workingSetMaintenanceReq", "Isobustest", "MTC_CT", "Isobustest", "MTC_CT", has_timer, timer_value);
current_location.update_lineno(653);
#line 653 "Isobustest.ttcn"
Isobus::CAN__frame__j1939_template t__CAN__frame__j1939;
{
Isobus::J1939_template& tmp_92 = t__CAN__frame__j1939.can__j1939();
tmp_92.prio() = bs_11;
tmp_92.res() = bs_1;
tmp_92.dp() = bs_1;
tmp_92.pf() = os_7;
tmp_92.ps() = os_7;
tmp_92.sa() = os_7;
}
{
IsobusVTMessageTypes::WorkingSetMaintenanceBitMask tmp_93;
tmp_93.initiatingWorkingSetMaintenance() = TRUE;
tmp_93.reserved1() = FALSE;
tmp_93.reserved2() = FALSE;
tmp_93.reserved3() = FALSE;
tmp_93.reserved4() = FALSE;
tmp_93.reserved5() = FALSE;
tmp_93.reserved6() = FALSE;
tmp_93.reserved7() = FALSE;
t__CAN__frame__j1939.can__pdu() = Isobus__Templates::t__WorkingSetMaintenanceReq__pdu(tmp_93, IsobusVTMessageTypes::e__WorkingSetMaintenanceVersionNumber::compliantWithVTVersion4);
}
current_location.update_lineno(663);
#line 663 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof()).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(664);
#line 664 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__decode__CAN__frame__j1939(Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof())).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
} catch (const TC_Error& tc_error) {
} catch (const TC_End& tc_end) {
TTCN_Logger::log_str(TTCN_FUNCTION, "Test case tc_encdec_ecu2vt_workingSetMaintenanceReq was stopped.");
}
return TTCN_Runtime::end_testcase();
}
verdicttype testcase_tc__encdec__etp__dt(boolean has_timer, double timer_value)
{
TTCN_Runtime::check_begin_testcase(has_timer, timer_value);
TTCN_Location current_location("Isobustest.ttcn", 668, TTCN_Location::LOCATION_TESTCASE, "tc_encdec_etp_dt");
try {
TTCN_Runtime::begin_testcase("Isobustest", "tc_encdec_etp_dt", "Isobustest", "MTC_CT", "Isobustest", "MTC_CT", has_timer, timer_value);
current_location.update_lineno(670);
#line 670 "Isobustest.ttcn"
Isobus::CAN__frame__j1939_template t__CAN__frame__j1939;
{
Isobus::J1939_template& tmp_94 = t__CAN__frame__j1939.can__j1939();
tmp_94.prio() = bs_11;
tmp_94.res() = bs_2;
tmp_94.dp() = bs_2;
tmp_94.pf() = os_24;
tmp_94.ps() = os_7;
tmp_94.sa() = os_25;
}
{
IsobusCMMessageTypes::ETP__DT_template& tmp_95 = t__CAN__frame__j1939.can__pdu().etp__dt();
tmp_95.seq__no() = 105;
tmp_95.data() = os_26;
}
current_location.update_lineno(672);
#line 672 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof()).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(673);
#line 673 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__decode__CAN__frame__j1939(Isobus::f__encode__CAN__frame__j1939(t__CAN__frame__j1939.valueof())).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
} catch (const TC_Error& tc_error) {
} catch (const TC_End& tc_end) {
TTCN_Logger::log_str(TTCN_FUNCTION, "Test case tc_encdec_etp_dt was stopped.");
}
return TTCN_Runtime::end_testcase();
}
verdicttype testcase_tc__dec__requestForAddressClaimed(boolean has_timer, double timer_value)
{
TTCN_Runtime::check_begin_testcase(has_timer, timer_value);
TTCN_Location current_location("Isobustest.ttcn", 677, TTCN_Location::LOCATION_TESTCASE, "tc_dec_requestForAddressClaimed");
try {
TTCN_Runtime::begin_testcase("Isobustest", "tc_dec_requestForAddressClaimed", "Isobustest", "MTC_CT", "Isobustest", "MTC_CT", has_timer, timer_value);
current_location.update_lineno(680);
#line 680 "Isobustest.ttcn"
OCTETSTRING j1939__pdu;
current_location.update_lineno(681);
#line 681 "Isobustest.ttcn"
j1939__pdu = os_27;
current_location.update_lineno(683);
#line 683 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
j1939__pdu.log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(684);
#line 684 "Isobustest.ttcn"
TTCN_Logger::log_str(TTCN_USER, "--------------------------------------------");
current_location.update_lineno(685);
#line 685 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__decode__CAN__frame__j1939(j1939__pdu).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(686);
#line 686 "Isobustest.ttcn"
TTCN_Logger::log_str(TTCN_USER, "--------------------------------------------");
} catch (const TC_Error& tc_error) {
} catch (const TC_End& tc_end) {
TTCN_Logger::log_str(TTCN_FUNCTION, "Test case tc_dec_requestForAddressClaimed was stopped.");
}
return TTCN_Runtime::end_testcase();
}
verdicttype testcase_tc__dec__largemessage(boolean has_timer, double timer_value)
{
TTCN_Runtime::check_begin_testcase(has_timer, timer_value);
TTCN_Location current_location("Isobustest.ttcn", 691, TTCN_Location::LOCATION_TESTCASE, "tc_dec_largemessage");
try {
TTCN_Runtime::begin_testcase("Isobustest", "tc_dec_largemessage", "Isobustest", "MTC_CT", "Isobustest", "MTC_CT", has_timer, timer_value);
current_location.update_lineno(694);
#line 694 "Isobustest.ttcn"
OCTETSTRING j1939__pdu;
current_location.update_lineno(699);
#line 699 "Isobustest.ttcn"
j1939__pdu = os_28;
current_location.update_lineno(717);
#line 717 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
j1939__pdu.log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(718);
#line 718 "Isobustest.ttcn"
TTCN_Logger::log_str(TTCN_USER, "--------------------------------------------");
current_location.update_lineno(719);
#line 719 "Isobustest.ttcn"
try {
TTCN_Logger::begin_event(TTCN_USER);
Isobus::f__decode__CAN__frame__j1939(j1939__pdu).log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(720);
#line 720 "Isobustest.ttcn"
TTCN_Logger::log_str(TTCN_USER, "--------------------------------------------");
} catch (const TC_Error& tc_error) {
} catch (const TC_End& tc_end) {
TTCN_Logger::log_str(TTCN_FUNCTION, "Test case tc_dec_largemessage was stopped.");
}
return TTCN_Runtime::end_testcase();
}
verdicttype testcase_tc__Example001(boolean has_timer, double timer_value)
{
TTCN_Runtime::check_begin_testcase(has_timer, timer_value);
TTCN_Location current_location("Isobustest.ttcn", 724, TTCN_Location::LOCATION_TESTCASE, "tc_Example001");
try {
TTCN_Runtime::begin_testcase("Isobustest", "tc_Example001", "Isobustest", "MTC_CT", "Isobustest", "MTC_CT", has_timer, timer_value);
current_location.update_lineno(727);
#line 727 "Isobustest.ttcn"
COMPONENT v__PTC__isobus;
current_location.update_lineno(728);
#line 728 "Isobustest.ttcn"
COMPONENT v__PTC1;
current_location.update_lineno(731);
#line 731 "Isobustest.ttcn"
v__PTC__isobus = TTCN_Runtime::create_component("Isobustest", "PTC_isobus_CT", NULL, NULL, FALSE);
current_location.update_lineno(732);
#line 732 "Isobustest.ttcn"
v__PTC1 = TTCN_Runtime::create_component("Isobustest", "PTC1_CT", NULL, NULL, FALSE);
current_location.update_lineno(739);
#line 739 "Isobustest.ttcn"
start_f__behaviour1__sync(v__PTC1);
current_location.update_lineno(740);
#line 740 "Isobustest.ttcn"
start_f__behaviour__isobus(v__PTC__isobus, v__PTC1);
current_location.update_lineno(743);
#line 743 "Isobustest.ttcn"
{
tmp_100:
alt_status alt_flag = ALT_UNCHECKED, default_flag = ALT_UNCHECKED;
TTCN_Snapshot::take_new(FALSE);
for ( ; ; ) {
if (alt_flag != ALT_NO) {
alt_flag = TTCN_Runtime::component_done(ALL_COMPREF);
if (alt_flag == ALT_YES) break;
else if (alt_flag == ALT_REPEAT) goto tmp_100;
}
if (default_flag != ALT_NO) {
default_flag = TTCN_Default::try_altsteps();
if (default_flag == ALT_YES || default_flag == ALT_BREAK) break;
else if (default_flag == ALT_REPEAT) goto tmp_100;
}
current_location.update_lineno(743);
#line 743 "Isobustest.ttcn"
if (alt_flag == ALT_NO && default_flag == ALT_NO) TTCN_error("Stand-alone done statement failed in file Isobustest.ttcn, line 743.");
TTCN_Snapshot::take_new(TRUE);
}
}
current_location.update_lineno(749);
#line 749 "Isobustest.ttcn"
TTCN_Runtime::kill_component(ALL_COMPREF);
} catch (const TC_Error& tc_error) {
} catch (const TC_End& tc_end) {
TTCN_Logger::log_str(TTCN_FUNCTION, "Test case tc_Example001 was stopped.");
}
return TTCN_Runtime::end_testcase();
}
verdicttype testcase_tc__Example002(boolean has_timer, double timer_value)
{
TTCN_Runtime::check_begin_testcase(has_timer, timer_value);
TTCN_Location current_location("Isobustest.ttcn", 756, TTCN_Location::LOCATION_TESTCASE, "tc_Example002");
try {
TTCN_Runtime::begin_testcase("Isobustest", "tc_Example002", "Isobustest", "MTC_CT", "Isobustest", "MTC_CT", has_timer, timer_value);
current_location.update_lineno(759);
#line 759 "Isobustest.ttcn"
COMPONENT v__PTC__isobus;
current_location.update_lineno(760);
#line 760 "Isobustest.ttcn"
COMPONENT v__PTC1;
current_location.update_lineno(763);
#line 763 "Isobustest.ttcn"
v__PTC__isobus = TTCN_Runtime::create_component("Isobustest", "PTC_isobus_CT", NULL, NULL, FALSE);
current_location.update_lineno(764);
#line 764 "Isobustest.ttcn"
v__PTC1 = TTCN_Runtime::create_component("Isobustest", "PTC1_CT", NULL, NULL, FALSE);
current_location.update_lineno(771);
#line 771 "Isobustest.ttcn"
start_f__behaviour2__sync(v__PTC1);
current_location.update_lineno(772);
#line 772 "Isobustest.ttcn"
start_f__behaviour__isobus(v__PTC__isobus, v__PTC1);
current_location.update_lineno(775);
#line 775 "Isobustest.ttcn"
{
tmp_103:
alt_status alt_flag = ALT_UNCHECKED, default_flag = ALT_UNCHECKED;
TTCN_Snapshot::take_new(FALSE);
for ( ; ; ) {
if (alt_flag != ALT_NO) {
alt_flag = TTCN_Runtime::component_done(ALL_COMPREF);
if (alt_flag == ALT_YES) break;
else if (alt_flag == ALT_REPEAT) goto tmp_103;
}
if (default_flag != ALT_NO) {
default_flag = TTCN_Default::try_altsteps();
if (default_flag == ALT_YES || default_flag == ALT_BREAK) break;
else if (default_flag == ALT_REPEAT) goto tmp_103;
}
current_location.update_lineno(775);
#line 775 "Isobustest.ttcn"
if (alt_flag == ALT_NO && default_flag == ALT_NO) TTCN_error("Stand-alone done statement failed in file Isobustest.ttcn, line 775.");
TTCN_Snapshot::take_new(TRUE);
}
}
current_location.update_lineno(781);
#line 781 "Isobustest.ttcn"
TTCN_Runtime::kill_component(ALL_COMPREF);
} catch (const TC_Error& tc_error) {
} catch (const TC_End& tc_end) {
TTCN_Logger::log_str(TTCN_FUNCTION, "Test case tc_Example002 was stopped.");
}
return TTCN_Runtime::end_testcase();
}
/* Bodies of static functions */
static void pre_init_module()
{
TTCN_Location current_location("Isobustest.ttcn", 0, TTCN_Location::LOCATION_UNKNOWN, "Isobustest");
CanError::module_object.pre_init_module();
SocketCANtest::module_object.pre_init_module();
Isobus__Templates::module_object.pre_init_module();
current_location.update_lineno(75);
#line 75 "Isobustest.ttcn"
const_MAX__CONNECTIONS = 65535;
module_object.add_function("f_open_socket2", (genericfunc_t)&f__open__socket2, (genericfunc_t)&start_f__open__socket2);
module_object.add_function("f_open_raw2", (genericfunc_t)&f__open__raw2, (genericfunc_t)&start_f__open__raw2);
module_object.add_function("f_ioctl_get_if_index2", (genericfunc_t)&f__ioctl__get__if__index2, (genericfunc_t)&start_f__ioctl__get__if__index2);
module_object.add_function("f_bind2", (genericfunc_t)&f__bind2, (genericfunc_t)&start_f__bind2);
module_object.add_function("f_close_socket2", (genericfunc_t)&f__close__socket2, (genericfunc_t)&start_f__close__socket2);
module_object.add_function("f_behaviour_isobus", (genericfunc_t)&f__behaviour__isobus, (genericfunc_t)&start_f__behaviour__isobus);
module_object.add_function("f_behaviour1_sync", (genericfunc_t)&f__behaviour1__sync, (genericfunc_t)&start_f__behaviour1__sync);
module_object.add_function("f_get_component", (genericfunc_t)&f__get__component, (genericfunc_t)&start_f__get__component);
module_object.add_function("f_behaviour2_sync", (genericfunc_t)&f__behaviour2__sync, (genericfunc_t)&start_f__behaviour2__sync);
module_object.add_function("f_behaviour_connections", (genericfunc_t)&f__behaviour__connections, (genericfunc_t)&start_f__behaviour__connections);
module_object.add_testcase_nonpard("tc_encdec", testcase_tc__encdec);
module_object.add_testcase_nonpard("tc_encdec_vt2ecu_vtStatusReq", testcase_tc__encdec__vt2ecu__vtStatusReq);
module_object.add_testcase_nonpard("tc_encdec_ecu2vt_getMemoryReq", testcase_tc__encdec__ecu2vt__getMemoryReq);
module_object.add_testcase_nonpard("tc_encdec_ecu2vt_getMemoryReq_with_templateI", testcase_tc__encdec__ecu2vt__getMemoryReq__with__templateI);
module_object.add_testcase_nonpard("tc_encdec_ecu2vt_getMemoryReq_with_template_II", testcase_tc__encdec__ecu2vt__getMemoryReq__with__template__II);
module_object.add_testcase_nonpard("tc_encdec_networkMessage_N_SP_Response_pdu_with_template", testcase_tc__encdec__networkMessage__N__SP__Response__pdu__with__template);
module_object.add_testcase_nonpard("tc_encdec_networkMessage_N_SP_Response_with_template", testcase_tc__encdec__networkMessage__N__SP__Response__with__template);
module_object.add_testcase_nonpard("tc_encdec_N_SP_Response_with_template", testcase_tc__encdec__N__SP__Response__with__template);
module_object.add_testcase_nonpard("tc_encdec_ecu2vt_workingSetMaintenanceReq", testcase_tc__encdec__ecu2vt__workingSetMaintenanceReq);
module_object.add_testcase_nonpard("tc_encdec_etp_dt", testcase_tc__encdec__etp__dt);
module_object.add_testcase_nonpard("tc_dec_requestForAddressClaimed", testcase_tc__dec__requestForAddressClaimed);
module_object.add_testcase_nonpard("tc_dec_largemessage", testcase_tc__dec__largemessage);
module_object.add_testcase_nonpard("tc_Example001", testcase_tc__Example001);
module_object.add_testcase_nonpard("tc_Example002", testcase_tc__Example002);
}
static void post_init_module()
{
TTCN_Location current_location("Isobustest.ttcn", 0, TTCN_Location::LOCATION_UNKNOWN, "Isobustest");
CanError::module_object.post_init_module();
SocketCANtest::module_object.post_init_module();
Isobus__Templates::module_object.post_init_module();
}
static boolean init_comp_type(const char *component_type, boolean init_base_comps)
{
(void)init_base_comps;
if (!strcmp(component_type, "MTC_CT")) {
return TRUE;
} else if (!strcmp(component_type, "PTC_isobus_CT")) {
PTC__isobus__CT_component_pt__socketCAN.activate_port();
PTC__isobus__CT_component_pt__isobus.activate_port();
return TRUE;
} else if (!strcmp(component_type, "PTC1_CT")) {
PTC1__CT_component_pt__isobus.activate_port();
PTC1__CT_component_openConnections.clean_up();
PTC1__CT_component_openConnectionsFlags.clean_up();
return TRUE;
} else if (!strcmp(component_type, "PTC2_CT")) {
PTC2__CT_component_pt__isobus.activate_port();
PTC2__CT_component_receivedUnacknowledgedData.clean_up();
PTC2__CT_component_msgSizeInBytes.clean_up();
PTC2__CT_component_receivedUnacknowledgedMsgSizeInBytes.clean_up();
PTC2__CT_component_nextExpectedPacketNumber.clean_up();
PTC2__CT_component_pgnOfMultiPacketMessage.clean_up();
PTC2__CT_component_ps.clean_up();
PTC2__CT_component_sa.clean_up();
PTC2__CT_component_tp__dt__can__id.clean_up();
return TRUE;
} else if (!strcmp(component_type, "PTC")) {
PTC_component_pt__sync.activate_port();
PTC_component_pt__socketCAN.activate_port();
PTC_component_v__phase = SocketCANtest::c__firstPhase;
return TRUE;
} else return FALSE;
}
static boolean init_system_port(const char* component_type, const char* port_name)
{
if (!strcmp(component_type, "PTC_isobus_CT")) {
if (!strcmp(port_name, "pt_isobus")) {
PTC__isobus__CT_component_pt__isobus.safe_start();
return TRUE;
}
if (!strcmp(port_name, "pt_socketCAN")) {
PTC__isobus__CT_component_pt__socketCAN.safe_start();
return TRUE;
}
}
else if (!strcmp(component_type, "PTC1_CT")) {
if (!strcmp(port_name, "pt_isobus")) {
PTC1__CT_component_pt__isobus.safe_start();
return TRUE;
}
}
else if (!strcmp(component_type, "PTC2_CT")) {
if (!strcmp(port_name, "pt_isobus")) {
PTC2__CT_component_pt__isobus.safe_start();
return TRUE;
}
}
else if (!strcmp(component_type, "PTC")) {
if (!strcmp(port_name, "pt_socketCAN")) {
PTC_component_pt__socketCAN.safe_start();
return TRUE;
}
if (!strcmp(port_name, "pt_sync")) {
PTC_component_pt__sync.safe_start();
return TRUE;
}
}
return FALSE;
}
static boolean start_ptc_function(const char *function_name, Text_Buf& function_arguments)
{
if (!strcmp(function_name, "f_open_socket2")) {
SocketCANtest::SocketCAN__open__socket__type v__socket__type;
v__socket__type.decode_text(function_arguments);
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_open_socket2(");
v__socket__type.log();
TTCN_Logger::log_event_str(").");
TTCN_Logger::end_event();
TTCN_Runtime::function_started(function_arguments);
f__open__socket2(v__socket__type);
TTCN_Runtime::function_finished("f_open_socket2");
return TRUE;
} else if (!strcmp(function_name, "f_open_raw2")) {
TTCN_Logger::log_str(TTCN_Logger::PARALLEL_PTC, "Starting function f_open_raw2().");
TTCN_Runtime::function_started(function_arguments);
f__open__raw2();
TTCN_Runtime::function_finished("f_open_raw2");
return TRUE;
} else if (!strcmp(function_name, "f_ioctl_get_if_index2")) {
INTEGER p__socket__id;
p__socket__id.decode_text(function_arguments);
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_ioctl_get_if_index2(");
p__socket__id.log();
TTCN_Logger::log_event_str(").");
TTCN_Logger::end_event();
TTCN_Runtime::function_started(function_arguments);
f__ioctl__get__if__index2(p__socket__id);
TTCN_Runtime::function_finished("f_ioctl_get_if_index2");
return TRUE;
} else if (!strcmp(function_name, "f_bind2")) {
INTEGER p__socket__id;
INTEGER p__if__index;
p__socket__id.decode_text(function_arguments);
p__if__index.decode_text(function_arguments);
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_bind2(");
p__socket__id.log();
TTCN_Logger::log_event_str(", ");
p__if__index.log();
TTCN_Logger::log_event_str(").");
TTCN_Logger::end_event();
TTCN_Runtime::function_started(function_arguments);
f__bind2(p__socket__id, p__if__index);
TTCN_Runtime::function_finished("f_bind2");
return TRUE;
} else if (!strcmp(function_name, "f_close_socket2")) {
INTEGER p__socket__id;
p__socket__id.decode_text(function_arguments);
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_close_socket2(");
p__socket__id.log();
TTCN_Logger::log_event_str(").");
TTCN_Logger::end_event();
TTCN_Runtime::function_started(function_arguments);
f__close__socket2(p__socket__id);
TTCN_Runtime::function_finished("f_close_socket2");
return TRUE;
} else if (!strcmp(function_name, "f_behaviour_isobus")) {
COMPONENT v__ptc1;
v__ptc1.decode_text(function_arguments);
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_behaviour_isobus(");
v__ptc1.log();
TTCN_Logger::log_event_str(").");
TTCN_Logger::end_event();
TTCN_Runtime::function_started(function_arguments);
f__behaviour__isobus(v__ptc1);
TTCN_Runtime::function_finished("f_behaviour_isobus");
return TRUE;
} else if (!strcmp(function_name, "f_behaviour1_sync")) {
TTCN_Logger::log_str(TTCN_Logger::PARALLEL_PTC, "Starting function f_behaviour1_sync().");
TTCN_Runtime::function_started(function_arguments);
f__behaviour1__sync();
TTCN_Runtime::function_finished("f_behaviour1_sync");
return TRUE;
} else if (!strcmp(function_name, "f_get_component")) {
OCTETSTRING connectioninitiator;
OCTETSTRING connectionresponder;
connectioninitiator.decode_text(function_arguments);
connectionresponder.decode_text(function_arguments);
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_get_component(");
connectioninitiator.log();
TTCN_Logger::log_event_str(", ");
connectionresponder.log();
TTCN_Logger::log_event_str(").");
TTCN_Logger::end_event();
TTCN_Runtime::function_started(function_arguments);
f__get__component(connectioninitiator, connectionresponder);
TTCN_Runtime::function_finished("f_get_component");
return TRUE;
} else if (!strcmp(function_name, "f_behaviour2_sync")) {
TTCN_Logger::log_str(TTCN_Logger::PARALLEL_PTC, "Starting function f_behaviour2_sync().");
TTCN_Runtime::function_started(function_arguments);
f__behaviour2__sync();
TTCN_Runtime::function_finished("f_behaviour2_sync");
return TRUE;
} else if (!strcmp(function_name, "f_behaviour_connections")) {
TTCN_Logger::log_str(TTCN_Logger::PARALLEL_PTC, "Starting function f_behaviour_connections().");
TTCN_Runtime::function_started(function_arguments);
f__behaviour__connections();
TTCN_Runtime::function_finished("f_behaviour_connections");
return TRUE;
} else return FALSE;
}
static void module_control_part()
{
TTCN_Location current_location("Isobustest.ttcn", 788, TTCN_Location::LOCATION_CONTROLPART, "Isobustest");
TTCN_Runtime::begin_controlpart("Isobustest");
current_location.update_lineno(792);
#line 792 "Isobustest.ttcn"
testcase_tc__Example001(FALSE, 0.0);
TTCN_Runtime::end_controlpart();
}
} /* end of namespace */