diff options
author | sbw1 <sbw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-05-26 23:12:31 +0000 |
---|---|---|
committer | sbw1 <sbw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-05-26 23:12:31 +0000 |
commit | 11e00ec7877a488d7c461627a6d3bd8d9df30e0a (patch) | |
tree | e13585a0ed3ae489e752d19d7b4b28099e058d86 /apps | |
parent | 83bac82cf9438649fc61eba4c2611a7906765ef7 (diff) | |
download | ATCD-11e00ec7877a488d7c461627a6d3bd8d9df30e0a.tar.gz |
The application side files for remora
Diffstat (limited to 'apps')
-rwxr-xr-x | apps/JAWS/remora/app/Makefile | 19 | ||||
-rw-r--r-- | apps/JAWS/remora/app/Remora_Export.cc | 84 | ||||
-rw-r--r-- | apps/JAWS/remora/app/Remora_Export.h | 85 | ||||
-rw-r--r-- | apps/JAWS/remora/app/Remora_Export.i | 146 | ||||
-rw-r--r-- | apps/JAWS/remora/app/Remora_Import.cc | 102 | ||||
-rw-r--r-- | apps/JAWS/remora/app/Remora_Import.h | 69 | ||||
-rw-r--r-- | apps/JAWS/remora/app/Remora_Import.i | 85 | ||||
-rw-r--r-- | apps/JAWS/remora/app/remora.idl | 100 | ||||
-rwxr-xr-x | apps/JAWS/remora/app/stdmk | 40 | ||||
-rw-r--r-- | apps/JAWS/remora/app/test.cc | 77 |
10 files changed, 807 insertions, 0 deletions
diff --git a/apps/JAWS/remora/app/Makefile b/apps/JAWS/remora/app/Makefile new file mode 100755 index 00000000000..395684b2cb4 --- /dev/null +++ b/apps/JAWS/remora/app/Makefile @@ -0,0 +1,19 @@ +include stdmk + +EXE = test + +all: $(EXE) + +clean: + -rm -f core *~ *.o *_c.hh *_c.cc *_s.hh *_s.cc $(EXE) + -rm -rf Templates.DB + +remora_c.cc: remora.idl + $(ORBCC) remora.idl + +remora_s.cc: remora.idl + $(ORBCC) remora.idl + +test: remora_c.o test.o Remora_Import.o Remora_Export.o + $(CC) -o test test.o remora_c.o Remora_Import.o Remora_Export.o\ + $(LIBPATH) $(LIBORB) $(STDCC_LIBS) $(LIBACE) diff --git a/apps/JAWS/remora/app/Remora_Export.cc b/apps/JAWS/remora/app/Remora_Export.cc new file mode 100644 index 00000000000..84fcf6511e0 --- /dev/null +++ b/apps/JAWS/remora/app/Remora_Export.cc @@ -0,0 +1,84 @@ +#include "Remora_Export.h" + + +Remora_Export::Remora_Export(const char* label, int value, int max_value) + : remora_agent_(0) +{ + this->stat_.value_ = value; + this->stat_.label_ = label; + this->stat_.max_ = max_value; + + this->init(); +} + +Remora_Export::Remora_Export(const Remora_Export& export) + : remora_agent_(export.remora_agent_) +{ + this->stat_.value_ = export.stat_.value_; + this->stat_.label_ = export.stat_.label_; + this->stat_.max_ = export.stat_.max_; +} + +Remora_Export::~Remora_Export() +{ + try + { + if (this->remora_agent_ != 0) + { + this->remora_agent_->removeStatistic(this->stat_.label_); + this->remora_agent_->_release(); + } + } + catch(remora::Invalid_Statistic& excp) + { + } + catch(CORBA::SystemException& excp) + { + CORBA::release(this->remora_agent_); + } +} + +void +Remora_Export::init() +{ + try + { + int argc = 1; + char* argv[1]; + argv[0] = STATS_AGENT_NAME; + + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + + this->remora_agent_ = + remora::Remora_Statistics_Agent::_bind(STATS_AGENT_NAME); + + this->remora_agent_->acceptNewStatistic(this->stat_); + } + catch(CORBA::Exception& excp) + { + cerr << excp << endl; + } +} + +void +Remora_Export::update_value(int new_value) +{ + this->stat_.value_ = new_value; + + try + { + if (this->remora_agent_ != 0 && (! this->remora_agent_->_non_existent())) + this->remora_agent_->updateStatistic(this->stat_); + } + catch(CORBA::SystemException& sysex) + { + cerr << sysex << endl; + this->remora_agent_->_release(); + this->remora_agent_ = 0; + } + catch(remora::Invalid_Statistic& excp) + { + cerr << excp << endl; + } +} + diff --git a/apps/JAWS/remora/app/Remora_Export.h b/apps/JAWS/remora/app/Remora_Export.h new file mode 100644 index 00000000000..379f3bb1a82 --- /dev/null +++ b/apps/JAWS/remora/app/Remora_Export.h @@ -0,0 +1,85 @@ +// $Id + +// =================================================================== +// +// = FILENAME +// Remora_Export.h +// +// = AUTHOR +// Seth Widoff +// +// =================================================================== + + +#ifndef REMORA_EXPORT_H +#define REMORA_EXPORT_H + +#include <bstring.h> +#include "remora_c.hh" + +#define MAX_VALUE 100 +#define NO_NAME "Unnamed Statistic" +#define STATS_AGENT_NAME "Remora Statistics Agent" + +class Remora_Export +{ +public: + + Remora_Export(const char* label = NO_NAME, int value = 0, + int max_value = MAX_VALUE); + + Remora_Export(const Remora_Export& export); + + ~Remora_Export(); + + void operator=(const int new_value); + void operator=(const Remora_Export& export); + + void operator+=(const int new_value); + void operator+=(const Remora_Export& export); + + void operator*=(const int new_value); + void operator*=(const Remora_Export& export); + + void operator/=(const int new_value); + void operator/=(const Remora_Export& export); + + void operator-=(const int new_value); + void operator-=(const Remora_Export& export); + + operator CORBA::Long() const; + operator CORBA::Long&(); + + friend int operator==(const Remora_Export& me, const int new_value); + friend int operator==(const Remora_Export& me, const Remora_Export& export); + + friend int operator!=(const Remora_Export& me, const int new_value); + friend int operator!=(const Remora_Export& me, const Remora_Export& export); + + friend int operator<=(const Remora_Export& me, const int new_value); + friend int operator<=(const Remora_Export& me, const Remora_Export& export); + + friend int operator>=(const Remora_Export& me, const int new_value); + friend int operator>=(const Remora_Export& me, const Remora_Export& export); + + friend int operator<(const Remora_Export& me, const int new_value); + friend int operator<(const Remora_Export& me, const Remora_Export& export); + + friend int operator>(const Remora_Export& me, const int new_value); + friend int operator>(const Remora_Export& me, const Remora_Export& export); + +private: + + void init(); + + void update_value(int new_value); + + remora::Statistic stat_; + + remora::Remora_Statistics_Agent_ptr remora_agent_; + +}; + +#include "Remora_Export.i" + +#endif diff --git a/apps/JAWS/remora/app/Remora_Export.i b/apps/JAWS/remora/app/Remora_Export.i new file mode 100644 index 00000000000..f4b158721d2 --- /dev/null +++ b/apps/JAWS/remora/app/Remora_Export.i @@ -0,0 +1,146 @@ +// $Id + +inline void +Remora_Export::operator=(const int new_value) +{ + this->update_value(new_value); +} + +inline void +Remora_Export::operator=(const Remora_Export& export) +{ + this->update_value(export.stat_.value_); +} + +inline void +Remora_Export::operator+=(const int new_value) +{ + this->update_value(this->stat_.value_ + new_value); +} + +inline void +Remora_Export::operator+=(const Remora_Export& export) +{ + this->update_value(this->stat_.value_ + export.stat_.value_); +} + +inline void +Remora_Export::operator-=(const int new_value) +{ + this->update_value(this->stat_.value_ - new_value); +} + +inline void +Remora_Export::operator-=(const Remora_Export& export) +{ + this->update_value(this->stat_.value_ - export.stat_.value_); +} + +inline void +Remora_Export::operator*=(const int new_value) +{ + this->update_value(this->stat_.value_ * new_value); +} + +inline void +Remora_Export::operator*=(const Remora_Export& export) +{ + this->update_value(this->stat_.value_ * export.stat_.value_); +} + +inline void +Remora_Export::operator/=(const int new_value) +{ + this->update_value(this->stat_.value_ / new_value); +} + +inline void +Remora_Export::operator/=(const Remora_Export& export) +{ + this->update_value(this->stat_.value_ / export.stat_.value_); +} + +inline +Remora_Export::operator CORBA::Long() const +{ + return this->stat_.value_; +} + +inline +Remora_Export::operator CORBA::Long&() +{ + return this->stat_.value_; +} + +inline int +operator==(const Remora_Export& me, const int new_value) +{ + return me.stat_.value_ == new_value; +} + +inline int +operator==(const Remora_Export& me, const Remora_Export& export) +{ + return me.stat_.value_ == export.stat_.value_; +} + +inline int +operator!=(const Remora_Export& me, const int new_value) +{ + return me.stat_.value_ != new_value; +} + +inline int +operator!=(const Remora_Export& me, const Remora_Export& export) +{ + return me.stat_.value_ != export.stat_.value_; +} + +inline int +operator<=(const Remora_Export& me, const int new_value) +{ + return me.stat_.value_ <= new_value; +} + +inline int +operator<=(const Remora_Export& me, const Remora_Export& export) +{ + return me.stat_.value_ <= export.stat_.value_; +} + +inline int +operator>=(const Remora_Export& me, const int new_value) +{ + return me.stat_.value_ >= new_value; +} + +inline int +operator>=(const Remora_Export& me, const Remora_Export& export) +{ + return me.stat_.value_ >= export.stat_.value_; +} + +inline int +operator<(const Remora_Export& me, const int new_value) +{ + return me.stat_.value_ < new_value; +} + +inline int +operator<(const Remora_Export& me, const Remora_Export& export) +{ + return me.stat_.value_ < export.stat_.value_; +} + +inline int +operator>(const Remora_Export& me, const int new_value) +{ + return me.stat_.value_ > new_value; +} + +inline int +operator>(const Remora_Export& me, const Remora_Export& export) +{ + return me.stat_.value_ > export.stat_.value_; +} + diff --git a/apps/JAWS/remora/app/Remora_Import.cc b/apps/JAWS/remora/app/Remora_Import.cc new file mode 100644 index 00000000000..369ca1eb7fd --- /dev/null +++ b/apps/JAWS/remora/app/Remora_Import.cc @@ -0,0 +1,102 @@ +// $Id + +#include "Remora_Import.h" + +Remora_Import::Remora_Import(const char* label, int value, + int min_value, int max_value) + : remora_agent_(0) +{ + this->control_.value_ = value; + this->control_.label_ = label; + this->control_.max_ = max_value; + this->control_.min_ = min_value; + + this->init(); +} + +Remora_Import::Remora_Import(const Remora_Import& import) + : remora_agent_(import.remora_agent_) +{ + this->control_.value_ = import.control_.value_; + this->control_.label_ = import.control_.label_; + this->control_.max_ = import.control_.max_; + this->control_.min_ = import.control_.min_; +} + +Remora_Import::~Remora_Import() +{ + try + { + if (this->remora_agent_ != 0) + { + this->remora_agent_->removeControl(this->control_.label_); + this->remora_agent_->_release(); + } + } + catch(remora::Invalid_Statistic& excp) + { + cerr << "Tried to remove invalid statistic."; + } + catch(CORBA::SystemException& excp) + { + CORBA::release(this->remora_agent_); + } +} + +void +Remora_Import::init() +{ + try + { + int argc = 1; + char* argv[1]; + argv[0] = CONTROL_AGENT_NAME; + + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + + this->remora_agent_ = + remora::Remora_Controls_Agent::_bind(CONTROL_AGENT_NAME); + + this->remora_agent_->acceptNewControl(this->control_); + } + catch(CORBA::Exception& excp) + { + cerr << excp << endl; + } +} + +CORBA::Long +Remora_Import::grab_value(void) +{ + try + { + if (this->remora_agent_ != 0) + { + this->remora_agent_->getControlState(this->control_); + } + + // C++ exception handling needs a 'finally' construct + return this->control_.value_; + } + catch(CORBA::SystemException& sysex) + { + cerr << sysex << endl; + this->remora_agent_->_release(); + this->remora_agent_ = 0; + + return this->control_.value_; + } + catch(remora::Invalid_Control& excp) + { + try + { + this->remora_agent_->acceptNewControl(this->control_); + } + catch(CORBA::SystemException& sysex2) + { + return this->control_.value_; + } + + return this->control_.value_; + } +} diff --git a/apps/JAWS/remora/app/Remora_Import.h b/apps/JAWS/remora/app/Remora_Import.h new file mode 100644 index 00000000000..8cfecd84ac4 --- /dev/null +++ b/apps/JAWS/remora/app/Remora_Import.h @@ -0,0 +1,69 @@ +// $Id + +// =================================================================== +// +// = FILENAME +// Remora_Import.h +// +// = AUTHOR +// Seth Widoff +// +// =================================================================== + +#ifndef REMORA_IMPORT_H +#define REMORA_IMPORT_H + +#include <bstring.h> +#include "remora_c.hh" + +#define NO_NAME "Unnamed Statistic" +#define MAX_VALUE 100 +#define CONTROL_AGENT_NAME "Remora Controls Agent" + +class Remora_Import +{ +public: + + Remora_Import(const char * label = NO_NAME, int value = 0, + int min_value = 0, int max_value = MAX_VALUE); + + Remora_Import(const Remora_Import& import); + + ~Remora_Import(); + + CORBA::Long get(void); + + operator CORBA::Long(); + + friend int operator==( Remora_Import& me, int new_value); + friend int operator==( Remora_Import& me, Remora_Import& export); + + friend int operator!=( Remora_Import& me, int new_value); + friend int operator!=( Remora_Import& me, Remora_Import& export); + + friend int operator<=( Remora_Import& me, int new_value); + friend int operator<=( Remora_Import& me, Remora_Import& export); + + friend int operator>=( Remora_Import& me, int new_value); + friend int operator>=( Remora_Import& me, Remora_Import& export); + + friend int operator<( Remora_Import& me, int new_value); + friend int operator<( Remora_Import& me, Remora_Import& export); + + friend int operator>( Remora_Import& me, int new_value); + friend int operator>( Remora_Import& me, Remora_Import& export); + +private: + + void init(); + + CORBA::Long grab_value(); + + remora::Control control_; + + remora::Remora_Controls_Agent_ptr remora_agent_; + +}; + +#include "Remora_Import.i" +#endif diff --git a/apps/JAWS/remora/app/Remora_Import.i b/apps/JAWS/remora/app/Remora_Import.i new file mode 100644 index 00000000000..48fc01f3ed7 --- /dev/null +++ b/apps/JAWS/remora/app/Remora_Import.i @@ -0,0 +1,85 @@ +// $Id + +inline +Remora_Import::operator CORBA::Long() +{ + return this->grab_value(); +} + +inline CORBA::Long +Remora_Import::get(void) +{ + return this->grab_value(); +} + +inline int +operator==( Remora_Import& me, int new_value) +{ + return me.grab_value() == new_value; +} + +inline int +operator==( Remora_Import& me, Remora_Import& import) +{ + return me.grab_value() == import.grab_value(); +} + +inline int +operator!=( Remora_Import& me, int new_value) +{ + return me.grab_value() != new_value; +} + +inline int +operator!=( Remora_Import& me, Remora_Import& import) +{ + return me.grab_value() != import.grab_value(); +} + +inline int +operator<=( Remora_Import& me, int new_value) +{ + return me.grab_value() <= new_value; +} + +inline int +operator<=( Remora_Import& me, Remora_Import& import) +{ + return me.grab_value() <= import.grab_value(); +} + +inline int +operator>=( Remora_Import& me, int new_value) +{ + return me.grab_value() >= new_value; +} + +inline int +operator>=( Remora_Import& me, Remora_Import& import) +{ + return me.grab_value() >= import.grab_value(); +} + +inline int +operator<( Remora_Import& me, int new_value) +{ + return me.grab_value() < new_value; +} + +inline int +operator<( Remora_Import& me, Remora_Import& import) +{ + return me.grab_value() < import.grab_value(); +} + +inline int +operator>( Remora_Import& me, int new_value) +{ + return me.grab_value() > new_value; +} + +inline int +operator>( Remora_Import& me, Remora_Import& import) +{ + return me.grab_value() > import.grab_value(); +} diff --git a/apps/JAWS/remora/app/remora.idl b/apps/JAWS/remora/app/remora.idl new file mode 100644 index 00000000000..4f6c8713099 --- /dev/null +++ b/apps/JAWS/remora/app/remora.idl @@ -0,0 +1,100 @@ +// $Id + +// =================================================================== +// +// = FILENAME +// remora.idl +// +// = AUTHOR +// Seth Widoff +// +// =================================================================== + +// The IDL interface for the published Remora interfaces. + +module remora +{ + struct Statistic + { + string label_; + long value_; + long max_; + }; + + struct Control + { + string label_; + long value_; + long min_; + long max_; + }; + + typedef long Token; + typedef sequence<Statistic> Statistics_List; + typedef sequence<Control> Controls_List; + + exception Invalid_Statistic {}; + exception Invalid_Control {}; + + interface Statistics_Update + { + void acceptNewStatistic(in Statistic stat) raises (Invalid_Statistic); + + void updateStatistic(in Statistic stat) raises (Invalid_Statistic); + + void removeStatistic(in string label) raises (Invalid_Statistic); + }; + + interface Controls_Update + { + void acceptNewControl(in Control control) raises (Invalid_Control); + + void getControlState(inout Control control) raises (Invalid_Control); + + void removeControl(in string label) raises (Invalid_Control); + }; + + // Located in an applet, the client receives and displays + // statistics from the server. + interface Remora_Statistics_Client : Statistics_Update + { + oneway void acceptManyStatistics(in Statistics_List stats, in long length); + + oneway void updateManyStatistics(in Statistics_List stats, in long length); + // Update all statistics registered with the client + + oneway void shutdownStatistics(); + // Suggest that the client shut itself down + }; + + interface Remora_Controls_Client : Controls_Update + { + oneway void acceptManyControls(in Controls_List controls, in long length); + // Deliver many new controls to the client. + + oneway void shutdownControls(); + }; + + // Located on the server side, the Agent delivers statistics to + // registered clients. + interface Remora_Statistics_Agent : Statistics_Update + { + oneway void setFrequency(in long id, in long update_time); + // Set the frequency at which the Agent will transmit + // the statistics to the clients. + + long registerClient(in Remora_Statistics_Client client, in long update_time); + // Register a client for periodic updates. + + oneway void terminateRegistration(in long client_id); + // Unregister the client from the server. + }; + + interface Remora_Controls_Agent : Controls_Update + { + Token grabControlLock(in Remora_Controls_Client client); + + void releaseControlLock(in Token token); + }; +}; + diff --git a/apps/JAWS/remora/app/stdmk b/apps/JAWS/remora/app/stdmk new file mode 100755 index 00000000000..cc3f98edcae --- /dev/null +++ b/apps/JAWS/remora/app/stdmk @@ -0,0 +1,40 @@ +CC = CC +DEBUG = + +DOVE = /project/waltz/seth/doc/dove + +ACE_DIR = /project/waltz/seth/ACE_wrappers + +ORBELINEDIR = /project/waltz/Orbeline2.0 + +STL_DIR = /project/flamenco/irfan/STL/work-in-progress/Solaris-port.STL/Microsoft/STL + +ORBCC = $(ORBELINEDIR)/bin/orbeline -v _c -m _s + +CCINCLUDES = -I. -I$(ORBELINEDIR)/include -I$(STL_DIR) -I$(ACE_DIR) + +CCFLAGS = -g $(CCINCLUDES) $(DEBUG) + +LIBPATH = -L$(ORBELINEDIR)/lib -L$(ACE_DIR)/ace + +STDCC_LIBS = -lsocket -lnsl -ldl -mt + +LIBORB = -lorb + +LIBACE = -lACE + +.SUFFIXES: .C .o .h .hh .cc .cpp + +.C.o: + $(CC) $(CCFLAGS) -c -o $@ $< + +.cc.o: + $(CC) $(CCFLAGS) -c -o $@ $< + +.C.cpp: + $(CC) -E $(CCFLAGS) $< > $@ + +.cc.cpp: + $(CC) -E $(CCFLAGS) $< > $@ + + diff --git a/apps/JAWS/remora/app/test.cc b/apps/JAWS/remora/app/test.cc new file mode 100644 index 00000000000..76158aac5a5 --- /dev/null +++ b/apps/JAWS/remora/app/test.cc @@ -0,0 +1,77 @@ +// $Id + +#include <unistd.h> +#include <stdlib.h> +#include <iostream.h> +#include "ace/Signal.h" +#include "Remora_Export.h" +#include "Remora_Import.h" + +class Shutdown : public ACE_Event_Handler +{ +public: + Shutdown(int& cond) : cond_(cond) {} + + virtual int handle_signal(int, siginfo*, ucontext*) + { + this->cond_ = 0; + return 0; + } + +private: + + int& cond_; +}; + + +int +main(int argc, char** argv) +{ + int lcv = 1; + ACE_Sig_Handler shutdown; + + shutdown.register_handler(SIGINT, new Shutdown(lcv)); + + try + { + Remora_Export cpu("CPU Usage", 0, 100); + Remora_Export thread("Thread Count", 0, 24); + Remora_Export through("Throughput", 0, 150); + Remora_Export energy("Energy Levels", 0, 2084); + Remora_Export warp("Warp Drive Output", 0, 1023); + + Remora_Import in_threads("Threads", 1, 0, 24); + Remora_Import in_tachyon("Tachyon Emmissions", 25, 0, 100); + Remora_Import in_shields("Shield Integrity", 100, 0, 100); + Remora_Import in_phasers("Phaser Power", 421, 0, 1024); + + while (lcv) + { + cpu = rand() % 100; + thread = rand() % 24; + energy = rand() % 2084; + through = rand() % 150; + warp = rand() % 1023; + + cout << "Statistics: " << endl; + cout << "CPU: " << CORBA::Long(cpu) << endl; + cout << "Thread: " << CORBA::Long(thread) << endl; + cout << "Throughput: " << CORBA::Long(through) << endl; + cout << "Energy: " << CORBA::Long(energy) << endl; + cout << "Warp: " << CORBA::Long(cpu) << endl; + + cout << "Controls: " << endl; + cout << "Threads: " << CORBA::Long(in_threads) << endl; + cout << "Tachyon: " << CORBA::Long(in_tachyon) << endl; + cout << "Shields: " << CORBA::Long(in_shields) << endl; + cout << "Phasers: " << CORBA::Long(in_phasers) << endl; + + sleep(1); + } + } + catch(CORBA::SystemException& e) + { + + cerr << e << endl; + } +} |