Changeset 10348


Ignore:
Timestamp:
Apr 10, 2011, 10:27:43 AM (9 years ago)
Author:
tbretz
Message:
Undoing change committed by mistake in r10347.
File:
1 edited

Legend:

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

    r10347 r10348  
    66#include <iostream>
    77
    8 class DimDescriptionService
    9 {
    10     static int         fCount;
    11     static DimService *fService;
    12     static std::string fFormat;
    13 
    14     std::string fFmt;
    15 
    16 public:
    17     DimDescriptionService(const std::string &name, const std::string &format)
    18     {
    19         // FIXME: throw is DimServer::itsName==0
    20 
    21         std::string n = std::string(DimServer::itsName)+"/SERVICE_DESC";
    22 
    23         if (!fService)
    24             fService = new DimService(n.c_str(), const_cast<char*>(""));
    25 
    26         fCount++;
    27 
    28         fFmt = name + '=' + format + '\n';
    29 
    30         if (fFormat.find(fFmt)!=std::string::npos)
    31             return;
    32 
    33         fFormat += fFmt;
    34 
    35         fService->setData(const_cast<char*>(fFormat.c_str()));
    36         fService->updateService();
    37 
    38     }
    39     ~DimDescriptionService()
    40     {
    41         const size_t pos = fFormat.find(fFmt);
    42         if (pos!=std::string::npos)
    43             fFormat.replace(pos, fFmt.size(), "");
    44 
    45         if (--fCount>0)
    46             return;
    47 
    48         delete fService;
    49         fService=0;
    50     }
    51 };
    52 
    53 class DimDescribedService : public DimDescriptionService, public DimService
    54 {
    55 public:
    56     template<typename T>
    57         DimDescribedService(const char *name, T &val, const char *desc)
    58         : DimDescriptionService(name, desc), DimService(name, val)
    59     {
    60     }
    61 
    62     DimDescribedService(const char *name, const char *val, const char *desc)
    63         : DimDescriptionService(name, desc), DimService(name, const_cast<char*>(val)) { }
    64 
    65     DimDescribedService(const char *name, char *format, void *structure, int size, const char *desc)
    66         : DimDescriptionService(name, desc), DimService(name, format, structure, size)
    67     {
    68         // FIXME: compare number of ; with number of |
    69     }
    70 };
    71 
    72 DimService *DimDescriptionService::fService = 0;
    73 int DimDescriptionService::fCount = 0;
    74 std::string DimDescriptionService::fFormat;
    75 
    76 
    778int main(int, const char **)
    789{
    79     // We could use putenv to make the Configure class change the value...
     10   // We could use putenv to make the Configure class change the value...
    8011    setenv("DIM_DNS_NODE", "localhost", 0);
    8112
     
    8617    std::cout << "Offering TIME/MESSAGE...\n" << std::endl;
    8718
    88     short s;
    89     int i;
    90     long long ll;
    91     float f;
    92     DimDescribedService servt("TIME/TEST", "C:1;I:1;C", NULL, 0,
    93                               "Char[c]:This is a char|   Int This is an int|String[s]:This is a string");
    94 
    95     DimDescribedService servs("TIME/SHORT",     s,  "[a]");
    96     DimDescribedService servx("TIME/LONGLONG",  ll, ": This is my long long");
    97     DimDescribedService servi("TIME/INT",       i,  "MyInt{mi}");
    98     DimDescribedService servf("TIME/FLOAT",     f,  "   MyFloat  :   This is my float");
    99     DimDescribedService servc("TIME/TIME", const_cast<char*>(""), "MyTime[T]:This is my time");
    100 
    101     DimCommand cmd("TIME/CMD", "I:2;F:2");
    102 
    103     DimDescriptionService des("TIME/CMD", "range[addr]:From DAC to DAC|values[DAC]:DAC values to be set");
    104 
    10519    // Setup a DimService called TIME/MESSAGE
    10620    MessageDimTX msg("TIME");
     
    10923        // Send current time
    11024        msg.Message(Time().GetAsStr());
    111 //        servx.Update();
    112         /*
    113         servs.updateService();
    114         servi.updateService();
    115         servf.updateService();
    116         servc.updateService();
    117          */
     25
    11826        // wait approximately one second
    119         usleep(100000);
     27        usleep(1000000);
    12028    }
    12129
Note: See TracChangeset for help on using the changeset viewer.