From 1326b11d65f7020f5f6c691305d2c090b064bd04 Mon Sep 17 00:00:00 2001 From: chatty Date: Tue, 28 Nov 2000 17:07:46 +0000 Subject: Looks nicer --- comm/testbus.cc | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'comm') diff --git a/comm/testbus.cc b/comm/testbus.cc index 757688b..ec06f18 100644 --- a/comm/testbus.cc +++ b/comm/testbus.cc @@ -44,12 +44,12 @@ print_event (DnnEvent& ev) UchBusEvent* be = dynamic_cast (&ev); if (!be) return; - const char* m = be->Matches; - cout << "Event '" << be->Matches << "' matches '" << be->Regexp << "'\n"; - cout << "\t(" << be->NbMatches << " matches:"; + + cout << "Event matches '" << be->Regexp << "'\n"; + cout << "\t(" << be->NbMatches << " matches: "; CcuListIterOf li = be->MatchList; while (++li) - cout << **li << ", "; + cout << "'" << **li << "' "; cout << ")\n"; } @@ -65,7 +65,7 @@ agentready (DnnEvent& ev) return; UchBusAgent* a = ae->GetAgent (); - cout << "HELLO " << a->GetName () << "!\n"; + cout << "Hello " << a->GetName () << "!\n"; C->SubscribeTo (a->Bye); } @@ -89,33 +89,27 @@ agentbye (DnnEvent& ev) main () { - fprintf (stderr, "00\n"); - const char* bus = getenv ("IVYBUS"); - int bus_number = bus ? atoi (bus) : 2010; - - fprintf (stderr, "0\n"); + /* initialize communication library */ UchOpen (); - fprintf (stderr, "1\n"); - UchBusAccess a ("Uch test", bus_number); A = &a; - fprintf (stderr, "2\n"); + /* create bus access */ + UchBusAccess a ("Uch test"); A = &a; + /* periodically send messages on the bus (see foo for timeout handling) */ UchTimeOut t (1000, foo); - fprintf (stderr, "3\n"); - /* subscribe to a few types of events (see print_event for event handling) */ + /* subscribe to a few event types (see print_event for event handling) */ /* Note that you can use every subclass of DnnBaseReaction instead of DnnCallback */ DnnCallback c1 (print_event); - a.Subscribe (c1, "^(glidepoint) (.*)"); - a.Subscribe (c1, "TRAFFIC START"); - a.Subscribe (c1, "(.*TRAFFIC FILE NAME.*)"); - a.Subscribe (c1, "^AVION:(.*) RADAR (.*)"); + a.Subscribe (c1, "^(CLOCK) (.*)"); + a.Subscribe (c1, "TRAFFIC Start"); + a.Subscribe (c1, "(.*Tick.*)"); + a.Subscribe (c1, "^AIRCRAFT:(.*) Moved (.*)"); /* react to new agents calling (see agentready for event handling) */ DnnCallback c3 (agentready); c3.SubscribeTo (a.NewAgents); - fprintf (stderr, "4\n"); /* reaction to agents leaving (see agentready for subscription, and agentbye for event handling) */ -- cgit v1.1