-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.h
114 lines (86 loc) · 3.05 KB
/
main.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
// #############################################################################
#include <stdlib.h>
#include <gtk/gtk.h>
#include <glib/gprintf.h>
#include <math.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_odeiv2.h>
// #############################################################################
#ifndef MAIN_H_INCLUDED
#define MAIN_H_INCLUDED
// #############################################################################
#define GROUP_NAME "Configuration"
#define DC_MOTOR_RC_RELPATH ("DC_motor" G_DIR_SEPARATOR_S "dc_motor_rc")
/* Ein Objekt, das allen Callbacks übergeben wird */
struct CallbackObjekt
{
GtkBuilder *builder;
GtkWidget *window;
GtkWidget *drawingarea;
GThread *pthread;
gboolean dc_motor_run;
struct DC_MOTOR_LOOP_DATA *loop_data;
struct DC_MOTOR_TIMEOUT_DATA *timeout_data;
};
struct DC_MOTOR_LOOP_DATA
{
GtkWidget *button;
struct CallbackObjekt *obj;
GFile *file;
GFileOutputStream *stream;
gsl_odeiv2_step *ode_step;
gsl_odeiv2_control *ode_control;
gsl_odeiv2_evolve *ode_evolve;
gsl_odeiv2_system ode_sys;
gsl_odeiv2_step_type *step_type;
double eps_abs; /**< Absolute error */
double eps_rel; /**< Relative error */
double a_y; /**< Scaling factor for the system state y(t) */
double a_dydt; /**< Scaling factor for the system state y'(t) */
double t; /**< Start time */
double t1; /**< End time */
double h; /**< Initial timestep */
double y[2]; /** Initial conditions of the system */
double i_max; /**< Variable to track peak current */
GString *out;
gchar *tmp_buf;
GString *buffer;
guint event_source_timeout;
gboolean done;
};
enum RHEOSTAT_MODE
{
RHEOSTAT_MODE_NONE = 0,
RHEOSTAT_MODE_SPEED,
RHEOSTAT_MODE_CURRENT
};
enum REGULATOR_STATE
{
REGULATOR_STATE_NONE = 0,
REGULATOR_STATE_SPEED,
REGULATOR_STATE_CURRENT_LIMIT
};
enum REGULATOR_MODE
{
REGULATOR_MODE_NONE = 0,
REGULATOR_MODE_SPEED
};
// #############################################################################
gboolean settings_init( struct CallbackObjekt *obj );
gboolean settings_update( struct CallbackObjekt *obj );
gboolean settings_load( );
gboolean settings_store( );
void show_action_infobar( struct CallbackObjekt *obj, gchar *format, ... ) G_GNUC_PRINTF (2, 3);
void messagebox( GtkBuilder *b, gchar *format, ... ) G_GNUC_PRINTF (2, 3);
gboolean dc_motor_init( struct CallbackObjekt *obj );
int dc_motor_model( double t, const double y[], double f[], void *params );
gboolean dc_motor_source_func( gpointer user_data );
gpointer dc_motor_loop( gpointer userdata );
gboolean dc_motor_stop( gpointer user_data );
void gtk_label_printf( struct CallbackObjekt *obj, const gchar *name, gchar *format, ... );
//gssize g_output_stream_printf( GFileOutputStream *stream, gchar *format, ... );
// #############################################################################
#endif // MAIN_H_INCLUDED
// #############################################################################