epyt-flow 0.14.0__py3-none-any.whl → 0.14.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- epyt_flow/EPANET/EPANET/SRC_engines/AUTHORS +40 -8
- epyt_flow/EPANET/EPANET/SRC_engines/LICENSE +3 -3
- epyt_flow/EPANET/EPANET/SRC_engines/enumstxt.h +24 -7
- epyt_flow/EPANET/EPANET/SRC_engines/epanet.c +726 -374
- epyt_flow/EPANET/EPANET/SRC_engines/epanet2.c +128 -32
- epyt_flow/EPANET/EPANET/SRC_engines/errors.dat +7 -1
- epyt_flow/EPANET/EPANET/SRC_engines/flowbalance.c +186 -0
- epyt_flow/EPANET/EPANET/SRC_engines/funcs.h +40 -14
- epyt_flow/EPANET/EPANET/SRC_engines/hash.c +177 -177
- epyt_flow/EPANET/EPANET/SRC_engines/hash.h +28 -28
- epyt_flow/EPANET/EPANET/SRC_engines/hydcoeffs.c +192 -40
- epyt_flow/EPANET/EPANET/SRC_engines/hydraul.c +101 -46
- epyt_flow/EPANET/EPANET/SRC_engines/hydsolver.c +85 -24
- epyt_flow/EPANET/EPANET/SRC_engines/hydstatus.c +29 -63
- epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2.h +70 -37
- epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_2.h +408 -234
- epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_enums.h +87 -37
- epyt_flow/EPANET/EPANET/SRC_engines/inpfile.c +153 -79
- epyt_flow/EPANET/EPANET/SRC_engines/input1.c +59 -94
- epyt_flow/EPANET/EPANET/SRC_engines/input2.c +73 -202
- epyt_flow/EPANET/EPANET/SRC_engines/input3.c +446 -351
- epyt_flow/EPANET/EPANET/SRC_engines/leakage.c +527 -0
- epyt_flow/EPANET/EPANET/SRC_engines/mempool.c +8 -4
- epyt_flow/EPANET/EPANET/SRC_engines/mempool.h +23 -23
- epyt_flow/EPANET/EPANET/SRC_engines/output.c +5 -4
- epyt_flow/EPANET/EPANET/SRC_engines/project.c +407 -75
- epyt_flow/EPANET/EPANET/SRC_engines/quality.c +12 -2
- epyt_flow/EPANET/EPANET/SRC_engines/qualreact.c +70 -13
- epyt_flow/EPANET/EPANET/SRC_engines/qualroute.c +7 -5
- epyt_flow/EPANET/EPANET/SRC_engines/report.c +88 -20
- epyt_flow/EPANET/EPANET/SRC_engines/rules.c +144 -6
- epyt_flow/EPANET/EPANET/SRC_engines/smatrix.c +19 -19
- epyt_flow/EPANET/EPANET/SRC_engines/text.h +16 -5
- epyt_flow/EPANET/EPANET/SRC_engines/types.h +73 -19
- epyt_flow/EPANET/EPANET/SRC_engines/util/cstr_helper.c +59 -0
- epyt_flow/EPANET/EPANET/SRC_engines/util/cstr_helper.h +38 -0
- epyt_flow/EPANET/EPANET/SRC_engines/util/errormanager.c +92 -0
- epyt_flow/EPANET/EPANET/SRC_engines/util/errormanager.h +39 -0
- epyt_flow/EPANET/EPANET/SRC_engines/util/filemanager.c +212 -0
- epyt_flow/EPANET/EPANET/SRC_engines/util/filemanager.h +81 -0
- epyt_flow/EPANET/EPANET/SRC_engines/validate.c +408 -0
- epyt_flow/EPANET/compile_linux.sh +1 -1
- epyt_flow/EPANET/compile_macos.sh +1 -1
- epyt_flow/VERSION +1 -1
- epyt_flow/gym/scenario_control_env.py +26 -3
- epyt_flow/simulation/events/quality_events.py +6 -6
- epyt_flow/simulation/events/sensor_faults.py +24 -24
- epyt_flow/simulation/events/system_event.py +3 -3
- epyt_flow/simulation/scada/scada_data.py +1 -1
- epyt_flow/simulation/scenario_simulator.py +14 -11
- epyt_flow/topology.py +8 -1
- epyt_flow/uncertainty/model_uncertainty.py +292 -150
- {epyt_flow-0.14.0.dist-info → epyt_flow-0.14.1.dist-info}/METADATA +2 -2
- {epyt_flow-0.14.0.dist-info → epyt_flow-0.14.1.dist-info}/RECORD +57 -51
- epyt_flow/EPANET/EPANET/SRC_engines/Readme_SRC_Engines.txt +0 -18
- epyt_flow/EPANET/EPANET/SRC_engines/epanet2.def +0 -131
- epyt_flow/EPANET/EPANET/SRC_engines/main.c +0 -93
- {epyt_flow-0.14.0.dist-info → epyt_flow-0.14.1.dist-info}/WHEEL +0 -0
- {epyt_flow-0.14.0.dist-info → epyt_flow-0.14.1.dist-info}/licenses/LICENSE +0 -0
- {epyt_flow-0.14.0.dist-info → epyt_flow-0.14.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
******************************************************************************
|
|
3
|
+
Project: OWA EPANET
|
|
4
|
+
Version: 2.3
|
|
5
|
+
Module: util/errormanager.h
|
|
6
|
+
Description: Provides a simple interface for managing errors
|
|
7
|
+
Authors: see AUTHORS
|
|
8
|
+
Copyright: see AUTHORS
|
|
9
|
+
License: see LICENSE
|
|
10
|
+
Last Updated: 04/02/2019
|
|
11
|
+
******************************************************************************
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
#ifndef ERRORMANAGER_H_
|
|
15
|
+
#define ERRORMANAGER_H_
|
|
16
|
+
|
|
17
|
+
#define ERR_MAXMSG 256
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
#if defined(__cplusplus)
|
|
21
|
+
extern "C" {
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
// Forward declaration
|
|
25
|
+
typedef struct error_s error_handle_t;
|
|
26
|
+
|
|
27
|
+
error_handle_t* create_error_manager(void (*p_error_message)(int, char*, int));
|
|
28
|
+
void delete_error_manager(error_handle_t* error_handle);
|
|
29
|
+
|
|
30
|
+
int set_error(error_handle_t* error_handle, int error_code);
|
|
31
|
+
int check_error(error_handle_t* error_handle, char **error_message);
|
|
32
|
+
void clear_error(error_handle_t* error_handle);
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
#if defined(__cplusplus)
|
|
36
|
+
}
|
|
37
|
+
#endif
|
|
38
|
+
|
|
39
|
+
#endif /* ERRORMANAGER_H_ */
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/*
|
|
2
|
+
******************************************************************************
|
|
3
|
+
Project: OWA EPANET
|
|
4
|
+
Version: 2.3
|
|
5
|
+
Module: util/filemanager.c
|
|
6
|
+
Description: Provides a simple interface for managing files
|
|
7
|
+
Authors: see AUTHORS
|
|
8
|
+
Copyright: see AUTHORS
|
|
9
|
+
License: see LICENSE
|
|
10
|
+
Last Updated: 08/02/2023
|
|
11
|
+
******************************************************************************
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
// MSVC ONLY
|
|
16
|
+
#ifdef _DEBUG
|
|
17
|
+
#define _CRTDBG_MAP_ALLOC
|
|
18
|
+
#include <stdlib.h>
|
|
19
|
+
#include <crtdbg.h>
|
|
20
|
+
#else
|
|
21
|
+
#include <stdlib.h>
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
#include <stdarg.h>
|
|
25
|
+
|
|
26
|
+
#include "filemanager.h"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
typedef struct file_s {
|
|
30
|
+
char *filename; // Assumes this is a null terminated string
|
|
31
|
+
FILE *file;
|
|
32
|
+
} file_handle_t;
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
// local (private) functions
|
|
36
|
+
int _fopen(FILE **f, const char *name, const char *mode);
|
|
37
|
+
int _get_temp_filename(char **tempname);
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
file_handle_t *create_file_manager() {
|
|
41
|
+
|
|
42
|
+
file_handle_t *file_handle;
|
|
43
|
+
file_handle = (file_handle_t *)calloc(1, sizeof(file_handle_t));
|
|
44
|
+
if (file_handle == NULL) return NULL;
|
|
45
|
+
|
|
46
|
+
file_handle->filename = NULL;
|
|
47
|
+
file_handle->file = NULL;
|
|
48
|
+
|
|
49
|
+
return file_handle;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void delete_file_manager(file_handle_t *file_handle) {
|
|
53
|
+
|
|
54
|
+
if (file_handle->file != NULL)
|
|
55
|
+
close_file(file_handle);
|
|
56
|
+
|
|
57
|
+
free(file_handle->filename);
|
|
58
|
+
free(file_handle);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
int get_filename(file_handle_t *file_handle, char **filename)
|
|
63
|
+
//
|
|
64
|
+
// BE AWARE: The memory allocated here must be freed by the caller
|
|
65
|
+
//
|
|
66
|
+
{
|
|
67
|
+
return cstr_duplicate(filename, file_handle->filename);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
int open_file(file_handle_t *file_handle, const char *filename, const char *file_mode) {
|
|
72
|
+
int error = 0;
|
|
73
|
+
|
|
74
|
+
if (filename == NULL)
|
|
75
|
+
_get_temp_filename(&(file_handle->filename));
|
|
76
|
+
else
|
|
77
|
+
cstr_duplicate(&(file_handle->filename), filename);
|
|
78
|
+
|
|
79
|
+
if (file_mode == NULL)
|
|
80
|
+
error = -1;
|
|
81
|
+
else {
|
|
82
|
+
error = _fopen(&(file_handle->file), file_handle->filename, file_mode);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return error;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
int seek_file(file_handle_t *file_handle, F_OFF offset, int whence)
|
|
89
|
+
{
|
|
90
|
+
#ifdef _MSC_VER // Windows (32-bit and 64-bit)
|
|
91
|
+
#define FSEEK64 _fseeki64
|
|
92
|
+
#else // Other platforms
|
|
93
|
+
#define FSEEK64 fseeko
|
|
94
|
+
#endif
|
|
95
|
+
|
|
96
|
+
return FSEEK64(file_handle->file, offset, whence);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
F_OFF tell_file(file_handle_t *file_handle)
|
|
100
|
+
{
|
|
101
|
+
#ifdef _MSC_VER // Windows (32-bit and 64-bit)
|
|
102
|
+
#define FTELL64 _ftelli64
|
|
103
|
+
#else // Other platforms
|
|
104
|
+
#define FTELL64 ftello
|
|
105
|
+
#endif
|
|
106
|
+
|
|
107
|
+
return FTELL64(file_handle->file);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Read and write to a binary file
|
|
111
|
+
size_t read_file(void *ptr, size_t size, size_t nmemb, file_handle_t *file_handle)
|
|
112
|
+
{
|
|
113
|
+
return fread(ptr, size, nmemb, file_handle->file);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
size_t write_file(const void * ptr, size_t size, size_t count, file_handle_t *file_handle)
|
|
117
|
+
{
|
|
118
|
+
return fwrite(ptr, size, count, file_handle->file);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
// print and get from a text file
|
|
123
|
+
int printf_file(file_handle_t *file_handle, const char *format, ... )
|
|
124
|
+
{
|
|
125
|
+
int error = 0;
|
|
126
|
+
va_list args;
|
|
127
|
+
|
|
128
|
+
va_start(args, format);
|
|
129
|
+
error = vfprintf(file_handle->file, format, args);
|
|
130
|
+
va_end(args);
|
|
131
|
+
|
|
132
|
+
return error;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
int gets_file(char *str, int num, file_handle_t *file_handle)
|
|
136
|
+
{
|
|
137
|
+
fgets(str, num, file_handle->file);
|
|
138
|
+
return 0;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
int close_file(file_handle_t *file_handle) {
|
|
143
|
+
int error = 0;
|
|
144
|
+
|
|
145
|
+
if (file_handle->file != NULL) {
|
|
146
|
+
error = fclose(file_handle->file);
|
|
147
|
+
file_handle->file = NULL;
|
|
148
|
+
}
|
|
149
|
+
return error;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
int remove_file(file_handle_t *file_handle) {
|
|
153
|
+
return remove(file_handle->filename);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
bool is_valid(file_handle_t *file_handle)
|
|
158
|
+
{
|
|
159
|
+
if ((file_handle->filename == NULL && file_handle->file == NULL) ||
|
|
160
|
+
(cstr_isnullterm(file_handle->filename) && file_handle != NULL))
|
|
161
|
+
return true;
|
|
162
|
+
else
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
int _fopen(FILE **f, const char *name, const char *mode)
|
|
168
|
+
//
|
|
169
|
+
// Purpose: Substitute for fopen_s on platforms where it doesn't exist
|
|
170
|
+
// Note: fopen_s is part of C++11 standard
|
|
171
|
+
//
|
|
172
|
+
{
|
|
173
|
+
int ret = 0;
|
|
174
|
+
|
|
175
|
+
#ifdef _MSC_VER
|
|
176
|
+
ret = (int)fopen_s(f, name, mode);
|
|
177
|
+
#else
|
|
178
|
+
*f = fopen(name, mode);
|
|
179
|
+
if (!*f)
|
|
180
|
+
ret = -1;
|
|
181
|
+
#endif
|
|
182
|
+
return ret;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
int _get_temp_filename(char **tempname)
|
|
186
|
+
{
|
|
187
|
+
int error = 0;
|
|
188
|
+
|
|
189
|
+
#ifdef _MSC_VER
|
|
190
|
+
char *name = NULL;
|
|
191
|
+
|
|
192
|
+
// --- use Windows _tempnam function to get a pointer to an
|
|
193
|
+
// unused file name that begins with "en"
|
|
194
|
+
if ((name = _tempnam(name, "en")) == NULL) {
|
|
195
|
+
error = -1;
|
|
196
|
+
return error;
|
|
197
|
+
}
|
|
198
|
+
else
|
|
199
|
+
cstr_duplicate(tempname, name);
|
|
200
|
+
|
|
201
|
+
// --- free the pointer returned by _tempnam
|
|
202
|
+
if (name)
|
|
203
|
+
free(name);
|
|
204
|
+
|
|
205
|
+
// --- for non-Windows systems:
|
|
206
|
+
#else
|
|
207
|
+
// --- use system function mkstemp() to create a temporary file name
|
|
208
|
+
cstr_duplicate(tempname, "enXXXXXX");
|
|
209
|
+
error = mkstemp(*tempname);
|
|
210
|
+
#endif
|
|
211
|
+
return error;
|
|
212
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/*
|
|
2
|
+
******************************************************************************
|
|
3
|
+
Project: OWA EPANET
|
|
4
|
+
Version: 2.3
|
|
5
|
+
Module: util/filemanager.h
|
|
6
|
+
Description: Provides a simple interface for managing files
|
|
7
|
+
Authors: see AUTHORS
|
|
8
|
+
Copyright: see AUTHORS
|
|
9
|
+
License: see LICENSE
|
|
10
|
+
Last Updated: 04/01/2019
|
|
11
|
+
******************************************************************************
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
#ifndef FILEMANAGER_H_
|
|
15
|
+
#define FILEMANAGER_H_
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
#include <stdio.h>
|
|
19
|
+
#include <stdarg.h>
|
|
20
|
+
|
|
21
|
+
#include "cstr_helper.h"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
// F_OFF Must be a 8 byte / 64 bit integer for large file support
|
|
25
|
+
#ifdef _MSC_VER // Windows (32-bit and 64-bit)
|
|
26
|
+
#define F_OFF __int64
|
|
27
|
+
#else // Other platforms
|
|
28
|
+
#define F_OFF off_t
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
#define FILE_MAXNAME 259
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
#if defined(__cplusplus)
|
|
35
|
+
extern "C" {
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
// Forward declariation of file_handle_t
|
|
39
|
+
typedef struct file_s file_handle_t;
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
file_handle_t *create_file_manager();
|
|
43
|
+
|
|
44
|
+
void delete_file_manager(file_handle_t *file_handle);
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
int get_filename(file_handle_t *file_handle, char **filename);
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
int open_file(file_handle_t *file_handle, const char *filename, const char *file_mode);
|
|
51
|
+
|
|
52
|
+
int seek_file(file_handle_t *file_handle, F_OFF offset, int whence);
|
|
53
|
+
|
|
54
|
+
F_OFF tell_file(file_handle_t *file_handle);
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
// Functions for working with binary files
|
|
58
|
+
size_t read_file(void *ptr, size_t size, size_t nmemb, file_handle_t *file_handle);
|
|
59
|
+
|
|
60
|
+
size_t write_file(const void *ptr, size_t size, size_t count, file_handle_t *file_handle);
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
// Functions for working with text files
|
|
64
|
+
int printf_file(file_handle_t *file_handle, const char *format, ... );
|
|
65
|
+
|
|
66
|
+
int gets_file(char *str, int num, file_handle_t *file_handle);
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
int close_file(file_handle_t *file_handle);
|
|
70
|
+
|
|
71
|
+
int remove_file(file_handle_t *file_handle);
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
bool is_valid(file_handle_t *file_handle);
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
#if defined(__cplusplus)
|
|
78
|
+
}
|
|
79
|
+
#endif
|
|
80
|
+
|
|
81
|
+
#endif /* FILEMANAGER_H_ */
|