Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gauthier Quesnel
irritator
Commits
99efa2eb
Commit
99efa2eb
authored
Apr 27, 2020
by
Gauthier Quesnel
Browse files
gui: replace status code with message
parent
763a9ab3
Pipeline
#11637
passed with stage
in 1 minute and 8 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/gui/gui.hpp
View file @
99efa2eb
...
...
@@ -12,6 +12,14 @@
namespace
irt
{
enum
class
simulation_status
{
success
,
running
,
uninitialized
,
internal_error
,
};
void
node_editor_initialize
();
...
...
@@ -45,6 +53,68 @@ load_file_dialog(std::filesystem::path& out);
bool
save_file_dialog
(
std
::
filesystem
::
path
&
out
);
static
inline
const
char
*
simulation_status_string
[]
=
{
"success"
,
"running"
,
"uninitialized"
,
"internal_error"
,
};
static
inline
const
char
*
status_string
[]
=
{
"success"
,
"unknown_dynamics"
,
"block_allocator_bad_capacity"
,
"block_allocator_not_enough_memory"
,
"head_allocator_bad_capacity"
,
"head_allocator_not_enough_memory"
,
"simulation_not_enough_model"
,
"simulation_not_enough_memory_message_list_allocator"
,
"simulation_not_enough_memory_input_port_list_allocator"
,
"simulation_not_enough_memory_output_port_list_allocator"
,
"data_array_init_capacity_error"
,
"data_array_not_enough_memory"
,
"data_array_archive_init_capacity_error"
,
"data_array_archive_not_enough_memory"
,
"array_init_capacity_zero"
,
"array_init_capacity_too_big"
,
"array_init_not_enough_memory"
,
"vector_init_capacity_zero"
,
"vector_init_capacity_too_big"
,
"vector_init_not_enough_memory"
,
"dynamics_unknown_id"
,
"dynamics_unknown_port_id"
,
"dynamics_not_enough_memory"
,
"model_connect_output_port_unknown"
,
"model_connect_input_port_unknown"
,
"model_connect_already_exist"
,
"model_adder_empty_init_message"
,
"model_adder_bad_init_message"
,
"model_adder_bad_external_message"
,
"model_mult_empty_init_message"
,
"model_mult_bad_init_message"
,
"model_mult_bad_external_message"
,
"model_integrator_internal_error"
,
"model_integrator_output_error"
,
"model_integrator_running_without_x_dot"
,
"model_integrator_ta_with_bad_x_dot"
,
"model_integrator_bad_external_message"
,
"model_quantifier_bad_quantum_parameter"
,
"model_quantifier_bad_archive_length_parameter"
,
"model_quantifier_shifting_value_neg"
,
"model_quantifier_shifting_value_less_1"
,
"model_quantifier_bad_external_message"
,
"model_cross_bad_external_message"
,
"model_time_func_bad_init_message"
,
"gui_not_enough_memory"
,
"io_file_format_error"
,
"io_file_format_model_error"
,
"io_file_format_model_number_error"
,
"io_file_format_model_unknown"
,
"io_file_format_dynamics_unknown"
,
"io_file_format_dynamics_limit_reach"
,
"io_file_format_dynamics_init_error"
};
}
// namespace irt
#endif
app/gui/node-editor.cpp
View file @
99efa2eb
...
...
@@ -20,14 +20,6 @@ namespace irt {
window_logger
log_w
;
enum
class
simulation_status
{
success
,
running
,
uninitialized
,
internal_error
,
};
struct
observation_output
{
enum
class
type
...
...
@@ -137,16 +129,19 @@ run_simulation(simulation& sim,
{
current
=
begin
;
if
(
auto
ret
=
sim
.
initialize
(
current
);
irt
::
is_bad
(
ret
))
{
log_w
.
log
(
3
,
"Simulation initialization failure (%d)
\n
"
,
static_cast
<
int
>
(
ret
));
log_w
.
log
(
3
,
"Simulation initialization failure (%s)
\n
"
,
irt
::
status_string
[
static_cast
<
int
>
(
ret
)]);
st
=
simulation_status
::
internal_error
;
return
;
}
do
{
if
(
auto
ret
=
sim
.
run
(
current
);
irt
::
is_bad
(
ret
))
{
log_w
.
log
(
3
,
"Simulation run failure (%d)
\n
"
,
static_cast
<
int
>
(
ret
));
log_w
.
log
(
3
,
"Simulation failure (%s)
\n
"
,
irt
::
status_string
[
static_cast
<
int
>
(
ret
)]);
st
=
simulation_status
::
internal_error
;
return
;
}
...
...
@@ -837,14 +832,19 @@ struct editor
if
(
ImGui
::
BeginMenu
(
"Examples"
))
{
if
(
ImGui
::
MenuItem
(
"Insert Lotka Volterra model"
))
{
if
(
is_bad
(
initialize_lotka_volterra
()))
log_w
.
log
(
3
,
"Fail to initialize a Lotka Volterra
\n
"
);
if
(
auto
ret
=
initialize_lotka_volterra
();
is_bad
(
ret
))
log_w
.
log
(
3
,
"Fail to initialize a Lotka Volterra model (%s)
\n
"
,
status_string
[
static_cast
<
int
>
(
ret
)]);
}
if
(
ImGui
::
MenuItem
(
"Insert Izhikevitch model"
))
{
if
(
is_bad
(
initialize_izhikevitch
()))
log_w
.
log
(
3
,
"Fail to initialize an Izhikevitch model
\n
"
);
if
(
auto
ret
=
initialize_izhikevitch
();
is_bad
(
ret
))
log_w
.
log
(
3
,
"Fail to initialize an Izhikevitch model (%s)
\n
"
,
status_string
[
static_cast
<
int
>
(
ret
)]);
}
ImGui
::
EndMenu
();
...
...
@@ -1184,8 +1184,9 @@ editors_new()
auto
&
ed
=
editors
.
alloc
();
if
(
auto
ret
=
ed
.
initialize
(
get_index
(
editors
.
get_id
(
ed
)));
is_bad
(
ret
))
{
log_w
.
log
(
2
,
"Fail to initialize irritator: %d
\n
"
,
static_cast
<
int
>
(
ret
));
log_w
.
log
(
2
,
"Fail to initialize irritator: %s
\n
"
,
status_string
[
static_cast
<
int
>
(
ret
)]);
editors
.
free
(
ed
);
return
nullptr
;
}
...
...
@@ -1340,8 +1341,9 @@ void
node_editor_initialize
()
{
if
(
auto
ret
=
editors
.
init
(
50u
);
is_bad
(
ret
))
{
log_w
.
log
(
2
,
"Fail to initialize irritator: %d
\n
"
,
static_cast
<
int
>
(
ret
));
log_w
.
log
(
2
,
"Fail to initialize irritator: %s
\n
"
,
irt
::
status_string
[
static_cast
<
int
>
(
ret
)]);
}
else
{
if
(
auto
*
ed
=
editors_new
();
ed
)
ed
->
context
=
imnodes
::
EditorContextCreate
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment