1 #pragma rtGlobals=3 // Use modern global access method and strict wave access. 3 #pragma IgorVersion = 6.2 4 #pragma ModuleName = PearlElog 103 if (ItemsInList(templates) < 1)
108 if (strlen(logbook) == 0)
112 string win_name = logbook + "ElogPanel"
113 if (strlen(logbook) > 0)
114 if (strlen(WinList(win_name, ";", "")) > 0)
115 DoWindow /F $win_name
118 STRUCT WMWinHookStruct s
128 string igorApplicationNameStr
136 string igorApplicationNameStr
145 String file,pathName,type,creator
146 if( (kind >= 1) && (kind <= 2))
174 dfref df_package = $package_path
175 dfref df_persistent = df_package:persistent
176 dfref df_volatile = df_package:volatile
180 dfref df_parent = df_package
183 dfref df_parent = df_persistent
186 dfref df_parent = df_persistent:templates
189 dfref df_parent = df_volatile
192 Abort "
get_elog_df: undefined data folder category."
195 if ((strlen(name) > 0) && (category >= 1))
197 dfref df_logbooks = df_parent
199 dfref df_logbooks = df_parent:logbooks
201 dfref df_logbook = df_logbooks:$name
220 if (ParamIsDefault(clean))
224 dfref savedf = getdatafolderdfr()
226 if ((clean == 0) && (DataFolderRefStatus(df_root) == 1))
231 newdatafolder /o/s packages
232 newdatafolder /o/s $package_name
233 dfref df_package_root = getdatafolderdfr()
234 newdatafolder /o/s volatile
235 dfref df_volatile = getdatafolderdfr()
236 newdatafolder /o logbooks
237 setdatafolder df_package_root
238 newdatafolder /o/s persistent
239 dfref df_persistent = getdatafolderdfr()
240 newdatafolder /o logbooks
241 newdatafolder /o templates
244 setdatafolder df_persistent
245 string /g elog_path = "c:\\program files (x86)\\ELOG\\elog.exe"
246 string /g hostname = "localhost"
249 string /g subdir = ""
250 variable /g loglevel = 4
263 dfref savedf = getdatafolderdfr()
265 dfref df_root = get_elog_df("",
kdfRoot)
270 setdatafolder df_templates
271 newdatafolder /o/s Experiments
275 string /g attributes = "author;project;p-group;sample;source;task;technique;file;valid;"
278 string /g controls = "sv_author;sv_project;sv_pgroup;sv_sample;pm_source;pm_task;pm_technique;sv_file;cb_valid;"
280 string /g options = "source=sources;task=tasks;technique=techniques"
282 string /g required_attributes = "author;project;p-group;sample;source;task;technique;valid"
285 string /g sources = "Manual Entry;PShell;Scienta Data;SScan Data;Prosilica Data;OTF Data;Beamline Status;LEED Data;QMS Data;Matrix Data;Igor Pro;Other"
286 string /g tasks = "Measurement;Optimization;Analysis;Sample Preparation;Sample Storage;Comment;Development;Maintenance;Test;Other"
287 string /g techniques = "XPS;UPS;XPD;XAS;XMCD;PhD;ARUPS;STM;STS;LEED;AES;QMS;MBE;Sputter/Anneal;Test;Other"
290 setdatafolder df_templates
291 newdatafolder /o/s Calculations
295 string /g attributes = "author;project;p-group;sample;program;revision;machine;job;experiment;source path;result path;valid"
298 string /g controls = "sv_author;sv_project;sv_pgroup;sv_sample;pm_program;sv_revision;pm_machine;sv_job;sv_experiment;sv_sourcepath;sv_resultpath;cb_valid"
300 string /g options = "program=programs;machine=machines"
302 string /g required_attributes = "author;project;sample"
305 string /g programs = "PMSCO;EDAC;MSC;SSC;MUFPOT;DMSUP;Other"
306 string /g machines = "PC;VM;Ra;Merlin;llcx;Other"
309 setdatafolder df_templates
310 newdatafolder /o/s System
314 string /g attributes = "author;type;system;source;file"
317 string /g controls = "sv_author;pm_type;pm_system;pm_source;sv_file"
319 string /g options = "type=types;system=systems;source=sources"
321 string /g required_attributes = "author;type;system"
324 string /g types = "Installation;Repair;Maintenance;Test;Commissioning;Bakeout;Incident;Cool-down;Warm-up;Storage;Other"
325 string /g systems = "Vacuum;Control System;BL;XA;XP;SA;SP;T;LL;Monochromator;Carving;Scienta;STM;PC-Scienta;PC-Matrix;PC-Console;PC-Console-Win;PC-XP;EPS;LAC;Desiccator;Other"
326 string /g sources = "Manual Entry;PShell;Scienta Data;SScan Data;Prosilica Data;OTF Data;Beamline Status;LEED Data;QMS Data;Matrix Data;Igor Pro;Other"
341 dfref savedf = GetDataFolderDFR()
343 dfref df_volatile_root = get_elog_df("",
kdfVolatile)
344 dfref df_volatile_parent = df_volatile_root:logbooks
348 variable nlb = ItemsInList(logbooks)
351 SetDataFolder df_volatile_root
352 if (exists("temp_graph_files") != 2)
353 string /g temp_graph_files = ""
356 for (ilb = 0; ilb < nlb; ilb += 1)
357 logbook = StringFromList(ilb, logbooks)
359 SetDataFolder df_volatile_parent
360 if (DataFolderExists(logbook))
361 SetDataFolder $logbook
363 NewDataFolder /o/s $logbook
366 if (exists("username") != 2)
367 string /g username = ""
369 if (exists("password") != 2)
370 string /g password = ""
372 if (exists("msg_id") != 2)
373 variable /g msg_id = 0
375 if (exists("att_list") != 1)
376 make /n=(0,3) /t /o attach_list
377 make /n=(0,3) /i /o attach_sel
379 if (exists("url") != 2)
418 if (ParamIsDefault(template))
422 dfref savedf = getdatafolderdfr()
423 dfref df_root = get_elog_df("",
kdfRoot)
425 dfref df_persistent_parent = df_persistent_root:logbooks
426 dfref df_volatile_root = get_elog_df("",
kdfVolatile)
427 dfref df_volatile_parent = df_volatile_root:logbooks
429 setdatafolder df_persistent_parent
430 if (CheckName(name, 11) != 0)
432 Abort "invalid logbook name"
436 if (strlen(template) > 0)
439 if (DataFolderRefStatus(df_existing))
440 KillDataFolder /Z df_existing
442 DuplicateDataFolder df_template, df_persistent_parent:$name
444 NewDataFolder /o/s df_persistent_parent:$name
447 string /g logbook = name
450 string /g attributes = ""
453 string /g controls = ""
455 string /g options = ""
457 string /g required_attributes = ""
462 string /g recent = ""
463 string /g recent_message = ""
481 if (!ParamIsDefault(elog_path))
482 svar /sdfr=df g_elog_path = elog_path
483 g_elog_path = elog_path
485 if (!ParamIsDefault(hostname))
486 svar /sdfr=df g_hostname = hostname
487 g_hostname = hostname
489 if (!ParamIsDefault(port))
490 nvar /sdfr=df g_port = port
493 if (!ParamIsDefault(subdir))
494 svar /sdfr=df g_subdir = subdir
519 svar /sdfr=df g_username=username
520 svar /sdfr=df g_password=password
521 g_username = username
522 g_password = password
537 if (strlen(logbook) > 0)
538 svar /z /sdfr=df g_username=username
539 svar /z /sdfr=df g_password=password
540 if (svar_exists(g_username))
543 if (svar_exists(g_password))
547 dfref df2 = df:logbooks
548 variable nlb = CountObjectsDFR(df2, 4)
551 for (ilb = 0; ilb < nlb; ilb += 1)
552 slb = GetIndexedObjNameDFR(df2, 4, ilb)
565 dfref saveDF = GetDataFolderDFR()
568 if (DataFolderRefStatus(df) == 1)
569 string fullPath = SpecialDirPath("Packages", 0, 0, 0)
571 NewPath/O/C/Q tempPackagePrefsPath, fullPath
572 fullPath += ":preferences.pxp"
574 SaveData /O /Q /R fullPath
575 KillPath/Z tempPackagePrefsPath
585 dfref saveDF = GetDataFolderDFR()
591 string fullPath = SpecialDirPath("Packages", 0, 0, 0)
594 GetFileFolderInfo /Q /Z fullPath
596 fullPath += ":preferences.pxp"
597 GetFileFolderInfo /Q /Z fullPath
599 LoadData /O /R /Q fullPath
621 if (ParamIsDefault(templates))
627 dfref df_logbooks = df_persistent:templates
629 dfref df_logbooks = df_persistent:logbooks
633 variable nlb = CountObjectsDFR(df_logbooks, 4)
636 for (ilb = 0; ilb < nlb; ilb += 1)
637 slb = GetIndexedObjNameDFR(df_logbooks, 4, ilb)
639 logbooks = AddListItem(slb, logbooks)
643 return SortList(logbooks, ";", 16)
693 if (ParamIsDefault(encoding))
696 if (ParamIsDefault(graphs))
699 if (ParamIsDefault(replyto))
703 dfref savedf = getdatafolderdfr()
705 dfref df_volatile = get_elog_df(logbook,
kdfVolatile)
708 nvar /sdfr=df_volatile msg_id
709 nvar /sdfr=df_general loglevel
713 print "ELOG: failed to validate attributes."
719 if (strlen(cmd) == 0)
721 print "ELOG: failed to prepare command line."
727 cmd += " -r " + num2str(replyto)
729 cmd += " -n " + num2str(encoding)
731 variable nattr = ItemsInList(attributes, ";")
734 for (iattr = 0; (iattr < nattr) && (result == 0); iattr += 1)
735 sattr = StringFromList(iattr, attributes, ";")
736 if (strlen(StringFromList(1, sattr, "=")) > 0)
737 sattr = ReplaceString("%", sattr, "")
738 cmd += " -a \"" + sattr + "\""
744 cmd += " " + cmd_graphs
747 if ((result == 0) && (strlen(message) > 0))
749 if (strlen(messagefile) > 0)
750 cmd += " -m \"" + messagefile + "\""
756 if (strlen(cmd_file_path) > 0)
757 ExecuteScriptText cmd_file_path
762 print "ELOG: sent message " + num2str(
id)
766 print "ELOG: sending message failed."
775 print "ELOG: failed to create temporary message file."
797 dfref savedf = getdatafolderdfr()
799 dfref df_volatile = get_elog_df(logbook,
kdfVolatile)
802 nvar /sdfr=df_volatile msg_id
803 nvar /sdfr=df_general loglevel
806 if (strlen(cmd) == 0)
810 cmd += " -e " + num2str(
id)
814 if (strlen(cmd_graphs) == 0)
820 cmd += " " + cmd_graphs
823 if (strlen(cmd_file_path) > 0)
824 ExecuteScriptText cmd_file_path
829 print "ELOG: attached graphs to message " + num2str(
id)
833 print "ELOG: failed to attach graphs."
858 dfref df_volatile = get_elog_df(logbook,
kdfVolatile)
860 svar /sdfr=df_general elog_path
861 svar /sdfr=df_general hostname
862 nvar /sdfr=df_general port
863 nvar /sdfr=df_general ssl
864 svar /sdfr=df_general subdir
865 nvar /sdfr=df_general loglevel
866 svar /sdfr=df_volatile username
867 svar /sdfr=df_volatile password
870 cmd = "\"" + elog_path + "\""
874 cmd += " -h " + hostname
875 if ((nvar_exists(port)) && (port > 0))
876 cmd += " -p " + num2str(port)
878 if ((svar_exists(subdir)) && (strlen(subdir) > 0))
879 cmd += " -d " + subdir
881 cmd += " -l \"" + logbook + "\""
882 if ((nvar_exists(ssl)) && (ssl != 0))
886 if (svar_exists(username) && svar_exists(password) && (strlen(username) > 0) && (strlen(password) > 0))
887 cmd += " -u " + username + " " + password
907 svar /sdfr=df_general hostname
908 nvar /sdfr=df_general port
909 nvar /sdfr=df_general ssl
910 svar /sdfr=df_general subdir
913 if ((nvar_exists(ssl)) && (ssl != 0))
919 if ((nvar_exists(port)) && (port > 0))
920 cmd += ":" + num2str(port)
922 if ((svar_exists(subdir)) && (strlen(subdir) > 0))
943 variable ngraphs = ItemsInList(graphs, ";")
947 for (igraph = 0; igraph < ngraphs; igraph += 1)
948 sgraph = StringFromList(igraph, graphs, ";")
950 if (strlen(graph_path) > 0)
951 cmd += " -f \"" + graph_path + "\""
960 Variable now = DateTime
961 string dat = ReplaceString("-", Secs2Date(DateTime, -2), "")
962 string tim = ReplaceString(":", Secs2Time(DateTime, 3), "")
963 return dat + sep + tim
985 message = ReplaceString("%", message, "")
986 string path = SpecialDirPath("Temporary", 0, 1, 0)
987 variable len = strlen(path)
990 if (numtype(len) == 0)
991 filename = "elog_temp_message.txt"
1027 dfref df_volatile_root = get_elog_df("",
kdfVolatile)
1028 svar /sdfr=df_volatile_root temp_graph_files
1030 string path = SpecialDirPath("Temporary", 0, 1, 0)
1032 variable len = strlen(path)
1035 if (numtype(len) == 0)
1036 filename = "elog_" + ts + "_" + num2str(fileindex) + ".png"
1038 SavePICT /B=72 /E=-5 /M /O /W=(0,0,8,6) /WIN=$graphname /Z as path
1040 temp_graph_files = AddListItem(path, temp_graph_files, ";", inf)
1063 nvar /sdfr=df_general loglevel
1065 if (strlen(cmd) >= 1024)
1067 print "ELOG: command line too
long (add fewer attachments)."
1072 string work_path = SpecialDirPath("Temporary", 0, 1, 0)
1073 variable len = strlen(work_path)
1074 if (numtype(len) == 0)
1076 string cmd_path = work_path + "elog_temp_cmd.bat"
1082 cmdx = "cd \"" + work_path + "\"\r\n"
1084 cmdx = "del elog.log"
1085 fprintf f1, cmdx + "\r\n"
1096 string path = SpecialDirPath("Temporary", 0, 1, 0)
1097 variable len = strlen(path)
1098 if (numtype(len) == 0)
1116 dfref df_volatile_root = get_elog_df("",
kdfVolatile)
1117 if (DataFolderRefStatus(df_volatile_root))
1118 svar /sdfr=df_volatile_root /z temp_graph_files
1119 if (SVAR_Exists(temp_graph_files))
1120 variable nfi = ItemsInList(temp_graph_files)
1123 for (ifi = 0; ifi < nfi; ifi += 1)
1124 sfi = StringFromList(ifi, temp_graph_files)
1127 temp_graph_files = ""
1143 nvar /sdfr=df_general loglevel
1148 variable success = 0
1153 variable len = strlen(path)
1154 if (numtype(len) == 0)
1156 Open /R/Z f1 as path
1160 if (strlen(line) > 0)
1161 part1 = StringFromList(0, line, ",")
1162 part2 = ReplaceString(" ", StringFromList(1, line, ","), "")
1186 logbooks = AddListItem("(new)", logbooks)
1188 templates = AddListItem("(none)", templates)
1190 string logbook = StringFromList(0, logbooks)
1191 string template = StringFromList(0, logbooks)
1193 string username = ""
1194 string password = ""
1196 prompt logbook, "logbook", popup logbooks
1197 prompt template, "template", popup templates
1198 prompt name, "new logbook name"
1200 doprompt "select logbook", logbook, template, name
1202 if (cmpstr(logbook, "(new)") == 0)
1219 string username = ""
1220 string password = ""
1222 prompt logbook, "logbook", popup logbooks
1223 prompt username, "user name"
1224 prompt password, "password (blank to log out)"
1226 doprompt "log in to logbook", logbook, username, password
1244 dfref savedf = getdatafolderdfr()
1247 dfref df_volatile = get_elog_df(logbook,
kdfVolatile)
1249 string win_name = logbook + "ElogPanel"
1250 string win_title = "ELOG " + logbook
1252 NewPanel /K=1 /N=$win_name /W=(600,200,1200,700) as win_title
1254 ModifyPanel /w=$win_name cbRGB=(52224,52224,65280)
1256 svar /sdfr=df_persistent attributes
1257 svar /sdfr=df_persistent controls
1258 svar /sdfr=df_persistent options
1259 wave /t /sdfr=df_volatile attach_list
1260 wave /sdfr=df_volatile attach_sel
1261 svar /sdfr=df_volatile url
1264 variable nattr = ItemsInList(attributes, ";")
1268 string persistent_path = GetDataFolder(1, df_persistent)
1269 string volatile_path = GetDataFolder(1, df_volatile)
1271 string variable_path
1275 for (iattr = 0; iattr < nattr; iattr += 1)
1276 s_attr = StringFromList(iattr, attributes, ";")
1277 s_control = StringFromList(iattr, controls, ";")
1278 strswitch(s_control[0,1])
1280 SetVariable $s_control, win=$win_name, pos={0,ypos}, size={300,16}, bodyWidth=230
1281 SetVariable $s_control, win=$win_name, title=s_attr, value= _STR:
"" 1282 SetVariable $s_control, win=$win_name, userdata(attribute)=s_attr
1286 options_path = persistent_path + StringByKey(s_attr, options,
"=",
";")
1287 PopupMenu $s_control, win=$win_name, pos={0,ypos}, size={300,21}, bodyWidth=230
1288 PopupMenu $s_control, win=$win_name, title=s_attr
1289 PopupMenu $s_control, win=$win_name, mode=1, popvalue=
"Test", value= #options_path
1290 PopupMenu $s_control, win=$win_name, userdata(attribute)=s_attr
1294 CheckBox $s_control, win=$win_name, pos={70,ypos}, size={300,14}
1295 CheckBox $s_control, win=$win_name, title=s_attr, value= 1
1296 CheckBox $s_control, win=$win_name, userdata(attribute)=s_attr
1301 ypos = max(ypos, 80)
1303 TitleBox t_attach, win=$win_name, pos={308,5}, size={70,14}, title=
"Attachments", frame=0
1304 height = ypos - 21 - 4
1305 ListBox lb_attach, win=$win_name, pos={308,21}, size={264,height}
1306 ListBox lb_attach, win=$win_name, listWave=attach_list
1307 ListBox lb_attach, win=$win_name, mode=1, selWave=attach_sel, selRow=-1
1308 ListBox lb_attach, win=$win_name, widths={20,160,80}
1309 ListBox lb_attach, win=$win_name, help={
"Choose graphs to attach to the message."}
1311 Button b_attach_top, win=$win_name, pos={420,2}, size={40,18}, title=
"top" 1312 Button b_attach_top, win=$win_name, fcolor=(56576,60928,47872)
1314 Button b_attach_top, win=$win_name, help={
"Select top graph for attachment."}
1315 Button b_attach_all, win=$win_name, pos={460,2}, size={40,18}, title=
"all" 1316 Button b_attach_all, win=$win_name, fcolor=(56576,60928,47872)
1318 Button b_attach_all, win=$win_name, help={
"Select all graphs for attachment."}
1319 Button b_attach_none, win=$win_name, pos={500,2}, size={40,18}, title=
"none" 1320 Button b_attach_none, win=$win_name, fcolor=(56576,60928,47872)
1322 Button b_attach_none, win=$win_name, help={
"Deselect all attachments."}
1323 Button b_save_graphs, win=$win_name, pos={540,2}, size={40,18}, title=
"save" 1324 Button b_save_graphs, win=$win_name, fcolor=(56576,60928,47872)
1326 Button b_save_graphs, win=$win_name, help={
"Save selected graphs as PNG bitmap files."}
1327 Button b_attach_up, win=$win_name, pos={576,20}, size={20,20}, title=
"\\W517" 1328 Button b_attach_up, win=$win_name, fcolor=(56576,60928,47872)
1330 Button b_attach_up, win=$win_name, help={
"Move selected graph up."}
1331 Button b_attach_dw, win=$win_name, pos={576,40}, size={20,20}, title=
"\\W523" 1332 Button b_attach_dw, win=$win_name, fcolor=(56576,60928,47872)
1334 Button b_attach_dw, win=$win_name, help={
"Move selected graph down."}
1337 Button b_submit,win=$win_name, pos={70,ypos},size={46,20},proc=
PearlElog#
bp_submit,title=
"Submit" 1338 Button b_submit,win=$win_name, help={
"Submit form data to ELOG (new entry)."}
1339 Button b_submit,win=$win_name, fcolor=(56576,60928,47872)
1340 Button b_clear,win=$win_name, pos={120,ypos},size={46,20},proc=
PearlElog#
bp_clear,title=
"Clear" 1341 Button b_clear,win=$win_name, help={
"Clear the form fields"}
1342 Button b_clear,win=$win_name, fcolor=(56576,60928,47872)
1345 variable_path = volatile_path +
"msg_id" 1346 SetVariable sv_id,win=$win_name, pos={51,ypos},size={119,16},bodyWidth=77
1347 SetVariable sv_id,win=$win_name, title=
"ID",value=$variable_path
1348 SetVariable sv_id,win=$win_name, help={
"ID of last submitted message, or message to attach or reply to."}
1350 TitleBox t_host, win=$win_name, pos={170,ypos+4}, size={112.00,14.00}, frame=0
1351 TitleBox t_host, win=$win_name, variable=url
1354 Button b_attach,win=$win_name, pos={170,ypos},size={48,20},proc=
PearlElog#
bp_attach,title=
"Attach" 1355 Button b_attach,win=$win_name, help={
"Attach the selected graph to an existing ELOG entry (correct ID required)."}
1356 Button b_attach,win=$win_name, fcolor=(56576,60928,47872)
1357 Button b_reply,win=$win_name, pos={220,ypos},size={48,20},proc=
PearlElog#
bp_submit,title=
"Reply" 1358 Button b_reply,win=$win_name, help={
"Submit form data to ELOG as a reply to an existing message (correct ID required)."}
1359 Button b_reply,win=$win_name, fcolor=(56576,60928,47872)
1360 Button b_login,win=$win_name, pos={550,ypos},size={46,20},proc=
PearlElog#
bp_login,title=
"Login" 1361 Button b_login,win=$win_name, help={
"Enter user name and password."}
1362 Button b_login,win=$win_name, fcolor=(56576,60928,47872)
1363 Button b_logout,win=$win_name, pos={550,ypos},size={46,20},proc=
PearlElog#
bp_logout,title=
"Logout" 1364 Button b_logout,win=$win_name, help={
"Clear user name and password."}
1365 Button b_logout,win=$win_name, fcolor=(56576,60928,47872), disable=3
1368 SetWindow $win_name, userdata(logbook)=logbook
1371 TitleBox t_message,win=$win_name, pos={10,ypos},size={58,16},fixedSize=1,frame=0,anchor=RT,title=
"Message" 1372 DefineGuide UGH0={FT,ypos},UGV0={FL,70},UGH1={FB,-52},UGV1={FR,-2}
1373 NewNotebook /F=0 /N=Message /OPTS=3 /W=(115,404,345,341)/FG=(UGV0,UGH0,UGV1,UGH1) /HOST=#
1374 Notebook kwTopWin, defaultTab=20, statusWidth=0, autoSave=0
1375 Notebook kwTopWin fSize=10, fStyle=0, textRGB=(0,0,0)
1376 RenameWindow #,Message
1377 string nb_name = win_name +
"#Message" 1378 SetActiveSubwindow ##
1381 svar /z /sdfr=df_persistent recent
1382 if (svar_exists(recent) && (strlen(recent) > 0))
1385 svar /z /sdfr=df_persistent recent_message
1386 if (svar_exists(recent_message) && (strlen(recent_message) > 0))
1389 Notebook $nb_name selection={startOfFile,startOfFile}, findText={
"",1}
1391 setdatafolder savedf
1396 STRUCT WMWinHookStruct &s
1398 Variable hookResult = 0
1402 string logbook = GetUserData(s.winName,
"",
"logbook")
1403 if (strlen(logbook) > 0)
1405 svar /sdfr=df_volatile url
1412 variable b_top = s.winRect.bottom + 4
1413 Button b_submit,pos={70,b_top}
1414 Button b_clear,pos={120,b_top}
1415 TitleBox t_host, pos={170,b_top+4}
1417 Button b_attach,pos={170,b_top}
1418 Button b_reply,pos={220,b_top}
1419 Button b_login, pos={550,b_top}
1420 Button b_logout, pos={550,b_top}
1422 SetVariable sv_id,pos={51,b_top}
1437 dfref savedf = getdatafolderdfr()
1439 wave /t /sdfr=df_volatile attach_list
1440 wave /sdfr=df_volatile attach_sel
1442 if (!waveexists(attach_list))
1445 string names = WinList("*", ";", "WIN:1;VISIBLE:1")
1446 names = SortList(names, ";", 16)
1451 variable n = DimSize(attach_list, 0)
1453 for (i = n-1; i >= 0; i -= 1)
1454 s = attach_list[i][kAttachColName]
1455 if (WhichListItem(s, names) < 0)
1456 DeletePoints /M=0 i, 1, attach_list, attach_sel
1461 n = ItemsInList(names)
1462 for (i = 0; i < n; i += 1)
1463 s = StringFromList(i, names)
1464 FindValue /text=s /txop=4 /z attach_list
1466 k = DimSize(attach_list, 0)
1467 Redimension /n=(k+1,3) attach_list, attach_sel
1469 attach_list[k][kAttachColSel] = ""
1470 attach_list[k][kAttachColTitle] = ""
1471 attach_list[k][kAttachColName] = s
1472 attach_sel[k][kAttachColSel] = 32
1473 attach_sel[k][kAttachColTitle] = 0
1474 attach_sel[k][kAttachColName] = 0
1479 n = DimSize(attach_list, 0)
1480 for (i = n-1; i >= 0; i -= 1)
1481 s = attach_list[i][kAttachColName]
1482 getwindow /z $s, wtitle
1484 attach_list[i][kAttachColTitle] = s_value
1486 attach_list[i][kAttachColTitle] = s
1490 setdatafolder savedf
1500 dfref savedf = getdatafolderdfr()
1502 wave /t /sdfr=df_volatile attach_list
1503 wave /sdfr=df_volatile attach_sel
1504 variable n = DimSize(attach_list, 0)
1505 variable dest = item + distance
1507 if ((item >= 0) && (item < n) && (dest >= 0) && (dest < n))
1508 string name = attach_list[item][kAttachColName]
1509 variable sel = attach_sel[item][kAttachColSel]
1510 DeletePoints /M=0 item, 1, attach_list, attach_sel
1511 InsertPoints /M=0 dest, 1, attach_list, attach_sel
1512 attach_list[dest][kAttachColName] = name
1514 attach_sel[dest][kAttachColSel] = sel
1520 STRUCT WMButtonAction &ba
1522 switch( ba.eventCode )
1524 string logbook = GetUserData(ba.win, "", "logbook")
1525 ControlInfo /w=$ba.win lb_attach
1526 variable row = v_value
1527 dfref df = $s_datafolder
1528 wave /t /sdfr=df attach_list = $s_value
1529 if (cmpstr(ba.ctrlName, "b_attach_up") == 0)
1533 ListBox lb_attach, win=$ba.win, selRow=(row-1)
1537 if (row < DimSize(attach_list, 0) - 1)
1539 ListBox lb_attach, win=$ba.win, selRow=(row+1)
1551 static function bp_submit(ba) : ButtonControl
1552 STRUCT WMButtonAction &ba
1554 switch( ba.eventCode )
1556 string logbook = GetUserData(ba.win, "", "logbook")
1565 if (cmpstr(ba.ctrlName, "b_reply") == 0)
1567 ControlInfo /w=$ba.win sv_id
1576 result =
elog_create_entry(logbook, attributes, message, graphs=graphs, replyto=
id)
1579 svar /sdfr=df recent
1581 svar /sdfr=df recent_message
1582 recent_message = message
1584 abort "Submission failed. Error code " + num2str(result) + "."
1587 abort "Submission failed due to missing/invalid attribute."
1599 STRUCT WMButtonAction &ba
1601 switch( ba.eventCode )
1603 string graphs = WinName(0, 1, 1)
1615 STRUCT WMButtonAction &ba
1617 switch( ba.eventCode )
1619 string logbook = GetUserData(ba.win, "", "logbook")
1621 wave /sdfr=df_volatile attach_sel
1622 if (cmpstr(ba.ctrlName, "b_attach_all") == 0)
1623 attach_sel[][kAttachColSel] = attach_sel[p][kAttachColSel] | 16
1625 attach_sel[][kAttachColSel] = attach_sel[p][kAttachColSel] & ~16
1635 static function bp_attach(ba) : ButtonControl
1636 STRUCT WMButtonAction &ba
1638 switch( ba.eventCode )
1640 string logbook = GetUserData(ba.win, "", "logbook")
1645 ControlInfo /w=$ba.win sv_id
1649 DoAlert /T="ELOG" 1, "This operation will replace all existing attachments. Do you want to continue?"
1651 if ((
id > 0) && (v_flag == 1))
1655 abort "Submission failed. Error code " + num2str(result) + "."
1658 abort "Submission failed due to missing/invalid attribute."
1669 STRUCT WMButtonAction &ba
1671 switch( ba.eventCode )
1673 string logbook = GetUserData(ba.win, "", "logbook")
1675 variable ngraphs = ItemsInList(graphs, ";")
1680 for (igraph = 0; igraph < ngraphs; igraph += 1)
1681 sgraph = StringFromList(igraph, graphs, ";")
1683 if (strlen(graph_path) > 0)
1696 static function bp_clear(ba) : ButtonControl
1697 STRUCT WMButtonAction &ba
1699 switch( ba.eventCode )
1712 static function bp_login(ba) : ButtonControl
1713 STRUCT WMButtonAction &ba
1715 switch( ba.eventCode )
1717 string logbook = GetUserData(ba.win, "", "logbook")
1719 Button b_login, win=$ba.win, disable=3
1720 Button b_logout, win=$ba.win, disable=0
1730 static function bp_logout(ba) : ButtonControl
1731 STRUCT WMButtonAction &ba
1733 switch( ba.eventCode )
1735 string logbook = GetUserData(ba.win, "", "logbook")
1737 Button b_login, win=$ba.win, disable=0
1738 Button b_logout, win=$ba.win, disable=3
1749 windowname = StringFromList(0, WinList("*ElogPanel*", ";", "WIN:64"), ";")
1763 if (strlen(windowname) == 0)
1766 if (strlen(windowname) == 0)
1770 string controls = ControlNameList(windowname, ";")
1771 string attributes = ""
1775 variable nco = ItemsInList(controls, ";")
1776 for (ico = 0; ico < nco; ico += 1)
1777 control = StringFromList(ico, controls, ";")
1778 attribute = GetUserData(windowname, control, "attribute")
1779 if (strlen(attribute) > 0)
1780 ControlInfo /w=$windowname $control
1783 attributes = ReplaceNumberByKey(attribute, attributes, v_value, "=", ";")
1787 attributes = ReplaceStringByKey(attribute, attributes, s_value, "=", ";")
1812 if (strlen(windowname) == 0)
1815 if (strlen(windowname) == 0)
1818 if (ParamIsDefault(clear))
1824 string logbook = GetUserData(windowname, "", "logbook")
1826 string persistent_path = GetDataFolder(1, df_persistent)
1827 svar /sdfr=df_persistent options
1830 string controls = ControlNameList(windowname, ";")
1836 variable nco = ItemsInList(controls, ";")
1837 for (ico = 0; ico < nco; ico += 1)
1838 control = StringFromList(ico, controls, ";")
1839 attribute = GetUserData(windowname, control, "attribute")
1840 if (strlen(attribute))
1841 value = StringByKey(attribute, attributes, "=", ";")
1842 if (strlen(value) || clear)
1843 ControlInfo /w=$windowname $control
1846 numval = NumberByKey(attribute, attributes, "=", ";")
1847 if ((numtype(numval) != 0) && clear)
1850 if (numtype(numval) == 0)
1851 CheckBox $control, value=numval, win=$windowname
1855 options_path = persistent_path + StringByKey(attribute, options, "=", ";")
1856 svar values = $options_path
1857 numval = WhichListItem(value, values, ";") + 1
1859 PopupMenu $control, mode=numval, win=$windowname
1863 SetVariable /z $control, value= _STR:value, win=$windowname
1883 if (strlen(windowname) == 0)
1886 if (strlen(windowname) == 0)
1890 string nb = windowname + "
#Message" 1891 notebook $nb selection={startOfFile, endOfFile}
1892 getselection notebook, $nb, 2
1910 if (strlen(windowname) == 0)
1914 string nb = windowname + "
#Message" 1915 notebook $nb selection={startOfFile, endOfFile},text=message
1929 dfref savedf = getdatafolderdfr()
1930 if (strlen(windowname) == 0)
1933 if (strlen(windowname) == 0)
1937 string logbook = GetUserData(windowname, "", "logbook")
1939 wave /t /sdfr=df_volatile attach_list
1940 wave /sdfr=df_volatile attach_sel
1945 variable n = DimSize(attach_sel, 0)
1947 for (i = 0; i < n; i += 1)
1948 if (attach_sel[i][kAttachColSel] & 16)
1949 graphname = attach_list[i][kAttachColName]
1950 windows = WinList(graphname, ";", "WIN:1")
1951 if (ItemsInList(windows) == 1)
1952 graphs = AddListItem(graphname, graphs, ";", inf)
1970 if (strlen(windowname) == 0)
1973 if (strlen(windowname) == 0)
1977 string logbook = GetUserData(windowname, "", "logbook")
1980 wave /t /sdfr=df_volatile attach_list
1981 wave /sdfr=df_volatile attach_sel
1983 variable n = DimSize(attach_sel, 0)
1986 for (i = 0; i < n; i += 1)
1987 graphname = attach_list[i][kAttachColName]
1988 if (WhichListItem(graphname, graphs)>= 0)
1989 attach_sel[i][kAttachColSel] = 48
1991 attach_sel[i][kAttachColSel] = 32
variable elog_create_entry(string logbook, string attributes, string message, variable encoding=defaultValue, string graphs=defaultValue, variable replyto=defaultValue)
create a new entry in ELOG
static variable AfterFileOpenHook(variable refNum, string file, string pathName, string type, string creator, variable kind)
initialize the package and reload preferences after an experiment is loaded.
variable elog_add_attachment(string logbook, variable id, string graphs)
add one or more graphs to an existing ELOG entry
static const string package_path
static string get_panel_graphs(string windowname)
get the names of the graphs selected for attachment
static variable bp_attach_updown(WMButtonAction *ba)
button procedure for the attachment up and down buttons
static string create_message_file(string message)
save the message to a temporary text file
static variable parse_result()
parse the result file from an elog invokation.
variable elog_create_logbook(string name, string template=defaultValue)
create a new logbook.
static string set_panel_attributes(string windowname, string attributes, variable clear=defaultValue)
set the fields of the ELOG panel
static variable bp_logout(WMButtonAction *ba)
static string get_default_panel_name()
static variable elog_panel_hook(WMWinHookStruct *s)
variable elog_config(string elog_path=defaultValue, string hostname=defaultValue, variable port=defaultValue, string subdir=defaultValue)
set global module configuration parameters
interface for writing ELOG entries with Igor graphs as attachment.
static variable IgorBeforeNewHook(string igorApplicationNameStr)
save preferences and recent values before Igor opens a new experiment.
static string set_panel_graphs(string windowname, string graphs)
update selection of graphs for attachment
variable elog_init_pearl_templates()
setup PEARL template logbooks.
static string create_graph_file(string graphname, variable fileindex)
save a graph to a temporary graphics file
static const variable kAttachColName
static variable bp_clear(WMButtonAction *ba)
variable elog_login(string logbook, string username, string password)
set username and password for login to a logbook
static variable bp_attach_top(WMButtonAction *ba)
select top graph window for attachment
static const variable kAttachColSel
string PearlElogPanel(string logbook)
open a new panel for submitting data to ELOG.
variable elog_validate_attributes(string logbook, string attributes)
validate attributes
static string prepare_graph_attachments(string graphs)
prepare screenshots of graph windows for attachments
static string list_logbooks(variable templates=defaultValue)
get a list of configured logbooks or templates.
static variable bp_attach(WMButtonAction *ba)
static variable move_attach_item(string logbook, variable item, variable distance)
move an attachment item in the list of attachments
static dfr get_elog_df(string name, variable category)
get the package, logbook, or template datafolder.
string elog_prompt_logbook()
prompt to open or create a logbook
static variable bp_save_graphs(WMButtonAction *ba)
static variable update_attach_items(string logbook)
update the list of attachments
static variable bp_login(WMButtonAction *ba)
static const variable kdfVolatile
static const variable kdfTemplates
static string prepare_command_line(string logbook)
format the ELOG command and essential address arguments.
static variable cleanup_temp_files()
delete temporary files created by the ELOG module.
static string get_log_path()
static const variable kAttachColTitle
static const string elog_parse_id
static string get_panel_message(string windowname)
get the message field of the ELOG panel
static string create_cmd_file(string cmd)
write the command line to a file.
static variable init_volatile_vars()
initialize volatile variables.
static variable load_prefs()
load persistent package data from the preferences file.
static const variable kdfPersistent
static variable init_package(variable clean=defaultValue)
initialize the package data folder.
static variable save_prefs()
save persistent package data to the preferences file.
static const variable kdfRoot
variable elog_prompt_login(string logbook)
prompt the user for login to a logbook
static string set_panel_message(string windowname, string message)
set the message field of the ELOG panel
static variable IgorQuitHook(string igorApplicationNameStr)
save preferences and recent values before Igor quits.
static variable bp_submit(WMButtonAction *ba)
button procedure for the Submit and Reply buttons
static variable bp_attach_allnone(WMButtonAction *ba)
select/deselect all graph windows for attachment
static string get_panel_attributes(string windowname)
get a list of attributes from the fields of the ELOG panel.
static const string elog_success_msg
static string get_timestamp(string sep)
variable elog_logout(string logbook)
clear username and password of a logbook or all logbooks.
variable pearl_elog(string logbook)
main function to initialize ELOG and to open an ELOG panel.
static string format_url(string logbook)
format the URL for display to the user
static const string package_name