MIDAS - The Multiple Instance Data Acquisition System

Data Acquisition - Memory Spectrum Server

These procedures provide a method for a data acquisition program to access the counts space of spectra which have been previously created by the MIDAS GUI. The spectrum counts space is mapped into the address space of the data acquisition program which can then easily modify (normally increment) the spectrum. The new data is immediately available for access by the MIDAS GUI using the standard spectrum display methods.
Versions are currently available for LynxOS and Windows.


Usage

   To map a spectrum 

      memaddr = (unsigned long *) sasGetSpecMem(char specname);
      
      memaddr is the virtual address of the base of the counts space of the spectrum
      or NULL if the request failed
      
   To obtain spectrum length

      memlen = (unsigned int) sasGetSpecLen(char specname);
      
      memlen is the length of the spectrum in channels (32 bits)
      
   To unmap a spectrum 

      (void) sasReleaseSpecMem(char specname, unsigned char * memaddr);

specname is the name of the spectrum to be accessed

The spectrum is always created by the server as a 32 bit unsigned histogram
if memaddr is declared to be a (unsigned int *) then channel x of the histogram can be incremented by memaddr[x]++
x should be in the range 0 <= x < memlen


Implementation

A spectrum is created within a shared memory segment (LynxOS/Linux) or shared memory object (Windows). The sasGetSpecMem() procedure call maps this segment or object into the address space of the data acquisition program. The procedure sasGetSpecMem() will return NULL if either the spectrum does not exist (a useful way to discover which spectra are required by the user) or if the system is unable to perform the map.

A spectrum must be released (unmapped) before the GUI can delete it.

 

Back to documentation index documentation index


© 2011 NPG - STFC