00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <DecMachineBroker.h>
00039 #include <stdlib.h>
00040
00041 #include <string.h>
00042 #include <remote.h>
00043 #include <Channel.h>
00044
00045
00046 DecMachineBroker::DecMachineBroker(FEM_ObjectBroker *theBroker)
00047 :MachineBroker(theBroker), currentMachine(0), maxNumMachines(9)
00048 {
00049 char *dec1 = "dec-1";
00050 char *dec2 = "dec-2";
00051 char *dec3 = "dec-3";
00052 char *dec4 = "dec-4";
00053 char *dec5 = "dec-5";
00054 char *dec6 = "dec-6";
00055 char *dec7 = "dec-7";
00056 char *dec8 = "dec-8";
00057 char *dec9 = "dec-9";
00058
00059 char **theMachines = (char **)malloc(9*sizeof(char *));
00060 theMachines[0] = dec9;
00061 theMachines[1] = dec8;
00062 theMachines[2] = dec7;
00063 theMachines[3] = dec6;
00064 theMachines[4] = dec5;
00065 theMachines[5] = dec4;
00066 theMachines[6] = dec3;
00067 theMachines[7] = dec2;
00068 theMachines[8] = dec1;
00069
00070 machines = theMachines;
00071 }
00072 DecMachineBroker::~DecMachineBroker()
00073 {
00074 }
00075
00076
00077 int
00078 DecMachineBroker::startActor(char *actorProgram,
00079 Channel &theChannel,
00080 int compDemand)
00081 {
00082 char remotecmd[400];
00083
00084
00085 char *machine;
00086 if (currentMachine < maxNumMachines)
00087 machine = machines[currentMachine];
00088 else {
00089 currentMachine = 0;
00090 machine = machines[currentMachine];
00091 }
00092
00093 currentMachine++;
00094
00095 strcpy(remotecmd,REMOTE);
00096 strcat(remotecmd," ");
00097 strcat(remotecmd,machine);
00098 strcat(remotecmd," ");
00099 strcat(remotecmd,actorProgram);
00100 strcat(remotecmd," ");
00101 strcat(remotecmd,theChannel.addToProgram());
00102 strcat(remotecmd,"\n");
00103
00104 system(remotecmd);
00105
00106 return 0;
00107 }
00108