Help wth receiving different types on a port
I hope I can explain this problem well enough... The library I am using has a scenario where a port mapped to a system component (in practice attaches to a real world IP port), waits on receive of one of two different types in various test cases. The issue is that the IP packet received could possibly represent either type. But the type we are interested in is the one that is currently waiting to be received.
The best I can come up with as an analogy is to think of an IP packet and a UDP packet. An IP packet is always received physically, but it could be a UDP packet too. Some tests wait on receive of an IP packet, others wait on receive of a UDP packet. But it is impossible to know in the C++ implementation of the port if an IP or UDP should be sent to incoming_message().
May be there is a way to achieve this with port translation? Where if waiting on a UDP, and an IP arrives, the UDP part only is extracted via a conversion function, but I don't know if this is possible? Also, the port needs to use map param and address, which according to section 4.37 of the manual, these are not supported for ports with translation capability.
Here is an example. Any suggestions greatly appreciated. The library was presented without the port implementation, so I have to work out their intention myself!
`// TTCN-3 version of "Hello, world!" module MyExample {
type record PortParam { charstring ipAddr, integer port_ }
type record IP { integer something }
type record UDP { integer somethingElse }
type charstring address;
type port PCOType message { map param(PortParam prm); inout IP; inout UDP; } with { extension "address" }
type component MTCType { var PortParam vc_pp; port PCOType MyPCO_PT; }
type component SysType { port PCOType MyPCO_PT; }
template PortParam m_params1 := { ipAddr := "local", port_ := 12345 }
template IP m_anyIP := { something := ? }
template UDP m_anyUDP := { somethingElse := ? }
testcase tc_ReceiveIP() runs on MTCType system SysType { vc_pp := valueof(m_params1); map(mtc:MyPCO_PT, system:MyPCO_PT) param (vc_pp);
var UDP u := {0}; MyPCO_PT.send(u) to "me"; MyPCO_PT.receive(m_anyIP); setverdict(pass); }
testcase tc_ReceiveUDP() runs on MTCType system SysType { vc_pp := valueof(m_params1); map(mtc:MyPCO_PT, system:MyPCO_PT) param (vc_pp);
var UDP u := {0}; MyPCO_PT.send(u) to "me"; MyPCO_PT.receive(m_anyUDP); setverdict(pass); }
control { execute(tc_ReceiveIP()); execute(tc_ReceiveUDP()); } } `