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