Exemple #1
1
void VisualStudioProvider::outputGlobalPropFile(std::ofstream &properties, int bits, const StringList &defines, const std::string &prefix, bool runBuildEvents) {
	std::string warnings;
	for (StringList::const_iterator i = _globalWarnings.begin(); i != _globalWarnings.end(); ++i)
		warnings +=  *i + ';';

	std::string definesList;
	for (StringList::const_iterator i = defines.begin(); i != defines.end(); ++i) {
		if (i != defines.begin())
			definesList += ';';
		definesList += *i;
	}

	// Add define to include revision header
	if (runBuildEvents)
		definesList += REVISION_DEFINE ";";

	properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"
	              "<VisualStudioPropertySheet\n"
	              "\tProjectType=\"Visual C++\"\n"
	              "\tVersion=\"8.00\"\n"
	              "\tName=\"" << PROJECT_DESCRIPTION << "_Global\"\n"
	              "\tOutputDirectory=\"$(ConfigurationName)" << bits << "\"\n"
	              "\tIntermediateDirectory=\"$(ConfigurationName)" << bits << "/$(ProjectName)\"\n"
	              "\t>\n"
	              "\t<Tool\n"
	              "\t\tName=\"VCCLCompilerTool\"\n"
	              "\t\tDisableLanguageExtensions=\"true\"\n"
	              "\t\tDisableSpecificWarnings=\"" << warnings << "\"\n"
	              "\t\tAdditionalIncludeDirectories=\"" << prefix << ";" << prefix << "\\engines;$(" << LIBS_DEFINE << ")\\include;$(TargetDir)\"\n"
	              "\t\tPreprocessorDefinitions=\"" << definesList << "\"\n"
	              "\t\tExceptionHandling=\"0\"\n";

#if NEEDS_RTTI
	properties << "\t\tRuntimeTypeInfo=\"true\"\n";
#else
	properties << "\t\tRuntimeTypeInfo=\"false\"\n";
#endif

	properties << "\t\tRuntimeTypeInfo=\"false\"\n"
	              "\t\tWarningLevel=\"4\"\n"
	              "\t\tWarnAsError=\"false\"\n"
	              "\t\tCompileAs=\"0\"\n"
	              "\t\t/>\n"
	              "\t<Tool\n"
	              "\t\tName=\"VCLibrarianTool\"\n"
	              "\t\tIgnoreDefaultLibraryNames=\"\"\n"
	              "\t/>\n"
	              "\t<Tool\n"
	              "\t\tName=\"VCLinkerTool\"\n"
	              "\t\tIgnoreDefaultLibraryNames=\"\"\n"
	              "\t\tSubSystem=\"1\"\n"
	              "\t\tEntryPointSymbol=\"WinMainCRTStartup\"\n"
	              "\t\tAdditionalLibraryDirectories=\"$(" << LIBS_DEFINE << ")\\lib\\" << ((bits == 32) ? "x86" : "x64") << "\"\n"
	              "\t/>\n"
	              "\t<Tool\n"
	              "\t\tName=\"VCResourceCompilerTool\"\n"
	              "\t\tPreprocessorDefinitions=\"HAS_INCLUDE_SET\"\n"
	              "\t\tAdditionalIncludeDirectories=\"" << prefix << "\"\n"
	              "\t/>\n"
	              "</VisualStudioPropertySheet>\n";

	properties.flush();
}
Exemple #2
0
VOID trace_instrument(TRACE trace, VOID *v){
  for (BBL bbl = TRACE_BblHead(trace); BBL_Valid(bbl); bbl = BBL_Next(bbl)){ 
    /* iterate over all basic blocks */
    
    string codelet_string = "";
    // this writes disassembly 
    char codelet_buffer[65536*2]; int cbs = 0;
    INS head = BBL_InsHead(bbl);
    INS tail = BBL_InsTail(bbl);
    
    ADDRINT stage_entry = INS_Address( head );
    ADDRINT target = 0;
    if (INS_IsCall(tail)){
      if( INS_IsDirectBranchOrCall(tail)){
        target = INS_DirectBranchOrCallTargetAddress(tail);}}

    INS cur ;
    int branch_id = slp_count;
      
    /* If compression is turned off (default), only output the addresses of
     * the BBL once
     */
    if (!KnobNoCompress){
      /* Instrument the head instruction right before it is called, but also
       * before we instrument the instructions in the basic block 
       */
      string msg_pre  = "\n@@BBL(" + decstr( branch_id ) + ") STAGE " + Target2String(stage_entry)->c_str() + "\n" ;
      INS_InsertCall(head, IPOINT_BEFORE, AFUNPTR(string_report),
		     IARG_PTR, new string(msg_pre),
		     IARG_END);
    }
   
    /* Walk the list of instructions inside the BBL. Disassemble each, and add
     * it to the codelet string. Also, instrument each instruction at the
     * point before it is called with the do_count function.
     */
    for ( cur = head; INS_Valid( cur ); cur = INS_Next(cur ) ){
      cbs += sprintf( codelet_buffer + cbs , "\n\t@%llx\t%s", INS_Address( cur ), INS_Disassemble( cur ).c_str() );
      INS_InsertCall(cur, IPOINT_BEFORE, (AFUNPTR)do_count, IARG_ADDRINT, INS_Address( cur ), IARG_END);
    }

    /* Finish off the codelet assembly string with an out message and
     * address ranges of the BBL
     */
    cbs += sprintf( codelet_buffer + cbs , "\n\t}BBL.OUT [%d] %llx - %llx\n", branch_id, INS_Address( head ), INS_Address( tail ));
  
    /* If compression is turned on, output the codelet every single time we
     * hit the same block.
     */
    if(KnobNoCompress){
      INS_InsertCall(tail, IPOINT_BEFORE, AFUNPTR(string_report),
		     IARG_PTR, new string(codelet_buffer),
		     IARG_END);
      slp_count ++;
    }
    else{
      /* add the mapped BBL to output */
      TraceFile.write(codelet_buffer, cbs);	
 
      /* Instrument the tail instruction by inserting just before it is called
      */
      string msg_post = "+@@BBL(" + decstr( branch_id ) + ") ACHIEVE : GOTO " + Target2String(target)->c_str();
      INS_InsertCall(tail, IPOINT_BEFORE, AFUNPTR(string_report),
		     IARG_PTR, new string(msg_post),
		     IARG_END);

      slp_count ++;
    }
  }
}
Exemple #3
0
VOID Fini(INT32 code, VOID *v)
{
    TraceFile.close();
}
		bool write(const uint8_t v) { m_fp.put(v); return true; }
Exemple #5
0
AutoThread::~AutoThread()

