108#include "TRestRawMemoryBufferToSignalProcess.h"
119#if (defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)) || __APPLE__
124 struct semid_ds* buf;
125 unsigned short int* array;
126 struct seminfo* __buf;
130struct sembuf Operacion;
167 Operacion.sem_num = 0;
168 Operacion.sem_op = -1;
169 Operacion.sem_flg = 0;
171 semop(
id, &Operacion, 1);
179 Operacion.sem_num = 0;
180 Operacion.sem_op = 1;
181 Operacion.sem_flg = 0;
183 semop(
id, &Operacion, 1);
190 SetName(
"sharedMemoryBufferToSignal-Default");
191 SetTitle(
"Default config");
193 cout <<
"SharedMemoryBufferToSignal metadata not found. Loading default "
230 cout <<
"TRestRawMemoryBufferToSignalProcess::InitProcess. Creating "
231 "access to shared memory"
235 int memId = shmget(MemKey,
sizeof(daqInfo), 0777);
237 printf(
"Failed to access daqInfo resource\n");
247 printf(
"Failed to access semaphore resource\n");
272 memId = shmget(MemKey, N_DATA *
sizeof(
unsigned short int), 0777 | IPC_CREAT);
274 printf(
"Failed to access buffer resource\n");
278 fShMem_Buffer = (
unsigned short int*)shmat(memId, (
char*)0, 0);
302 if (dataReady == 2) {
311 cout <<
"s : " << s <<
" id : " << signal.
GetSignalID() << endl;
313 for (
int n = 0; n < maxSamples; n++) {
337 cout <<
"------------------------------------------" << endl;
341 cout <<
"------------------------------------------" << endl;
345 cout <<
"Signal N : " << n
A base class for any REST event.
void SetTime(Double_t time)
void SemaphoreRed(int id)
This method will increase the semaphore red level to protect shared memory regions.
TRestRawMemoryBufferToSignalProcess()
Default constructor.
void Initialize() override
Function to initialize input/output event members and define the section name.
void LoadDefaultConfig()
Function to load the default config in absence of RML input.
void BeginOfEventProcess(TRestEvent *inputEvent=nullptr) override
Function including required initialization before each event starts to process.
void InitFromConfigFile() override
Function reading input parameters from the RML TRestRawMemoryBufferToSignalProcess metadata section.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
unsigned short int * fShMem_Buffer
void LoadConfig(const std::string &configFilename, const std::string &name="")
Function to load the configuration from an external configuration file.
void SemaphoreGreen(int id)
This method will increase the semaphore green level to release shared memory regions.
int fSemaphoreId
It is used internally to control the semaphore.
void InitProcess() override
To be executed at the beginning of the run (outside event loop)
TRestRawSignalEvent * fOutputRawSignalEvent
A pointer to the specific TRestRawSignalEvent input.
~TRestRawMemoryBufferToSignalProcess()
Default destructor.
An event container for time rawdata signals with fixed length.
It defines a Short_t array with a physical parameter that evolves in time using a fixed time bin.
Int_t GetID() const
Returns the value of signal ID.
void Print() const
It prints the signal data on screen.
void SetSignalID(Int_t sID)
It sets the id number of the signal.
void AddPoint(Short_t)
Adds a new point to the end of the signal data array.
Int_t GetSignalID() const
Returns the value of signal ID.
@ REST_Extreme
show everything
@ REST_Info
+show most of the information for each steps
@ REST_Debug
+show the defined debug messages
Int_t GetChar(std::string hint="Press a KEY to continue ...")
Helps to pause the program, printing a message before pausing.
Int_t StringToInteger(std::string in)
Gets an integer from a string.