Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://hea-www.harvard.edu/RD/saotng/shm.html
Дата изменения: Unknown Дата индексирования: Mon Oct 1 22:56:14 2012 Кодировка: Поисковые слова: п п п п п п п п п п п п п п п п п |
SAOtng supports a shared memory XPA public access point through which it can access FITS data created by external programs. The motivation for adding this functionality was to allow near real-time processes (such as a data acquisition systems) to utilize SAOtng's image display capabilities directly. Shared memory support is based on the standard Unix shared memory operations (shmat, etc.). An external process defines a shared memory segment using the shmget and shmat system calls. The shared memory should contain a FITS image (i.e., a data buffer containing a FITS header followed by an image array). For example:
/* size = data buf size */ /* get a shared memory identifier of at least size bytes */ shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0600); /* attach the shared memory segment */ shmbuf = shmat(shmid, 0, 0);The data buffer shmbuf then is filled with a FITS image representation and information about this shared data is sent to SAOtng using XPA and the shm public access point:
char *fmt = "echo \"shm %s %d %d\" | xpaset SAOtng"; /* get info about shared segment, including size of segment */ shmctl(shmid, IPC_STAT, &sbuf); /* send this info to the SAOtng "shm" public access point */ sprintf(tbuf, fmt, shm_name, shmid, sbuf.shm_segsz); system(tbuf);SAOtng will retrieve an image section from the shared memory segment, scale it, and display it. As the external process acquires new data into the shared segment, it can be rescaled and redisplayed by SAOtng using the "rescale" public access point:
/* send a rescale command */ char *cmd="echo rescale | xpaset SAOtng"; system(cmd);Each time SAOtng receives the rescale command, it will access the shared memory image to extract the desired image section, rescale the data, and display it. All SAOtng functions (region markers, analysis, etc.) are available.
External processes can exercise complete control over scaling and data extraction by creating a shared segment containing an 8-bit FITS image the same size as the SAOtng frame, rather than n-bit data of arbitrary dimension. In this case, SAOtng will simply display the already scaled and extracted image.
See also Overview of the X Public Access Mechanism.