using System.Threading; using Etsi.Ttcn3; public class ResponseAdapter { static TriCommunicationTE MyTTS = Framework.GetTriCommunicationTE(); static Thread Receiver; static TriPortId PortId; static TriComponentId ComponentId; public static void SwitchOn(TriPortId pid, TriComponentId cid) { PortId = pid; ComponentId = cid; Receiver = new Thread( new ThreadStart(ReceiverBehaviour) ); Receiver.Start(); } public static void SwitchOff() { Receiver.Abort(); } private static void ReceiverBehaviour() { while(true) { while(CoffeeMachine.Output.Count == 0) Thread.Sleep(100); byte[] bytes = CoffeeMachine.Output.Dequeue(); TriMessage msg = Framework.GetFactory().TriMessage(); msg.setEncodedMessage(bytes); MyTTS.triEnqueueMsg (PortId, null, ComponentId, msg); } } }