Changeset 198
- Timestamp:
- 05/19/11 19:06:32 (14 years ago)
- Location:
- XMLIO_V2/dev/dev_rv/src/xmlio
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/xmlio/buffer.cpp
r196 r198 40 40 { 41 41 if (delIdata) delete [] this->idata; 42 else this->fillData('\0', this->getSize(), 0); 42 43 //CMPIManager::FreeMem(idata); 43 44 } … … 78 79 std::copy(this->getData(position), this->getData(position + size), data); 79 80 } 80 81 82 //--------------------------------------------------------------- 83 81 84 void CBuffer::setData(const char * data, StdSize size, StdSize position) 82 85 { … … 248 251 } 249 252 253 //--------------------------------------------------------------- 254 255 void CBuffer::fillData(char data, StdSize size, StdSize position) 256 { 257 if (this->size < (size + position)) 258 ERROR("CBuffer::getData(data, size, position)", 259 << " Buffer size < size + position !"); 260 std::fill_n(this->getData(position), size, data); 261 } 262 250 263 ///-------------------------------------------------------------- 251 264 -
XMLIO_V2/dev/dev_rv/src/xmlio/buffer.hpp
r196 r198 115 115 116 116 void setData(const char * data, StdSize size, StdSize position); 117 void fillData(char data, StdSize size, StdSize position); 117 118 118 119 private : -
XMLIO_V2/dev/dev_rv/src/xmlio/buffer_impl.hpp
r152 r198 27 27 { 28 28 if (this->size < (position + this->getRequestedSize(data))) 29 ERROR("CBuffer::getData <T>(data, size, position)",29 ERROR("CBuffer::getData(data, position)", 30 30 << " Buffer size < size + position !"); 31 31 CBufferData bufdata; 32 32 this->getBufferData(bufdata, position); 33 33 if (bufdata.type != this->getBufferDataType<T>()) 34 ERROR("CBuffer::getData(data, position)", << " invalid type !"); 34 ERROR("CBuffer::getData(data, position)", 35 << "[ BufferDataType Read : " << bufdata.type << ", " 36 << ", BufferDataType T : " << this->getBufferDataType<T>() << "] " 37 << " invalid type !"); 35 38 if (bufdata.isArray != false) 36 39 ERROR("CBuffer::getData(data, position)", -
XMLIO_V2/dev/dev_rv/src/xmlio/buffer_list.cpp
r196 r198 19 19 bool CBufferList::hasRequests(void) const 20 20 { 21 bool retvalue = true;22 for (StdSize i = 0; i < this->nbbuffer; i++)21 bool retvalue = SuperClass::operator[](0).hasRequest(); 22 for (StdSize i = 1; i < this->nbbuffer; i++) 23 23 retvalue = retvalue && SuperClass::operator[](i).hasRequest(); 24 24 return (retvalue); … … 36 36 if (SuperClass::operator[](i-1).isAvailable(size)) 37 37 { 38 std::cout << " b:" << i << std::endl;38 std::cout << "Données reçues de " << i << std::endl; 39 39 CMPIManager::ReceiveCircularBuffer 40 40 (com_client_server, i, SuperClass::operator[](i-1)); … … 50 50 } 51 51 } 52 std::cout << "lol" << std::endl; 52 53 static int u = 0; 54 std::cout << "Nouvelle requête disponible " << u++ << std::endl; 55 /*if (u == 3046) 56 for (int i = 1; i < CMPIManager::GetCommSize(com_client_server); i++) 57 { 58 StdOStringStream oss; oss << "data/buffer"<<i<<".txt"; 59 SuperClass::operator[](i-1).printToTextFile (oss.str()); 60 }*/ 61 53 62 return (true); 54 63 } … … 57 66 { 58 67 for (StdSize i = 0; i < this->nbbuffer; i++) 68 { 69 std::cout << "Récupération de la requête " << (i+1) << std::endl; 59 70 lbuffer.push_back(SuperClass::operator[](i).getNextRequest()); 71 } 60 72 } 61 73 -
XMLIO_V2/dev/dev_rv/src/xmlio/buffer_pair.cpp
r196 r198 20 20 bool CBufferPair::mustBeSent(void) 21 21 { 22 if (((currentBuffer == 0) && (first.getUsedSize() != 0) && 23 ((second_request == -1) || CMPIManager::Test (second_request))) || 24 ((currentBuffer == 1) && (second.getUsedSize() != 0) && 25 ((first_request == -1) || CMPIManager::Test (first_request)))) 22 if ((currentBuffer == 0) && (first.getUsedSize() != 0) && 23 ((second_request == -1) || CMPIManager::Test (second_request))) 24 return (true); 25 26 if ((currentBuffer == 1) && (second.getUsedSize() != 0) && 27 ((first_request == -1) || CMPIManager::Test (first_request))) 26 28 return (true); 29 27 30 return (false); 28 31 } … … 30 33 //--------------------------------------------------------------- 31 34 32 voidCBufferPair::wait(void)35 int CBufferPair::wait(void) 33 36 { 34 37 if (this->currentBuffer == 0) 35 CMPIManager::Wait(this->second_request); 36 else CMPIManager::Wait(this->first_request); 38 { 39 CMPIManager::Wait(this->second_request); 40 this->second_request = -1; 41 return (this->second_request); 42 } 43 else 44 { 45 CMPIManager::Wait(this->first_request); 46 this->first_request = -1; 47 return (this->first_request); 48 } 37 49 } 38 50 … … 45 57 CMPIManager::SendLinearBuffer 46 58 (this->com_client_server, 0, this->first, this->first_request); 47 this->currentBuffer = 1; 59 this->currentBuffer = 1; 60 this->second_request = -1; 48 61 this->second.clear(); 49 62 } 50 else 63 else if(this->currentBuffer == 1) 51 64 { 52 65 CMPIManager::SendLinearBuffer 53 66 (this->com_client_server, 0, this->second, this->second_request); 54 this->currentBuffer = 0; 67 this->currentBuffer = 0; 68 this->first_request = -1; 55 69 this->first.clear(); 56 70 } -
XMLIO_V2/dev/dev_rv/src/xmlio/buffer_pair.hpp
r196 r198 38 38 39 39 /// Traitements divers /// 40 voidwait(void);40 int wait(void); 41 41 void sendCurrentBuffer(void); 42 42 … … 66 66 A1 * arg1, A2 * arg2, A3 * arg3, A4 * arg4) 67 67 { 68 static int recurse = 0; 69 if (recurse > 1) 70 { 71 std::cout << "putain :" << recurse << "," << this->mustBeSent() 72 << "," << currentBuffer << "," << first.getUsedSize() << "," << second.getUsedSize(); 73 if ((currentBuffer == 0) && (first.getUsedSize() != 0) && (second_request != -1)) 74 std::cout << "," << CMPIManager::Test (second_request); 75 if ((currentBuffer == 1) && (second.getUsedSize() != 0) && (first_request != -1)) 76 std::cout << "," << CMPIManager::Test (first_request); 77 std::cout << "," << second_request << "," << first_request << std::endl; 78 } 79 80 if (recurse == 10) exit (-1); 81 68 82 if (this->mustBeSent()) 69 83 this->sendCurrentBuffer(); … … 87 101 if (rsize <= usize) 88 102 { 89 cbuffer.appendRequestInfos(managerId, methodId, nbargs); 103 cbuffer.appendRequestInfos(managerId, methodId, nbargs); 104 recurse = 0; 90 105 } 91 106 else 92 107 { 93 this->wait(); 108 int o = this->wait(); 109 recurse ++; 110 if (recurse > 1) 111 { 112 113 std::cout << "putain bis:" << recurse << "," << this->mustBeSent() << "," << CMPIManager::Test (o) 114 << "," << currentBuffer << "," << first.getUsedSize() << "," << second.getUsedSize(); 115 if ((currentBuffer == 0) && (first.getUsedSize() != 0) && (second_request != -1)) 116 std::cout << "," << CMPIManager::Test (second_request); 117 if ((currentBuffer == 1) && (second.getUsedSize() != 0) && (first_request != -1)) 118 std::cout << "," << CMPIManager::Test (first_request); 119 std::cout << "," << second_request << "," << first_request << "," << o << std::endl; 120 } 94 121 this->prepareRequest(managerId, methodId, arg1, arg2, arg3, arg4); 95 122 } -
XMLIO_V2/dev/dev_rv/src/xmlio/circular_buffer.cpp
r196 r198 50 50 nbargs = SuperClass::getInt(startpos + currsize); 51 51 currsize += SuperClass::getRequestedSize(nbargs); 52 52 53 53 for (long int i = 0; i < nbargs; i++) 54 54 { 55 55 CBufferData bufdata; 56 SuperClass::getBufferData(bufdata, currsize);56 SuperClass::getBufferData(bufdata, startpos + currsize); 57 57 currsize += (bufdata.size + DATA_HEADER_SIZE); 58 58 } … … 66 66 StdSize startpos = this-> p_read; 67 67 StdSize currsize = this->getNextRequestSize(); 68 68 69 this->movePRead(currsize); 69 70 this->nbrequest--; 71 std::cout << this->nbrequest << std::endl; 72 70 73 return (CLinearBuffer(SuperClass::getData(startpos), currsize)); 71 74 } … … 111 114 { 112 115 this-> p_read += data_size; 116 if ((this-> p_read == this-> p_unused) && 117 (this-> p_read == this-> p_write)) 118 { 119 this->clear(); 120 } 121 113 122 if (this-> p_read == this-> p_unused) 114 123 { 115 124 this-> p_unused = this-> p_write; 116 125 this-> p_read = 0; 126 return; 117 127 } 118 128 if (this-> p_read == this-> p_write) 129 { 119 130 this->clear(); 131 } 120 132 } 121 133 … … 209 221 void CCircularBuffer::updateNbRequests(StdSize data_begin, StdSize data_end) 210 222 { 211 StdSize position = data_begin , i = 0;223 StdSize position = data_begin; 212 224 while (position != data_end) 213 225 { 214 i++;215 226 this->nbrequest++; 216 position = SuperClass::getNextDataPosition(position); // manager id 217 position = SuperClass::getNextDataPosition(position); // method id 227 position = SuperClass::getNextDataPosition(position); // manager id 228 position = SuperClass::getNextDataPosition(position); // method id 229 SuperClass::updateBufferData(position); 218 230 long int nbarg = SuperClass::getInt(position); 219 231 position = SuperClass::getNextDataPosition(position); 220 232 for (long int i = 0; i < nbarg; i++) 221 233 position = SuperClass::getNextDataPosition(position); 234 235 if (position > data_end) 236 ERROR("CCircularBuffer::updateNbRequests(StdSize data_begin, StdSize data_end)", 237 << "[ position courante" << position 238 << ", fin de traitement" << data_end << " ] " 239 << "Impossible de mettre à jour la liste des requêtes !"); 222 240 } 223 241 } -
XMLIO_V2/dev/dev_rv/src/xmlio/config/properties.conf
r152 r198 16 16 /// Buffer Size /// 17 17 DECLARE_PROPERTY (StdSize, BUFFER_CLIENT_SIZE, 1E6) // 1 Mo 18 DECLARE_PROPERTY (StdSize, BUFFER_SERVER_SIZE, 1 E6) // 10 Mo18 DECLARE_PROPERTY (StdSize, BUFFER_SERVER_SIZE, 10E6) // 10 Mo 19 19 20 20 -
XMLIO_V2/dev/dev_rv/src/xmlio/linear_buffer.cpp
r196 r198 34 34 35 35 void CLinearBuffer::clear(void) 36 { this->bdata.clear(); this->p_write = 0; } 37 36 { 37 this->bdata.clear(); 38 //SuperClass::fillData('\0', SuperClass::getSize(), 0); 39 this->p_write = 0; 40 } 41 42 //--------------------------------------------------------------- 43 38 44 StdSize CLinearBuffer::getUsedSize(void) const 39 { return (this->p_write); } 40 45 { 46 return (this->p_write); 47 } 48 49 //--------------------------------------------------------------- 50 41 51 StdSize CLinearBuffer::getUnusedSize(void) const 42 { return (SuperClass::getSize() - this->getUsedSize()); } 52 { 53 return (SuperClass::getSize() - this->getUsedSize()); 54 } 43 55 44 56 //--------------------------------------------------------------- -
XMLIO_V2/dev/dev_rv/src/xmlio/main_server.cpp
r196 r198 15 15 try 16 16 { 17 ARRAY_CREATE(value0, double, 1, [200]); 18 ARRAY_CREATE(value1, double, 1, [1000]); 19 ARRAY_CREATE(value2, double, 1, [2000]); 17 20 comm::CMPIManager::Initialise(&argc, &argv); // < seulement en mode connecté 18 21 … … 22 25 server.run(); 23 26 std::cout << "fin serveur" << std::endl; 27 comm::CMPIManager::Barrier(); 24 28 25 29 } 26 30 else 27 31 { 32 28 33 comm::CClient client(comm::CMPIManager::GetCommWorld()); 29 34 client.initialize(); 35 client.setContext("lol"); 36 37 for (int j = 0; j < 10000; j++) 38 { 39 client.updateCalendar(j); 40 client.sendData("mon_champ0", value0); 41 client.sendData("mon_champ1", value1); 42 client.sendData("mon_champ2", value2); 43 } 30 44 client.finalize(); 45 comm::CMPIManager::Barrier(); 31 46 } 32 47 -
XMLIO_V2/dev/dev_rv/src/xmlio/server.cpp
r196 r198 26 26 while (this->blist.recvRequests()) 27 27 { 28 long int managerId = 0, methodId = 0, nbargs = 0;29 long int managerId_= 0, methodId_ = 0, nbargs_ = 0;28 long int managerId = -1, methodId = -1, nbargs = -1; 29 long int managerId_= -1, methodId_ = -1, nbargs_ = -1; 30 30 std::vector<CLinearBuffer> lbuffer; 31 31 this->blist.getRequests(lbuffer); 32 32 33 for (StdSize i = 0; i < lbuffer.size(); i++) 33 { 34 { 34 35 lbuffer[i].getRequestInfos(0, managerId, methodId, nbargs); 35 36 if (((managerId_ != managerId) || (methodId_ != methodId) || (nbargs_ != nbargs)) && (i != 0 )) 36 37 { 37 / *std::cout << managerId_ << "<->" << managerId << std::endl38 39 << nbargs_ << "<->" << nbargs << std::endl;*/38 //std::cout << managerId_ << "<->" << managerId << std::endl 39 // << methodId_ << "<->" << methodId << std::endl 40 // << nbargs_ << "<->" << nbargs << std::endl; 40 41 ERROR("CServer::run(void)", << "[" << i << "] Les requêtes ne sont pas synchronisées !"); 41 42 } … … 119 120 { 120 121 std::cout << "finalize called " << std::endl; 121 } 122 122 } 123 123 124 124 //-------------------------------------------------------------- 125 125 126 126 void CServer::setContext(const std::vector<CLinearBuffer> & buffer) // manager 1, method 0 127 { 128 std::cout << "setContext called " << std::endl; 127 { 128 StdString contextId; 129 for (StdSize i = 0; i < buffer.size(); i++) 130 { 131 StdString contextId_ = buffer[i].getString(3); 132 if (contextId.compare(contextId_) != 0 && (i != 0)) 133 { 134 ERROR("CServer::setContext(const std::vector<CLinearBuffer> & buffer)", 135 << "[ contextId 1 = " << contextId << ", " 136 << "[ contextId 2 = " << contextId_ << "] " 137 << " Changement de contexte désynchronisé !"); 138 } 139 else contextId = contextId_; 140 141 } 142 std::cout << "setContext called " << contextId << std::endl; 129 143 } 130 144 … … 133 147 void CServer::updateCalendar(const std::vector<CLinearBuffer> & buffer) // manager 1, method 1 134 148 { 135 std::cout << "updateCalendar called " << std::endl; 149 int timestep = -1; 150 for (StdSize i = 0; i < buffer.size(); i++) 151 { 152 int timestep_ = buffer[i].getInt(3); 153 if ((timestep_ != timestep) && (i != 0)) 154 { 155 ERROR("CServer::updateCalendar(const std::vector<CLinearBuffer> & buffer)", 156 << "[ timestep 1 = " << timestep << ", " 157 << "[ timestep 2 = " << timestep_ << "] " 158 << " Mise à jour du calendrier désynchronisée !"); 159 } 160 else timestep = timestep_; 161 162 } 163 std::cout << "updateCalendar called " << timestep <<std::endl; 136 164 } 137 165 … … 140 168 void CServer::writeData(const std::vector<CLinearBuffer> & buffer, int prec) // manager 2, method 0 - 1 141 169 { 142 std::cout << "writeData called " << std::endl; 170 StdString fieldId; 171 for (StdSize i = 0; i < buffer.size(); i++) 172 { 173 StdString fieldId_ = buffer[i].getString(3); 174 if (fieldId.compare(fieldId_) != 0 && (i != 0)) 175 { 176 ERROR("CServer::writeData(const std::vector<CLinearBuffer> & buffer, int prec)", 177 << "[fieldId 1 = " << fieldId << ", " 178 << " fieldId 2 = " << fieldId_ << "] " 179 << " Ecriture des données désynchronisée !"); 180 } 181 else fieldId = fieldId_; 182 } 183 184 if (prec == 4) 185 { 186 std::deque<ARRAY(float, 1)> dataArray(buffer.size()); 187 for (StdSize i = 0; i < buffer.size(); i++) 188 dataArray[i] = buffer[i].getFloatArray(4); 189 190 std::cout << "writeData called (float) " << fieldId << ", " << dataArray[0] << std::endl; 191 return; 192 } 193 else if (prec == 8) 194 { 195 std::deque<ARRAY(double, 1)> dataArray(buffer.size()); 196 for (StdSize i = 0; i < buffer.size(); i++) 197 dataArray[i] = buffer[i].getDoubleArray(4); 198 199 std::cout << "writeData called (double) " << fieldId << ", " << dataArray[0] << std::endl; 200 return; 201 } 202 else 203 { 204 ERROR("CServer::writeData(const std::vector<CLinearBuffer> & buffer, int prec)", 205 << " Précision des données invalide !"); 206 } 143 207 } 144 208
Note: See TracChangeset
for help on using the changeset viewer.