Changeset 300 for XMLIO_V2/dev/common/src/node/field.hpp
- Timestamp:
- 02/13/12 19:35:25 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/common/src/node/field.hpp
r286 r300 11 11 #include "declare_group.hpp" 12 12 #include "calendar_util.hpp" 13 //#include "context.hpp" 14 13 15 14 16 namespace xmlioserver { … … 23 25 class CFile; 24 26 class CGrid; 25 27 class CContext ; 26 28 ///-------------------------------------------------------------- 27 29 … … 48 50 typedef CFieldGroup RelGroup; 49 51 52 enum EEventId 53 { 54 EVENT_ID_UPDATE_DATA 55 } ; 56 50 57 /// Constructeurs /// 51 58 CField(void); … … 82 89 void incrementNStep(void); 83 90 84 template <StdSize N> 85 inline bool updateData 86 (const date::CDate & currDate, 87 const date::CDuration & timestep, 88 const ARRAY(double, N) data); 89 91 template <StdSize N> bool updateData(const ARRAY(double, N) data); 92 90 93 bool updateDataServer 91 94 (const date::CDate & currDate, 92 95 const std::deque<ARRAY(double, 1)> storedClient); 93 94 public :96 97 public : 95 98 96 99 /// Test /// … … 112 115 113 116 static ENodeType GetType(void); 114 115 private : 117 118 template <StdSize N> void setData(const ARRAY(double, N) _data) ; 119 static bool dispatchEvent(CEventServer& event) ; 120 void sendUpdateData(void) ; 121 static void recvUpdateData(CEventServer& event) ; 122 void recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) ; 123 void writeField(void) ; 124 void outputField(ARRAY(double,3) fieldOut) ; 125 void outputField(ARRAY(double,2) fieldOut) ; 126 127 public : 116 128 117 129 /// Propriétés privées /// … … 123 135 124 136 date::CDuration freq_operation, freq_write; 137 date::CDuration freq_operation_srv, freq_write_srv; 125 138 126 139 StdSize nstep; 127 140 boost::shared_ptr<date::CDate> last_Write, last_operation; 141 boost::shared_ptr<date::CDate> last_Write_srv, last_operation_srv; 142 128 143 boost::shared_ptr<func::CFunctor> foperation; 144 map<int,boost::shared_ptr<func::CFunctor> > foperation_srv; 129 145 130 146 ARRAY(double, 1) data; 147 map<int,ARRAY(double,1)> data_srv ; 131 148 132 149 }; // class CField … … 153 170 154 171 template <StdSize N> 155 bool CField::updateData(const date::CDate & currDate, const date::CDuration & timestep, const ARRAY(double, N) _data) 172 void CField::setData(const ARRAY(double, N) _data) 173 { 174 const std::vector<boost::shared_ptr<CField> > & refField=getAllReference(); 175 std::vector<boost::shared_ptr<CField> >::const_iterator it = refField.begin(), end = refField.end(); 176 177 for (; it != end; it++) (*it)->updateData(_data) ; 178 } 179 180 template <StdSize N> 181 bool CField::updateData(const ARRAY(double, N) _data) 156 182 { 183 shared_ptr<CContext> context=CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()) ; 184 const date::CDate & currDate = context->getCalendar()->getCurrentDate(); 157 185 const date::CDate opeDate = *last_operation + freq_operation; 158 186 const date::CDate writeDate = *last_Write + freq_write; 159 187 160 // std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl;161 // std::cout << "Champ : " << this->getBaseFieldId() << std::endl;162 // std::cout << "CurrDate : " << currDate << std::endl;163 // std::cout << "opeDate : " << opeDate << " = " << *last_operation << " + " << freq_operation << std::endl;164 // std::cout << "writeDate : " << writeDate << " = " << *last_Write << " + " << freq_write << std::endl;165 // std::cout << "(opeDate <= currDate) = " << std::boolalpha << (opeDate <= currDate) << std::endl;166 // std::cout << "(writeDate <= currDate) = " << std::boolalpha << (writeDate <= currDate) << std::endl;167 188 168 std::cout << ">> " << currDate << " : Envoi de données " << this->getBaseFieldId() << std::endl; 169 std::cout << ">> next operation " << opeDate<<std::endl; 189 info(50) << "CField::updateData " << currDate << " : send data to " << this->getBaseFieldId() << std::endl; 190 info(50) << "Next operation " << opeDate<<std::endl; 191 170 192 if (opeDate <= currDate) 171 193 { 172 //std::cout << "> " << currDate << ": Operation du champs" << this->getBaseFieldId() << std::endl; 173 if (this->data->num_elements() != this->grid->storeIndex[0]->num_elements()) 194 if (this->data->num_elements() != this->grid->storeIndex_client->num_elements()) 174 195 { 175 this->data->resize(boost::extents[this->grid->storeIndex [0]->num_elements()]);196 this->data->resize(boost::extents[this->grid->storeIndex_client ->num_elements()]); 176 197 } 177 198 … … 181 202 182 203 *last_operation = currDate; 183 std::cout<< "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl;204 info(50) << "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl; 184 205 } 185 206 … … 187 208 { 188 209 this->foperation->final(); 189 this->incrementNStep();190 210 *last_Write = writeDate; 191 std::cout << "(*last_Write = currDate) : " << *last_Write << " = " << currDate << std::endl; 211 info(50) << "(*last_Write = currDate) : " << *last_Write << " = " << currDate << std::endl; 212 sendUpdateData() ; 192 213 return (true); 193 214 } 194 // std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl; 215 195 216 return (false); 196 } ;217 } 197 218 198 219 } // namespace tree
Note: See TracChangeset
for help on using the changeset viewer.