Changeset 12805 for trunk/FACT++


Ignore:
Timestamp:
02/01/12 09:09:38 (13 years ago)
Author:
tbretz
Message:
Store calibration; implemented command to print a stored calibration; fixed a bug which caused the feedback to remain in state Calibrating even a STOP command was issued.
File:
1 edited

Legend:

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

    r12716 r12805  
    9393    vector<int64_t>  fCurrentsRms;
    9494
     95    vector<double>   fCalibration;
     96
    9597    vector<vector<float>> fData;
    9698
     
    243245            }
    244246
    245             vector<float> val(2*416, 0);
     247            fCalibration.resize(416);
    246248            for (int i=0; i<416; i++)
    247249            {
    248                 val[i]     = double(fCurrentsAvg[i])/fCursor;
    249                 val[i+416] = sqrt(double(fCurrentsRms[i])/fCursor-val[i]*val[i]);
    250             }
    251 
    252             fDimCalibration.Update(val);
     250                fCalibration[i]     = double(fCurrentsAvg[i])/fCursor;
     251                fCalibration[i+416] = sqrt(double(fCurrentsRms[i])/fCursor-val[i]*val[i]);
     252            }
     253
     254            fDimCalibration.Update(fCalibration);
    253255
    254256            fOutputEnabled = false;
     
    522524    }
    523525
     526    int PrintCalibration()
     527    {
     528        if (fCalibration.size()==0)
     529        {
     530            Out() << "No calibration performed so far." << endl;
     531            return GetCurrentStatus();
     532        }
     533
     534        for (int k=0; k<13; k++)
     535            for (int j=0; j<8; j++)
     536            {
     537                Out() << setw(2) << k << "|" << setw(2) << j*4 << "|";
     538                for (int i=0; i<4; i++)
     539                    Out() << Tools::Format(" %6.1f+-4.1f", fCalibration[i], fCalibration[i+416]);
     540                Out() << endl;
     541            }
     542        }
     543
     544        return GetCurrentState();
     545    }
     546
    524547    int SetConstant(const EventImp &evt, int constant)
    525548    {
     
    644667        fCurrentsAvg.assign(416, 0);
    645668        fCurrentsRms.assign(416, 0);
     669        fCalibration.resize(0);
    646670        fStartTime = Time();
    647671        fOutputEnabled = true;
     
    673697            fStatusFSC.second<2)
    674698            return kStateConnecting;
    675 
    676         if (GetCurrentState()==kStateCalibrating && fCursor<100)
    677             return GetCurrentState();
    678699
    679700/*
     
    720741
    721742        if (fControlType==kTemp)
     743        {
     744            if (GetCurrentState()==kStateCalibrating && fCursor<100)
     745                return GetCurrentState();
     746
    722747            return fOutputEnabled ? kStateTempCtrlRunning : kStateTempCtrlIdle;
     748        }
    723749
    724750        return kStateConnected;
     
    834860        AddEvent("PRINT")
    835861            (bind(&StateMachineFeedback::Print, this))
     862            ("");
     863
     864        AddEvent("PRINT_CALIBRATION")
     865            (bind(&StateMachineFeedback::PrintCalibration, this))
    836866            ("");
    837867    }
Note: See TracChangeset for help on using the changeset viewer.