blob: 1e8429a4656345edc5856b96bedbb5bc1c4764a4 [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
// //
// 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 //
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// Module: EPTF_LGenBaseDemo_TransportFunctions
//
// Purpose:
// This module contains functions for message handling on the testport
//
// Module Parameters:
// -
//
// Module depends on:
//
// Current Owner:
// ELSZSKU
//
// Last Review Date:
// 20 - -
//
// Detailed Comments:
// The functions don't contain demo about the use of the LGenBase,
// but they are necessary for the application.
//
///////////////////////////////////////////////////////////
module EPTF_LGenBaseDemo_TransportFunctions
{
import from EPTF_CLL_Base_Functions all;
import from EPTF_LGenBaseDemo_TransportDefinitions all
///////////////////////////////////////////////////////////////////////////////
// Initialization of the Common component
///////////////////////////////////////////////////////////////////////////////
public function f_LGenBaseDemo_Transport_init(
in charstring pl_name,
in LGenBaseDemo_Transport_msgReceived_FT pl_msgProcessFn,
in LGenBaseDemo_Transport_CT pl_connectTo := null)
runs on LGenBaseDemo_Transport_CT{
f_EPTF_Base_init_CT(pl_name)
v_LGenBaseDemo_Transport_connectedTo := pl_connectTo
f_EPTF_Base_registerCleanup(refers(f_LGenBaseDemo_Transport_cleanup))
if(null != pl_connectTo){
connect(self:LGenBaseDemoIf, v_LGenBaseDemo_Transport_connectedTo:LGenBaseDemoIf)
}
v_LGenBaseDemo_Transport_receiveCallbackFn := pl_msgProcessFn
//v_LGenBaseDemo_Transport_myBehavId := f_EPTF_LGenBase_declareBehaviorType(c_LGenBaseDemo_Transport_BehaviorName, -1, null, null, null)
// Activates the message handling altstep as a default
// Note:
// Don't use alt statements inside the functions. Blocking statements
// can be used only as activated altsteps.
v_LGenBaseDemo_Transport_default := activate(as_LGenBaseDemo_Transport_messageHandler())
}
///////////////////////////////////////////////////////////////////////////////
// Sends out a message
///////////////////////////////////////////////////////////////////////////////
public function f_LGenBaseDemo_Transport_sendMessage(
in LGenBaseDemo_Msg pl_msg)
runs on LGenBaseDemo_Transport_CT{
LGenBaseDemoIf.send( pl_msg )
}
///////////////////////////////////////////////////////////////////////////////
// Disconnects the connected testport, and deactivates the message processing
// altstep
///////////////////////////////////////////////////////////////////////////////
private function f_LGenBaseDemo_Transport_cleanup()
runs on LGenBaseDemo_Transport_CT{
if(null != v_LGenBaseDemo_Transport_connectedTo){
disconnect(self:LGenBaseDemoIf, v_LGenBaseDemo_Transport_connectedTo:LGenBaseDemoIf)
}
deactivate(v_LGenBaseDemo_Transport_default)
}
///////////////////////////////////////////////////////////////////////////////
// Fills up a Register message and sends it out
///////////////////////////////////////////////////////////////////////////////
public function f_LGenBaseDemo_Transport_sendRegister(in charstring pl_msg)
runs on LGenBaseDemo_Transport_CT{
log(%definitionId&": Sending Register message: "&log2str(pl_msg))
var LGenBaseDemo_Msg vl_msg := {register := c_LGenBaseDemo_emptyRegister}
vl_msg.register.msg := pl_msg
f_LGenBaseDemo_Transport_sendMessage( vl_msg )
}
///////////////////////////////////////////////////////////////////////////////
// Fills up a ReRegister message and sends it out
///////////////////////////////////////////////////////////////////////////////
public function f_LGenBaseDemo_Transport_sendReRegister(in charstring pl_msg)
runs on LGenBaseDemo_Transport_CT{
log(%definitionId&": Sending ReRegister message: "&log2str(pl_msg))
var LGenBaseDemo_Msg vl_msg := {reRegister := c_LGenBaseDemo_emptyReRegister}
vl_msg.reRegister.msg := pl_msg
f_LGenBaseDemo_Transport_sendMessage( vl_msg )
}
///////////////////////////////////////////////////////////////////////////////
// Fills up a DoMsg message and sends it out
///////////////////////////////////////////////////////////////////////////////
public function f_LGenBaseDemo_Transport_sendDoMsg(in charstring pl_msg)
runs on LGenBaseDemo_Transport_CT{
log(%definitionId&": Sending DoMsg message: "&log2str(pl_msg))
var LGenBaseDemo_Msg vl_msg := {doMsg := c_LGenBaseDemo_emptyDoMsg}
vl_msg.doMsg.msg := pl_msg
f_LGenBaseDemo_Transport_sendMessage( vl_msg )
}
///////////////////////////////////////////////////////////////////////////////
// Fills up an Ack message and sends it out
///////////////////////////////////////////////////////////////////////////////
public function f_LGenBaseDemo_Transport_sendMsgAck(
in integer pl_msgId,
in boolean pl_resp)
runs on LGenBaseDemo_Transport_CT{
var LGenBaseDemo_Msg vl_msg := { msgAck := c_LGenBaseDemo_emptyMsgAck}
vl_msg.msgAck.msgId := pl_msgId
vl_msg.msgAck.resp := pl_resp
f_LGenBaseDemo_Transport_sendMessage( vl_msg )
}
///////////////////////////////////////////////////////////////////////////////
// Catches the incoming messages on the internal testport, stores the received
// message in a component variable and calls the appropriate processing function.
//
// Don't use alt statements inside the functions. Blocking statements
// can be used only as activated default altsteps.
///////////////////////////////////////////////////////////////////////////////
private altstep as_LGenBaseDemo_Transport_messageHandler()
runs on LGenBaseDemo_Transport_CT{
var LGenBaseDemo_Msg vl_msg;
//Do NOT use template matching to decide which kind of message is received!
[]LGenBaseDemoIf.receive(?)-> value vl_msg{
if(null != v_LGenBaseDemo_Transport_receiveCallbackFn){
v_LGenBaseDemo_Transport_lastMsg := vl_msg
v_LGenBaseDemo_Transport_receiveCallbackFn.apply( vl_msg )
}
repeat
}
}
///////////////////////////////////////////////////////////////////////////////
// Returns the last received message
///////////////////////////////////////////////////////////////////////////////
public function f_LGenBaseDemo_Transport_getLastMsg()
runs on LGenBaseDemo_Transport_CT
return charstring{
if ( ischosen(v_LGenBaseDemo_Transport_lastMsg.register) ){
return v_LGenBaseDemo_Transport_lastMsg.register.msg
}
else if ( ischosen(v_LGenBaseDemo_Transport_lastMsg.reRegister) ){
return v_LGenBaseDemo_Transport_lastMsg.reRegister.msg
}
else if ( ischosen(v_LGenBaseDemo_Transport_lastMsg.doMsg) ){
return v_LGenBaseDemo_Transport_lastMsg.doMsg.msg
}
return ""
}
} // end of module