ICP  1
Classes | Typedefs | Functions | Variables
icputils.h File Reference
#include "IsisBase.h"
#include "isisvme_types.h"
#include "DAEstatus.h"

Go to the source code of this file.

Classes

class  Win32Exception
 
class  Win32StructuredException
 
class  CRTLException
 
class  WinsockException
 
class  ThreadPriorityRaiser
 
class  ICPClock
 
struct  ValueWithTimestamp< T >
 this must have NO VIRTUAL FUNCTIONS as it is embedded inside the CRPT More...
 
class  ICPTimer
 
struct  ICPTimer::timings_t
 
struct  MD5_CTX
 
class  ICPCritical
 
struct  pair_second< T1, T2 >
 
class  sum_values< T >
 nice idea, but problems with return type... More...
 
class  GenericTask< T >
 
class  GenericProgressHandler
 
class  GenericWorkNotification< T >
 
class  GenericWorker< T >
 
class  ActiveObject< R >
 
class  ScopedSemaphore
 
class  SimpleStore< T >
 

Typedefs

typedef unsigned char md5checksum_t [16]
 
typedef void(* overlap_complete_func_t )(void *arg)
 
typedef void(__stdcall * MD5Init_t )(MD5_CTX *)
 
typedef void(__stdcall * MD5Update_t )(MD5_CTX *, const unsigned char *, unsigned int)
 
typedef void(__stdcall * MD5Final_t )(MD5_CTX *)
 

Functions

std::string convertLatin1ToUTF8 (const std::string &latin_string)
 convert ISO Latin-1 (8859-1) to UTF-8 More...
 
std::string convertWindows1252ToUTF8 (const std::string &win_string)
 
SECURITY_ATTRIBUTES * defaultNoInheritHandles ()
 
void getConfigStringList (std::vector< std::string > &string_list, const std::string &config_item)
 read a ; separated list of items from a properties file and return the items as a vector<string> More...
 
void getConfigIntList (std::vector< int > &int_list, const std::string &config_item)
 read a ; separated list of items from a properties file and return the items as a vector<int> More...
 
static void RetryWIN32APIBOOL (boost::function< BOOL()> func, int nretry)
 
std::string padWithZeros (int number, int len)
 
std::string fileNameFromMappedView (void *pMem)
 
void printComputerMemoryStats (DAEstatus &status)
 
void registerExtraLoggerChannels ()
 
void setICPChannelReporter (DAEreport_func_t *report_func, void *report_arg)
 
int loadAppConfig (const std::string &app_name)
 load a config file from ../../.. i.e. from c:/labview modules/dae if we are in c:/labview modules/dae/service/x64/release More...
 
int removeWithRetry (const char *filename)
 return 0 on success, else error More...
 
int createEmptyFileAndClose (const std::string &file_name, size_t file_size)
 
HANDLE createEmptyFile (const std::string &file_name, size_t file_size)
 
int compareBuffers (const std::string &title, const isisU32_t *buffer1, const isisU32_t *buffer2, int nbuffer, DAEstatus &status)
 
template<typename T >
void findConsecutive (const std::vector< T > &vec, T invalid_val, std::vector< int > &indexes, std::vector< int > &sizes)
 return an array of indices containing the start points of consecutive sequences of numbers More...
 
int sendSMS (const std::string &phone, const std::string &message, DAEstatus &status)
 
int sendEmail (const std::string &sender, const std::string &recipient, const std::string &subject, const std::string &content, DAEstatus &status)
 
void pollUntilTasksComplete (const Poco::TaskManager &tm, int poll_time_in_ms)
 
int findFiles (const char *directory, const char *pattern, std::vector< std::string > &list, bool full_path=true)
 
void AddEventSource (PCTSTR pszName, PCTSTR pszMessageFile, DWORD dwCategoryCount)
 
std::string unescapeXML (const char *xml_str)
 
std::string escapeXML (const char *xml_str)
 
int md5sumFile (const char *filename, unsigned char *md5sum, DAEstatus &status)
 
int md5sumString (const void *buffer, int len, unsigned char *md5sum, DAEstatus &status)
 
bool compareChecksums (const unsigned char *md5sum1, const unsigned char *md5sum2)
 
int updateChecksum (unsigned char *md5sum1, const unsigned char *md5sum2)
 
int parseSpectraRange (const std::string &spec_range, int &spec_from, int &spec_to)
 
std::string checksumAsString (md5checksum_t checksum)
 
void appendToFileAsync (const char *filename, const char *message)
 
void appendToFileAsync (HANDLE h, const char *message, bool close_after_write=false)
 
HANDLE createAppendFile (const char *filename)
 
template<typename T >
int atomic_write (const std::string &filename, const std::string &old_suffix, const std::string &new_suffix, T *data, int n)
 
int flushed_write (const std::string &file, const void *data, int nbytes)
 
template<typename T >
int atomic_read (const std::string &filename, const std::string &old_suffix, T *data, size_t n)
 
