Skip to content

Commit

Permalink
Merge pull request #181 from project8/feature/findSkips
Browse files Browse the repository at this point in the history
Feature/find skips
  • Loading branch information
pslocum authored Feb 11, 2021
2 parents 216b263 + f757854 commit db4b819
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
35 changes: 31 additions & 4 deletions Source/Generators/LMCArraySignalGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ namespace locust
ElementFIRBuffer( 1 ),
fFieldBufferSize( 50 ),
fSwapFrequency( 1000 ),
fKassNeverStarted( false ),
fSkippedSamples( false ),
fInterface( new KassLocustInterface() )
{
fRequiredSignalState = Signal::kTime;
Expand Down Expand Up @@ -419,7 +421,7 @@ namespace locust
}


void ArraySignalGenerator::DriveAntenna(FILE *fp, int PreEventCounter, unsigned index, Signal* aSignal, int nfilterbins, double dtfilter)
bool ArraySignalGenerator::DriveAntenna(FILE *fp, int startingIndex, unsigned index, Signal* aSignal, int nfilterbins, double dtfilter)
{

const int signalSize = aSignal->TimeSize();
Expand Down Expand Up @@ -458,6 +460,11 @@ namespace locust

FillBuffers(aSignal, tFieldSolution[1], tFieldSolution[0], fphiLO, index, channelIndex, elementIndex);
double VoltageFIRSample = GetFIRSample(nfilterbins, dtfilter, channelIndex, elementIndex);
if ((VoltageFIRSample == 0.)&&(index-startingIndex > fFieldBufferSize*fPowerCombiner->GetNElementsPerStrip()))
{
LERROR(lmclog,"A digitizer sample was skipped due to likely unresponsive thread.\n");
return false;
}
fPowerCombiner->AddOneVoltageToStripSum(aSignal, VoltageFIRSample, fphiLO, elementIndex, IndexBuffer[channelIndex*fNElementsPerStrip+elementIndex].front());
PopBuffers(channelIndex, elementIndex);

Expand All @@ -469,6 +476,7 @@ namespace locust

fInterface->fTOld += 1./(fAcquisitionRate*1.e6*aSignal->DecimationFactor());
if ( index%fSwapFrequency == 0 ) CleanupBuffers(); // release memory
return true;

}

Expand Down Expand Up @@ -599,6 +607,7 @@ namespace locust
if (fTransmitter->IsKassiopeia())
{
bool fTruth = false;
int startingIndex;
fInterface->fKassTimeStep = 1./(fAcquisitionRate*1.e6*aSignal->DecimationFactor());
std::thread tKassiopeia (&ArraySignalGenerator::KassiopeiaInit, this, gxml_filename); // spawn new thread

Expand All @@ -625,6 +634,7 @@ namespace locust
{
fInterface->fPreEventInProgress = false; // reset.
fInterface->fEventInProgress = true;
startingIndex = index;
LPROG( lmclog, "LMC about to WakeBeforeEvent()" );
WakeBeforeEvent(); // trigger Kass event.
}
Expand All @@ -639,8 +649,17 @@ namespace locust
fInterface->fDigitizerCondition.wait( tLock );
if (fInterface->fEventInProgress)
{
DriveAntenna(fp, PreEventCounter, index, aSignal, nfilterbins, dtfilter);
PreEventCounter = 0; // reset
if (DriveAntenna(fp, startingIndex, index, aSignal, nfilterbins, dtfilter))
{
PreEventCounter = 0; // reset
}
else if (!DriveAntenna(fp, startingIndex, index, aSignal, nfilterbins, dtfilter))
{
LERROR(lmclog,"The antenna did not respond correctly after two tries. Exiting.\n");
fSkippedSamples = true;
tLock.unlock();
break;
}
}
tLock.unlock();
}
Expand All @@ -652,8 +671,13 @@ namespace locust
{
tLock.unlock();
}
else // no Kass event ever started, unlock and break out of signal loop entirely.
else // Kass event has not started, unlock and exit.
{
if ( index < fNPreEventSamples+1 )
{
LERROR(lmclog,"Kass thread is unresponsive. Exiting.\n");
fKassNeverStarted = true;
}
tLock.unlock();
break;
}
Expand All @@ -665,8 +689,11 @@ namespace locust
fInterface->fDoneWithSignalGeneration = true;
if (fTextFileWriting==1) fclose(fp);
LPROG( lmclog, "Finished signal loop." );
fInterface->fWaitBeforeEvent = false;
WakeBeforeEvent();
tKassiopeia.join(); // finish thread
if (fKassNeverStarted == true) return false;
if (fSkippedSamples == true) return false;


} // fTransmitter->IsKassiopeia()
Expand Down
6 changes: 4 additions & 2 deletions Source/Generators/LMCArraySignalGenerator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "LMCSinglePatchPositioner.hh"
#include "LMCPlanarArrayPositioner.hh"
#include <vector>

#include "LMCException.hh"


namespace locust
Expand Down Expand Up @@ -92,6 +92,8 @@ namespace locust
bool fTextFileWriting;
unsigned fFieldBufferSize;
int fSwapFrequency;
bool fKassNeverStarted;
bool fSkippedSamples;
double fphiLO; // voltage phase of LO in radians;

void KassiopeiaInit(const std::string &aFile);
Expand All @@ -117,7 +119,7 @@ namespace locust


bool DoGenerate( Signal* aSignal );
void DriveAntenna(FILE *fp, int PreEventCounter, unsigned index, Signal* aSignal, int nfilterbins, double dtfilter);
bool DriveAntenna(FILE *fp, int startingIndex, unsigned index, Signal* aSignal, int nfilterbins, double dtfilter);
bool InitializeElementArray();
AntennaElementPositioner* fAntennaElementPositioner;
Transmitter* fTransmitter; // transmitter object
Expand Down

0 comments on commit db4b819

Please sign in to comment.