MillMachineBroker.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.3 $
00022 // $Date: 2003/08/29 07:19:26 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/actor/machineBroker/MillMachineBroker.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/actor/broker/MillMachineBroker.h
00027 //
00028 // Written: fmk
00029 // Created: March 1998
00030 // Revision: A
00031 //
00032 // Purpose: This file contains the class definition for MillMachineBroker.
00033 // MillMachineBroker is a machine broker for use with the cluster of
00034 // Millennium machines in Sida Hall.
00035 //
00036 // What: "@(#) MillMachineBroker.h, revA"
00037 
00038 #include <MillMachineBroker.h>
00039 #include <stdlib.h>
00040 
00041 #include <string.h>
00042 #include <remote.h>
00043 #include <Channel.h>
00044 
00045 MillMachineBroker::MillMachineBroker(FEM_ObjectBroker *theBroker)
00046   :MachineBroker(theBroker), currentMachine(0),maxNumMachines(5)
00047 {
00048     char *mill0 = "mill0";
00049     char *mill1 = "mill1";
00050     char *mill2 = "mill2";
00051     char *mill3 = "mill3";
00052     char *mill4 = "mill4";
00053     
00054     char **theMachines = (char **)malloc(5*sizeof(char *));
00055     theMachines[0] = mill0;
00056     theMachines[1] = mill1;
00057     theMachines[2] = mill2;
00058     theMachines[3] = mill3;
00059     theMachines[4] = mill4;
00060     
00061     machines = theMachines;
00062 }
00063 MillMachineBroker::~MillMachineBroker()
00064 {
00065 }
00066 
00067 
00068 int 
00069 MillMachineBroker::startActor(char *actorProgram, 
00070                                Channel &theChannel,
00071                                int compDemand)
00072 { 
00073     char  remotecmd[400];
00074 
00075     // get the next machine, a round-robin approach
00076     char *machine;
00077     if (currentMachine < maxNumMachines)
00078         machine = machines[currentMachine];
00079     else {
00080         currentMachine = 0;
00081         machine = machines[currentMachine];
00082     }
00083 
00084     currentMachine++;
00085     
00086     strcpy(remotecmd,REMOTE);
00087     strcat(remotecmd," ");          
00088     strcat(remotecmd,machine);
00089     strcat(remotecmd," ");
00090     strcat(remotecmd,actorProgram);
00091     strcat(remotecmd," ");
00092     strcat(remotecmd,theChannel.addToProgram());    
00093     strcat(remotecmd,"\n");
00094 
00095     // opserr << "MillMachineBroker::Constructor - command\n"<< remotecmd;
00096     system(remotecmd);
00097 
00098     return 0;
00099 }
00100 

Generated on Mon Oct 23 15:04:56 2006 for OpenSees by doxygen 1.5.0