summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchatty2000-11-28 17:07:46 +0000
committerchatty2000-11-28 17:07:46 +0000
commit1326b11d65f7020f5f6c691305d2c090b064bd04 (patch)
tree8470b3a717aebb907d91a507a08120ca47786bcc
parent08bcb724cf306422ee01edf90f2432898c4278f5 (diff)
downloadivy-league-1326b11d65f7020f5f6c691305d2c090b064bd04.zip
ivy-league-1326b11d65f7020f5f6c691305d2c090b064bd04.tar.gz
ivy-league-1326b11d65f7020f5f6c691305d2c090b064bd04.tar.bz2
ivy-league-1326b11d65f7020f5f6c691305d2c090b064bd04.tar.xz
Looks nicer
-rw-r--r--comm/testbus.cc34
1 files changed, 14 insertions, 20 deletions
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<UchBusEvent*> (&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<CcuString> 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) */