ICP  1
Classes | Functions | Variables
icputils.cpp File Reference
#include "stdafx.h"
#include "DAEstatus.h"
#include "icputils.h"
#include "Poco/StreamCopier.h"
#include "Poco/Path.h"
#include "Poco/URI.h"
#include "Poco/Exception.h"
#include "Poco/Net/HTTPClientSession.h"
#include "Poco/Net/HTTPRequest.h"
#include "Poco/Net/HTTPResponse.h"
#include "Poco/Net/HTMLForm.h"
#include "Poco/Net/SMTPClientSession.h"
#include "Poco/Net/MailMessage.h"
#include "Poco/Net/MailRecipient.h"
#include "Poco/Net/StringPartSource.h"
#include "Poco/StringTokenizer.h"

Go to the source code of this file.

Classes

struct  MyOverlapped
 
struct  my_overlap_t
 
class  DebuggerChannel
 
class  ICPFileChannel
 
class  TestChannel
 
struct  my_SECURITY_ATTRIBUTES
 

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)
 
std::string unescapeXML (const char *xml_str)
 
std::string escapeXML (const char *xml_str)
 
void AddEventSource (PCTSTR pszName, PCTSTR pszMessageFile, DWORD dwCategoryCount)
 
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)
 
static void my_overlap (void *arg)
 
void my_io_complete (void *arg)
 
HANDLE createAppendFile (const char *filename)
 
void appendToFileAsync (HANDLE h, const char *message, bool close_after_write)
 
void appendToFileAsync (const char *filename, const char *message)
 
int findFiles (const char *directory, const char *pattern, std::vector< std::string > &list, bool full_path)
 
static int sendSMSMain (const std::string &phone, const std::string &message, DAEstatus &status)
 
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)
 
double diffFileTimesInMilliSec (const FILETIME &start, const FILETIME &finish)
 finish - start in milliseconds More...
 
LONGLONG diffFileTimes (const FILETIME &start, const FILETIME &finish)
 finish - start, returned in 100ns units More...
 
off_t file_size_bytes (const std::string &filename)
 return size of a file in bytes More...
 
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 compareBuffers (const std::string &title, const isisU32_t *buffer1, const isisU32_t *buffer2, int nbuffer, DAEstatus &status)
 
template void findConsecutive (const std::vector< int > &vec, int invalid_val, std::vector< int > &indexes, std::vector< int > &sizes)
 
void registerExtraLoggerChannels ()
 
void setICPChannelReporter (DAEreport_func_t *report_func, void *report_arg)
 
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...
 
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...
 
static int flushed_write (const std::vector< std::string > &files, const std::vector< const void * > &data, const std::vector< int > &nbytes)
 
int flushed_write (const std::string &file, const void *data, int nbytes)
 
HANDLE createEmptyFile (const std::string &file_name, size_t file_size)
 
static void deviceNameToDriveLetter (TCHAR *pszFilename)
 
std::string fileNameFromMappedView (void *pMem)
 
int64_t fileSizeBytes (const std::string &filename)
 
int createEmptyFileAndClose (const std::string &file_name, size_t file_size)
 
void printComputerMemoryStats (DAEstatus &status)
 
int removeWithRetry (const char *filename)
 return 0 on success, else error More...
 
void pollUntilTasksComplete (const Poco::TaskManager &tm, int poll_time_in_ms)
 
SECURITY_ATTRIBUTES * defaultNoInheritHandles ()
 

Variables

Poco::SingletonHolder< ICPClockg_icp_clock
 
static const char * escape_sequence [] = { "&quot;", "&apos;" }
 
static const int escape_length [] = { 6, 6 }
 
static const char * escape_replace [] = { "\"", "\'" }
 
static HANDLE file_complete = NULL
 
static Poco::Mutex atomic_mutex_impl
 
Poco::Mutex * atomic_mutex = &atomic_mutex_impl
 
static my_SECURITY_ATTRIBUTES my_security_attributes
 

Function Documentation

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

Definition at line 206 of file icputils.cpp.

void appendToFileAsync ( HANDLE  h,
const char *  message,
bool  close_after_write 
)
void appendToFileAsync ( const char *  filename,
const char *  message 
)

Definition at line 463 of file icputils.cpp.

References appendToFileAsync(), and createAppendFile().

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 ( )
static void deviceNameToDriveLetter ( TCHAR *  pszFilename)
static

Definition at line 986 of file icputils.cpp.

Referenced by fileNameFromMappedView().

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().

template void findConsecutive ( const std::vector< int > &  vec,
int  invalid_val,
std::vector< int > &  indexes,
std::vector< int > &  sizes 
)
int findFiles ( const char *  directory,
const char *  pattern,
std::vector< std::string > &  list,
bool  full_path 
)
static int flushed_write ( const std::vector< std::string > &  files,
const std::vector< const void * > &  data,
const std::vector< int > &  nbytes 
)
static

Definition at line 910 of file icputils.cpp.

Referenced by flushed_write().

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 
)
void my_io_complete ( void *  arg)

Definition at line 410 of file icputils.cpp.

References MyOverlapped::arg, and MyOverlapped::func.

Referenced by createAppendFile().

static void my_overlap ( void *  arg)
static

Definition at line 402 of file icputils.cpp.

Referenced by appendToFileAsync().

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.

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().

static int sendSMSMain ( const std::string &  phone,
const std::string &  message,
DAEstatus status 
)
static

Definition at line 531 of file icputils.cpp.

References DAEstatus::add(), DAEstatus::addInfo(), ERRTYPE_OUTOFMEM, FAC_DAE, and SEV_ERROR.

Referenced by sendSMS().

void setICPChannelReporter ( DAEreport_func_t report_func,
void *  report_arg 
)

Definition at line 839 of file icputils.cpp.

References ICPFileChannel::setReporter().

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 = &atomic_mutex_impl

Definition at line 778 of file icputils.cpp.

Poco::Mutex atomic_mutex_impl
static

Definition at line 777 of file icputils.cpp.

const int escape_length[] = { 6, 6 }
static

Definition at line 69 of file icputils.cpp.

const char* escape_replace[] = { "\"", "\'" }
static

Definition at line 70 of file icputils.cpp.

const char* escape_sequence[] = { "&quot;", "&apos;" }
static

Definition at line 68 of file icputils.cpp.

Referenced by unescapeXML().

HANDLE file_complete = NULL
static

Definition at line 408 of file icputils.cpp.

Poco::SingletonHolder<ICPClock> g_icp_clock
my_SECURITY_ATTRIBUTES my_security_attributes
static

Definition at line 1119 of file icputils.cpp.

Referenced by defaultNoInheritHandles().