///////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2019 Ericsson Telecom AB
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v2.0
// which accompanies this distribution, and is available at
// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
///////////////////////////////////////////////////////////////////////////////
//
//  File:     ISUP_Mapping.ttcn
//  Rev:      R8A
//  Prodnr:   CNL 113 365
//  Updated:  2006-05-10
//  Contact:  http://ttcn.ericsson.se
///////////////////////////////////////////////////////////////////////////////
module ISUP_Mapping
{
 import from MTP3asp_PortType all;
 import from MTP3asp_Types all;
 import from ISUP_Types all;

group Types
{
  type record MSC_ISUP_MTP3_parameters
    {
     MTP3_Field_sio    sio,
     integer           opc,
     integer           dpc,
     integer           sls
    }

group PortTypes
{
  //*************************************************************************
  //*                      ISUP port types                                  *
  //*************************************************************************
  type port MTP3asp_ISUP_PT message
    {
     inout    PDU_ISUP;
    } with {extension "internal"}

  type port MTC_ISUP_PT message    //  Coordination message
    {
     inout    charstring;
     inout    octetstring;
    } with {extension "internal"}
}//end group PortTypes


group ComponentTypes
{
  //*************************************************************************
  //*                       ISUP Component types                            *
  //*************************************************************************
  type component ISUP_CT
    {
    //========================Component constants===========================

    //========================Component variables===========================
     var PDU_ISUP           v_PDU_ISUP;

    //========================Component Timers-=============================

    //========================Component Port Declarations====================
     port MTC_ISUP_PT       MTC_ISUP_PORT;      //up
     port MTP3asp_ISUP_PT   MTP3_ISUP_PORT;     //down
    } // end component type definition

  //*************************************************************************
  //*                       ISUP EncDec component                           *
  //*************************************************************************
  type component ISUP_EncDec_CT
    {
    //========================Component Port Declarations====================
     port MTP3asp_ISUP_PT   MTP3_ISUP_PORT;  //<= SP_PT=_PT
     port MTP3asp_PT        MTP3_PORT;
    } // end component type definition
}//end group ComponentTypes

}//end group Types


//*************************************************************************
//*                       ISUP EncDec component behaviour                 *
//*************************************************************************
function f_ISUP_EncDecComp_Behaviour
     ( MSC_ISUP_MTP3_parameters pl_address_ISUP )  runs on ISUP_EncDec_CT
  {
  var  ASP_MTP3_TRANSFERind   vl_ASP_MTP3_TRANSFERind;
  var  PDU_ISUP               vl_PDU_ISUP;
  pl_address_ISUP.sio.si := '0101'B;

  while (true)
    {
    alt
      {
      [] MTP3_ISUP_PORT.receive ( PDU_ISUP : ?) -> value vl_PDU_ISUP
        {
        MTP3_PORT.send (t_ASP_MTP3_TRANSFERreq
                        (pl_address_ISUP.sio,
                         pl_address_ISUP.opc,
                         pl_address_ISUP.dpc,
                         pl_address_ISUP.sls,
                         enc_PDU_ISUP(vl_PDU_ISUP)));
        repeat;
        }

      // receive message from below (to be decoded)
      [] MTP3_PORT.receive (tr_ASP_MTP3_TRANSFERind_sio
                            (pl_address_ISUP.sio.ni,
                             ?,          //priority: no filtering
                             pl_address_ISUP.sio.si,
                             ?,
                             ?,
                             ?,
                             ? )) -> value  vl_ASP_MTP3_TRANSFERind
        {
        MTP3_ISUP_PORT.send (dec_PDU_ISUP(vl_ASP_MTP3_TRANSFERind.data));
        repeat;
        }

      [] MTP3_PORT.receive (t_ASP_MTP3_TRANSFERind( ?, ?, ?, ?, ? ))
        { log("Invalid SIO:  MESSAGE dropped!!!"); }
      }   //end of alt
    } // end while
  }  // end of f_ISUP_EncDecComp_Behaviour
}
