<commit_before>/*
 * FrameProcessorApp.cpp
 *
 *  Created on: 25 May 2016
 *      Author: gnx91527
 */

#include <signal.h>
#include <string>
#include <cstring>
#include <iostream>
#include <fstream>
using namespace std;

#include <log4cxx/logger.h>
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/propertyconfigurator.h>
#include <log4cxx/helpers/exception.h>
using namespace log4cxx;
using namespace log4cxx::helpers;

#include <boost/foreach.hpp>
#include <boost/program_options.hpp>
#include "boost/date_time/posix_time/posix_time.hpp"
#include <boost/filesystem.hpp>
namespace po = boost::program_options;

#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/prettywriter.h"
using namespace rapidjson;

#include "FrameProcessorController.h"

using namespace FrameProcessor;

void parse_arguments(int argc, char** argv, po::variables_map& vm, LoggerPtr& logger)
{
  try
  {
    std::string config_file;

    // Declare a group of options that will allowed only on the command line
    po::options_description generic("Generic options");
    generic.add_options()
        ("help,h",
         "Print this help message")
        ("config,c",    po::value<string>(&config_file),
         "Specify program configuration file")
        ;

    // Declare a group of options that will be allowed both on the command line
    // and in the configuration file
    po::options_description config("Configuration options");
    config.add_options()
        ("logconfig,l",   po::value<string>(),
           "Set the log4cxx logging configuration file")
        ("ctrl",          po::value<std::string>()->default_value("tcp://127.0.0.1:5004"),
           "Set the control endpoint")
        ("sharedbuf",     po::value<std::string>()->default_value("FrameReceiverBuffer"),
           "Set the name of the shared memory frame buffer")
        ("ready",         po::value<std::string>()->default_value("tcp://127.0.0.1:5001"),
           "Ready ZMQ endpoint from frameReceiver")
        ("release",       po::value<std::string>()->default_value("tcp://127.0.0.1:5002"),
           "Release frame ZMQ endpoint from frameReceiver")
        ("meta",          po::value<std::string>()->default_value("tcp://*:5558"),
           "ZMQ meta data channel publish stream")
        ("no-client,N",   po::bool_switch(),
           "Enable full initial configuration to run without any client controller."
           "You must also be provide: detector, path, datasets, dtype and dims.")
        ("processes,p",   po::value<unsigned int>()->default_value(1),
           "Number of concurrent file writer processes")
        ("rank,r",        po::value<unsigned int>()->default_value(0),
           "The rank (index number) of the current file writer process in relation to the other concurrent ones")
        ("detector,d",    po::value<std::string>(),
           "Detector to configure for")
        ("path",          po::value<std::string>(),
           "Path to detector shared library with format 'lib<detector>ProcessPlugin.so'")
        ("datasets",      po::value<std::vector<string> >()->multitoken(),
           "Name(s) of datasets to write (space separated)")
        ("dtype",         po::value<int>(),
           "Data type of raw detector data (0: 8bit, 1: 16bit, 2: 32bit, 3:64bit)")
        ("dims",          po::value<std::vector<int> >()->multitoken(),
           "Dimensions of each frame (space separated)")
        ("chunk-dims,C",  po::value<std::vector<int> >()->multitoken(),
           "Chunk size of each sub-frame (space separated)")
        ("bit-depth",     po::value<std::string>(),
           "Bit-depth mode of detector")
        ("compression",   po::value<int>(),
           "Compression type of input data (0: None, 1: LZ4, 2: BSLZ4)")
        ("output,o",      po::value<std::string>()->default_value("test.hdf5"),
           "Name of HDF5 file to write frames to (default: test.hdf5)")
        ("output-dir",    po::value<std::string>()->default_value("/tmp/"),
           "Directory to write HDF5 file to (default: /tmp/)")
        ("single-shot,S", po::bool_switch(),
           "Shutdown after one dataset completed")
        ("frames,f",      po::value<unsigned int>()->default_value(0),
           "Set the number of frames to write into dataset")
        ("acqid",     po::value<std::string>(),
           "Set the Acquisition Id of the acquisition")
    ;
<commit_msg>Fix for running FrameProcessor with no Acquisition ID<commit_after>/*
 * FrameProcessorApp.cpp
 *
 *  Created on: 25 May 2016
 *      Author: gnx91527
 */

#include <signal.h>
#include <string>
#include <cstring>
#include <iostream>
#include <fstream>
using namespace std;

#include <log4cxx/logger.h>
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/propertyconfigurator.h>
#include <log4cxx/helpers/exception.h>
using namespace log4cxx;
using namespace log4cxx::helpers;

#include <boost/foreach.hpp>
#include <boost/program_options.hpp>
#include "boost/date_time/posix_time/posix_time.hpp"
#include <boost/filesystem.hpp>
namespace po = boost::program_options;

#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/prettywriter.h"
using namespace rapidjson;

#include "FrameProcessorController.h"

using namespace FrameProcessor;

void parse_arguments(int argc, char** argv, po::variables_map& vm, LoggerPtr& logger)
{
  try
  {
    std::string config_file;

    // Declare a group of options that will allowed only on the command line
    po::options_description generic("Generic options");
    generic.add_options()
        ("help,h",
         "Print this help message")
        ("config,c",    po::value<string>(&config_file),
         "Specify program configuration file")
        ;

    // Declare a group of options that will be allowed both on the command line
    // and in the configuration file
    po::options_description config("Configuration options");
    config.add_options()
        ("logconfig,l",   po::value<string>(),
           "Set the log4cxx logging configuration file")
        ("ctrl",          po::value<std::string>()->default_value("tcp://127.0.0.1:5004"),
           "Set the control endpoint")
        ("sharedbuf",     po::value<std::string>()->default_value("FrameReceiverBuffer"),
           "Set the name of the shared memory frame buffer")
        ("ready",         po::value<std::string>()->default_value("tcp://127.0.0.1:5001"),
           "Ready ZMQ endpoint from frameReceiver")
        ("release",       po::value<std::string>()->default_value("tcp://127.0.0.1:5002"),
           "Release frame ZMQ endpoint from frameReceiver")
        ("meta",          po::value<std::string>()->default_value("tcp://*:5558"),
           "ZMQ meta data channel publish stream")
        ("no-client,N",   po::bool_switch(),
           "Enable full initial configuration to run without any client controller."
           "You must also be provide: detector, path, datasets, dtype and dims.")
        ("processes,p",   po::value<unsigned int>()->default_value(1),
           "Number of concurrent file writer processes")
        ("rank,r",        po::value<unsigned int>()->default_value(0),
           "The rank (index number) of the current file writer process in relation to the other concurrent ones")
        ("detector,d",    po::value<std::string>(),
           "Detector to configure for")
        ("path",          po::value<std::string>(),
           "Path to detector shared library with format 'lib<detector>ProcessPlugin.so'")
        ("datasets",      po::value<std::vector<string> >()->multitoken(),
           "Name(s) of datasets to write (space separated)")
        ("dtype",         po::value<int>(),
           "Data type of raw detector data (0: 8bit, 1: 16bit, 2: 32bit, 3:64bit)")
        ("dims",          po::value<std::vector<int> >()->multitoken(),
           "Dimensions of each frame (space separated)")
        ("chunk-dims,C",  po::value<std::vector<int> >()->multitoken(),
           "Chunk size of each sub-frame (space separated)")
        ("bit-depth",     po::value<std::string>(),
           "Bit-depth mode of detector")
        ("compression",   po::value<int>(),
           "Compression type of input data (0: None, 1: LZ4, 2: BSLZ4)")
        ("output,o",      po::value<std::string>()->default_value("test.hdf5"),
           "Name of HDF5 file to write frames to (default: test.hdf5)")
        ("output-dir",    po::value<std::string>()->default_value("/tmp/"),
           "Directory to write HDF5 file to (default: /tmp/)")
        ("single-shot,S", po::bool_switch(),
           "Shutdown after one dataset completed")
        ("frames,f",      po::value<unsigned int>()->default_value(0),
           "Set the number of frames to write into dataset")
        ("acqid",         po::value<std::string>()->default_value(""),
           "Set the Acquisition Id of the acquisition")
    ;

{'fraction_non_alphanumeric': 0.15046529880031392, 'fraction_numerical': 0.016818028927009756, 'mean_word_length': 3.06378132118451, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 104, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4925812', 'n_tokens_mistral': 2688, 'n_tokens_neox': 2610, 'n_words': 713}