update pshell explorer and data import, misc. improvements
FEATURES - pshell: convert scienta data to true counts - pre-process: add gauss2_reduction data reduction function - anglescan: add set_contrast and normalize_strip_phi functions - explorer: show info about multi-region scans - documentation: add detailed instructions for angle-scan processing BUGFIXES - explorer: fix attributes notebook - pshell: fix progress bar - elog: increase the number of accepted attachments
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
|
||||
#pragma version = 1.40
|
||||
#pragma version = 1.41
|
||||
#pragma IgorVersion = 6.2
|
||||
#pragma ModuleName = PearlElog
|
||||
|
||||
// author: matthias.muntwiler@psi.ch
|
||||
// Copyright (c) 2013-16 Paul Scherrer Institut
|
||||
// Copyright (c) 2013-17 Paul Scherrer Institut
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -71,7 +71,7 @@
|
||||
///
|
||||
/// @author matthias muntwiler, matthias.muntwiler@psi.ch
|
||||
///
|
||||
/// @copyright 2013-16 Paul Scherrer Institut @n
|
||||
/// @copyright 2013-17 Paul Scherrer Institut @n
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License"); @n
|
||||
/// you may not use this file except in compliance with the License. @n
|
||||
/// You may obtain a copy of the License at
|
||||
@ -247,7 +247,7 @@ static function init_package([clean])
|
||||
variable /g port = 0 // 0 = unspecified (default)
|
||||
variable /g ssl = 0 // 0 = plain text (incl. passwords), 1 = secure connection
|
||||
string /g subdir = ""
|
||||
variable /g loglevel = 3
|
||||
variable /g loglevel = 4
|
||||
|
||||
setdatafolder savedf
|
||||
return 0
|
||||
@ -748,23 +748,27 @@ function elog_create_entry(logbook, attributes, message, [encoding, graphs, repl
|
||||
string messagefile = create_message_file(message)
|
||||
if (strlen(messagefile) > 0)
|
||||
cmd += " -m \"" + messagefile + "\""
|
||||
cmd += " > \"" + get_log_path() + "\""
|
||||
cmd += " > elog.log"
|
||||
if (loglevel >= 5)
|
||||
print cmd
|
||||
endif
|
||||
string cmd_file_path = create_cmd_file(cmd)
|
||||
ExecuteScriptText cmd_file_path
|
||||
variable id = parse_result()
|
||||
if (id > 0)
|
||||
msg_id = id
|
||||
if (loglevel >= 4)
|
||||
print "ELOG: sent message " + num2str(id)
|
||||
if (strlen(cmd_file_path) > 0)
|
||||
ExecuteScriptText cmd_file_path
|
||||
variable id = parse_result()
|
||||
if (id > 0)
|
||||
msg_id = id
|
||||
if (loglevel >= 4)
|
||||
print "ELOG: sent message " + num2str(id)
|
||||
endif
|
||||
else
|
||||
if (loglevel >= 2)
|
||||
print "ELOG: sending message failed."
|
||||
endif
|
||||
result = -4
|
||||
endif
|
||||
else
|
||||
if (loglevel >= 2)
|
||||
print "ELOG: sending message failed."
|
||||
endif
|
||||
result = -4
|
||||
result = -2
|
||||
endif
|
||||
else
|
||||
if (loglevel >= 2)
|
||||
@ -814,20 +818,24 @@ function elog_add_attachment(logbook, id, graphs)
|
||||
|
||||
if (result == 0)
|
||||
cmd += " " + cmd_graphs
|
||||
cmd += " > \"" + get_log_path() + "\""
|
||||
cmd += " > elog.log"
|
||||
string cmd_file_path = create_cmd_file(cmd)
|
||||
ExecuteScriptText cmd_file_path
|
||||
id = parse_result()
|
||||
if (id > 0)
|
||||
msg_id = id
|
||||
if (loglevel >= 4)
|
||||
print "ELOG: attached graphs to message " + num2str(id)
|
||||
if (strlen(cmd_file_path) > 0)
|
||||
ExecuteScriptText cmd_file_path
|
||||
id = parse_result()
|
||||
if (id > 0)
|
||||
msg_id = id
|
||||
if (loglevel >= 4)
|
||||
print "ELOG: attached graphs to message " + num2str(id)
|
||||
endif
|
||||
else
|
||||
if (loglevel >= 2)
|
||||
print "ELOG: failed to attach graphs."
|
||||
endif
|
||||
result = -4 // error: elog returned error
|
||||
endif
|
||||
else
|
||||
if (loglevel >= 2)
|
||||
print "ELOG: failed to attach graphs."
|
||||
endif
|
||||
result = -4 // error: elog returned error
|
||||
result = -2 // error: invalid command line
|
||||
endif
|
||||
endif
|
||||
|
||||
@ -923,7 +931,8 @@ end
|
||||
///
|
||||
/// prepares the attachment files from Igor graph windows
|
||||
/// and returns the arguments to the elog command to attach the files.
|
||||
/// the result string does not include leading or trailing space
|
||||
/// file names are returned without path.
|
||||
/// the result string does not include leading or trailing space.
|
||||
///
|
||||
/// @param graphs names of graph windows to be added as attachments, semicolon separated
|
||||
///
|
||||
@ -954,25 +963,63 @@ static function /s get_timestamp(sep)
|
||||
return dat + sep + tim
|
||||
end
|
||||
|
||||
/// save the message to a temporary text file
|
||||
///
|
||||
/// the file is saved to the Temporary directory returned by igor's SpecialDirPath function
|
||||
/// under the file name "elog_temp_message.txt".
|
||||
/// the function returns the name of the file (excluding path!)
|
||||
///
|
||||
/// @note percent characters (%) cannot be passed to elog.
|
||||
/// they are removed silently from the message.
|
||||
///
|
||||
/// @param message text message to save to the file.
|
||||
/// @return (string) name of the created file.
|
||||
/// empty string if unsuccessful.
|
||||
///
|
||||
/// @version 1.41 the return value has changed from full path to file name only
|
||||
/// due to the limited length of the command line (1024 bytes).
|
||||
///
|
||||
static function /s create_message_file(message)
|
||||
string message
|
||||
|
||||
message = ReplaceString("%", message, "")
|
||||
string path = SpecialDirPath("Temporary", 0, 1, 0)
|
||||
variable len = strlen(path)
|
||||
string filename
|
||||
|
||||
if (numtype(len) == 0)
|
||||
path += "elog_temp_message.txt"
|
||||
filename = "elog_temp_message.txt"
|
||||
path += filename
|
||||
variable f1
|
||||
Open f1 as path
|
||||
fprintf f1, message
|
||||
Close f1
|
||||
else
|
||||
path = ""
|
||||
filename = ""
|
||||
endif
|
||||
|
||||
return path
|
||||
return filename
|
||||
end
|
||||
|
||||
/// save a graph to a temporary graphics file
|
||||
///
|
||||
/// the file is saved to the Temporary directory returned by igor's SpecialDirPath function.
|
||||
/// the file name contains a time stamp and the specified file index to make it unique.
|
||||
/// the function returns the name of the file (excluding path!)
|
||||
///
|
||||
/// the full path is added to the temp_graph_files global list.
|
||||
/// a hook function will delete the files listed there when igor quits.
|
||||
///
|
||||
/// @param graphname object name of the graph to save.
|
||||
/// @param fileindex incrememtal index of the file within one submission.
|
||||
/// the file name is made unique by a time stamp and this file index.
|
||||
/// submissions within the same second must have a unique file index.
|
||||
/// @return (string) name of the created file.
|
||||
/// empty string if unsuccessful.
|
||||
///
|
||||
/// @version 1.41 the return value has changed from full path to file name only
|
||||
/// due to the limited length of the command line (1024 bytes).
|
||||
///
|
||||
static function /s create_graph_file(graphname, fileindex)
|
||||
string graphname
|
||||
variable fileindex
|
||||
@ -983,37 +1030,66 @@ static function /s create_graph_file(graphname, fileindex)
|
||||
string path = SpecialDirPath("Temporary", 0, 1, 0)
|
||||
string ts = get_timestamp("_")
|
||||
variable len = strlen(path)
|
||||
string filename
|
||||
|
||||
if (numtype(len) == 0)
|
||||
path += "elog_" + ts + "_" + num2str(fileindex) + ".png"
|
||||
filename = "elog_" + ts + "_" + num2str(fileindex) + ".png"
|
||||
path += filename
|
||||
SavePICT /B=72 /E=-5 /M /O /W=(0,0,8,6) /WIN=$graphname /Z as path
|
||||
if (v_flag == 0)
|
||||
temp_graph_files = AddListItem(path, temp_graph_files, ";", inf)
|
||||
else
|
||||
path = ""
|
||||
filename = ""
|
||||
endif
|
||||
else
|
||||
path = ""
|
||||
filename = ""
|
||||
endif
|
||||
|
||||
return path
|
||||
return filename
|
||||
end
|
||||
|
||||
/// write the command line to a file.
|
||||
///
|
||||
/// the command script changes the working directory to the Temporary directory.
|
||||
/// it also deletes a previous elog.log file.
|
||||
///
|
||||
/// @note somewhere the command line (even inside command files) is limited to 1024 bytes.
|
||||
/// for this reason all files should now be in the Temporary directory assigned by igor.
|
||||
///
|
||||
static function /s create_cmd_file(cmd)
|
||||
string cmd
|
||||
|
||||
string path = SpecialDirPath("Temporary", 0, 1, 0)
|
||||
variable len = strlen(path)
|
||||
dfref df_general = get_elog_df("", kdfPersistent)
|
||||
nvar /sdfr=df_general loglevel
|
||||
|
||||
if (strlen(cmd) >= 1024)
|
||||
if (loglevel >= 2)
|
||||
print "ELOG: command line too long (add fewer attachments)."
|
||||
endif
|
||||
return ""
|
||||
endif
|
||||
|
||||
string work_path = SpecialDirPath("Temporary", 0, 1, 0)
|
||||
variable len = strlen(work_path)
|
||||
if (numtype(len) == 0)
|
||||
path += "elog_temp_cmd.bat"
|
||||
string cmdx
|
||||
string cmd_path = work_path + "elog_temp_cmd.bat"
|
||||
|
||||
variable f1
|
||||
Open f1 as path
|
||||
Open f1 as cmd_path
|
||||
cmdx = "c:\r\n"
|
||||
fprintf f1, cmdx
|
||||
cmdx = "cd \"" + work_path + "\"\r\n"
|
||||
fprintf f1, cmdx
|
||||
cmdx = "del elog.log"
|
||||
fprintf f1, cmdx + "\r\n"
|
||||
fprintf f1, cmd
|
||||
Close f1
|
||||
else
|
||||
path = ""
|
||||
cmd_path = ""
|
||||
endif
|
||||
|
||||
return path
|
||||
return cmd_path
|
||||
end
|
||||
|
||||
static function /s get_log_path()
|
||||
|
Reference in New Issue
Block a user