1 | #pragma TextEncoding = "MacRoman" |
---|
2 | #pragma rtGlobals=3 // Use modern global access method and strict wave access. |
---|
3 | #pragma IgorVersion = 7.00 |
---|
4 | |
---|
5 | // April 2019 |
---|
6 | // routines to read + plot the data in the temperature_env block |
---|
7 | // |
---|
8 | |
---|
9 | // I don't know in general what may or may not be present, so I'll need to search for |
---|
10 | // data, and let the user decide what to do with what is there. |
---|
11 | |
---|
12 | // Paul K.? also puts a temperature_log block on the same level as temperature_env. |
---|
13 | // I need to figure out which sensor and fields this is duplicating. |
---|
14 | // - this may be the easiest and most appropriate to report - or not. |
---|
15 | |
---|
16 | // |
---|
17 | |
---|
18 | // list the temperature log folders |
---|
19 | // list all of the metadata (name, attached to, set point, etc.) |
---|
20 | // graph the values vs. time |
---|
21 | // where will I get the proper units?? |
---|
22 | // |
---|
23 | Function V_InitSensorGraph() |
---|
24 | |
---|
25 | DoWindow/F V_SensorGraph |
---|
26 | if(V_flag==0) |
---|
27 | String/G root:Packages:NIST:VSANS:Globals:gSensorFolders = "none;" |
---|
28 | String/G root:Packages:NIST:VSANS:Globals:gSensorMetaData = "no information" |
---|
29 | |
---|
30 | Execute "V_SensorGraph()" |
---|
31 | Make/O/D/N=1 root:Packages:NIST:VSANS:Globals:value |
---|
32 | Make/O/D/n=1 root:Packages:NIST:VSANS:Globals:time_point |
---|
33 | // Wave value=value,time_point=time0 |
---|
34 | AppendToGraph root:Packages:NIST:VSANS:Globals:value vs root:Packages:NIST:VSANS:Globals:time_point |
---|
35 | ModifyGraph mode=4,marker=8,opaque=1,mirror=2 |
---|
36 | Legend |
---|
37 | Label left,"Sensor Value" |
---|
38 | Label bottom,"Time (s)" |
---|
39 | |
---|
40 | STRUCT WMPopupAction pa |
---|
41 | pa.eventCode=2 |
---|
42 | pa.popStr="RAW" |
---|
43 | V_WorkFolderPopMenuProc(pa) |
---|
44 | endif |
---|
45 | |
---|
46 | return(0) |
---|
47 | End |
---|
48 | |
---|
49 | |
---|
50 | Window V_SensorGraph() : Graph |
---|
51 | PauseUpdate; Silent 1 // building window... |
---|
52 | // Display /W=(1500,350,2300,750)/N=V_SensorGraph/K=1 |
---|
53 | // ControlBar/L 300 |
---|
54 | Display /W=(600,50,1050,780)/N=V_SensorGraph/K=1 |
---|
55 | ControlBar/T 380 |
---|
56 | // ShowTools/A |
---|
57 | PopupMenu popup0,pos={10.00,10.00},size={87.00,23.00},proc=V_WorkFolderPopMenuProc,title="folder" |
---|
58 | PopupMenu popup0,mode=1,popvalue="RAW",value= #"\"RAW;SAM;ABS;\"" |
---|
59 | PopupMenu popup1,pos={10.00,40.00},size={84.00,23.00},proc=V_SensorPopMenuProc,title="sensor" |
---|
60 | PopupMenu popup1,mode=1,popvalue="pick folder",value= root:Packages:NIST:VSANS:Globals:gSensorFolders |
---|
61 | TitleBox title0,pos={10.00,80.00},size={25.00,19.00},fSize=10,variable=root:Packages:NIST:VSANS:Globals:gSensorMetaData |
---|
62 | EndMacro |
---|
63 | |
---|
64 | |
---|
65 | // pick the work folder of interest, and get the list of sensors, if any |
---|
66 | Function V_WorkFolderPopMenuProc(pa) : PopupMenuControl |
---|
67 | STRUCT WMPopupAction &pa |
---|
68 | |
---|
69 | switch( pa.eventCode ) |
---|
70 | case 2: // mouse up |
---|
71 | Variable popNum = pa.popNum |
---|
72 | String popStr = pa.popStr |
---|
73 | String dfStr |
---|
74 | |
---|
75 | // repopulate the list of sensors, if any |
---|
76 | SVAR gList = root:Packages:NIST:VSANS:Globals:gSensorFolders |
---|
77 | |
---|
78 | // do any data folders exist? |
---|
79 | if(!DataFolderExists("root:Packages:NIST:VSANS:"+popStr+":entry:sample:temperature_env:")) |
---|
80 | // data folder does not exist |
---|
81 | DoAlert 0,"No Sensor Data Exists" |
---|
82 | SVAR gMeta=root:Packages:NIST:VSANS:Globals:gSensorMetaData |
---|
83 | gMeta = "no sensors found" |
---|
84 | gList = "none" |
---|
85 | // DoWindow/K V_SensorGraph |
---|
86 | return(0) |
---|
87 | endif |
---|
88 | |
---|
89 | SetDataFolder $("root:Packages:NIST:VSANS:"+popStr+":entry:sample:temperature_env:") |
---|
90 | dfStr = DataFolderDir(1) // bit 0 = data folders |
---|
91 | gList = StringByKey("FOLDERS", dfStr ,":",";") |
---|
92 | gList = ReplaceString(",",gList,";") |
---|
93 | |
---|
94 | SetDataFolder root: |
---|
95 | |
---|
96 | break |
---|
97 | case -1: // control being killed |
---|
98 | break |
---|
99 | endswitch |
---|
100 | |
---|
101 | return 0 |
---|
102 | End |
---|
103 | |
---|
104 | // form the list of sensors, when popped, update the metadata and the plot |
---|
105 | // |
---|
106 | Function V_SensorPopMenuProc(pa) : PopupMenuControl |
---|
107 | STRUCT WMPopupAction &pa |
---|
108 | |
---|
109 | switch( pa.eventCode ) |
---|
110 | case 2: // mouse up |
---|
111 | Variable popNum = pa.popNum |
---|
112 | String popStr = pa.popStr |
---|
113 | |
---|
114 | string folderStr,wStr,wStr_2 |
---|
115 | SVAR gMeta=root:Packages:NIST:VSANS:Globals:gSensorMetaData |
---|
116 | |
---|
117 | Variable ii |
---|
118 | String item |
---|
119 | |
---|
120 | ControlInfo popup0 |
---|
121 | folderStr = S_Value |
---|
122 | // add single quote since sensor folder name may have a space in it |
---|
123 | if(!DataFolderExists("root:Packages:NIST:VSANS:"+folderStr+":entry:sample:temperature_env:'"+popStr+"':")) |
---|
124 | // data folder does not exist |
---|
125 | DoAlert 0,"No Sensor Data Exists" |
---|
126 | // DoWindow/K V_SensorGraph |
---|
127 | return(0) |
---|
128 | endif |
---|
129 | |
---|
130 | |
---|
131 | SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr+":entry:sample:temperature_env:'"+popStr+"':") |
---|
132 | |
---|
133 | wStr = DataFolderDir(2) //*bit* 0=FOLDERS, 1=WAVES, 2=VARIABLES, 3=STRINGS |
---|
134 | wStr = StringByKey("WAVES", wStr ,":",";") |
---|
135 | gMeta = "" |
---|
136 | for(ii=0;ii<ItemsInList(wStr,",");ii+=1) |
---|
137 | item = StringFromList(ii, wStr,",") |
---|
138 | if(WaveType($item,1) == 2) //2= text, 1=numeric |
---|
139 | Wave/T wt = $item |
---|
140 | gMeta += item + " = " + wt[0] + "\r" |
---|
141 | else |
---|
142 | Wave w = $item |
---|
143 | gMeta += item + " = " + num2str(w[0]) + "\r" |
---|
144 | endif |
---|
145 | endfor |
---|
146 | gMeta = ReplaceString(",",gMeta,"\t\r") |
---|
147 | gMeta += "\r" |
---|
148 | |
---|
149 | |
---|
150 | // waves in the value_log folder |
---|
151 | SetDataFolder value_log |
---|
152 | wStr = DataFolderDir(2) //*bit* 0=FOLDERS, 1=WAVES, 2=VARIABLES, 3=STRINGS |
---|
153 | wStr = StringByKey("WAVES", wStr ,":",";") |
---|
154 | |
---|
155 | for(ii=0;ii<ItemsInList(wStr,",");ii+=1) |
---|
156 | item = StringFromList(ii, wStr,",") |
---|
157 | if(cmpstr(item,"value") != 0 && cmpstr(item,"time0") != 0) |
---|
158 | if(WaveType($item,1) == 2) //2= text, 1=numeric |
---|
159 | Wave/T wt = $item |
---|
160 | gMeta += item + " = " + wt[0] + "\r" |
---|
161 | else |
---|
162 | Wave w = $item |
---|
163 | gMeta += item + " = " + num2str(w[0]) + "\r" |
---|
164 | endif |
---|
165 | endif |
---|
166 | endfor |
---|
167 | // remove last "\r" (a single character) |
---|
168 | gMeta = gMeta[0,strlen(gMeta)-2] |
---|
169 | |
---|
170 | //update the waves on the plot, plus the variables in this folder |
---|
171 | // SetDataFolder value_log //already here |
---|
172 | Wave newVal=value,newTime=time0 |
---|
173 | Duplicate/O newVal, root:Packages:NIST:VSANS:Globals:value |
---|
174 | Duplicate/O newTime, root:Packages:NIST:VSANS:Globals:time_point |
---|
175 | |
---|
176 | |
---|
177 | setDataFolder root: |
---|
178 | break |
---|
179 | case -1: // control being killed |
---|
180 | break |
---|
181 | endswitch |
---|
182 | |
---|
183 | return 0 |
---|
184 | End |
---|
185 | |
---|