CORBA SAMPLE CODE: STATION
MONITOR
INTRODUCTION
TABLE OF CONTENTS
STATION MONITOR
DESIGN
SCENARIO
The Station Monitor example is based around the concept of a manufacturing
station. Imagine a factory that produces widgets using an assembly
line. The assembly line is composed of a series of work stations,
each of which accomplishes some small part of the manufacturing process
by taking parts from an input bin, doing something to them, and putting
the result into an output bin. The output bin would then becomes
the input bin for the next station down the line. Each station has
different operational characteristics which can be tracked over time, such
as the number of parts in the input or output bins, the rate at which parts
are processed, and so forth.
This code example implements a simple station monitor applet that is
capable of monitoring the status of a single station, and a standalone
Java application that monitors multiple stations at once.
CORBA OBJECTS
Station
The Station object is a standalone Java application whose purpose is
to monitor the characteristics of a station. When queried through
its get_status() method, the station object returns to the caller
the current status of the station in the form of a structure. In
"real life", the station object would probably get the current station
status from a database, or from querying a set of hardware sensors set
up to monitor the station. In this example, the station object simulates
the operation of a station. It has a thread named SimTimer
(StationServer.java) that calls a private method on the station
object (updateIt)once per second. The updateIt()
method then updates the current station status based on assumptions of
the inital input bin size and time to complete a single operation.
These assumptions are settable through command-line options.
If started with the "-r" option, the Station will register itself with
a running Collector object (see below)
The Station object is implemented in the following source files:
-
mfgDemo.idl: Contains the Station object's interface defintion
in IDL
-
StationSource/StationImpl.java: Implementation of the Station
object
-
StationSource/StationServer.java: Server startup, Station instantiation
and registration with the ORB and Web Naming service
-
StationSource/StationOptions.java: Command-line option processing
Collector
Single-Station Display Applet
Multiple-Station Display Client
RUNNING
THE STATION MONITOR
PRE-REQUISITES
The Station Monitor example comes pre-compiled, so you don't need to
build it in order to run it. However, you must have the following:
On the Enterprise Server Machine:
-
Windows NT
-
Enterprise Server 3.0
-
Web naming needs to be configured so that IORs can be written to the directory
tree starting at iiop_objects.
-
A standalone Java VM supporting the JDK1.1 installed. (Ex: JDK1.1.X
from JavaSoft, or Symantec's Visual Cafe for Java 1.1)
-
The Java VM is used by idl2java to process the IDL file
-
Your CLASSPATH should include the following directories (in this order)
-
<JDK 1.1 Libraries> (Location dependent on your vendor.)
-
<Enterprise Server Install Directory>\wai\java\nisb.zip
-
<Enterprise Server Install Directory>\wai\java\wai.zip
-
Your PATH should include the directory for your Java VM (So that
you can just type "java" to run it)
On the Client Machine (Perhaps the same machine as the server machine)
-
Communicator 4.0.X installed and configured
STARTING STATIONS
AND THE COLLECTOR
To start the Collector and two default Stations ("StationR" and "StationT"):
-
Bring-up a DOS-box and verify that your PATH and CLASSPATH are correctly
set
-
Navigate to the root demo directory
-
Type "run" from the root demo directory.
-
The Collector and stations will each start in a separate, minimized DOS
box
SINGLE
STATION DISPLAYAPPLET
To run the single-station display applet:
-
From Communicator, navigate to the demo directory and select the file "sglStClasses.html".
MULTIPLE
STATION MONITOR CLIENT
(COMMAND-LINE)
To start the multiple-station monitor client:
-
Bring-up a DOS-box and verify that your PATH and CLASSPATH are correctly
set
-
Type "runmmclt" from the root demo directory
-
The monitor will start. Press Ctl-C to quit it.
BUILDING
THE STATION MONITOR
PRE-REQUISITES
To build the station monitor example, you will need to have the following:
-
Enterprise Server 3.0
-
A standalone Java VM supporting the JDK1.1. (Ex: JDK1.1.X from JavaSoft,
or Symantec's Visual Cafe for Java 1.1)
-
Your CLASSPATH should include the following directories (in this order)
-
<JDK 1.1 Libraries> (Location dependent on your vendor.)
-
<Enterprise Server Install Directory>\wai\java\nisb.zip
-
<Enterprise Server Install Directory>\wai\java\wai.zip
-
Your PATH should include:
-
The directory for your Java VM (So that you can just type "java"
to run it)
-
The directory for your Java compiler (javac)
FILE AND
DIRECTORY STRUCTURE
The station monitor example has the following directory structure:
-
<root dir>: Batch files to run and build example.
HTML files for running applet. Readme. IDL source file.
-
amd: Source files for a freeware progress
bar widget
-
CollectorSource: Source files for the Collector
-
MonitorSource: Source files for the Single-Station Monitor
applet and Multi-Station Monitor Client
-
StationSource: Source files for the Station
-
classes: Directory tree of class files created from the
example source
BUILDING
Once you have your environment set-up according to the above pre-requisites:
-
Open a DOS box and verify your PATH and CLASSPATH variables are correctly
set
-
Type "makeidl" to call the IDL compiler
-
Type "make" to compile all the source
REFERENCE
Batch files
mm1.bat
call idl2java -no_comments -no_examples -no_tie mfgDemo.idl
mm2.bat
md classes
javac -d classes .\StationModule\*.java
javac -d classes .\MonitorModule\*.java
javac -d classes .\CollectorModule\*.java
javac -d classes .\amd\AMD*.java
javac -d classes Collector*.java
javac -d classes Station*.java
javac -d classes Monitor*.java
javac -d classes Display*.java
stObject.bat
start "Collector" /min java -DDISABLE_ORB_LOCATOR CollectorModule.CollectorServer
-n Collector
start "StationR" /min java -DDISABLE_ORB_LOCATOR StationModule.StationServer
-n StationR -i R -d "Airplane Assembly" -u 100 -t 4 -s 5 -r -c Collector
start "StationT" /min java -DDISABLE_ORB_LOCATOR StationModule.StationServer
-n StationT -i T -d "Airplane Finishing" -u 25 -t 8 -s 5 -r -c Collector