Rev 164 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 164 | Rev 165 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include "MPOD.h" |
1 | #include "MPOD.h" |
2 | #include <utility.h> |
2 | #include <utility.h> |
3 | #include "HVtest_ui.h" |
3 | #include "HVtest_ui.h" |
4 | 4 | ||
5 | #define HVSLOT 3 |
5 | #define HVSLOT 3 |
6 | #define NTICSMAX |
6 | #define NTICSMAX 240 |
7 | 7 | ||
8 | static int p1h, pID, rID; //, tfID; |
8 | static int p1h, pID, rID; //, tfID; |
9 | 9 | ||
10 | int CVICALLBACK refreshTimer (int panel, int control, int event, void *callbackData, |
10 | int CVICALLBACK refreshTimer (int panel, int control, int event, void *callbackData, |
11 | int eventData1, int eventData2) { |
11 | int eventData1, int eventData2) { |
Line 33... | Line 33... | ||
33 | char cMainSwitch[2][30]= {"Turn system OFF?","Turn system ON?"}; |
33 | char cMainSwitch[2][30]= {"Turn system OFF?","Turn system ON?"}; |
34 | char HVBid[4][4]; |
34 | char HVBid[4][4]; |
35 | int HVBid_rID[4]={P1_HVBid_1,P1_HVBid_2,P1_HVBid_3,P1_HVBid_4}; |
35 | int HVBid_rID[4]={P1_HVBid_1,P1_HVBid_2,P1_HVBid_3,P1_HVBid_4}; |
36 | char HVBfname[4][200]; |
36 | char HVBfname[4][200]; |
37 | FILE *HVBfp[4]={NULL,NULL,NULL,NULL}; |
37 | FILE *HVBfp[4]={NULL,NULL,NULL,NULL}; |
- | 38 | FILE *LIDfp=NULL; |
|
38 | 39 | ||
39 | HSNMP crate1; |
40 | HSNMP crate1; |
40 | 41 | ||
41 | if (InitCVIRTE (hInstance, 0, 0) == 0) |
42 | if (InitCVIRTE (hInstance, 0, 0) == 0) |
42 | return -1; /* out of memory */ |
43 | return -1; /* out of memory */ |
43 | 44 | ||
Line 54... | Line 55... | ||
54 | // printf("Fan nominal speed = %i\n", iret); |
55 | // printf("Fan nominal speed = %i\n", iret); |
55 | 56 | ||
56 | if ((p1h = LoadPanel (0, "HVtest_ui.uir", P1)) < 0) return -1; |
57 | if ((p1h = LoadPanel (0, "HVtest_ui.uir", P1)) < 0) return -1; |
57 | DisplayPanel (p1h); |
58 | DisplayPanel (p1h); |
58 | SetCtrlVal (p1h, P1_TESTon, 0); |
59 | SetCtrlVal (p1h, P1_TESTon, 0); |
- | 60 | LIDfp=fopen("lastids.txt","r"); |
|
- | 61 | for (i=0;i<4;i++) { |
|
- | 62 | fscanf(LIDfp,"%s",HVBid[i]); |
|
- | 63 | SetCtrlVal(p1h,HVBid_rID[i],HVBid[i]); |
|
59 | 64 | } |
|
- | 65 | fclose(LIDfp); |
|
- | 66 | LIDfp=NULL; |
|
60 | 67 | ||
61 | //Initial state |
68 | //Initial state |
62 | mainonoff=getMainSwitch(crate1); |
69 | mainonoff=getMainSwitch(crate1); |
63 | SetCtrlVal (p1h, P1_MSW, mainonoff); |
70 | SetCtrlVal (p1h, P1_MSW, mainonoff); |
64 | SetCtrlVal (p1h, P1_MSWLED, mainonoff); |
71 | SetCtrlVal (p1h, P1_MSWLED, mainonoff); |
Line 112... | Line 119... | ||
112 | for (i=0;i<4;i++) |
119 | for (i=0;i<4;i++) |
113 | fprintf(HVBfp[i],"%5d %10.1f %10.4f\n",ntics,HVvdis[i],HVcdis[i]); |
120 | fprintf(HVBfp[i],"%5d %10.1f %10.4f\n",ntics,HVvdis[i],HVcdis[i]); |
114 | switch (ntics) { |
121 | switch (ntics) { |
115 | case 5: |
122 | case 5: |
116 | SetCtrlVal(p1h,P1_HVonoffall, 1); |
123 | SetCtrlVal(p1h,P1_HVonoffall, 1); |
117 | QueueUserEvent (1001, p1h, P1_HVonoffall); |
124 | QueueUserEvent (1001, p1h, P1_HVonoffall); |
118 | break; |
125 | break; |
119 | case NTICSMAX-25: |
126 | case NTICSMAX-25: |
120 | SetCtrlVal(p1h,P1_HVonoffall, 0); |
127 | SetCtrlVal(p1h,P1_HVonoffall, 0); |
121 | QueueUserEvent (1001, p1h, P1_HVonoffall); |
128 | QueueUserEvent (1001, p1h, P1_HVonoffall); |
122 | break; |
129 | break; |
123 | case NTICSMAX: |
130 | case NTICSMAX: |
Line 150... | Line 157... | ||
150 | HVcset[0]=1e+6*getOutputCurrent(crate1,ch0); |
157 | HVcset[0]=1e+6*getOutputCurrent(crate1,ch0); |
151 | SetCtrlVal (p1h, P1_HVcset, HVcset[0]); |
158 | SetCtrlVal (p1h, P1_HVcset, HVcset[0]); |
152 | SetAxisScalingMode (p1h, P1_G1, VAL_LEFT_YAXIS, VAL_MANUAL, -(HVcset[0]+1), 1.); |
159 | SetAxisScalingMode (p1h, P1_G1, VAL_LEFT_YAXIS, VAL_MANUAL, -(HVcset[0]+1), 1.); |
153 | HVvrise=getModuleRampSpeedVoltage(crate1,mo); |
160 | HVvrise=getModuleRampSpeedVoltage(crate1,mo); |
154 | SetCtrlVal (p1h, P1_HVvrise, HVvrise); |
161 | SetCtrlVal (p1h, P1_HVvrise, HVvrise); |
- | 162 | } |
|
- | 163 | break; |
|
- | 164 | case P1_HVBidinc: |
|
- | 165 | if (!TESTon) { |
|
- | 166 | for (i=0;i<4;i++) { |
|
- | 167 | GetCtrlVal(p1h, HVBid_rID[i], HVBid[i]); |
|
- | 168 | sscanf(HVBid[i],"%d",&iret); |
|
- | 169 | iret+=4; |
|
- | 170 | sprintf(HVBid[i],"%3.3d",iret); |
|
- | 171 | SetCtrlVal(p1h, HVBid_rID[i], HVBid[i]); |
|
- | 172 | } |
|
155 | } |
173 | } |
156 | break; |
174 | break; |
157 | } |
175 | } |
158 | if (!mainonoff) continue; |
176 | if (!mainonoff) continue; |
159 | switch (rID) { |
177 | switch (rID) { |
Line 174... | Line 192... | ||
174 | GetCtrlVal (p1h, P1_HVcset, &HVcset[0]); |
192 | GetCtrlVal (p1h, P1_HVcset, &HVcset[0]); |
175 | SetAxisScalingMode (p1h, P1_G1, VAL_LEFT_YAXIS, VAL_MANUAL, -(HVcset[0]+1), 1.); |
193 | SetAxisScalingMode (p1h, P1_G1, VAL_LEFT_YAXIS, VAL_MANUAL, -(HVcset[0]+1), 1.); |
176 | HVcset[0]/=1e+6; //[uA] |
194 | HVcset[0]/=1e+6; //[uA] |
177 | for (i=0;i<4;i++) |
195 | for (i=0;i<4;i++) |
178 | setOutputCurrent(crate1, ch0+i, HVcset[0]); |
196 | setOutputCurrent(crate1, ch0+i, HVcset[0]); |
179 | break; |
197 | break; |
180 | case P1_HVvrise: |
198 | case P1_HVvrise: |
181 | GetCtrlVal (p1h, P1_HVvrise, &HVvrise); |
199 | GetCtrlVal (p1h, P1_HVvrise, &HVvrise); |
182 | setModuleRampSpeedVoltage(crate1, mo, HVvrise); |
200 | setModuleRampSpeedVoltage(crate1, mo, HVvrise); |
183 | HVvrise=getModuleRampSpeedVoltage(crate1,mo); |
201 | HVvrise=getModuleRampSpeedVoltage(crate1,mo); |
184 | SetCtrlVal (p1h, P1_HVvrise, HVvrise); |
202 | SetCtrlVal (p1h, P1_HVvrise, HVvrise); |
Line 186... | Line 204... | ||
186 | case P1_TESTon: |
204 | case P1_TESTon: |
187 | GetCtrlVal (p1h, P1_TESTon, &TESTon); |
205 | GetCtrlVal (p1h, P1_TESTon, &TESTon); |
188 | if (TESTon) { |
206 | if (TESTon) { |
189 | ntics=0; |
207 | ntics=0; |
190 | ClearStripChart (p1h, P1_G1); |
208 | ClearStripChart (p1h, P1_G1); |
- | 209 | LIDfp=fopen("lastids.txt","w"); |
|
191 | for (i=0;i<4;i++) { |
210 | for (i=0;i<4;i++) { |
192 | GetCtrlVal(p1h, HVBid_rID[i], HVBid[i]); |
211 | GetCtrlVal(p1h, HVBid_rID[i], HVBid[i]); |
193 | sprintf(HVBfname[i],"HVB_%s.dat",HVBid[i]); |
212 | sprintf(HVBfname[i],"data/HVB_%s.dat",HVBid[i]); |
- | 213 | fprintf(LIDfp,"%s\n",HVBid[i]); |
|
194 | HVBfp[i]=fopen(HVBfname[i],"w"); |
214 | HVBfp[i]=fopen(HVBfname[i],"w"); |
195 | } |
215 | } |
- | 216 | fclose(LIDfp); |
|
- | 217 | LIDfp=NULL; |
|
196 | } else { |
218 | } else { |
197 | SetCtrlVal(p1h,P1_HVonoffall, 0); |
219 | SetCtrlVal(p1h,P1_HVonoffall, 0); |
198 | QueueUserEvent (1001, p1h, P1_HVonoffall); |
220 | QueueUserEvent (1001, p1h, P1_HVonoffall); |
199 | for (i=0;i<4;i++) |
221 | for (i=0;i<4;i++) { |
200 | fclose(HVBfp[i]); |
222 | fclose(HVBfp[i]); |
- | 223 | HVBfp[i]=NULL; |
|
- | 224 | } |
|
201 | } |
225 | } |
202 | break; |
226 | break; |
203 | // case P1_VFA0: |
227 | // case P1_VFA0: |
204 | // GetCtrlVal (p1h, P1_VFA0, &ret); |
228 | // GetCtrlVal (p1h, P1_VFA0, &ret); |
205 | // setOutputFallRate(crate1, ch, ret); |
229 | // setOutputFallRate(crate1, ch, ret); |