1 | #pragma rtGlobals=3 // Use modern global access method and strict wave access. |
---|
2 | |
---|
3 | |
---|
4 | //////////////////////////////// |
---|
5 | // |
---|
6 | // SRK NOV 2014 |
---|
7 | // |
---|
8 | // A panel to make it easy to set up "runs" for simulation |
---|
9 | // |
---|
10 | // |
---|
11 | // |
---|
12 | // |
---|
13 | // |
---|
14 | // TO DO: |
---|
15 | // x- Move everything to a proper data folder so that everything is saved in its proper place |
---|
16 | // x- configurations, samples, and listBox waves. |
---|
17 | // |
---|
18 | // |
---|
19 | // use Sim_ as a prefix for the functions rather than MC_ |
---|
20 | // |
---|
21 | // root:Packages:NIST:RunSim |
---|
22 | // |
---|
23 | // |
---|
24 | // -- add buttons for: |
---|
25 | // x- Run the checked runs from the list (non-consecutive OK) |
---|
26 | // x- Save the run list + later restore |
---|
27 | // x- save the configurations to disk + restore |
---|
28 | // x- save the samples to disk + restore (but the model must be loaded too when these are restored) |
---|
29 | // |
---|
30 | /////////////////////////////// |
---|
31 | |
---|
32 | Proc ShowRunListPanel() |
---|
33 | DoWindow/F RunListPanel |
---|
34 | if(V_flag==0) |
---|
35 | Initialize_RLP() |
---|
36 | RunListPanel() |
---|
37 | endif |
---|
38 | End |
---|
39 | |
---|
40 | |
---|
41 | // |
---|
42 | // |
---|
43 | Function Initialize_RLP() |
---|
44 | |
---|
45 | Variable row,col |
---|
46 | row=50 |
---|
47 | col=8 |
---|
48 | |
---|
49 | NewDataFolder/O/S root:Packages:NIST:RunSim |
---|
50 | |
---|
51 | Variable/G gRunIndex = 100 |
---|
52 | |
---|
53 | Make/O/T/N=(row,col) textW |
---|
54 | Make/O/B/N=(row,col) selW=0 |
---|
55 | |
---|
56 | //set the column Labels |
---|
57 | Variable ii |
---|
58 | Make/O/T/N=(col) names |
---|
59 | names[0,4] = {"Run","Config","Sample","Sample Label","Count Time"} |
---|
60 | names[5,7] = {"Save Name","Abs ?","Noise ?"} |
---|
61 | for(ii=0;ii<col;ii+=1) |
---|
62 | SetDimLabel 1,ii,$names[ii],textW |
---|
63 | endfor |
---|
64 | |
---|
65 | //make all cells editable |
---|
66 | selW = (0x02) |
---|
67 | // make the first column a checkbox, not editable |
---|
68 | selW[][0] = (0x20) |
---|
69 | textW[][0] = num2Str(p) |
---|
70 | |
---|
71 | SetDataFolder root: |
---|
72 | |
---|
73 | return(0) |
---|
74 | end |
---|
75 | |
---|
76 | |
---|
77 | // |
---|
78 | // Always visible: |
---|
79 | // -- run list |
---|
80 | // -- "Run" button |
---|
81 | // |
---|
82 | // Tabs: |
---|
83 | // - setup samples (+ save) |
---|
84 | // - setup configurations (+save) |
---|
85 | // - setup run list (+ add + save + modify) |
---|
86 | // |
---|
87 | // |
---|
88 | Proc RunListPanel() : Panel |
---|
89 | PauseUpdate; Silent 1 // building window... |
---|
90 | NewPanel /W=(517,291,1210,852) /K=1 |
---|
91 | ModifyPanel cbRGB=(40941,58697,43183) |
---|
92 | DoWindow/C RunListPanel |
---|
93 | |
---|
94 | // |
---|
95 | TabControl RunListTab,pos={10,10},size={660,230},tabLabel(0)="Configurations",proc=RunListTabProc |
---|
96 | TabControl RunListTab,tabLabel(1)="Setup Samples",tabLabel(2)="Setup Runs"//,tabLabel(3)="2-D Ops",tabLabel(4)="Misc Ops" |
---|
97 | TabControl RunListTab,value=0 |
---|
98 | TabControl RunListTab labelBack=(65535,58981,27524) |
---|
99 | |
---|
100 | // always visible |
---|
101 | // clickEventModifiers=8 = ignore the shift key in the list box (I'm using that bit (3) of selWave to flag trans) |
---|
102 | ListBox RLCtrlA,pos={17,290},size={660,250},proc=MyListboxProc,frame=2,clickEventModifiers=8 |
---|
103 | ListBox RLCtrlA,listWave=root:Packages:NIST:RunSim:textW,selWave=root:Packages:NIST:RunSim:selW//,colorWave=root:Packages:NIST:RunSim:myColors |
---|
104 | ListBox RLCtrlA,row= 0,mode= 2,editStyle= 2,widths= {40,70,120,120,50,120,30,30} |
---|
105 | |
---|
106 | Button RLCtrlB,pos={20,255},size={140,20},proc=Sim_RunSelected1DButton,title="Run Selected 1D" |
---|
107 | Button RLCtrlC,pos={180,255},size={140,20},proc=Sim_RunSelected2DButton,title="Run Selected 2D" |
---|
108 | Button RLCtrlD,pos={340,255},size={140,20},proc=Sim_RunSelectedDryButton,title="Dry Run 2D" |
---|
109 | |
---|
110 | SetVariable RLCtrlE,pos={500,255},size={100,20},title="Run Index" |
---|
111 | SetVariable RLCtrlE,limits={0,900,1},value= root:Packages:NIST:RunSim:gRunIndex |
---|
112 | |
---|
113 | Button RLCtrlF,pos={650,6},size={20,20},proc=Sim_RLHelpButtonProc,title="?" |
---|
114 | |
---|
115 | |
---|
116 | // tab 0 |
---|
117 | // for saving configurations |
---|
118 | Button RLCtrl_0a,pos={25,60},size={100,20},proc=Sim_StoreConfigButton,title="Store Config" |
---|
119 | PopupMenu RLCtrl_0b,pos={25,100},size={107,20},proc=Sim_RecallConfigPopMenu,title="Recall Config" |
---|
120 | PopupMenu RLCtrl_0b,mode=1,value= ListSASCALCConfigs() |
---|
121 | Button RLCtrl_0c,pos={270,60},size={120,20},proc=Sim_SaveConfigButton,title="Save Configs" |
---|
122 | Button RLCtrl_0d,pos={270,90},size={120,20},proc=Sim_RestoreConfigButton,title="Restore Configs" |
---|
123 | Button RLCtrl_0e,pos={270,120},size={120,20},proc=Sim_ClearConfigButton,title="Clear All Configs" |
---|
124 | |
---|
125 | // tab 1 |
---|
126 | // for saving sample conditions |
---|
127 | |
---|
128 | ///////////// don't relabel control 1j |
---|
129 | SetVariable RLCtrl_1j,pos={25,40},size={300,15},title="Sample Label" |
---|
130 | SetVariable RLCtrl_1j,limits={-inf,inf,0},value= _STR:"Enter Sample Label",disable=1 |
---|
131 | |
---|
132 | Button RLCtrl_1a,pos={25,180},size={100,20},proc=Sim_StoreSampleButton,title="Store Sample",disable=1 |
---|
133 | |
---|
134 | PopupMenu RLCtrl_1b,pos={25,210},size={111,20},proc=Sim_RecallSamplePopMenu,title="Recall Sample" |
---|
135 | PopupMenu RLCtrl_1b,mode=1,value= ListSimSamples(),disable=1 |
---|
136 | |
---|
137 | SetVariable RLCtrl_1c,pos={25,65},size={160,15},title="Thickness (cm)" |
---|
138 | SetVariable RLCtrl_1c,limits={0,inf,0.1},value= root:Packages:NIST:SAS:gThick |
---|
139 | SetVariable RLCtrl_1c, proc=Sim_1D_SamThickSetVarProc,disable=1 |
---|
140 | |
---|
141 | SetVariable RLCtrl_1d,pos={25,90},size={160,15},title="Sample Transmission" |
---|
142 | SetVariable RLCtrl_1d,limits={0,1,0.01},value= root:Packages:NIST:SAS:gSamTrans |
---|
143 | SetVariable RLCtrl_1d, proc=Sim_1D_SamTransSetVarProc,disable=1 |
---|
144 | |
---|
145 | SetVariable RLCtrl_1e,pos={25,115},size={160,15},title="Incoherent XS (1/cm)" |
---|
146 | SetVariable RLCtrl_1e,limits={0,10,0.001},value= root:Packages:NIST:SAS:gSig_incoh |
---|
147 | SetVariable RLCtrl_1e,disable=1 |
---|
148 | |
---|
149 | SetVariable RLCtrl_1f,pos={25,140},size={160,15},title="Sample Radius (cm)" |
---|
150 | SetVariable RLCtrl_1f,limits={0,10,0.001},value= root:Packages:NIST:SAS:gR2 |
---|
151 | SetVariable RLCtrl_1f,disable=1 |
---|
152 | |
---|
153 | Button RLCtrl_1g,pos={270,90},size={120,20},proc=Sim_SaveSampleButton,title="Save Samples",disable=1 |
---|
154 | Button RLCtrl_1h,pos={270,120},size={120,20},proc=Sim_RestoreSampleButton,title="Restore Samples",disable=1 |
---|
155 | Button RLCtrl_1i,pos={270,150},size={120,20},proc=Sim_ClearSampleButton,title="Clear All Samples",disable=1 |
---|
156 | |
---|
157 | |
---|
158 | // tab 2 |
---|
159 | // for setting up of the run list |
---|
160 | // RLCtrl_2 |
---|
161 | PopupMenu RLCtrl_2a,pos={26,40},size={161,20},title="Configuration" |
---|
162 | PopupMenu RLCtrl_2a,mode=2,popvalue="Config_",proc=Sim_RecallConfigPopMenu,value= #"ListSASCALCConfigs()",disable=1 |
---|
163 | |
---|
164 | PopupMenu RLCtrl_2b,pos={26,70},size={161,20},title="Sample" |
---|
165 | PopupMenu RLCtrl_2b,mode=2,popvalue="Sam_",proc=Sim_RecallSamplePopMenu,value= #"ListSimSamples()",disable=1 |
---|
166 | |
---|
167 | ///////// don't relabel control 2c |
---|
168 | SetVariable RLCtrl_2c,pos={26,100},size={300,15},title="Sample Label" |
---|
169 | SetVariable RLCtrl_2c,limits={-inf,inf,0},value= _STR:"Enter Sample Label",disable=1 |
---|
170 | |
---|
171 | CheckBox RLCtrl_2d,pos={26,130},size={60,14},title="Abs scale?",variable= root:Packages:NIST:SAS:g_1D_DoABS,disable=1 |
---|
172 | CheckBox RLCtrl_2d,proc=RL_ABSCheck |
---|
173 | CheckBox RLCtrl_2e,pos={26,160},size={60,14},title="Noise?",variable= root:Packages:NIST:SAS:g_1D_AddNoise,disable=1 |
---|
174 | CheckBox RLCtrl_2e,proc=RL_NoiseCheck |
---|
175 | |
---|
176 | |
---|
177 | SetVariable RLCtrl_2f,pos={26,185},size={150,15},title="Count Time (s)",format="%d" |
---|
178 | SetVariable RLCtrl_2f,limits={1,36000,10},value= root:Packages:NIST:SAS:gCntTime,disable=1 |
---|
179 | |
---|
180 | SetVariable RLCtrl_2g,pos={26,210},size={300,15},title="Save Name" |
---|
181 | SetVariable RLCtrl_2g,limits={-inf,inf,0},value= _STR:"Enter File Name",disable=1 |
---|
182 | |
---|
183 | Button RLCtrl_2h,pos={350,140},size={120,20},proc=Sim_AddToRunListButton,title="Add to Run List",disable=1 |
---|
184 | Button RLCtrl_2i,pos={350,170},size={120,20},proc=Sim_AddTransToRunListButton,title="Add Trans Run",disable=1 |
---|
185 | Button RLCtrl_2j,pos={350,200},size={120,20},proc=Sim_AddEmptyToRunListButton,title="Add Empty Beam",disable=1 |
---|
186 | |
---|
187 | Button RLCtrl_2k,pos={500,140},size={120,20},proc=Sim_SaveRunListButton,title="Save Run List",disable=1 |
---|
188 | Button RLCtrl_2l,pos={500,170},size={120,20},proc=Sim_RestoreRunListButton,title="Restore Run List",disable=1 |
---|
189 | Button RLCtrl_2m,pos={500,200},size={120,20},proc=Sim_ClearRowRunListButton,title="Clear Run",disable=1 |
---|
190 | |
---|
191 | SetVariable RLCtrl_2n,pos={400,70},size={200,15},title="Currently Executing" |
---|
192 | SetVariable RLCtrl_2n,limits={-inf,inf,0},value= _STR:"Nothing",disable=1 |
---|
193 | EndMacro |
---|
194 | |
---|
195 | Function RL_ABSCheck(name,value) |
---|
196 | String name |
---|
197 | Variable value |
---|
198 | |
---|
199 | NVAR gRadioVal= root:Packages:NIST:SAS:g_1D_DoABS |
---|
200 | |
---|
201 | CheckBox RLCtrl_2d,value= gRadioVal==1 |
---|
202 | |
---|
203 | return 0 |
---|
204 | End |
---|
205 | |
---|
206 | Function RL_NoiseCheck(name,value) |
---|
207 | String name |
---|
208 | Variable value |
---|
209 | |
---|
210 | NVAR gRadioVal= root:Packages:NIST:SAS:g_1D_AddNoise |
---|
211 | |
---|
212 | CheckBox RLCtrl_2e,value= gRadioVal==1 |
---|
213 | |
---|
214 | return 0 |
---|
215 | End |
---|
216 | |
---|
217 | |
---|
218 | Proc Sim_RLHelpButtonProc(ctrlName) : ButtonControl |
---|
219 | String ctrlName |
---|
220 | DisplayHelpTopic/Z/K=1 "Simulating a Run List" |
---|
221 | if(V_flag !=0) |
---|
222 | DoAlert 0,"The Simulating a Run List Help file could not be found" |
---|
223 | endif |
---|
224 | End |
---|
225 | |
---|
226 | // |
---|
227 | // return the list of stored configurations - useful for popup |
---|
228 | // |
---|
229 | Function/S ListSASCALCConfigs() |
---|
230 | String str |
---|
231 | SetDataFolder root:Packages:NIST:SAS |
---|
232 | str = WaveList("Conf*",";","") |
---|
233 | SetDataFolder root: |
---|
234 | // print str |
---|
235 | return(str) |
---|
236 | End |
---|
237 | |
---|
238 | // |
---|
239 | // return the list of stored sample conditions - userful for popup |
---|
240 | // |
---|
241 | Function/S ListSimSamples() |
---|
242 | String str |
---|
243 | SetDataFolder root:Packages:NIST:RunSim |
---|
244 | str = WaveList("Sam*",";","") |
---|
245 | SetDataFolder root: |
---|
246 | // print str |
---|
247 | return(str) |
---|
248 | End |
---|
249 | |
---|
250 | |
---|
251 | // |
---|
252 | // stores a configuration to a wave |
---|
253 | // any string can be used, "Config_" prefix is added |
---|
254 | // |
---|
255 | Function Sim_StoreConfigButton(ba) : ButtonControl |
---|
256 | STRUCT WMButtonAction &ba |
---|
257 | |
---|
258 | switch( ba.eventCode ) |
---|
259 | case 2: // mouse up |
---|
260 | // click code here |
---|
261 | Execute "Sim_StoreConfProc()" |
---|
262 | break |
---|
263 | case -1: // control being killed |
---|
264 | break |
---|
265 | endswitch |
---|
266 | |
---|
267 | return 0 |
---|
268 | End |
---|
269 | |
---|
270 | // |
---|
271 | // moves to the specified configuration and recalculates the intensity |
---|
272 | // at the new configuration (done by the move function) |
---|
273 | // |
---|
274 | Function Sim_RecallConfigPopMenu(pa) : PopupMenuControl |
---|
275 | STRUCT WMPopupAction &pa |
---|
276 | |
---|
277 | switch( pa.eventCode ) |
---|
278 | case 2: // mouse up |
---|
279 | Variable popNum = pa.popNum |
---|
280 | String popStr = pa.popStr |
---|
281 | |
---|
282 | Sim_MoveToConfiguration($("root:Packages:NIST:SAS:"+popStr)) |
---|
283 | break |
---|
284 | case -1: // control being killed |
---|
285 | break |
---|
286 | endswitch |
---|
287 | |
---|
288 | return 0 |
---|
289 | End |
---|
290 | |
---|
291 | // |
---|
292 | // gather all of the information to "store" the state of a sample |
---|
293 | // so that it can be recalled later |
---|
294 | // |
---|
295 | // coefficents are from unsmeared models only, so they are in the root folder |
---|
296 | // |
---|
297 | // sample has information to do either a 1D or 2D simulation, fill it all in whether needed or not |
---|
298 | // |
---|
299 | // stores a copy of the coefficient wave + all of the other information as a wave note: |
---|
300 | // |
---|
301 | // FUNC:function name |
---|
302 | // COEF:coefficient wave name |
---|
303 | // THICK:thickness |
---|
304 | // TRANS:transmission |
---|
305 | // INCXS:incoherent cross section |
---|
306 | // SAMRAD:sample radius |
---|
307 | // LABEL:sample label string |
---|
308 | // |
---|
309 | // |
---|
310 | Function Sim_StoreSampleButton(ba) : ButtonControl |
---|
311 | STRUCT WMButtonAction &ba |
---|
312 | |
---|
313 | switch( ba.eventCode ) |
---|
314 | case 2: // mouse up |
---|
315 | // click code here |
---|
316 | NVAR thick = root:Packages:NIST:SAS:gThick |
---|
317 | NVAR trans = root:Packages:NIST:SAS:gSamTrans |
---|
318 | NVAR xs = root:Packages:NIST:SAS:gSig_incoh |
---|
319 | NVAR r2 = root:Packages:NIST:SAS:gR2 |
---|
320 | |
---|
321 | String funcStr="",cwStr="",noteStr="",lblStr="" |
---|
322 | // |
---|
323 | ControlInfo/W=WrapperPanel popup_1 |
---|
324 | funcStr=S_Value |
---|
325 | ControlInfo/W=WrapperPanel popup_2 |
---|
326 | cwStr=S_Value |
---|
327 | ControlInfo/W=RunListPanel RLCtrl_1j |
---|
328 | lblStr = S_Value |
---|
329 | |
---|
330 | sprintf noteStr,"FUNC:%s;COEF:%s;THICK:%g;TRANS:%g;INCXS:%g;SAMRAD:%g;LABEL:%s;",funcStr,cwStr,thick,trans,xs,r2,lblStr |
---|
331 | Wave cw = $("root:"+cwStr) |
---|
332 | |
---|
333 | Duplicate/O cw tmpCW |
---|
334 | Note tmpCW,noteStr |
---|
335 | |
---|
336 | Execute "Sim_StoreSampleProc()" |
---|
337 | |
---|
338 | KillWaves/Z root:tmpCW |
---|
339 | break |
---|
340 | case -1: // control being killed |
---|
341 | break |
---|
342 | endswitch |
---|
343 | |
---|
344 | return 0 |
---|
345 | End |
---|
346 | |
---|
347 | // |
---|
348 | // "store" the sample conditions to the root:Packages:NIST:RunSim folder |
---|
349 | // -- need to do things this way to present a dialog for a name |
---|
350 | // |
---|
351 | Proc Sim_StoreSampleProc(waveStr) |
---|
352 | String waveStr |
---|
353 | |
---|
354 | SetDataFolder root:Packages:NIST:RunSim |
---|
355 | waveStr = CleanupName("Sam_"+waveStr,0) |
---|
356 | Duplicate/O root:tmpCW $(waveStr) |
---|
357 | SetDataFolder root: |
---|
358 | |
---|
359 | End |
---|
360 | |
---|
361 | |
---|
362 | // |
---|
363 | // sample has information to do either a 1D or 2D simulation, fill it all in whether needed or not |
---|
364 | // |
---|
365 | // reset all of the sample information, and recalculate the intensity |
---|
366 | // |
---|
367 | Function Sim_RecallSamplePopMenu(pa) : PopupMenuControl |
---|
368 | STRUCT WMPopupAction &pa |
---|
369 | |
---|
370 | switch( pa.eventCode ) |
---|
371 | case 2: // mouse up |
---|
372 | Variable popNum = pa.popNum |
---|
373 | String popStr = pa.popStr |
---|
374 | |
---|
375 | String noteStr="",funcStr="",coefStr="",lblStr="" |
---|
376 | Variable val |
---|
377 | // read the wave note |
---|
378 | Wave samWave = $("root:Packages:NIST:RunSim:"+popStr) |
---|
379 | noteStr = note(samWave) |
---|
380 | |
---|
381 | // reset the function, coef |
---|
382 | funcStr = StringByKey("FUNC", noteStr, ":", ";") |
---|
383 | PopupMenu popup_1 win=WrapperPanel,popmatch=funcStr |
---|
384 | SVAR gStr = root:Packages:NIST:SAS:gFuncStr |
---|
385 | gStr = funcStr |
---|
386 | |
---|
387 | // coef wave |
---|
388 | coefStr = StringByKey("COEF", noteStr, ":", ";") |
---|
389 | Wave cw = $("root:"+coefStr) |
---|
390 | cw = samWave |
---|
391 | |
---|
392 | // now fake a mouse up on the function popup, and the table subwindow should repopulate |
---|
393 | // |
---|
394 | Struct WMPopupAction ps |
---|
395 | ps.eventCode = 2 //fake mouse up |
---|
396 | ps.popStr = funcStr |
---|
397 | Function_PopMenuProc(ps) |
---|
398 | |
---|
399 | // and set the variables |
---|
400 | NVAR thick = root:Packages:NIST:SAS:gThick |
---|
401 | NVAR trans = root:Packages:NIST:SAS:gSamTrans |
---|
402 | NVAR xs = root:Packages:NIST:SAS:gSig_incoh |
---|
403 | NVAR r2 = root:Packages:NIST:SAS:gR2 |
---|
404 | |
---|
405 | thick = NumberByKey("THICK", noteStr, ":", ";") |
---|
406 | trans = NumberByKey("TRANS", noteStr, ":", ";") |
---|
407 | xs = NumberByKey("INCXS", noteStr, ":", ";") |
---|
408 | r2 = NumberByKey("SAMRAD", noteStr, ":", ";") |
---|
409 | lblStr = StringByKey("LABEL",noteStr,":",";") |
---|
410 | |
---|
411 | SetVariable RLCtrl_2c,win=RunListPanel,value= _STR:lblStr |
---|
412 | SetVariable RLCtrl_1j,win=RunListPanel,value= _STR:lblStr |
---|
413 | |
---|
414 | // fake a "set" of the thickness to re-calculate, or simply re-calculate(since that's all that is done) |
---|
415 | ReCalculateInten(1) |
---|
416 | |
---|
417 | break |
---|
418 | case -1: // control being killed |
---|
419 | break |
---|
420 | endswitch |
---|
421 | |
---|
422 | return 0 |
---|
423 | End |
---|
424 | |
---|
425 | |
---|
426 | |
---|
427 | // function to control the drawing of controls in the TabControl on the RunList panel |
---|
428 | // Naming scheme for the controls MUST be strictly adhered to... else controls will |
---|
429 | // appear in odd places... |
---|
430 | // all controls are named RLCtrl_NA where N is the tab number and A is the letter denoting |
---|
431 | // the controls position on that particular tab. |
---|
432 | // in this way, they will always be drawn correctly.. |
---|
433 | // |
---|
434 | // -- see the preference panel -- duplicated from there |
---|
435 | // |
---|
436 | Function RunListTabProc(name,tab) |
---|
437 | String name |
---|
438 | Variable tab |
---|
439 | |
---|
440 | // Print "name,number",name,tab |
---|
441 | String ctrlList = ControlNameList("",";"),item="",nameStr="" |
---|
442 | Variable num = ItemsinList(ctrlList,";"),ii,onTab |
---|
443 | Variable numChar |
---|
444 | numChar = strlen("RLCtrl_") |
---|
445 | for(ii=0;ii<num;ii+=1) |
---|
446 | //items all start w/"RLCtrl_", 7 characters |
---|
447 | item=StringFromList(ii, ctrlList ,";") |
---|
448 | nameStr=item[0,numChar-1] |
---|
449 | if(cmpstr(nameStr,"RLCtrl_")==0) |
---|
450 | onTab = str2num(item[numChar]) //[numChar] is a number |
---|
451 | ControlInfo $item |
---|
452 | switch(abs(V_flag)) |
---|
453 | case 1: |
---|
454 | Button $item,disable=(tab!=onTab) |
---|
455 | break |
---|
456 | case 2: |
---|
457 | CheckBox $item,disable=(tab!=onTab) |
---|
458 | break |
---|
459 | case 5: |
---|
460 | SetVariable $item,disable=(tab!=onTab) |
---|
461 | break |
---|
462 | case 10: |
---|
463 | TitleBox $item,disable=(tab!=onTab) |
---|
464 | break |
---|
465 | case 4: |
---|
466 | ValDisplay $item,disable=(tab!=onTab) |
---|
467 | break |
---|
468 | case 9: |
---|
469 | GroupBox $item,disable=(tab!=onTab) |
---|
470 | break |
---|
471 | case 3: |
---|
472 | PopupMenu $item,disable=(tab!=onTab) |
---|
473 | break |
---|
474 | // add more items to the switch if different control types are used |
---|
475 | endswitch |
---|
476 | endif |
---|
477 | endfor |
---|
478 | return(0) |
---|
479 | End |
---|
480 | |
---|
481 | |
---|
482 | // |
---|
483 | // parses the panel to fill in the values on the run list, which is a big listBox control |
---|
484 | // |
---|
485 | // setting the selW bits to flag as trans or empty beam runs |
---|
486 | // ** this not an approved use of these bits, so I may run into trouble later... |
---|
487 | // |
---|
488 | // 2^2 = empty beam |
---|
489 | // 2^3 = sample trans |
---|
490 | // |
---|
491 | // before exiting, increment the selected row in the listBox |
---|
492 | // |
---|
493 | Function Sim_AddToRunListButton(ba) : ButtonControl |
---|
494 | STRUCT WMButtonAction &ba |
---|
495 | |
---|
496 | switch( ba.eventCode ) |
---|
497 | case 2: // mouse up |
---|
498 | // Lots of steps to make this happen |
---|
499 | |
---|
500 | // declarations |
---|
501 | SetDataFolder root:Packages:NIST:RunSim |
---|
502 | |
---|
503 | Wave/T textW = textW |
---|
504 | Wave selW = selW |
---|
505 | |
---|
506 | SetDataFolder root: |
---|
507 | |
---|
508 | // get the selected row (not based on checkboxes) |
---|
509 | Variable selRow |
---|
510 | |
---|
511 | ControlInfo/W=RunListPanel RLCtrlA |
---|
512 | // Print "sel = ",V_value |
---|
513 | selRow = V_value |
---|
514 | |
---|
515 | // fill in each of the 7 columns, and check the box (default is to run the sample) |
---|
516 | selW[selRow][0] = 2^5 + 2^4 //2^5 = checkbox, 2^4 true = checked |
---|
517 | |
---|
518 | // config |
---|
519 | ControlInfo/W=RunListPanel RLCtrl_2a |
---|
520 | textW[selRow][1] = S_Value |
---|
521 | |
---|
522 | // sample |
---|
523 | ControlInfo/W=RunListPanel RLCtrl_2b |
---|
524 | textW[selRow][2] = S_Value |
---|
525 | |
---|
526 | // sample Label |
---|
527 | ControlInfo/W=RunListPanel RLCtrl_2c |
---|
528 | textW[selRow][3] = S_Value |
---|
529 | |
---|
530 | // Count time |
---|
531 | NVAR ctTime = root:Packages:NIST:SAS:gCntTime |
---|
532 | textW[selRow][4] = num2str(ctTime) |
---|
533 | |
---|
534 | //save name |
---|
535 | ControlInfo/W=RunListPanel RLCtrl_2g |
---|
536 | textW[selRow][5] = S_Value |
---|
537 | |
---|
538 | // abs? |
---|
539 | NVAR doAbs = root:Packages:NIST:SAS:g_1D_DoABS |
---|
540 | textW[selRow][6] = num2str(doAbs) |
---|
541 | |
---|
542 | // noise? |
---|
543 | NVAR doNoise = root:Packages:NIST:SAS:g_1D_AddNoise |
---|
544 | textW[selRow][7] = num2str(doNoise) |
---|
545 | |
---|
546 | // move the selected row before exiting |
---|
547 | ListBox RLCtrlA,win=RunListPanel,selRow=(selRow+1) |
---|
548 | |
---|
549 | break |
---|
550 | case -1: // control being killed |
---|
551 | break |
---|
552 | endswitch |
---|
553 | |
---|
554 | |
---|
555 | return 0 |
---|
556 | End |
---|
557 | |
---|
558 | |
---|
559 | // |
---|
560 | // parses the panel to fill in the values on the run list, which is a big listBox control |
---|
561 | // |
---|
562 | // setting the selW bits to flag as trans or empty beam runs |
---|
563 | // 2^2 = empty beam |
---|
564 | // 2^3 = sample trans |
---|
565 | // |
---|
566 | // |
---|
567 | Function Sim_AddTransToRunListButton(ba) : ButtonControl |
---|
568 | STRUCT WMButtonAction &ba |
---|
569 | |
---|
570 | switch( ba.eventCode ) |
---|
571 | case 2: // mouse up |
---|
572 | |
---|
573 | // set the sample conditions as "normal" |
---|
574 | STRUCT WMButtonAction bb |
---|
575 | bb.eventCode = 2 |
---|
576 | Sim_AddToRunListButton(bb) |
---|
577 | |
---|
578 | // declarations |
---|
579 | SetDataFolder root:Packages:NIST:RunSim |
---|
580 | Wave selW = selW |
---|
581 | Wave/T textW = textW |
---|
582 | SetDataFolder root: |
---|
583 | |
---|
584 | // get the selected row (not based on checkboxes) |
---|
585 | Variable selRow |
---|
586 | |
---|
587 | ControlInfo/W=RunListPanel RLCtrlA |
---|
588 | selRow = V_value |
---|
589 | selRow -= 1 // since Sim_AddToRunListButton() increments the selection row by default |
---|
590 | |
---|
591 | // flag the row as a sample transmission measurement to deal with when running |
---|
592 | selW[selRow][0] += 2^3 // |
---|
593 | |
---|
594 | textW[selRow][4] = "1" //force the count time to 1 s |
---|
595 | |
---|
596 | break |
---|
597 | case -1: // control being killed |
---|
598 | break |
---|
599 | endswitch |
---|
600 | |
---|
601 | return 0 |
---|
602 | End |
---|
603 | |
---|
604 | |
---|
605 | // |
---|
606 | // parses the panel to fill in the values on the run list, which is a big listBox control |
---|
607 | // |
---|
608 | // setting the selW bits to flag as trans or empty beam runs |
---|
609 | // 2^2 = empty beam |
---|
610 | // 2^3 = sample trans |
---|
611 | // |
---|
612 | // |
---|
613 | Function Sim_AddEmptyToRunListButton(ba) : ButtonControl |
---|
614 | STRUCT WMButtonAction &ba |
---|
615 | |
---|
616 | switch( ba.eventCode ) |
---|
617 | case 2: // mouse up |
---|
618 | |
---|
619 | // set the sample conditions as "normal" |
---|
620 | STRUCT WMButtonAction bb |
---|
621 | bb.eventCode = 2 |
---|
622 | Sim_AddToRunListButton(bb) |
---|
623 | |
---|
624 | // declarations |
---|
625 | SetDataFolder root:Packages:NIST:RunSim |
---|
626 | Wave selW = selW |
---|
627 | Wave/T textW = textW |
---|
628 | SetDataFolder root: |
---|
629 | |
---|
630 | // get the selected row (not based on checkboxes) |
---|
631 | Variable selRow |
---|
632 | |
---|
633 | ControlInfo/W=RunListPanel RLCtrlA |
---|
634 | selRow = V_value |
---|
635 | selRow -= 1 // since Sim_AddToRunListButton() increments the selection row by default |
---|
636 | |
---|
637 | // flag the row as an empty beam measurement to deal with when running |
---|
638 | selW[selRow][0] += 2^2 // |
---|
639 | |
---|
640 | textW[selRow][4] = "1" //force the count time to 1 s |
---|
641 | |
---|
642 | break |
---|
643 | case -1: // control being killed |
---|
644 | break |
---|
645 | endswitch |
---|
646 | |
---|
647 | return 0 |
---|
648 | End |
---|
649 | |
---|
650 | // |
---|
651 | // clears the selected row in the list box |
---|
652 | // |
---|
653 | Function Sim_ClearRowRunListButton(ba) : ButtonControl |
---|
654 | STRUCT WMButtonAction &ba |
---|
655 | |
---|
656 | switch( ba.eventCode ) |
---|
657 | case 2: // mouse up |
---|
658 | // Lots of steps to make this happen |
---|
659 | |
---|
660 | // declarations |
---|
661 | SetDataFolder root:Packages:NIST:RunSim |
---|
662 | |
---|
663 | Wave/T textW = textW |
---|
664 | Wave selW = selW |
---|
665 | |
---|
666 | SetDataFolder root: |
---|
667 | // get the selected row (not based on checkboxes) |
---|
668 | Variable selRow |
---|
669 | |
---|
670 | ControlInfo/W=RunListPanel RLCtrlA |
---|
671 | selRow = V_value |
---|
672 | |
---|
673 | // fill in each of the 7 columns, and check the box (default is to run the sample) |
---|
674 | selW[selRow][0] = 2^5 //set back to an un-checked checkBox |
---|
675 | |
---|
676 | textW[selRow][1,] = "" // don't clear the run number |
---|
677 | |
---|
678 | break |
---|
679 | case -1: // control being killed |
---|
680 | break |
---|
681 | endswitch |
---|
682 | |
---|
683 | return 0 |
---|
684 | End |
---|
685 | |
---|
686 | |
---|
687 | // |
---|
688 | // saves the entire run list to disk as an Igor text file |
---|
689 | // |
---|
690 | Function Sim_SaveRunListButton(ba) : ButtonControl |
---|
691 | STRUCT WMButtonAction &ba |
---|
692 | |
---|
693 | switch( ba.eventCode ) |
---|
694 | case 2: // mouse up |
---|
695 | // click code here |
---|
696 | |
---|
697 | SetDataFolder root:Packages:NIST:RunSim |
---|
698 | |
---|
699 | Wave/T textW = textW |
---|
700 | Wave/T names = names |
---|
701 | Wave selW = selW |
---|
702 | // save as Igor text to preserve everything |
---|
703 | Save/I/T/P=home textW,selW,names as "RunList.itx" |
---|
704 | |
---|
705 | SetDataFolder root: |
---|
706 | |
---|
707 | break |
---|
708 | case -1: // control being killed |
---|
709 | break |
---|
710 | endswitch |
---|
711 | |
---|
712 | return 0 |
---|
713 | End |
---|
714 | |
---|
715 | // |
---|
716 | // read a saved run list from an Igor text file |
---|
717 | // -- this will wipe out whatever is currently on the list |
---|
718 | // |
---|
719 | Function Sim_RestoreRunListButton(ba) : ButtonControl |
---|
720 | STRUCT WMButtonAction &ba |
---|
721 | |
---|
722 | switch( ba.eventCode ) |
---|
723 | case 2: // mouse up |
---|
724 | // click code here |
---|
725 | |
---|
726 | SetDataFolder root:Packages:NIST:RunSim |
---|
727 | |
---|
728 | String fname |
---|
729 | |
---|
730 | fname = "RunList.itx" |
---|
731 | LoadWave/O/T fname |
---|
732 | |
---|
733 | SetDataFolder root: |
---|
734 | |
---|
735 | break |
---|
736 | case -1: // control being killed |
---|
737 | break |
---|
738 | endswitch |
---|
739 | |
---|
740 | return 0 |
---|
741 | End |
---|
742 | |
---|
743 | // |
---|
744 | // saves all of the currently stored samples to disk as an Igor text file |
---|
745 | // -- the Igor text format preserves the wave note |
---|
746 | // |
---|
747 | Function Sim_SaveSampleButton(ba) : ButtonControl |
---|
748 | STRUCT WMButtonAction &ba |
---|
749 | |
---|
750 | switch( ba.eventCode ) |
---|
751 | case 2: // mouse up |
---|
752 | // click code here |
---|
753 | |
---|
754 | SetDataFolder root:Packages:NIST:RunSim |
---|
755 | |
---|
756 | String strList = "" |
---|
757 | strList = WaveList("Sam*", ";", "" ) |
---|
758 | |
---|
759 | // save as Igor text to preserve everything |
---|
760 | Save/B/I/T/P=home strList as "Samples.itx" |
---|
761 | |
---|
762 | SetDataFolder root: |
---|
763 | |
---|
764 | break |
---|
765 | case -1: // control being killed |
---|
766 | break |
---|
767 | endswitch |
---|
768 | |
---|
769 | return 0 |
---|
770 | End |
---|
771 | |
---|
772 | // |
---|
773 | // reads a saved set of samples from a file. Will only wipe out samples that unfortunately have |
---|
774 | // the same name. otherwise, they will simply be added to the list of samples |
---|
775 | // |
---|
776 | // -- NOTE that the model functions must be present (loaded and plotted separately) for the samples |
---|
777 | // to actually be used. |
---|
778 | // |
---|
779 | // |
---|
780 | Function Sim_RestoreSampleButton(ba) : ButtonControl |
---|
781 | STRUCT WMButtonAction &ba |
---|
782 | |
---|
783 | switch( ba.eventCode ) |
---|
784 | case 2: // mouse up |
---|
785 | // click code here |
---|
786 | |
---|
787 | SetDataFolder root:Packages:NIST:RunSim |
---|
788 | |
---|
789 | String fname |
---|
790 | |
---|
791 | fname = "Samples.itx" |
---|
792 | LoadWave/O/T fname |
---|
793 | |
---|
794 | SetDataFolder root: |
---|
795 | |
---|
796 | break |
---|
797 | case -1: // control being killed |
---|
798 | break |
---|
799 | endswitch |
---|
800 | |
---|
801 | return 0 |
---|
802 | End |
---|
803 | |
---|
804 | |
---|
805 | // |
---|
806 | // save the currently stored configurations to an Igor text file |
---|
807 | // |
---|
808 | Function Sim_SaveConfigButton(ba) : ButtonControl |
---|
809 | STRUCT WMButtonAction &ba |
---|
810 | |
---|
811 | switch( ba.eventCode ) |
---|
812 | case 2: // mouse up |
---|
813 | // click code here |
---|
814 | |
---|
815 | SetDataFolder root:Packages:NIST:SAS |
---|
816 | |
---|
817 | String strList = "" |
---|
818 | strList = WaveList("Config*", ";", "" ) |
---|
819 | |
---|
820 | // save as Igor text to preserve everything |
---|
821 | Save/B/I/T/P=home strList as "Configurations.itx" |
---|
822 | |
---|
823 | SetDataFolder root: |
---|
824 | |
---|
825 | break |
---|
826 | case -1: // control being killed |
---|
827 | break |
---|
828 | endswitch |
---|
829 | |
---|
830 | return 0 |
---|
831 | End |
---|
832 | |
---|
833 | // |
---|
834 | // reads a saved set of configurations from a file. Will only wipe out configurations that unfortunately have |
---|
835 | // the same name. otherwise, they will simply be added to the list of configurations |
---|
836 | // |
---|
837 | Function Sim_RestoreConfigButton(ba) : ButtonControl |
---|
838 | STRUCT WMButtonAction &ba |
---|
839 | |
---|
840 | switch( ba.eventCode ) |
---|
841 | case 2: // mouse up |
---|
842 | // click code here |
---|
843 | |
---|
844 | SetDataFolder root:Packages:NIST:SAS |
---|
845 | |
---|
846 | String fname |
---|
847 | |
---|
848 | fname = "Configurations.itx" |
---|
849 | LoadWave/O/T fname |
---|
850 | |
---|
851 | SetDataFolder root: |
---|
852 | |
---|
853 | break |
---|
854 | case -1: // control being killed |
---|
855 | break |
---|
856 | endswitch |
---|
857 | |
---|
858 | return 0 |
---|
859 | End |
---|
860 | |
---|
861 | // |
---|
862 | // will delete ALL of the stored configurations |
---|
863 | // |
---|
864 | Function Sim_ClearConfigButton(ba) : ButtonControl |
---|
865 | STRUCT WMButtonAction &ba |
---|
866 | |
---|
867 | switch( ba.eventCode ) |
---|
868 | case 2: // mouse up |
---|
869 | // click code here |
---|
870 | |
---|
871 | DoAlert 1,"Do you really want to delete all of the stored configurations?" |
---|
872 | if(V_flag==2) //no, get out now |
---|
873 | return(0) |
---|
874 | endif |
---|
875 | |
---|
876 | SetDataFolder root:Packages:NIST:SAS |
---|
877 | |
---|
878 | Variable num,ii |
---|
879 | String strList = "",item="" |
---|
880 | strList = WaveList("Config*", ";", "" ) |
---|
881 | num = ItemsInList(strList) |
---|
882 | for(ii=0;ii<num;ii+=1) |
---|
883 | item = StringFromList(ii, strList) |
---|
884 | KillWaves/Z $item |
---|
885 | endfor |
---|
886 | |
---|
887 | SetDataFolder root: |
---|
888 | |
---|
889 | break |
---|
890 | case -1: // control being killed |
---|
891 | break |
---|
892 | endswitch |
---|
893 | |
---|
894 | return 0 |
---|
895 | End |
---|
896 | |
---|
897 | // |
---|
898 | // will delete ALL of the stored sample conditions |
---|
899 | // |
---|
900 | Function Sim_ClearSampleButton(ba) : ButtonControl |
---|
901 | STRUCT WMButtonAction &ba |
---|
902 | |
---|
903 | switch( ba.eventCode ) |
---|
904 | case 2: // mouse up |
---|
905 | // click code here |
---|
906 | |
---|
907 | DoAlert 1,"Do you really want to delete all of the stored sample conditions?" |
---|
908 | if(V_flag==2) //no, get out now |
---|
909 | return(0) |
---|
910 | endif |
---|
911 | SetDataFolder root:Packages:NIST:RunSim |
---|
912 | |
---|
913 | Variable num,ii |
---|
914 | String strList = "",item="" |
---|
915 | strList = WaveList("Sam*", ";", "" ) |
---|
916 | num = ItemsInList(strList) |
---|
917 | for(ii=0;ii<num;ii+=1) |
---|
918 | item = StringFromList(ii, strList) |
---|
919 | KillWaves/Z $item |
---|
920 | endfor |
---|
921 | |
---|
922 | SetDataFolder root: |
---|
923 | |
---|
924 | break |
---|
925 | case -1: // control being killed |
---|
926 | break |
---|
927 | endswitch |
---|
928 | |
---|
929 | return 0 |
---|
930 | End |
---|
931 | |
---|
932 | |
---|
933 | // |
---|
934 | // step through the listBox, and execute the 1D simulation for each checked row, saving the result |
---|
935 | // |
---|
936 | Function Sim_RunSelected1DButton(ba) : ButtonControl |
---|
937 | STRUCT WMButtonAction &ba |
---|
938 | |
---|
939 | switch( ba.eventCode ) |
---|
940 | case 2: // mouse up |
---|
941 | // Lots of steps to make this happen |
---|
942 | DoWindow Sim_1D_Panel |
---|
943 | if(V_flag == 0) |
---|
944 | Sim_SetSimulationType(0) //kill the simulation panel |
---|
945 | Sim_SetSimulationType(1) //open the 1D simulation panel |
---|
946 | endif |
---|
947 | |
---|
948 | // declarations |
---|
949 | SetDataFolder root:Packages:NIST:RunSim |
---|
950 | |
---|
951 | Wave/T textW = textW |
---|
952 | Wave selW = selW |
---|
953 | |
---|
954 | SetDataFolder root: |
---|
955 | |
---|
956 | String configStr="",sampleStr="",lblStr="",saveStr="",ctTimeStr="" |
---|
957 | Variable numRows,ii,selRow |
---|
958 | numRows = DimSize(textW,0) |
---|
959 | |
---|
960 | NVAR g_estimateOnly = root:Packages:NIST:SAS:g_estimateOnly // == 1 for just count rate, == 0 (default) to do the simulation and save |
---|
961 | g_estimateOnly = 0 // be sure this is zero, or it will only get CR, not actually run |
---|
962 | |
---|
963 | //loop through all of the rows |
---|
964 | for(ii=0;ii<numRows;ii+=1) |
---|
965 | if((selW[ii][0] & 2^4) != 0) //checkbox is checked |
---|
966 | |
---|
967 | Print "**************** Running simulation for row = ",ii |
---|
968 | |
---|
969 | // move to configuration (no, Sim_RunSample_1D() will take care of this) |
---|
970 | configStr = textW[ii][1] |
---|
971 | // Sim_MoveToConfiguration($("root:Packages:NIST:SAS:"+configStr)) |
---|
972 | |
---|
973 | // set the sample |
---|
974 | sampleStr = textW[ii][2] |
---|
975 | |
---|
976 | Struct WMPopupAction ps |
---|
977 | ps.eventCode = 2 //fake mouse up |
---|
978 | ps.popStr = sampleStr |
---|
979 | Function_PopMenuProc(ps) |
---|
980 | |
---|
981 | Sim_RecallSamplePopMenu(ps) |
---|
982 | |
---|
983 | // set the count time |
---|
984 | // NVAR ctTime = root:Packages:NIST:SAS:gCntTime |
---|
985 | // ctTime = str2num(textW[ii][4]) |
---|
986 | |
---|
987 | // set the abs, noise checkboxes |
---|
988 | NVAR doAbs = root:Packages:NIST:SAS:g_1D_DoABS |
---|
989 | doAbs = str2num(textW[ii][6]) |
---|
990 | |
---|
991 | NVAR doNoise = root:Packages:NIST:SAS:g_1D_AddNoise |
---|
992 | doNoise = str2num(textW[ii][7]) |
---|
993 | |
---|
994 | // finally, run the simulation, saving the result (use scripting I've already written) |
---|
995 | lblStr = textW[ii][3] |
---|
996 | ctTimeStr = textW[ii][4] |
---|
997 | saveStr = textW[ii][5] |
---|
998 | Sim_RunSample_1D(configStr,ctTimeStr,lblStr,saveStr) |
---|
999 | |
---|
1000 | endif |
---|
1001 | |
---|
1002 | endfor |
---|
1003 | |
---|
1004 | Print "****************** Run list has been completed ***********************" |
---|
1005 | |
---|
1006 | break |
---|
1007 | case -1: // control being killed |
---|
1008 | break |
---|
1009 | endswitch |
---|
1010 | |
---|
1011 | return 0 |
---|
1012 | End |
---|
1013 | |
---|
1014 | // |
---|
1015 | // sets the simulation to "estimate only" mode, and determines the projected total "run" time, reporting |
---|
1016 | // the result to the command window. Resets to normal simulation mode on exiting. |
---|
1017 | // |
---|
1018 | Function Sim_RunSelectedDryButton(ba) : ButtonControl |
---|
1019 | STRUCT WMButtonAction &ba |
---|
1020 | |
---|
1021 | switch( ba.eventCode ) |
---|
1022 | case 2: // mouse up |
---|
1023 | // click code here |
---|
1024 | |
---|
1025 | NVAR g_estimateOnly = root:Packages:NIST:SAS:g_estimateOnly // == 1 for just count rate, == 0 (default) to do the simulation and save |
---|
1026 | g_estimateOnly = 1 |
---|
1027 | |
---|
1028 | STRUCT WMButtonAction bb |
---|
1029 | bb.eventCode = 2 |
---|
1030 | Sim_RunSelected2DList(bb) |
---|
1031 | |
---|
1032 | g_estimateOnly = 0 |
---|
1033 | |
---|
1034 | break |
---|
1035 | case -1: // control being killed |
---|
1036 | break |
---|
1037 | endswitch |
---|
1038 | |
---|
1039 | return 0 |
---|
1040 | End |
---|
1041 | |
---|
1042 | |
---|
1043 | // |
---|
1044 | // Runs the selected items in the list as 2D simulation. Either run the dry run first, or be prepared |
---|
1045 | // to wait for some unknown length of time, maybe forever. There is no stop button. |
---|
1046 | // |
---|
1047 | // |
---|
1048 | // |
---|
1049 | Function Sim_RunSelected2DButton(ba) : ButtonControl |
---|
1050 | STRUCT WMButtonAction &ba |
---|
1051 | |
---|
1052 | switch( ba.eventCode ) |
---|
1053 | case 2: // mouse up |
---|
1054 | // click code here |
---|
1055 | |
---|
1056 | NVAR g_estimateOnly = root:Packages:NIST:SAS:g_estimateOnly // == 1 for just count rate, == 0 (default) to do the simulation and save |
---|
1057 | g_estimateOnly = 0 |
---|
1058 | |
---|
1059 | STRUCT WMButtonAction bb |
---|
1060 | bb.eventCode = 2 |
---|
1061 | Sim_RunSelected2DList(bb) |
---|
1062 | |
---|
1063 | break |
---|
1064 | case -1: // control being killed |
---|
1065 | break |
---|
1066 | endswitch |
---|
1067 | |
---|
1068 | return 0 |
---|
1069 | End |
---|
1070 | |
---|
1071 | |
---|
1072 | // |
---|
1073 | // Runs the selected items in the list as 2D simulation. Either run the dry run first, or be prepared |
---|
1074 | // to wait for some unknown length of time, maybe forever. There is no stop button. |
---|
1075 | // |
---|
1076 | // this is the function that really does the work |
---|
1077 | // |
---|
1078 | // sets everything up - sample and configuration, then checks the selW bit to dispatch |
---|
1079 | // to sample trans, empty beam, or regular run. |
---|
1080 | // |
---|
1081 | // run Index comes in as a global from the panel. |
---|
1082 | // |
---|
1083 | Function Sim_RunSelected2DList(ba) |
---|
1084 | STRUCT WMButtonAction &ba |
---|
1085 | |
---|
1086 | switch( ba.eventCode ) |
---|
1087 | case 2: // mouse up |
---|
1088 | // Lots of steps to make this happen |
---|
1089 | DoWindow MC_SASCALC |
---|
1090 | if(V_flag == 0) |
---|
1091 | Sim_SetSimulationType(0) //kill the simulation panel |
---|
1092 | Sim_SetSimulationType(2) //open the 2D simulation panel |
---|
1093 | endif |
---|
1094 | |
---|
1095 | Sim_SetSimTimeWarning(36000) //sets the threshold for the warning dialog to 10 hours |
---|
1096 | |
---|
1097 | // declarations |
---|
1098 | SetDataFolder root:Packages:NIST:RunSim |
---|
1099 | |
---|
1100 | Wave/T textW = textW |
---|
1101 | Wave selW = selW |
---|
1102 | |
---|
1103 | SetDataFolder root: |
---|
1104 | |
---|
1105 | String configStr="",sampleStr="",lblStr="",saveStr="",ctTimeStr="",funcStr="",noteStr="" |
---|
1106 | Variable numRows,ii,selRow,totalTime,thick,xs,r2,index,saveVal |
---|
1107 | numRows = DimSize(textW,0) |
---|
1108 | |
---|
1109 | NVAR g_estimateOnly = root:Packages:NIST:SAS:g_estimateOnly // == 1 for just count rate, == 0 (default) to do the simulation and save |
---|
1110 | |
---|
1111 | NVAR gIndex = root:Packages:NIST:RunSim:gRunIndex |
---|
1112 | // local copy to be able to PBR |
---|
1113 | index = gIndex |
---|
1114 | |
---|
1115 | totalTime = 0 |
---|
1116 | |
---|
1117 | //loop through all of the rows |
---|
1118 | for(ii=0;ii<numRows;ii+=1) |
---|
1119 | if((selW[ii][0] & 2^4) != 0) //checkbox is checked |
---|
1120 | |
---|
1121 | Print "**************** Running simulation for row = ",ii |
---|
1122 | |
---|
1123 | SetVariable RLCtrl_2n, win=RunListPanel,value= _STR:"Row "+num2str(ii) |
---|
1124 | // DoUpdate/W=RunListPanel |
---|
1125 | |
---|
1126 | // move to configuration |
---|
1127 | configStr = textW[ii][1] |
---|
1128 | // Sim_MoveToConfiguration($("root:Packages:NIST:SAS:"+configStr)) |
---|
1129 | |
---|
1130 | // set the sample |
---|
1131 | sampleStr = textW[ii][2] |
---|
1132 | |
---|
1133 | Struct WMPopupAction ps |
---|
1134 | ps.eventCode = 2 //fake mouse up |
---|
1135 | ps.popStr = sampleStr |
---|
1136 | Function_PopMenuProc(ps) |
---|
1137 | |
---|
1138 | Sim_RecallSamplePopMenu(ps) |
---|
1139 | |
---|
1140 | // don't set the count time here -- this is set in Run_Sim(function) |
---|
1141 | // NVAR ctTime = root:Packages:NIST:SAS:gCntTime |
---|
1142 | // ctTime = str2num(textW[ii][4]) |
---|
1143 | |
---|
1144 | //set the function String, radius, thickness, and Incoh from the sample specifics |
---|
1145 | Wave samWave = $("root:Packages:NIST:RunSim:"+sampleStr) |
---|
1146 | noteStr = note(samWave) |
---|
1147 | |
---|
1148 | // reset the function, coef |
---|
1149 | funcStr = StringByKey("FUNC", noteStr, ":", ";") |
---|
1150 | thick = NumberByKey("THICK", noteStr, ":", ";") |
---|
1151 | xs = NumberByKey("INCXS", noteStr, ":", ";") |
---|
1152 | r2 = NumberByKey("SAMRAD", noteStr, ":", ";") |
---|
1153 | Sim_SetModelFunction(funcStr) // model function name |
---|
1154 | Sim_SetSampleRadius(r2) // sam radius (cm) |
---|
1155 | Sim_SetThickness(thick) // thickness (cm) |
---|
1156 | Sim_SetIncohXS(xs) // incoh XS |
---|
1157 | |
---|
1158 | |
---|
1159 | // set the abs, noise checkboxes |
---|
1160 | Sim_SetRawCountsCheck(!str2num(textW[ii][6])) // raw cts? 1== yes |
---|
1161 | Sim_SetBeamStopInOut(1) // BS in? 1==yes, this is a scattering measurement |
---|
1162 | |
---|
1163 | |
---|
1164 | lblStr = textW[ii][3] |
---|
1165 | ctTimeStr = textW[ii][4] |
---|
1166 | saveStr = textW[ii][5] |
---|
1167 | |
---|
1168 | // now do the run depending what the type of sample actually is... |
---|
1169 | // 2^2 = empty beam |
---|
1170 | // 2^3 = sample trans |
---|
1171 | if ((selW[ii][0] & 2^2) != 0) //run is an empty beam |
---|
1172 | totalTime += Sim_RunEmptyBeamTrans_2D(configStr,ctTimeStr,lblStr,index) |
---|
1173 | elseif ((selW[ii][0] & 2^3) != 0) //run is a sample transmission, if not, run as a sample (no other choice) |
---|
1174 | totalTime += Sim_RunTrans_2D(configStr,ctTimeStr,lblStr,index) |
---|
1175 | else |
---|
1176 | totalTime += Sim_RunSample_2D(configStr,ctTimeStr,lblStr,index) //it's a regular sample run |
---|
1177 | endif |
---|
1178 | |
---|
1179 | endif |
---|
1180 | |
---|
1181 | endfor |
---|
1182 | |
---|
1183 | Sim_SetSimTimeWarning(10) //reset this before exiting |
---|
1184 | gIndex = index // reset the global |
---|
1185 | |
---|
1186 | Print "****************** Run list has been completed ***********************" |
---|
1187 | if(g_estimateOnly) |
---|
1188 | Print "Total Time (s) = ",totalTime |
---|
1189 | Print "Total Time (m) = ",totalTime/60 |
---|
1190 | Print "Total Time (h) = ",totalTime/60/60 |
---|
1191 | endif |
---|
1192 | |
---|
1193 | SetVariable RLCtrl_2n, win=RunListPanel,value= _STR:"Nothing" |
---|
1194 | // DoUpdate/W=RunListPanel |
---|
1195 | |
---|
1196 | break |
---|
1197 | case -1: // control being killed |
---|
1198 | break |
---|
1199 | endswitch |
---|
1200 | |
---|
1201 | return 0 |
---|
1202 | End |
---|
1203 | |
---|