Skip to content

Commit

Permalink
final clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
zack-vii committed May 18, 2021
1 parent 14fd90a commit e5ee2d1
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 152 deletions.
34 changes: 16 additions & 18 deletions device_support/redpitaya/AsyncStoreManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
pthread_mutex_t globalMutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t segmentMutex = PTHREAD_MUTEX_INITIALIZER;


SaveItem::SaveItem(short *buffer, int segmentSamples, MDSplus::TreeNode *dataNode,
MDSplus::Data *triggerTime, void *treePtr,
double *startTimes, double *endTimes, double freq, int blocksInSegment,
MDSplus::TreeNode *resampledNode)
SaveItem::SaveItem(short *buffer, int segmentSamples, MDSplus::TreeNode *dataNode,
MDSplus::Data *triggerTime, void *treePtr,
double *startTimes, double *endTimes, double freq, int blocksInSegment,
MDSplus::TreeNode *resampledNode)
{
this->buffer = buffer;
this->segmentSamples = segmentSamples;
Expand All @@ -17,17 +16,16 @@ SaveItem::SaveItem(short *buffer, int segmentSamples, MDSplus::TreeNode *dataNod
this->blocksInSegment = blocksInSegment;
this->startTimes = new double[blocksInSegment];
this->endTimes = new double[blocksInSegment];
for(int i = 0; i < blocksInSegment; i++)
for (int i = 0; i < blocksInSegment; i++)
{
this->startTimes[i] = startTimes[i];
this->endTimes[i] = endTimes[i];
this->startTimes[i] = startTimes[i];
this->endTimes[i] = endTimes[i];
}
this->freq = freq;
this->resampledNode = resampledNode;
nxt = 0;
}


void SaveItem::save()
{
MDSplus::Array *chanData =
Expand Down Expand Up @@ -62,7 +60,7 @@ void SaveItem::save()
MDSplus::compileWithArgs("$1+$2", treePtr, 2, endData, triggerTime);
try
{
std::cout << "MAKE SEGMENT SAMPLES:"<< segmentSamples << std::endl;
std::cout << "MAKE SEGMENT SAMPLES:" << segmentSamples << std::endl;
dataNode->makeSegment(startSegData, endSegData, timebase, chanData);
}
catch (MDSplus::MdsException &exc)
Expand All @@ -76,10 +74,10 @@ void SaveItem::save()
MDSplus::deleteData(startSegData);
MDSplus::deleteData(endSegData);
delete[] buffer;
delete [] startTimes;
delete [] endTimes;
}
delete[] startTimes;
delete[] endTimes;
}

SaveList::SaveList()
{
int status = pthread_mutex_init(&mutex, NULL);
Expand All @@ -90,13 +88,13 @@ SaveList::SaveList()
}

void SaveList::addItem(short *buffer, int segmentSamples, MDSplus::TreeNode *dataNode,
MDSplus::Data *triggerTime, void *treePtr,
double *startTimes, double *endTimes, double freq, int blocksInSegment,
MDSplus::TreeNode *resampledNode)
MDSplus::Data *triggerTime, void *treePtr,
double *startTimes, double *endTimes, double freq, int blocksInSegment,
MDSplus::TreeNode *resampledNode)

{
SaveItem *newItem = new SaveItem(
buffer, segmentSamples, dataNode, triggerTime, treePtr, startTimes, endTimes, freq, blocksInSegment, resampledNode);
buffer, segmentSamples, dataNode, triggerTime, treePtr, startTimes, endTimes, freq, blocksInSegment, resampledNode);
pthread_mutex_lock(&mutex);

if (saveHead == NULL)
Expand Down
13 changes: 6 additions & 7 deletions device_support/redpitaya/AsyncStoreManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ class SaveItem
double *startTimes, *endTimes;
double freq;
int blocksInSegment;

public:

SaveItem(short *buffer, int segmentSamples, MDSplus::TreeNode *dataNode,
MDSplus::Data *triggerTime, void *treePtr,
double *startTimes, double *endTimes, double freq, int blocksInSegment,
MDSplus::TreeNode *resampledNode = NULL);
SaveItem(short *buffer, int segmentSamples, MDSplus::TreeNode *dataNode,
MDSplus::Data *triggerTime, void *treePtr,
double *startTimes, double *endTimes, double freq, int blocksInSegment,
MDSplus::TreeNode *resampledNode = NULL);

void setNext(SaveItem *itm) { nxt = itm; }
SaveItem *getNext() { return nxt; }
Expand Down Expand Up @@ -70,7 +69,7 @@ class SaveList
SaveList();