off_t file_size_bytes (const std::string &filename)
 return size of a file in bytes More...
 
int64_t fileSizeBytes (const std::string &filename)
 
template<typename T >
size_t array_length (const T &)
 calculate number of elements in a fixed array e.g. int something[10] ot int s[] = { "a", "b" } More...
 
LONGLONG diffFileTimes (const FILETIME &start, const FILETIME &finish)
 finish - start, returned in 100ns units More...
 
double diffFileTimesInMilliSec (const FILETIME &start, const FILETIME &finish)
 finish - start in milliseconds More...
 
template<typename T , typename U >
sum_map_values (const std::map< T, U > &m)
 

Variables

Poco::SingletonHolder< ICPClockg_icp_clock
 
Poco::Mutex * atomic_mutex
 

Typedef Documentation

typedef unsigned char md5checksum_t[16]

Definition at line 303 of file icputils.h.

typedef void(__stdcall * MD5Final_t)(MD5_CTX *)

Definition at line 328 of file icputils.h.

typedef void(__stdcall * MD5Init_t)(MD5_CTX *)

Definition at line 324 of file icputils.h.

typedef void(__stdcall * MD5Update_t)(MD5_CTX *, const unsigned char *, unsigned int)

Definition at line 326 of file icputils.h.

typedef void(* overlap_complete_func_t)(void *arg)

Definition at line 311 of file icputils.h.

Function Documentation

void AddEventSource ( PCTSTR  pszName,
PCTSTR  pszMessageFile,
DWORD  dwCategoryCount 
)

Definition at line 206 of file icputils.cpp.

void appendToFileAsync ( const char *  filename,
const char *  message 
)

Definition at line 463 of file icputils.cpp.

References appendToFileAsync(), and createAppendFile().

void appendToFileAsync ( HANDLE  h,
const char *  message,
bool  close_after_write = false 
)
template<typename T >
size_t array_length ( const T &  )
inline

calculate number of elements in a fixed array e.g. int something[10] ot int s[] = { "a", "b" }

Definition at line 468 of file icputils.h.

Referenced by EnvPeriodCard< EnvPeriodPolicy >::getFermiChopperVetoedFrames(), and EnvPeriodCard< EnvPeriodPolicy >::processFermiChopperVeto().

template<typename T >
int atomic_read ( const std::string &  filename,
const std::string &  old_suffix,
T *  data,
size_t  n 
)

Definition at line 433 of file icputils.h.

Referenced by EventStoreCard::getInfoFileData().

template<typename T >
int atomic_write ( const std::string &  filename,
const std::string &  old_suffix,
const std::string &  new_suffix,
T *  data,
int  n 
)

Definition at line 380 of file icputils.h.

References RetryWIN32APIBOOL().

Referenced by EventStoreCard::updateFilePosition().

std::string checksumAsString ( md5checksum_t  checksum)

Definition at line 354 of file icputils.cpp.

Referenced by DetectorCard< DetCardPolicy >::printStatus().

int compareBuffers ( const std::string &  title,
const isisU32_t buffer1,
const isisU32_t buffer2,
int  nbuffer,
DAEstatus status 
)

Definition at line 748 of file icputils.cpp.

References DAEstatus::addInfoVa(), FAC_DAE, and findConsecutive().

Referenced by ISISDAE::readAllDAE1Spectra().

bool compareChecksums ( const unsigned char *  md5sum1,
const unsigned char *  md5sum2 
)
std::string convertLatin1ToUTF8 ( const std::string &  latin_string)

convert ISO Latin-1 (8859-1) to UTF-8

Definition at line 8 of file icputils.cpp.

std::string convertWindows1252ToUTF8 ( const std::string &  win_string)

Definition at line 18 of file icputils.cpp.

Referenced by ISISinstrumentControl::writeJournal().

HANDLE createAppendFile ( const char *  filename)

Definition at line 424 of file icputils.cpp.

References defaultNoInheritHandles(), and my_io_complete().

Referenced by appendToFileAsync().

HANDLE createEmptyFile ( const std::string &  file_name,
size_t  file_size 
)

create an empty file and return a handle to it return INVALID_HANDLE_VALUE on error

Definition at line 963 of file icputils.cpp.

References defaultNoInheritHandles().

Referenced by createEmptyFileAndClose(), and CRPTProxy::createFrom().

int createEmptyFileAndClose ( const std::string &  file_name,
size_t  file_size 
)

Definition at line 1061 of file icputils.cpp.

References createEmptyFile(), DAEstatus::Failure, and DAEstatus::Success.

SECURITY_ATTRIBUTES* defaultNoInheritHandles ( )
LONGLONG diffFileTimes ( const FILETIME &  start,
const FILETIME &  finish 
)

finish - start, returned in 100ns units

Definition at line 630 of file icputils.cpp.

Referenced by diffFileTimesInMilliSec(), and EnvPeriodCard< EnvPeriodPolicy >::frameTimerDrift().

