Changeset 11228 for trunk/FACT++/src


Ignore:
Timestamp:
07/01/11 08:30:53 (13 years ago)
Author:
tbretz
Message:
Layout update FAD tab
Location:
trunk/FACT++/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/argv.cc

    r10707 r11228  
    44
    55using namespace std;
     6
     7template<class T,class S>
     8std::ostream &operator<<(std::ostream &out, const pair<T,S> &f)
     9{
     10    out << f.first << "|" << f.second;
     11    return out;
     12}
     13template<class T, class S>
     14std::istream &operator>>(std::istream &in,  pair<T,S> &f)
     15{
     16    char c;
     17    in >> f.first;
     18    in >> c;
     19    if (c!=':')
     20        return in;
     21    in >> f.second;
     22    return in;
     23}
     24
     25typedef pair<int,int> mytype;
     26
     27
     28//Source is OutputStreamable, meaning that an operator<< is defined
     29// that takes a std::ostream or std::wostream object on the left hand side
     30// and an instance of the argument type on the right.
     31
     32// Target is InputStreamable, meaning that an operator>> is defined that
     33// takes a std::istream or std::wistream object on the left hand side and
     34// an instance of the result type on the right.
     35
     36//Target is CopyConstructible [20.1.3].
     37//Target is DefaultConstructible, meaning that it is possible to default-initialize an object of that type [8.5, 20.1.4].
    638
    739// --------------------------------------------------------------------------
     
    82114        ("switch",        po_switch(),                    "include path")
    83115        ("bool",          var<bool>()->implicit_value(true),                    "include path")
     116        ("mytype",        var<mytype>(),                  "include path")
    84117        ;
    85118
     
    172205    cout << conf.Has("switch") << " " << conf.Get<bool>("switch") << endl;
    173206    cout << conf.Has("bool") << " " << conf.Get<bool>("bool") << endl;
     207    cout << conf.Has("mytype") << " " << conf.Get<mytype>("mytype") << endl;
    174208
    175209    return 0;
  • trunk/FACT++/src/fad.cc

    r11209 r11228  
    8989        fHeader.fTriggerId = fHeader.fEventCounter;
    9090        fHeader.fTimeStamp = uint32_t((Time(Time::utc).UnixTime()-fStartTime)*10000);
     91        fHeader.fFreqRefClock = 997+rand()/(RAND_MAX/7);
    9192
    9293        for (int i=0; i<FAD::kNumTemp; i++)
  • trunk/FACT++/src/logtime.cc

    r10348 r11228  
    66#include <iostream>
    77
     8#include "DimDescriptionService.h"
     9
    810int main(int, const char **)
    911{
    10    // We could use putenv to make the Configure class change the value...
     12    // We could use putenv to make the Configure class change the value...
    1113    setenv("DIM_DNS_NODE", "localhost", 0);
    1214
     
    1416    DimServer::start("TIME");
    1517
     18    usleep(2000000);
     19
     20    DimServer::stop();
     21
     22    return 0;
     23
    1624    // Some info on the console
    1725    std::cout << "Offering TIME/MESSAGE...\n" << std::endl;
     26
     27    short s;
     28    int i;
     29    long long ll;
     30    float f;
     31    DimDescribedService servt("TIME/TEST", "O:1;I:1;C",
     32                              "This is my test command|Char[c]:This is a char|   Int This is an int|String[s]:This is a string");
     33
     34    DimDescribedService servs("TIME/SHORT",     s,  "[a]");
     35    DimDescribedService servx("TIME/LONGLONG",  ll, "|: This is my long long");
     36    DimDescribedService servi("TIME/INT",       i,  "|MyInt  [  mi  ] ");
     37    DimDescribedService servf("TIME/FLOAT",     f,  "|   MyFloat  :   This is my float");
     38    DimDescribedService servc("TIME/TIME", const_cast<char*>(""), "|MyTime[T]:This is my time");
     39
     40    DimCommand cmd("TIME/CMD", "I:2;F:2");
     41
     42    DimDescriptionService des("TIME/CMD", "|range[addr]:From DAC to DAC|values[DAC]:DAC values to be set");
     43
     44    {
     45    Time t0;
    1846
    1947    // Setup a DimService called TIME/MESSAGE
     
    2351        // Send current time
    2452        msg.Message(Time().GetAsStr());
     53//        servx.Update();
     54        /*
     55        servs.updateService();
     56        servi.updateService();
     57        servf.updateService();
     58        servc.updateService();
     59         */
     60        // wait approximately one second
     61        usleep(100000);
    2562
    26         // wait approximately one second
    27         usleep(1000000);
     63//        if (t0.UnixTime()-Time().UnixTime()<-5)
     64//            break;
    2865    }
     66    }
     67
     68    DimDescribedService servxx("TIME/XXX", const_cast<char*>(""), "|MyTime[T]:This is my time");
     69    usleep(10000000);
    2970
    3071    return 0;
  • trunk/FACT++/src/tools.cc

    r10429 r11228  
    1212#include <stdarg.h>
    1313
     14#include <boost/filesystem.hpp>
     15
    1416using namespace std;
    15 
     17/*
    1618string Tools::Format(const char *fmt, va_list &ap)
    1719{
     
    4951    return str;
    5052}
     53*/
    5154
    5255// --------------------------------------------------------------------------
     
    5457//! This is a static helper to remove leading and trailing whitespaces.
    5558//!
    56 //! @param buf
     59//! @param str
    5760//!    a pointer to the char array from which the whitespaces should be
    5861//!    removed
     
    7376    return str.substr(start, end-start+1);
    7477}
     78
     79// --------------------------------------------------------------------------
     80//
     81//! Splits a string of the form [SERVER/]COMMAND[ arguments]
     82//! into SERVER, COMMAND and arguments.
     83//!
     84//! @param str
     85//!    string to be splitted
     86//!
     87//! @returns
     88//!    a vector<string> with three components. Depending on what is existing
     89//!    in the string some of the components might be empty.
     90//!
     91/*
     92vector<string> Split(std::string str)
     93{
     94    const size_t p0 = str.find_first_of('/');
     95
     96    size_t p1 = str.find_first_of(' ');
     97
     98    vector<string> v(3);
     99
     100    // string starts with SERVER/COMMAND[ arguments]
     101    if (p0<p1)
     102    {
     103        // SERVER
     104        v[0] = str.substr(0, p0);
     105
     106        // COMMAND[ arguments)
     107        str = str.substr(p0+1);
     108        p1  = str.find_first_of(' ');
     109    }
     110
     111    // String is of the form: COMMAND[ arguments]
     112
     113    // COMMAND
     114    v[1] = str.substr(0, p1);
     115
     116    // Has arguments
     117    if (p1!=string::npos)
     118        v[2] = str.substr(p1+1);
     119
     120    return v;
     121}
     122*/
  • trunk/FACT++/src/tools.h

    r10429 r11228  
    11#include <string>
     2#include <vector>
    23
    34namespace Tools
    45{
    5     std::string Format(const char *fmt, va_list &ap);
    6     std::string Form(const char *fmt, ...);
     6//    std::string Format(const char *fmt, va_list &ap);
     7//    std::string Form(const char *fmt, ...);
    78    std::string Trim(const std::string &str);
    89}
Note: See TracChangeset for help on using the changeset viewer.