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
143 static variable
AfterFileOpenHook(variable refNum,
string file,
string pathName,
string type,
string creator, variable kind){
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()
270 setdatafolder df_templates
271 newdatafolder /o/s Experiments
275 string /g attributes =
"author;project;sample;source;task;technique;file;valid;" 278 string /g controls =
"sv_author;sv_project;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;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;sample;program;revision;machine;job;experiment;source path;result path;valid" 298 string /g controls =
"sv_author;sv_project;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" 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()
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()
425 dfref df_persistent_parent = df_persistent_root:logbooks
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 =
"" 473 variable
elog_config(
string elog_path = defaultValue,
string hostname = defaultValue, variable port = defaultValue,
string subdir = defaultValue){
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
513 variable
elog_login(
string logbook,
string username,
string password){
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)
685 variable
elog_create_entry(
string logbook,
string attributes,
string message, variable encoding = defaultValue,
string graphs = defaultValue, variable replyto = defaultValue){
693 if (ParamIsDefault(encoding))
696 if (ParamIsDefault(graphs))
699 if (ParamIsDefault(replyto))
703 dfref savedf = getdatafolderdfr()
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()
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." 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" 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)
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()
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
1302 TitleBox t_attach, win=$win_name, pos={308,5}, size={70,14}, title=
"Attachments", frame=0
1303 height = ypos - 21 - 4
1304 ListBox lb_attach, win=$win_name, pos={308,21}, size={264,height}
1305 ListBox lb_attach, win=$win_name, listWave=attach_list
1306 ListBox lb_attach, win=$win_name, mode=1, selWave=attach_sel, selRow=-1
1307 ListBox lb_attach, win=$win_name, widths={20,160,80}
1308 ListBox lb_attach, win=$win_name, help={
"Choose graphs to attach to the message."}
1310 Button b_attach_top, win=$win_name, pos={420,2}, size={40,18}, title=
"top" 1311 Button b_attach_top, win=$win_name, fcolor=(56576,60928,47872)
1313 Button b_attach_top, win=$win_name, help={
"Select top graph for attachment."}
1314 Button b_attach_all, win=$win_name, pos={460,2}, size={40,18}, title=
"all" 1315 Button b_attach_all, win=$win_name, fcolor=(56576,60928,47872)
1317 Button b_attach_all, win=$win_name, help={
"Select all graphs for attachment."}
1318 Button b_attach_none, win=$win_name, pos={500,2}, size={40,18}, title=
"none" 1319 Button b_attach_none, win=$win_name, fcolor=(56576,60928,47872)
1321 Button b_attach_none, win=$win_name, help={
"Deselect all attachments."}
1322 Button b_save_graphs, win=$win_name, pos={540,2}, size={40,18}, title=
"save" 1323 Button b_save_graphs, win=$win_name, fcolor=(56576,60928,47872)
1325 Button b_save_graphs, win=$win_name, help={
"Save selected graphs as PNG bitmap files."}
1326 Button b_attach_up, win=$win_name, pos={576,20}, size={20,20}, title=
"\\W517" 1327 Button b_attach_up, win=$win_name, fcolor=(56576,60928,47872)
1329 Button b_attach_up, win=$win_name, help={
"Move selected graph up."}
1330 Button b_attach_dw, win=$win_name, pos={576,40}, size={20,20}, title=
"\\W523" 1331 Button b_attach_dw, win=$win_name, fcolor=(56576,60928,47872)
1333 Button b_attach_dw, win=$win_name, help={
"Move selected graph down."}
1336 Button b_submit,win=$win_name, pos={70,ypos},size={46,20},proc=
PearlElog#
bp_submit,title=
"Submit" 1337 Button b_submit,win=$win_name, help={
"Submit form data to ELOG (new entry)."}
1338 Button b_submit,win=$win_name, fcolor=(56576,60928,47872)
1339 Button b_clear,win=$win_name, pos={120,ypos},size={46,20},proc=
PearlElog#
bp_clear,title=
"Clear" 1340 Button b_clear,win=$win_name, help={
"Clear the form fields"}
1341 Button b_clear,win=$win_name, fcolor=(56576,60928,47872)
1344 variable_path = volatile_path +
"msg_id" 1345 SetVariable sv_id,win=$win_name, pos={51,ypos},size={119,16},bodyWidth=77
1346 SetVariable sv_id,win=$win_name, title=
"ID",value=$variable_path
1347 SetVariable sv_id,win=$win_name, help={
"ID of last submitted message, or message to attach or reply to."}
1349 TitleBox t_host, win=$win_name, pos={170,ypos+4}, size={112.00,14.00}, frame=0
1350 TitleBox t_host, win=$win_name, variable=url
1353 Button b_attach,win=$win_name, pos={170,ypos},size={48,20},proc=
PearlElog#
bp_attach,title=
"Attach" 1354 Button b_attach,win=$win_name, help={
"Attach the selected graph to an existing ELOG entry (correct ID required)."}
1355 Button b_attach,win=$win_name, fcolor=(56576,60928,47872)
1356 Button b_reply,win=$win_name, pos={220,ypos},size={48,20},proc=
PearlElog#
bp_submit,title=
"Reply" 1357 Button b_reply,win=$win_name, help={
"Submit form data to ELOG as a reply to an existing message (correct ID required)."}
1358 Button b_reply,win=$win_name, fcolor=(56576,60928,47872)
1359 Button b_login,win=$win_name, pos={550,ypos},size={46,20},proc=
PearlElog#
bp_login,title=
"Login" 1360 Button b_login,win=$win_name, help={
"Enter user name and password."}
1361 Button b_login,win=$win_name, fcolor=(56576,60928,47872)
1362 Button b_logout,win=$win_name, pos={550,ypos},size={46,20},proc=
PearlElog#
bp_logout,title=
"Logout" 1363 Button b_logout,win=$win_name, help={
"Clear user name and password."}
1364 Button b_logout,win=$win_name, fcolor=(56576,60928,47872), disable=3
1367 SetWindow $win_name, userdata(logbook)=logbook
1370 TitleBox t_message,win=$win_name, pos={10,ypos},size={58,16},fixedSize=1,frame=0,anchor=RT,title=
"Message" 1371 DefineGuide UGH0={FT,ypos},UGV0={FL,70},UGH1={FB,-52},UGV1={FR,-2}
1372 NewNotebook /F=0 /N=Message /OPTS=3 /W=(115,404,345,341)/FG=(UGV0,UGH0,UGV1,UGH1) /HOST=#
1373 Notebook kwTopWin, defaultTab=20, statusWidth=0, autoSave=0
1374 Notebook kwTopWin fSize=10, fStyle=0, textRGB=(0,0,0)
1375 RenameWindow #,Message
1376 string nb_name = win_name +
"#Message" 1377 SetActiveSubwindow ##
1380 svar /z /sdfr=df_persistent recent
1381 if (svar_exists(recent) && (strlen(recent) > 0))
1384 svar /z /sdfr=df_persistent recent_message
1385 if (svar_exists(recent_message) && (strlen(recent_message) > 0))
1388 Notebook $nb_name selection={startOfFile,startOfFile}, findText={
"",1}
1390 setdatafolder savedf
1395 STRUCT WMWinHookStruct &s
1397 Variable hookResult = 0
1401 string logbook = GetUserData(s.winName,
"",
"logbook")
1402 if (strlen(logbook) > 0)
1404 svar /sdfr=df_volatile url
1411 variable b_top = s.winRect.bottom + 4
1412 Button b_submit,pos={70,b_top}
1413 Button b_clear,pos={120,b_top}
1414 TitleBox t_host, pos={170,b_top+4}
1416 Button b_attach,pos={170,b_top}
1417 Button b_reply,pos={220,b_top}
1418 Button b_login, pos={550,b_top}
1419 Button b_logout, pos={550,b_top}
1421 SetVariable sv_id,pos={51,b_top}
1436 dfref savedf = getdatafolderdfr()
1438 wave /t /sdfr=df_volatile attach_list
1439 wave /sdfr=df_volatile attach_sel
1441 if (!waveexists(attach_list))
1444 string names = WinList(
"*",
";",
"WIN:1;VISIBLE:1")
1445 names = SortList(names,
";", 16)
1450 variable n = DimSize(attach_list, 0)
1452 for (i = n-1; i >= 0; i -= 1)
1454 if (WhichListItem(s, names) < 0)
1455 DeletePoints /M=0 i, 1, attach_list, attach_sel
1460 n = ItemsInList(names)
1461 for (i = 0; i < n; i += 1)
1462 s = StringFromList(i, names)
1463 FindValue /text=s /txop=4 /z attach_list
1465 k = DimSize(attach_list, 0)
1466 Redimension /n=(k+1,3) attach_list, attach_sel
1478 n = DimSize(attach_list, 0)
1479 for (i = n-1; i >= 0; i -= 1)
1481 getwindow /z $s, wtitle
1489 setdatafolder savedf
1499 dfref savedf = getdatafolderdfr()
1501 wave /t /sdfr=df_volatile attach_list
1502 wave /sdfr=df_volatile attach_sel
1503 variable n = DimSize(attach_list, 0)
1504 variable dest = item + distance
1506 if ((item >= 0) && (item < n) && (dest >= 0) && (dest < n))
1509 DeletePoints /M=0 item, 1, attach_list, attach_sel
1510 InsertPoints /M=0 dest, 1, attach_list, attach_sel
1519 STRUCT WMButtonAction &ba
1521 switch( ba.eventCode )
1523 string logbook = GetUserData(ba.win,
"",
"logbook")
1524 ControlInfo /w=$ba.win lb_attach
1525 variable row = v_value
1526 dfref df = $s_datafolder
1527 wave /t /sdfr=df attach_list = $s_value
1528 if (cmpstr(ba.ctrlName,
"b_attach_up") == 0)
1532 ListBox lb_attach, win=$ba.win, selRow=(row-1)
1536 if (row < DimSize(attach_list, 0) - 1)
1538 ListBox lb_attach, win=$ba.win, selRow=(row+1)
1551 STRUCT WMButtonAction &ba
1553 switch( ba.eventCode )
1555 string logbook = GetUserData(ba.win,
"",
"logbook")
1564 if (cmpstr(ba.ctrlName,
"b_reply") == 0)
1566 ControlInfo /w=$ba.win sv_id
1575 result =
elog_create_entry(logbook, attributes, message, graphs=graphs, replyto=
id)
1578 svar /sdfr=df recent
1580 svar /sdfr=df recent_message
1581 recent_message = message
1583 abort
"Submission failed. Error code " + num2str(result) +
"." 1586 abort
"Submission failed due to missing/invalid attribute." 1598 STRUCT WMButtonAction &ba
1600 switch( ba.eventCode )
1602 string graphs = WinName(0, 1, 1)
1614 STRUCT WMButtonAction &ba
1616 switch( ba.eventCode )
1618 string logbook = GetUserData(ba.win,
"",
"logbook")
1620 wave /sdfr=df_volatile attach_sel
1621 if (cmpstr(ba.ctrlName,
"b_attach_all") == 0)
1635 STRUCT WMButtonAction &ba
1637 switch( ba.eventCode )
1639 string logbook = GetUserData(ba.win,
"",
"logbook")
1644 ControlInfo /w=$ba.win sv_id
1648 DoAlert /T=
"ELOG" 1,
"This operation will replace all existing attachments. Do you want to continue?" 1650 if ((
id > 0) && (v_flag == 1))
1654 abort
"Submission failed. Error code " + num2str(result) +
"." 1657 abort
"Submission failed due to missing/invalid attribute." 1668 STRUCT WMButtonAction &ba
1670 switch( ba.eventCode )
1672 string logbook = GetUserData(ba.win,
"",
"logbook")
1674 variable ngraphs = ItemsInList(graphs,
";")
1679 for (igraph = 0; igraph < ngraphs; igraph += 1)
1680 sgraph = StringFromList(igraph, graphs,
";")
1682 if (strlen(graph_path) > 0)
1696 STRUCT WMButtonAction &ba
1698 switch( ba.eventCode )
1712 STRUCT WMButtonAction &ba
1714 switch( ba.eventCode )
1716 string logbook = GetUserData(ba.win,
"",
"logbook")
1718 Button b_login, win=$ba.win, disable=3
1719 Button b_logout, win=$ba.win, disable=0
1730 STRUCT WMButtonAction &ba
1732 switch( ba.eventCode )
1734 string logbook = GetUserData(ba.win,
"",
"logbook")
1736 Button b_login, win=$ba.win, disable=0
1737 Button b_logout, win=$ba.win, disable=3
1748 windowname = StringFromList(0, WinList(
"*ElogPanel*",
";",
"WIN:64"),
";")
1762 if (strlen(windowname) == 0)
1765 if (strlen(windowname) == 0)
1769 string controls = ControlNameList(windowname,
";")
1770 string attributes =
"" 1774 variable nco = ItemsInList(controls,
";")
1775 for (ico = 0; ico < nco; ico += 1)
1776 control = StringFromList(ico, controls,
";")
1777 attribute = GetUserData(windowname, control,
"attribute")
1778 if (strlen(attribute) > 0)
1779 ControlInfo /w=$windowname $control
1782 attributes = ReplaceNumberByKey(attribute, attributes, v_value,
"=",
";")
1786 attributes = ReplaceStringByKey(attribute, attributes, s_value,
"=",
";")
1811 if (strlen(windowname) == 0)
1814 if (strlen(windowname) == 0)
1817 if (ParamIsDefault(clear))
1823 string controls = ControlNameList(windowname,
";")
1829 variable nco = ItemsInList(controls,
";")
1830 for (ico = 0; ico < nco; ico += 1)
1831 control = StringFromList(ico, controls,
";")
1832 attribute = GetUserData(windowname, control,
"attribute")
1833 if (strlen(attribute))
1834 value = StringByKey(attribute, attributes,
"=",
";")
1835 if (strlen(value) || clear)
1836 ControlInfo /w=$windowname $control
1839 numval = NumberByKey(attribute, attributes,
"=",
";")
1840 if ((numtype(numval) != 0) && clear)
1843 if (numtype(numval) == 0)
1844 CheckBox $control, value=numval, win=$windowname
1848 PopupMenu $control, popvalue=value, win=$windowname
1851 SetVariable /z $control, value= _STR:value, win=$windowname
1871 if (strlen(windowname) == 0)
1874 if (strlen(windowname) == 0)
1878 string nb = windowname +
"#Message" 1879 notebook $nb selection={startOfFile, endOfFile}
1880 getselection notebook, $nb, 2
1898 if (strlen(windowname) == 0)
1902 string nb = windowname +
"#Message" 1903 notebook $nb selection={startOfFile, endOfFile},text=message
1917 dfref savedf = getdatafolderdfr()
1918 if (strlen(windowname) == 0)
1921 if (strlen(windowname) == 0)
1925 string logbook = GetUserData(windowname,
"",
"logbook")
1927 wave /t /sdfr=df_volatile attach_list
1928 wave /sdfr=df_volatile attach_sel
1933 variable n = DimSize(attach_sel, 0)
1935 for (i = 0; i < n; i += 1)
1938 windows = WinList(graphname,
";",
"WIN:1")
1939 if (ItemsInList(windows) == 1)
1940 graphs = AddListItem(graphname, graphs,
";", inf)
1958 if (strlen(windowname) == 0)
1961 if (strlen(windowname) == 0)
1965 string logbook = GetUserData(windowname,
"",
"logbook")
1968 wave /t /sdfr=df_volatile attach_list
1969 wave /sdfr=df_volatile attach_sel
1971 variable n = DimSize(attach_sel, 0)
1974 for (i = 0; i < n; i += 1)
1976 if (WhichListItem(graphname, graphs)>= 0)
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