| // 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 "Isotptest.hh" |
| |
| namespace Isotptest { |
| |
| /* 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 os_2_octets[] = { 0, 0, 0, 35 }, |
| os_1_octets[] = { 0, 0, 0, 50 }, |
| os_0_octets[] = { 0, 17, 34, 51, 68, 85, 102, 119, 136, 153 }; |
| static const OCTETSTRING os_2(4, os_2_octets), |
| os_1(4, os_1_octets), |
| os_0(10, os_0_octets); |
| static const unsigned char module_checksum[] = { 0x67, 0xa6, 0x54, 0x50, 0xd9, 0x71, 0xec, 0xb2, 0x7e, 0x4d, 0x8e, 0xd0, 0x71, 0x0a, 0xa7, 0xff }; |
| |
| /* Global variable definitions */ |
| |
| static FLOAT const_c__guard; |
| const FLOAT& c__guard = const_c__guard; |
| // No XER for SocketCAN__open__socket__type |
| const TTCN_Typedescriptor_t SocketCAN__open__socket__type_descr_ = { "@Isotptest.SocketCAN_open_socket_type", NULL, NULL, NULL, NULL, &ENUMERATED_json_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
| const XERdescriptor_t SocketCAN__open__isotp__result_socket__id_xer_ = { {"socket_id>\n", "socket_id>\n"}, {11, 11}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; |
| const TTCN_OERdescriptor_t SocketCAN__open__isotp__result_socket__id_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; |
| const TTCN_Typedescriptor_t SocketCAN__open__isotp__result_socket__id_descr_ = { "@Isotptest.SocketCAN_open_isotp_result.socket_id", &INTEGER_ber_, &INTEGER_raw_, &INTEGER_text_, &SocketCAN__open__isotp__result_socket__id_xer_, &INTEGER_json_, &SocketCAN__open__isotp__result_socket__id_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
| // No XER for SocketCAN__open__isotp__result |
| const TTCN_Typedescriptor_t SocketCAN__open__isotp__result_descr_ = { "@Isotptest.SocketCAN_open_isotp_result", NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
| const TTCN_Typedescriptor_t& MTC__CT_descr_ = COMPONENT_descr_; |
| const TTCN_Typedescriptor_t& PTC__isotp__CT_descr_ = COMPONENT_descr_; |
| SocketCAN__PortType::SocketCAN__PT PTC__isotp__CT_component_pt__socketCAN("pt_socketCAN"); |
| TIMER PTC__isotp__CT_component_T0("T0", 2.0e-1); |
| TTCN_Module module_object("Isotptest", __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 */ |
| |
| SocketCAN__open__socket__type::SocketCAN__open__socket__type() |
| { |
| enum_value = UNBOUND_VALUE; |
| } |
| |
| SocketCAN__open__socket__type::SocketCAN__open__socket__type(int other_value) |
| { |
| if (!is_valid_enum(other_value)) TTCN_error("Initializing a variable of enumerated type @Isotptest.SocketCAN_open_socket_type with invalid numeric value %d.", other_value); |
| enum_value = (enum_type)other_value; |
| } |
| |
| SocketCAN__open__socket__type::SocketCAN__open__socket__type(enum_type other_value) |
| { |
| enum_value = other_value; |
| } |
| |
| SocketCAN__open__socket__type::SocketCAN__open__socket__type(const SocketCAN__open__socket__type& other_value) |
| : Base_Type() |
| { |
| if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Copying an unbound value of enumerated type @Isotptest.SocketCAN_open_socket_type."); |
| enum_value = other_value.enum_value; |
| } |
| |
| SocketCAN__open__socket__type& SocketCAN__open__socket__type::operator=(int other_value) |
| { |
| if (!is_valid_enum(other_value)) TTCN_error("Assigning unknown numeric value %d to a variable of enumerated type @Isotptest.SocketCAN_open_socket_type.", other_value); |
| enum_value = (enum_type)other_value; |
| return *this; |
| } |
| |
| SocketCAN__open__socket__type& SocketCAN__open__socket__type::operator=(enum_type other_value) |
| { |
| enum_value = other_value; |
| return *this; |
| } |
| |
| SocketCAN__open__socket__type& SocketCAN__open__socket__type::operator=(const SocketCAN__open__socket__type& other_value) |
| { |
| if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @Isotptest.SocketCAN_open_socket_type."); |
| enum_value = other_value.enum_value; |
| return *this; |
| } |
| |
| boolean SocketCAN__open__socket__type::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 @Isotptest.SocketCAN_open_socket_type."); |
| return enum_value == other_value; |
| } |
| |
| boolean SocketCAN__open__socket__type::operator==(const SocketCAN__open__socket__type& other_value) const |
| { |
| if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Isotptest.SocketCAN_open_socket_type."); |
| if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @Isotptest.SocketCAN_open_socket_type."); |
| return enum_value == other_value.enum_value; |
| } |
| |
| boolean SocketCAN__open__socket__type::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 @Isotptest.SocketCAN_open_socket_type."); |
| return enum_value < other_value; |
| } |
| |
| boolean SocketCAN__open__socket__type::operator<(const SocketCAN__open__socket__type& other_value) const |
| { |
| if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Isotptest.SocketCAN_open_socket_type."); |
| if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @Isotptest.SocketCAN_open_socket_type."); |
| return enum_value < other_value.enum_value; |
| } |
| |
| boolean SocketCAN__open__socket__type::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 @Isotptest.SocketCAN_open_socket_type."); |
| return enum_value > other_value; |
| } |
| |
| boolean SocketCAN__open__socket__type::operator>(const SocketCAN__open__socket__type& other_value) const |
| { |
| if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Isotptest.SocketCAN_open_socket_type."); |
| if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @Isotptest.SocketCAN_open_socket_type."); |
| return enum_value > other_value.enum_value; |
| } |
| |
| const char *SocketCAN__open__socket__type::enum_to_str(enum_type enum_par) |
| { |
| switch (enum_par) { |
| case OPEN__CAN__RAW: return "OPEN_CAN_RAW"; |
| case OPEN__CAN__BCM: return "OPEN_CAN_BCM"; |
| case OPEN__CAN__ISOTP: return "OPEN_CAN_ISOTP"; |
| default: return "<unknown>"; |
| } |
| } |
| |
| SocketCAN__open__socket__type::enum_type SocketCAN__open__socket__type::str_to_enum(const char *str_par) |
| { |
| if (!strcmp(str_par, "OPEN_CAN_RAW")) return OPEN__CAN__RAW; |
| else if (!strcmp(str_par, "OPEN_CAN_BCM")) return OPEN__CAN__BCM; |
| else if (!strcmp(str_par, "OPEN_CAN_ISOTP")) return OPEN__CAN__ISOTP; |
| else return UNKNOWN_VALUE; |
| } |
| |
| boolean SocketCAN__open__socket__type::is_valid_enum(int int_par) |
| { |
| switch (int_par) { |
| case 0: |
| case 1: |
| case 2: |
| return TRUE; |
| default: |
| return FALSE; |
| } |
| } |
| |
| int SocketCAN__open__socket__type::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 @Isotptest.SocketCAN_open_socket_type.", enum_par==UNBOUND_VALUE?"unbound":"invalid"); |
| return enum_par; |
| } |
| |
| int SocketCAN__open__socket__type::enum2int(const SocketCAN__open__socket__type& 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 @Isotptest.SocketCAN_open_socket_type.", enum_par==UNBOUND_VALUE?"unbound":"invalid"); |
| return enum_par.enum_value; |
| } |
| |
| void SocketCAN__open__socket__type::int2enum(int int_val) |
| { |
| if (!is_valid_enum(int_val)) TTCN_error("Assigning invalid numeric value %d to a variable of enumerated type @Isotptest.SocketCAN_open_socket_type.", int_val); |
| enum_value = (enum_type)int_val; |
| } |
| |
| SocketCAN__open__socket__type::operator SocketCAN__open__socket__type::enum_type() const |
| { |
| if (enum_value == UNBOUND_VALUE) TTCN_error("Using the value of an unbound variable of enumerated type @Isotptest.SocketCAN_open_socket_type."); |
| return enum_value; |
| } |
| |
| void SocketCAN__open__socket__type::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 SocketCAN__open__socket__type::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", "@Isotptest.SocketCAN_open_socket_type"); |
| enum_value = str_to_enum(param.get_enumerated()); |
| if (!is_valid_enum(enum_value)) { |
| param.error("Invalid enumerated value for type @Isotptest.SocketCAN_open_socket_type."); |
| } |
| } |
| |
| void SocketCAN__open__socket__type::encode_text(Text_Buf& text_buf) const |
| { |
| if (enum_value == UNBOUND_VALUE) TTCN_error("Text encoder: Encoding an unbound value of enumerated type @Isotptest.SocketCAN_open_socket_type."); |
| text_buf.push_int(enum_value); |
| } |
| |
| void SocketCAN__open__socket__type::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 @Isotptest.SocketCAN_open_socket_type.", enum_value); |
| } |
| |
| void SocketCAN__open__socket__type_template::copy_template(const SocketCAN__open__socket__type_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 SocketCAN__open__socket__type_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 @Isotptest.SocketCAN_open_socket_type."); |
| } |
| } |
| |
| SocketCAN__open__socket__type_template::SocketCAN__open__socket__type_template() |
| { |
| } |
| |
| SocketCAN__open__socket__type_template::SocketCAN__open__socket__type_template(template_sel other_value) |
| : Base_Template(other_value) |
| { |
| check_single_selection(other_value); |
| } |
| |
| SocketCAN__open__socket__type_template::SocketCAN__open__socket__type_template(int other_value) |
| : Base_Template(SPECIFIC_VALUE) |
| { |
| if (!SocketCAN__open__socket__type::is_valid_enum(other_value)) TTCN_error("Initializing a template of enumerated type @Isotptest.SocketCAN_open_socket_type with unknown numeric value %d.", other_value); |
| single_value = (SocketCAN__open__socket__type::enum_type)other_value; |
| } |
| |
| SocketCAN__open__socket__type_template::SocketCAN__open__socket__type_template(SocketCAN__open__socket__type::enum_type other_value) |
| : Base_Template(SPECIFIC_VALUE) |
| { |
| single_value = other_value; |
| } |
| |
| SocketCAN__open__socket__type_template::SocketCAN__open__socket__type_template(const SocketCAN__open__socket__type& other_value) |
| : Base_Template(SPECIFIC_VALUE) |
| { |
| if (other_value.enum_value == SocketCAN__open__socket__type::UNBOUND_VALUE) TTCN_error("Creating a template from an unbound value of enumerated type @Isotptest.SocketCAN_open_socket_type."); |
| single_value = other_value.enum_value; |
| } |
| |
| SocketCAN__open__socket__type_template::SocketCAN__open__socket__type_template(const OPTIONAL<SocketCAN__open__socket__type>& other_value) |
| { |
| switch (other_value.get_selection()) { |
| case OPTIONAL_PRESENT: |
| set_selection(SPECIFIC_VALUE); |
| single_value = (SocketCAN__open__socket__type::enum_type)(const SocketCAN__open__socket__type&)other_value; |
| break; |
| case OPTIONAL_OMIT: |
| set_selection(OMIT_VALUE); |
| break; |
| default: |
| TTCN_error("Creating a template of enumerated type @Isotptest.SocketCAN_open_socket_type from an unbound optional field."); |
| } |
| } |
| |
| SocketCAN__open__socket__type_template::SocketCAN__open__socket__type_template(const SocketCAN__open__socket__type_template& other_value) |
| : Base_Template() |
| { |
| copy_template(other_value); |
| } |
| |
| SocketCAN__open__socket__type_template::~SocketCAN__open__socket__type_template() |
| { |
| clean_up(); |
| } |
| |
| boolean SocketCAN__open__socket__type_template::is_bound() const |
| { |
| if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE; |
| return TRUE; |
| } |
| |
| boolean SocketCAN__open__socket__type_template::is_value() const |
| { |
| if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; |
| return single_value != SocketCAN__open__socket__type::UNBOUND_VALUE; |
| } |
| |
| void SocketCAN__open__socket__type_template::clean_up() |
| { |
| if (template_selection == VALUE_LIST || template_selection == COMPLEMENTED_LIST) delete [] value_list.list_value; |
| template_selection = UNINITIALIZED_TEMPLATE; |
| } |
| |
| SocketCAN__open__socket__type_template& SocketCAN__open__socket__type_template::operator=(template_sel other_value) |
| { |
| check_single_selection(other_value); |
| clean_up(); |
| set_selection(other_value); |
| return *this; |
| } |
| |
| SocketCAN__open__socket__type_template& SocketCAN__open__socket__type_template::operator=(int other_value) |
| { |
| if (!SocketCAN__open__socket__type::is_valid_enum(other_value)) TTCN_warning("Assigning unknown numeric value %d to a template of enumerated type @Isotptest.SocketCAN_open_socket_type.", other_value); |
| clean_up(); |
| set_selection(SPECIFIC_VALUE); |
| single_value = (SocketCAN__open__socket__type::enum_type)other_value; |
| return *this; |
| } |
| |
| SocketCAN__open__socket__type_template& SocketCAN__open__socket__type_template::operator=(SocketCAN__open__socket__type::enum_type other_value) |
| { |
| clean_up(); |
| set_selection(SPECIFIC_VALUE); |
| single_value = other_value; |
| return *this; |
| } |
| |
| SocketCAN__open__socket__type_template& SocketCAN__open__socket__type_template::operator=(const SocketCAN__open__socket__type& other_value) |
| { |
| if (other_value.enum_value == SocketCAN__open__socket__type::UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @Isotptest.SocketCAN_open_socket_type to a template."); |
| clean_up(); |
| set_selection(SPECIFIC_VALUE); |
| single_value = other_value.enum_value; |
| return *this; |
| } |
| |
| SocketCAN__open__socket__type_template& SocketCAN__open__socket__type_template::operator=(const OPTIONAL<SocketCAN__open__socket__type>& other_value) |
| { |
| clean_up(); |
| switch (other_value.get_selection()) { |
| case OPTIONAL_PRESENT: |
| set_selection(SPECIFIC_VALUE); |
| single_value = (SocketCAN__open__socket__type::enum_type)(const SocketCAN__open__socket__type&)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 @Isotptest.SocketCAN_open_socket_type."); |
| } |
| return *this; |
| } |
| |
| SocketCAN__open__socket__type_template& SocketCAN__open__socket__type_template::operator=(const SocketCAN__open__socket__type_template& other_value) |
| { |
| if (&other_value != this) { |
| clean_up(); |
| copy_template(other_value); |
| } |
| return *this; |
| } |
| |
| boolean SocketCAN__open__socket__type_template::match(SocketCAN__open__socket__type::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 @Isotptest.SocketCAN_open_socket_type."); |
| } |
| return FALSE; |
| } |
| |
| boolean SocketCAN__open__socket__type_template::match(const SocketCAN__open__socket__type& other_value, boolean) const |
| { |
| if (other_value.enum_value == SocketCAN__open__socket__type::UNBOUND_VALUE) TTCN_error("Matching a template of enumerated type @Isotptest.SocketCAN_open_socket_type with an unbound value."); |
| return match(other_value.enum_value); |
| } |
| |
| SocketCAN__open__socket__type::enum_type SocketCAN__open__socket__type_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 @Isotptest.SocketCAN_open_socket_type."); |
| return single_value; |
| } |
| |
| void SocketCAN__open__socket__type_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 @Isotptest.SocketCAN_open_socket_type."); |
| clean_up(); |
| set_selection(template_type); |
| value_list.n_values = list_length; |
| value_list.list_value = new SocketCAN__open__socket__type_template[list_length]; |
| } |
| |
| SocketCAN__open__socket__type_template& SocketCAN__open__socket__type_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 @Isotptest.SocketCAN_open_socket_type."); |
| if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of enumerated type @Isotptest.SocketCAN_open_socket_type."); |
| return value_list.list_value[list_index]; |
| } |
| |
| void SocketCAN__open__socket__type_template::log() const |
| { |
| switch (template_selection) { |
| case SPECIFIC_VALUE: |
| TTCN_Logger::log_event_enum(SocketCAN__open__socket__type::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 SocketCAN__open__socket__type_template::log_match(const SocketCAN__open__socket__type& 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 SocketCAN__open__socket__type_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 @Isotptest.SocketCAN_open_socket_type."); |
| } |
| } |
| |
| void SocketCAN__open__socket__type_template::decode_text(Text_Buf& text_buf) |
| { |
| clean_up(); |
| decode_text_base(text_buf); |
| switch (template_selection) { |
| case SPECIFIC_VALUE: |
| single_value = (SocketCAN__open__socket__type::enum_type)text_buf.pull_int().get_val(); |
| if (!SocketCAN__open__socket__type::is_valid_enum(single_value)) TTCN_error("Text decoder: Unknown numeric value %d was received for a template of enumerated type @Isotptest.SocketCAN_open_socket_type.", 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 SocketCAN__open__socket__type_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 @Isotptest.SocketCAN_open_socket_type."); |
| } |
| } |
| |
| boolean SocketCAN__open__socket__type_template::is_present(boolean legacy) const |
| { |
| if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; |
| return !match_omit(legacy); |
| } |
| |
| boolean SocketCAN__open__socket__type_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 SocketCAN__open__socket__type_template::set_param(Module_Param& param) |
| { |
| param.basic_check(Module_Param::BC_TEMPLATE, "enumerated template"); |
| Module_Param_Ptr m_p = ¶m; |
| 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: { |
| SocketCAN__open__socket__type_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: { |
| SocketCAN__open__socket__type::enum_type enum_val = SocketCAN__open__socket__type::str_to_enum(m_p->get_enumerated()); |
| if (!SocketCAN__open__socket__type::is_valid_enum(enum_val)) { |
| param.error("Invalid enumerated value for type @Isotptest.SocketCAN_open_socket_type."); |
| } |
| *this = enum_val; |
| } break; |
| default: |
| param.type_error("enumerated template", "@Isotptest.SocketCAN_open_socket_type"); |
| } |
| is_ifpresent = param.get_ifpresent(); |
| } |
| |
| void SocketCAN__open__socket__type_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 : "@Isotptest.SocketCAN_open_socket_type"); |
| } |
| |
| SocketCAN__open__isotp__result::SocketCAN__open__isotp__result() |
| { |
| } |
| |
| SocketCAN__open__isotp__result::SocketCAN__open__isotp__result(const SocketCAN__Types::SocketCAN__ifr& par_ifr, |
| const INTEGER& par_socket__id) |
| : field_ifr(par_ifr), |
| field_socket__id(par_socket__id) |
| { |
| } |
| |
| SocketCAN__open__isotp__result::SocketCAN__open__isotp__result(const SocketCAN__open__isotp__result& other_value) |
| { |
| if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @Isotptest.SocketCAN_open_isotp_result."); |
| if (other_value.ifr().is_bound()) field_ifr = other_value.ifr(); |
| else field_ifr.clean_up(); |
| if (other_value.socket__id().is_bound()) field_socket__id = other_value.socket__id(); |
| else field_socket__id.clean_up(); |
| } |
| |
| void SocketCAN__open__isotp__result::clean_up() |
| { |
| field_ifr.clean_up(); |
| field_socket__id.clean_up(); |
| } |
| |
| const TTCN_Typedescriptor_t* SocketCAN__open__isotp__result::get_descriptor() const { return &SocketCAN__open__isotp__result_descr_; } |
| SocketCAN__open__isotp__result& SocketCAN__open__isotp__result::operator=(const SocketCAN__open__isotp__result& other_value) |
| { |
| if (this != &other_value) { |
| if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @Isotptest.SocketCAN_open_isotp_result."); |
| if (other_value.ifr().is_bound()) field_ifr = other_value.ifr(); |
| else field_ifr.clean_up(); |
| if (other_value.socket__id().is_bound()) field_socket__id = other_value.socket__id(); |
| else field_socket__id.clean_up(); |
| } |
| return *this; |
| } |
| |
| boolean SocketCAN__open__isotp__result::operator==(const SocketCAN__open__isotp__result& other_value) const |
| { |
| return field_ifr==other_value.field_ifr |
| && field_socket__id==other_value.field_socket__id; |
| } |
| |
| boolean SocketCAN__open__isotp__result::is_bound() const |
| { |
| return (field_ifr.is_bound()) |
| || (field_socket__id.is_bound()); |
| } |
| boolean SocketCAN__open__isotp__result::is_value() const |
| { |
| return field_ifr.is_value() |
| && field_socket__id.is_value(); |
| } |
| void SocketCAN__open__isotp__result::log() const |
| { |
| if (!is_bound()) { |
| TTCN_Logger::log_event_unbound(); |
| return; |
| } |
| TTCN_Logger::log_event_str("{ ifr := "); |
| field_ifr.log(); |
| TTCN_Logger::log_event_str(", socket_id := "); |
| field_socket__id.log(); |
| TTCN_Logger::log_event_str(" }"); |
| } |
| |
| void SocketCAN__open__isotp__result::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 @Isotptest.SocketCAN_open_isotp_result 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) ifr().set_param(*param.get_elem(0)); |
| if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) socket__id().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(), "ifr")) { |
| if (curr_param->get_type()!=Module_Param::MP_NotUsed) { |
| ifr().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(), "socket_id")) { |
| if (curr_param->get_type()!=Module_Param::MP_NotUsed) { |
| socket__id().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 @Isotptest.SocketCAN_open_isotp_result: %s", curr_param->get_id()->get_name()); |
| break; |
| } |
| } break; |
| default: |
| param.type_error("record value", "@Isotptest.SocketCAN_open_isotp_result"); |
| } |
| } |
| |
| void SocketCAN__open__isotp__result::set_implicit_omit() |
| { |
| if (ifr().is_bound()) ifr().set_implicit_omit(); |
| if (socket__id().is_bound()) socket__id().set_implicit_omit(); |
| } |
| |
| void SocketCAN__open__isotp__result::encode_text(Text_Buf& text_buf) const |
| { |
| field_ifr.encode_text(text_buf); |
| field_socket__id.encode_text(text_buf); |
| } |
| |
| void SocketCAN__open__isotp__result::decode_text(Text_Buf& text_buf) |
| { |
| field_ifr.decode_text(text_buf); |
| field_socket__id.decode_text(text_buf); |
| } |
| |
| struct SocketCAN__open__isotp__result_template::single_value_struct { |
| SocketCAN__Types::SocketCAN__ifr_template field_ifr; |
| INTEGER_template field_socket__id; |
| }; |
| |
| void SocketCAN__open__isotp__result_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_ifr = ANY_VALUE; |
| single_value->field_socket__id = ANY_VALUE; |
| } |
| } |
| } |
| |
| void SocketCAN__open__isotp__result_template::copy_value(const SocketCAN__open__isotp__result& other_value) |
| { |
| single_value = new single_value_struct; |
| if (other_value.ifr().is_bound()) { |
| single_value->field_ifr = other_value.ifr(); |
| } else { |
| single_value->field_ifr.clean_up(); |
| } |
| if (other_value.socket__id().is_bound()) { |
| single_value->field_socket__id = other_value.socket__id(); |
| } else { |
| single_value->field_socket__id.clean_up(); |
| } |
| set_selection(SPECIFIC_VALUE); |
| } |
| |
| void SocketCAN__open__isotp__result_template::copy_template(const SocketCAN__open__isotp__result_template& other_value) |
| { |
| switch (other_value.template_selection) { |
| case SPECIFIC_VALUE: |
| single_value = new single_value_struct; |
| if (UNINITIALIZED_TEMPLATE != other_value.ifr().get_selection()) { |
| single_value->field_ifr = other_value.ifr(); |
| } else { |
| single_value->field_ifr.clean_up(); |
| } |
| if (UNINITIALIZED_TEMPLATE != other_value.socket__id().get_selection()) { |
| single_value->field_socket__id = other_value.socket__id(); |
| } else { |
| single_value->field_socket__id.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 SocketCAN__open__isotp__result_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 @Isotptest.SocketCAN_open_isotp_result."); |
| break; |
| } |
| set_selection(other_value); |
| } |
| |
| SocketCAN__open__isotp__result_template::SocketCAN__open__isotp__result_template() |
| { |
| } |
| |
| SocketCAN__open__isotp__result_template::SocketCAN__open__isotp__result_template(template_sel other_value) |
| : Base_Template(other_value) |
| { |
| check_single_selection(other_value); |
| } |
| |
| SocketCAN__open__isotp__result_template::SocketCAN__open__isotp__result_template(const SocketCAN__open__isotp__result& other_value) |
| { |
| copy_value(other_value); |
| } |
| |
| SocketCAN__open__isotp__result_template::SocketCAN__open__isotp__result_template(const OPTIONAL<SocketCAN__open__isotp__result>& other_value) |
| { |
| switch (other_value.get_selection()) { |
| case OPTIONAL_PRESENT: |
| copy_value((const SocketCAN__open__isotp__result&)other_value); |
| break; |
| case OPTIONAL_OMIT: |
| set_selection(OMIT_VALUE); |
| break; |
| default: |
| TTCN_error("Creating a template of type @Isotptest.SocketCAN_open_isotp_result from an unbound optional field."); |
| } |
| } |
| |
| SocketCAN__open__isotp__result_template::SocketCAN__open__isotp__result_template(const SocketCAN__open__isotp__result_template& other_value) |
| : Base_Template() |
| { |
| copy_template(other_value); |
| } |
| |
| SocketCAN__open__isotp__result_template::~SocketCAN__open__isotp__result_template() |
| { |
| clean_up(); |
| } |
| |
| SocketCAN__open__isotp__result_template& SocketCAN__open__isotp__result_template::operator=(template_sel other_value) |
| { |
| check_single_selection(other_value); |
| clean_up(); |
| set_selection(other_value); |
| return *this; |
| } |
| |
| SocketCAN__open__isotp__result_template& SocketCAN__open__isotp__result_template::operator=(const SocketCAN__open__isotp__result& other_value) |
| { |
| clean_up(); |
| copy_value(other_value); |
| return *this; |
| } |
| |
| SocketCAN__open__isotp__result_template& SocketCAN__open__isotp__result_template::operator=(const OPTIONAL<SocketCAN__open__isotp__result>& other_value) |
| { |
| clean_up(); |
| switch (other_value.get_selection()) { |
| case OPTIONAL_PRESENT: |
| copy_value((const SocketCAN__open__isotp__result&)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 @Isotptest.SocketCAN_open_isotp_result."); |
| } |
| return *this; |
| } |
| |
| SocketCAN__open__isotp__result_template& SocketCAN__open__isotp__result_template::operator=(const SocketCAN__open__isotp__result_template& other_value) |
| { |
| if (&other_value != this) { |
| clean_up(); |
| copy_template(other_value); |
| } |
| return *this; |
| } |
| |
| boolean SocketCAN__open__isotp__result_template::match(const SocketCAN__open__isotp__result& 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.ifr().is_bound()) return FALSE; |
| if(!single_value->field_ifr.match(other_value.ifr(), legacy))return FALSE; |
| if(!other_value.socket__id().is_bound()) return FALSE; |
| if(!single_value->field_socket__id.match(other_value.socket__id(), 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 @Isotptest.SocketCAN_open_isotp_result."); |
| } |
| return FALSE; |
| } |
| |
| boolean SocketCAN__open__isotp__result_template::is_bound() const |
| { |
| if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE; |
| if (template_selection != SPECIFIC_VALUE) return TRUE; |
| return single_value->field_ifr.is_bound() |
| |
| ||single_value->field_socket__id.is_bound() |
| ; |
| } |
| |
| boolean SocketCAN__open__isotp__result_template::is_value() const |
| { |
| if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; |
| return single_value->field_ifr.is_value() |
| &&single_value->field_socket__id.is_value(); |
| } |
| |
| void SocketCAN__open__isotp__result_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; |
| } |
| |
| SocketCAN__open__isotp__result SocketCAN__open__isotp__result_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 @Isotptest.SocketCAN_open_isotp_result."); |
| SocketCAN__open__isotp__result ret_val; |
| if (single_value->field_ifr.is_bound()) { |
| ret_val.ifr() = single_value->field_ifr.valueof(); |
| } |
| if (single_value->field_socket__id.is_bound()) { |
| ret_val.socket__id() = single_value->field_socket__id.valueof(); |
| } |
| return ret_val; |
| } |
| |
| void SocketCAN__open__isotp__result_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 @Isotptest.SocketCAN_open_isotp_result."); |
| clean_up(); |
| set_selection(template_type); |
| value_list.n_values = list_length; |
| value_list.list_value = new SocketCAN__open__isotp__result_template[list_length]; |
| } |
| |
| SocketCAN__open__isotp__result_template& SocketCAN__open__isotp__result_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 @Isotptest.SocketCAN_open_isotp_result."); |
| if (list_index >= value_list.n_values) |
| TTCN_error("Index overflow in a value list template of type @Isotptest.SocketCAN_open_isotp_result."); |
| return value_list.list_value[list_index]; |
| } |
| |
| SocketCAN__Types::SocketCAN__ifr_template& SocketCAN__open__isotp__result_template::ifr() |
| { |
| set_specific(); |
| return single_value->field_ifr; |
| } |
| |
| const SocketCAN__Types::SocketCAN__ifr_template& SocketCAN__open__isotp__result_template::ifr() const |
| { |
| if (template_selection != SPECIFIC_VALUE) |
| TTCN_error("Accessing field ifr of a non-specific template of type @Isotptest.SocketCAN_open_isotp_result."); |
| return single_value->field_ifr; |
| } |
| |
| INTEGER_template& SocketCAN__open__isotp__result_template::socket__id() |
| { |
| set_specific(); |
| return single_value->field_socket__id; |
| } |
| |
| const INTEGER_template& SocketCAN__open__isotp__result_template::socket__id() const |
| { |
| if (template_selection != SPECIFIC_VALUE) |
| TTCN_error("Accessing field socket_id of a non-specific template of type @Isotptest.SocketCAN_open_isotp_result."); |
| return single_value->field_socket__id; |
| } |
| |
| int SocketCAN__open__isotp__result_template::size_of() const |
| { |
| if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @Isotptest.SocketCAN_open_isotp_result 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 @Isotptest.SocketCAN_open_isotp_result 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 @Isotptest.SocketCAN_open_isotp_result containing a value list with different sizes."); |
| } |
| return item_size; |
| } |
| case OMIT_VALUE: |
| TTCN_error("Performing sizeof() operation on a template of type @Isotptest.SocketCAN_open_isotp_result containing omit value."); |
| case ANY_VALUE: |
| case ANY_OR_OMIT: |
| TTCN_error("Performing sizeof() operation on a template of type @Isotptest.SocketCAN_open_isotp_result containing */? value."); |
| case COMPLEMENTED_LIST: |
| TTCN_error("Performing sizeof() operation on a template of type @Isotptest.SocketCAN_open_isotp_result containing complemented list."); |
| default: |
| TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @Isotptest.SocketCAN_open_isotp_result."); |
| } |
| return 0; |
| } |
| |
| void SocketCAN__open__isotp__result_template::log() const |
| { |
| switch (template_selection) { |
| case SPECIFIC_VALUE: |
| TTCN_Logger::log_event_str("{ ifr := "); |
| single_value->field_ifr.log(); |
| TTCN_Logger::log_event_str(", socket_id := "); |
| single_value->field_socket__id.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 SocketCAN__open__isotp__result_template::log_match(const SocketCAN__open__isotp__result& 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_ifr.match(match_value.ifr(), legacy)){ |
| TTCN_Logger::log_logmatch_info(".ifr"); |
| single_value->field_ifr.log_match(match_value.ifr(), legacy); |
| TTCN_Logger::set_logmatch_buffer_len(previous_size); |
| } |
| if(!single_value->field_socket__id.match(match_value.socket__id(), legacy)){ |
| TTCN_Logger::log_logmatch_info(".socket_id"); |
| single_value->field_socket__id.log_match(match_value.socket__id(), 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("{ ifr := "); |
| single_value->field_ifr.log_match(match_value.ifr(), legacy); |
| TTCN_Logger::log_event_str(", socket_id := "); |
| single_value->field_socket__id.log_match(match_value.socket__id(), 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 SocketCAN__open__isotp__result_template::encode_text(Text_Buf& text_buf) const |
| { |
| encode_text_base(text_buf); |
| switch (template_selection) { |
| case SPECIFIC_VALUE: |
| single_value->field_ifr.encode_text(text_buf); |
| single_value->field_socket__id.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 @Isotptest.SocketCAN_open_isotp_result."); |
| } |
| } |
| |
| void SocketCAN__open__isotp__result_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_ifr.decode_text(text_buf); |
| single_value->field_socket__id.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 SocketCAN__open__isotp__result_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 @Isotptest.SocketCAN_open_isotp_result."); |
| } |
| } |
| |
| void SocketCAN__open__isotp__result_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: { |
| SocketCAN__open__isotp__result_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 @Isotptest.SocketCAN_open_isotp_result 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) ifr().set_param(*param.get_elem(0)); |
| if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) socket__id().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(), "ifr")) { |
| if (curr_param->get_type()!=Module_Param::MP_NotUsed) { |
| ifr().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(), "socket_id")) { |
| if (curr_param->get_type()!=Module_Param::MP_NotUsed) { |
| socket__id().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 @Isotptest.SocketCAN_open_isotp_result: %s", curr_param->get_id()->get_name()); |
| break; |
| } |
| } break; |
| default: |
| param.type_error("record template", "@Isotptest.SocketCAN_open_isotp_result"); |
| } |
| is_ifpresent = param.get_ifpresent(); |
| } |
| |
| void SocketCAN__open__isotp__result_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_ifr.check_restriction(t_res, t_name ? t_name : "@Isotptest.SocketCAN_open_isotp_result"); |
| single_value->field_socket__id.check_restriction(t_res, t_name ? t_name : "@Isotptest.SocketCAN_open_isotp_result"); |
| 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 : "@Isotptest.SocketCAN_open_isotp_result"); |
| } |
| |
| boolean SocketCAN__open__isotp__result_template::is_present(boolean legacy) const |
| { |
| if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; |
| return !match_omit(legacy); |
| } |
| |
| boolean SocketCAN__open__isotp__result_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; |
| } |
| |
| |
| /* Bodies of functions, altsteps and testcases */ |
| |
| SocketCAN__Types::SocketCAN__socket__result f__open__socket(const SocketCAN__open__socket__type& v__socket__type) |
| { |
| TTCN_Location current_location("Isotptest.ttcn", 68, TTCN_Location::LOCATION_FUNCTION, "f_open_socket"); |
| current_location.update_lineno(72); |
| #line 72 "Isotptest.ttcn" |
| SocketCAN__Types::SocketCAN__socket__result v__result; |
| current_location.update_lineno(73); |
| #line 73 "Isotptest.ttcn" |
| TIMER t__guard("t_guard"); |
| current_location.update_lineno(74); |
| #line 74 "Isotptest.ttcn" |
| t__guard.start(1.0e1); |
| current_location.update_lineno(76); |
| #line 76 "Isotptest.ttcn" |
| SocketCAN__Types::SocketCAN__socket socket; |
| current_location.update_lineno(78); |
| #line 78 "Isotptest.ttcn" |
| if ((v__socket__type == SocketCAN__open__socket__type::OPEN__CAN__RAW)) { |
| current_location.update_lineno(79); |
| #line 79 "Isotptest.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(80); |
| #line 80 "Isotptest.ttcn" |
| if ((v__socket__type == SocketCAN__open__socket__type::OPEN__CAN__BCM)) { |
| current_location.update_lineno(81); |
| #line 81 "Isotptest.ttcn" |
| socket.domain() = Can::AdresseFamily__enum::PF__CAN; |
| socket.ptype() = Can::ProtocolFamily__enum::SOCK__DGRAM; |
| socket.protocol() = Can::PF__CAN__protocols__enum::CAN__BCM; |
| } |
| else { |
| current_location.update_lineno(82); |
| #line 82 "Isotptest.ttcn" |
| if ((v__socket__type == SocketCAN__open__socket__type::OPEN__CAN__ISOTP)) { |
| current_location.update_lineno(83); |
| #line 83 "Isotptest.ttcn" |
| socket.domain() = Can::AdresseFamily__enum::PF__CAN; |
| socket.ptype() = Can::ProtocolFamily__enum::SOCK__DGRAM; |
| socket.protocol() = Can::PF__CAN__protocols__enum::CAN__ISOTP; |
| } |
| } |
| } |
| current_location.update_lineno(86); |
| #line 86 "Isotptest.ttcn" |
| PTC__isotp__CT_component_pt__socketCAN.send(socket, NULL); |
| current_location.update_lineno(89); |
| #line 89 "Isotptest.ttcn" |
| { |
| tmp_3: |
| alt_status tmp_3_alt_flag_0 = ALT_MAYBE; |
| alt_status tmp_3_alt_flag_1 = ALT_MAYBE; |
| alt_status tmp_3_alt_flag_2 = ALT_MAYBE; |
| alt_status tmp_3_alt_flag_3 = ALT_MAYBE; |
| alt_status tmp_3_default_flag = ALT_MAYBE; |
| TTCN_Snapshot::take_new(FALSE); |
| for ( ; ; ) { |
| if (tmp_3_alt_flag_0 == ALT_MAYBE) { |
| current_location.update_lineno(90); |
| #line 90 "Isotptest.ttcn" |
| tmp_3_alt_flag_0 = PTC__isotp__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_3_alt_flag_0 == ALT_YES) { |
| current_location.update_lineno(92); |
| #line 92 "Isotptest.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_3_alt_flag_1 == ALT_MAYBE) { |
| current_location.update_lineno(93); |
| #line 93 "Isotptest.ttcn" |
| tmp_3_alt_flag_1 = PTC__isotp__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_3_alt_flag_1 == ALT_YES) { |
| current_location.update_lineno(94); |
| #line 94 "Isotptest.ttcn" |
| TTCN_Logger::log_str(TTCN_USER, "Received Opening Socket failed"); |
| current_location.update_lineno(94); |
| #line 94 "Isotptest.ttcn" |
| TTCN_Runtime::setverdict(FAIL); |
| break; |
| } |
| } |
| if (tmp_3_alt_flag_2 == ALT_MAYBE) { |
| current_location.update_lineno(95); |
| #line 95 "Isotptest.ttcn" |
| tmp_3_alt_flag_2 = t__guard.timeout(NULL); |
| if (tmp_3_alt_flag_2 == ALT_YES) { |
| current_location.update_lineno(96); |
| #line 96 "Isotptest.ttcn" |
| TTCN_Logger::log_str(TTCN_USER, "timeout!"); |
| current_location.update_lineno(97); |
| #line 97 "Isotptest.ttcn" |
| TTCN_Runtime::setverdict(FAIL); |
| break; |
| } |
| } |
| if (tmp_3_alt_flag_3 == ALT_MAYBE) { |
| current_location.update_lineno(98); |
| #line 98 "Isotptest.ttcn" |
| tmp_3_alt_flag_3 = t__guard.timeout(NULL); |
| if (tmp_3_alt_flag_3 == ALT_YES) { |
| current_location.update_lineno(99); |
| #line 99 "Isotptest.ttcn" |
| TTCN_Logger::log_str(TTCN_USER, "timeout!"); |
| current_location.update_lineno(100); |
| #line 100 "Isotptest.ttcn" |
| TTCN_Runtime::setverdict(FAIL); |
| break; |
| } |
| } |
| if (tmp_3_default_flag == ALT_MAYBE) { |
| tmp_3_default_flag = TTCN_Default::try_altsteps(); |
| if (tmp_3_default_flag == ALT_YES || tmp_3_default_flag == ALT_BREAK) break; |
| else if (tmp_3_default_flag == ALT_REPEAT) goto tmp_3; |
| } |
| current_location.update_lineno(89); |
| #line 89 "Isotptest.ttcn" |
| if (tmp_3_alt_flag_0 == ALT_NO && tmp_3_alt_flag_1 == ALT_NO && tmp_3_alt_flag_2 == ALT_NO && tmp_3_alt_flag_3 == ALT_NO && tmp_3_default_flag == ALT_NO) TTCN_error("None of the branches can be chosen in the alt statement in file Isotptest.ttcn between lines 89 and 101."); |
| TTCN_Snapshot::take_new(TRUE); |
| } |
| } |
| current_location.update_lineno(102); |
| #line 102 "Isotptest.ttcn" |
| t__guard.stop(); |
| current_location.update_lineno(103); |
| #line 103 "Isotptest.ttcn" |
| return v__result; |
| } |
| |
| void start_f__open__socket(const COMPONENT& component_reference, const SocketCAN__open__socket__type& v__socket__type) |
| { |
| TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); |
| TTCN_Logger::log_event_str("Starting function f_open_socket("); |
| 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, "Isotptest", "f_open_socket", text_buf); |
| v__socket__type.encode_text(text_buf); |
| TTCN_Runtime::send_start_component(text_buf); |
| } |
| |
| SocketCAN__open__isotp__result f__open__isotp(const OCTETSTRING& p__rx__can__id, const OCTETSTRING& p__tx__can__id) |
| { |
| TTCN_Location current_location("Isotptest.ttcn", 106, TTCN_Location::LOCATION_FUNCTION, "f_open_isotp"); |
| current_location.update_lineno(110); |
| #line 110 "Isotptest.ttcn" |
| INTEGER v__socket__id; |
| current_location.update_lineno(111); |
| #line 111 "Isotptest.ttcn" |
| v__socket__id = f__open__socket(SocketCAN__open__socket__type::OPEN__CAN__ISOTP).id(); |
| current_location.update_lineno(112); |
| #line 112 "Isotptest.ttcn" |
| SocketCAN__Types::SocketCAN__ifr v__ifr; |
| current_location.update_lineno(113); |
| #line 113 "Isotptest.ttcn" |
| v__ifr = f__ioctl__get__if__index(v__socket__id).ifr(); |
| current_location.update_lineno(114); |
| #line 114 "Isotptest.ttcn" |
| SocketCAN__Types::SocketCAN__bind__result v__bind__result; |
| current_location.update_lineno(115); |
| #line 115 "Isotptest.ttcn" |
| v__bind__result = f__bind(v__socket__id, const_cast< const SocketCAN__Types::SocketCAN__ifr&>(v__ifr).if__index(), p__rx__can__id, p__tx__can__id); |
| current_location.update_lineno(117); |
| #line 117 "Isotptest.ttcn" |
| SocketCAN__open__isotp__result v__result; |
| current_location.update_lineno(118); |
| #line 118 "Isotptest.ttcn" |
| v__result.ifr() = v__ifr; |
| v__result.socket__id() = v__socket__id; |
| current_location.update_lineno(120); |
| #line 120 "Isotptest.ttcn" |
| return v__result; |
| } |
| |
| void start_f__open__isotp(const COMPONENT& component_reference, const OCTETSTRING& p__rx__can__id, const OCTETSTRING& p__tx__can__id) |
| { |
| TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); |
| TTCN_Logger::log_event_str("Starting function f_open_isotp("); |
| p__rx__can__id.log(); |
| TTCN_Logger::log_event_str(", "); |
| p__tx__can__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, "Isotptest", "f_open_isotp", text_buf); |
| p__rx__can__id.encode_text(text_buf); |
| p__tx__can__id.encode_text(text_buf); |
| TTCN_Runtime::send_start_component(text_buf); |
| } |
| |
| SocketCAN__Types::SocketCAN__ioctl__result f__ioctl__get__if__index(const INTEGER& p__socket__id) |
| { |
| TTCN_Location current_location("Isotptest.ttcn", 123, TTCN_Location::LOCATION_FUNCTION, "f_ioctl_get_if_index"); |
| current_location.update_lineno(126); |
| #line 126 "Isotptest.ttcn" |
| SocketCAN__Types::SocketCAN__ioctl__result v__result; |
| current_location.update_lineno(127); |
| #line 127 "Isotptest.ttcn" |
| TIMER t__guard("t_guard"); |
| current_location.update_lineno(128); |
| #line 128 "Isotptest.ttcn" |
| t__guard.start(1.0e1); |
| current_location.update_lineno(130); |
| #line 130 "Isotptest.ttcn" |
| { |
| SocketCAN__Types::SocketCAN__ioctl_template tmp_8; |
| tmp_8.id() = p__socket__id; |
| tmp_8.ifu() = OMIT_VALUE; |
| PTC__isotp__CT_component_pt__socketCAN.send(tmp_8, NULL); |
| } |
| current_location.update_lineno(132); |
| #line 132 "Isotptest.ttcn" |
| { |
| tmp_9: |
| alt_status tmp_9_alt_flag_0 = ALT_MAYBE; |
| alt_status tmp_9_alt_flag_1 = ALT_MAYBE; |
| alt_status tmp_9_alt_flag_2 = ALT_MAYBE; |
| alt_status tmp_9_default_flag = ALT_MAYBE; |
| TTCN_Snapshot::take_new(FALSE); |
| for ( ; ; ) { |
| if (tmp_9_alt_flag_0 == ALT_MAYBE) { |
| current_location.update_lineno(133); |
| #line 133 "Isotptest.ttcn" |
| tmp_9_alt_flag_0 = PTC__isotp__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_9_alt_flag_0 == ALT_YES) { |
| current_location.update_lineno(134); |
| #line 134 "Isotptest.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_9_alt_flag_1 == ALT_MAYBE) { |
| current_location.update_lineno(135); |
| #line 135 "Isotptest.ttcn" |
| tmp_9_alt_flag_1 = PTC__isotp__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_9_alt_flag_1 == ALT_YES) { |
| current_location.update_lineno(136); |
| #line 136 "Isotptest.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(136); |
| #line 136 "Isotptest.ttcn" |
| TTCN_Runtime::setverdict(FAIL); |
| break; |
| } |
| } |
| if (tmp_9_alt_flag_2 == ALT_MAYBE) { |
| current_location.update_lineno(137); |
| #line 137 "Isotptest.ttcn" |
| tmp_9_alt_flag_2 = t__guard.timeout(NULL); |
| if (tmp_9_alt_flag_2 == ALT_YES) { |
| current_location.update_lineno(138); |
| #line 138 "Isotptest.ttcn" |
| TTCN_Logger::log_str(TTCN_USER, "timeout!"); |
| current_location.update_lineno(139); |
| #line 139 "Isotptest.ttcn" |
| TTCN_Runtime::setverdict(FAIL); |
| break; |
| } |
| } |
| if (tmp_9_default_flag == ALT_MAYBE) { |
| tmp_9_default_flag = TTCN_Default::try_altsteps(); |
| if (tmp_9_default_flag == ALT_YES || tmp_9_default_flag == ALT_BREAK) break; |
| else if (tmp_9_default_flag == ALT_REPEAT) goto tmp_9; |
| } |
| current_location.update_lineno(132); |
| #line 132 "Isotptest.ttcn" |
| if (tmp_9_alt_flag_0 == ALT_NO && tmp_9_alt_flag_1 == ALT_NO && tmp_9_alt_flag_2 == ALT_NO && tmp_9_default_flag == ALT_NO) TTCN_error("None of the branches can be chosen in the alt statement in file Isotptest.ttcn between lines 132 and 141."); |
| TTCN_Snapshot::take_new(TRUE); |
| } |
| } |
| current_location.update_lineno(142); |
| #line 142 "Isotptest.ttcn" |
| return v__result; |
| } |
| |
| void start_f__ioctl__get__if__index(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_index("); |
| 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, "Isotptest", "f_ioctl_get_if_index", text_buf); |
| p__socket__id.encode_text(text_buf); |
| TTCN_Runtime::send_start_component(text_buf); |
| } |
| |
| SocketCAN__Types::SocketCAN__bind__result f__bind(const INTEGER& p__socket__id, const INTEGER& p__if__index, const OCTETSTRING& p__rx__can__id, const OCTETSTRING& p__tx__can__id) |
| { |
| TTCN_Location current_location("Isotptest.ttcn", 145, TTCN_Location::LOCATION_FUNCTION, "f_bind"); |
| current_location.update_lineno(151); |
| #line 151 "Isotptest.ttcn" |
| SocketCAN__Types::SocketCAN__bind__result v__result; |
| current_location.update_lineno(152); |
| #line 152 "Isotptest.ttcn" |
| TIMER t__guard("t_guard"); |
| current_location.update_lineno(153); |
| #line 153 "Isotptest.ttcn" |
| t__guard.start(1.0e1); |
| current_location.update_lineno(155); |
| #line 155 "Isotptest.ttcn" |
| { |
| SocketCAN__Types::SocketCAN__bind_template tmp_10; |
| tmp_10.id() = p__socket__id; |
| { |
| SocketCAN__Types::SocketCAN__bind__isotp_template& tmp_11 = tmp_10.bindu().isotp(); |
| tmp_11.if__index() = p__if__index; |
| tmp_11.rx__can__id() = p__rx__can__id; |
| tmp_11.tx__can__id() = p__tx__can__id; |
| } |
| PTC__isotp__CT_component_pt__socketCAN.send(tmp_10, NULL); |
| } |
| current_location.update_lineno(158); |
| #line 158 "Isotptest.ttcn" |
| { |
| tmp_12: |
| alt_status tmp_12_alt_flag_0 = ALT_MAYBE; |
| alt_status tmp_12_alt_flag_1 = ALT_MAYBE; |
| alt_status tmp_12_alt_flag_2 = ALT_MAYBE; |
| alt_status tmp_12_default_flag = ALT_MAYBE; |
| TTCN_Snapshot::take_new(FALSE); |
| for ( ; ; ) { |
| if (tmp_12_alt_flag_0 == ALT_MAYBE) { |
| current_location.update_lineno(159); |
| #line 159 "Isotptest.ttcn" |
| tmp_12_alt_flag_0 = PTC__isotp__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_12_alt_flag_0 == ALT_YES) { |
| current_location.update_lineno(160); |
| #line 160 "Isotptest.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_12_alt_flag_1 == ALT_MAYBE) { |
| current_location.update_lineno(161); |
| #line 161 "Isotptest.ttcn" |
| tmp_12_alt_flag_1 = PTC__isotp__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_12_alt_flag_1 == ALT_YES) break; |
| } |
| if (tmp_12_alt_flag_2 == ALT_MAYBE) { |
| current_location.update_lineno(162); |
| #line 162 "Isotptest.ttcn" |
| tmp_12_alt_flag_2 = t__guard.timeout(NULL); |
| if (tmp_12_alt_flag_2 == ALT_YES) { |
| current_location.update_lineno(163); |
| #line 163 "Isotptest.ttcn" |
| TTCN_Logger::log_str(TTCN_USER, "timeout!"); |
| current_location.update_lineno(164); |
| #line 164 "Isotptest.ttcn" |
| TTCN_Runtime::setverdict(FAIL); |
| break; |
| } |
| } |
| if (tmp_12_default_flag == ALT_MAYBE) { |
| tmp_12_default_flag = TTCN_Default::try_altsteps(); |
| if (tmp_12_default_flag == ALT_YES || tmp_12_default_flag == ALT_BREAK) break; |
| else if (tmp_12_default_flag == ALT_REPEAT) goto tmp_12; |
| } |
| current_location.update_lineno(158); |
| #line 158 "Isotptest.ttcn" |
| if (tmp_12_alt_flag_0 == ALT_NO && tmp_12_alt_flag_1 == ALT_NO && tmp_12_alt_flag_2 == ALT_NO && tmp_12_default_flag == ALT_NO) TTCN_error("None of the branches can be chosen in the alt statement in file Isotptest.ttcn between lines 158 and 166."); |
| TTCN_Snapshot::take_new(TRUE); |
| } |
| } |
| current_location.update_lineno(167); |
| #line 167 "Isotptest.ttcn" |
| return v__result; |
| } |
| |
| void start_f__bind(const COMPONENT& component_reference, const INTEGER& p__socket__id, const INTEGER& p__if__index, const OCTETSTRING& p__rx__can__id, const OCTETSTRING& p__tx__can__id) |
| { |
| TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); |
| TTCN_Logger::log_event_str("Starting function f_bind("); |
| p__socket__id.log(); |
| TTCN_Logger::log_event_str(", "); |
| p__if__index.log(); |
| TTCN_Logger::log_event_str(", "); |
| p__rx__can__id.log(); |
| TTCN_Logger::log_event_str(", "); |
| p__tx__can__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, "Isotptest", "f_bind", text_buf); |
| p__socket__id.encode_text(text_buf); |
| p__if__index.encode_text(text_buf); |
| p__rx__can__id.encode_text(text_buf); |
| p__tx__can__id.encode_text(text_buf); |
| TTCN_Runtime::send_start_component(text_buf); |
| } |
| |
| void f__close__socket(const INTEGER& p__socket__id) |
| { |
| TTCN_Location current_location("Isotptest.ttcn", 170, TTCN_Location::LOCATION_FUNCTION, "f_close_socket"); |
| current_location.update_lineno(172); |
| #line 172 "Isotptest.ttcn" |
| { |
| SocketCAN__Types::SocketCAN__close_template tmp_13; |
| tmp_13.id() = p__socket__id; |
| PTC__isotp__CT_component_pt__socketCAN.send(tmp_13, NULL); |
| } |
| } |
| |
| void start_f__close__socket(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_socket("); |
| 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, "Isotptest", "f_close_socket", text_buf); |
| p__socket__id.encode_text(text_buf); |
| TTCN_Runtime::send_start_component(text_buf); |
| } |
| |
| void f__send__isotp__message(const INTEGER& p__socket__id, const OCTETSTRING& p__pdu) |
| { |
| TTCN_Location current_location("Isotptest.ttcn", 174, TTCN_Location::LOCATION_FUNCTION, "f_send_isotp_message"); |
| current_location.update_lineno(177); |
| #line 177 "Isotptest.ttcn" |
| { |
| SocketCAN__Types::SocketCAN__write__isotp_template tmp_14; |
| tmp_14.id() = p__socket__id; |
| tmp_14.pdu() = p__pdu; |
| PTC__isotp__CT_component_pt__socketCAN.send(tmp_14, NULL); |
| } |
| current_location.update_lineno(178); |
| #line 178 "Isotptest.ttcn" |
| { |
| tmp_15: |
| alt_status tmp_15_alt_flag_0 = ALT_MAYBE; |
| alt_status tmp_15_default_flag = ALT_MAYBE; |
| TTCN_Snapshot::take_new(FALSE); |
| for ( ; ; ) { |
| if (tmp_15_alt_flag_0 == ALT_MAYBE) { |
| current_location.update_lineno(179); |
| #line 179 "Isotptest.ttcn" |
| tmp_15_alt_flag_0 = PTC__isotp__CT_component_pt__socketCAN.receive(Isotp::a__SocketCAN__write__isotp__result(SocketCAN__Templates::a__result(SocketCAN__Types::SocketCAN__Result__code::SocketCAN__SUCCESS)), NULL, any_compref, NULL, NULL, NULL); |
| if (tmp_15_alt_flag_0 == ALT_YES) { |
| current_location.update_lineno(180); |
| #line 180 "Isotptest.ttcn" |
| TTCN_Logger::log_str(TTCN_USER, "Sent ISOTP Message \n"); |
| break; |
| } |
| } |
| if (tmp_15_default_flag == ALT_MAYBE) { |
| tmp_15_default_flag = TTCN_Default::try_altsteps(); |
| if (tmp_15_default_flag == ALT_YES || tmp_15_default_flag == ALT_BREAK) break; |
| else if (tmp_15_default_flag == ALT_REPEAT) goto tmp_15; |
| } |
| current_location.update_lineno(178); |
| #line 178 "Isotptest.ttcn" |
| if (tmp_15_alt_flag_0 == ALT_NO && tmp_15_default_flag == ALT_NO) TTCN_error("None of the branches can be chosen in the alt statement in file Isotptest.ttcn between lines 178 and 182."); |
| TTCN_Snapshot::take_new(TRUE); |
| } |
| } |
| } |
| |
| void start_f__send__isotp__message(const COMPONENT& component_reference, const INTEGER& p__socket__id, const OCTETSTRING& p__pdu) |
| { |
| TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); |
| TTCN_Logger::log_event_str("Starting function f_send_isotp_message("); |
| p__socket__id.log(); |
| TTCN_Logger::log_event_str(", "); |
| p__pdu.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, "Isotptest", "f_send_isotp_message", text_buf); |
| p__socket__id.encode_text(text_buf); |
| p__pdu.encode_text(text_buf); |
| TTCN_Runtime::send_start_component(text_buf); |
| } |
| |
| void f__behaviour__isotp(const BOOLEAN& p__initiator, const OCTETSTRING& p__rx__can__id, const OCTETSTRING& p__tx__can__id) |
| { |
| TTCN_Location current_location("Isotptest.ttcn", 186, TTCN_Location::LOCATION_FUNCTION, "f_behaviour_isotp"); |
| current_location.update_lineno(191); |
| #line 191 "Isotptest.ttcn" |
| { |
| Map_Params tmp_16(0); |
| TTCN_Runtime::map_port(self, PTC__isotp__CT_component_pt__socketCAN.get_name(), SYSTEM_COMPREF, "pt_socketCAN", tmp_16); |
| } |
| current_location.update_lineno(192); |
| #line 192 "Isotptest.ttcn" |
| INTEGER v__socket__id; |
| current_location.update_lineno(193); |
| #line 193 "Isotptest.ttcn" |
| SocketCAN__Types::SocketCAN__ifr v__ifr; |
| current_location.update_lineno(194); |
| #line 194 "Isotptest.ttcn" |
| SocketCAN__Types::SocketCAN__send__data__ifu v__ifu; |
| current_location.update_lineno(196); |
| #line 196 "Isotptest.ttcn" |
| SocketCAN__open__isotp__result res; |
| current_location.update_lineno(197); |
| #line 197 "Isotptest.ttcn" |
| res = f__open__isotp(p__rx__can__id, p__tx__can__id); |
| current_location.update_lineno(198); |
| #line 198 "Isotptest.ttcn" |
| v__socket__id = const_cast< const SocketCAN__open__isotp__result&>(res).socket__id(); |
| current_location.update_lineno(199); |
| #line 199 "Isotptest.ttcn" |
| v__ifr = const_cast< const SocketCAN__open__isotp__result&>(res).ifr(); |
| current_location.update_lineno(200); |
| #line 200 "Isotptest.ttcn" |
| v__ifu.if__name() = const_cast< const SocketCAN__Types::SocketCAN__ifr&>(v__ifr).if__name(); |
| current_location.update_lineno(202); |
| #line 202 "Isotptest.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(204); |
| #line 204 "Isotptest.ttcn" |
| BOOLEAN condition3(TRUE); |
| current_location.update_lineno(207); |
| #line 207 "Isotptest.ttcn" |
| if ((p__initiator == TRUE)) { |
| current_location.update_lineno(208); |
| #line 208 "Isotptest.ttcn" |
| OCTETSTRING v__pdu(os_0); |
| current_location.update_lineno(209); |
| #line 209 "Isotptest.ttcn" |
| f__send__isotp__message(v__socket__id, v__pdu); |
| } |
| for ( ; ; ) { |
| current_location.update_lineno(211); |
| #line 211 "Isotptest.ttcn" |
| if (!condition3) break; |
| current_location.update_lineno(214); |
| #line 214 "Isotptest.ttcn" |
| SocketCAN__Types::SocketCAN__receive__CAN__or__CAN__FD__frame v__result__socketcan; |
| current_location.update_lineno(215); |
| #line 215 "Isotptest.ttcn" |
| SocketCAN__Types::SocketCAN__receive__isotp__pdu v__result__isotp__pdu; |
| current_location.update_lineno(218); |
| #line 218 "Isotptest.ttcn" |
| { |
| tmp_21: |
| alt_status tmp_21_alt_flag_0 = ALT_MAYBE; |
| alt_status tmp_21_alt_flag_1 = ALT_MAYBE; |
| alt_status tmp_21_default_flag = ALT_MAYBE; |
| TTCN_Snapshot::take_new(FALSE); |
| for ( ; ; ) { |
| if (tmp_21_alt_flag_0 == ALT_MAYBE) { |
| current_location.update_lineno(220); |
| #line 220 "Isotptest.ttcn" |
| tmp_21_alt_flag_0 = PTC__isotp__CT_component_pt__socketCAN.receive(Isotp::a__SocketCAN__receive__isotp__pdu(INTEGER_template(v__socket__id), OCTETSTRING_template(ANY_VALUE), OCTETSTRING_template(ANY_VALUE)), &(v__result__isotp__pdu), any_compref, NULL, NULL, NULL); |
| if (tmp_21_alt_flag_0 == ALT_YES) { |
| current_location.update_lineno(221); |
| #line 221 "Isotptest.ttcn" |
| try { |
| TTCN_Logger::begin_event(TTCN_USER); |
| TTCN_Logger::log_event_str("SocketCan:Isotp pdu received"); |
| v__result__isotp__pdu.log(); |
| TTCN_Logger::end_event(); |
| } catch (...) { |
| TTCN_Logger::finish_event(); |
| throw; |
| } |
| current_location.update_lineno(222); |
| #line 222 "Isotptest.ttcn" |
| f__send__isotp__message(v__socket__id, const_cast< const SocketCAN__Types::SocketCAN__receive__isotp__pdu&>(v__result__isotp__pdu).pdu()); |
| break; |
| } |
| } |
| if (tmp_21_alt_flag_1 == ALT_MAYBE) { |
| current_location.update_lineno(224); |
| #line 224 "Isotptest.ttcn" |
| tmp_21_alt_flag_1 = PTC__isotp__CT_component_pt__socketCAN.receive(Isotp::a__SocketCAN__receive__isotp__pdu(INTEGER_template(ANY_VALUE), OCTETSTRING_template(ANY_VALUE), OCTETSTRING_template(ANY_VALUE)), &(v__result__isotp__pdu), any_compref, NULL, NULL, NULL); |
| if (tmp_21_alt_flag_1 == ALT_YES) { |
| current_location.update_lineno(225); |
| #line 225 "Isotptest.ttcn" |
| try { |
| TTCN_Logger::begin_event(TTCN_USER); |
| TTCN_Logger::log_event_str("SocketCan:Isotp pdu received from unexpected port"); |
| v__result__isotp__pdu.log(); |
| TTCN_Logger::end_event(); |
| } catch (...) { |
| TTCN_Logger::finish_event(); |
| throw; |
| } |
| current_location.update_lineno(226); |
| #line 226 "Isotptest.ttcn" |
| TTCN_Runtime::setverdict(INCONC); |
| break; |
| } |
| } |
| if (tmp_21_default_flag == ALT_MAYBE) { |
| tmp_21_default_flag = TTCN_Default::try_altsteps(); |
| if (tmp_21_default_flag == ALT_YES || tmp_21_default_flag == ALT_BREAK) break; |
| else if (tmp_21_default_flag == ALT_REPEAT) goto tmp_21; |
| } |
| current_location.update_lineno(218); |
| #line 218 "Isotptest.ttcn" |
| if (tmp_21_alt_flag_0 == ALT_NO && tmp_21_alt_flag_1 == ALT_NO && tmp_21_default_flag == ALT_NO) TTCN_error("None of the branches can be chosen in the alt statement in file Isotptest.ttcn between lines 218 and 228."); |
| TTCN_Snapshot::take_new(TRUE); |
| } |
| } |
| } |
| current_location.update_lineno(230); |
| #line 230 "Isotptest.ttcn" |
| f__close__socket(v__socket__id); |
| current_location.update_lineno(231); |
| #line 231 "Isotptest.ttcn" |
| { |
| Map_Params tmp_22(0); |
| TTCN_Runtime::unmap_port(self, PTC__isotp__CT_component_pt__socketCAN.get_name(), SYSTEM_COMPREF, "pt_socketCAN", tmp_22); |
| } |
| current_location.update_lineno(232); |
| #line 232 "Isotptest.ttcn" |
| TTCN_Runtime::setverdict(PASS); |
| } |
| |
| void start_f__behaviour__isotp(const COMPONENT& component_reference, const BOOLEAN& p__initiator, const OCTETSTRING& p__rx__can__id, const OCTETSTRING& p__tx__can__id) |
| { |
| TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); |
| TTCN_Logger::log_event_str("Starting function f_behaviour_isotp("); |
| p__initiator.log(); |
| TTCN_Logger::log_event_str(", "); |
| p__rx__can__id.log(); |
| TTCN_Logger::log_event_str(", "); |
| p__tx__can__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, "Isotptest", "f_behaviour_isotp", text_buf); |
| p__initiator.encode_text(text_buf); |
| p__rx__can__id.encode_text(text_buf); |
| p__tx__can__id.encode_text(text_buf); |
| TTCN_Runtime::send_start_component(text_buf); |
| } |
| |
| verdicttype testcase_tc__Isotp__Example001(boolean has_timer, double timer_value) |
| { |
| TTCN_Runtime::check_begin_testcase(has_timer, timer_value); |
| TTCN_Location current_location("Isotptest.ttcn", 237, TTCN_Location::LOCATION_TESTCASE, "tc_Isotp_Example001"); |
| try { |
| TTCN_Runtime::begin_testcase("Isotptest", "tc_Isotp_Example001", "Isotptest", "MTC_CT", "Isotptest", "MTC_CT", has_timer, timer_value); |
| current_location.update_lineno(240); |
| #line 240 "Isotptest.ttcn" |
| COMPONENT v__PTC__isotp1; |
| current_location.update_lineno(240); |
| #line 240 "Isotptest.ttcn" |
| COMPONENT v__PTC__isotp2; |
| current_location.update_lineno(243); |
| #line 243 "Isotptest.ttcn" |
| v__PTC__isotp1 = TTCN_Runtime::create_component("Isotptest", "PTC_isotp_CT", NULL, NULL, FALSE); |
| current_location.update_lineno(244); |
| #line 244 "Isotptest.ttcn" |
| v__PTC__isotp2 = TTCN_Runtime::create_component("Isotptest", "PTC_isotp_CT", NULL, NULL, FALSE); |
| current_location.update_lineno(252); |
| #line 252 "Isotptest.ttcn" |
| start_f__behaviour__isotp(v__PTC__isotp1, TRUE, os_1, os_2); |
| current_location.update_lineno(253); |
| #line 253 "Isotptest.ttcn" |
| start_f__behaviour__isotp(v__PTC__isotp2, TRUE, os_2, os_1); |
| current_location.update_lineno(256); |
| #line 256 "Isotptest.ttcn" |
| { |
| tmp_25: |
| 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_25; |
| } |
| 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_25; |
| } |
| current_location.update_lineno(256); |
| #line 256 "Isotptest.ttcn" |
| if (alt_flag == ALT_NO && default_flag == ALT_NO) TTCN_error("Stand-alone done statement failed in file Isotptest.ttcn, line 256."); |
| TTCN_Snapshot::take_new(TRUE); |
| } |
| } |
| current_location.update_lineno(262); |
| #line 262 "Isotptest.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_Isotp_Example001 was stopped."); |
| } |
| return TTCN_Runtime::end_testcase(); |
| } |
| |
| |
| /* Bodies of static functions */ |
| |
| static void pre_init_module() |
| { |
| TTCN_Location current_location("Isotptest.ttcn", 0, TTCN_Location::LOCATION_UNKNOWN, "Isotptest"); |
| CanError::module_object.pre_init_module(); |
| SocketCAN__PortType::module_object.pre_init_module(); |
| SocketCAN__Templates::module_object.pre_init_module(); |
| Isotp::module_object.pre_init_module(); |
| current_location.update_lineno(21); |
| #line 21 "Isotptest.ttcn" |
| const_c__guard = 1.0e1; |
| module_object.add_function("f_open_socket", (genericfunc_t)&f__open__socket, (genericfunc_t)&start_f__open__socket); |
| module_object.add_function("f_open_isotp", (genericfunc_t)&f__open__isotp, (genericfunc_t)&start_f__open__isotp); |
| module_object.add_function("f_ioctl_get_if_index", (genericfunc_t)&f__ioctl__get__if__index, (genericfunc_t)&start_f__ioctl__get__if__index); |
| module_object.add_function("f_bind", (genericfunc_t)&f__bind, (genericfunc_t)&start_f__bind); |
| module_object.add_function("f_close_socket", (genericfunc_t)&f__close__socket, (genericfunc_t)&start_f__close__socket); |
| module_object.add_function("f_send_isotp_message", (genericfunc_t)&f__send__isotp__message, (genericfunc_t)&start_f__send__isotp__message); |
| module_object.add_function("f_behaviour_isotp", (genericfunc_t)&f__behaviour__isotp, (genericfunc_t)&start_f__behaviour__isotp); |
| module_object.add_testcase_nonpard("tc_Isotp_Example001", testcase_tc__Isotp__Example001); |
| } |
| |
| static void post_init_module() |
| { |
| TTCN_Location current_location("Isotptest.ttcn", 0, TTCN_Location::LOCATION_UNKNOWN, "Isotptest"); |
| CanError::module_object.post_init_module(); |
| SocketCAN__PortType::module_object.post_init_module(); |
| SocketCAN__Templates::module_object.post_init_module(); |
| Isotp::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_isotp_CT")) { |
| PTC__isotp__CT_component_pt__socketCAN.activate_port(); |
| return TRUE; |
| } else return FALSE; |
| } |
| |
| static boolean init_system_port(const char* component_type, const char* port_name) |
| { |
| if (!strcmp(component_type, "PTC_isotp_CT")) { |
| if (!strcmp(port_name, "pt_socketCAN")) { |
| PTC__isotp__CT_component_pt__socketCAN.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_socket")) { |
| 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_socket("); |
| v__socket__type.log(); |
| TTCN_Logger::log_event_str(")."); |
| TTCN_Logger::end_event(); |
| TTCN_Runtime::function_started(function_arguments); |
| f__open__socket(v__socket__type); |
| TTCN_Runtime::function_finished("f_open_socket"); |
| return TRUE; |
| } else if (!strcmp(function_name, "f_open_isotp")) { |
| OCTETSTRING p__rx__can__id; |
| OCTETSTRING p__tx__can__id; |
| p__rx__can__id.decode_text(function_arguments); |
| p__tx__can__id.decode_text(function_arguments); |
| TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); |
| TTCN_Logger::log_event_str("Starting function f_open_isotp("); |
| p__rx__can__id.log(); |
| TTCN_Logger::log_event_str(", "); |
| p__tx__can__id.log(); |
| TTCN_Logger::log_event_str(")."); |
| TTCN_Logger::end_event(); |
| TTCN_Runtime::function_started(function_arguments); |
| f__open__isotp(p__rx__can__id, p__tx__can__id); |
| TTCN_Runtime::function_finished("f_open_isotp"); |
| return TRUE; |
| } else if (!strcmp(function_name, "f_ioctl_get_if_index")) { |
| 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_index("); |
| p__socket__id.log(); |
| TTCN_Logger::log_event_str(")."); |
| TTCN_Logger::end_event(); |
| TTCN_Runtime::function_started(function_arguments); |
| f__ioctl__get__if__index(p__socket__id); |
| TTCN_Runtime::function_finished("f_ioctl_get_if_index"); |
| return TRUE; |
| } else if (!strcmp(function_name, "f_bind")) { |
| INTEGER p__socket__id; |
| INTEGER p__if__index; |
| OCTETSTRING p__rx__can__id; |
| OCTETSTRING p__tx__can__id; |
| p__socket__id.decode_text(function_arguments); |
| p__if__index.decode_text(function_arguments); |
| p__rx__can__id.decode_text(function_arguments); |
| p__tx__can__id.decode_text(function_arguments); |
| TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); |
| TTCN_Logger::log_event_str("Starting function f_bind("); |
| p__socket__id.log(); |
| TTCN_Logger::log_event_str(", "); |
| p__if__index.log(); |
| TTCN_Logger::log_event_str(", "); |
| p__rx__can__id.log(); |
| TTCN_Logger::log_event_str(", "); |
| p__tx__can__id.log(); |
| TTCN_Logger::log_event_str(")."); |
| TTCN_Logger::end_event(); |
| TTCN_Runtime::function_started(function_arguments); |
| f__bind(p__socket__id, p__if__index, p__rx__can__id, p__tx__can__id); |
| TTCN_Runtime::function_finished("f_bind"); |
| return TRUE; |
| } else if (!strcmp(function_name, "f_close_socket")) { |
| 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_socket("); |
| p__socket__id.log(); |
| TTCN_Logger::log_event_str(")."); |
| TTCN_Logger::end_event(); |
| TTCN_Runtime::function_started(function_arguments); |
| f__close__socket(p__socket__id); |
| TTCN_Runtime::function_finished("f_close_socket"); |
| return TRUE; |
| } else if (!strcmp(function_name, "f_send_isotp_message")) { |
| INTEGER p__socket__id; |
| OCTETSTRING p__pdu; |
| p__socket__id.decode_text(function_arguments); |
| p__pdu.decode_text(function_arguments); |
| TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); |
| TTCN_Logger::log_event_str("Starting function f_send_isotp_message("); |
| p__socket__id.log(); |
| TTCN_Logger::log_event_str(", "); |
| p__pdu.log(); |
| TTCN_Logger::log_event_str(")."); |
| TTCN_Logger::end_event(); |
| TTCN_Runtime::function_started(function_arguments); |
| f__send__isotp__message(p__socket__id, p__pdu); |
| TTCN_Runtime::function_finished("f_send_isotp_message"); |
| return TRUE; |
| } else if (!strcmp(function_name, "f_behaviour_isotp")) { |
| BOOLEAN p__initiator; |
| OCTETSTRING p__rx__can__id; |
| OCTETSTRING p__tx__can__id; |
| p__initiator.decode_text(function_arguments); |
| p__rx__can__id.decode_text(function_arguments); |
| p__tx__can__id.decode_text(function_arguments); |
| TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); |
| TTCN_Logger::log_event_str("Starting function f_behaviour_isotp("); |
| p__initiator.log(); |
| TTCN_Logger::log_event_str(", "); |
| p__rx__can__id.log(); |
| TTCN_Logger::log_event_str(", "); |
| p__tx__can__id.log(); |
| TTCN_Logger::log_event_str(")."); |
| TTCN_Logger::end_event(); |
| TTCN_Runtime::function_started(function_arguments); |
| f__behaviour__isotp(p__initiator, p__rx__can__id, p__tx__can__id); |
| TTCN_Runtime::function_finished("f_behaviour_isotp"); |
| return TRUE; |
| } else return FALSE; |
| } |
| |
| static void module_control_part() |
| { |
| TTCN_Location current_location("Isotptest.ttcn", 268, TTCN_Location::LOCATION_CONTROLPART, "Isotptest"); |
| TTCN_Runtime::begin_controlpart("Isotptest"); |
| current_location.update_lineno(272); |
| #line 272 "Isotptest.ttcn" |
| testcase_tc__Isotp__Example001(FALSE, 0.0); |
| TTCN_Runtime::end_controlpart(); |
| } |
| |
| |
| } /* end of namespace */ |