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 #include <Shadow.h>
00034 #include <stdlib.h>
00035
00036 #include <Channel.h>
00037 #include <MachineBroker.h>
00038 #include <Message.h>
00039 #include <MovableObject.h>
00040 #include <Matrix.h>
00041 #include <Vector.h>
00042 #include <ID.h>
00043 #include <FEM_ObjectBroker.h>
00044
00045 Shadow::Shadow(Channel &theChan,
00046 FEM_ObjectBroker &myBroker)
00047 :theChannel(&theChan), theBroker(&myBroker), theRemoteActorsAddress(0), commitTag(0)
00048 {
00049 theChannel->setUpConnection();
00050 }
00051
00052
00053 Shadow::Shadow(Channel &theChan,
00054 FEM_ObjectBroker &myBroker,
00055 ChannelAddress &theAddress)
00056 :theChannel(&theChan), theBroker(&myBroker), theRemoteActorsAddress(&theAddress),
00057 commitTag(0)
00058 {
00059 theChannel->setUpConnection();
00060 }
00061
00062 Shadow::Shadow(int actorType,
00063 FEM_ObjectBroker &myBroker,
00064 MachineBroker &theMachineBroker,
00065 int compDemand)
00066 :theBroker(&myBroker), theRemoteActorsAddress(0), commitTag(0)
00067 {
00068
00069 theChannel = theMachineBroker.startActor(actorType, compDemand);
00070 if (theChannel < 0) {
00071 opserr << "Shadow::Shadow - could not start remote actor\n";
00072 opserr << " using program " << actorType << endln;
00073 exit(-1);
00074 }
00075
00076
00077 theChannel->setUpConnection();
00078 theRemoteActorsAddress = theChannel->getLastSendersAddress();
00079 }
00080
00081 Shadow::~Shadow()
00082 {
00083
00084 }
00085
00086 int
00087 Shadow::sendObject(MovableObject &theObject)
00088 {
00089 return theChannel->sendObj(commitTag, theObject, theRemoteActorsAddress);
00090 }
00091
00092 int
00093 Shadow::recvObject(MovableObject &theObject)
00094 {
00095 return theChannel->recvObj(commitTag, theObject,*theBroker, theRemoteActorsAddress);
00096 }
00097
00098
00099 int
00100 Shadow::recvMessage(Message &theMessage)
00101 {
00102 return theChannel->recvMsg(0, commitTag, theMessage, theRemoteActorsAddress);
00103 }
00104
00105 int
00106 Shadow::sendMessage(const Message &theMessage)
00107 {
00108 return theChannel->sendMsg(0, commitTag, theMessage, theRemoteActorsAddress);
00109 }
00110
00111 int
00112 Shadow::sendMatrix(const Matrix &theMatrix)
00113 {
00114 return theChannel->sendMatrix(0, commitTag, theMatrix, theRemoteActorsAddress);
00115 }
00116
00117 int
00118 Shadow::recvMatrix(Matrix &theMatrix)
00119 {
00120 return theChannel->recvMatrix(0, commitTag, theMatrix, theRemoteActorsAddress);
00121 }
00122
00123 int
00124 Shadow::sendVector(const Vector &theVector)
00125 {
00126 return theChannel->sendVector(0, commitTag, theVector, theRemoteActorsAddress);
00127 }
00128
00129 int
00130 Shadow::recvVector(Vector &theVector)
00131 {
00132 return theChannel->recvVector(0, commitTag, theVector, theRemoteActorsAddress);
00133 }
00134
00135 int
00136 Shadow::sendID(const ID &theID)
00137 {
00138 return theChannel->sendID(0, commitTag, theID, theRemoteActorsAddress);
00139 }
00140
00141 int
00142 Shadow::recvID(ID &theID)
00143 {
00144 return theChannel->recvID(0, commitTag, theID, theRemoteActorsAddress);
00145 }
00146
00147
00148 void
00149 Shadow::setCommitTag(int tag)
00150 {
00151 commitTag = tag;
00152 }
00153
00154
00155 Channel *
00156 Shadow::getChannelPtr(void) const
00157 {
00158 return theChannel;
00159 }
00160
00161 FEM_ObjectBroker *
00162 Shadow::getObjectBrokerPtr(void) const
00163 {
00164 return theBroker;
00165 }
00166
00167 ChannelAddress *
00168 Shadow::getActorAddressPtr(void) const
00169 {
00170 return theRemoteActorsAddress;
00171 }
00172
00173