Changeset 643
- Timestamp:
- 07/17/15 13:58:13 (10 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 2 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/calendar_util.cpp
r550 r643 211 211 ///---------------------------------------------------------------- 212 212 213 bool DurationFakeLessComparator::operator()(const CDuration& dur1, const CDuration& dur2) const 214 { 215 if (dur1.year < dur2.year) 216 return true; 217 else if (dur1.year == dur2.year) 218 { 219 if (dur1.month < dur2.month) 220 return true; 221 else if (dur1.month == dur2.month) 222 { 223 if (dur1.day < dur2.day) 224 return true; 225 else if (dur1.day == dur2.day) 226 { 227 if (dur1.hour < dur2.hour) 228 return true; 229 else if (dur1.hour == dur2.hour) 230 { 231 if (dur1.minute < dur2.minute) 232 return true; 233 else if (dur1.minute == dur2.minute) 234 { 235 if (dur1.second < dur2.second) 236 return true; 237 else if (dur1.second == dur2.second) 238 return (dur1.timestep < dur2.timestep); 239 } 240 } 241 } 242 } 243 } 244 return false; 245 } 246 247 ///---------------------------------------------------------------- 248 213 249 } // namespace xios 214 250 -
XIOS/trunk/src/calendar_util.hpp
r591 r643 36 36 ///--------------------------------------------------------------- 37 37 38 //!< Provides a fake "less" comparator for durations that can be used as a comparator for maps 39 struct DurationFakeLessComparator { 40 bool operator()(const CDuration& dur1, const CDuration& dur2) const; 41 }; 38 42 } // namespace xios 39 43 -
XIOS/trunk/src/filter/binary_arithmetic_filter.cpp
r642 r643 12 12 { 13 13 CDataPacketPtr packet(new CDataPacket); 14 packet->date = data[0]->date; 14 15 packet->timestamp = data[0]->timestamp; 15 16 packet->status = data[0]->status; … … 30 31 { 31 32 CDataPacketPtr packet(new CDataPacket); 33 packet->date = data[0]->date; 32 34 packet->timestamp = data[0]->timestamp; 33 35 packet->status = data[0]->status; … … 47 49 { 48 50 CDataPacketPtr packet(new CDataPacket); 51 packet->date = data[0]->date; 49 52 packet->timestamp = data[0]->timestamp; 50 53 -
XIOS/trunk/src/filter/data_packet.hpp
r637 r643 5 5 6 6 #include "array_new.hpp" 7 #include "d uration.hpp"7 #include "date.hpp" 8 8 9 9 namespace xios … … 23 23 24 24 CArray<double, 1> data; //!< Array containing the data 25 CDate date; //!< Date associated to the data 25 26 Time timestamp; //!< Timestamp of the data 26 27 StatusCode status; //!< Status of the packet … … 35 36 p->data.resize(data.shape()); 36 37 p->data = data; 38 p->date = date; 37 39 p->timestamp = timestamp; 38 40 p->status = status; -
XIOS/trunk/src/filter/source_filter.cpp
r638 r643 14 14 15 15 template <int N> 16 void CSourceFilter::streamData( Time timestamp, const CArray<double, N>& data)16 void CSourceFilter::streamData(CDate date, const CArray<double, N>& data) 17 17 { 18 18 CDataPacketPtr packet(new CDataPacket); 19 packet->timestamp = timestamp; 19 packet->date = date; 20 packet->timestamp = date; 20 21 packet->status = CDataPacket::NO_ERROR; 21 22 … … 26 27 } 27 28 28 template void CSourceFilter::streamData<1>( Time timestamp, const CArray<double, 1>& data);29 template void CSourceFilter::streamData<2>( Time timestamp, const CArray<double, 2>& data);30 template void CSourceFilter::streamData<3>( Time timestamp, const CArray<double, 3>& data);29 template void CSourceFilter::streamData<1>(CDate date, const CArray<double, 1>& data); 30 template void CSourceFilter::streamData<2>(CDate date, const CArray<double, 2>& data); 31 template void CSourceFilter::streamData<3>(CDate date, const CArray<double, 3>& data); 31 32 32 void CSourceFilter::streamDataFromServer( Time timestamp, const std::map<int, CArray<double, 1> >& data)33 void CSourceFilter::streamDataFromServer(CDate date, const std::map<int, CArray<double, 1> >& data) 33 34 { 34 35 CDataPacketPtr packet(new CDataPacket); 35 packet->timestamp = timestamp; 36 packet->date = date; 37 packet->timestamp = date; 36 38 packet->status = CDataPacket::NO_ERROR; 37 39 38 40 if (data.size() != grid->storeIndex_toSrv.size()) 39 ERROR("CSourceFilter::streamDataFromServer( Time timestamp, const std::map<int, CArray<double, 1> >& data)",41 ERROR("CSourceFilter::streamDataFromServer(CDate date, const std::map<int, CArray<double, 1> >& data)", 40 42 << "Incoherent data received from servers," 41 43 << " expected " << grid->storeIndex_toSrv.size() << " chunks but " << data.size() << " were given."); … … 54 56 } 55 57 56 void CSourceFilter::signalEndOfStream( Time timestamp)58 void CSourceFilter::signalEndOfStream(CDate date) 57 59 { 58 60 CDataPacketPtr packet(new CDataPacket); 59 packet->timestamp = timestamp; 61 packet->date = date; 62 packet->timestamp = date; 60 63 packet->status = CDataPacket::END_OF_STREAM; 61 64 deliverOuput(packet); -
XIOS/trunk/src/filter/source_filter.hpp
r638 r643 28 28 * immediately after this method returns. 29 29 * 30 * \param timestamp the timestamp ofthe data30 * \param date the date associated to the data 31 31 * \param data an array containing the data 32 32 */ 33 33 template <int N> 34 void streamData( Time timestamp, const CArray<double, N>& data);34 void streamData(CDate date, const CArray<double, N>& data); 35 35 36 36 /*! … … 39 39 * immediately after this method returns. 40 40 * 41 * \param timestamp the timestamp ofthe data41 * \param date the date associated to the data 42 42 * \param data an array containing the data 43 43 */ 44 void streamDataFromServer( Time timestamp, const std::map<int, CArray<double, 1> >& data);44 void streamDataFromServer(CDate date, const std::map<int, CArray<double, 1> >& data); 45 45 46 46 /*! 47 47 * Signals the filter graph that the end of stream was reached. 48 48 * 49 * \param timestamp the timestampat which the end of stream occurred49 * \param date the date at which the end of stream occurred 50 50 */ 51 void signalEndOfStream( Time timestamp);51 void signalEndOfStream(CDate date); 52 52 53 53 private: -
XIOS/trunk/src/filter/unary_arithmetic_filter.cpp
r642 r643 11 11 { 12 12 CDataPacketPtr packet(new CDataPacket); 13 packet->date = data[0]->date; 13 14 packet->timestamp = data[0]->timestamp; 14 15 packet->status = data[0]->status; -
XIOS/trunk/src/node/field.cpp
r642 r643 21 21 #include "filter_expr_node.hpp" 22 22 #include "lex_parser.hpp" 23 #include "temporal_filter.hpp" 23 24 24 25 namespace xios{ … … 810 811 { 811 812 fileWriterFilter = boost::shared_ptr<CFileWriterFilter>(new CFileWriterFilter(gc, this)); 812 instantDataFilter->connectOutput(fileWriterFilter, 0);813 getTemporalDataFilter(gc, file->output_freq)->connectOutput(fileWriterFilter, 0); 813 814 } 814 815 } … … 834 835 835 836 return clientSourceFilter; 837 } 838 839 /*! 840 * Returns the temporal filter corresponding to the field's temporal operation 841 * for the specified operation frequency. The filter is created if it does not 842 * exist, otherwise it is reused. 843 * 844 * \param gc the garbage collector to use 845 * \param outFreq the operation frequency, i.e. the frequency at which the output data will be computed 846 * \return the output pin corresponding to the requested temporal filter 847 */ 848 boost::shared_ptr<COutputPin> CField::getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq) 849 { 850 std::map<CDuration, boost::shared_ptr<COutputPin> >::iterator it = temporalDataFilters.find(outFreq); 851 852 if (it == temporalDataFilters.end()) 853 { 854 if (operation.isEmpty()) 855 ERROR("void CField::getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq)", 856 << "An operation must be defined for field \"" << getId() << "\"."); 857 858 if (freq_op.isEmpty()) 859 freq_op.setValue(TimeStep); 860 if (freq_offset.isEmpty()) 861 freq_offset.setValue(NoneDu); 862 863 const bool ignoreMissingValue = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true); 864 865 boost::shared_ptr<CTemporalFilter> temporalFilter(new CTemporalFilter(gc, operation, 866 CContext::getCurrent()->getCalendar()->getInitDate(), 867 freq_op, freq_offset, outFreq, 868 ignoreMissingValue, ignoreMissingValue ? default_value : 0.0)); 869 instantDataFilter->connectOutput(temporalFilter, 0); 870 871 it = temporalDataFilters.insert(std::make_pair(outFreq, temporalFilter)).first; 872 } 873 874 return it->second; 836 875 } 837 876 -
XIOS/trunk/src/node/field.hpp
r642 r643 134 134 void buildFilterGraph(CGarbageCollector& gc, bool enableOutput); 135 135 boost::shared_ptr<COutputPin> getSelfReference(CGarbageCollector& gc); 136 boost::shared_ptr<COutputPin> getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq); 136 137 137 138 // virtual void fromBinary(StdIStream & is); … … 246 247 //! The output pin of the filter providing the instant data for the field 247 248 boost::shared_ptr<COutputPin> instantDataFilter; 249 //! The output pin of the filters providing the result of the field's temporal operation 250 std::map<CDuration, boost::shared_ptr<COutputPin>, DurationFakeLessComparator> temporalDataFilters; 248 251 //! The source filter for data provided by the client 249 252 boost::shared_ptr<CSourceFilter> clientSourceFilter; -
XIOS/trunk/src/parse_expr/filter_expr_node.cpp
r642 r643 32 32 33 33 return outputPin; 34 } 35 36 CFilterTemporalFieldExprNode::CFilterTemporalFieldExprNode(const std::string& fieldId) 37 : fieldId(fieldId) 38 { /* Nothing to do */ } 39 40 boost::shared_ptr<COutputPin> CFilterTemporalFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const 41 { 42 if (!CField::has(fieldId)) 43 ERROR("boost::shared_ptr<COutputPin> CFilterTemporalFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", 44 << "The field " << fieldId << " does not exist."); 45 46 CField* field = CField::get(fieldId); 47 if (field == &thisField) 48 ERROR("boost::shared_ptr<COutputPin> CFilterFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", 49 << "The field " << fieldId << " has an invalid reference to itself."); 50 51 field->buildFilterGraph(gc, false); 52 return field->getTemporalDataFilter(gc, thisField.freq_op.isEmpty() ? TimeStep : thisField.freq_op); 34 53 } 35 54 -
XIOS/trunk/src/parse_expr/filter_expr_node.hpp
r642 r643 42 42 */ 43 43 CFilterFieldExprNode(const std::string& fieldId); 44 45 virtual boost::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField) const; 46 47 private: 48 std::string fieldId; //!< The identifier of the field 49 }; 50 51 /*! 52 * Expression node corresponding to a field for which the result of 53 * the temporal operation is requested instead of the instant value. 54 */ 55 class CFilterTemporalFieldExprNode : public IFilterExprNode 56 { 57 public: 58 /*! 59 * Constructs an expression node corresponding 60 * to the field whose id is provided. 61 * 62 * \param fieldId the identifier of the field 63 */ 64 CFilterTemporalFieldExprNode(const std::string& fieldId); 44 65 45 66 virtual boost::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField) const; -
XIOS/trunk/src/parse_expr/yacc_parser.cpp
r642 r643 1373 1373 case 15: 1374 1374 #line 78 "yacc_parser.yacc" /* yacc.c:1646 */ 1375 { /* TODO: Use temporal operation */ (yyval.filterNode) = new CFilterFieldExprNode(*(yyvsp[0].str)); delete (yyvsp[0].str); }1375 { (yyval.filterNode) = new CFilterTemporalFieldExprNode(*(yyvsp[0].str)); delete (yyvsp[0].str); } 1376 1376 #line 1377 "yacc_parser.cpp" /* yacc.c:1646 */ 1377 1377 break; -
XIOS/trunk/src/parse_expr/yacc_parser.yacc
r642 r643 76 76 Field_expr: 77 77 ID { $$ = new CFilterFieldExprNode(*$1); delete $1; } 78 | AVERAGE { /* TODO: Use temporal operation */ $$ = new CFilterFieldExprNode(*$1); delete $1; }78 | AVERAGE { $$ = new CFilterTemporalFieldExprNode(*$1); delete $1; } 79 79 | Field_expr PLUS Field_expr { $$ = new CFilterFieldFieldOpExprNode($1, "add", $3); } 80 80 | Field_expr MINUS Field_expr { $$ = new CFilterFieldFieldOpExprNode($1, "minus", $3); }
Note: See TracChangeset
for help on using the changeset viewer.