{
    output.close();

}
		uint64_t tell() { return m_fp.tellp(); }
		bool is_open() { return m_fp.is_open(); }
Exemple #8
0
namespace Log {

   // component-scope variables
   const unsigned int log_master = 0;
   std::string log_file;
   std::ofstream lout;

   bool initialized = false;
   std::stringstream buffer;

   // =========================================================================
   // Set up

   void setup () {

      // ----------------------------------------------------------------------
      // Initialize the Log component

      // Name of log file
      log_file = Parameters::get_optional<std::string>(
            "Log.log_file", "log.txt");
      log_file = Driver::output_dir + log_file;

      // Open log file
#ifdef PARALLEL_MPI
      if (Driver::proc_ID == log_master) {
         lout.open(log_file.c_str());
      }
#else // PARALLEL_MPI
      lout.open(log_file.c_str());
#endif // PARALLEL_MPI
      initialized = true;

      // Write the log file header
      lout << "Hydrodynamics Simulation" << std::endl << std::endl;

      // If the buffer is not empty, push it to the file
      lout << buffer.str();
      buffer.clear();
      buffer.str("");

   }

   // =========================================================================
   // Clean up

   void cleanup () {

      // Final printing
      write_single("\n" + std::string(79,'_') + "\nProgram Complete\n");

      if (initialized) {
         // If the log file is open, close it
#ifdef PARALLEL_MPI
         if (Driver::proc_ID == log_master) {
#endif // PARALLEL_MPI
            lout.close();
            initialized = false;
#ifdef PARALLEL_MPI
         }
#endif // PARALLEL_MPI
      } else {
         // If the log file was never opened, print the buffer to the screen
         std::cout << buffer.str();
         buffer.clear();
         buffer.str("");
      }

   }

   // =========================================================================
   // Write to the log file

   void write_all(std::string message) {
#ifdef PARALLEL_MPI
      // Declare variables
      int length, max_length;
      char *send_buf, *recv_buf;

      // MPI_Allreduce to determine length of longest message
      length = message.length();
      MPI_Allreduce(&length, &max_length, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);

      // Pad message to max_length
      message.resize(max_length, '\0');

      // Allocate a character array of max_length
      send_buf = (char*) message.c_str();
      recv_buf = new char[Driver::n_procs*max_length];

      // MPI_Gather the messages into a read buffer
      MPI_Gather(send_buf, max_length, MPI_CHAR,
                 recv_buf, max_length, MPI_CHAR, log_master, MPI_COMM_WORLD);

      // If you are the master:
      if (Driver::proc_ID == log_master) {
         // Parse the read buffer into individual messages
         for (int i = 0; i < Driver::n_procs; i++) {
            for (int j = 0; j < max_length; j++) {
               if (recv_buf[i*max_length+j] == '\0') {
                  break;
               }
               write_single(recv_buf[i*max_length+j]);
            }
         }
      }
#else // PARALLEL_MPI
      write_single(message);
#endif // PARALLEL_MPI
   }

   // =========================================================================
   // Flush

   void flush() {
      lout.flush();
   }

}
Exemple #9
0
bool EyeRecord::saveToStream(std::ofstream& output) const
{
    output.write((const char*) &cEYES, 4);
    if (!saveSizeAndUnknownValues(output, getWriteSize())) return false;

    //write EDID
    output.write((const char*) &cEDID, 4);
    //EDID's length
    uint16_t subLength = editorID.length()+1;
    output.write((const char*) &subLength, 2);
    //write editor ID
    output.write(editorID.c_str(), subLength);

    //write FULL
    if (!name.saveToStream(output, cFULL))
        return false;

    //write ICON
    output.write((const char*) &cICON, 4);
    //ICON's length
    subLength = iconPath.length()+1;
    output.write((const char*) &subLength, 2);
    //write icon path
    output.write(iconPath.c_str(), subLength);

    //write DATA
    output.write((const char*) &cDATA, 4);
    //DATA's length
    subLength = 1;
    output.write((const char*) &subLength, 2);
    //write DATA's content
    output.write((const char*) &flags, 1);

    return output.good();
}
Exemple #10
0
bool Cylinder::saveParameters(std::ofstream& fout) const
{
  fout << "# cylinder normal_x normal_y normal_z point_x point_y point_z radius" << std::endl;
  fout << "cylinder " << _normal << " " << _point << " " << _radius << std::endl;
  return fout.good();
}
Exemple #11
0
 void flush() {
    lout.flush();
 }
bool PathGridRecord::saveToStream(std::ofstream& output) const
{
    output.write((const char*) &cPGRD, 4);
    uint32_t Size;
    Size = 4 /* DATA */ +4 /* 4 bytes for length */ + 12 /* size of data */
           +4 /* NAME */ +4 /* 4 bytes for length */
           +CellName.length()+1 /* length of cell name +1 byte for NUL termination */;
    if (!Points.empty())
    {
        Size = Size + 4 /* PGRP */ +4 /* 4 bytes for length */
               +16 * Points.size();
    }
    if (!Connections.empty())
    {
        Size = Size + 4 /* PGRC */ +4 /* 4 bytes for length */
               +8 * Connections.size();
    }
    output.write((const char*) &Size, 4);
    output.write((const char*) &HeaderOne, 4);
    output.write((const char*) &HeaderFlags, 4);

    /*Path Grid:
      DATA = (path grid data, 12 bytes)
               int32_t GridX
               int32_t GridY
               uint16_t Granularity (a power of two within [128;4096])
               uint16_t NumQuads (number of points in PGRP)
      NAME = name of cell the grid belongs to
      PGRP = unknown data (path grid points?)
               looks like an array of int32_t quads
               struct PointData
               {
                 int32_t X
                 int32_t Y
                 int32_t Z
                 int32_t Unknown
               };

      PGRC = unknown data (length: ?)
               Possibly path grid connections?
               Looks like an array of uint32_t pairs, where
               first value is the index of the starting point
               and second value is index of the end point.
    */

    //write DATA
    output.write((const char*) &cDATA, 4);
    //DATA's length
    uint32_t SubLength;
    SubLength = 12; //length is always twelve bytes
    output.write((const char*) &SubLength, 4);
    //write path grid data
    output.write((const char*) &GridX, 4);
    output.write((const char*) &GridY, 4);
    output.write((const char*) &Granularity, 2);
    output.write((const char*) &NumQuads, 2);

    //write NAME
    output.write((const char*) &cNAME, 4);
    //NAME's length
    SubLength = CellName.length()+1;//length of string plus one for NUL-termination
    output.write((const char*) &SubLength, 4);
    //write cell name
    output.write(CellName.c_str(), SubLength);

    if (!Points.empty())
    {
        //write PGRP
        output.write((const char*) &cPGRP, 4);
        //PGRP's length
        SubLength = Points.size()*16;//length is 16 bytes per point
        output.write((const char*) &SubLength, 4);
        //write points
        unsigned int i;
        for (i=0; i<Points.size(); ++i)
        {
            //write next point
            output.write((const char*) &(Points[i].X), 4);
            output.write((const char*) &(Points[i].Y), 4);
            output.write((const char*) &(Points[i].Z), 4);
            output.write((const char*) &(Points[i].Unknown), 4);
        }//for
    }//Points

    if (!Connections.empty())
    {
        //write PGRC
        output.write((const char*) &cPGRC, 4);
        //PGRC's length
        SubLength = Connections.size()*8;//length is 8 bytes per connection
        output.write((const char*) &SubLength, 4);
        //write connections
        unsigned int i;
        for (i=0; i<Connections.size(); ++i)
        {
            //write next point
            output.write((const char*) &(Connections[i].Start), 4);
            output.write((const char*) &(Connections[i].End), 4);
        }//for
    }//connections

    return output.good();
}
Exemple #13
0
 virtual void sample() {
   DVLOG(5) << "sampling " << name;
   if (value_ != nil_value) log.write((char*)&value_, sizeof(&value_));
   value_ = nil_value;
 }
