Changeset 198


Ignore:
Timestamp:
05/19/11 19:06:32 (13 years ago)
Author:
hozdoba
Message:
 
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  
    4040      { 
    4141         if (delIdata) delete [] this->idata; 
     42         else this->fillData('\0', this->getSize(), 0); 
    4243         //CMPIManager::FreeMem(idata); 
    4344      } 
     
    7879         std::copy(this->getData(position), this->getData(position + size), data); 
    7980      } 
    80  
     81       
     82      //--------------------------------------------------------------- 
     83       
    8184      void CBuffer::setData(const char * data, StdSize size, StdSize position) 
    8285      { 
     
    248251      } 
    249252       
     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       
    250263      ///-------------------------------------------------------------- 
    251264 
  • XMLIO_V2/dev/dev_rv/src/xmlio/buffer.hpp

    r196 r198  
    115115 
    116116            void setData(const char * data, StdSize size, StdSize position); 
     117            void fillData(char data, StdSize size, StdSize position); 
    117118 
    118119         private : 
  • XMLIO_V2/dev/dev_rv/src/xmlio/buffer_impl.hpp

    r152 r198  
    2727      { 
    2828         if (this->size < (position + this->getRequestedSize(data))) 
    29             ERROR("CBuffer::getData<T>(data, size, position)", 
     29            ERROR("CBuffer::getData(data, position)", 
    3030                   << " Buffer size <  size + position !"); 
    3131         CBufferData bufdata; 
    3232         this->getBufferData(bufdata, position); 
    3333         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 !"); 
    3538         if (bufdata.isArray != false) 
    3639            ERROR("CBuffer::getData(data, position)", 
  • XMLIO_V2/dev/dev_rv/src/xmlio/buffer_list.cpp

    r196 r198  
    1919      bool CBufferList::hasRequests(void) const 
    2020      { 
    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++) 
    2323            retvalue = retvalue && SuperClass::operator[](i).hasRequest(); 
    2424         return (retvalue); 
     
    3636                  if (SuperClass::operator[](i-1).isAvailable(size)) 
    3737                  { 
    38                      std::cout << "b:" << i << std::endl; 
     38                     std::cout << "Données reçues de " << i << std::endl; 
    3939                     CMPIManager::ReceiveCircularBuffer 
    4040                        (com_client_server, i, SuperClass::operator[](i-1)); 
     
    5050            } 
    5151         } 
    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             
    5362         return (true); 
    5463      } 
     
    5766      { 
    5867         for (StdSize i = 0; i < this->nbbuffer; i++) 
     68         { 
     69            std::cout << "Récupération de la requête " << (i+1) << std::endl; 
    5970            lbuffer.push_back(SuperClass::operator[](i).getNextRequest()); 
     71         } 
    6072      } 
    6173 
  • XMLIO_V2/dev/dev_rv/src/xmlio/buffer_pair.cpp

    r196 r198  
    2020      bool CBufferPair::mustBeSent(void) 
    2121      { 
    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))) 
    2628            return (true); 
     29             
    2730         return (false); 
    2831      } 
     
    3033      //--------------------------------------------------------------- 
    3134       
    32       void CBufferPair::wait(void) 
     35      int CBufferPair::wait(void) 
    3336      { 
    3437         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         } 
    3749      } 
    3850       
     
    4557            CMPIManager::SendLinearBuffer 
    4658               (this->com_client_server, 0, this->first, this->first_request); 
    47             this->currentBuffer = 1; 
     59            this->currentBuffer  =  1; 
     60            this->second_request = -1; 
    4861            this->second.clear(); 
    4962         } 
    50          else 
     63         else  if(this->currentBuffer == 1) 
    5164         { 
    5265            CMPIManager::SendLinearBuffer 
    5366               (this->com_client_server, 0, this->second, this->second_request); 
    54             this->currentBuffer = 0; 
     67            this->currentBuffer =  0; 
     68            this->first_request = -1; 
    5569            this->first.clear(); 
    5670         } 
  • XMLIO_V2/dev/dev_rv/src/xmlio/buffer_pair.hpp

    r196 r198  
    3838             
    3939            /// Traitements divers /// 
    40             void wait(void); 
     40            int wait(void); 
    4141            void sendCurrentBuffer(void);  
    4242                         
     
    6666                                          A1 * arg1, A2 * arg2, A3 * arg3, A4 * arg4) 
    6767      { 
     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          
    6882         if (this->mustBeSent())  
    6983            this->sendCurrentBuffer(); 
     
    87101         if (rsize <= usize) 
    88102         { 
    89             cbuffer.appendRequestInfos(managerId, methodId, nbargs);         
     103            cbuffer.appendRequestInfos(managerId, methodId, nbargs); 
     104            recurse = 0;        
    90105         } 
    91106         else 
    92107         { 
    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            } 
    94121            this->prepareRequest(managerId, methodId, arg1, arg2, arg3, arg4); 
    95122         } 
  • XMLIO_V2/dev/dev_rv/src/xmlio/circular_buffer.cpp

    r196 r198  
    5050         nbargs    = SuperClass::getInt(startpos + currsize); 
    5151         currsize += SuperClass::getRequestedSize(nbargs); 
    52  
     52          
    5353         for (long int i = 0; i < nbargs; i++) 
    5454         { 
    5555            CBufferData bufdata; 
    56             SuperClass::getBufferData(bufdata, currsize); 
     56            SuperClass::getBufferData(bufdata, startpos + currsize); 
    5757            currsize += (bufdata.size + DATA_HEADER_SIZE); 
    5858         } 
     
    6666         StdSize startpos = this-> p_read; 
    6767         StdSize currsize = this->getNextRequestSize(); 
     68         
    6869         this->movePRead(currsize); 
    6970         this->nbrequest--; 
     71         std::cout <<  this->nbrequest << std::endl; 
     72         
    7073         return (CLinearBuffer(SuperClass::getData(startpos), currsize)); 
    7174      } 
     
    111114      { 
    112115         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          
    113122         if (this-> p_read == this-> p_unused) 
    114123         { 
    115124            this-> p_unused = this-> p_write; 
    116125            this-> p_read   = 0; 
     126            return; 
    117127         } 
    118128         if (this-> p_read == this-> p_write) 
     129         { 
    119130            this->clear(); 
     131         } 
    120132      } 
    121133       
     
    209221      void CCircularBuffer::updateNbRequests(StdSize data_begin, StdSize data_end) 
    210222      { 
    211          StdSize position = data_begin, i = 0; 
     223         StdSize position = data_begin;         
    212224         while (position != data_end) 
    213225         { 
    214             i++; 
    215226            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); 
    218230            long int nbarg = SuperClass::getInt(position); 
    219231            position = SuperClass::getNextDataPosition(position); 
    220232            for (long int i = 0; i < nbarg; i++) 
    221233               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 !"); 
    222240         } 
    223241      } 
  • XMLIO_V2/dev/dev_rv/src/xmlio/config/properties.conf

    r152 r198  
    1616/// Buffer Size /// 
    1717DECLARE_PROPERTY (StdSize, BUFFER_CLIENT_SIZE, 1E6) // 1 Mo 
    18 DECLARE_PROPERTY (StdSize, BUFFER_SERVER_SIZE, 1E6) // 10 Mo 
     18DECLARE_PROPERTY (StdSize, BUFFER_SERVER_SIZE, 10E6) // 10 Mo 
    1919 
    2020 
  • XMLIO_V2/dev/dev_rv/src/xmlio/linear_buffer.cpp

    r196 r198  
    3434 
    3535      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       
    3844      StdSize CLinearBuffer::getUsedSize(void) const 
    39       { return (this->p_write); } 
    40  
     45      {  
     46         return (this->p_write);  
     47      } 
     48       
     49      //--------------------------------------------------------------- 
     50       
    4151      StdSize CLinearBuffer::getUnusedSize(void) const 
    42       { return (SuperClass::getSize() - this->getUsedSize()); } 
     52      { 
     53          return (SuperClass::getSize() - this->getUsedSize());  
     54      } 
    4355 
    4456      //--------------------------------------------------------------- 
  • XMLIO_V2/dev/dev_rv/src/xmlio/main_server.cpp

    r196 r198  
    1515   try 
    1616   { 
     17      ARRAY_CREATE(value0, double, 1, [200]); 
     18      ARRAY_CREATE(value1, double, 1, [1000]); 
     19      ARRAY_CREATE(value2, double, 1, [2000]); 
    1720      comm::CMPIManager::Initialise(&argc, &argv); // < seulement en mode connecté 
    1821       
     
    2225         server.run(); 
    2326         std::cout << "fin serveur" << std::endl; 
     27         comm::CMPIManager::Barrier(); 
    2428          
    2529      } 
    2630      else 
    2731      { 
     32          
    2833         comm::CClient client(comm::CMPIManager::GetCommWorld()); 
    2934         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         } 
    3044         client.finalize(); 
     45         comm::CMPIManager::Barrier(); 
    3146      } 
    3247       
  • XMLIO_V2/dev/dev_rv/src/xmlio/server.cpp

    r196 r198  
    2626      while (this->blist.recvRequests()) 
    2727      { 
    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; 
    3030         std::vector<CLinearBuffer> lbuffer; 
    3131         this->blist.getRequests(lbuffer); 
     32                  
    3233         for (StdSize i = 0; i < lbuffer.size(); i++) 
    33          { 
     34         {            
    3435            lbuffer[i].getRequestInfos(0, managerId, methodId, nbargs); 
    3536            if (((managerId_ != managerId) || (methodId_ != methodId) || (nbargs_ != nbargs)) && (i != 0 )) 
    3637            { 
    37                /*std::cout << managerId_ << "<->" << managerId << std::endl 
    38                            << methodId_  << "<->" << methodId  << std::endl 
    39                            << nbargs_    << "<->" << nbargs    << std::endl;*/ 
     38               //std::cout << managerId_ << "<->" << managerId << std::endl 
     39               //          << methodId_  << "<->" << methodId  << std::endl 
     40               //          << nbargs_    << "<->" << nbargs    << std::endl; 
    4041               ERROR("CServer::run(void)", << "[" << i << "] Les requêtes ne sont pas synchronisées !"); 
    4142            } 
     
    119120   { 
    120121      std::cout << "finalize called " << std::endl; 
    121    } 
    122     
     122   }    
    123123    
    124124   //-------------------------------------------------------------- 
    125125              
    126126   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; 
    129143   } 
    130144    
     
    133147   void CServer::updateCalendar(const std::vector<CLinearBuffer> & buffer) // manager 1, method 1 
    134148   { 
    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; 
    136164   } 
    137165    
     
    140168   void CServer::writeData(const std::vector<CLinearBuffer> & buffer, int prec)  // manager 2, method 0 - 1 
    141169   { 
    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      } 
    143207   } 
    144208   
Note: See TracChangeset for help on using the changeset viewer.