24 start(crpt, create_empty);
29 throw std::runtime_error(
"not implemented");
38 std::vector<int> ev_source_ids;
57 Poco::Thread::sleep(500);
75 if ( close_file && (
m_file != NULL) )
119 if ( !Poco::Util::Application::instance().config().getBool(
"isisicp.incrementaleventnexus",
false) )
130 NXsetcache(64*1024*1024);
137 std::vector<int> ev_source_ids;
142 std::list<boost::signals2::connection> cb;
154 if ( !Poco::Util::Application::instance().config().getBool(
"isisicp.incrementaleventnexus",
false) )
189 static std::string app_dir = Poco::Util::Application::instance().config().getString(
"application.dir");
190 static std::string shadow_user = Poco::Util::Application::instance().config().getString(
"isisicp.shadow.user");
191 static std::string shadow_pass = Poco::Util::Application::instance().config().getString(
"isisicp.shadow.pass");
192 static std::string shadow_snapvol = Poco::Util::Application::instance().config().getString(
"isisicp.shadow.snapvolume");
193 static std::string shadow_copydir = Poco::Util::Application::instance().config().getString(
"isisicp.shadow.copydir");
194 static std::string shadow_prog_name = Poco::Util::Application::instance().config().getString(
"isisicp.shadow.progname");
195 static std::string shadow_dir = Poco::Util::Application::instance().config().getString(
"isisicp.shadow.dir");
196 static std::string comspec = getenv(
"ComSpec");
197 static std::string tmpdir = getenv(
"TEMP");
198 static std::string script_name = Poco::Path(tmpdir,
"isisicp_shadow.cmd").toString(Poco::Path::PATH_WINDOWS);
204 if ( !Poco::File(shadow_dir).exists() )
206 LOGSTR_ERROR(
"Shadow Directory \"" << shadow_dir <<
"\" does not exist");
210 Poco::Path shadow_prog_path(app_dir, shadow_prog_name);
211 shadow_prog_path.pushDirectory(
"..");
212 std::string shadow_prog = shadow_prog_path.toString(Poco::Path::PATH_WINDOWS);
213 DWORD len_comp_name = MAX_COMPUTERNAME_LENGTH + 1;
214 wchar_t comp_name[MAX_COMPUTERNAME_LENGTH + 1];
215 GetComputerNameW(comp_name, &len_comp_name);
216 comp_name[len_comp_name] =
'\0';
217 PROCESS_INFORMATION pi = {0};
218 STARTUPINFO si = {0};
219 STARTUPINFOW siw = {0};
220 ZeroMemory( &si,
sizeof(si) );
221 ZeroMemory( &siw,
sizeof(siw) );
222 ZeroMemory( &pi,
sizeof(pi) );
226 siw.cb =
sizeof(siw);
231 std::string command_line_s = Poco::format(
"\"%s\" /k \"\"%s\" -tracing -nw -p -script=\"%s\" \"%s\"\"", comspec,
232 shadow_prog, script_name, shadow_snapvol);
233 char* command_line = strdup(command_line_s.c_str());
236 if (shadow_user.size() == 0)
238 res = CreateProcess(NULL, command_line, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi);
242 res = CreateProcessWithLogonW(CT2OLE(shadow_user.c_str()), comp_name, CT2OLE(shadow_pass.c_str()),
243 0, NULL, CT2OLE(command_line), 0, NULL, NULL, &siw, &pi);
252 WaitForSingleObject( pi.hProcess, INFINITE );
253 CloseHandle(pi.hProcess);
254 CloseHandle(pi.hThread);
256 ZeroMemory( &si,
sizeof(si) );
257 ZeroMemory( &siw,
sizeof(siw) );
258 ZeroMemory( &pi,
sizeof(pi) );
262 siw.cb =
sizeof(siw);
266 f.open(script_name, std::ios::app);
267 f <<
"\"" << shadow_prog <<
"\" -tracing -el=%SHADOW_ID_1%,\"" << shadow_dir <<
"\"" << std::endl;
269 Poco::Path ff(shadow_dir, fn.getFileName());
270 ff.pushDirectory(shadow_copydir);
271 f <<
"COPY /B /Y \"" << ff.toString() <<
"\" \"" << name <<
"\"" << std::endl;
272 f <<
"\"" << shadow_prog <<
"\" -tracing -ds=%SHADOW_ID_1%" << std::endl;
274 command_line_s = Poco::format(
"\"%s\" /k \"%s\"", comspec, script_name);
275 command_line = strdup(command_line_s.c_str());
276 if (shadow_user.size() == 0)
278 res = CreateProcess(NULL, command_line, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi);
282 res = CreateProcessWithLogonW(CT2OLE(shadow_user.c_str()), comp_name, CT2OLE(shadow_pass.c_str()),
283 0, NULL, CT2OLE(command_line), 0, NULL, NULL, &siw, &pi);
289 remove(script_name.c_str());
292 WaitForSingleObject( pi.hProcess, INFINITE );
293 CloseHandle(pi.hProcess);
294 CloseHandle(pi.hThread);
295 remove(script_name.c_str());
300 static std::string app_dir = Poco::Util::Application::instance().config().getString(
"application.dir");
301 static std::string shadow_user = Poco::Util::Application::instance().config().getString(
"isisicp.shadow.user");
302 static std::string shadow_pass = Poco::Util::Application::instance().config().getString(
"isisicp.shadow.pass");
303 static std::string shadow_prog_name = Poco::Util::Application::instance().config().getString(
"isisicp.shadow.progname");
304 static std::string shadow_dir = Poco::Util::Application::instance().config().getString(
"isisicp.shadow.dir");
305 static std::string comspec = getenv(
"ComSpec");
306 static std::string tmpdir = getenv(
"TEMP");
307 static std::string script_name = Poco::Path(tmpdir,
"isisicp_shadow.cmd").toString(Poco::Path::PATH_WINDOWS);
313 if ( !Poco::File(shadow_dir).exists() )
315 LOGSTR_ERROR(
"Shadow Directory \"" << shadow_dir <<
"\" does not exist");
319 Poco::Path shadow_prog_path(app_dir, shadow_prog_name);
320 shadow_prog_path.pushDirectory(
"..");
321 std::string shadow_prog = shadow_prog_path.toString(Poco::Path::PATH_WINDOWS);
322 DWORD len_comp_name = MAX_COMPUTERNAME_LENGTH + 1;
323 wchar_t comp_name[MAX_COMPUTERNAME_LENGTH + 1];
324 GetComputerNameW(comp_name, &len_comp_name);
325 comp_name[len_comp_name] =
'\0';
326 PROCESS_INFORMATION pi = {0};
327 STARTUPINFO si = {0};
328 STARTUPINFOW siw = {0};
329 ZeroMemory( &si,
sizeof(si) );
330 ZeroMemory( &siw,
sizeof(siw) );
331 ZeroMemory( &pi,
sizeof(pi) );
335 siw.cb =
sizeof(siw);
341 std::string filename_base(src_dir.getFileName());
342 src_dir.setFileName(
"");
343 Poco::Path dest_filename(shadow_dir, filename_base);
346 f.open(script_name, std::ios::out | std::ios::trunc);
347 f <<
"REM \"" << shadow_prog <<
"\" /full \"" << src_dir.toString() <<
"\" \"" << shadow_dir <<
"\" \"" << filename_base <<
"\"" << std::endl;
349 f <<
"REM REN \"" << dest_filename.toString() <<
"\" \"" << name <<
"\"" << std::endl;
351 std::string command_line_s = Poco::format(
"\"%s\" /k \"%s\"", comspec, script_name);
352 char* command_line = strdup(command_line_s.c_str());
355 if (shadow_user.size() == 0)
357 res = CreateProcess(NULL, command_line, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi);
361 res = CreateProcessWithLogonW(CT2OLE(shadow_user.c_str()), comp_name, CT2OLE(shadow_pass.c_str()),
362 0, NULL, CT2OLE(command_line), 0, NULL, NULL, &siw, &pi);
369 remove(script_name.c_str());
372 WaitForSingleObject( pi.hProcess, INFINITE );
373 CloseHandle(pi.hProcess);
374 CloseHandle(pi.hThread);
376 remove(script_name.c_str());
void allEventCallback(const DAEEventHeader *head, const DetectorEvent32 *det_ev, int n, int event_source_id, const int *mapping)
void noFrameCallbackNull(bool end_present, NoFrameCallbackMode mode, int event_source_id)
void start(const ISISCRPT_STRUCT *crpt, IXNeXusFile *file, bool create_empty)
static void nxErrorFunc(void *arg, char *text)
int addVa(int facility, int severity, int errtype, const char *format,...)
virtual void stop(bool close_file)
void stop(bool delete_file=false)
void createEmptyFileStructure()
int open(const char *filename, int mode, int type=IXNeXusFile::HDF5)
int makeNewGroup(const char *name, const char *nxclass, bool open_group=true)
void getEnabledEventSourceIDs(std::vector< int > &ids)
void snapshotOld(const std::string &name)
void getEnabledEventSourceIDs(std::vector< int > &ids)
void allFrameCallback(const DAEEventHeader *head, int event_source_id)
this will get called for each frame for EACH event source
int compression_block_size
#define LOGSTR_WARNING(__arg)
std::string padWithZeros(int number, int len)
std::list< boost::signals2::connection > addAllEventCallback(const EventCallbackSlotType &slot)
void stop(bool immediate)
std::list< boost::signals2::connection > addAllFrameCallback(const FrameCallbackSlotType &slot)
void setSpectraChunkSize(int nsp)
void clearCallbacks(const std::list< boost::signals2::connection > &callback_list)
void snapshot(const std::string &name)
#define LOGSTR_INFORMATION(__arg)
#define LOGSTR_ERROR(__arg)
std::list< boost::signals2::connection > addAllFrameCallback(const FrameCallbackSlotType &slot)
CRITICAL_SECTION nx_critical
void setup(const ISISCRPT_STRUCT *crpt, ISISDAE *dae, int run_number_digits, DAEstatus &status)
NeXusEventCallback * m_nxcallback
std::list< boost::signals2::connection > addNoFrameCallback(const NoFrameCallbackSlotType &slot)
void setLoggerName(const std::string &logger_name)
const ISISCRPT_STRUCT * m_crpt
void enableCompression(int comp_level=NX_COMP_LZW)
NeXusEventCallback * m_nxcallback
std::list< boost::signals2::connection > addNoFrameCallback(const NoFrameCallbackSlotType &slot)
void addFileInputSource(int run_number, FileEventSourceInfo &info)
std::list< boost::signals2::connection > addAllEventCallback(const EventCallbackSlotType &slot)
void noFrameCallbackEnd(bool end_present, NoFrameCallbackMode mode, int event_source_id)
std::list< boost::signals2::connection > m_callbacks