-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAOloopControl_loop_onoff.c
173 lines (109 loc) · 4.33 KB
/
AOloopControl_loop_onoff.c
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
/**
* @file AOloopControl_loop_onoff.c
* @brief AO loop Control functions wave front sensor and deformable mirror
*
* REAL TIME COMPUTING ROUTINES
*
* @bug No known bugs.
*
*/
#define _GNU_SOURCE
#include "AOloopControl.h"
#include "CommandLineInterface/CLIcore.h"
#include "00CORE/00CORE.h"
#include "COREMOD_memory/COREMOD_memory.h"
#include "AOloopControl_perfTest/AOloopControl_perfTest.h"
extern AOLOOPCONTROL_CONF *AOconf; // configuration - this can be an array
extern AOloopControl_var aoloopcontrol_var;
//aoloopcontrol_var.LOOPNUMBER = 0; // current loop index
/* =============================================================================================== */
/** @name AOloopControl - 3.1. LOOP CONTROL INTERFACE - MAIN CONTROL : LOOP ON/OFF START/STOP/STEP/RESET
* Set parameters */
/* =============================================================================================== */
int_fast8_t AOloopControl_loopon()
{
int rtlindex;
if(aoloopcontrol_var.AOloopcontrol_meminit==0)
AOloopControl_InitializeMemory(1);
AOconf[aoloopcontrol_var.LOOPNUMBER].aorun.cntmax = AOconf[aoloopcontrol_var.LOOPNUMBER].aorun.cnt-1;
AOconf[aoloopcontrol_var.LOOPNUMBER].aorun.on = 1;
// initialize RT logging frame indices
for (rtlindex=0; rtlindex<MAX_NUMBER_RTLOGSTREAM; rtlindex++ )
AOconf[aoloopcontrol_var.LOOPNUMBER].RTSLOGarray[rtlindex].frameindex = 0;
AOloopControl_perfTest_showparams(aoloopcontrol_var.LOOPNUMBER);
return 0;
}
int_fast8_t AOloopControl_loopoff()
{
int rtlindex;
if(aoloopcontrol_var.AOloopcontrol_meminit==0)
AOloopControl_InitializeMemory(1);
AOconf[aoloopcontrol_var.LOOPNUMBER].aorun.on = 0;
AOloopControl_perfTest_showparams(aoloopcontrol_var.LOOPNUMBER);
return 0;
}
int_fast8_t AOloopControl_loopWFScompon()
{
int rtlindex;
if(aoloopcontrol_var.AOloopcontrol_meminit==0)
AOloopControl_InitializeMemory(1);
AOconf[aoloopcontrol_var.LOOPNUMBER].aorun.cntmax = AOconf[aoloopcontrol_var.LOOPNUMBER].aorun.cnt-1;
AOconf[aoloopcontrol_var.LOOPNUMBER].AOcompute.ComputeWFSsol_FLAG = 1;
// initialize RT logging frame indices
for (rtlindex=0; rtlindex<MAX_NUMBER_RTLOGSTREAM; rtlindex++ )
AOconf[aoloopcontrol_var.LOOPNUMBER].RTSLOGarray[rtlindex].frameindex = 0;
AOloopControl_perfTest_showparams(aoloopcontrol_var.LOOPNUMBER);
return 0;
}
int_fast8_t AOloopControl_loopWFScompoff()
{
int rtlindex;
if(aoloopcontrol_var.AOloopcontrol_meminit==0)
AOloopControl_InitializeMemory(1);
AOconf[aoloopcontrol_var.LOOPNUMBER].AOcompute.ComputeWFSsol_FLAG = 0;
AOloopControl_perfTest_showparams(aoloopcontrol_var.LOOPNUMBER);
return 0;
}
int_fast8_t AOloopControl_loopkill()
{
if(aoloopcontrol_var.AOloopcontrol_meminit==0)
AOloopControl_InitializeMemory(1);
AOconf[aoloopcontrol_var.LOOPNUMBER].aorun.kill = 1;
return 0;
}
int_fast8_t AOloopControl_loopstep(long loop, long NBstep)
{
if(aoloopcontrol_var.AOloopcontrol_meminit==0)
AOloopControl_InitializeMemory(1);
AOconf[loop].aorun.cntmax = AOconf[loop].aorun.cnt + NBstep;
AOconf[aoloopcontrol_var.LOOPNUMBER].AOpmodecoeffs.RMSmodesCumul = 0.0;
AOconf[aoloopcontrol_var.LOOPNUMBER].AOpmodecoeffs.RMSmodesCumulcnt = 0;
AOconf[loop].aorun.on = 1;
while(AOconf[loop].aorun.on==1)
usleep(100); // THIS WAITING IS OK
return 0;
}
int_fast8_t AOloopControl_loopreset()
{
long k;
long mb;
if(aoloopcontrol_var.AOloopcontrol_meminit==0)
AOloopControl_InitializeMemory(1);
if(aoloopcontrol_var.aoconfID_cmd_modes==-1)
{
char name[200];
if(sprintf(name, "DMmode_cmd_%ld", aoloopcontrol_var.LOOPNUMBER) < 1)
printERROR(__FILE__, __func__, __LINE__, "sprintf wrote <1 char");
aoloopcontrol_var.aoconfID_cmd_modes = read_sharedmem_image(name);
}
AOconf[aoloopcontrol_var.LOOPNUMBER].aorun.on = 0;
for(k=0; k<AOconf[aoloopcontrol_var.LOOPNUMBER].AOpmodecoeffs.NBDMmodes; k++)
data.image[aoloopcontrol_var.aoconfID_cmd_modes].array.F[k] = 0.0;
for(mb=0; mb<AOconf[aoloopcontrol_var.LOOPNUMBER].AOpmodecoeffs.DMmodesNBblock; mb)
{
AOloopControl_setgainblock(mb, 0.0);
AOloopControl_setlimitblock(mb, 0.01);
AOloopControl_setmultfblock(mb, 0.95);
}
return 0;
}