summaryrefslogtreecommitdiff
path: root/comm/testbus.cc
diff options
context:
space:
mode:
Diffstat (limited to 'comm/testbus.cc')
-rw-r--r--comm/testbus.cc55
1 files changed, 25 insertions, 30 deletions
diff --git a/comm/testbus.cc b/comm/testbus.cc
index ec06f18..6edeaec 100644
--- a/comm/testbus.cc
+++ b/comm/testbus.cc
@@ -1,21 +1,18 @@
-
-#include "Multiplexer.h"
+#include "Scheduler.h"
#include "TimeOut.h"
#include "BusAccess.h"
-#include "dnn/Reaction.h"
+#include "ivl/Reaction.h"
#include <stdlib.h>
#include <stdio.h>
#include <ostream.h>
-class DnnEvent;
-
+class IvlEvent;
/*
-Global variables. This is because we use DnnCallbacks and functions
-instead of DnnReactions and objects. But this is only a test...
+Global variables. This is because we use IvlCallbacks and functions
+instead of IvlReactions and objects. But this is only a test...
*/
-UchBusAccess* A;
-DnnCallback* C;
-
+IvlBusAccess* A;
+IvlCallback* C;
/*
This is an example of how to emit messages on the bus.
@@ -39,15 +36,15 @@ from the bus. Here, this function is associated to a callback,
which in turn is associated to a regexp (see in main).
*/
void
-print_event (DnnEvent& ev)
+print_event (IvlEvent& ev)
{
- UchBusEvent* be = dynamic_cast<UchBusEvent*> (&ev);
+ IvlBusEvent* be = dynamic_cast<IvlBusEvent*> (&ev);
if (!be)
return;
cout << "Event matches '" << be->Regexp << "'\n";
cout << "\t(" << be->NbMatches << " matches: ";
- CcuListIterOf<CcuString> li = be->MatchList;
+ IvlListIterOf<IvlString> li = be->MatchList;
while (++li)
cout << "'" << **li << "' ";
cout << ")\n";
@@ -58,13 +55,13 @@ This is an example of how to handle a new agent connecting to
the bus. Most applications are not interested in such events...
*/
void
-agentready (DnnEvent& ev)
+agentready (IvlEvent& ev)
{
- UchAgentEvent* ae = dynamic_cast<UchAgentEvent*> (&ev);
+ IvlAgentEvent* ae = dynamic_cast<IvlAgentEvent*> (&ev);
if (!ae)
return;
- UchBusAgent* a = ae->GetAgent ();
+ IvlBusAgent* a = ae->GetAgent ();
cout << "Hello " << a->GetName () << "!\n";
C->SubscribeTo (a->Bye);
@@ -75,45 +72,43 @@ This is an example of how to handle an agent leaving
the bus. Most applications are not interested in such events...
*/
void
-agentbye (DnnEvent& ev)
+agentbye (IvlEvent& ev)
{
- UchAgentEvent* ae = dynamic_cast<UchAgentEvent*> (&ev);
+ IvlAgentEvent* ae = dynamic_cast<IvlAgentEvent*> (&ev);
if (!ae)
return;
- UchBusAgent* a = ae->GetAgent ();
+ IvlBusAgent* a = ae->GetAgent ();
cout << "BYE " << a->GetName () << "!\n";
}
-
-
main ()
{
/* initialize communication library */
- UchOpen ();
+ IvlOpen ();
/* create bus access */
- UchBusAccess a ("Uch test"); A = &a;
+ IvlBusAccess a ("Ivl test"); A = &a;
/* periodically send messages on the bus (see foo for timeout handling) */
- UchTimeOut t (1000, foo);
+ IvlTimeOut t (1000, foo);
/* 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);
+ /* Note that you can use every subclass of IvlBaseReaction instead
+ of IvlCallback */
+ IvlCallback c1 (print_event);
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);
+ IvlCallback c3 (agentready);
c3.SubscribeTo (a.NewAgents);
/* reaction to agents leaving (see agentready for subscription,
and agentbye for event handling) */
- DnnCallback c4 (agentbye); C = &c4;
+ IvlCallback c4 (agentbye); C = &c4;
- UchLoop ();
+ IvlLoop ();
}