// The #pragma is specific to OpenDDS
#pragma DCPS_DATA_TYPE "Quote"
struct Quote {
double price;
string symbol;
string full_name;
};
You will use the mwc.pl Perl script on the file
Quoter.mpc (which uses the
Quoter.idl file) to generate the needed
support code and makefiles for the publisher and subscriber
executables. This script is located in $ACE_ROOT/bin. For Linux,
the command line might look something like this:
$ $ACE_ROOT/bin/mwc.pl -type gnuace
For Visual Studio 2005, the command line might look something like this:
C:\> %ACE_ROOT%\bin\mwc.pl -type vc8
The makefiles or solution files should then be ready for you to use.
The publisher executable (whose source code you must modify) will update values to the stocks. The subscriber application (whose source code you also must modify) will then output updates when they are received.
You will be given boilerplate code for the parts that are not generated for you by the mpc.pl script. This is described in more detail below. You can download all of this code in a single zip file from here.
When the subscriber starts up, it will wait for data updates and manipulate the data when it arrives (e.g., display it to the screen). On the subscriber side, you'll need to modify the boilerplate code supplied in subscriber.cpp and DataReaderListener.cpp to make the appropriate DDS calls. You will also need the file DataReaderListener.h as well but you shouldn't need to modify it.
In particular, you will need to modify subscriber.cpp to:
The subscriber executable takes 2 command line arguments: one to set up the transport (i.e., -ORBSvcConf tcp.conf) and one to set up the subscriber (i.e., -DCPSConfigFile sub.ini). You will not need to modify these files. Here are the tcp.conf and sub.ini files.
If anything fails to work properly the subscriber should simply print out the appropriate exception and exit with a return status of 1. If everything works correctly, the program should exit with a return status of 0.
When the publisher starts up, it will update and publish stock prices. On the publisher side, you'll need to modify the boilerplate code supplied in publisher.cpp and Writer.cpp to make the appropriate DDS calls. You will also need the file Writer.h as well but you shouldn't need to modify it.
In particular, you will need to modify publisher.cpp to:
The publisher executable takes 2 command line arguments: one to set up the transport (i.e., -ORBSvcConf tcp.conf) and one to set up the publisher (i.e., -DCPSConfigFile pub.ini). You will not need to modify these files. Here are the tcp.conf and pub.ini files.
If anything fails to work properly the publisher should simply print out the appropriate exception and exit with a return status of 1. If everything works correctly, the program should exit with a return status of 0.
Also, the order in which the executables are invoked in important. The Info Repository needs to be launched first, then the subscriber, then the publisher.
The Info Repository should be launched as follows:
$DDS_ROOT/dds/InfoRepo/DCPSInfoRepo -ORBSvcConf tcp.conf -o repo.ior -d domain_ids
where DDS_ROOT is equivalent to $ACE_wrappers/TAO/DDS.It also needs to be manually killed when the DDS application is done running. There will be a file named repo.ior left in the directory. It is a good idea to delete this file to avoid any confusion for succeeding invocations (although there may be no harm in leaving it alone).
Example output for the Info Repository:
$ $DDS_ROOT/dds/InfoRepo/DCPSInfoRepo -ORBSvcConf tcp.conf -o repo.ior -d domain_ids
(12588|3078248128) 13:55:01.262144 Repo main
(12588|3078248128)INFO: not using file configuration - no configuration file specified.
Example output for the supplier:
$ ./subscriber -ORBSvcConf tcp.conf -DCPSConfigFile sub.ini
DataReaderListenerImpl::on_subscription_match
Quoter: price = 100
symbol = IBM
full name = International Business Machines
Quoter: price = 10
symbol = MSFT
full name = Microsoft Corporation
Quoter: price = 200
symbol = IBM
full name = International Business Machines
Quoter: price = 20
symbol = MSFT
full name = Microsoft Corporation
Quoter: price = 300
symbol = IBM
full name = International Business Machines
Quoter: price = 30
symbol = MSFT
full name = Microsoft Corporation
Quoter: price = 400
symbol = IBM
full name = International Business Machines
Quoter: price = 40
symbol = MSFT
full name = Microsoft Corporation
Quoter: price = 500
symbol = IBM
full name = International Business Machines
Quoter: price = 50
symbol = MSFT
full name = Microsoft Corporation
Quoter: price = 600
symbol = IBM
full name = International Business Machines
Quoter: price = 60
symbol = MSFT
full name = Microsoft Corporation
Quoter: price = 700
symbol = IBM
full name = International Business Machines
Quoter: price = 70
symbol = MSFT
full name = Microsoft Corporation
Quoter: price = 800
symbol = IBM
full name = International Business Machines
Quoter: price = 80
symbol = MSFT
full name = Microsoft Corporation
Quoter: price = 900
symbol = IBM
full name = International Business Machines
Quoter: price = 90
symbol = MSFT
full name = Microsoft Corporation
Quoter: price = 1000
symbol = IBM
full name = International Business Machines
Quoter: price = 100
symbol = MSFT
full name = Microsoft Corporation
Example output for the publisher:
$ ./publisher -ORBSvcConf tcp.conf -DCPSConfigFile pub.ini
(20553|3086640832) Writer::start
(20553|3027631024) Writer::svc begins.
13:55:31.995447 (20553|3027631024) Writer::svc starting to write.
(20553|3027631024) Writer::svc finished.
(20553|3086640832) Writer::end
You will also need to download and install ACE and TAO. Please see the online documentation for information on how to setup your ACE and TAO development environment on EECS's computing system.
NOTE: There is also an example OpenDDS application in the OpenDDS distribution under $DDS_ROOT/DevGuideExamples/DCPS/Messenger. This example should be helpful if you're stuck on what OpenDDS calls to make in your code.
Back to CS 395-2 home page.