double diffFileTimesInMilliSec ( const FILETIME &  start,
const FILETIME &  finish 
)

finish - start in milliseconds

Definition at line 624 of file icputils.cpp.

References diffFileTimes().

Referenced by ISISinstrumentControl::ISISinstrumentControl(), and ISISinstrumentControl::updateICPTimeDiffLog().

std::string escapeXML ( const char *  xml_str)

Definition at line 118 of file icputils.cpp.

off_t file_size_bytes ( const std::string &  filename)

return size of a file in bytes

Definition at line 648 of file icputils.cpp.

std::string fileNameFromMappedView ( void *  pMem)

Definition at line 1033 of file icputils.cpp.

References deviceNameToDriveLetter().

Referenced by ISISCRPT_DATA::map().

int64_t fileSizeBytes ( const std::string &  filename)

Definition at line 1049 of file icputils.cpp.

Referenced by ISISCRPT_DATA::map().

template<typename T >
void findConsecutive ( const std::vector< T > &  vec,
invalid_val,
std::vector< int > &  indexes,
std::vector< int > &  sizes 
)

return an array of indices containing the start points of consecutive sequences of numbers

Definition at line 664 of file icputils.cpp.

Referenced by compareBuffers(), DetectorCard< DetCardPolicy >::readAllDAE1Spectra(), and DetectorCard< DetCardPolicy >::readDAE1Spectra().

int findFiles ( const char *  directory,
const char *  pattern,
std::vector< std::string > &  list,
bool  full_path = true 
)
int flushed_write ( const std::string &  file,
const void *  data,
int  nbytes 
)

Definition at line 950 of file icputils.cpp.

References flushed_write().

void getConfigIntList ( std::vector< int > &  int_list,
const std::string &  config_item 
)

read a ; separated list of items from a properties file and return the items as a vector<int>

Definition at line 854 of file icputils.cpp.

References getConfigStringList().

void getConfigStringList ( std::vector< std::string > &  string_list,
const std::string &  config_item 
)

read a ; separated list of items from a properties file and return the items as a vector<string>

Definition at line 845 of file icputils.cpp.

Referenced by getConfigIntList().

int loadAppConfig ( const std::string &  app_name)

load a config file from ../../.. i.e. from c:/labview modules/dae if we are in c:/labview modules/dae/service/x64/release

Definition at line 866 of file icputils.cpp.

References the_app.

Referenced by EventsToolApp::main().

int md5sumFile ( const char *  filename,
unsigned char *  md5sum,
DAEstatus status 
)
int md5sumString ( const void *  buffer,
int  len,
unsigned char *  md5sum,
DAEstatus status 
)
std::string padWithZeros ( int  number,
int  len 
)
inline
int parseSpectraRange ( const std::string &  spec_range,
int &  spec_from,
int &  spec_to 
)
void pollUntilTasksComplete ( const Poco::TaskManager &  tm,
int  poll_time_in_ms 
)

Definition at line 1100 of file icputils.cpp.

Referenced by ISISDAE::clearHistogramMemory(), and ISISDAE::readAllDAE1Spectra().

void printComputerMemoryStats ( DAEstatus status)

Definition at line 1072 of file icputils.cpp.

References DAEstatus::addInfoVa(), and FAC_DAE.

Referenced by ISISinstrumentControl::ISISinstrumentControl().

void registerExtraLoggerChannels ( )

Definition at line 830 of file icputils.cpp.

int removeWithRetry ( const char *  filename)

return 0 on success, else error

Definition at line 1090 of file icputils.cpp.

static void RetryWIN32APIBOOL ( boost::function< BOOL()>  func,
int  nretry 
)
static
int sendEmail ( const std::string &  sender,
const std::string &  recipient,
const std::string &  subject,
const std::string &  content,
DAEstatus status 
)
int sendSMS ( const std::string &  phone,
const std::string &  message,
DAEstatus status 
)

Definition at line 569 of file icputils.cpp.

References DAEstatus::addInfoVa(), FAC_DAE, and sendSMSMain().

Referenced by ISISinstrumentControl::updateFunc().

void setICPChannelReporter ( DAEreport_func_t report_func,
void *  report_arg 
)

Definition at line 839 of file icputils.cpp.

References ICPFileChannel::setReporter().

template<typename T , typename U >
U sum_map_values ( const std::map< T, U > &  m)

Definition at line 507 of file icputils.h.

Referenced by NeXusEventCallback::finish(), and EventsToolApp::main().

std::string unescapeXML ( const char *  xml_str)

Definition at line 72 of file icputils.cpp.

References escape_sequence.

int updateChecksum ( unsigned char *  md5sum1,
const unsigned char *  md5sum2 
)

Variable Documentation

Poco::Mutex* atomic_mutex

Definition at line 778 of file icputils.cpp.

Poco::SingletonHolder<ICPClock> g_icp_clock