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 = 3
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 ExecuteScriptText cmd_file_path
761 print
"ELOG: sent message " + num2str(
id)
765 print
"ELOG: sending message failed." 771 print
"ELOG: failed to create temporary message file." 793 dfref savedf = getdatafolderdfr()
798 nvar /sdfr=df_volatile msg_id
799 nvar /sdfr=df_general loglevel
802 if (strlen(cmd) == 0)
806 cmd +=
" -e " + num2str(
id)
810 if (strlen(cmd_graphs) == 0)
816 cmd +=
" " + cmd_graphs
819 ExecuteScriptText cmd_file_path
824 print
"ELOG: attached graphs to message " + num2str(
id)
828 print
"ELOG: failed to attach graphs." 852 svar /sdfr=df_general elog_path
853 svar /sdfr=df_general hostname
854 nvar /sdfr=df_general port
855 nvar /sdfr=df_general ssl
856 svar /sdfr=df_general subdir
857 nvar /sdfr=df_general loglevel
858 svar /sdfr=df_volatile username
859 svar /sdfr=df_volatile password
862 cmd =
"\"" + elog_path +
"\"" 866 cmd +=
" -h " + hostname
867 if ((nvar_exists(port)) && (port > 0))
868 cmd +=
" -p " + num2str(port)
870 if ((svar_exists(subdir)) && (strlen(subdir) > 0))
871 cmd +=
" -d " + subdir
873 cmd +=
" -l \"" + logbook +
"\"" 874 if ((nvar_exists(ssl)) && (ssl != 0))
878 if (svar_exists(username) && svar_exists(password) && (strlen(username) > 0) && (strlen(password) > 0))
879 cmd +=
" -u " + username +
" " + password
899 svar /sdfr=df_general hostname
900 nvar /sdfr=df_general port
901 nvar /sdfr=df_general ssl
902 svar /sdfr=df_general subdir
905 if ((nvar_exists(ssl)) && (ssl != 0))
911 if ((nvar_exists(port)) && (port > 0))
912 cmd +=
":" + num2str(port)
914 if ((svar_exists(subdir)) && (strlen(subdir) > 0))
934 variable ngraphs = ItemsInList(graphs,
";")
938 for (igraph = 0; igraph < ngraphs; igraph += 1)
939 sgraph = StringFromList(igraph, graphs,
";")
941 if (strlen(graph_path) > 0)
942 cmd +=
" -f \"" + graph_path +
"\"" 951 Variable now = DateTime
952 string dat = ReplaceString(
"-", Secs2Date(DateTime, -2),
"")
953 string tim = ReplaceString(
":", Secs2Time(DateTime, 3),
"")
954 return dat + sep + tim
960 message = ReplaceString(
"%", message,
"")
961 string path = SpecialDirPath(
"Temporary", 0, 1, 0)
962 variable len = strlen(path)
963 if (numtype(len) == 0)
964 path +=
"elog_temp_message.txt" 981 svar /sdfr=df_volatile_root temp_graph_files
983 string path = SpecialDirPath(
"Temporary", 0, 1, 0)
985 variable len = strlen(path)
986 if (numtype(len) == 0)
987 path +=
"elog_" + ts +
"_" + num2str(fileindex) +
".png" 988 SavePICT /B=72 /E=-5 /M /O /W=(0,0,8,6) /WIN=$graphname /Z as path
990 temp_graph_files = AddListItem(path, temp_graph_files,
";", inf)
1004 string path = SpecialDirPath(
"Temporary", 0, 1, 0)
1005 variable len = strlen(path)
1006 if (numtype(len) == 0)
1007 path +=
"elog_temp_cmd.bat" 1020 string path = SpecialDirPath(
"Temporary", 0, 1, 0)
1021 variable len = strlen(path)
1022 if (numtype(len) == 0)
1041 if (DataFolderRefStatus(df_volatile_root))
1042 svar /sdfr=df_volatile_root /z temp_graph_files
1043 if (SVAR_Exists(temp_graph_files))
1044 variable nfi = ItemsInList(temp_graph_files)
1047 for (ifi = 0; ifi < nfi; ifi += 1)
1048 sfi = StringFromList(ifi, temp_graph_files)
1051 temp_graph_files =
"" 1067 nvar /sdfr=df_general loglevel
1072 variable success = 0
1077 variable len = strlen(path)
1078 if (numtype(len) == 0)
1080 Open /R/Z f1 as path
1084 if (strlen(line) > 0)
1085 part1 = StringFromList(0, line,
",")
1086 part2 = ReplaceString(
" ", StringFromList(1, line,
","),
"")
1110 logbooks = AddListItem(
"(new)", logbooks)
1112 templates = AddListItem(
"(none)", templates)
1114 string logbook = StringFromList(0, logbooks)
1115 string template = StringFromList(0, logbooks)
1117 string username =
"" 1118 string password =
"" 1120 prompt logbook,
"logbook", popup logbooks
1121 prompt
template,
"template", popup templates
1122 prompt name,
"new logbook name" 1124 doprompt
"select logbook", logbook,
template, name
1126 if (cmpstr(logbook,
"(new)") == 0)
1143 string username =
"" 1144 string password =
"" 1146 prompt logbook,
"logbook", popup logbooks
1147 prompt username,
"user name" 1148 prompt password,
"password (blank to log out)" 1150 doprompt
"log in to logbook", logbook, username, password
1168 dfref savedf = getdatafolderdfr()
1173 string win_name = logbook +
"ElogPanel" 1174 string win_title =
"ELOG " + logbook
1176 NewPanel /K=1 /N=$win_name /W=(600,200,1200,700) as win_title
1178 ModifyPanel /w=$win_name cbRGB=(52224,52224,65280)
1180 svar /sdfr=df_persistent attributes
1181 svar /sdfr=df_persistent controls
1182 svar /sdfr=df_persistent options
1183 wave /t /sdfr=df_volatile attach_list
1184 wave /sdfr=df_volatile attach_sel
1185 svar /sdfr=df_volatile url
1188 variable nattr = ItemsInList(attributes,
";")
1192 string persistent_path = GetDataFolder(1, df_persistent)
1193 string volatile_path = GetDataFolder(1, df_volatile)
1195 string variable_path
1199 for (iattr = 0; iattr < nattr; iattr += 1)
1200 s_attr = StringFromList(iattr, attributes,
";")
1201 s_control = StringFromList(iattr, controls,
";")
1202 strswitch(s_control[0,1])
1204 SetVariable $s_control, win=$win_name, pos={0,ypos}, size={300,16}, bodyWidth=230
1205 SetVariable $s_control, win=$win_name, title=s_attr, value= _STR:
"" 1206 SetVariable $s_control, win=$win_name, userdata(attribute)=s_attr
1210 options_path = persistent_path + StringByKey(s_attr, options,
"=",
";")
1211 PopupMenu $s_control, win=$win_name, pos={0,ypos}, size={300,21}, bodyWidth=230
1212 PopupMenu $s_control, win=$win_name, title=s_attr
1213 PopupMenu $s_control, win=$win_name, mode=1, popvalue=
"Test", value= #options_path
1214 PopupMenu $s_control, win=$win_name, userdata(attribute)=s_attr
1218 CheckBox $s_control, win=$win_name, pos={70,ypos}, size={300,14}
1219 CheckBox $s_control, win=$win_name, title=s_attr, value= 1
1220 CheckBox $s_control, win=$win_name, userdata(attribute)=s_attr
1226 TitleBox t_attach, win=$win_name, pos={308,5}, size={70,14}, title=
"Attachments", frame=0
1227 height = ypos - 21 - 4
1228 ListBox lb_attach, win=$win_name, pos={308,21}, size={264,height}
1229 ListBox lb_attach, win=$win_name, listWave=attach_list
1230 ListBox lb_attach, win=$win_name, mode=1, selWave=attach_sel, selRow=-1
1231 ListBox lb_attach, win=$win_name, widths={20,160,80}
1232 ListBox lb_attach, win=$win_name, help={
"Choose graphs to attach to the message."}
1234 Button b_attach_top, win=$win_name, pos={420,2}, size={40,18}, title=
"top" 1235 Button b_attach_top, win=$win_name, fcolor=(56576,60928,47872)
1237 Button b_attach_top, win=$win_name, help={
"Select top graph for attachment."}
1238 Button b_attach_all, win=$win_name, pos={460,2}, size={40,18}, title=
"all" 1239 Button b_attach_all, win=$win_name, fcolor=(56576,60928,47872)
1241 Button b_attach_all, win=$win_name, help={
"Select all graphs for attachment."}
1242 Button b_attach_none, win=$win_name, pos={500,2}, size={40,18}, title=
"none" 1243 Button b_attach_none, win=$win_name, fcolor=(56576,60928,47872)
1245 Button b_attach_none, win=$win_name, help={
"Deselect all attachments."}
1246 Button b_save_graphs, win=$win_name, pos={540,2}, size={40,18}, title=
"save" 1247 Button b_save_graphs, win=$win_name, fcolor=(56576,60928,47872)
1249 Button b_save_graphs, win=$win_name, help={
"Save selected graphs as PNG bitmap files."}
1250 Button b_attach_up, win=$win_name, pos={576,20}, size={20,20}, title=
"\\W517" 1251 Button b_attach_up, win=$win_name, fcolor=(56576,60928,47872)
1253 Button b_attach_up, win=$win_name, help={
"Move selected graph up."}
1254 Button b_attach_dw, win=$win_name, pos={576,40}, size={20,20}, title=
"\\W523" 1255 Button b_attach_dw, win=$win_name, fcolor=(56576,60928,47872)
1257 Button b_attach_dw, win=$win_name, help={
"Move selected graph down."}
1260 Button b_submit,win=$win_name, pos={70,ypos},size={46,20},proc=
PearlElog#
bp_submit,title=
"Submit" 1261 Button b_submit,win=$win_name, help={
"Submit form data to ELOG (new entry)."}
1262 Button b_submit,win=$win_name, fcolor=(56576,60928,47872)
1263 Button b_clear,win=$win_name, pos={120,ypos},size={46,20},proc=
PearlElog#
bp_clear,title=
"Clear" 1264 Button b_clear,win=$win_name, help={
"Clear the form fields"}
1265 Button b_clear,win=$win_name, fcolor=(56576,60928,47872)
1268 variable_path = volatile_path +
"msg_id" 1269 SetVariable sv_id,win=$win_name, pos={51,ypos},size={119,16},bodyWidth=77
1270 SetVariable sv_id,win=$win_name, title=
"ID",value=$variable_path
1271 SetVariable sv_id,win=$win_name, help={
"ID of last submitted message, or message to attach or reply to."}
1273 TitleBox t_host, win=$win_name, pos={170,ypos+4}, size={112.00,14.00}, frame=0
1274 TitleBox t_host, win=$win_name, variable=url
1277 Button b_attach,win=$win_name, pos={170,ypos},size={48,20},proc=
PearlElog#
bp_attach,title=
"Attach" 1278 Button b_attach,win=$win_name, help={
"Attach the selected graph to an existing ELOG entry (correct ID required)."}
1279 Button b_attach,win=$win_name, fcolor=(56576,60928,47872)
1280 Button b_reply,win=$win_name, pos={220,ypos},size={48,20},proc=
PearlElog#
bp_submit,title=
"Reply" 1281 Button b_reply,win=$win_name, help={
"Submit form data to ELOG as a reply to an existing message (correct ID required)."}
1282 Button b_reply,win=$win_name, fcolor=(56576,60928,47872)
1283 Button b_login,win=$win_name, pos={550,ypos},size={46,20},proc=
PearlElog#
bp_login,title=
"Login" 1284 Button b_login,win=$win_name, help={
"Enter user name and password."}
1285 Button b_login,win=$win_name, fcolor=(56576,60928,47872)
1286 Button b_logout,win=$win_name, pos={550,ypos},size={46,20},proc=
PearlElog#
bp_logout,title=
"Logout" 1287 Button b_logout,win=$win_name, help={
"Clear user name and password."}
1288 Button b_logout,win=$win_name, fcolor=(56576,60928,47872), disable=3
1291 SetWindow $win_name, userdata(logbook)=logbook
1294 TitleBox t_message,win=$win_name, pos={10,ypos},size={58,16},fixedSize=1,frame=0,anchor=RT,title=
"Message" 1295 DefineGuide UGH0={FT,ypos},UGV0={FL,70},UGH1={FB,-52},UGV1={FR,-2}
1296 NewNotebook /F=0 /N=Message /OPTS=3 /W=(115,404,345,341)/FG=(UGV0,UGH0,UGV1,UGH1) /HOST=#
1297 Notebook kwTopWin, defaultTab=20, statusWidth=0, autoSave=0
1298 Notebook kwTopWin fSize=10, fStyle=0, textRGB=(0,0,0)
1299 RenameWindow #,Message
1300 string nb_name = win_name +
"#Message" 1301 SetActiveSubwindow ##
1304 svar /z /sdfr=df_persistent recent
1305 if (svar_exists(recent) && (strlen(recent) > 0))
1308 svar /z /sdfr=df_persistent recent_message
1309 if (svar_exists(recent_message) && (strlen(recent_message) > 0))
1312 Notebook $nb_name selection={startOfFile,startOfFile}, findText={
"",1}
1314 setdatafolder savedf
1319 STRUCT WMWinHookStruct &s
1321 Variable hookResult = 0
1325 string logbook = GetUserData(s.winName,
"",
"logbook")
1326 if (strlen(logbook) > 0)
1328 svar /sdfr=df_volatile url
1335 variable b_top = s.winRect.bottom + 4
1336 Button b_submit,pos={70,b_top}
1337 Button b_clear,pos={120,b_top}
1338 TitleBox t_host, pos={170,b_top+4}
1340 Button b_attach,pos={170,b_top}
1341 Button b_reply,pos={220,b_top}
1342 Button b_login, pos={550,b_top}
1343 Button b_logout, pos={550,b_top}
1345 SetVariable sv_id,pos={51,b_top}
1360 dfref savedf = getdatafolderdfr()
1362 wave /t /sdfr=df_volatile attach_list
1363 wave /sdfr=df_volatile attach_sel
1365 if (!waveexists(attach_list))
1368 string names = WinList(
"*",
";",
"WIN:1;VISIBLE:1")
1369 names = SortList(names,
";", 16)
1374 variable n = DimSize(attach_list, 0)
1376 for (i = n-1; i >= 0; i -= 1)
1378 if (WhichListItem(s, names) < 0)
1379 DeletePoints /M=0 i, 1, attach_list, attach_sel
1384 n = ItemsInList(names)
1385 for (i = 0; i < n; i += 1)
1386 s = StringFromList(i, names)
1387 FindValue /text=s /txop=4 /z attach_list
1389 k = DimSize(attach_list, 0)
1390 Redimension /n=(k+1,3) attach_list, attach_sel
1402 n = DimSize(attach_list, 0)
1403 for (i = n-1; i >= 0; i -= 1)
1405 getwindow /z $s, wtitle
1413 setdatafolder savedf
1423 dfref savedf = getdatafolderdfr()
1425 wave /t /sdfr=df_volatile attach_list
1426 wave /sdfr=df_volatile attach_sel
1427 variable n = DimSize(attach_list, 0)
1428 variable dest = item + distance
1430 if ((item >= 0) && (item < n) && (dest >= 0) && (dest < n))
1433 DeletePoints /M=0 item, 1, attach_list, attach_sel
1434 InsertPoints /M=0 dest, 1, attach_list, attach_sel
1443 STRUCT WMButtonAction &ba
1445 switch( ba.eventCode )
1447 string logbook = GetUserData(ba.win,
"",
"logbook")
1448 ControlInfo /w=$ba.win lb_attach
1449 variable row = v_value
1450 dfref df = $s_datafolder
1451 wave /t /sdfr=df attach_list = $s_value
1452 if (cmpstr(ba.ctrlName,
"b_attach_up") == 0)
1456 ListBox lb_attach, win=$ba.win, selRow=(row-1)
1460 if (row < DimSize(attach_list, 0) - 1)
1462 ListBox lb_attach, win=$ba.win, selRow=(row+1)
1475 STRUCT WMButtonAction &ba
1477 switch( ba.eventCode )
1479 string logbook = GetUserData(ba.win,
"",
"logbook")
1488 if (cmpstr(ba.ctrlName,
"b_reply") == 0)
1490 ControlInfo /w=$ba.win sv_id
1499 result =
elog_create_entry(logbook, attributes, message, graphs=graphs, replyto=
id)
1502 svar /sdfr=df recent
1504 svar /sdfr=df recent_message
1505 recent_message = message
1507 abort
"Submission failed. Error code " + num2str(result) +
"." 1510 abort
"Submission failed due to missing/invalid attribute." 1522 STRUCT WMButtonAction &ba
1524 switch( ba.eventCode )
1526 string graphs = WinName(0, 1, 1)
1538 STRUCT WMButtonAction &ba
1540 switch( ba.eventCode )
1542 string logbook = GetUserData(ba.win,
"",
"logbook")
1544 wave /sdfr=df_volatile attach_sel
1545 if (cmpstr(ba.ctrlName,
"b_attach_all") == 0)
1559 STRUCT WMButtonAction &ba
1561 switch( ba.eventCode )
1563 string logbook = GetUserData(ba.win,
"",
"logbook")
1568 ControlInfo /w=$ba.win sv_id
1572 DoAlert /T=
"ELOG" 1,
"This operation will replace all existing attachments. Do you want to continue?" 1574 if ((
id > 0) && (v_flag == 1))
1578 abort
"Submission failed. Error code " + num2str(result) +
"." 1581 abort
"Submission failed due to missing/invalid attribute." 1592 STRUCT WMButtonAction &ba
1594 switch( ba.eventCode )
1596 string logbook = GetUserData(ba.win,
"",
"logbook")
1598 variable ngraphs = ItemsInList(graphs,
";")
1603 for (igraph = 0; igraph < ngraphs; igraph += 1)
1604 sgraph = StringFromList(igraph, graphs,
";")
1606 if (strlen(graph_path) > 0)
1620 STRUCT WMButtonAction &ba
1622 switch( ba.eventCode )
1636 STRUCT WMButtonAction &ba
1638 switch( ba.eventCode )
1640 string logbook = GetUserData(ba.win,
"",
"logbook")
1642 Button b_login, win=$ba.win, disable=3
1643 Button b_logout, win=$ba.win, disable=0
1654 STRUCT WMButtonAction &ba
1656 switch( ba.eventCode )
1658 string logbook = GetUserData(ba.win,
"",
"logbook")
1660 Button b_login, win=$ba.win, disable=0
1661 Button b_logout, win=$ba.win, disable=3
1672 windowname = StringFromList(0, WinList(
"*ElogPanel*",
";",
"WIN:64"),
";")
1686 if (strlen(windowname) == 0)
1689 if (strlen(windowname) == 0)
1693 string controls = ControlNameList(windowname,
";")
1694 string attributes =
"" 1698 variable nco = ItemsInList(controls,
";")
1699 for (ico = 0; ico < nco; ico += 1)
1700 control = StringFromList(ico, controls,
";")
1701 attribute = GetUserData(windowname, control,
"attribute")
1702 if (strlen(attribute) > 0)
1703 ControlInfo /w=$windowname $control
1706 attributes = ReplaceNumberByKey(attribute, attributes, v_value,
"=",
";")
1710 attributes = ReplaceStringByKey(attribute, attributes, s_value,
"=",
";")
1735 if (strlen(windowname) == 0)
1738 if (strlen(windowname) == 0)
1741 if (ParamIsDefault(clear))
1747 string controls = ControlNameList(windowname,
";")
1753 variable nco = ItemsInList(controls,
";")
1754 for (ico = 0; ico < nco; ico += 1)
1755 control = StringFromList(ico, controls,
";")
1756 attribute = GetUserData(windowname, control,
"attribute")
1757 if (strlen(attribute))
1758 value = StringByKey(attribute, attributes,
"=",
";")
1759 if (strlen(value) || clear)
1760 ControlInfo /w=$windowname $control
1763 numval = NumberByKey(attribute, attributes,
"=",
";")
1764 if ((numtype(numval) != 0) && clear)
1767 if (numtype(numval) == 0)
1768 CheckBox $control, value=numval, win=$windowname
1772 PopupMenu $control, popvalue=value, win=$windowname
1775 SetVariable /z $control, value= _STR:value, win=$windowname
1795 if (strlen(windowname) == 0)
1798 if (strlen(windowname) == 0)
1802 string nb = windowname +
"#Message" 1803 notebook $nb selection={startOfFile, endOfFile}
1804 getselection notebook, $nb, 2
1822 if (strlen(windowname) == 0)
1826 string nb = windowname +
"#Message" 1827 notebook $nb selection={startOfFile, endOfFile},text=message
1841 dfref savedf = getdatafolderdfr()
1842 if (strlen(windowname) == 0)
1845 if (strlen(windowname) == 0)
1849 string logbook = GetUserData(windowname,
"",
"logbook")
1851 wave /t /sdfr=df_volatile attach_list
1852 wave /sdfr=df_volatile attach_sel
1857 variable n = DimSize(attach_sel, 0)
1859 for (i = 0; i < n; i += 1)
1862 windows = WinList(graphname,
";",
"WIN:1")
1863 if (ItemsInList(windows) == 1)
1864 graphs = AddListItem(graphname, graphs,
";", inf)
1882 if (strlen(windowname) == 0)
1885 if (strlen(windowname) == 0)
1889 string logbook = GetUserData(windowname,
"",
"logbook")
1892 wave /t /sdfr=df_volatile attach_list
1893 wave /sdfr=df_volatile attach_sel
1895 variable n = DimSize(attach_sel, 0)
1898 for (i = 0; i < n; i += 1)
1900 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)
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)
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)
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