Changeset 567 for XIOS/trunk/src/node/axis.cpp
- Timestamp:
- 03/10/15 10:49:02 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/axis.cpp
- Property svn:executable set to *
r566 r567 6 6 #include "message.hpp" 7 7 #include "type.hpp" 8 #include "context.hpp" 9 #include "context_client.hpp" 8 10 #include "xmlioserver_spl.hpp" 9 11 … … 14 16 CAxis::CAxis(void) 15 17 : CObjectTemplate<CAxis>() 16 , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject() 18 , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject(), areClientAttributesChecked_(false) 17 19 { /* Ne rien faire de plus */ } 18 20 19 21 CAxis::CAxis(const StdString & id) 20 22 : CObjectTemplate<CAxis>(id) 21 , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject() 23 , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject(), areClientAttributesChecked_(false) 22 24 { /* Ne rien faire de plus */ } 23 25 … … 52 54 void CAxis::checkAttributes(void) 53 55 { 54 if (this->isChecked) return;55 56 if (this->size.isEmpty()) 56 57 ERROR("CAxis::checkAttributes(void)", … … 76 77 else this->ni.setValue(size); 77 78 78 StdSize zoom_begin,zoom_end, zoom_size;79 80 // Maybe index begins at 0 (zero)81 zoom_begin = (this->zoom_begin.isEmpty()) ? 0 : this->zoom_begin.getValue();82 zoom_end = (this->zoom_end.isEmpty()) ? size-1 : this->zoom_end.getValue();83 zoom_size = (this->zoom_size.isEmpty()) ? size : this->zoom_size.getValue();84 85 if (this->zoom_begin.isEmpty()) zoom_begin=zoom_end-zoom_size+1;86 if (this->zoom_end.isEmpty()) zoom_end=zoom_begin+zoom_size-1;87 if (this->zoom_size.isEmpty()) zoom_size=zoom_end-zoom_begin+1;88 89 if ( (zoom_begin < 0) || (zoom_begin > size-1) || (zoom_end<0) || (zoom_end>size-1) || (zoom_size<1) || (zoom_size>size) || (zoom_begin>zoom_end))90 ERROR("CAxis::checkAttributes(void)",91 79 << "One or more attributes among <zoom_begin>, <zoom_end>, <zoom_size> of axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] are not well specified"); 92 93 this->zoom_begin.setValue(zoom_begin);94 this->zoom_end.setValue(zoom_end);95 this->zoom_size.setValue(zoom_size);96 97 80 StdSize true_size = value.numElements(); 98 81 if (size != true_size) … … 102 85 this->checkData(); 103 86 this->checkMask(); 104 this-> isChecked = true;87 this->checkZoom(); 105 88 } 106 89 … … 122 105 for (int i = 0; i < dn; ++i) data_index(i) = (i+1); 123 106 } 107 } 108 109 void CAxis::checkZoom(void) 110 { 111 StdSize zoom_begin,zoom_end, zoom_size; 112 113 zoom_begin = (this->zoom_begin.isEmpty()) ? 0 : this->zoom_begin.getValue() ; 114 zoom_size = (this->zoom_size.isEmpty()) ? size.getValue() : this->zoom_size.getValue() ; 115 zoom_end = (this->zoom_end.isEmpty()) ? (size.getValue() - 1) : this->zoom_end.getValue() ; 116 117 if (this->zoom_begin.isEmpty()) zoom_begin=zoom_end-zoom_size+1 ; 118 if (this->zoom_end.isEmpty()) zoom_end=zoom_begin+zoom_size-1 ; 119 if (this->zoom_size.isEmpty()) zoom_size=zoom_end-zoom_begin+1 ; 120 121 if ( (zoom_begin < 0) || (zoom_begin > size-1) || (zoom_end<0) || (zoom_end>size-1) || (zoom_size<1) || (zoom_size>size) || (zoom_begin>zoom_end)) 122 ERROR("CAxis::checkAttributes(void)",<< "One or more attribut of <zoom_begin>, <zoom_end>, <zoom_size>, are not well specified") ; 123 124 this->zoom_begin.setValue(zoom_begin) ; 125 this->zoom_end.setValue(zoom_end) ; 126 this->zoom_size.setValue(zoom_size) ; 127 128 // compute client zoom indices 129 // zoom_begin_client = ibegin_client > zoom_begin ? begin_client : zoom_begin ; 130 // zoom_end_client = iend_client < zoom_end ? iend_client : zoom_end ; 131 // zoom_size_client = zoom_end_client-zoom_begin_client+1 ; 132 // if (zoom_ni_client<0) zoom_ni_client=0 ; 124 133 } 125 134 … … 166 175 } 167 176 177 bool CAxis::dispatchEvent(CEventServer& event) 178 { 179 if (SuperClass::dispatchEvent(event)) return true ; 180 else 181 { 182 switch(event.type) 183 { 184 case EVENT_ID_SERVER_ATTRIBUT : 185 recvServerAttribut(event) ; 186 return true ; 187 break ; 188 default : 189 ERROR("bool CContext::dispatchEvent(CEventServer& event)", 190 <<"Unknown Event") ; 191 return false ; 192 } 193 } 194 } 195 196 void CAxis::checkAttributesOnClient(const std::vector<int>& globalDim, int orderPositionInGrid, 197 CServerDistributionDescription::ServerDistributionType distType) 198 { 199 if (this->areClientAttributesChecked_) return; 200 this->checkAttributes(); 201 202 CContext* context=CContext::getCurrent() ; 203 if (context->hasClient) 204 { 205 computeServerIndex(globalDim, orderPositionInGrid, distType); 206 } 207 208 this->areClientAttributesChecked_ = true; 209 } 210 211 void CAxis::computeServerIndex(const std::vector<int>& globalDim, int orderPositionInGrid, 212 CServerDistributionDescription::ServerDistributionType distType) 213 { 214 CServerDistributionDescription serverDescription(globalDim); 215 216 CContext* context=CContext::getCurrent() ; 217 CContextClient* client=context->client ; 218 int nbServer=client->serverSize ; 219 int serverRank=client->getServerLeader() ; 220 221 serverDescription.computeServerDistribution(nbServer, false, distType); 222 std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 223 std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 224 begin_srv = (serverIndexBegin[serverRank])[orderPositionInGrid]; 225 ni_srv = serverDimensionSizes[serverRank][orderPositionInGrid]; 226 end_srv = begin_srv+ni_srv-1; 227 } 228 229 // Send all checked attributes to server 230 void CAxis::sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, 231 CServerDistributionDescription::ServerDistributionType distType) 232 { 233 if (!this->areClientAttributesChecked_) checkAttributesOnClient(globalDim, 234 orderPositionInGrid, 235 distType); 236 CContext* context=CContext::getCurrent() ; 237 238 if (this->isChecked) return; 239 if (context->hasClient) 240 { 241 sendServerAttribut() ; 242 } 243 244 this->isChecked = true; 245 } 246 247 void CAxis::sendServerAttribut(void) 248 { 249 CContext* context=CContext::getCurrent(); 250 CContextClient* client=context->client; 251 252 CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT) ; 253 if (client->isServerLeader()) 254 { 255 CMessage msg ; 256 msg<<this->getId() ; 257 msg<<ni_srv<<begin_srv<<end_srv; 258 event.push(client->getServerLeader(),1,msg) ; 259 client->sendEvent(event) ; 260 } 261 else client->sendEvent(event) ; 262 } 263 264 void CAxis::recvServerAttribut(CEventServer& event) 265 { 266 CBufferIn* buffer=event.subEvents.begin()->buffer; 267 string axisId ; 268 *buffer>>axisId ; 269 get(axisId)->recvServerAttribut(*buffer) ; 270 } 271 272 void CAxis::recvServerAttribut(CBufferIn& buffer) 273 { 274 int zoom_end = zoom_begin.getValue()+zoom_size.getValue()-1; 275 int ni_srv, begin_srv, end_srv; 276 277 buffer>>ni_srv>>begin_srv>>end_srv; 278 279 zoom_begin_srv = zoom_begin.getValue() > begin_srv ? zoom_begin.getValue() : begin_srv ; 280 zoom_end_srv = zoom_end < end_srv ? zoom_end : end_srv ; 281 zoom_size_srv = zoom_end_srv-zoom_begin_srv+1 ; 282 283 if (zoom_size_srv<=0) 284 { 285 zoom_begin_srv=0 ; zoom_end_srv=0 ; zoom_size_srv=0 ; 286 } 287 } 288 168 289 DEFINE_REF_FUNC(Axis,axis) 169 290
Note: See TracChangeset
for help on using the changeset viewer.