Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
plot.h
Go to the documentation of this file.
1 /*
2 ** Copyright 2014-2018 The Earlham Institute
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 ** http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16 /*
17  * plot.h
18  *
19  * Created on: 23 Jul 2018
20  * Author: billy
21  */
22 
23 #ifndef SERVICES_FIELD_TRIALS_INCLUDE_PLOT_H_
24 #define SERVICES_FIELD_TRIALS_INCLUDE_PLOT_H_
25 
27 #include "study.h"
28 #include "jansson.h"
29 
30 
31 #include "linked_list.h"
32 
33 
34 #ifndef DOXYGEN_SHOULD_SKIP_THIS
35 
36 #ifdef ALLOCATE_PLOT_TAGS
37  #define PLOT_PREFIX DFW_FIELD_TRIAL_SERVICE_API
38  #define PLOT_VAL(x) = x
39  #define PLOT_CONCAT_VAL(x,y) = x y
40 #else
41  #define PLOT_PREFIX extern
42  #define PLOT_VAL(x)
43  #define PLOT_CONCAT_VAL(x,y)
44 #endif
45 
46 #endif /* #ifndef DOXYGEN_SHOULD_SKIP_THIS */
47 
48 
49 PLOT_PREFIX const char *PL_ID_S PLOT_VAL ("id");
50 
51 PLOT_PREFIX const char *PL_PARENT_STUDY_S PLOT_VAL ("parent_study_id");
52 
53 PLOT_PREFIX const char *PL_SOWING_DATE_S PLOT_VAL ("sowing_date");
54 
55 PLOT_PREFIX const char *PL_HARVEST_DATE_S PLOT_VAL ("harvest_date");
56 
57 PLOT_PREFIX const char *PL_WIDTH_S PLOT_VAL ("width");
58 
59 PLOT_PREFIX const char *PL_LENGTH_S PLOT_VAL ("length");
60 
61 PLOT_PREFIX const char *PL_TREATMENT_S PLOT_VAL ("treatment");
62 
63 PLOT_PREFIX const char *PL_ROW_INDEX_S PLOT_VAL ("row_index");
64 
65 PLOT_PREFIX const char *PL_COLUMN_INDEX_S PLOT_VAL ("column_index");
66 
67 PLOT_PREFIX const char *PL_ROWS_S PLOT_VAL ("rows");
68 
69 PLOT_PREFIX const char *PL_RACK_INDICES_S PLOT_VAL ("rack_indices");
70 
71 PLOT_PREFIX const char *PL_COMMENT_S PLOT_VAL ("comment");
72 
73 PLOT_PREFIX const char *PL_IMAGE_S PLOT_CONCAT_VAL (CONTEXT_PREFIX_SCHEMA_ORG_S, "image");
74 
75 PLOT_PREFIX const char *PL_THUMBNAIL_S PLOT_CONCAT_VAL (CONTEXT_PREFIX_SCHEMA_ORG_S, "thumbnail");
76 
77 PLOT_PREFIX int32 PL_UNSET_ID PLOT_VAL (INT32_MAX);
78 
79 PLOT_PREFIX const char *PL_SOWING_ORDER_S PLOT_VAL ("sowing_order");
80 
81 PLOT_PREFIX const char *PL_WALKING_ORDER_S PLOT_VAL ("walking_order");
82 
83 
84 typedef struct Plot
85 {
86  bson_oid_t *pl_id_p;
87 
89 
90  /*
91  * Drilling
92  */
93 
94  uint32 pl_row_index;
95 
97 
98  struct tm *pl_sowing_date_p;
99 
101 
103 
105 
106  /*
107  * Plots
108  */
109 
110  double64 *pl_width_p;
111 
112  double64 *pl_length_p;
113 
115 
117 
119 
120 
121  struct tm *pl_harvest_date_p;
122 
123 
130 
135 
136 
141 
142 
143 } Plot;
144 
145 
146 typedef struct PlotNode
147 {
149 
151 } PlotNode;
152 
153 
154 /*
155  * forward declaration
156  */
157 struct Row;
158 
159 #ifdef __cplusplus
160 extern "C"
161 {
162 #endif
163 
164 
165 DFW_FIELD_TRIAL_SERVICE_LOCAL Plot *AllocatePlot (bson_oid_t *id_p, const struct tm *sowing_date_p, const struct tm *harvest_date_p, const double64 *width_p, const double64 *length_p, const uint32 row_index,
166  const uint32 column_index, const char *treatments_s, const char *comment_s, const char *image_s, const char *thumbnail_s,
167  const uint32 *walking_order_p, const uint32 *sowing_order_p, Study *parent_p);
168 
169 
171 
173 
175 
176 
177 DFW_FIELD_TRIAL_SERVICE_LOCAL json_t *GetPlotAsJSON (Plot *plot_p, const ViewFormat format, JSONProcessor *processor_p, const FieldTrialServiceData *data_p);
178 
179 
180 DFW_FIELD_TRIAL_SERVICE_LOCAL Plot *GetPlotFromJSON (const json_t *plot_json_p, Study *parent_study_p, const ViewFormat format, FieldTrialServiceData *data_p);
181 
182 
183 DFW_FIELD_TRIAL_SERVICE_LOCAL bool GetPlotRows (Plot *plot_p, json_t *rows_array_p, const Study *study_p, const ViewFormat format, FieldTrialServiceData *data_p);
184 
185 
187 
188 
189 DFW_FIELD_TRIAL_SERVICE_LOCAL bool AddRowToPlot (Plot *plot_p, struct Row *row_p);
190 
191 
192 DFW_FIELD_TRIAL_SERVICE_LOCAL struct Row *GetRowFromPlotByStudyIndex (Plot *plot_p, const uint32 by_study_index);
193 
194 //DFW_FIELD_TRIAL_SERVICE_LOCAL Plot *GetPlotByIndex (const Study *study_p, const uint32 plot_index, const FieldTrialServiceData *data_p);
195 
196 DFW_FIELD_TRIAL_SERVICE_LOCAL struct Row *GetRowFromPlotByStudyIndex (Plot *plot_p, const uint32 by_study_index);
197 
198 
199 DFW_FIELD_TRIAL_SERVICE_LOCAL struct Row *GetRowFromPlotByRackIndex (Plot *plot_p, const uint32 rack_index);
200 
201 
202 DFW_FIELD_TRIAL_SERVICE_LOCAL Plot *GetPlotByIdString (const char *plot_id_s, const ViewFormat format, const FieldTrialServiceData *data_p);
203 
204 
205 DFW_FIELD_TRIAL_SERVICE_LOCAL void *GetPlotCallback (const json_t *json_p, const ViewFormat format, const FieldTrialServiceData *data_p);
206 
207 #ifdef __cplusplus
208 }
209 #endif
210 
211 
212 
213 #endif /* SERVICES_FIELD_TRIALS_INCLUDE_PLOT_H_ */
GetPlotFromJSON
Plot * GetPlotFromJSON(const json_t *plot_json_p, Study *parent_study_p, const ViewFormat format, FieldTrialServiceData *data_p)
Plot::pl_sowing_order_index_p
uint32 * pl_sowing_order_index_p
Definition: plot.h:102
Plot
Definition: plot.h:84
Plot::pl_row_index
uint32 pl_row_index
Definition: plot.h:94
GetRowFromPlotByRackIndex
struct Row * GetRowFromPlotByRackIndex(Plot *plot_p, const uint32 rack_index)
study.h
Plot::pl_harvest_date_p
struct tm * pl_harvest_date_p
Definition: plot.h:121
GetPlotRows
bool GetPlotRows(Plot *plot_p, json_t *rows_array_p, const Study *study_p, const ViewFormat format, FieldTrialServiceData *data_p)
PLOT_CONCAT_VAL
const PLOT_PREFIX char *PL_IMAGE_S PLOT_CONCAT_VAL(CONTEXT_PREFIX_SCHEMA_ORG_S, "image")
GetPlotCallback
void * GetPlotCallback(const json_t *json_p, const ViewFormat format, const FieldTrialServiceData *data_p)
PlotNode
Definition: plot.h:146
GetPlotByIdString
Plot * GetPlotByIdString(const char *plot_id_s, const ViewFormat format, const FieldTrialServiceData *data_p)
JSONProcessor
Definition: json_processor.h:21
Plot::pl_sowing_date_p
struct tm * pl_sowing_date_p
Definition: plot.h:98
Plot::pl_comment_s
char * pl_comment_s
Definition: plot.h:118
FreePlotNode
void FreePlotNode(ListItem *node_p)
Plot::pl_length_p
double64 * pl_length_p
Definition: plot.h:112
dfw_field_trial_service_library.h
PlotNode::pn_node
ListItem pn_node
Definition: plot.h:148
DFW_FIELD_TRIAL_SERVICE_LOCAL
#define DFW_FIELD_TRIAL_SERVICE_LOCAL
Definition: dfw_field_trial_service_library.h:43
CONTEXT_PREFIX_SCHEMA_ORG_S
#define CONTEXT_PREFIX_SCHEMA_ORG_S
Definition: schema_keys.h:103
PlotNode::pn_plot_p
Plot * pn_plot_p
Definition: plot.h:150
Plot::pl_treatments_s
char * pl_treatments_s
Definition: plot.h:114
Plot::pl_soil_type_s
char * pl_soil_type_s
Definition: plot.h:116
PLOT_VAL
const PLOT_PREFIX char *PL_ID_S PLOT_VAL("id")
Plot::pl_image_url_s
char * pl_image_url_s
A url for any images,.
Definition: plot.h:134
LinkedList
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
Plot::pl_thumbnail_url_s
char * pl_thumbnail_url_s
A url for any images thumbnail,.
Definition: plot.h:140
GetRowFromPlotByStudyIndex
struct Row * GetRowFromPlotByStudyIndex(Plot *plot_p, const uint32 by_study_index)
Plot::pl_sowing_rate
double pl_sowing_rate
Definition: plot.h:100
AllocatePlot
Plot * AllocatePlot(bson_oid_t *id_p, const struct tm *sowing_date_p, const struct tm *harvest_date_p, const double64 *width_p, const double64 *length_p, const uint32 row_index, const uint32 column_index, const char *treatments_s, const char *comment_s, const char *image_s, const char *thumbnail_s, const uint32 *walking_order_p, const uint32 *sowing_order_p, Study *parent_p)
Plot::pl_column_index
uint32 pl_column_index
Definition: plot.h:96
AddRowToPlot
bool AddRowToPlot(Plot *plot_p, struct Row *row_p)
FreePlot
void FreePlot(Plot *plot_p)
GetPlotAsJSON
json_t * GetPlotAsJSON(Plot *plot_p, const ViewFormat format, JSONProcessor *processor_p, const FieldTrialServiceData *data_p)
linked_list.h
A doubly-linked list.
Plot::pl_parent_p
Study * pl_parent_p
Definition: plot.h:88
Plot::pl_width_p
double64 * pl_width_p
Definition: plot.h:110
Plot::pl_id_p
bson_oid_t * pl_id_p
Definition: plot.h:86
FieldTrialServiceData
The configuration data used by the DFW Field Trial Service.
Definition: dfw_field_trial_service_data.h:118
ViewFormat
ViewFormat
An indicator of what the output destination is for the JSON data values.
Definition: view_format.h:19
AllocatePlotNode
PlotNode * AllocatePlotNode(Plot *plot_p)
Study
Definition: study.h:182
Plot::pl_rows_p
LinkedList * pl_rows_p
A LinkedList of RowNodes for all of the Rows in this Plot.
Definition: plot.h:129
Row
Definition: row.h:54
Plot::pl_walking_order_index_p
uint32 * pl_walking_order_index_p
Definition: plot.h:104
SavePlot
bool SavePlot(Plot *plot_p, const FieldTrialServiceData *data_p)
ListItem
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43