00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "C_MessageBinarySeparator.hpp"
00021
00022 #include "GeneratorTrace.hpp"
00023 #include "GeneratorError.h"
00024
00025 #include "ProtocolData.hpp"
00026
00027 C_MessageBinarySeparator::C_MessageBinarySeparator(C_ProtocolBinarySeparator *P_protocol)
00028 : C_MessageBinary(P_protocol) {
00029
00030 GEN_DEBUG(1, "C_MessageBinarySeparator::C_MessageBinarySeparator() start");
00031 GEN_DEBUG(1, "C_MessageBinarySeparator::C_MessageBinarySeparator() end");
00032 }
00033
00034 bool C_MessageBinarySeparator::update_fields (C_MessageFrame* P_msg) {
00035
00036 bool L_result ;
00037 C_MessageBinarySeparator *L_msg ;
00038 int L_i ;
00039
00040 L_msg = dynamic_cast<C_MessageBinarySeparator*>(P_msg) ;
00041
00042 GEN_DEBUG(1, "C_MessageBinarySeparator::update_fields() start");
00043
00044 if (L_msg == NULL) {
00045 L_result = false ;
00046 } else {
00047 L_result = (L_msg ->m_nb_body_values == m_nb_body_values) ? true : false ;
00048 if (L_result) {
00049 m_header_id = L_msg->get_id_message();
00050 for (L_i =0 ; L_i < m_nb_body_values ; L_i++) {
00051 m_body_val[L_i].m_id = L_msg->m_body_val[L_i].m_id ;
00052 }
00053 }
00054 }
00055
00056 GEN_DEBUG(1, "C_MessageBinarySeparator::update_fields() end");
00057
00058 return (L_result);
00059 }
00060
00061
00062 C_MessageBinarySeparator::~C_MessageBinarySeparator() {
00063
00064 GEN_DEBUG(1,
00065 "C_MessageBinarySeparator::~C_MessageBinarySeparator() start: ");
00066 GEN_DEBUG(1, "C_MessageBinarySeparator::~C_MessageBinarySeparator() end");
00067 }
00068
00069 bool C_MessageBinarySeparator::compare_types (C_MessageFrame* P_msg) {
00070
00071 bool L_result ;
00072 C_MessageBinarySeparator *L_msg ;
00073
00074 L_msg = dynamic_cast<C_MessageBinarySeparator*>(P_msg) ;
00075
00076 GEN_DEBUG(1, "C_MessageBinarySeparator::compare_types() start");
00077 if (L_msg == NULL) {
00078 L_result = false ;
00079 } else {
00080 T_Value L_orig, L_dest ;
00081 L_orig = L_msg->get_type() ;
00082 L_dest = get_type() ;
00083 L_result = compare_value(L_orig, L_dest) ? true : false ;
00084 FREE_TABLE(L_orig.m_val_binary.m_value);
00085 FREE_TABLE(L_dest.m_val_binary.m_value);
00086 GEN_DEBUG(1, "C_MessageBinarySeparator::compare_types() end");
00087 }
00088 GEN_DEBUG(1, "C_MessageBinarySeparator::compare_types() end");
00089
00090 return (L_result) ;
00091 }
00092
00093 T_Value C_MessageBinarySeparator::get_type() {
00094
00095
00096 int L_idx ;
00097
00098 T_Value L_value ;
00099 bool L_found = false ;
00100 int L_i ;
00101
00102 GEN_DEBUG(1, "C_MessageBinarySeparator::get_type() start");
00103
00104 L_idx = m_protocol -> get_header_type_id_body() ;
00105
00106 for (L_i=0; L_i < m_nb_body_values ; L_i++) {
00107 if (m_body_val[L_i].m_id == L_idx) {
00108 L_found=true;
00109 break;
00110 }
00111 }
00112
00113 if (L_found == true) {
00114 L_value.m_val_binary.m_size = m_body_val[L_i].m_value.m_val_binary.m_size;
00115
00116 if (L_value.m_val_binary.m_size != 0) {
00117 ALLOC_TABLE(L_value.m_val_binary.m_value,
00118 unsigned char*,
00119 sizeof(unsigned char),
00120 L_value.m_val_binary.m_size);
00121
00122 memcpy(L_value.m_val_binary.m_value,
00123 m_body_val[L_i].m_value.m_val_binary.m_value,
00124 L_value.m_val_binary.m_size);
00125 }
00126 }
00127 GEN_DEBUG(1, "C_MessageBinarySeparator::get_type() end");
00128 return (L_value) ;
00129 }
00130
00131
00132 void C_MessageBinarySeparator::update_message_stats () {
00133 int L_i ;
00134
00135 GEN_DEBUG(1, "C_MessageBinarySeparator::update_message_stats() start");
00136
00137 if (m_protocol->get_stats()) {
00138 (m_protocol->get_stats())->updateStats (E_MESSAGE,
00139 E_RECEIVE,
00140 m_header_id);
00141
00142 for (L_i =0 ; L_i < m_nb_body_values ; L_i++) {
00143 if (m_body_val[L_i].m_value.m_val_binary.m_size != 0 ) {
00144 (m_protocol->get_stats())->updateStats (E_MESSAGE_COMPONENT,
00145 E_RECEIVE,
00146 m_body_val[L_i].m_id);
00147 }
00148 }
00149 }
00150 GEN_DEBUG(1, "C_MessageBinarySeparator::update_message_stats() end");
00151 }