Debian Codegraph @

spectro/vtpglut.h

raw symbols SCIP
1
2 #ifndef VTPGLUT_H
3
4 /*
5 * v3dlut/vtpg API definition.
6 *
7 * Abstract base class for common color Video Test Pattern Generator interface
8 * and Video 3DLut devices.
9 */
10
11 /*
12 * Argyll Color Management System
13 *
14 * Author: Graeme W. Gill
15 * Date: 15/3/2001
16 *
17 * Copyright 2001 - 2013 Graeme W. Gill
18 * All rights reserved.
19 *
20 * This material is licenced under the GNU GENERAL PUBLIC LICENSE Version 2 or later :-
21 * see the License2.txt file for licencing details.
22 *
23 */
24
25 #include "dev.h" /* Device base class */
26 #include "insttypes.h" /* libinst Includes this functionality */
27 #include "icoms.h" /* libinst Includes this functionality */
28 #include "conv.h"
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /* ------------------------------------------------- */
35 /* aprox. debug level guide:
36
37 1,2 Applications, internal errors
38 2,3 High level instrument drivers
39 4,5 High level instrument communications
40 6,7 High level serial/USB communications
41 8,9 Low level serial/USB communications
42
43 */
44
45 /* ---------------------------------------- */
46 /* Device interface abstract base class. */
47
48 /* This is used for all device types except color instruments */
49
50 /* Abstract return codes in ms 8bits. */
51 /* Device dependant codes in ls 16 bits. */
52 /* Note :- update vtpglut_interp_error() in other.c if anything here is changed. */
53 /* and also check all the device specific XXX_interp_code() routines too. */
54 typedef enum {
55 vtpglut_ok = 0x000000,
56 vtpglut_notify = 0x010000, /* A Notification */
57 vtpglut_warning = 0x020000, /* A Warning */
58 vtpglut_no_coms = 0x030000, /* init_coms() hasn't been called yet */
59 vtpglut_no_init = 0x040000, /* init_dev() hasn't been called yet */
60 vtpglut_unsupported = 0x050000, /* Unsupported function */
61 vtpglut_internal_error = 0x060000, /* Internal software error */
62 vtpglut_coms_fail = 0x070000, /* Communication failure */
63 vtpglut_unknown_model = 0x080000, /* Not the expected device */
64 vtpglut_protocol_error = 0x090000, /* Read or Write protocol error */
65 vtpglut_user_abort = 0x0A0000, /* User hit escape */
66 vtpglut_user_trig = 0x0C0000, /* User hit trigger key */
67 vtpglut_unexpected_reply = 0x140000, /* Unexpected Reply */
68 vtpglut_wrong_setup = 0x150000, /* Setup is wrong or conflicting */
69 vtpglut_hardware_fail = 0x160000, /* Hardware failure */
70 vtpglut_system_error = 0x170000, /* System call (ie malloc) fail */
71 vtpglut_bad_parameter = 0x180000, /* Bad parameter value */
72 vtpglut_other_error = 0x190000, /* Some other error */
73 vtpglut_mask = 0xff0000, /* vtpglut_code mask value */
74 vtpglut_dmask = 0x00ffff /* device specific mask value */
75 } vtpglut_code;
76
77 /* Device capabilities & modes */
78 /* Note that due to the binary combinations, capabilities is not definititive */
79 /* as to valid modes. check_mode() is definitive. */
80 /* #defines are for saving modes in a version independent way. */
81 /* Note :- update vtpglut_mode_sym[] table in vtpglut.c if anything here is changed. */
82 typedef enum {
83 vtpglut_mode_none = 0x00000000, /* No capability/mode */
84 } vtpglut_mode;
85
86 typedef enum {
87 vtpglut2_none = 0x00000000, /* No capability */
88 } vtpglut_capability;
89
90
91 /* Device options for get_set_opt() */
92 typedef enum {
93 vtpglut_opt_unknown = 0x0000, /* Option not specified */
94 } vtpglut_opt_type;
95
96 /* User interaction callback (uicallback()) function purpose */
97 /* (Make sure vtpglut.c inst_code ser_uicallbac() is updated if this changes. */
98 typedef enum {
99 vtpglut_negcoms /* Negotiating communications - can abort */
100 } vtpglut_ui_purp;
101
102 /* Asynchronous event callback type */
103 typedef enum {
104 inst_event_none /* (Placeholder) */
105 } vtpglut_event_type;
106
107 /* ---------------------------------------- */
108 /* Device interface abstract base class */
109
110 # define EXTRA_VTPGLUT_OBJ
111
112 /* vtpg/v3dlut interface base object */
113 /* Note that some methods work after creation, while many */
114 /* will return an error if communications hasn't been established and */
115 /* the device initialised. Some may change their response before and */
116 /* after initialisation. */
117 #define VTPGLUT_OBJ_BASE \
118 \
119 DEV_OBJ_BASE \
120 \
121 EXTRA_VTPGLUT_OBJ \
122 \
123 vtpglut_code (*uicallback)(void *cntx, vtpglut_ui_purp purp); \
124 void *uic_cntx; /* User interaction callback function */ \
125 void (*eventcallback)(void *cntx, vtpglut_event_type event); \
126 void *event_cntx; /* Asynchronous event callback function */ \
127 \
128 /* Virtual delete. Cleans up things done by new_vtpglut(). */ \
129 vtpglut_code (*vdel)( \
130 struct _vtpglut *p); \
131 \
132 /* Establish communications at the indicated baud rate. */ \
133 /* (Serial parameters are ignored for USB/Network device) */ \
134 /* Timeout in to seconds, and return non-zero error code */ \
135 vtpglut_code (*init_coms)( \
136 struct _vtpglut *p); \
137 \
138 /* Initialise or re-initialise the vtpglut. */ \
139 /* return non-zero on an error, with dev error code */ \
140 vtpglut_code (*init_vtpglut)( \
141 struct _vtpglut *p); \
142 \
143 /* Return the device type */ \
144 /* (this could concievably change after init_vtpglut()) */ \
145 /* Can be called before init */ \
146 devType (*get_dtype)( \
147 struct _vtpglut *p); \
148 \
149 /* Return the device serial number. */ \
150 /* (This will be an empty string if there is no serial no) */ \
151 char *(*get_serial_no)( \
152 struct _vtpglut *p); \
153 \
154 /* Return the available devices modes and capabilities. */ \
155 /* Can be called before init, but may be different to */ \
156 /* what's returned after initilisation. */ \
157 /* Note that these may change with the mode. */ \
158 /* Arguments may be NULL */ \
159 void (*capabilities)(struct _vtpglut *p, \
160 vtpglut_mode *cap1, \
161 vtpglut_capability *cap2); \
162 \
163 /* Check that the particular device measurement mode is valid, */ \
164 /* since it's not possible to be 100% sure from capabilities */ \
165 vtpglut_code (*check_mode)( \
166 struct _vtpglut *p, \
167 vtpglut_mode m); /* Requested mode */ \
168 \
169 /* Set the device mode */ \
170 /* Note that this may change the capabilities. */ \
171 vtpglut_code (*set_mode)( \
172 struct _vtpglut *p, \
173 vtpglut_mode m); /* Requested mode */ \
174 \
175 /* Get a status or get or set an option */ \
176 /* option state. */ \
177 /* Some options can be set before init */ \
178 /* See vtpglut_opt_type typedef for list of mode types */ \
179 vtpglut_code (*get_set_opt)( \
180 struct _vtpglut *p, \
181 vtpglut_opt_type m, /* Requested option mode */ \
182 ...); /* Option parameters */ \
183 \
184 /* Supply a user interaction callback function. \
185 * (Nothing currentlt defined) \
186 * \
187 * NULL can be set to disable the callback. \
188 */ \
189 void (*set_uicallback)(struct _vtpglut *p, \
190 vtpglut_code (*uicallback)(void *cntx, vtpglut_ui_purp purp), \
191 void *cntx); \
192 \
193 /* Supply an aynchronous event callback function. \
194 * This is called from a different thread with the following possible events: \
195 * \
196 * inst_event_XXX: (placeholder) \
197 * \
198 * NULL can be set to disable the callback. \
199 */ \
200 void (*set_event_callback)(struct _vtpglut *p, \
201 void (*eventcallback)(void *cntx, vtpglut_event_type event), \
202 void *cntx); \
203 \
204 /* Generic device error codes interpretation */ \
205 char * (*vtpglut_interp_error)(struct _vtpglut *p, vtpglut_code ec); \
206 \
207 /* Instrument specific error codes interpretation */ \
208 char * (*interp_error)(struct _vtpglut *p, int ec); \
209 \
210 /* Return the last serial communication error code */ \
211 /* (This is used for deciding fallback/retry strategies) */ \
212 int (*last_scomerr)(struct _vtpglut *p); \
213 \
214 /* Destroy ourselves */ \
215 void (*del)(struct _vtpglut *p); \
216
217
218 /* The base object type */
219 struct _vtpglut {
220 VTPGLUT_OBJ_BASE
221 }; typedef struct _vtpglut vtpglut;
222
223 /* Virtual constructor. */
224 /* Return NULL for unknown device, */
225 /* or serial device if nocoms == 0. */
226 /* (Doesn't copy icompaths log!) */
227 extern vtpglut *new_vtpglut(
228 icompath *path, /* Device path for this device */
229 int nocoms, /* Don't open if communications are needed to establish device type */
230 a1log *log, /* Log to use */
231 vtpglut_code (*uicallback)(void *cntx, vtpglut_ui_purp purp),
232 /* optional uicallback for abort */
233 void *cntx /* Context for callback */
234 );
235
236 /* - - - - - - - - - - - - - - - - - - -- */
237
238 #ifdef __cplusplus
239 }
240 #endif
241
242 #define VTPGLUT_H
243 #endif /* VTPGLUT_H */