Changeset 12853 for trunk/FACT++


Ignore:
Timestamp:
02/06/12 14:26:31 (13 years ago)
Author:
tbretz
Message:
Reverting to last revision.
File:
1 edited

Legend:

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

    r12711 r12853  
    33#include "tools.h"
    44#include "Time.h"
    5 #include "dic.hxx"
     5
    66#include <iostream>
    7 
    8 using namespace std;
    9 struct testType {
    10         long v1;
    11         long v2;
    12         long v3;
    13         long v4;
    14         long v5;
    15         long v6;
    16         long v7;
    17         long v8;
    18         long v9;
    19         long v10;
    20 };
    21 
    22 struct DataLoggerStats {
    23     long sizeWritten;
    24     long freeSpace;
    25     long writingRate;
    26 };
    27 
    28 class StatSub : public DimClient
    29 {
    30     DimStampedInfo* info;
    31     DimStampedInfo* info2;
    32 
    33 public:
    34     StatSub()
    35     {
    36         info = new DimStampedInfo("FAD_CONTROL/START_RUN", const_cast<char*>(""), this);
    37         info2 = new DimStampedInfo("TIME/EMPTY", const_cast<char*>(""), this);
    38     }
    39     void infoHandler()
    40     {
    41         return;
    42         DimInfo* I = getInfo();
    43         if (I == info2)
    44         {
    45             cout << "EMPTY SERVICE UPDATED. " << "Format: " << I->getFormat() << endl;
    46         }
    47         if (I != info)
    48             return;
    49         DataLoggerStats* data = reinterpret_cast<DataLoggerStats*>(I->getData());
    50         std::cout << "size written: " << data->sizeWritten << " free space: " << data->freeSpace << " writing rate" << data->writingRate << std::endl;
    51     }
    52 };
    53 
    54 DimService * myService;
    557
    568int main(int, const char **)
     
    5911    setenv("DIM_DNS_NODE", "localhost", 0);
    6012
    61     cout << "This is the new version of the service 21 July 2011" << endl;
    62 
    6313    // Start a DimServer called TIME
    64     DimServer::start("FAD_CONTROL");
     14    DimServer::start("TIME");
    6515
    6616    // Some info on the console
    6717    std::cout << "Offering TIME/MESSAGE...\n" << std::endl;
    68     long emptyFormatVariable[2];
    69     emptyFormatVariable[0] = 1;
    70     emptyFormatVariable[1] = 2;
    71     const char* format = "X:1;X:1";
    72     DimService* emptyFormatService = new DimService("FAD_CONTROL/START_RUN", "X:1;X:1", emptyFormatVariable, 2*sizeof(long));
    73     testType variable;
    74     variable.v1 = 0;
    75     variable.v2 = 1;
    76     variable.v3 = 2;
    77     variable.v4 = 3;
    78     variable.v5 = 4;
    79     variable.v6 = 5;
    80     variable.v7 = 6;
    81     variable.v8 = 7;
    82     variable.v9 = 8;
    83     variable.v10 = 9;
    84  //   DimDescribedService srvc("TIME/ETIENNE", "X:1;X:1;X:1;X:1;X:1;X:1;X:1;X:1;X:1;X:1", variable, "Test Service");
    8518
    86     StatSub stSub;
    87 //    delete emptyFormatService;
    88  //   usleep(1000000);
    89 //    emptyFormatService = new DimService("TIME/EMPTY", "X:1", &emptyFormatVariable, sizeof(long));
    90 
    91     cout << "Test service created" << endl;
    9219    // Setup a DimService called TIME/MESSAGE
    9320    MessageDimTX msg("TIME");
    9421    while (1)
    9522    {
    96 //        if (variable.v1 %10 == 0)
    97 //        {
    98 //            delete emptyFormatService;
    99 //            cout << "Service deleted" << endl;
    100 //            usleep(1000000);
    101 //            emptyFormatService = new DimService("TIME/EMPTY", "X:1", &emptyFormatVariable, sizeof(long));
    102 //            cout << "Service re-created" << endl;
    103 //        }
     23        // Send current time
     24        msg.Message(Time().GetAsStr());
    10425
    105 //        srvc.updateService();
    106         emptyFormatService->updateService();
    107         emptyFormatVariable[0]++;
    108         emptyFormatVariable[1]++;
    109                 variable.v1++;
    110                 variable.v2++;
    111                 variable.v3++;
    112                 variable.v4++;
    113                 variable.v5++;
    114                 variable.v6++;
    115                 variable.v7++;
    116                 variable.v8++;
    117                 variable.v9++;
    118                 variable.v10++;
    11926        // wait approximately one second
    12027        usleep(1000000);
Note: See TracChangeset for help on using the changeset viewer.