MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / setupConnection

Method setupConnection

SRC/element/adapter/Adapter.cpp:1004–1099  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1002
1003
1004int Adapter::setupConnection()
1005{
1006 // setup the connection
1007 if (udp)
1008 theChannel = new UDP_Socket(ipPort);
1009#ifdef SSL
1010 else if (ssl)
1011 theChannel = new TCP_SocketSSL(ipPort);
1012#endif
1013 else
1014 theChannel = new TCP_Socket(ipPort);
1015
1016 if (theChannel != 0) {
1017 opserr << "\nChannel successfully created: "
1018 << "Waiting for ECSimAdapter experimental control...\n";
1019 } else {
1020 opserr << "Adapter::setupConnection() - "
1021 << "could not create channel\n";
1022 return -1;
1023 }
1024 if (theChannel->setUpConnection() != 0) {
1025 opserr << "Adapter::setupConnection() - "
1026 << "failed to setup connection\n";
1027 return -2;
1028 }
1029
1030 // get the data sizes
1031 // sizes = {ctrlDisp, ctrlVel, ctrlAccel, ctrlForce, ctrlTime,
1032 // daqDisp, daqVel, daqAccel, daqForce, daqTime, dataSize}
1033 ID sizes(11);
1034 theChannel->recvID(0, 0, sizes, 0);
1035 for (int i=0; i<10; i++) {
1036 if (sizes(i) != 0 && sizes(i) != numBasicDOF) {
1037 opserr << "Adapter::Adapter() - wrong data sizes != "
1038 << numBasicDOF << " received\n";
1039 return -3;
1040 }
1041 }
1042
1043 // allocate memory for the receive vectors
1044 int id = 1;
1045 rData = new double [sizes(10)];
1046 recvData = new Vector(rData, sizes(10));
1047 if (sizes(0) != 0) {
1048 ctrlDisp = new Vector(&rData[id], sizes(0));
1049 id += sizes(0);
1050 }
1051 if (sizes(1) != 0) {
1052 ctrlVel = new Vector(&rData[id], sizes(1));
1053 id += sizes(1);
1054 }
1055 if (sizes(2) != 0) {
1056 ctrlAccel = new Vector(&rData[id], sizes(2));
1057 id += sizes(2);
1058 }
1059 if (sizes(3) != 0) {
1060 ctrlForce = new Vector(&rData[id], sizes(3));
1061 id += sizes(3);

Callers 1

updateMethod · 0.95

Calls 4

setUpConnectionMethod · 0.45
recvIDMethod · 0.45
ZeroMethod · 0.45
getTagMethod · 0.45

Tested by

no test coverage detected