// This Test Port skeleton source file was generated by the
// TTCN-3 Compiler of the TTCN-3 Test Executor version 11.0.0
// for Botond Baranyi (ebotbar@seliiuvd10571) on Wed May 14 15:41:32 2025

// Copyright (c) 2000-2025 Ericsson Telecom AB

// You may modify this file. Complete the body of empty functions and
// add your member functions here.

#include "PT_Proc_Ext.hh"

namespace broadcast {

Vector< INTEGER > PT__Proc__Ext::expected_calls;
Vector< INTEGER > PT__Proc__Ext::expected_replies;
Vector< INTEGER > PT__Proc__Ext::expected_exceptions;

void ef__add__call__target(const INTEGER& p__target)
{
  PT__Proc__Ext::expected_calls.push_back(p__target);
}

void ef__add__reply__target(const INTEGER& p__target)
{
  PT__Proc__Ext::expected_replies.push_back(p__target);
}

void ef__add__raise__target(const INTEGER& p__target)
{
  PT__Proc__Ext::expected_exceptions.push_back(p__target);
}

PT__Proc__Ext::PT__Proc__Ext(const char *par_port_name)
	: PT__Proc__Ext_BASE(par_port_name)
{

}

PT__Proc__Ext::~PT__Proc__Ext()
{

}

void PT__Proc__Ext::set_parameter(const char * /*parameter_name*/,
	const char * /*parameter_value*/)
{

}

/*void PT__Proc__Ext::Handle_Fd_Event(int fd, boolean is_readable,
	boolean is_writable, boolean is_error) {}*/

void PT__Proc__Ext::Handle_Fd_Event_Error(int /*fd*/)
{

}

void PT__Proc__Ext::Handle_Fd_Event_Writable(int /*fd*/)
{

}

void PT__Proc__Ext::Handle_Fd_Event_Readable(int /*fd*/)
{

}

/*void PT__Proc__Ext::Handle_Timeout(double time_since_last_call) {}*/

void PT__Proc__Ext::user_map(const char * /*system_port*/, Map_Params& /*params*/)
{

}

void PT__Proc__Ext::user_unmap(const char * /*system_port*/, Map_Params& /*params*/)
{

}

void PT__Proc__Ext::user_start()
{

}

void PT__Proc__Ext::user_stop()
{

}

void PT__Proc__Ext::outgoing_call(const Sig_call& call_par,
	const INTEGER * destination_address)
{
  if (expected_calls.empty()) {
    TTCN_Runtime::setverdict(FAIL, "Unexpected message received on system.");
  }
  else {
    INTEGER target_exp = expected_calls.front();
    INTEGER target_got = destination_address != NULL ? *destination_address : c__default__target;
    if (target_exp == target_got) {
      if (call_par.p() != c__call__par) {
        TTCN_Runtime::setverdict(FAIL, (TTCN_Logger::begin_event_log2str(),
          TTCN_Logger::log_event_str("Incorrect call parameter received on system. Got: "),
          call_par.p().log(),
          TTCN_Logger::log_event_str(", expected: "),
          c__call__par.log(),
          TTCN_Logger::end_event_log2str()));
      }
    }
    else {
      TTCN_Runtime::setverdict(FAIL, (TTCN_Logger::begin_event_log2str(),
        TTCN_Logger::log_event_str("Address of received call on system is incorrect. Got: "),
        target_got.log(),
        TTCN_Logger::log_event_str(", expected: "),
        target_exp.log(),
        TTCN_Logger::end_event_log2str()));
    }
    expected_calls.erase_at(0);
  }
}

void PT__Proc__Ext::outgoing_reply(const Sig_reply& reply_par,
	const INTEGER * destination_address)
{
  if (expected_replies.empty()) {
    TTCN_Runtime::setverdict(FAIL, "Unexpected message received on system.");
  }
  else {
    INTEGER target_exp = expected_replies.front();
    INTEGER target_got = destination_address != NULL ? *destination_address : c__default__target;
    if (target_exp == target_got) {
      if (reply_par.p() != c__reply__par) {
        TTCN_Runtime::setverdict(FAIL, (TTCN_Logger::begin_event_log2str(),
          TTCN_Logger::log_event_str("Incorrect reply parameter received on system. Got: "),
          reply_par.p().log(),
          TTCN_Logger::log_event_str(", expected: "),
          c__reply__par.log(),
          TTCN_Logger::end_event_log2str()));
      }
      else if (reply_par.return_value() != c__reply__val) {
        TTCN_Runtime::setverdict(FAIL, (TTCN_Logger::begin_event_log2str(),
          TTCN_Logger::log_event_str("Incorrect reply parameter received on system. Got: "),
          reply_par.return_value().log(),
          TTCN_Logger::log_event_str(", expected: "),
          c__reply__val.log(),
          TTCN_Logger::end_event_log2str()));
      }
    }
    else {
      TTCN_Runtime::setverdict(FAIL, (TTCN_Logger::begin_event_log2str(),
        TTCN_Logger::log_event_str("Address of received reply on system is incorrect. Got: "),
        target_got.log(),
        TTCN_Logger::log_event_str(", expected: "),
        target_exp.log(),
        TTCN_Logger::end_event_log2str()));
    }
    expected_replies.erase_at(0);
  }
}

void PT__Proc__Ext::outgoing_raise(const Sig_exception& raise_exception,
	const INTEGER * destination_address)
{
  if (expected_exceptions.empty()) {
    TTCN_Runtime::setverdict(FAIL, "Unexpected message received on system.");
  }
  else {
    INTEGER target_exp = expected_exceptions.front();
    INTEGER target_got = destination_address != NULL ? *destination_address : c__default__target;
    if (target_exp == target_got) {
      if (raise_exception.INTEGER_field() != c__exception) {
        TTCN_Runtime::setverdict(FAIL, (TTCN_Logger::begin_event_log2str(),
          TTCN_Logger::log_event_str("Incorrect call parameter received on system. Got: "),
          raise_exception.INTEGER_field().log(),
          TTCN_Logger::log_event_str(", expected: "),
          c__exception.log(),
          TTCN_Logger::end_event_log2str()));
      }
    }
    else {
      TTCN_Runtime::setverdict(FAIL, (TTCN_Logger::begin_event_log2str(),
        TTCN_Logger::log_event_str("Address of received call on system is incorrect. Got: "),
        target_got.log(),
        TTCN_Logger::log_event_str(", expected: "),
        target_exp.log(),
        TTCN_Logger::end_event_log2str()));
    }
    expected_exceptions.erase_at(0);
  }
}

} /* end of namespace */