Exemple #14
0
int main(int argcc, char* argvv[])
{
    Magick::InitializeMagick(NULL);
                                        // welcome to the main  :)
    std::stringstream ss_welcome;

    ss_welcome << "*** " << NAME <<" v. " << SDVERSION  << " - Analysis of 2D/3D multicolor SD-dSTORM data ***" ;



    std::cout << "\n" << ss_welcome.str() << std::endl;

    int dir_match_count = 0;
    int file_match_count = 0;

    std::string default_config_filename = NAME".conf";      // if u haven't specified it in the command-line
    std::string logfilename = get_date().append("_" NAME ".log");

    //std::string strDimensions;

    unsigned long file_count = 0;
    unsigned long dir_count = 0;
    unsigned long err_count = 0;

    std::stringstream ssusage_string;
    ssusage_string  << "\nUsage: " << argvv[0] <<
    " PATH [OPTIONS] \nruns "<< NAME << " in working directory \n\n" <<
    "optional arguments:\n" <<
    "\t-d \t\t : if specified, 2D image output of a 3D data set\n" <<
    "\t-o \t\t : one-color flag, overrides filter information\n" <<
    "\t-c FILENAME \t : specify an alternative configuration file\n" <<
    "\t-s STAGE_VALUE \t : skip stage, value has to be 1, 2 or 3.\n\t\t\t   1: skip PairFinder" <<
    "\n\t\t\t   2: skip Filter" <<
    "\n\t\t\t   3: skip Reconstructor\n" <<
    "\t-e STAGE_VALUE \t : end after stage, value has to be 1 or 2.\n\t\t\t   1: end after PairFinder" <<
    "\n\t\t\t   2: end after Filter\n" <<
    "\t-h \t\t : print this usage information\n"
    << std::endl;

    int nonopt_count = 0;                          // counter for optional argumnets
    bool force_dim = false;                     // -d
    int hflag = 0;                              // -h
    bool one_color = false;
    char *opt_conf_file = NULL;

    int skip_stage = 0;                         // value of -s
    int end_stage = 0;                          // value of -e

    int index;
    int c;
    opterr = 0;

    while ((c = getopt (argcc, argvv, "dc:s:e:oh")) != -1)
    {
        switch (c)
        {
            case 'd':
                force_dim = true;                   // force 2d analysis of 3d data set (why should one do this :)?
                break;
            case 'c':
                opt_conf_file = optarg;             // c-style string to our optional config file
                break;
            case 's':
                skip_stage = atoi(optarg);
                if (skip_stage != 1 && skip_stage != 2 && skip_stage != 3)
                {
                    std::cout << "\nERROR: skip stage: value has to be 1, 2 or 3\n" << std::endl;
                    return 1;
                }
                break;
            case 'e':
                end_stage = atoi(optarg);
                if (end_stage != 1 && end_stage != 2)
                {
                    std::cout << "\nERROR: end after stage: value has to be 1 or 2\n" << std::endl;
                    return 1;
                }
                break;
            case 'o':
                one_color = true;                   // one-color flag, overrides filter information
                break;
            case 'h':
                hflag = 1;
                std::cout << ssusage_string.str() ;
                return 1;
                break;
            case '?':
                if (optopt == 'c' || optopt == 's')
                {
                    std::cout << "\nERROR: Option '-" << (char) optopt << "' requires an argument\nrun " << argvv[0] << " -h for help\n";
                }

                else if (isprint (optopt))
                {
                    std::cout << "\nERROR: Unknown option '-" << (char) optopt << "'\nrun " << argvv[0] << " -h for help\n";
                }
                else                         // who the f*** would enter "umlaute" und/oder ß as an argument???
                {
                    std::cout << "\nERROR: Unknown optional character '-" << (wchar_t)optopt <<
                    "', Non-ASCII characters are not valid arguments!\nrun " << argvv[0] << " -h for help\n";
                }
                return 1;
            default:
            abort ();
        }
    }

    if (optind == argcc && hflag == 0)                      // jeah, genius give me an working dir or an help flag!
    {
        std::cout << "\nERROR: no path to working dir specified!\nrun " << argvv[0] << " -h for help\n";
        return 1;
    }

    for (index = optind; index < argcc; index++)
    {
        ++nonopt_count;
    }

    if (nonopt_count > 1)                               // one working dir is enough!
    {
        std::cout << "\nERROR: only one path to working dir is allowed!\nrun " << argvv[0] << " -h for help\n";
        return 1;
    }


    std::vector<std::string> dir_list;
    std::vector<std::string> file_list;


    boost::property_tree::ptree ptree_config_file;
    fs::path full_path( fs::initial_path<fs::path>() );
    full_path = fs::system_complete( fs::path( argvv[optind] ) );           // full path is the specified working dir

                                                    // this is seriously strange work-around to run octave main
                                                                        // but it works.
                                                                        // it would cause a segmentation fault when octave_main()
                                                                       // would be run with not the same nr. of args that were passed to the
                                                                        //sdmixer main.. ???
    string_vector om(argcc);                                            //
    for (int a = 0; a<argcc; ++a)
    {
         om(a) = "--silent";
         //om(a) = "-x";
    }
    octave_main(argcc, om.c_str_vec(), 1);                              // now its ok
                                                                        // if you have a better solution write to: [email protected]



    if ( !fs::exists( full_path ) )
    {

        std::cout << "\nERROR: working directory not found: " << full_path.string() << std::endl << std::endl;
        return 1;
    }

    fs::path config_file_full_path = operator/(full_path, default_config_filename);     // add name of default config file to working dir
                                                                                    // really nice construct this "operator/" it adds
                                                                                    // the right directory_seperator for unix "/"
                                                                                    // let's see if it works with windows...


    if (opt_conf_file != NULL)                                            // user specified an other location for the config file
    {
        config_file_full_path = opt_conf_file;                             // redefinition of the path above

        if (!std::ifstream(config_file_full_path.string().c_str()))
        {
            std::cout << "\nERROR: failed opening specified configuration file " << config_file_full_path.string()  << std::endl;
            return 1;
        }

    }
    else
    {
        if (!std::ifstream(config_file_full_path.string().c_str()))
        {
            std::cout << "\nERROR: no configuration file found in the working directory." << std::endl;
            return 1;
        }

    }


    fs::path log_file_full_path = operator/(full_path,logfilename);
   // fs::path log_file_full_path2 = operator/(full_path,"log.out");

    logFile.open(log_file_full_path.string().c_str());

    //LogFile::GetInstance()->OpenLogFile(log_file_full_path2.string().c_str());
/*
    LogFile &lg = *LogFile::GetInstance();
    lg.OpenLogFile(log_file_full_path2.string().c_str());

    lg << "Test\n";

*/


    if (!std::ifstream(log_file_full_path.string().c_str()))
    {
            std::cout << "\nERROR: unable to write logfile in working dir." << std::endl;
            return 1;
    }

    //logFile <<  "\n*** " << NAME <<" v. " << SDVERSION  << " - Analysis of 2D/3D multicolor SD-dSTORM data ***\n" << std::endl;
    logFile << ss_welcome.str() << "\n" << std::endl;

    std::string search_pattern_dir;
    std::string search_pattern_file;


    try                                                                 // try to read the config file
    {
        boost::property_tree::ini_parser::read_ini(config_file_full_path.string(), ptree_config_file);
    }
    catch( const std::exception & ex )
    {

        std::cout << "\nERROR: syntax error in config file: " << config_file_full_path.string() << std::endl << ex.what() << std::endl;

        return 1;

    }
    try                                                               // try to load some config-file entries
    {
        search_pattern_dir = ptree_config_file.get<std::string>("General.search_pattern_dir");
        search_pattern_file = ptree_config_file.get<std::string>("General.search_pattern_file");
        PairFinderFileStamp = ptree_config_file.get<std::string>("PairFinder.FileStamp");
        FilterFileStamp = ptree_config_file.get<std::string>("Filter.FileStamp");

        //crap!
        std::string str_grouping = ptree_config_file.get<std::string>("grouping.grouping_on");
        std::string str_groupingFileStamp = ptree_config_file.get<std::string>("grouping.OutputFileStamp");
        //CHANGE ME!!
        int grouping_on = atoi(str_grouping.c_str());
        PairFinderFileStampGroupingFailed = PairFinderFileStamp;        //just in case there are no groups..
        if(grouping_on != 0)
            PairFinderFileStamp = PairFinderFileStamp+str_groupingFileStamp;
    }
    catch( const std::exception & ex )
    {

        std::cout << "\nERROR: syntax error in config file: " << config_file_full_path.string() << std::endl << ex.what() << std::endl;

        return 1;

    }

    boost::regex pattern_dir(search_pattern_dir.c_str(), boost::regex_constants::icase);
    boost::regex pattern_file(search_pattern_file.c_str(), boost::regex_constants::icase);


    if ( fs::is_directory( full_path ) )                            // the working dir should be an directory
    {
        try
        {
            fs::directory_iterator end_iter;

            //std::cout << "\nWorking directory: " << full_path.string() << "\n" << std::endl;


            for ( fs::directory_iterator dir_itr( full_path ); dir_itr != end_iter; ++dir_itr )
            {
                try
                {
                    if ( fs::is_directory( dir_itr->status() ) )        // found a directory
                    {
                        ++dir_count;

                        std::stringstream ssfile;
                        ssfile << dir_itr->path().filename();

                        if (boost::regex_match(ssfile.str(), pattern_dir))      //dir matches the search pattern from config file
                        {                                                        //
                            std::string match_dir = ssfile.str();               //

                            fs::path full_path_matched_dir = operator/(full_path.string(), dir_itr->path().filename());

                            dir_list.push_back(full_path_matched_dir.string());         // add to vector which contains all our matched dirs

                            ++dir_match_count;
                        }

                    }
                    else if ( fs::is_regular_file( dir_itr->status() ) )            // found a subdir in the working dir
                    {
                        ++file_count;

                        std::stringstream ssfile;
                        ssfile << dir_itr->path().filename();

                        if (boost::regex_match(ssfile.str(), pattern_file))             // pattern matching?
                        {

                            std::string match_file = ssfile.str();

                            fs::path full_path_matched_file = operator/(full_path.string(), dir_itr->path().filename());
                            file_list.push_back(full_path_matched_file.string());       // yes, add to vector containing all the files

                            ++file_match_count;
                        }
                    }

                }
                catch ( const std::exception & ex )
                {
                    ++err_count;
                    std::cout << dir_itr->path().filename() << " " << ex.what() << std::endl;
                    return 1;
                }
            }
        }

        catch ( const std::exception & ex )
        {
            std::cout << "ERROR: failed opening directory " << full_path.string() << std::endl << ex.what() << std::endl;
            return 1;
        }
    }
    else
    {
        std::cout << "\nERROR: " << full_path.string() << " is not a directory" << std::endl << std::endl;
        return 1;
    }

    if ( file_match_count == 0 && dir_match_count != 0)
    {

        std::sort(dir_list.begin(), dir_list.end());
        //std::cout << "\nstarting analysis of " << dir_match_count << " subdirectorie(s). lean back, this may take a while...\n\n";
        AnalyseDirs(ptree_config_file, config_file_full_path, force_dim, one_color, dir_list, skip_stage, full_path.string(), end_stage);

    }

    if ( file_match_count != 0 && dir_match_count == 0)
    {
        int nr_of_dir = 0;
        //std::cout << "\nstarting analysis of " << file_match_count << " file(s) in the working directory.\n";
        std::sort(file_list.begin(), file_list.end());
        AnalyseFiles(ptree_config_file, config_file_full_path, force_dim, one_color, file_list, skip_stage, full_path.string(), end_stage, dir_list, nr_of_dir);

    }

    if ( file_match_count != 0 && dir_match_count != 0)
    {
        std::cout << "\nERROR: found " << file_match_count << " file(s) and "
        << dir_match_count << " directorie(s) that matched the search pattern\n" <<
        "please make sure that your working directory contains either subdirectories\nwhich content has to be processed " <<
        "OR files that have to be processed. Not both!\n" <<
        "don't know what you want me to do. terminating\n\n";

        return 1;
    }

    if ( file_match_count == 0 && dir_match_count == 0)
    {
        std::cout << "\nfound no files or directories that match the regex search pattern.\nNothing to do, terminating..\n\n";
        return 0;
    }

}
void createOutputFile (std::ofstream & outputFile, FILE * ptr_fp, bool isRestart, double delT, double delV, 
		       double tMin, double tMax, double vMin, double vMax, int Nvsteps, int Ntsteps, 
		       int downSampleT, int downSampleV, char * rChoice, char * regionChoice, 
		       char * distChoice, char * scattType, char * gradientOption, double vthe, 
		       double memi, double B, double wpe, double wce, double wci, double beta_e, 
		       double vA, double c1, double nu, double omega, double delB, double deln, 
		       double delR, double kpar, int Lx, int l0) {
  
  if (isRestart == 1) {
    outputFile.open("outputFile.txt", std::ios::out | std::ios::app); 
    std::cout << "Restart -> appending already existing outfile" << std::endl; 
  } else {

    // Opening output file 
    outputFile.open("outputFile.txt"); 

    // Opening saving file
    /*if((ptr_fp = fopen("cppTestOutput.bin", "ab")) == NULL)
      {
	printf("Unable to open file!\n");
	exit(1);
	}else printf("Opened file successfully for writing.\n");*/
    
    // Adding important information to the output file
    outputFile << "Simulation Variables:" << std::endl; 
    outputFile << "delT = " << delT << std::endl; 
    outputFile << "delV = " << delV << std::endl;
    outputFile << "tMin = " << tMin << std::endl; 
    outputFile << "tMax = " << tMax << std::endl; 
    outputFile << "vMin = " << vMin << std::endl; 
    outputFile << "vMax = " << vMax << std::endl;
    outputFile << "Nvsteps = " << Nvsteps << std::endl;
    outputFile << "Ntsteps = " << Ntsteps << std::endl; 
    outputFile << "downSampleT = " << downSampleT << std::endl; 
    outputFile << "downSampleV = " << downSampleV << std::endl << std::endl; 
  
    outputFile << "Physical Variables:" << std::endl;
    outputFile << "rChoice = " << rChoice << std::endl; 
    outputFile << "regionChoice = " << regionChoice << std::endl; 
    outputFile << "distChoice = " << distChoice << std::endl; 
    outputFile << "scattType = " << scattType << std::endl; 
    outputFile << "gradientOption = " << gradientOption << std::endl << std::endl;

    outputFile << "Physical Parameters:" << std::endl; 
    outputFile << "vthe = " << vthe << std::endl; 
    outputFile << "memi = " << memi << std::endl; 
    outputFile << "B = " << B << std::endl;
    outputFile << "wpe = " << wpe << std::endl;
    outputFile << "wce = " << wce << std::endl;
    outputFile << "wci = " << wci << std::endl;
    outputFile << "beta_e = " << beta_e << std::endl;
    outputFile << "vA = " << vA << std::endl;
    outputFile << "c1 = " << c1 << std::endl;
    outputFile << "nu = " << nu << std::endl;
    outputFile << "omega = " << omega << std::endl;
    outputFile << "delB = " << delB << std::endl;
    outputFile << "deln = " << deln << std::endl;
    outputFile << "delR = " << delR << std::endl;
    outputFile << "kpar = " << kpar << std::endl;
    outputFile << "Lx = " << Lx << std::endl;
    outputFile << "l0 = " << l0 << std::endl << std::endl;

    outputFile << "Simulation Output:" << std::endl;
  }
}
Exemple #16
0
// where everything begins...
int main(int argc, char** argv)
{
    const unsigned ONECHAR_ARG = 3, TWOCHAR_ARG = 4;

    // check that syntax is ok
    if (argc != 4)
    {
        std::cerr << "syntax: regress <options file> <xml file> <output file>" << std::endl;
        return -1;
    }

    // read in the options file
    std::ifstream options_in(argv[1]);
    if (options_in.fail())
    {
        std::cerr << "regress: error opening options file " << argv[1] << std::endl;
        return -1;
    }

    // get the options
    std::vector<std::string> options;
    std::string str;
    while (true)
    {
        options_in >> str;
        if (options_in.eof())
            break;
        options.push_back(str);
    }
    options_in.close();

    // get all options
    for (unsigned i=0; i< options.size(); i++)
    {
        // get the option
        const std::string& option = options[i];

        // process options
        if (option.find("-oi") != std::string::npos)
            OUTPUT_ITER_NUM = true;
        else if (option.find("-or") != std::string::npos)
            OUTPUT_SIM_RATE = true;
        else if (option.find("-s=") != std::string::npos)
        {
            STEP_SIZE = std::atof(option.substr(ONECHAR_ARG).c_str());
            assert(STEP_SIZE >= 0.0 && STEP_SIZE < 1);
        }
        else if (option.find("-mi=") != std::string::npos)
        {
            MAX_ITER = std::atoi(option.substr(TWOCHAR_ARG).c_str());
            assert(MAX_ITER > 0);
        }
        else if (option.find("-mt=") != std::string::npos)
        {
            MAX_TIME = std::atof(option.substr(TWOCHAR_ARG).c_str());
            assert(MAX_TIME > 0);
        }
        else if (option.find("-p=") != std::string::npos)
            read_plugin(option.substr(ONECHAR_ARG));
    }

    // setup the simulation
    READ_MAP = XMLReader::read(std::string(argv[argc-2]));

    // get the (only) simulation object
    boost::shared_ptr<Simulator> s;
    for (std::map<std::string, BasePtr>::const_iterator i = READ_MAP.begin(); i != READ_MAP.end(); i++)
    {
        s = boost::dynamic_pointer_cast<Simulator>(i->second);
        if (s)
            break;
    }

    // make sure that a simulator was found
    if (!s)
    {
        std::cerr << "regress: no simulator found in " << argv[argc-2] << std::endl;
        return -1;
    }

    // setup the output file
    outfile.open(argv[argc-1]);

    // call the initializers, if any
    if (!INIT.empty())
    {
        BOOST_FOREACH(init_t i, INIT)
        (*i)(NULL, READ_MAP, STEP_SIZE);
    }

    // begin timing
    start_time = clock();

    // begin rendering
    while (step((void*) &s))
    {
    }

    // close the loaded library
    for(size_t i = 0; i < handles.size(); ++i) {
        dlclose(handles[i]);
    }

    // write the number of clock ticks elapsed
    clock_t end_time = clock();
    double elapsed = (end_time - start_time) / (double) CLOCKS_PER_SEC;
    outfile << elapsed << std::endl;

    // close the output file
    outfile.close();
}
bool BamProcessor::init (const ContalignParams& p)
{
    read_cnt_ = proc_cnt_ = toolongs_ = unaligned_cnt_ = fail_cnt_ = nomd_cnt_ = realigned_cnt_ = modified_cnt_ = pos_adjusted_cnt_ = 0;
    log_diff_ = log_matr_ = log_base_ = false;

    p_ = &p;

    if (!*p.inbam ())
        ers << "Input file name not specified" << Throw;

    limit_ = p.limit ();
    skip_ = p.skip ();

    infile_.OpenForRead (p.inbam ());
    if (!infile_.IsOpen ())
        ers << p.inbam () << ThrowEx (FileNotFoundRerror);

    bool index_ok = false;
    if (*p.bamidx ())
    {
        index_ok = infile_.ReadBamIndex (p.bamidx ());
        if (!index_ok)
            warn << "Unable to open specified BAM index: " << p.bamidx () << ". Default index will be attempted" <<  std::endl;
    }
    if (!index_ok)
    {
        try
        {
            index_ok = infile_.ReadBamIndex ();
        }
        catch (std::exception& e)
        {
            // for some reason not converted into return status by libStatGen
        }
        if (!index_ok)
            warn << "Unable to open default BAM index for " << p.inbam () << std::endl;
    }
    if (*p.refname () || p.refno () != -1)
    {
        if (!index_ok)
            ers << "Reference section specified, but the BAM index could not be open." << Throw;
        if (*p.refname ())
        {
            if (p.endpos () != 0)
            {
                infile_.SetReadSection (p.refname (), p.begpos (), p.endpos ());
                info << "Read section set : " << p.refname () << ": " << p.begpos () << "-" << p.endpos () << std::endl;
            }
            else
            {
                infile_.SetReadSection (p.refname ());
                info << "Read section set : " << p.refname () << std::endl;
            }
        }
        else
        {
            if (p.endpos () != 0)
            {
                info << "Read section set : ref# " << p.refno () << ": " << p.begpos () << "-" << p.endpos () << std::endl;
                infile_.SetReadSection (p.refno (), p.begpos (), p.endpos ());
            }
            else
            {
                info << "Read section set : ref# " << p.refno () << std::endl;
                infile_.SetReadSection (p.refno ());
            }
        }
    }
    if (*p.outbam ())
    {
        if (!p.overwrite () && file_exists (p.outbam ()))
            ers << "Output file " << p.outbam () << " exists. Use --ov key to allow overwriting" << Throw;
        outfile_.OpenForWrite (p.outbam ());
        if (!outfile_.IsOpen ())
            ers << "Unable to open output file " << p.outbam () << std::endl;
    }
    if (*p.logfname ())
    {
        if (!p.overwrite () && file_exists (p.logfname ()))
            ers << "Log file " << p.logfname () << " exists. Use --ov key to allow overwriting" << Throw;
        logfile_.open (p.logfname (), std::fstream::out);
        if (!logfile_.is_open ())
            ers << "Unable to open log file " << p.logfname () << std::endl;

        time_t t = time (NULL);
        logfile_ << "Context-aware realigner log\nStarted at " << asctime (localtime (&t)) << "\nParameters:\n";
        logfile_ << *(p.parameters_);
        logfile_ << std::endl;
        log_base_ = p.logging ("base");
        log_diff_ = p.logging ("diff");
        log_matr_ = p.logging ("matr");
    }
    band_width_ = p.bwid ();

    switch (p.algo ())
    {
        case ContalignParams::TEMPL:
        {
            matrix_.configure (genstr::nucleotides.symbols (), genstr::nucleotides.size (), genstr::NegUnitaryMatrix <int, 4>().values ());
            gap_cost_.configure (p.gip (), p.gep ());
            taligner_.configure (&matrix_, &gap_cost_, &gap_cost_, &genstr::nn2num, &genstr::nn2num);
        }
        break;
        case ContalignParams::PLAIN:
        {
            batches_.reset (max_batch_no_);
            aligner_.init (MAX_SEQ_LEN, MAX_SEQ_LEN*MAX_BAND_WIDTH, p.gip (), p.gep (), p.mat (), -p.mis ());
            if (log_matr_)
                aligner_.set_log (logfile_);
            if (p.debug () > 5)
                aligner_.set_trace (true);
        }
        break;
        case ContalignParams::POLY:
        {
            batches_.reset (max_batch_no_);
            contalign_.init (MAX_SEQ_LEN, MAX_RSEQ_LEN, MAX_SEQ_LEN*MAX_BAND_WIDTH, p.gip (), p.gep (), p.mat (), -p.mis ());
            if (log_matr_)
                contalign_.set_log (logfile_);
            if (p.debug () > 5)
                contalign_.set_trace (true);
        }
        break;
        default:
        {
            ers << "Alignment algorithm " << p.algostr () << " not yet supported" << Throw;
        }
    }
    timer_.reset (DEFAULT_REPORT_IVAL, 1);
    return true;
}
Exemple #18
0
 static void closeFileStream(std::ofstream& fileStream) {
     assert_true(fileStream.good());
     fileStream.close();
 }
		uint64_t seek(const uint64_t offs) { m_fp.seekp(offs,std::ios::beg); return m_fp.tellp();  }
