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 | Proc V_SensorGraph() : Graph |
---|
51 | |
---|
52 | Variable sc = 1 |
---|
53 | |
---|
54 | if(root:Packages:NIST:VSANS:Globals:gLaptopMode == 1) |
---|
55 | sc = 0.7 |
---|
56 | endif |
---|
57 | |
---|
58 | PauseUpdate; Silent 1 // building window... |
---|
59 | // Display /W=(1500,350,2300,750)/N=V_SensorGraph/K=1 |
---|
60 | // ControlBar/L 300 |
---|
61 | |
---|
62 | if(root:Packages:NIST:VSANS:Globals:gLaptopMode == 1) |
---|
63 | Display /W=(600*sc,50*sc,1050*sc,600*sc)/N=V_SensorGraph/K=1 |
---|
64 | ControlBar/T 300*sc |
---|
65 | else |
---|
66 | Display /W=(600,50,1050,780)/N=V_SensorGraph/K=1 |
---|
67 | ControlBar/T 380 |
---|
68 | endif |
---|
69 | |
---|
70 | // ShowTools/A |
---|
71 | PopupMenu popup0,pos={sc*10.00,10.00*sc},size={sc*87.00,23.00*sc},proc=V_WorkFolderPopMenuProc,title="folder" |
---|
72 | PopupMenu popup0,mode=1,popvalue="RAW",value= #"\"RAW;SAM;ABS;\"" |
---|
73 | PopupMenu popup1,pos={sc*10.00,40.00*sc},size={sc*84.00,23.00*sc},proc=V_SensorPopMenuProc,title="sensor" |
---|
74 | PopupMenu popup1,mode=1,popvalue="pick folder",value= root:Packages:NIST:VSANS:Globals:gSensorFolders |
---|
75 | TitleBox title0,pos={sc*10.00,80.00*sc},size={sc*25.00,19.00*sc},fSize=10,variable=root:Packages:NIST:VSANS:Globals:gSensorMetaData |
---|
76 | EndMacro |
---|
77 | |
---|
78 | |
---|
79 | // pick the work folder of interest, and get the list of sensors, if any |
---|
80 | Function V_WorkFolderPopMenuProc(pa) : PopupMenuControl |
---|
81 | STRUCT WMPopupAction &pa |
---|
82 | |
---|
83 | switch( pa.eventCode ) |
---|
84 | case 2: // mouse up |
---|
85 | Variable popNum = pa.popNum |
---|
86 | String popStr = pa.popStr |
---|
87 | String dfStr |
---|
88 | |
---|
89 | // repopulate the list of sensors, if any |
---|
90 | SVAR gList = root:Packages:NIST:VSANS:Globals:gSensorFolders |
---|
91 | |
---|
92 | // do any data folders exist? |
---|
93 | if(!DataFolderExists("root:Packages:NIST:VSANS:"+popStr+":entry:sample:temperature_env:")) |
---|
94 | // data folder does not exist |
---|
95 | DoAlert 0,"No Sensor Data Exists" |
---|
96 | SVAR gMeta=root:Packages:NIST:VSANS:Globals:gSensorMetaData |
---|
97 | gMeta = "no sensors found" |
---|
98 | gList = "none" |
---|
99 | // DoWindow/K V_SensorGraph |
---|
100 | return(0) |
---|
101 | endif |
---|
102 | |
---|
103 | SetDataFolder $("root:Packages:NIST:VSANS:"+popStr+":entry:sample:temperature_env:") |
---|
104 | dfStr = DataFolderDir(1) // bit 0 = data folders |
---|
105 | gList = StringByKey("FOLDERS", dfStr ,":",";") |
---|
106 | gList = ReplaceString(",",gList,";") |
---|
107 | |
---|
108 | SetDataFolder root: |
---|
109 | |
---|
110 | break |
---|
111 | case -1: // control being killed |
---|
112 | break |
---|
113 | endswitch |
---|
114 | |
---|
115 | return 0 |
---|
116 | End |
---|
117 | |
---|
118 | // form the list of sensors, when popped, update the metadata and the plot |
---|
119 | // |
---|
120 | Function V_SensorPopMenuProc(pa) : PopupMenuControl |
---|
121 | STRUCT WMPopupAction &pa |
---|
122 | |
---|
123 | switch( pa.eventCode ) |
---|
124 | case 2: // mouse up |
---|
125 | Variable popNum = pa.popNum |
---|
126 | String popStr = pa.popStr |
---|
127 | |
---|
128 | string folderStr,wStr,wStr_2 |
---|
129 | SVAR gMeta=root:Packages:NIST:VSANS:Globals:gSensorMetaData |
---|
130 | |
---|
131 | Variable ii |
---|
132 | String item |
---|
133 | |
---|
134 | ControlInfo popup0 |
---|
135 | folderStr = S_Value |
---|
136 | // add single quote since sensor folder name may have a space in it |
---|
137 | if(!DataFolderExists("root:Packages:NIST:VSANS:"+folderStr+":entry:sample:temperature_env:'"+popStr+"':")) |
---|
138 | // data folder does not exist |
---|
139 | DoAlert 0,"No Sensor Data Exists" |
---|
140 | // DoWindow/K V_SensorGraph |
---|
141 | return(0) |
---|
142 | endif |
---|
143 | |
---|
144 | |
---|
145 | SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr+":entry:sample:temperature_env:'"+popStr+"':") |
---|
146 | |
---|
147 | wStr = DataFolderDir(2) //*bit* 0=FOLDERS, 1=WAVES, 2=VARIABLES, 3=STRINGS |
---|
148 | wStr = StringByKey("WAVES", wStr ,":",";") |
---|
149 | gMeta = "" |
---|
150 | for(ii=0;ii<ItemsInList(wStr,",");ii+=1) |
---|
151 | item = StringFromList(ii, wStr,",") |
---|
152 | if(WaveType($item,1) == 2) //2= text, 1=numeric |
---|
153 | Wave/T wt = $item |
---|
154 | gMeta += item + " = " + wt[0] + "\r" |
---|
155 | else |
---|
156 | Wave w = $item |
---|
157 | gMeta += item + " = " + num2str(w[0]) + "\r" |
---|
158 | endif |
---|
159 | endfor |
---|
160 | gMeta = ReplaceString(",",gMeta,"\t\r") |
---|
161 | gMeta += "\r" |
---|
162 | |
---|
163 | |
---|
164 | // waves in the value_log folder |
---|
165 | SetDataFolder value_log |
---|
166 | wStr = DataFolderDir(2) //*bit* 0=FOLDERS, 1=WAVES, 2=VARIABLES, 3=STRINGS |
---|
167 | wStr = StringByKey("WAVES", wStr ,":",";") |
---|
168 | |
---|
169 | for(ii=0;ii<ItemsInList(wStr,",");ii+=1) |
---|
170 | item = StringFromList(ii, wStr,",") |
---|
171 | if(cmpstr(item,"value") != 0 && cmpstr(item,"time0") != 0) |
---|
172 | if(WaveType($item,1) == 2) //2= text, 1=numeric |
---|
173 | Wave/T wt = $item |
---|
174 | gMeta += item + " = " + wt[0] + "\r" |
---|
175 | else |
---|
176 | Wave w = $item |
---|
177 | gMeta += item + " = " + num2str(w[0]) + "\r" |
---|
178 | endif |
---|
179 | endif |
---|
180 | endfor |
---|
181 | // remove last "\r" (a single character) |
---|
182 | gMeta = gMeta[0,strlen(gMeta)-2] |
---|
183 | |
---|
184 | //update the waves on the plot, plus the variables in this folder |
---|
185 | // SetDataFolder value_log //already here |
---|
186 | Wave newVal=value,newTime=time0 |
---|
187 | Duplicate/O newVal, root:Packages:NIST:VSANS:Globals:value |
---|
188 | Duplicate/O newTime, root:Packages:NIST:VSANS:Globals:time_point |
---|
189 | |
---|
190 | |
---|
191 | setDataFolder root: |
---|
192 | break |
---|
193 | case -1: // control being killed |
---|
194 | break |
---|
195 | endswitch |
---|
196 | |
---|
197 | return 0 |
---|
198 | End |
---|
199 | |
---|