Commit 3b452716 authored by garciay's avatar garciay
Browse files

UpperTester changes ongoing

parent 154ab3f5
Loading
Loading
Loading
Loading
+76 −59
Original line number Diff line number Diff line
#include "UpperTesterLayer.hh"
#include "UpperTesterDenmLayer.hh"
#include "loggers.hh"

//=============================================================================
@@ -50,18 +50,17 @@ void UpperTesterPort::user_map(const char * system_port)
  {
    loggers::get_instance().log(">>> UpperTesterPort::user_map: %s", system_port);
    // Build layer stack
    /*    Params::iterator it = _cfg_params.find(std::string("params"));
    Params::iterator it = _cfg_params.find(std::string("params"));
    if (it != _cfg_params.end()) {
      loggers::get_instance().log("UpperTesterPort::user_map: %s", it->second.c_str());
      _layer = LayerStackBuilder::GetInstance()->createLayerStack(it->second.c_str());
    if (static_cast<UpperTesterLayer *>(_layer) == NULL) {
      if (static_cast<UpperTesterDenmLayer *>(_layer) == NULL) {
        loggers::get_instance().error("UpperTesterPort::user_map: Invalid stack configuration: %s", it->second.c_str());
      }
      static_cast<UpperTesterLayer *>(_layer)->addUpperPort(this);
      static_cast<UpperTesterDenmLayer *>(_layer)->addUpperPort(this);
    } else {
      loggers::get_instance().error("UpperTesterPort::user_map: No layers defined in configuration file");
    }
    */
  }

  void UpperTesterPort::user_unmap(const char * system_port)
@@ -84,9 +83,14 @@ void UpperTesterPort::user_stop()

  }

void UpperTesterPort::outgoing_send(const LibItsDenm__TypesAndValues::UtDenmInitialize& /*send_par*/)
  void UpperTesterPort::outgoing_send(const LibItsDenm__TypesAndValues::UtDenmInitialize& send_par)
  {
    loggers::get_instance().log_msg(">>> UppertesterPort::outgoing_send: ", send_par);
    
    float duration;
    loggers::get_instance().set_start_time(_time_key);
    static_cast<UpperTesterDenmLayer *>(_layer)->sendMsg(send_par, _layer_params);
    loggers::get_instance().set_stop_time(_time_key, duration);
  }

  void UpperTesterPort::outgoing_send(const LibItsDenm__TypesAndValues::UtDenmTrigger& /*send_par*/)
@@ -114,4 +118,17 @@ void UpperTesterPort::outgoing_send(const LibItsDenm__TypesAndValues::UtChangePs

  }

  void UpperTesterPort::receiveMsg (const Base_Type& p_ind, const Params& p_params) {
    loggers::get_instance().log_msg(">>> UpperTesterPort::receive_msg: ", p_ind);
    // Sanity check
    if (!p_ind.is_bound()) {
      return;
    }

    //loggers::get_instance().log("UpperTesterPort::receive_msg: %s", p_ind.get_descriptor()->name);
    if (std::string(p_ind.get_descriptor()->name).compare("@LibItsDenm_TypesAndValues.UtDenmResults") == 0) { // TODO To be refined
      incoming_message((LibItsDenm__TypesAndValues::UtDenmResults&)p_ind);
    }
  }

} /* end of namespace */
+31 −29
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ public:
    void set_parameter(const char *parameter_name,
                       const char *parameter_value);

    void receiveMsg (const Base_Type&, const Params&);

  private:
    /* void Handle_Fd_Event(int fd, boolean is_readable,
       boolean is_writable, boolean is_error); */
+56 −56
Original line number Diff line number Diff line
#include "UpperTesterLayer.hh"
#include "UpperTesterGnLayer.hh"
#include "loggers.hh"