Exemple #20
0
 /** Open file stream to write in */
 static void openTextFileStream(std::ofstream& fileStream,
                                const std::string& fileName) {
     fileStream.open(fileName, std::ios::out);
     assert_true(fileStream.is_open());
     fileStream.clear();
 }
		bool close() { m_fp.close(); return true; }
Exemple #22
0
VOID Fini(int, VOID * v)
{   
    out << "# eof" <<  endl;
    out.close();
}
	static void flush(std::ofstream& out)
	{
		out.write(_outBuffer, _outBufferSize);
		_outBufferSize = 0;
	}
void ParticleEmitterComponent::DoSerialization(std::ofstream &saveStream) const
{ 
	saveStream.write((char*)&particleEmitInterval_s, sizeof(particleEmitInterval_s));
	saveStream.write((char*)&lastTimeOfEmission_s, sizeof(lastTimeOfEmission_s));
	saveStream.write((char*)&particlesPerEmission, sizeof(particlesPerEmission));
}
static int process_arg(std::string		&basename,
	std::ofstream 	&fout,
	const int 		argc,
	char* 			argv[],
	float 			&min,
	float			&max,
	int				&num,
	int				&sfid,
	int				&efid)
{
	for (int i = 1; i < argc; ++i){
		std::string arg = argv[i];
		if ((arg == "-h") || (arg == "--help")){
			show_usage(argv[0]);
			return 0;
		}
		else if ((arg == "-i") || (arg == "--input")){
			if (i + 1 < argc){
				//fin.push_back(new std::ifstream(argv[i + 1], std::ios::in));
				basename = argv[i + 1];
				i++;
			}
			else {
				std::cerr << "--input option requires one argument." << std::endl;
				return 1;
			}
		}
		else if ((arg == "-l") || (arg == "--lower")){
			if (i + 1 < argc){
				min = strtof(argv[i + 1], NULL);
				i++;
			}
			else {
				std::cerr << "--input option requires one argument." << std::endl;
				return 1;
			}
		}
		else if ((arg == "-u") || (arg == "--upper")){
			if (i + 1 < argc){
				max = strtof(argv[i + 1], NULL);
				i++;
			}
			else {
				std::cerr << "--input option requires one argument." << std::endl;
				return 1;
			}
		}
		else if ((arg == "-N") || (arg == "--boxes")){
			if (i + 1 < argc){
				num = int(strtof(argv[i + 1], NULL));
				i++;
			}
			else {
				std::cerr << "--input option requires one argument." << std::endl;
				return 1;
			}
		}
		else if ((arg == "-s") || (arg == "--start")){
			if (i + 1 < argc){
				sfid = int(strtod(argv[i + 1], NULL));
				i++;
			}
			else {
				std::cerr << "--input option requires one argument." << std::endl;
				return 1;
			}
		}
		else if ((arg == "-e") || (arg == "--end")){
			if (i + 1 < argc){
				efid = int(strtod(argv[i + 1], NULL));
				i++;
			}
			else {
				std::cerr << "--input option requires one argument." << std::endl;
				return 1;
			}
		}
		else if ((arg == "-o") || (arg == "--output")){
			if (i + 1 < argc){
				fout.open(argv[i + 1]);
				i++;
			}
			else{
				std::cerr << "--output option requires one argument." << std::endl;
				return 1;
			}
		}
		else{
			fout.open("SvT.csv");
			return 2;
		}
	}
}
bool LoadScreenRecord::saveToStream(std::ofstream& output) const
{
  output.write((const char*) &cLSCR, 4);
  if (!saveSizeAndUnknownValues(output, getWriteSize())) return false;

  //write EDID
  output.write((const char*) &cEDID, 4);
  //EDID's length
  uint16_t subLength = editorID.length()+1;
  output.write((const char*) &subLength, 2);
  //write editor ID
  output.write(editorID.c_str(), subLength);

  //write DESC
  if (!text.saveToStream(output, cDESC))
    return false;

  std::vector<CTDA_CIS2_compound>::size_type i;
  for (i=0; i<unknownCTDA_CIS2s.size(); ++i)
  {
    //write CTDA and CIS2
    if (!unknownCTDA_CIS2s[i].saveToStream(output))
    {
      std::cout << "Error while writing CTDA and CIS2 of LSCR!\n";
      return false;
    }
  }//for

  //write NNAM
  output.write((const char*) &cNNAM, 4);
  //NNAM's length
  subLength = 4; //fixed size
  output.write((const char*) &subLength, 2);
  //write NNAM
  output.write((const char*) &unknownNNAM, 4);

  //write SNAM
  output.write((const char*) &cSNAM, 4);
  //SNAM's length
  subLength = 4; //fixed size
  output.write((const char*) &subLength, 2);
  //write SNAM
  output.write((const char*) &unknownSNAM, 4);

  //write RNAM
  output.write((const char*) &cRNAM, 4);
  //RNAM's length
  subLength = 6;
  output.write((const char*) &subLength, 2);
  //write RNAM's stuff
  output.write((const char*) unknownRNAM, 6);

  //write ONAM
  output.write((const char*) &cONAM, 4);
  //ONAM's length
  subLength = 4; //fixed size
  output.write((const char*) &subLength, 2);
  //write ONAM
  output.write((const char*) &unknownONAM, 4);

  //write XNAM
  output.write((const char*) &cXNAM, 4);
  //XNAM's length
  subLength = 12;
  output.write((const char*) &subLength, 2);
  //write XNAM's stuff
  output.write((const char*) unknownXNAM, 12);

  if (!unknownMOD2.empty())
  {
    //write MOD2
    output.write((const char*) &cMOD2, 4);
    //MOD2's length
    subLength = unknownMOD2.length()+1;
    output.write((const char*) &subLength, 2);
    //write model path
    output.write(unknownMOD2.c_str(), subLength);
  }

  return output.good();
}
Exemple #27
0
VOID string_report(const string *s){
  TraceFile.write(s->c_str(), s->size());
}
Exemple #28
0
void rsimpl::log_to_file(rs_log_severity min_severity, const char * file_path)
{
    minimum_file_severity = min_severity;
    log_file.open(file_path, std::ostream::out | std::ostream::app);
    rsimpl::minimum_log_severity = std::min(minimum_console_severity, minimum_file_severity);
}
Exemple #29
0
void OpenAndCleanFiles(){
	if (isDefaultFolder)
	{
		Log.open("..//OutPut//Log.txt", ios::trunc | ios::app);
		if (Log.is_open()) printf("Log File Not Open\n");
	}
	else
	{
		Log.open((OutPutFolder+"Log.txt").c_str(), ios::trunc | ios::app);
	}

	FILE * LogFile;
	errno_t err;
	if (isDefaultFolder)
	{
		err = fopen_s(&LogFile, "..//OutPut//Log.txt", "w");
	}
	else
	{
		err = fopen_s(&LogFile, (OutPutFolder+"Log.txt").c_str(), "w");
	}
	fclose(LogFile);
	ofstream  OutFile;
	if (isDefaultFolder)
	{
		OutFile.open("..//OutPut//Summary.txt", ios::trunc);
		OutFile.close();
		OutFile.open("..//OutPut//Paras.txt", ios::trunc);
		OutFile.close();
		OutFile.open("..//OutPut//PrintInputRequest.txt", ios::trunc);
		OutFile.close();
		OutFile.open("..//OutPut//AirLineDelayAndFairness.txt", ios::trunc);
		OutFile.close();
		OutFile.open("..//OutPut//ResultRequest.txt", ios::trunc);
		OutFile.close();
		OutFile.open("..//OutPut//AllocateTime.txt", ios::trunc);
		OutFile.close();
		OutFile.open("..//OutPut//AirLineByRuleSummary.txt", ios::trunc);
		OutFile.close();
		OutFile.open("..//OutPut//AllMovementDelay.txt", ios::trunc);
		OutFile.close();

		OutFile.open("..//OutPut//GFSummary.txt", ios::trunc);
		OutFile.close();

		OutFile.open("..//OutPut//NewSummary.txt", ios::trunc);
		OutFile.close();

		OutFile.open("..//OutPut//OtherSummary.txt", ios::trunc);
		OutFile.close();

		OutFile.open("..//OutPut//AllAirLineSummary.txt", ios::trunc);
		OutFile.close();


		OutFile.open("..//OutPut//GFMovementDelay.txt", ios::trunc);
		OutFile.close();

		OutFile.open("..//OutPut//NewMovementDelay.txt", ios::trunc);
		OutFile.close();

		OutFile.open("..//OutPut//OtherMovementDelay.txt", ios::trunc);
		OutFile.close();
		
		CplexLog.open("..//OutPut//CplexLog.txt", ios::trunc);
	}
	else
	{
		OutFile.open((OutPutFolder+"Summary.txt").c_str(), ios::trunc);
		OutFile.close();
		OutFile.open((OutPutFolder+"Paras.txt").c_str(), ios::trunc);
		OutFile.close();
		OutFile.open((OutPutFolder+"PrintInputRequest.txt").c_str(), ios::trunc);
		OutFile.close();
		OutFile.open((OutPutFolder+"AirLineDelayAndFairness.txt").c_str(), ios::trunc);
		OutFile.close();
		OutFile.open((OutPutFolder+"ResultRequest.txt").c_str(), ios::trunc);
		OutFile.close();
		OutFile.open((OutPutFolder+"AllocateTime.txt").c_str(), ios::trunc);
		OutFile.close();
		OutFile.open((OutPutFolder+"AirLineByRuleSummary.txt").c_str(), ios::trunc);
		OutFile.close();
		OutFile.open((OutPutFolder+"AllMovementDelay.txt").c_str(), ios::trunc);
		OutFile.close();

		OutFile.open((OutPutFolder + "GFSummary.txt").c_str(), ios::trunc);
		OutFile.close();

		OutFile.open((OutPutFolder + "NewSummary.txt").c_str(), ios::trunc);
		OutFile.close();

		OutFile.open((OutPutFolder + "OtherSummary.txt").c_str(), ios::trunc);
		OutFile.close();

		
		OutFile.open((OutPutFolder + "AllAirLineSummary.txt").c_str(), ios::trunc);
		OutFile.close();

		OutFile.open((OutPutFolder + "GFMovementDelay.txt").c_str(), ios::trunc);
		OutFile.close();

		OutFile.open((OutPutFolder + "NewMovementDelay.txt").c_str(), ios::trunc);
		OutFile.close();
		OutFile.open((OutPutFolder + "OtherMovementDelay.txt").c_str(), ios::trunc);
		OutFile.close();

		CplexLog.open((OutPutFolder + "CplexLog.txt").c_str(), ios::trunc);
	}


}
Exemple #30
0
void writePickle(){

	int data_length = 0;
	current_node = data_stream;
	// find length of linked list
	while (current_node->next != NULL){
		data_length++;
		current_node = current_node->next;
	}
	// create arrays to hold data
	float * zRotArray;
	zRotArray = new float[data_length];
	float * xRotArray;
	xRotArray = new float[data_length];
	float * facingAngle;
	facingAngle = new float[data_length];

	// fill arrays, first node holds no data
	current_node = data_stream->next;
	data_stream_node * temp_node;
	for (int i = 0; i < data_length - 1; i++){
		zRotArray[i] = current_node->zRotAngle;
		xRotArray[i] = current_node->xRotAngle;
		facingAngle[i] = current_node->facingAngle;
		temp_node = current_node;
		current_node = temp_node->next;
		delete temp_node;
	}
	current_node = data_stream;
	
	// construct file name from time
	time_t rawtime;
	struct tm timeinfo;
	char buffer[80];

	time(&rawtime);
	localtime_s(&timeinfo, &rawtime);
	strftime(buffer, 80, "Kinect %Y_%m_%d %H-%M-%S", &timeinfo);
	
	// create txt file
	if (pickled_data == FALSE){
		std::string file_name = std::string(buffer) + ".txt";
		output_file.open(file_name);
		output_file << std::flush;
		output_file << "frames," << std::endl;
		output_file << data_length - 1 << "," << std::endl;
		output_file << "zRotAngle," << std::endl;
		for (int i = 0; i < data_length - 1; i++){
			output_file << zRotArray[i] << ",";
		}
		output_file << std::endl;
		output_file << "xRotAngle," << std::endl;
		for (int i = 0; i < data_length - 1; i++){
			output_file << xRotArray[i] << ",";
		}
		output_file << std::endl;		
		output_file << "facingAngle," << std::endl;
		for (int i = 0; i < data_length - 1; i++){
			if (i < data_length - 2){
				output_file << facingAngle[i] << ",";
			}
			else {
				output_file << facingAngle[i] << std::endl;
			}
		}
		output_file.close();
	}
	// create python pickle file
	else { // pickled_data == TRUE
		std::string file_name = std::string(buffer) + ".p";
		output_file.open(file_name, std::ofstream::binary);
		output_file << std::flush;
		output_file << "(dp0" << "\n";
		output_file << "S'frames'" << "\n";
		output_file << "p1" << "\n";
		output_file << "I" << data_length - 1 << "\n";
		output_file << "sS'zRotAngle'" << "\n";
		output_file << "p2" << "\n";
		output_file << "(lp3" << "\n";
		output_file << "F" << zRotArray[0] << "\n";
		for (int i = 1; i < data_length - 1; i++){
			output_file << "aF" << zRotArray[i] << "\n";
		}
		output_file << "asS'xRotAngle'" << "\n";
		output_file << "p4" << "\n";
		output_file << "(lp5" << "\n";
		output_file << "F" << xRotArray[0] << "\n";
		for (int i = 1; i < data_length - 1; i++){
			output_file << "aF" << xRotArray[i] << "\n";
		}
		output_file << "asS'facingAngle'" << "\n";
		output_file << "p6" << "\n";
		output_file << "(lp7" << "\n";
		output_file << "F" << facingAngle[0] << "\n";
		for (int i = 1; i < data_length - 1; i++){
			output_file << "aF" << facingAngle[i] << "\n";
		}
		output_file << "as.";
		output_file.close();
	}
}