Professional Documents
Culture Documents
Language)
2007-2008 CORBA 1
23/10/08 CORBA 2
Goal of lecture
2007-2008 CORBA 3
Basic IDL Types
23/10/08 CORBA 4
Any
Type any is a universal container type.
A value of type any can hold a value of any
other IDL type, such as long or string, or
even another value of type any.
Type any can also hold object references or
user-defined complex types, such as arrays
or structures.
Type any is IDL’s equivalent of what in C++ is
typically achieved with a void *.
23/10/08 CORBA 5
User-Defined Types
typedef short YearType;
struct TimeOfDay {
short hour;
short minute;
short second;
};
23/10/08 CORBA 6
User-Defined Types
struct FirstNested {
long first;
long second;
};
struct SecondNested {
long first;
long second;
};
struct Outer {
FirstNested first;
SecondNested second;
};
23/10/08 CORBA 7
User-Defined Types
union ColorCount switch (Color) {
case red:
case green:
case blue:
unsigned long num_in_stock;
case black:
float discount;
default:
string order_details;
};
23/10/08 CORBA 8
User-Defined Types
enum InfoKind { text, numeric, none };
union Info switch (InfoKind) {
case text:
string description;
case numeric:
long index;
};
interface Order {
void set_details(in Info details);
};
23/10/08 CORBA 9
User-Defined Types
interface Order {
void set_text_details(in string details);
void set_details_index(in long index);
void clear_details();
};
23/10/08 CORBA 10
User-Defined Types
typedef Color ColorVector[10];
23/10/08 CORBA 11
User-Defined Types
typedef sequence<Color> Colors;
23/10/08 CORBA 12
User-Defined Types
struct NonZeroElement {
unsigned short row; // row index
unsigned short col; // column index
long val; // value in this cell
};
typedef sequence<NonZeroElement> Matrix;
interface MatrixProcessor {
Matrix invert_matrix(in Matrix m);
};
23/10/08 CORBA 13
User-Defined Types
enum OpType {
OP_AND, OP_OR, OP_NOT, OP_BITAND, OP_BITOR, OP_BITXOR, OP_BITNOT
};
enum NodeKind { LEAF_NODE, UNARY_NODE, BINARY_NODE };
union Node switch (NodeKind) {
case LEAF_NODE:
long value;
case UNARY_NODE:
struct UnaryOp {
OpType op;
sequence<Node, 1> child;
} u_op;
case BINARY_NODE:
struct BinaryOp {
OpType op;
sequence<Node, 2> children;
} bin_op;
};
23/10/08 CORBA 14
User-Defined Types
interface Thermostat {
// Read temperature
short get_temp();
// Update temperature, return previous value
short set_nominal_temp(in short new_temp);
};
23/10/08 CORBA 15
User-Defined Types
interface Haystack {
exception NotFound {
unsigned long num_straws_searched;
};
const unsigned long MAX_LENGTH = 10;
readonly attribute unsigned long num_straws;
typedef long Needle;
typedef string Straw;
void add(in Straw s);
boolean remove(in Straw s);
void find(in Needle n) raises(NotFound);
};
23/10/08 CORBA 16
User-Defined Types
interface FeedShed {
typedef sequence<Haystack> StackList;
StackList feed_on_hand();
void add(in Haystack s);
void eat(in Haystack s);
boolean find(in Haystack::Needle n)
raises(Haystack::NotFound);
void hide(in Haystack s, in Haystack::Needle n);
};
23/10/08 CORBA 17
User-Defined Types
interface Primes {
typedef unsigned long prime;
prime next_prime(in long n);
void next_prime2(in long n, out prime p);
void next_prime3(inout long n);
};
23/10/08 CORBA 18
User-Defined Types
module CCS {
typedef string LocType;
typedef short TempType;
interface Thermostat {
LocType get_location();
TempType get_temperature();
TempType get_nominal_temp();
void set_nominal_temp(in TempType t);
};
};
23/10/08 CORBA 19
User-Defined Types
module Weather {
enum WType { sunny, cloudy, rainy, foggy };
interface Forecast {
CCS::TempType tomorrows_minimum();
CCS::TempType tomorrows_maximum();
WType outlook();
};
};
23/10/08 CORBA 20
Inheritance
interface Thermometer {
typedef short TempType;
readonly attribute TempType temperature;
};
23/10/08 CORBA 21
Inheritance
interface Thermometer {
typedef long IDType;
const IDType TID = 5;
exception TempOutOfRange {};
};
23/10/08 CORBA 22
The Climate Control System
The climate control system controls the air-conditioning for
various rooms in a large building.
The same system controls the temperature of a number of
manufacturing devices, such as freezers and annealing
ovens.
The system contains two kinds of devices: Thermometers
and Thermostats.
These devices are installed at various locations and support
a proprietary instrument control protocol.
23/10/08 CORBA 23
The Climate Control System
Thermometers report the current temperature at a location.
Thermostats permit a desired temperature to be selected.
The climate control system attempts to keep the actual
temperature as close as possible to this selected
temperature.
We assume that the system contains hundreds of
thermometers and thermostats.
The entire collection of thermometers and thermostats can
be controlled from a single remote monitoring station.
An operator can monitor and set the desired temperature
for each location, find specific devices via various search
criteria, and raise or lower the temperature for a number of
rooms as a group.
23/10/08 CORBA 24
The Climate Control System
A climate control system server acts as a gateway between
the proprietary instrument control network and CORBA
applications.
We use CORBA to manage the system because it allows us
to use the regular corporate computing infrastructure
instead of having to extend the proprietary network to all
clients.
APIs for the proprietary protocol may not be available for
all the combinations of operating system and platform we
want to use for clients.
By using CORBA, we permit a much wider variety of client
implementations, including client implementations in
languages for which the proprietary API is not available.
23/10/08 CORBA 25
The Climate Control System
Thermometers:
A thermometer is a reporting device.
Its purpose is to allow the monitoring station to inquire
about the current temperature at the thermometer's
location.
Thermometers come equipped with a small amount of
memory that holds additional information.
Asset Number: the proprietary API requires an asset
23/10/08 CORBA 27
The Climate Control System
The monitoring system
The monitoring station (known as a controller) permits
access to and control of the devices in the system.
An operator can list all devices in the system, locate
specific devices by various search criteria, and make
relative changes to the temperature setting of a group
of thermostats.
Operations:
Listing Devices
Finding Devices
23/10/08 CORBA 28
The Climate Control System
UML
23/10/08 CORBA 29
The Climate Control System
IDL for Thermometers
typedef unsigned long AssetType;
typedef string ModelType;
typedef short TempType;
typedef string LocType;
interface Thermometer {
readonly attribute ModelType model;
readonly attribute AssetType asset_num;
readonly attribute TempType temperature;
attribute LocType location;
};
23/10/08 CORBA 30
The Climate Control System
IDL for Thermostats
interface Thermostat : Thermometer {
struct BtData {
TempType requested;
TempType min_permitted;
TempType max_permitted;
string error_msg;
};
exception BadTemp { BtData details; };
TempType get_nominal();
TempType set_nominal(in TempType new_temp)
raises(BadTemp);
};
23/10/08 CORBA 31
The Climate Control System
IDL for Controller
List Operation
interface Controller {
typedef sequence<Thermometer> ThermometerSeq;
ThermometerSeq list();
// ...
};
23/10/08 CORBA 32
The Climate Control System
IDL for Controller
Change Operation
interface Controller {
// ...
typedef sequence<Thermostat> ThermostatSeq;
struct ErrorDetails {
Thermostat tmstat_ref;
Thermostat::BtData info;
};
typedef sequence<ErrorDetails> ErrSeq;
exception EChange {
ErrSeq errors;
};
void change(in ThermostatSeq tlist, in short delta) raises(EChange);
// ...
};
23/10/08 CORBA 33
The Climate Control System
IDL for Controller
Find Operation
interface Controller {
// ...
enum SearchCriterion { ASSET, LOCATION, MODEL };
union KeyType switch(SearchCriterion) {
case ASSET:
AssetType asset_num;
case LOCATION:
LocType loc;
case MODEL:
ModelType model_desc;
};
// ...
};
23/10/08 CORBA 34
The Climate Control System
IDL for Controller
Find Operation
interface Controller {
// ...
struct SearchType {
KeyType key;
Thermometer device;
};
typedef sequence<SearchType> SearchSeq;
void find(inout SearchSeq slist);
// ...
};
23/10/08 CORBA 35
The Climate Control System
IDL for Controller
Find Operation
23/10/08 CORBA 36
The Climate Control System
The complete specification
module CCS {
typedef unsigned long AssetType;
typedef string ModelType;
typedef short TempType;
typedef string LocType;
interface Thermometer {
readonly attribute ModelType model;
readonly attribute AssetType asset_num;
readonly attribute TempType temperature;
attribute LocType location;
};
23/10/08 CORBA 37
The Climate Control System
The complete specification
interface Thermostat : Thermometer {
struct BtData {
TempType requested;
TempType min_permitted;
TempType max_permitted;
string error_msg;
};
exception BadTemp { BtData details; };
TempType get_nominal();
TempType set_nominal(in TempType new_temp)
raises(BadTemp);
};
23/10/08 CORBA 38
The Climate Control System
The complete specification
interface Controller {
typedef sequence<Thermometer> ThermometerSeq;
typedef sequence<Thermostat> ThermostatSeq;
enum SearchCriterion { ASSET, LOCATION, MODEL };
union KeyType switch(SearchCriterion) {
case ASSET:
AssetType asset_num;
case LOCATION:
LocType loc;
case MODEL:
ModelType model_desc;
23/10/08 }; CORBA 39
The Climate Control System
The complete specification
struct SearchType {
KeyType key;
Thermometer device;
};
typedef sequence<SearchType> SearchSeq;
struct ErrorDetails {
Thermostat tmstat_ref;
Thermostat::BtData info;
};
typedef sequence<ErrorDetails> ErrSeq;
exception EChange {
ErrSeq errors;
};
23/10/08 CORBA 40
The Climate Control System
The complete specification
ThermometerSeq list();
void find(inout SearchSeq slist);
void change( in ThermostatSeq tlist, in short delta )
raises(EChange);
};
};
23/10/08 CORBA 41
The End
THANK YOU!
2007-2008 CORBA 42