-
Notifications
You must be signed in to change notification settings - Fork 0
/
ENLink.h
243 lines (207 loc) · 4.74 KB
/
ENLink.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#ifndef SRC_LIBRARY_H
#define SRC_LIBRARY_H
#ifdef _WIN32
#ifdef __cplusplus
#define DLLEXPORT extern "C" __declspec(dllexport)
#define WINAPI
//#define WINAPI __stdcall
#else
#define DLLEXPORT __declspec(dllexport)
#define WINAPI __stdcall
#endif
#else
#ifdef __cplusplus
#define DLLEXPORT extern "C"
#define WINAPI
#else
#define DLLEXPORT
#define WINAPI
#endif
#endif
/**
* @brief Sets the working directory
*
* ENLink uses this to place files in - e.g. copies of the EN .inp file, and binary output files etc. Logging places
* logs here as well. You can ensure that the working files (apart from any log files which may be saved) are deleted
* when the analysis is finished as a parameter in the function clear.
*
* @param working_dir The path to the directory where files (e.g. log, temporary EN files etc) will be saved.
* @return an int error code. 0 means success
*/
DLLEXPORT int WINAPI
setWorkingDir(const char* working_dir);
/**
* @brief Creates a new analysis.
*
* Each analysis has its own runtime loaded EN library, and each analysis is identified by an integer returned from this
* function. Always use this integer identifier to specify what analysis to apply functions to, for each of the functions
* specified in ENLink.
*
* @param opt_cfg_file The path of the file
* @return A unique identifier for this analysis. Calls to this library use this identifier to get the cost, etc for the analysis intended.
* If this value is negative, this means an error occured during the creation of a new analysis.
*/
DLLEXPORT int WINAPI
createAnalysis(const char* opt_cfg_file);
/**
* @brief Turns on logging of the calculations performed
*
* A log file is generated in the working directory, with file name "enLink_calcs.log". This breaksdown the
* components of the calculation (e.g. costs for each pipe is costs are assessed.
*
* @param analysisID The identifier
* @return an int error code. 0 means success
*/
DLLEXPORT int WINAPI
doLog(int analysisID);
/**
*
* @return
*/
DLLEXPORT int WINAPI
getAnAnalysis();
/**
*
* @param numberDVs
* @param lower_bounds
* @param upper_bounds
* @return an int error code. 0 means success
*/
DLLEXPORT int* WINAPI
getDVBounds(int analysisID, int* numberDVs);
/**
*
* @param analysisID The identifier of this analysis
* @param decision_variables A integer array that contains the decision variable vales
* @return an integer error code. 0 means success. These error codes are the same as the EN2 error codes....
*/
DLLEXPORT int WINAPI
runEN(int analysisID, const int* decision_variables);
DLLEXPORT bool WINAPI
isPipeCapitalCostCalculated(int analysisID);
/**
*
* @param analysisID
* @return
*/
DLLEXPORT double WINAPI
getPipeCapitalCost(int analysisID);
DLLEXPORT bool WINAPI
isPressureViolationCalculated(int analysisID);
/**
*
* @param analysisID
* @return
*/
DLLEXPORT double WINAPI
getSumPressureTooHigh(int analysisID);
/**
*
* @param analysisID
* @return
*/
DLLEXPORT double WINAPI
getMaxPressureTooHigh(int analysisID);
/**
*
* @param analysisID
* @return
*/
DLLEXPORT double WINAPI
getSumPressureTooLow(int analysisID);
/**
*
* @param analysisID
* @return
*/
DLLEXPORT double WINAPI
getMinPressureTooLow(int analysisID);
DLLEXPORT bool WINAPI
isHeadViolationCalculated(int analysisID);
/**
*
* @param analysisID
* @return
*/
DLLEXPORT double WINAPI
getSumHeadTooHigh(int analysisID);
/**
*
* @param analysisID
* @return
*/
DLLEXPORT double WINAPI
getMaxHeadTooHigh(int analysisID);
/**
*
* @param analysisID
* @return
*/
DLLEXPORT double WINAPI
getSumHeadTooLow(int analysisID);
/**
*
* @param analysisID
* @return
*/
DLLEXPORT double WINAPI
getMinHeadTooLow(int analysisID);
//Not yet implemented.
//DLLEXPORT bool WINAPI
//isVelocityViolationCalculated(int analysisID);
/**
*
* @param analysisID
* @return
*/
DLLEXPORT double WINAPI
getSumVelocityTooHigh(int analysisID);
/**
*
* @param analysisID
* @return
*/
DLLEXPORT double WINAPI
getMaxVelocityTooHigh(int analysisID);
/**
*
*/
DLLEXPORT bool WINAPI
isNetworkResilienceCalculated(int analysisID);
/**
*
* @param analysisID
* @return
*/
DLLEXPORT double WINAPI
getNetworkResilience(int analysisID);
/**
*
*/
DLLEXPORT int WINAPI
saveAnalysisF(int analysisID, const char* file_path);
/**
*
*/
DLLEXPORT int WINAPI
saveAnalysis(int analysisID);
/**
* @param analysisID the index for the analysis to hand back (i.e. no longer need this analyssi to test network, so other threads can use)
* @return int code whether successful or not. 0 indicates success
*/
DLLEXPORT int WINAPI
handBackAnalysis(int analysisID);
/**
*
* @param analysisID
* @return
*/
DLLEXPORT int WINAPI
clear(int analysisID, bool _delete_temp_on_exit);
/**
*
* @return
*/
DLLEXPORT int WINAPI
clearAll(bool _delete_temp_on_exit);
#endif