//=============================================================================
@@ -53,10 +53,10 @@ void UpperTesterPort::user_map(const char * system_port)
    if (it != _cfg_params.end()) {
      loggers::get_instance().log("UpperTesterPort::user_map: %s", it->second.c_str());
      _layer = LayerStackBuilder::GetInstance()->createLayerStack(it->second.c_str());
    if (static_cast<UpperTesterLayer *>(_layer) == NULL) {
      if (static_cast<UpperTesterGnLayer *>(_layer) == NULL) {
        loggers::get_instance().error("UpperTesterPort::user_map: Invalid stack configuration: %s", it->second.c_str());
      }
      static_cast<UpperTesterLayer *>(_layer)->addUpperPort(this);
      static_cast<UpperTesterGnLayer *>(_layer)->addUpperPort(this);
    } else {
      loggers::get_instance().error("UpperTesterPort::user_map: No layers defined in configuration file");
    }
@@ -88,7 +88,7 @@ void UpperTesterPort::outgoing_send(const LibItsGeoNetworking__TypesAndValues::U
    
    float duration;
    loggers::get_instance().set_start_time(_time_key);
    static_cast<UpperTesterLayer *>(_layer)->sendMsg(send_par, _layer_params);
    static_cast<UpperTesterGnLayer *>(_layer)->sendMsg(send_par, _layer_params);
    loggers::get_instance().set_stop_time(_time_key, duration);
  }

@@ -98,7 +98,7 @@ void UpperTesterPort::outgoing_send(const LibItsGeoNetworking__TypesAndValues::U
    
    float duration;
    loggers::get_instance().set_start_time(_time_key);
    static_cast<UpperTesterLayer *>(_layer)->sendMsg(send_par, _layer_params);
    static_cast<UpperTesterGnLayer *>(_layer)->sendMsg(send_par, _layer_params);
    loggers::get_instance().set_stop_time(_time_key, duration);
  }

+19 −0
Original line number Diff line number Diff line
@@ -150,3 +150,22 @@ int UpperTesterCodec::decode (const OCTETSTRING& data, LibItsGeoNetworking__Type
  loggers::get_instance().log_msg("<<< UpperTesterCodec::decode", msg);
  return 0;
}

int UpperTesterCodec::decode (const OCTETSTRING& data, LibItsDenm__TypesAndValues::UtDenmResults& msg, Params* params)
{
  loggers::get_instance().log_to_hexa(">>> UpperTesterCodec::decode: decoding_buffer=", data);

  const unsigned char* ptr = static_cast<const unsigned char*>(data);
  if (*ptr == UpperTesterCodec::c_utDenmInitializeResult) {
    msg.utDenmInitializeResult() = BOOLEAN(*(ptr + 1) == 0x01);
  } else if (*ptr == UpperTesterCodec::c_utChangePositionResult) {
    msg.utDenmChangePositionResult() = BOOLEAN(*(ptr + 1) == 0x01);
  } else if (*ptr == UpperTesterCodec::c_utDenmTriggerResult) {
    // TODO msg.utDenmTriggerResult() = BOOLEAN(*(ptr + 1) == 0x01);
  } else {
    TTCN_warning("UpperTesterCodec::decode: Unsupported result");
  }
  
  loggers::get_instance().log_msg("<<< UpperTesterCodec::decode", msg);
  return 0;
}
+9 −1
Original line number Diff line number Diff line
@@ -14,6 +14,10 @@ namespace LibItsGeoNetworking__TypesAndValues {
  class UtGnResults;
}

namespace LibItsDenm__TypesAndValues {
  class UtDenmResults;
}

class UpperTesterCodec: public Codec <
  Record_Type,
  Record_Type>
@@ -29,6 +33,9 @@ class UpperTesterCodec: public Codec <
  const unsigned char c_utGnTrigger_Shb = 0x53;
  const unsigned char c_utGnTrigger_Tsb = 0x54;

  const unsigned char c_utDenmInitializeResult = 0x01;
  const unsigned char c_utDenmTriggerResult = 0x41;

  int encode_ (const Base_Type& type, const TTCN_Typedescriptor_t& field_descriptor, TTCN_Buffer& encoding_buffer);

public:
@@ -39,5 +46,6 @@ public:
  virtual int encode (const Base_Type&, OCTETSTRING& data);
  virtual int decode (const OCTETSTRING& data, Record_Type&, Params* params = NULL);
  int decode (const OCTETSTRING& data, LibItsGeoNetworking__TypesAndValues::UtGnResults& msg, Params* params = NULL);
  int decode (const OCTETSTRING& data, LibItsDenm__TypesAndValues::UtDenmResults& msg, Params* params = NULL);
};
#endif
Loading