libdballe  7.29
wr_exporters/common.h
1 /*
2  * dballe/wr_exporter/common - Common infrastructure for wreport exporters
3  *
4  * Copyright (C) 2013--2015 ARPA-SIM <urpsim@smr.arpa.emr.it>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * Author: Enrico Zini <enrico@enricozini.com>
20  */
21 
22 #ifndef DBALLE_MSG_WREXPORTER_BASE_H
23 #define DBALLE_MSG_WREXPORTER_BASE_H
24 
25 #include <dballe/msg/msg.h>
26 
27 namespace wreport {
28 struct Subset;
29 struct Bulletin;
30 struct Var;
31 }
32 
33 namespace dballe {
34 namespace msg {
35 namespace wr {
36 
38 {
39 protected:
40  // Subset being written
41  wreport::Subset* subset;
42  const Msg* msg = 0;
43  const msg::Context* c_ana = 0;
44  const msg::Context* c_surface_instant = 0;
45 
46  void add(wreport::Varcode code, const msg::Context* ctx, int shortcut) const;
47  void add(wreport::Varcode code, const msg::Context* ctx, wreport::Varcode srccode) const;
48  void add(wreport::Varcode code, const msg::Context* ctx) const;
49  void add(wreport::Varcode code, const wreport::Var* var) const;
50 
51 public:
52  void init(const Msg& msg, wreport::Subset& subset);
53  void scan_context(const msg::Context& c);
54 
55  void add_ecmwf_synop_head();
56 };
57 
59 {
60 protected:
61  const msg::Context* c_geopotential;
62  const msg::Context* c_thermo;
63  const msg::Context* c_tmax;
64  const msg::Context* c_tmin;
65  const msg::Context* c_prec1;
66  const msg::Context* c_prec2;
67  const msg::Context* c_prec24;
68  const msg::Context* c_cloud_cover;
69  const msg::Context* c_cloud_data[4];
70  const msg::Context* c_cloud_group[4];
71  const msg::Context* c_wind;
72  const msg::Context* c_gust1;
73  const msg::Context* c_gust2;
74  const msg::Context* c_visib;
75  const msg::Context* c_past_wtr;
76  const msg::Context* c_depth;
77  const msg::Context* c_swell_waves[2];
78 
79 public:
80  const wreport::Var* v_press;
81  const wreport::Var* v_pressmsl;
82  const wreport::Var* v_pchange3;
83  const wreport::Var* v_pchange24;
84  const wreport::Var* v_ptend;
85  const wreport::Var* v_geopotential;
86 
87  void init(const Msg& msg, wreport::Subset& subset);
88  void scan_context(const msg::Context& c);
89 
90  // Pressure data
91  void add_D02001();
92  // synop: pressure data
93  void add_D02031();
94  // synop: temperature and humidity
95  void add_D02032();
96  // ship: temperature and humidity
97  void add_D02052();
98  // synop: extreme temperature data
99  void add_D02041();
100  // ship: extreme temperature data
101  void add_D02058();
102  void add_pressure();
103  void add_geopotential(wreport::Varcode code);
104  // Precipitation past 24 hours
105  void add_D02034();
106  // Precipitation measurement
107  void add_D02040();
108  // synop: wind data
109  void add_D02042();
110  // ship: wind data
111  void add_D02059();
112  // Present and past weather
113  void add_D02038();
114  void add_ecmwf_synop_weather();
115  // Basic synoptic "instantaneous" data
116  void add_D02035();
117  // Icing and ice
118  void add_D02055();
119  void add_ecmwf_ice();
120  // ship: visibility data
121  void add_D02053();
122  // Ship marine data
123  void add_D02056();
124  // Sea waves
125  void add_plain_waves();
126  // Ship waves (wind and swell)
127  void add_D02024();
128 
133  void add_sensor_height(const msg::Context& c, const wreport::Var* sample_var=NULL);
134 
139  void add_marine_sensor_height(const msg::Context& c, const wreport::Var* sample_var=NULL);
140 
145  void add_xtemp_group(wreport::Varcode code, const msg::Context* c);
146 
150  void add_prec_group(const msg::Context* c);
151 
155  void add_cloud_data();
156 
158  void add_wind_gust(const msg::Context* c);
159 
164  void add_time_period(wreport::Varcode code, const msg::Context& c, const wreport::Var* sample_var, const Trange& tr_std);
165 };
166 
167 }
168 }
169 }
170 
171 #endif
Store an array of physical data all on the same level.
Definition: context.h:44
Storage for related physical data.
Definition: msg.h:70
Definition: wr_exporters/common.h:37
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:587
void add_marine_sensor_height(const msg::Context &c, const wreport::Var *sample_var=NULL)
Add B07032 and B07033 sensor heights, taking the value from the var attributes or the context...
void add_xtemp_group(wreport::Varcode code, const msg::Context *c)
Add an extreme temperature group, with the measured value added with the given code, from temperature data found on the given context.
void add_time_period(wreport::Varcode code, const msg::Context &c, const wreport::Var *sample_var, const Trange &tr_std)
Add a B04025 or B04025 time period variable, with data taken from its parameters as needed...
void add_prec_group(const msg::Context *c)
Add time period and total precipitation from the given context.
uint16_t Varcode
void add_wind_gust(const msg::Context *c)
Add a wind gust block with info from the given context.
Definition: wr_exporters/common.h:58
void add_sensor_height(const msg::Context &c, const wreport::Var *sample_var=NULL)
Add B07032 sensor height, taking the value from the var attributes or the context, as appropriate.
void add_cloud_data()
Add cloud data, as D02004 and a delayed replication of D02005.