Changeset 13675 for trunk


Ignore:
Timestamp:
05/12/12 18:05:53 (12 years ago)
Author:
tbretz
Message:
Use JavaData; ceck overcurrent status; someother cosetic changes and improvements
File:
1 edited

Legend:

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

    r13643 r13675  
    1919#include "HeadersFTM.h"
    2020
    21 namespace ba    = boost::asio;
    22 namespace bs    = boost::system;
    23 namespace dummy = ba::placeholders;
    24 
    2521using namespace std;
    2622
     
    6056    Time     fMcpConfigurationRunStart;
    6157
    62     enum weather_t { kWeatherBegin=0, kTemp = kWeatherBegin, kDew, kHum, kPress, kWind, kGusts, kDir, kWeatherEnd = kDir };
    63     deque<float> fMagicWeatherHist[kWeatherEnd+1];
     58    enum weather_t { kWeatherBegin=0, kTemp = kWeatherBegin, kDew, kHum, kPress, kWind, kGusts, kDir, kWeatherEnd = kDir+1 };
     59    deque<float> fMagicWeatherHist[kWeatherEnd];
    6460
    6561    vector<float> fFeedbackCalibration;
     
    240236
    241237        ofstream fout("www/"+fname+".bin");
     238        fout << offset << '\n';
     239        fout << offset+scale << '\n';
    242240        fout.write(ptr, val.size()*sizeof(uint8_t));
    243241    }
     
    255253        template<class T>
    256254            Statistics(const T &t, size_t offset_min=0, size_t offset_max=0)
    257         {
     255            : min(0), max(0), med(0), avg(0)
     256        {
     257            if (t.size()==0)
     258                return;
     259
    258260            T copy(t);
    259261            sort(copy.begin(), copy.end());
     
    294296        ostringstream out;
    295297        out << setprecision(3);
    296         out << uint64_t(d.time.UnixTime()*1000) << '\n';
     298        out << d.time.JavaDate() << '\n';
    297299
    298300        out << "#ffffff\t" << fMagicWeatherHist[i].back() << '\n';
     
    312314
    313315        // Store a history of the last 300 entries
    314         for (int i=kWeatherBegin; i<=kWeatherEnd; i++)
     316        for (int i=kWeatherBegin; i<kWeatherEnd; i++)
    315317        {
    316318            fMagicWeatherHist[i].push_back(d.ptr<float>(2)[i]);
     
    330332
    331333        ostringstream out;
    332         out << uint64_t(d.time.UnixTime()*1000) << '\n';
     334        out << d.time.JavaDate() << '\n';
    333335        for (int i=0; i<6; i++)
    334336            out << "#ffffff\t" << fMagicWeatherHist[i].back() << '\n';
     
    367369
    368370        ostringstream out;
    369         out << uint64_t(d.time.UnixTime()*1000) << '\n';
     371        out << d.time.JavaDate() << '\n';
    370372
    371373        out << setprecision(5);
     
    373375        out << az << '\n';
    374376
    375         ofstream fout("www/drive-pointing.txt");
    376         fout << out.str();
     377        ofstream("www/drive-pointing.txt") << out.str();
    377378    }
    378379
     
    411412
    412413        ostringstream out;
    413         out << uint64_t(d.time.UnixTime()*1000) << '\n';
     414        out << d.time.JavaDate() << '\n';
    414415
    415416        out << "#ffffff\t" << fDriveControlSourceName << '\n';
     
    421422        out << "#ffffff\t" << wang << '\n';
    422423
    423         ofstream fout("www/drive.txt");
    424         fout << out.str();
     424        ofstream("www/drive.txt") << out.str();
    425425    }
    426426
     
    462462        ostringstream out;
    463463        out << setprecision(3);
    464         out << uint64_t(d.time.UnixTime()*1000) << '\n';
     464        out << d.time.JavaDate() << '\n';
    465465        out << kHtmlWhite << '\t' << stat.min << '\n';
    466466        out << kHtmlWhite << '\t' << stat.med << '\n';
     
    513513        ostringstream out;
    514514        out << setprecision(3);
    515         out << uint64_t(d.time.UnixTime()*1000) << '\n';
     515        out << d.time.JavaDate() << '\n';
    516516        out << kHtmlWhite << '\t' << stat.min << '\n';
    517517        out << kHtmlWhite << '\t' << stat.med << '\n';
     
    524524    {
    525525        if (!CheckDataSize(d, "FtmControl:TriggerRates", 24+160+640+8))
     526            return;
     527
     528        // New run started
     529        if (d.get<float>(20)<0)
    526530            return;
    527531
     
    547551        ostringstream out;
    548552        out << setprecision(3);
    549         out << uint64_t(d.time.UnixTime()*1000) << '\n';
     553        out << d.time.JavaDate() << '\n';
    550554        out << "#ffffff\t" << fFtmControlTriggerRateCam << '\n';
    551555
     
    556560
    557561        out.str("");
    558         out << uint64_t(d.time.UnixTime()*1000) << '\n';
     562        out << d.time.JavaDate() << '\n';
    559563        out << kHtmlWhite << '\t' << bstat.min << '\n';
    560564        out << kHtmlWhite << '\t' << bstat.med << '\n';
     
    564568
    565569        out.str("");
    566         out << uint64_t(d.time.UnixTime()*1000) << '\n';
     570        out << d.time.JavaDate() << '\n';
    567571        out << kHtmlWhite << '\t' << pstat.min << '\n';
    568572        out << kHtmlWhite << '\t' << pstat.med << '\n';
     
    570574        out << kHtmlWhite << '\t' << pstat.max << '\n';
    571575        ofstream("www/patchrates.txt") << out.str();
    572 
    573 
    574576    }
    575577
     
    584586        //const float *pos = d.ptr<float>(1440*sizeof(float)*3);
    585587
    586         vector<float> max(320, -2000);
     588        vector<float> max(320, -2);
    587589        for (int i=0; i<1440; i++)
    588590        {
     
    591593
    592594            const int idx = (fPixelMap.hw(i).hw()/9)*2+fPixelMap.hw(i).group();
    593             if (dat[i]>max[idx])
    594                 max[idx]=dat[i];
     595            const double v = dat[i]/1000;
     596            if (v>max[idx])
     597                max[idx]=v;
    595598        }
    596599
    597600        switch (d.qos)
    598601        {
    599         case 0:  WriteBinary("fadcontrol-eventdata", max, 2000, -1000); break;
    600         case 1:  WriteBinary("fadcontrol-eventdata", max, 2000,     0); break;
    601         default: WriteBinary("fadcontrol-eventdata", max,  250,    0); break;
     602        case 0:  WriteBinary("fadcontrol-eventdata", max, 2,   -1); break;
     603        case 1:  WriteBinary("fadcontrol-eventdata", max, 2,    0); break;
     604        default: WriteBinary("fadcontrol-eventdata", max, 0.25, 0); break;
    602605        }
    603606    }
     
    646649        ostringstream out;
    647650        out << setprecision(3);
    648         out << uint64_t(d.time.UnixTime()*1000) << '\n';
     651        out << d.time.JavaDate() << '\n';
    649652        out << "#ffffff\t" << min      << '\n';
    650653        out << "#ffffff\t" << avg      << '\n';
     
    815818
    816819        ostringstream out;
    817         out << uint64_t(nearbyint(now.UnixTime()*1000)) << '\n';
     820        out << now.JavaDate() << '\n';
    818821        out << setprecision(3);
    819822
     
    897900
    898901        // --------------- MagicWeather -------------
    899         if (fDimMagicWeather.state()==3)
     902        if (fDimMagicWeather.state()==3 && fMagicWeatherHist[kWeatherBegin].size()>0)
    900903        {
    901904            /*
     
    938941
    939942        // --------------- BiasControl -------------
    940         if (fDimBiasControl.state()==5 || // Ramping
    941             fDimBiasControl.state()==7 || // On
    942             fDimBiasControl.state()==9)   // Off
     943        if (fDimBiasControl.state()==BIAS::kRamping     ||
     944            fDimBiasControl.state()==BIAS::kOverCurrent ||
     945            fDimBiasControl.state()==BIAS::kVoltageOn   ||
     946            fDimBiasControl.state()==BIAS::kVoltageOff)
    943947        {
    944948            string col = fBiasControlVoltageMed>3?kHtmlGreen:kHtmlWhite;
     
    950954            if (fFeedbackCalibration.size()==0)
    951955                col = kHtmlBlue;
     956            if (fDimBiasControl.state()==BIAS::kOverCurrent)
     957                col = kHtmlRed;
    952958
    953959            if (fDimFeedback.state()==13)
     
    956962                out << "***\t";
    957963                out << "***\t";
    958                 out << "---\n";
    959964            }
    960965            else
     
    963968                out << fBiasControlCurrentMed << '\t';
    964969                out << fBiasControlCurrentMax << '\t';
    965                 out << fBiasControlVoltageMed << '\n';
    966970            }
     971            out << fBiasControlVoltageMed << '\n';
    967972        }
    968973        else
     
    977982
    978983        out.str("");
    979         out << uint64_t(nearbyint(now.UnixTime()*1000)) << '\n';
     984        out << now.JavaDate() << '\n';
    980985
    981986        if (fDim.state()==0)
Note: See TracChangeset for help on using the changeset viewer.