areaDetector 3-14
EPICS areaDetector framework
merlin_low.h
Go to the documentation of this file.
1
8#ifndef MPX_LOW_H
9#define MPX_LOW_H
10
11#include <asynOctetSyncIO.h>
12
13extern int mpxSet(const char *command, const char *value);
14extern int mpxGet(const char *command, char *value);
15extern int mpxCmd(const char *command);
16extern int mpxData(unsigned int *data);
17extern int mpxConnect(const char *host, int commandPort, int dataPort);
18extern int mpxIsConnected(int *conn);
19extern int mpxDisconnect(void);
20
21/* Fixed protocol names*/
22#define MPX_HEADER "MPX"
23#define MPX_SET (char*)"SET"
24#define MPX_GET (char*)"GET"
25#define MPX_CMD (char*)"CMD"
26#define MPX_DATA_HEADER "CMD"
27#define MPX_DATA_ACQ_HDR "HDR"
28#define MPX_QUAD_DATA "MQ1"
29#define MPX_PROFILE "PR1"
30#define MPX_MSG_LEN_DIGITS 10
31#define MPX_MSG_DATATYPE_LEN 3
32
33#define MPX_MAXLINE 256
34#define MPX_IMG_HDR_LEN 256
35#define MPX_IMG_HDR_DAC_LEN 128
36#define MPX_IMG_HDR_MAX_CHIPS 16
37#define MPX_IMG_HDR_FULL_LEN MPX_IMG_HDR_LEN + MPX_IMG_HDR_DAC_LEN * MPX_IMG_HDR_MAX_CHIPS
38#define MPX_ACQUISITION_HEADER_LEN 2044
39
40#define MPX_X_SIZE 256
41#define MPX_Y_SIZE 256
42#define MPX_IMAGE_PIXELS 65536
43#define MPX_IMAGE_BYTES MPX_IMAGE_PIXELS * 2 // 16 bit pixels
44// size of buffer for image frame body including leading comma
45#define MPX_IMG_FRAME_LEN MPX_IMG_HDR_LEN + MPX_IMAGE_BYTES + MPX_MSG_DATATYPE_LEN + 2
46#define MPX_IMG_FRAME_LEN24 MPX_IMG_HDR_LEN + MPX_IMAGE_BYTES * 2 + MPX_MSG_DATATYPE_LEN + 2 // 32 bit pixels in 12 bit mode
47#define MAX_BUFF_MERLIN_QUAD 2000000
48#define MAX_BUFF_UOM 5300000 // TODO verify has this got an extra 0 on it??
49
50// error definitions
51#define MPX_OK 0 /*Ok*/
52#define MPX_ERR 1 /*Unknown Error*/
53#define MPX_ERR_CMD 2 /*Command not known.*/
54#define MPX_ERR_PARAM 3 /*Param out of range.*/
55#define MPX_ERR_BUSY 4 /*The controller is busy and not accepting commands */
56#define MPX_ERR_CONN 100 /*Not connected to detector.*/
57#define MPX_ERR_WRITE 101 /*Error writing to socket.*/
58#define MPX_ERR_READ 102 /*Error reading from socket.*/
59#define MPX_ERR_LEN 103 /*Length of command and value too long, or NULL*/
60#define MPX_ERR_DATA 110 /*Data formatting error.*/
61#define MPX_ERR_UNEXPECTED 111 /*unexpected response from labview */
62
63// variables - Acqusition and Trigger control
64#define MPXVAR_GETSOFTWAREVERSION (char*) "SOFTWAREVERSION"
65#define MPXVAR_DETECTORSTATUS (char*) "DETECTORSTATUS"
66#define MPXVAR_NUMFRAMESTOACQUIRE (char*) "NUMFRAMESTOACQUIRE"
67#define MPXVAR_ACQUISITIONTIME (char*) "ACQUISITIONTIME"
68#define MPXVAR_ACQUISITIONPERIOD (char*) "ACQUISITIONPERIOD"
69#define MPXVAR_TRIGGERSTART (char*) "TRIGGERSTART"
70#define MPXVAR_TRIGGERSTOP (char*) "TRIGGERSTOP"
71#define MPXVAR_NUMFRAMESPERTRIGGER (char*) "NUMFRAMESPERTRIGGER"
72#define MPXVAR_COUNTERDEPTH (char*) "COUNTERDEPTH"
73#define MPXVAR_ENABLECOUNTER1 (char*) "ENABLECOUNTER1"
74#define MPXVAR_CONTINUOUSRW (char*) "CONTINUOUSRW"
75#define MPXVAR_ROI (char*) "ROI"
76#define MPXVAR_ENABLEBACKROUNDCORR (char*) "BCKGRNDCORRECTION"
77#define MPXVAR_BACKGROUNDCOUNT (char*) "BCKGRND"
78#define MPXVAR_ENABLEIMAGEAVERAGE (char*) "IMGAVERAGE"
79#define MPXVAR_IMAGESTOSUM (char*) "IMAGESTOSUM"
80#define MPXVAR_COLOURMODE (char*) "COLOURMODE"
81#define MPXVAR_CHARGESUMMING (char*) "CHARGESUMMING"
82
83// variables Threshold Scan Control
84#define MPXVAR_THSSCAN (char*) "THSCAN"
85#define MPXVAR_THWINDOWMODE (char*) "THWINDOWMODE"
86#define MPXVAR_THWINDOWSIZE (char*) "THWINDOWSIZE"
87#define MPXVAR_THSTART (char*) "THSTART"
88#define MPXVAR_THSTOP (char*) "THSTOP"
89#define MPXVAR_THSTEP (char*) "THSTEP"
90#define MPXVAR_THRESHOLD0 (char*) "THRESHOLD0"
91#define MPXVAR_THRESHOLD1 (char*) "THRESHOLD1"
92#define MPXVAR_THRESHOLD2 (char*) "THRESHOLD2"
93#define MPXVAR_THRESHOLD3 (char*) "THRESHOLD3"
94#define MPXVAR_THRESHOLD4 (char*) "THRESHOLD4"
95#define MPXVAR_THRESHOLD5 (char*) "THRESHOLD5"
96#define MPXVAR_THRESHOLD6 (char*) "THRESHOLD6"
97#define MPXVAR_THRESHOLD7 (char*) "THRESHOLD7"
98#define MPXVAR_OPERATINGENERGY (char*) "OPERATINGENERGY"
99
100// commands
101#define MPXCMD_STARTACQUISITION (char*) "STARTACQUISITION"
102#define MPXCMD_STOPACQUISITION (char*) "STOPACQUISITION"
103#define MPXCMD_THSCAN (char*) "THSCAN"
104#define MPXCMD_SOFTWARETRIGGER (char*) "SWTRIGGER"
105#define MPXCMD_RESET (char*) "RESET"
106#define MPXCMD_PROFILECONTROL (char*) "PROFILES"
107#define MPXCMD_PROFILES (char*) "PROFILES"
108#define MPXCMD_BACKGROUNDACQUIRE (char*) "BCKGRND"
109
110
111// constants for parsing the Chip DAC sections
112static const int dacInfoCount = 19;
113static const char* const dacInfo[] =
114{ "Preamp", "Ikrum", "Shaper", "Disc", "Disc LS", "Shaper Test",
115 "DAC Disc L", "DAC Test", "DAC DISC H", "Delay", "TP Buff In",
116 "TP Buff Out", "RPZ", "GND", "TP Ref", "FBK", "Cas", "TP Ref A",
117 "TP Ref B" };
118
119// constants for parsing the optional fields section
120static const int optFieldsCount = 6;
121static const char* const optFields[] = { "ROI X", "ROI Y", "ROI Width",
122 "ROI Height", "Profile Select", "DACs Present" };
123#define OPT_START_STRING "OPT1"
124#define OPT_END_STRING "END1"
125#define OPT_TOKEN_LEN 4
126#define PROFILE_SELECT_POS 4
127#define DACS_PRESENT_POS 5
128
129// Bits in the PROFILES selection mask
130#define MPXPROFILES_IMAGE 1
131#define MPXPROFILES_XPROFILE 2
132#define MPXPROFILES_YPROFILE 4
133#define MPXPROFILES_SUM 8
134
135
136#endif /* MPX_LOW_H */
int mpxCmd(const char *command)
Send a cmd command.
Definition merlin_low.c:121
int mpxDisconnect(void)
Disconnect from the Labview program.
Definition merlin_low.c:231
int mpxSet(const char *command, const char *value)
Interface library to merlin Labview system.
Definition merlin_low.c:40
int mpxConnect(const char *host, int commandPort, int dataPort)
Connect to the Labview program.
Definition merlin_low.c:158
int mpxGet(const char *command, char *value)
Get a value for the specified command.
Definition merlin_low.c:79
int mpxData(unsigned int *data)
Read the latest data frame.
Definition merlin_low.c:430
int mpxIsConnected(int *conn)
Test the connection status.
Definition merlin_low.c:215
CONNECTION * conn
Definition nullhttpd_extern.c:4