aboutsummaryrefslogtreecommitdiff
path: root/sys/imio/iki/qpf/qpfopix.x
blob: 9b5750ffe2d4df7132193d2ba643e1b46985b557 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<imhdr.h>
include	<imio.h>
include	"qpf.h"

# QPF_OPIX -- Open the "pixel storage file", i.e., open the special QPF/QPOE
# virtual file driver, which samples the QPOE event list in real time to
# produce image "pixels", where each pixel contains a count of the number of
# photons mapping to that point in the output image matrix.

procedure qpf_opix (im, status)

pointer	im			#I image descriptor
int	status			#O return status

pointer	sp, fname, qpf
extern	qpfzop(), qpfzrd(), qpfzwr(), qpfzwt(), qpfzst(), qpfzcl()
int	fopnbf()

begin
	status = OK
	if (IM_PFD(im) != NULL)
	    return

	# Verify that the QPIO open succeeded at open time; if not, the file
	# may not have an event list (which is legal, but not for pixel i/o).

	qpf = IM_KDES(im)
	if (QPF_IO(qpf) == NULL) {
	    status = ERR
	    return
	}

	call smark (sp)
	call salloc (fname, SZ_FNAME, TY_CHAR)

	# Encode the QPF descriptor as a pseudo-filename to pass the descriptor
	# through fopnbf to the QPF virtual binary file driver.

	call sprintf (Memc[fname], SZ_FNAME, "QPF%d")
	    call pargi (IM_KDES(im))

	# Open a file descriptor for the dummy QPOE file driver, used to access
	# the event list as a virtual pixel array (sampled at runtime).

	iferr (IM_PFD(im) = fopnbf (Memc[fname], READ_ONLY,
	    qpfzop, qpfzrd, qpfzwr, qpfzwt, qpfzst, qpfzcl)) {

	    IM_PFD(im) = NULL
	    status = ERR
	}

	call sfree (sp)
end