Exemple #1
0
void Sim::run() {
  running = true;
  float t0 = 0, t1 = 0, dt = 0;
  float ft = 0, f = 0, fps = 0;
  clock_t start_time = raw_time();
  while (running) {
    t1 = (float) (raw_time() - start_time) * 1e-9;
    dt = t1 - t0;
    t0 = t1;

    if (f > 60) {
      fps = f / (t1 - ft);
      printf("%.1lf fps\n", fps);
      ft = t0;
      f = 0;
    }
    f++;

    keyboard_clear();
    glutMainLoopEvent();
    look();
    if (callback)
      callback(dt, cb_data);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    list<Geometry*>::iterator g, end = geoms.end();
    for(g = geoms.begin(); g != end; g++) {
      (*g)->draw(dt);
    }

    glutSwapBuffers();
  }
}
unsigned long long glwtGetNanoTime()
{
   static unsigned long long base = 0;
   if(base == 0)
      base = raw_time();
   return raw_time() - base;
}
Exemple #3
0
static fa_clock_t new_standard_clock()
{
    fa_ptr_t standard_clock_impl(fa_id_t interface);
    standard_fa_clock_t c = fa_new_struct(standard_clock);

    c->impl = &standard_clock_impl;
    c->origin.milliseconds = raw_milliseconds();
    c->origin.time         = raw_time();

    return (fa_clock_t) c;
	return NULL;
}
Exemple #4
0
static double get_time() {
  return (double) (raw_time() - start_time) * 1e-9;
}
Exemple #5
0
void game_run() {
  glutTimerFunc(16.6667, step, 0);
  start_time = raw_time();
  t0 = get_time();
  glutMainLoop();
}
Exemple #6
0
fa_time_t standard_fa_clock_time(fa_ptr_t x)
{
    standard_fa_clock_t clock = (standard_fa_clock_t) x;
    return fa_subtract(raw_time(), clock->origin.time);
}
Exemple #7
0
int main(int argc, const char *argv[])
{
    try
    {
        CmdArgParser parser(argc, argv);
        parser.setHeader("Archive Export version " ARCH_VERSION_TXT ", "
                         EPICS_VERSION_STRING
                         ", built " __DATE__ ", " __TIME__ "\n\n");
        parser.setArgumentsInfo("<index file> {channel}");
        CmdArgFlag   be_verbose (parser, "verbose", "Verbose mode");
        CmdArgString pattern    (parser, "match", "<reg. exp.>",
                                 "Channel name pattern");
        CmdArgFlag   do_list    (parser, "list", "List all channels");
        CmdArgFlag   do_info    (parser, "info", "Time-range info on channels");
        CmdArgString start_time (parser, "start", "<time>",
                                 "Format: \"mm/dd/yyyy[ hh:mm:ss[.nano-secs]]\"");
        CmdArgString end_time   (parser, "end", "<time>", "(exclusive)");
        CmdArgFlag   status_text(parser, "text",
                                 "Include text column for status/severity (default)");
        CmdArgFlag   no_status_text(parser, "no_text",
                                 "Exclude text column for status/severity");
        CmdArgString output     (parser,
                                 "output", "<file>", "Output to file");
        CmdArgDouble plotbin    (parser,
                                 "plotbin", "<seconds>",
                                 "Bin the raw data for plotting");
        CmdArgDouble average    (parser,
                                 "average", "<seconds>", "average values");
        CmdArgDouble linear     (parser,
                                 "linear", "<seconds>",
                                 "Interpolate values linearly");
        CmdArgString format_txt (parser,
                                 "format", "<decimal|engineering|exponential>",
                                 "Use specific format for numbers");
        CmdArgInt    prec       (parser,
                                 "precision", "<int>", "Precision of numbers");
        CmdArgFlag   GNUPlot    (parser,
                                 "gnuplot", "Generate GNUPlot command file");
        CmdArgFlag   image      (parser,
                                 "Gnuplot", "Generate GNUPlot output for Image");
        CmdArgFlag   raw_time   (parser, "raw_time",
                                 "Include columns for EPICS time stamp");
        CmdArgFlag   millisecs  (parser, "millisecs",
                                 "Truncate time to millisecs in spreadsheet dump.");
        // defaults
        prec.set(-1);
        if (! parser.parse())
            return -1;
        if (parser.getArguments().size() < 1)
        {
            parser.usage();
            return -1;
        }
        precision = prec;
        if (!strncmp(format_txt.get().c_str(), "d", 1))
            format = RawValue::DECIMAL;
        else if (!strncmp(format_txt.get().c_str(), "en", 2))
            format = RawValue::ENGINEERING;
        else if (!strncmp(format_txt.get().c_str(), "ex", 2))
            format = RawValue::EXPONENTIAL;
        else if (format_txt.get().length() > 0)
        {
            fprintf(stderr, "Unknown format string '%s'\n", format_txt.get().c_str());
            return -1;
        }   
        verbose = be_verbose;
        only_millisecs = millisecs;
        // Start/end time
        AutoPtr<epicsTime> start, end;
        stdString txt;
        if (start_time.get().length() > 0)
        {
            start = new epicsTime;
            if (!string2epicsTime(start_time.get(), *start))
            {
                fprintf(stderr, "Parse error for start time '%s'\n",
                        start_time.get().c_str());
                start = 0;
                parser.usage();
                return -1;
            }
            if (verbose)
                printf("Using start time %s\n", epicsTimeTxt(*start, txt));
        }
        if (end_time.get().length() > 0)
        {
            end = new epicsTime();
            if (!string2epicsTime(end_time.get(), *end))
            {
                fprintf(stderr, "Parse error for end time '%s'\n",
                        end_time.get().c_str());
                end = 0;
                parser.usage();
                return -1;
            }
            if (verbose)
                printf("Using end time   %s\n", epicsTimeTxt(*end, txt));
        }
        if (start && end && *start > *end)
        {   // Could simply swap start and end, but assume the user is
            // confused and should rethink the request.
            fprintf(stderr, "start time is greater than end time.\n");
            return -1;
        }
  
        // Index name
        stdString index_name = parser.getArgument(0);
        // Channel names
        stdVector<stdString> names;
        if (parser.getArguments().size() > 1)
        {
            if (! pattern.get().empty())
            {
                fputs("Pattern from '-m' switch is ignored\n"
                      "since a list of channels was also provided.\n", stderr);
            }
            // first argument was directory file name, skip that:
            for (size_t i=1; i<parser.getArguments().size(); ++i)
                names.push_back(parser.getArgument(i));
        }
        if ((GNUPlot || image) && output.get().length() == 0)
        {
    
            fprintf(stderr, "The -gnuplot/Gnuplot options require "
                    "an -output file\n");
            return -1;    
        }
        // How?
        ReaderFactory::How how = ReaderFactory::Raw;
        double delta = 0.0;
        if (double(plotbin) > 0.0)
        {
            how = ReaderFactory::Plotbin;
            delta = double(plotbin);
        }
        else if (double(average) > 0.0)
        {
            how = ReaderFactory::Average;
            delta = double(average);
        }
        else if (double(linear) > 0.0)
        {
            how = ReaderFactory::Linear;
            delta = double(linear);
        }
        // Open index
        AutoIndex index;
        index.open(index_name.c_str());
        if (verbose)
            printf("Opened index '%s'\n", index_name.c_str());
        if (do_info  &&  names.size()<=0  &&  pattern.get().length()<=0)
            do_list.set(); // otherwise it'd be a NOP
        if (names.size() <= 0 &&
            (do_list  ||  pattern.get().length() > 0))
            get_names_for_pattern(index, names, pattern);
        if (do_info)
            list_channels(index, names, true);
        else if (do_list)
            list_channels(index, names, false);
        else if (names.size() > 0)
        {
            if (GNUPlot || image)
                dump_gnuplot(index, names, start, end,
                             how, delta, output, image);
            else
                dump_spreadsheet(index, names, start, end,
                                 raw_time, !no_status_text, how, delta,
                                 output);
        }
        index.close();
    }
    catch (GenericException &e)
    {
        fprintf(stderr, "Error:\n%s\n", e.what());
        return -1;
    } 
    return 0;
}