void addItem(short *buffer, int segmentSamples, MDSplus::TreeNode *dataNode,
MDSplus::Data *triggerTime, void *treePtr,
MDSplus::Data *triggerTime, void *treePtr,
double *startTimes, double *endTimes, double freq, int blocksInSegment,
MDSplus::TreeNode *resampledNode = NULL);

Expand Down
24 changes: 12 additions & 12 deletions device_support/redpitaya/redpitaya.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <signal.h>
#include <AsyncStoreManager.h>


extern "C"
{
void rpadcStream(int fd, char *treeName, int shot, int chan1Nid, int chan2Nid,
Expand Down Expand Up @@ -226,7 +225,7 @@ static void adcTrigger(int fd)
ioctl(fd, RFX_STREAM_SET_COMMAND_REGISTER, &command);

ioctl(fd, RFX_STREAM_GET_DRIVER_BUFLEN, &command);
std::cout<<"DATA FIFO LEN: " << command << std::endl;
std::cout << "DATA FIFO LEN: " << command << std::endl;
// ioctl(fd, RFX_STREAM_GET_DATA_FIFO_VAL, &command);
// ioctl(fd, RFX_STREAM_GET_TIME_FIFO_LEN, &command);
// ioctl(fd, RFX_STREAM_GET_TIME_FIFO_VAL, &command);
Expand Down Expand Up @@ -261,8 +260,9 @@ static void writeSegment(MDSplus::Tree *t, MDSplus::TreeNode *chan1,
double *endTimes, int segmentSamples,
int blocksInSegment, double freq, SaveList *saveList)
{
std::cout << "WRITE SEGMENT " << segmentSamples;
if(segmentSamples == 0) return;
std::cout << "WRITE SEGMENT " << segmentSamples;
if (segmentSamples == 0)
return;
short *chan1Samples, *chan2Samples;
//std::cout << "WRITE SEGMENT SAMPLES: " << segmentSamples << std::endl;
chan1Samples = new short[segmentSamples];
Expand All @@ -273,12 +273,12 @@ if(segmentSamples == 0) return;
chan1Samples[i] = dataSamples[i] & 0x0000ffff;
chan2Samples[i] = (dataSamples[i] >> 16) & 0x0000ffff;
}

saveList->addItem(chan1Samples, segmentSamples, chan1, triggerTime, t,
startTimes, endTimes, freq, blocksInSegment);

saveList->addItem(chan2Samples, segmentSamples, chan2, triggerTime, t,
startTimes, endTimes, freq, blocksInSegment);
saveList->addItem(chan1Samples, segmentSamples, chan1, triggerTime, t,
startTimes, endTimes, freq, blocksInSegment);

saveList->addItem(chan2Samples, segmentSamples, chan2, triggerTime, t,
startTimes, endTimes, freq, blocksInSegment);
}
// Stop
void rpadcStop(int fd)
Expand Down Expand Up @@ -372,7 +372,7 @@ void rpadcStream(int fd, char *treeName, int shot, int chan1Nid, int chan2Nid,
ioctl(fd, RFX_STREAM_GET_LEV_TRIG_COUNT, &trig_lev_count);
trig_lev_count++;
ioctl(fd, RFX_STREAM_SET_LEV_TRIG_COUNT, &trig_lev_count);

while (true)
{
for (int currBlock = 0; currBlock < blocksInSegment; currBlock++)
Expand All @@ -382,7 +382,7 @@ void rpadcStream(int fd, char *treeName, int shot, int chan1Nid, int chan2Nid,
{
int rb = read(fd, &dataSamples[currBlock * blockSamples + currSample],
(blockSamples - currSample) * sizeof(int));
//std::cout << "READ " << rb << std::endl;
//std::cout << "READ " << rb << std::endl;
currSample += rb / sizeof(int);

if (stopped) // May happen when block readout has terminated or in the
Expand Down Expand Up @@ -424,7 +424,7 @@ void rpadcStream(int fd, char *treeName, int shot, int chan1Nid, int chan2Nid,
ioctl(fd, RFX_STREAM_GET_TIME_FIFO_VAL, &time2);
currTime = (unsigned long long)time1 |
(((unsigned long long)time2) << 32);
std::cout << "MULTIPLE 2 "<< currBlock << std::endl;
std::cout << "MULTIPLE 2 " << currBlock << std::endl;
startTimes[currBlock] = (currTime - preSamples) / freq;
endTimes[currBlock] =
(currTime + postSamples - 1) / freq; // include last sample
Expand Down
Loading

0 comments on commit e5ee2d1

Please sign in to comment.