~ubuntu-branches/ubuntu/trusty/argyll/trusty-proposed

« back to all changes in this revision

Viewing changes to spectro/inst.h

  • Committer: Package Import Robot
  • Author(s): Artur Rona
  • Date: 2014-02-12 00:35:39 UTC
  • mfrom: (13.1.24 sid)
  • Revision ID: package-import@ubuntu.com-20140212003539-24tautzlitsiz61w
Tags: 1.5.1-5ubuntu1
* Merge from Debian unstable. (LP: #1275572) Remaining changes:
  - debian/control:
    + Build-depend on libtiff-dev rather than libtiff4-dev.
  - debian/control, debian/patches/06_fix_udev_rule.patch:
    + Fix udev rules to actually work; ENV{ACL_MANAGE} has
      stopped working ages ago, and with logind it's now the
      "uaccess" tag. Dropping also consolekit from Recommends.
  - debian/patches/drop-usb-db.patch:
    + Use hwdb builtin, instead of the obsolete usb-db
      in the udev rules.
* debian/patches/05_ftbfs-underlinkage.diff:
  - Dropped change, no needed anymore.
* Refresh the patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
#ifndef INST_H
3
3
 
 
4
 /* instlib API definition. */
 
5
 
 
6
 /* See spotread.c, chartread.c, illumread.c & ccxxmake.c for examples of */
 
7
 /* the API usage. */
 
8
 
4
9
 /* Abstract base class for common color instrument interface */
5
10
 /* and other common instrument stuff.                        */
6
11
 
10
15
 * Author: Graeme W. Gill
11
16
 * Date:   15/3/2001
12
17
 *
13
 
 * Copyright 2001 - 2010 Graeme W. Gill
 
18
 * Copyright 2001 - 2013 Graeme W. Gill
14
19
 * All rights reserved.
15
20
 *
16
21
 * This material is licenced under the GNU GENERAL PUBLIC LICENSE Version 2 or later :-
45
50
#endif
46
51
 
47
52
/* ------------------------------------------------- */
 
53
/* aprox. debug level guide:
 
54
 
 
55
        1,2  Applications, internal errors
 
56
        2,3  High level instrument drivers
 
57
        4,5  High level instrument communications
 
58
        6,7  High level serial/USB communications
 
59
        8,9  Low level serial/USB communications
 
60
 
 
61
*/
 
62
 
 
63
/* ------------------------------------------------- */
48
64
/* Structure for holding an instrument patch reading */
49
65
 
50
66
#define ICOM_MAX_LOC_LEN 10
51
67
 
 
68
/* Type of measurement result */
 
69
typedef enum {                                          /* XYZ units,      spectral units */
 
70
        inst_mrt_none           = 0,    /* Not set */
 
71
        inst_mrt_emission       = 1,    /* cd/m^2,         mW/m^2/nm */
 
72
        inst_mrt_ambient        = 2,    /* Lux/3.1415926   ?? */
 
73
        inst_mrt_emission_flash = 3,    /* cd/m^2.s,       mW/m^2/nm.s*/
 
74
        inst_mrt_ambient_flash  = 4,    /* Lux/3.1415926/s ?? */
 
75
        inst_mrt_reflective     = 5,    /* %,              %/nm */
 
76
        inst_mrt_transmissive   = 6             /* %,              %/nm */
 
77
} inst_meas_type;
 
78
 
52
79
struct _ipatch {
53
80
        char loc[ICOM_MAX_LOC_LEN];     /* patch location */
54
81
 
55
 
        int XYZ_v;                      /* XYZ valid */
56
 
        double XYZ[3];          /* XYZ values, 0.0 .. 100.0% */
57
 
 
58
 
        int aXYZ_v;                     /* Absolute XYZ valid */
59
 
        double aXYZ[3];         /* XYZ values in cd/m^2 or Lux/PI */
60
 
                                                /* or cd/m^2 seconds for flash. */
61
 
 
62
 
        int Lab_v;                      /* Lab valid */
63
 
        double Lab[3];          /* Lab value */
 
82
        inst_meas_type mtype;   /* Measurement type */
 
83
        
 
84
        int XYZ_v;                              /* XYZ valid */
 
85
        double XYZ[3];                  /* XYZ values */
64
86
 
65
87
        xspect sp;                      /* Spectrum. sp.spec_n > 0 if valid */
66
88
                                                /* Reflectance/Transmittance 0.0 .. 100.0%, norm = 100.0 */
67
 
                                                /* or mW/nm/m^2, norm = 1.0  */
 
89
                                                /* or mW/nm/m^2, norm = 1.0, etc.  */
68
90
 
69
91
        double duration;        /* Apparent total duration in seconds (flash measurement) */
 
92
                                                /* Typicall limited to sampling rate of instrument. */
70
93
 
71
94
}; typedef struct _ipatch ipatch;
72
95
 
89
112
        inst_unknown_model     = 0x0800,        /* Not the expected instrument */
90
113
        inst_protocol_error    = 0x0900,        /* Read or Write protocol error */
91
114
        inst_user_abort        = 0x0A00,        /* User hit escape */
92
 
        inst_user_term         = 0x0B00,        /* User hit terminate key */
93
115
        inst_user_trig         = 0x0C00,        /* User hit trigger key */
94
 
        inst_user_cmnd         = 0x0D00,        /* User hit command key */
95
116
        inst_misread           = 0x0E00,        /* Bad reading, or strip misread */
96
117
        inst_nonesaved         = 0x0F00,        /* No saved data to read */
97
118
        inst_nochmatch         = 0x1000,        /* Chart doesn't match */
98
119
        inst_needs_cal         = 0x1100,        /* Instrument needs calibration, and read retried */
99
120
        inst_cal_setup         = 0x1200,        /* Calibration retry with correct setup is needed */
100
 
        inst_wrong_sensor_pos  = 0x1300,        /* Reading retry with correct sensor position is needed */
 
121
        inst_wrong_config      = 0x1300,        /* Retry with correct inst. config./sensor posn. needed */
101
122
        inst_unexpected_reply  = 0x1400,        /* Unexpected Reply */
102
 
        inst_wrong_config      = 0x1500,    /* Configuration is wrong */
 
123
        inst_wrong_setup       = 0x1500,    /* Setup is wrong or conflicting */
103
124
        inst_hardware_fail     = 0x1600,    /* Hardware failure */
104
125
        inst_bad_parameter     = 0x1700,        /* Bad parameter value */
105
126
        inst_other_error       = 0x1800,        /* Some other error */
107
128
        inst_imask             = 0x00ff         /* instrument specific mask value */
108
129
} inst_code;
109
130
 
110
 
/* Instrument capabilities */
111
 
/* (Some instrument capabilities may be mode dependent) */
112
 
typedef enum {
113
 
        inst_unknown            = 0x00000000, /* Capabilities can't be determined */
114
 
 
115
 
        inst_ref_spot           = 0x00000001, /* Capable of reflection spot measurement */
116
 
        inst_ref_strip          = 0x00000002, /* Capable of reflection strip measurement */
117
 
        inst_ref_xy             = 0x00000004, /* Capable of reflection X-Y page measurement */
118
 
        inst_ref_chart          = 0x00000008, /* Capable of reflection chart measurement */
119
 
        inst_reflection         = 0x0000000F, /* Capable of general reflection measurements */
120
 
 
121
 
        inst_s_ref_spot         = 0x00000010, /* Capable of saved reflection spot measurement */
122
 
        inst_s_ref_strip        = 0x00000020, /* Capable of saved reflection strip measurement */
123
 
        inst_s_ref_xy           = 0x00000040, /* Capable of saved reflection X-Y page measurement */
124
 
        inst_s_ref_chart        = 0x00000080, /* Capable of saved reflection chart measurement */
125
 
        inst_s_reflection       = 0x000000F0, /* Capable of general saved reflection measurements */
126
 
 
127
 
        inst_trans_spot         = 0x00000100, /* Capable of transmission spot measurement */
128
 
        inst_trans_strip        = 0x00000200, /* Capable of transmission strip measurement */
129
 
        inst_trans_xy           = 0x00000400, /* Capable of transmission X-Y measurement */
130
 
        inst_trans_chart        = 0x00000800, /* Capable of transmission chart measurement */
131
 
        inst_transmission       = 0x00000F00, /* Capable of general transmission measurements */
132
 
 
133
 
        inst_emis_spot          = 0x00001000, /* Capable of emission spot measurement */
134
 
        inst_emis_strip         = 0x00002000, /* Capable of emission strip measurement */
135
 
        inst_emis_disp          = 0x00004000, /* Capable of display emission measurement */
136
 
        inst_emis_proj          = 0x00008000, /* Capable of projector emission measurement */
137
 
        inst_emis_disptype      = 0x00010000, /* Has a display type selector */
138
 
        inst_emis_disptypem     = 0x00020000, /* Setting display type is mandatory */
139
 
        inst_emis_tele          = 0x00040000, /* Capable of telephoto emission measurement */
140
 
        inst_emis_ambient       = 0x00080000, /* Capable of ambient measurement */
141
 
        inst_emis_ambient_flash = 0x00100000, /* Capable of ambient flash measurement */
142
 
        inst_emis_ambient_mono  = 0x00200000, /* The ambient measurement is monochrome */
143
 
        inst_emission           = 0x003FF000, /* Capable of general emission measurements */
144
 
 
145
 
        inst_colorimeter        = 0x01000000, /* Colorimetric capability */
146
 
        inst_spectral           = 0x02000000, /* Spectral capability */
147
 
        inst_highres            = 0x04000000, /* High Resolution Spectral mode */
148
 
        inst_ccmx               = 0x08000000, /* Colorimeter Correction Matrix capability */
149
 
        inst_ccss               = 0x10000000  /* Colorimeter Calibration Spectral Set capability */
150
 
 
151
 
} inst_capability;
152
 
 
153
 
/* Instrument capabilities 2 */
154
 
typedef enum {
155
 
        inst2_unknown           = 0x00000000, /* Capabilities can't be determined */
156
 
 
157
 
        inst2_xy_holdrel        = 0x00000001, /* Needs paper hold/release between each sheet */
158
 
        inst2_xy_locate         = 0x00000002, /* Needs user to locate patch locations */
159
 
        inst2_xy_position       = 0x00000004, /* Can be positioned at a given location */
160
 
 
161
 
        inst2_cal_ref_white     = 0x00000010, /* Uses a reflective white/dark calibration */
162
 
        inst2_cal_ref_dark      = 0x00000020, /* Uses a reflective dark calibration */
163
 
        inst2_cal_trans_white   = 0x00000040, /* Uses a transmissive white reference calibration */
164
 
        inst2_cal_trans_dark    = 0x00000080, /* Uses a transmissive dark reference calibration */
165
 
        inst2_cal_disp_offset   = 0x00000100, /* Uses a display offset/black calibration */
166
 
        inst2_cal_disp_ratio    = 0x00000200, /* Uses a display ratio calibration */
167
 
        inst2_cal_disp_int_time = 0x00000400, /* Uses a display integration time calibration */
168
 
        inst2_cal_proj_offset   = 0x00000800, /* Uses a display offset/black calibration */
169
 
        inst2_cal_proj_ratio    = 0x00001000, /* Uses a display ratio calibration */
170
 
        inst2_cal_proj_int_time = 0x00002000, /* Uses a display integration time calibration */
171
 
        inst2_cal_crt_freq      = 0x00004000, /* Uses a refresh display calibration */
172
 
 
173
 
        inst2_prog_trig         = 0x00010000, /* Progromatic trigger measure capability */
174
 
        inst2_keyb_trig         = 0x00020000, /* Keyboard trigger measure capability */
175
 
        inst2_switch_trig       = 0x00040000, /* Inst. switch trigger measure capability */
176
 
        inst2_keyb_switch_trig  = 0x00080000, /* keyboard or switch trigger measure capability */
177
 
 
178
 
        inst2_bidi_scan         = 0x00100000, /* Try and recognise patches scanned from either dir. */
179
 
        inst2_cal_using_switch  = 0x00200000, /* DTP22 special - use switch triggered calibration */
180
 
        inst2_has_scan_toll     = 0x00400000, /* Instrument will honour modified scan tollerance */
181
 
        inst2_no_feedback       = 0x00800000, /* Instrument doesn't give any user feedback */
182
 
 
183
 
        inst2_has_leds          = 0x01000000, /* Instrument has some user viewable indicator LEDs */
184
 
        inst2_has_sensmode      = 0x02000000, /* Instrument can report it's sensors mode */
185
 
 
186
 
        inst2_has_battery       = 0x04000000  /* Instrument is battery powered */
187
 
 
188
 
} inst2_capability;
189
 
 
190
 
 
191
 
/* Instrument status commands for get_opt_details() */
192
 
typedef enum {
193
 
        inst_optdet_unknown           = 0x0000, /* Option detail type not specified */
194
 
 
195
 
        inst_optdet_disptypesel       = 0x0001  /* Return array of display type selectors */
196
 
                                                                                        /* [args: int *no_selectors,inst_disptypesel **sels] */
197
 
} inst_optdet_type;
198
 
 
199
 
/* Structure used to return display type selection information */
200
 
typedef struct _inst_disptypesel {
201
 
        int ix;                                 /* Selection index */
202
 
        char sel[10];                   /* String of selector characters */
203
 
        char desc[100];                 /* Textural description */
204
 
        int  ref;                               /* Refresh mode flag */
205
 
} inst_disptypesel;
206
 
 
207
 
 
208
 
/* Instrument measurement modes and sub-modes */
209
 
/* We assume that there can only be one measurement mode at a time */
210
 
typedef enum {
211
 
        inst_mode_unknown            = 0x0000,  /* Mode not specified */
212
 
 
213
 
        /* Sub modes that compose operating modes: */
 
131
/* Instrument capabilities & modes */
 
132
/* Note that due to the binary combinations, capabilities is not definititive */
 
133
/* as to valid modes. check_mode() is definitive. */
 
134
typedef enum {
 
135
        inst_mode_none               = 0x00000000, /* No capability or mode */
214
136
 
215
137
        /* Mode of light measurement */
216
 
        inst_mode_reflection         = 0x0001,  /* General reflection mode */
217
 
        inst_mode_s_reflection       = 0x0002,  /* General saved reflection mode */
218
 
        inst_mode_transmission       = 0x0003,  /* General transmission mode */
219
 
        inst_mode_emission           = 0x0004,  /* General emission mode */
220
 
        inst_mode_illum_mask         = 0x000f,  /* Mask of sample illumination sub mode */
 
138
        inst_mode_reflection         = 0x00000001,      /* General reflection mode */
 
139
        inst_mode_s_reflection       = 0x00000002,      /* General saved reflection mode */
 
140
        inst_mode_transmission       = 0x00000004,      /* General transmission mode */
 
141
        inst_mode_emission           = 0x00000008,      /* General emission mode */
 
142
        inst_mode_illum_mask         = 0x0000000f,      /* Mask of sample illumination sub mode */
221
143
 
222
144
        /* Access mode of measurement */
223
 
        inst_mode_spot               = 0x0010,  /* General spot measurement mode */
224
 
        inst_mode_strip              = 0x0020,  /* General strip measurement mode */
225
 
        inst_mode_xy                 = 0x0030,  /* General X-Y measurement mode */
226
 
        inst_mode_chart              = 0x0040,  /* General chart measurement mode */
227
 
        inst_mode_ambient            = 0x0050,  /* General ambient measurement mode */
228
 
        inst_mode_ambient_flash      = 0x0060,  /* General ambient flash measurement mode */
229
 
        inst_mode_tele               = 0x0070,  /* General telephoto measurement mode */
230
 
        inst_mode_sub_mask           = 0x00f0,  /* Mask of sub-mode */
231
 
 
232
 
        /* Measurement modifiers */
233
 
        inst_mode_disp               = 0x0100,  /* Display device (non-adaptive/refresh) mode */
234
 
        inst_mode_mod_mask           = 0x0f00,  /* Mask of measurement modifiers */
 
145
        inst_mode_spot               = 0x00000010,      /* General spot measurement mode */
 
146
        inst_mode_strip              = 0x00000020,      /* General strip measurement mode */
 
147
        inst_mode_xy                 = 0x00000040,      /* General X-Y measurement mode */
 
148
        inst_mode_chart              = 0x00000080,      /* General chart measurement mode */
 
149
        inst_mode_ambient            = 0x00000100,      /* General ambient measurement mode */
 
150
        inst_mode_ambient_flash      = 0x00000200,      /* General ambient flash measurement mode */
 
151
        inst_mode_tele               = 0x00000400,      /* General telephoto measurement mode */
 
152
        // Hmm. Should there be a tele_flash mode ????
 
153
        inst_mode_sub_mask           = 0x000007f0,      /* Mask of sub-mode */
 
154
 
 
155
        /* Basic mode */
 
156
        inst_mode_basic_mask         = inst_mode_illum_mask | inst_mode_sub_mask,
 
157
 
 
158
/*
 
159
        possible UV modes:
 
160
 
 
161
        Do the reflective measurement with UV rather than normal illuminant
 
162
        [ Should this be reflectivity against 'A', or absolute ?? ]
 
163
        (ie. spot, strip, xy or chart). inst_mode_ref_uv
 
164
 
 
165
        Do a white & UV measurement at the start of each strip reading.
 
166
        Return result with special call after each strip read.
 
167
                                        inst_mode_ref_uv_strip_1
 
168
 
 
169
        Do a dual white & UV measurement
 
170
        [ Can do in one hit for spot, but how should two strip passes be handled ?
 
171
          ie. two separate strip reads of phase 1 & then 2 ? ]
 
172
        (ie. spot, strip, xy or chart). inst_mode_ref_uv_2pass 
 
173
 
 
174
        Get normal illuminant spectrum.
 
175
        
 
176
        Get UV spectrum.
 
177
 
 
178
                                        get_meas_illum_spectrum(mode);
 
179
 */
 
180
 
 
181
        /* Extra dependent modes */
 
182
        inst_mode_emis_nonadaptive   = 0x00000800,      /* Emissom Non-adaptive mode */
 
183
        inst_mode_ref_uv             = 0x00001000,      /* Ultra Violet measurement mode */
 
184
        inst_mode_emis_refresh_ovd   = 0x00002000,      /* Emissom Refresh mode override */
 
185
        inst_mode_emis_norefresh_ovd = 0x00006000,      /* Emissom Non-refresh mode override */
 
186
        inst_mode_dep_extra_mask     = 0x00007800,      /* Mask of measurement modifiers */
 
187
 
 
188
        /* Extra independent modes */
 
189
        inst_mode_colorimeter        = 0x00004000,      /* Colorimetric mode */
 
190
        inst_mode_spectral           = 0x00008000,      /* Spectral mode */
 
191
        inst_mode_highres            = 0x00010000,      /* High Resolution Spectral mode */
 
192
        inst_mode_extra_mask         = 0x0001c000,      /* Mask of extra modes */
 
193
 
 
194
        /* Configured for calibration & capable of returning it from inst_mode_calibration */
 
195
        inst_mode_calibration        = 0x80000000,      /* Configured for calibration */
235
196
 
236
197
        /* Combined operating modes (from above): */
 
198
        /* These mode capabilities are also use to set the mode */
 
199
        /* Test for a mode should be IMODETST(flags, mode) */
237
200
        inst_mode_ref_spot           = inst_mode_spot   /* Reflection spot measurement mode */
238
201
                                     | inst_mode_reflection,
239
202
        inst_mode_ref_strip          = inst_mode_strip  /* Reflection strip measurement mode */
263
226
 
264
227
        inst_mode_emis_spot          = inst_mode_spot   /* Spot emission measurement mode */
265
228
                                     | inst_mode_emission,
266
 
        inst_mode_emis_strip         = inst_mode_strip  /* Strip emission measurement mode */
267
 
                                     | inst_mode_emission,
268
 
        inst_mode_emis_disp          = inst_mode_disp   /* Display emission measurement mode */
269
 
                                     | inst_mode_spot
270
 
                                     | inst_mode_emission,
271
 
        inst_mode_emis_proj          = inst_mode_disp   /* Projector emission measurement mode */
272
 
                                     | inst_mode_tele
273
 
                                     | inst_mode_emission,
274
229
        inst_mode_emis_tele          = inst_mode_tele   /* Telephoto emission measurement mode */
275
230
                                     | inst_mode_emission,
276
231
        inst_mode_emis_ambient       = inst_mode_ambient        /* Ambient emission measurement mode */
278
233
        inst_mode_emis_ambient_flash = inst_mode_ambient_flash  /* Ambient emission flash measurement */
279
234
                                     | inst_mode_emission,
280
235
 
281
 
        inst_mode_measurement_mask   = inst_mode_mod_mask       /* Mask of exclusive measurement modes */
 
236
        inst_mode_emis_strip         = inst_mode_strip  /* Strip emission measurement mode */
 
237
                                     | inst_mode_emission,
 
238
 
 
239
        inst_mode_measurement_mask   = inst_mode_illum_mask     /* Mask of exclusive measurement modes */
282
240
                                     | inst_mode_sub_mask
283
 
                                     | inst_mode_illum_mask,
284
 
 
285
 
        /* Independent extra modes */
286
 
        inst_mode_colorimeter        = 0x1000,  /* Colorimetric mode */
287
 
        inst_mode_spectral           = 0x2000   /* Spectral mode */
288
 
 
 
241
                                     | inst_mode_dep_extra_mask
289
242
} inst_mode;
290
243
 
291
 
/* Instrument options for set_opt_mode() */
 
244
/* Test for a specific mode */
 
245
#define IMODETST(mbits, mode) (((mbits) & (mode)) == (mode))
 
246
 
 
247
/* Test for a specific mode in capability and mode */
 
248
#define IMODETST2(mcap, mbits, mode) (IMODETST(mcap, mode) && IMODETST(mbits, mode))
 
249
 
 
250
/* Instrument capabilities 2 */
 
251
/* (Available capabilities may be mode dependent) */
 
252
typedef enum {
 
253
        inst2_none              = 0x00000000, /* No capabilities */
 
254
 
 
255
        inst2_xy_holdrel        = 0x00000001, /* Needs paper hold/release between each sheet */
 
256
        inst2_xy_locate         = 0x00000002, /* Needs user to locate patch locations */
 
257
        inst2_xy_position       = 0x00000004, /* Can be positioned at a given location */
 
258
 
 
259
        inst2_meas_disp_update  = 0x00000010, /* Is able to measure display update delay */
 
260
        inst2_refresh_rate      = 0x00000020, /* Is able to retrieve the calibrated refresh rate */
 
261
 
 
262
        inst2_prog_trig         = 0x00000100, /* Progromatic trigger measure capability */
 
263
        inst2_user_trig         = 0x00000200, /* User trigger measure capability */
 
264
        inst2_switch_trig       = 0x00000400, /* Inst. switch trigger measure capability */
 
265
        inst2_user_switch_trig  = 0x00000800, /* User or switch trigger measure capability */
 
266
 
 
267
        inst2_bidi_scan         = 0x00001000, /* Try and recognise patches scanned from either dir. */
 
268
        inst2_cal_using_switch  = 0x00002000, /* DTP22 special - use switch triggered calibration */
 
269
        inst2_has_scan_toll     = 0x00004000, /* Instrument will honour modified scan tollerance */
 
270
        inst2_no_feedback       = 0x00008000, /* Instrument doesn't give any user feedback */
 
271
 
 
272
        inst2_has_leds          = 0x00200000, /* Instrument has some user viewable indicator LEDs */
 
273
        inst2_has_sensmode      = 0x00400000, /* Instrument can report it's sensors mode */
 
274
 
 
275
        inst2_has_battery       = 0x00800000, /* Instrument is battery powered */
 
276
 
 
277
        inst2_disptype          = 0x01000000, /* Has a display type selector */
 
278
        inst2_ccmx              = 0x02000000, /* Colorimeter Correction Matrix capability */
 
279
        inst2_ccss              = 0x04000000, /* Colorimeter Cal. Spectral Set capability */
 
280
 
 
281
        inst2_ambient_mono      = 0x08000000, /* The ambient measurement is monochrome */
 
282
 
 
283
        inst2_emis_refr_meas    = 0x10000000, /* Has an emissive refresh rate measurement func. */
 
284
 
 
285
} inst2_capability;
 
286
 
 
287
/* Instrument capabilities 3 (room for expansion) */
 
288
/* (Available capabilities may be mode dependent) */
 
289
typedef enum {
 
290
        inst3_none              = 0x00000000, /* No capabilities */
 
291
 
 
292
} inst3_capability;
 
293
 
 
294
typedef enum {
 
295
        inst_dtflags_none    = 0x0000,                  /* no flags */
 
296
        inst_dtflags_default = 0x0001,                  /* default display type */
 
297
        inst_dtflags_ccss    = 0x0002,                  /* ccss */
 
298
        inst_dtflags_ccmx    = 0x0004,                  /* ccmx */
 
299
        inst_dtflags_end     = 0x8000                   /* end marker */
 
300
 
 
301
} inst_dtflags;
 
302
 
 
303
#define INST_DTYPE_SEL_LEN 10
 
304
#define INST_DTYPE_DESC_LEN 100
 
305
 
 
306
/* Structure used to return display type selection information */
 
307
typedef struct _inst_disptypesel {
 
308
 
 
309
  /* Public: */
 
310
        inst_dtflags flags;             /* Attribute flags */
 
311
        int cbid;                               /* Calibration base ID. NZ if valid ccmx calibration base. */
 
312
                                                        /* Should remain constant between releases */
 
313
        char sel[INST_DTYPE_SEL_LEN];   /* String of selector characters */
 
314
        char desc[INST_DTYPE_DESC_LEN]; /* Textural description */
 
315
        int  refr;                              /* Refresh mode flag */
 
316
 
 
317
  /* Private: */
 
318
        int ix;                                 /* Internal index,  */
 
319
 
 
320
        // Stuff for ccss & ccmx
 
321
        char *path;                             /* Path to ccss or ccmx */
 
322
        double mat[3][3];               /* ccmx matrix */
 
323
        xspect *sets;                   /* ccss set of sample spectra */
 
324
        int no_sets;                    /* ccs number of sets */
 
325
 
 
326
} inst_disptypesel;
 
327
 
 
328
/* Instrument options for get_set_opt() */
292
329
typedef enum {
293
330
        inst_opt_unknown            = 0x0000,   /* Option not specified */
294
331
 
295
 
        inst_opt_autocalib          = 0x0001,   /* Enable auto calibration (default) [No args] */
296
 
        inst_opt_noautocalib        = 0x0002,   /* Disable auto calibration [No args] */
297
 
 
298
 
        inst_opt_disp_type          = 0x0003,   /* Set display type by inst_disptypesel index [int] */
299
 
                                                                                        /* 0 sets to default, if not inst_emis_disptypem */ 
300
 
 
301
 
        inst_opt_set_filter         = 0x0007,   /* Set a filter configuration */
302
 
                                                                                        /* [1 argument type inst_opt_filter] */
303
 
 
304
 
        inst_opt_trig_prog          = 0x0008,   /* Trigger progromatically [No args] */
305
 
        inst_opt_trig_keyb          = 0x0009,   /* Trigger from keyboard (default) [No args] */
306
 
        inst_opt_trig_switch        = 0x000A,   /* Trigger using instrument switch [No args] */
307
 
        inst_opt_trig_keyb_switch   = 0x000B,   /* Trigger using keyboard or switch (def) [No args] */
308
 
 
309
 
        inst_opt_trig_return        = 0x000C,   /* Hack - emit "\n" after switch/kbd trigger [No args] */
310
 
        inst_opt_trig_no_return     = 0x000D,   /* Hack - don't emit "\n" after trigger (def) [No args] */
311
 
 
312
 
        inst_opt_highres            = 0x000E,   /* Enable high resolution spectral mode */
313
 
        inst_opt_stdres             = 0x000F,   /* Revert to standard resolution spectral mode */
314
 
 
315
 
        inst_opt_scan_toll          = 0x0010,   /* Modify the patch scan recognition tollnce [double] */
316
 
 
317
 
        inst_opt_get_gen_ledmask    = 0x0011,   /* Get the bitmask for general indication LEDs [*int] */
318
 
                                                                                        /* (More specialized indicator masks go here) */
319
 
        inst_opt_set_led_state      = 0x0012,   /* Set the current LED state. 0 = off, 1 == on [int] */
320
 
        inst_opt_get_led_state      = 0x0013,   /* Get the current LED state. 0 = off, 1 == on [*int] */
321
 
 
322
 
        inst_opt_get_pulse_ledmask  = 0x0014,   /* Get the bitmask for pulseable ind. LEDs [*int] */
323
 
        inst_opt_set_led_pulse_state= 0x0015,   /* Set the current LED state. [double period_in_secs, */
324
 
                                                /* double on_time_prop, double trans_time_prop] */
325
 
        inst_opt_get_led_pulse_state= 0x0016    /* Get the current pulse LED state. [*double period, */
326
 
 
327
 
} inst_opt_mode;
328
 
 
329
 
/* Instrument status commands for get_status() */
330
 
typedef enum {
331
 
        inst_stat_unknown           = 0x0000,   /* Status type not specified */
332
 
 
333
332
        inst_stat_saved_readings    = 0x0001,   /* Return status of saved reading values */ 
334
333
                                                                                        /* [1 argument type *inst_stat_savdrd] */
335
334
        inst_stat_s_spot            = 0x0002,   /* Return number of saved spot readings */ 
348
347
        inst_stat_battery           = 0x0006,   /* Return charged status of battery */
349
348
                                                                                        /* [1 argument type *double : range 0.0 - 1.0 ] */
350
349
 
351
 
        inst_stat_sensmode          = 0x0007,   /* Return sensor mode */
352
 
                                                                                        /* [1 argument type *inst_stat_smode ] */
353
 
 
354
 
        inst_stat_get_filter        = 0x0008    /* Set a filter configuration */
 
350
        inst_stat_get_filter        = 0x0007,   /* Get a filter configuration */
355
351
                                                                                        /* [1 argument type *inst_opt_filter ] */
356
 
} inst_status_type;
357
 
 
 
352
 
 
353
        inst_opt_initcalib          = 0x0008,   /* Enable initial calibration (default) [No args] */
 
354
        inst_opt_noinitcalib        = 0x0009,   /* Disable initial calibration if < losecs since last */                                                                                        /* opened, or losecs == 0 [int losecs] */
 
355
 
 
356
        inst_opt_set_ccss_obs       = 0x000A,   /* Set the observer used with ccss device types */
 
357
                                                                                        /* Only takes effect after inst_opt_set_disp_type */ 
 
358
                                                                                        /* or col_cal_spec_set() */
 
359
                                                                                        /* [args: icxObserverType obType,*/
 
360
                                                /*        xspect custObserver[3] */
 
361
 
 
362
        inst_opt_get_dtinfo         = 0x000C,   /* Get current display type information */
 
363
                                                                                        /* [args: int *refrmode,*/
 
364
                                                /*        int *cbid] */
 
365
 
 
366
        inst_opt_set_filter         = 0x000D,   /* Set a filter configuration */
 
367
                                                                                        /* [1 argument type inst_opt_filter] */
 
368
 
 
369
        inst_opt_trig_prog          = 0x000E,   /* Trigger progromatically [No args] */
 
370
        inst_opt_trig_user          = 0x000F,   /* Trigger from user via uicallback [No args] */
 
371
        inst_opt_trig_switch        = 0x0010,   /* Trigger using instrument switch [No args] */
 
372
        inst_opt_trig_user_switch   = 0x0011,   /* Trigger from user via uicallback or switch (def) [No args] */
 
373
 
 
374
        inst_opt_highres            = 0x0012,   /* Enable high resolution spectral mode */
 
375
        inst_opt_stdres             = 0x0013,   /* Revert to standard resolution spectral mode */
 
376
 
 
377
        inst_opt_scan_toll          = 0x0014,   /* Modify the patch scan recognition tollnce [double] */
 
378
 
 
379
        inst_opt_get_gen_ledmask    = 0x0015,   /* Get the bitmask for general indication LEDs [*int] */
 
380
                                                                                        /* (More specialized indicator masks go here) */
 
381
        inst_opt_set_led_state      = 0x0016,   /* Set the current LED state. 0 = off, 1 == on [int] */
 
382
        inst_opt_get_led_state      = 0x0017,   /* Get the current LED state. 0 = off, 1 == on [*int] */
 
383
        inst_opt_get_pulse_ledmask  = 0x0018,   /* Get the bitmask for pulseable ind. LEDs [*int] */
 
384
        inst_opt_set_led_pulse_state= 0x0019,   /* Set the current LED state. [double period_in_secs, */
 
385
                                                /* double on_time_prop, double trans_time_prop] */
 
386
        inst_opt_get_led_pulse_state= 0x001A    /* Get the current pulse LED state. [*double period, */
 
387
 
 
388
} inst_opt_type;
358
389
 
359
390
/* Optional filter fitted to instrument (for inst_opt_set_filter) */
360
391
typedef enum {
375
406
        inst_stat_savdrd_chart   = 0x08                 /* There are saved chart readings available */
376
407
} inst_stat_savdrd;
377
408
 
378
 
/* Sensor mode/position (status) */
379
 
/* Note that this is a mask, as the same position may be suitable */
380
 
/* for several different types of measurement. */
381
 
typedef enum {
382
 
        inst_stat_smode_unknown = 0x00, /* Unknown mode */
383
 
        inst_stat_smode_calib   = 0x01, /* Calibration tile */
384
 
        inst_stat_smode_ref     = 0x02, /* Reflective */
385
 
        inst_stat_smode_disp    = 0x04, /* Display */
386
 
        inst_stat_smode_proj    = 0x08, /* Projector */
387
 
        inst_stat_smode_amb     = 0x10  /* Ambient */
388
 
} inst_stat_smode;
389
 
 
390
 
/* Type of user interaction */
391
 
typedef enum {
392
 
        inst_verb              = 0x00,  /* verbose message */
393
 
        inst_question          = 0x01   /* A question requiring answers */
394
 
} inst_uiact;
395
 
 
396
 
/* Type of calibration needed/requested - corresponds to capabilities */
 
409
/* Type of calibration needed/available/requested - corresponds to capabilities */
 
410
/* [ inst_calt_trans_vwhite is "variable" white transmission calibration, needed */
 
411
/*   where transmission mode is being emulated. ] */
397
412
typedef enum {
398
413
        /* Response to needs_calibration() */
399
 
        inst_calt_unknown        = 0x00,        /* Unknown whether calibration is needed */
400
 
        inst_calt_none           = 0x01,        /* No callibration is needed */
401
 
 
402
 
        /* Type to prompt all needed calibrations */
403
 
        inst_calt_all            = 0x10,        /* All applicable calibrations */
404
 
 
405
 
        /* Specific type of calibration - corresponds to capabilities */
406
 
        inst_calt_ref_white      = 0x20,        /* Reflective white/emissive dark calibration */
407
 
        inst_calt_ref_dark       = 0x30,        /* Reflective dark calibration (in dark) */
408
 
        inst_calt_disp_offset    = 0x40,        /* Display offset/black calibration (dark surface) */
409
 
        inst_calt_disp_ratio     = 0x50,        /* Display ratio calibration */
410
 
        inst_calt_proj_offset    = 0x60,        /* Display offset/black calibration (dark surface) */
411
 
        inst_calt_proj_ratio     = 0x70,        /* Display ratio calibration */
412
 
        inst_calt_crt_freq       = 0x80,        /* Display CRT scan frequency calibration */
413
 
        inst_calt_disp_int_time  = 0x90,        /* Display integration time */
414
 
        inst_calt_proj_int_time  = 0xA0,        /* Display integration time */
415
 
        inst_calt_em_dark        = 0xB0,        /* Emissive dark calibration (in dark) */
416
 
        inst_calt_trans_white    = 0xC0,        /* Transmissive white reference calibration */
417
 
        inst_calt_trans_dark     = 0xD0,        /* Transmissive dark reference calibration */
418
 
 
419
 
        inst_calt_needs_cal_mask = 0xF0         /* One of the calibrations in needed */
 
414
        inst_calt_none           = 0x00000000,  /* No calibration or unknown */
 
415
 
 
416
        /* Psudo-calibration types */
 
417
        inst_calt_all            = 0x00000001,  /* Do required non-deferable cals for mode, but also */
 
418
                                                                                    /* do all possible calibrations for all other modes */
 
419
                                                                                    /* using the calibration conditions. This may be slow */
 
420
        /* Hmm. We don't have an "calt_all_needed" - do all needed cals of all possible modes. */
 
421
        /* This might be more useful than inst_calt_all ? */
 
422
        inst_calt_needed         = 0x00000002,  /* Do all required non-deferable cals for c.m. */
 
423
        inst_calt_available      = 0x00000003,  /* Do all available non-deferable cals for c.m. */
 
424
 
 
425
        /* Specific type of calibration - corresponds to capabilities  */
 
426
        inst_calt_wavelength     = 0x00000010,  /* Wavelength calibration using refl. cal. surface */ 
 
427
        inst_calt_ref_white      = 0x00000020,  /* Reflective white/emissive dark calibration */
 
428
        inst_calt_ref_dark       = 0x00000040,  /* Reflective dark calibration (in dark) */
 
429
        inst_calt_emis_offset    = 0x00000080,  /* Emissive offset/black calibration (dark surface) */
 
430
        inst_calt_emis_ratio     = 0x00000100,  /* Emissive ratio calibration */
 
431
        inst_calt_em_dark        = 0x00000200,  /* Emissive dark calibration (in dark) */
 
432
        inst_calt_trans_white    = 0x00000400,  /* Transmissive white reference calibration */
 
433
        inst_calt_trans_vwhite   = 0x00000800,  /* Transmissive variable white reference calibration */
 
434
        inst_calt_trans_dark     = 0x00001000,  /* Transmissive dark reference calibration */
 
435
 
 
436
        inst_calt_n_dfrble_mask  = 0x0000fff0,  /* Mask of non-deferrable calibrations */
 
437
 
 
438
        /* Calibrations that might be deferred until measurement */
 
439
        inst_calt_emis_int_time  = 0x00100000,  /* Emissive measurement range (integration time) */
 
440
        inst_calt_ref_freq       = 0x00200000,  /* Display refresh frequency calibration */
 
441
 
 
442
        inst_calt_dfrble_mask    = 0x00f00000,  /* Mask of deferrable calibrations */
 
443
 
 
444
        inst_calt_all_mask       = 0x00f0fff0,  /* Mask of all specific calibrations */
 
445
 
 
446
        inst_calt_ap_flag        = 0x80000000   /* Implementation flag indicating do all possible */
420
447
 
421
448
} inst_cal_type;
422
449
 
423
450
/* Calibration conditions. */
424
451
/* This is how the instrument communicates to the calling program */
425
 
/* about how to facilitate a calibration */
 
452
/* about how to facilitate a calibration, or what it's current measurement */
 
453
/* configuration provides. */
 
454
/* [There is no provission for explictly indicating calibrations that can be */
 
455
/* performed automatically and transparently by the instrument - for instance */
 
456
/* in the case of the spectroscan, since the required condition can be obtained */
 
457
/* without the users interaction. ] */
426
458
typedef enum {
427
 
        inst_calc_none             = 0x00000000, /* No particular calibration setup, or unknown */
 
459
        inst_calc_none             = 0x00000000, /* Not suitable for calibration */
 
460
        inst_calc_unknown          = 0xffffffff, /* Unknown calibration setup */
428
461
 
 
462
                                                        /* uop means that user has to trigger the within instrument */
 
463
                                                        /* calibration using its "front panel" or other direct keys */
429
464
        inst_calc_uop_ref_white    = 0x00000001, /* user operated reflective white calibration */
430
465
        inst_calc_uop_trans_white  = 0x00000002, /* user operated tranmissive white calibration */
431
466
        inst_calc_uop_trans_dark   = 0x00000003, /* user operated tranmissive dark calibration */
432
467
        inst_calc_uop_mask         = 0x0000000F, /* user operated calibration mask */
433
468
 
 
469
                                                        /* Man means that the user has to manualy configure the instrument */
 
470
                                                        /* to be on the correct reference for the software triggered cal. */
434
471
        inst_calc_man_ref_white    = 0x00000010, /* place instrument on reflective white reference */
435
472
        inst_calc_man_ref_whitek   = 0x00000020, /* click instrument on reflective white reference */
436
473
        inst_calc_man_ref_dark     = 0x00000030, /* place instrument in dark, not close to anything */
437
474
        inst_calc_man_em_dark      = 0x00000040, /* place cap on instrument, put on dark surface or white ref. */
438
 
        inst_calc_man_cal_smode    = 0x00000050, /* Put instrument sensor in calibration position */
 
475
        inst_calc_man_am_dark      = 0x00000050, /* Place cap over ambient sensor (wl calib capable) */
 
476
        inst_calc_man_cal_smode    = 0x00000060, /* Put instrument sensor in calibration position */
439
477
 
440
 
        inst_calc_man_trans_white  = 0x00000060, /* place instrument on transmissive white reference */
441
 
        inst_calc_man_trans_dark   = 0x00000070, /* place instrument on transmissive dark reference */
 
478
        inst_calc_man_trans_white  = 0x00000070, /* place instrument on transmissive white reference */
 
479
        inst_calc_man_trans_dark   = 0x00000080, /* place instrument on transmissive dark reference */
442
480
        inst_calc_man_man_mask     = 0x000000F0, /* user configured calibration mask */ 
443
481
 
444
 
        inst_calc_disp_white       = 0x00000100, /* Provide a white display test patch */
445
 
        inst_calc_disp_grey        = 0x00000200, /* Provide a grey display test patch */
446
 
        inst_calc_disp_grey_darker = 0x00000300, /* Provide a darker grey display test patch */
447
 
        inst_calc_disp_grey_ligher = 0x00000400, /* Provide a darker grey display test patch */
448
 
        inst_calc_disp_mask        = 0x00000F00, /* Display provided reference patch */
449
 
 
450
 
        inst_calc_proj_white       = 0x00001000, /* Provide a white projector test patch */
451
 
        inst_calc_proj_grey        = 0x00002000, /* Provide a grey projector test patch */
452
 
        inst_calc_proj_grey_darker = 0x00003000, /* Provide a darker grey projector test patch */
453
 
        inst_calc_proj_grey_ligher = 0x00004000, /* Provide a darker grey projector test patch */
454
 
        inst_calc_proj_mask        = 0x0000F000, /* Projector provided reference patch */
 
482
        inst_calc_emis_white       = 0x00000100, /* Provide a white test patch */
 
483
        inst_calc_emis_grey        = 0x00000200, /* Provide a grey test patch */
 
484
        inst_calc_emis_grey_darker = 0x00000300, /* Provide a darker grey test patch */
 
485
        inst_calc_emis_grey_ligher = 0x00000400, /* Provide a darker grey test patch */
 
486
        inst_calc_emis_mask        = 0x00000F00, /* Emmissive/display provided reference patch */
455
487
 
456
488
        inst_calc_change_filter    = 0x00010000, /* Filter needs changing on device - see id[] */
457
489
        inst_calc_message          = 0x00020000  /* Issue a message. - see id[] */
458
490
} inst_cal_cond;
459
491
 
 
492
/* Clamping state */
 
493
typedef enum {
 
494
    instNoClamp                 = 0,    /* Don't clamp XYZ/Lab to +ve */
 
495
    instClamp                   = 1,    /* Clamp XYZ/Lab to +ve */
 
496
} instClamping;
 
497
 
 
498
/* User interaction callback function purpose */
 
499
typedef enum {
 
500
    inst_negcoms,               /* Negotiating communications */
 
501
    inst_triggered,             /* Measurement has been triggered by switch or user (not progromatic) */
 
502
    inst_armed,                 /* Armed and waiting for a measurement trigger */
 
503
    inst_measuring              /* Busy measuring */
 
504
} inst_ui_purp;
 
505
 
 
506
/* Asynchronous event callback type */
 
507
typedef enum {
 
508
    inst_event_switch,  /* Instrument measure/calibrate switch pressed */
 
509
    inst_event_mconf    /* Change in measurement configuration (ie. sensor position) */
 
510
} inst_event_type;
 
511
 
 
512
/* Instrument configuration/sensor position*/
 
513
typedef enum {
 
514
    inst_conf_unknown,
 
515
    inst_conf_projector,
 
516
    inst_conf_surface,  
 
517
    inst_conf_emission, 
 
518
        inst_conf_calibration,
 
519
        inst_conf_ambient
 
520
} inst_config;
 
521
 
 
522
/* Off-line pending readings available (status) */
460
523
#define CALIDLEN 200    /* Maxumum length of calibration tile ID string */
461
524
 
462
525
/* Color instrument interface base object */
466
529
/* after initialisation. */
467
530
#define INST_OBJ_BASE                                                                                                                   \
468
531
                                                                                                                                                                \
469
 
        int debug;              /* debug level, 1..9 */                                                                         \
470
 
        int verb;               /* Verbosity level */                                       \
 
532
        a1log *log;                     /* Pointer to debug & error logging class */                    \
471
533
        instType  itype;        /* Instrument type determined by driver */                              \
472
 
        icoms *icom;    /* Instrument coms object */                                                            \
473
 
        int gotcoms;    /* Coms established flag */                                 \
474
 
        int inited;             /* Instrument open and initialized flag */                  \
 
534
        icoms *icom;            /* Instrument coms object */                                                    \
 
535
        int gotcoms;            /* Coms established flag */                             \
 
536
        int inited;                     /* Instrument open and initialized flag */              \
475
537
        double cal_gy_level; /* Display calibration test window state */                        \
476
538
        int cal_gy_count;       /* Display calibration test window state */                             \
 
539
        inst_code (*uicallback)(void *cntx, inst_ui_purp purp);                                         \
 
540
        void *uic_cntx;         /* User interaction callback function */                                \
 
541
        void (*eventcallback)(void *cntx, inst_event_type event);                                       \
 
542
        void *event_cntx;       /* Event callback function */                                                   \
477
543
                                                                                                                                                                \
478
544
        /* Establish communications at the indicated baud rate. */                                      \
479
545
        /* (Serial parameters are ignored for USB instrument) */                                        \
480
546
        /* Timout in to seconds, and return non-zero error code */                                      \
481
547
        inst_code (*init_coms)(                                                                                                         \
482
548
        struct _inst *p,                                                                                                                \
483
 
        int comport,            /* icom communication port number */                            \
484
549
        baud_rate br,           /* Baud rate */                                                                         \
485
550
        flow_control fc,        /* Flow control */                                                                      \
486
551
        double tout);           /* Timeout */                                                                           \
496
561
        instType (*get_itype)(                                                                                                          \
497
562
        struct _inst *p);                                                                                                               \
498
563
                                                                                                                                                                \
499
 
        /* Return the instrument capabilities. */                                                                       \
 
564
        /* Return the instrument serial number. */                                                                      \
 
565
        /* (This will be an empty string if there is no serial no) */               \
 
566
        char *(*get_serial_no)(                                                                                                         \
 
567
        struct _inst *p);                                                                                                               \
 
568
                                                                                                                                                                \
 
569
        /* Return the avilable instrument modes and capabilities. */                            \
500
570
        /* Can be called before init, but may be different to */                                        \
501
571
        /* what's returned after initilisation. */                                                                      \
502
572
        /* Note that these may change with the mode. */                                                         \
503
 
        inst_capability (*capabilities)(struct _inst *p);                                                       \
504
 
        inst2_capability (*capabilities2)(struct _inst *p);                                                     \
505
 
                                                                                                                                                                \
506
 
    /* Get mode and option details */                                                                                   \
507
 
    inst_code (*get_opt_details)(                                                                                               \
 
573
        /* Arguments may be NULL */                                                                                                     \
 
574
        void (*capabilities)(struct _inst *p,                                                                           \
 
575
                inst_mode *cap1,                                                                                                        \
 
576
                inst2_capability *cap2,                                                                                         \
 
577
                inst3_capability *cap3);                                                                                        \
 
578
                                                                                                                                                                \
 
579
        /* Return current or given configuration available measurement modes. */        \
 
580
        /* Most instruments have only one detectable configuration. */                          \
 
581
        /* If conf_ix == NULL or *conf_ix is an invalid configuration index, */         \
 
582
        /* then the current configuration modes are returned. */                                        \
 
583
        /* Otherwise the given configuration index is returned. */                                      \
 
584
        /* The i1d3 has 2, the Munki has 4, one being calibration. */                           \
 
585
        /* *cconds is valid if *mmodes = inst_mode_calibration */                                       \
 
586
        inst_code (*meas_config)(struct _inst *p,                                                                       \
 
587
                        inst_mode *mmodes,      /* Return all the valid measurement modes */    \
 
588
                                                                /* for the current configuration */                             \
 
589
                        inst_cal_cond *cconds,  /* Return the valid calibration conditions */           \
 
590
                        int *conf_ix);          /* Request mode for given configuration, and */                 \
 
591
                                    /* return the index of the configuration returned */        \
 
592
                                                                                                                                                                \
 
593
    /* Check that the particular device measurement mode is valid, */           \
 
594
        /* since it's not possible to be 100% sure from capabilities */                         \
 
595
    inst_code (*check_mode)(                                                                                                    \
508
596
        struct _inst *p,                                                                                                                \
509
 
        inst_optdet_type m,     /* Requested option detail type */                                      \
510
 
                ...);                           /* Parameters */                                                                        \
511
 
                                                                                                                                                                \
512
 
        /* Return the instrument serial number. */                                                                      \
513
 
        /* (This will be an empty string if there is no serial no) */               \
514
 
        char *(*get_serial_no)(                                                                                                         \
515
 
        struct _inst *p);                                                                                                               \
 
597
        inst_mode m);           /* Requested mode */                                                            \
516
598
                                                                                                                                                                \
517
599
    /* Set the device measurement mode */                                       \
518
600
        /* Note that this may change the capabilities. */                                                       \
520
602
        struct _inst *p,                                                                                                                \
521
603
        inst_mode m);           /* Requested mode */                                                            \
522
604
                                                                                                                                                                \
523
 
    /* Set or reset an option */                                                                                                \
524
 
    inst_code (*set_opt_mode)(                                                                                                  \
525
 
        struct _inst *p,                                                                                                                \
526
 
        inst_opt_mode m,        /* Requested option mode */                                                     \
 
605
        /* Return array of display type selectors */                                                            \
 
606
        inst_code (*get_disptypesel)(                                                                                           \
 
607
        struct _inst *p,                                                                                                                \
 
608
                int *no_selectors,              /* Return number of display types */                    \
 
609
                inst_disptypesel **sels,/* Return the array of display types */                 \
 
610
                int allconfig,                  /* nz to return list for all configs, not just current. */      \
 
611
                int recreate);                  /* nz to re-check for new ccmx & ccss files */  \
 
612
                                                                                                                                                                \
 
613
        /* Set the display type. index is into the inst_disptypesel[] returned */   \
 
614
        /* returned by get_disptypesel(). clears col_cor_mat() */                                       \
 
615
        inst_code (*set_disptype)(                                                                                                      \
 
616
        struct _inst *p,                                                                                                                \
 
617
                int index);                                                             \
 
618
                                                                                    \
 
619
    /* Get a status or get or set an option */                                  \
 
620
        /* option state. */                                                                                                                     \
 
621
        /* Some options can be set before init */                                                                       \
 
622
        /* See inst_opt_type typedef for list of mode types */                                          \
 
623
    inst_code (*get_set_opt)(                                                                                                   \
 
624
        struct _inst *p,                                                                                                                \
 
625
        inst_opt_type m,        /* Requested option mode */                                                     \
527
626
                ...);                           /* Option parameters */                             \
528
627
                                                                                                                                                                \
529
 
    /* Get a (dynamic) status */                                                                                                \
530
 
    inst_code (*get_status)(                                                                                                    \
531
 
        struct _inst *p,                                                                                                                \
532
 
        inst_status_type m,     /* Requested status type */                                                     \
533
 
                ...);                           /* Status parameters */                             \
534
 
                                                                                                                                                                \
535
 
                                                                                                                                                                \
536
628
        /* Read a full test chart composed of multiple sheets */                                        \
537
629
        /* DOESN'T use the trigger mode */                                                                                      \
538
630
        /* Return the inst error code */                                                                                        \
609
701
                                                                                                                                                                \
610
702
        /* Read a set of strips (applicable to strip reader) */                                         \
611
703
        /* Obeys the trigger mode set, and may return user trigger code */                      \
 
704
        /* (to hint that a user command may be available) */                                            \
612
705
        /* Return the inst error code */                                                                                        \
613
706
        inst_code (*read_strip)(                                                                                                        \
614
707
                struct _inst *p,                                                                                                                \
626
719
        /* Obeys the trigger mode set, and may return user trigger code */                      \
627
720
        /* Values are in XYZ 0..100 for reflective transmissive, */                                     \
628
721
        /* aXYZ in cd/m^2 for emissive, amd Lux/3.1415926 for ambient. */                       \
629
 
        /* Spectral will be analogous to the XYZ/aXYZ. */                                                       \
 
722
        /* Spectral will be analogous to the XYZ. */                                                            \
 
723
        /* By default values may be -ve due to noise (depending on instrument) */       \
630
724
        /* Return the inst error code */                                                                                        \
631
725
        inst_code (*read_sample)(                                                                                                       \
632
726
                struct _inst *p,                                                                                                                \
633
 
                char *name,                     /* Patch identifier (up to 7 chars) */                          \
634
 
                ipatch *val);           /* Pointer to value to be returned */                           \
635
 
                                                                                                                                                                \
636
 
        /* Determine if a calibration is needed. Returns inst_calt_none if not, */  \
637
 
        /* inst_calt_unknown if it is unknown, or inst_calt_XXX if needs calibration, */ \
638
 
        /* and the first type of calibration needed. */                                                         \
 
727
                char *name,                             /* Patch identifier (up to 7 chars) */                  \
 
728
                ipatch *val,                    /* Pointer to value to be returned */                   \
 
729
                instClamping clamp);    /* NZ to clamp XYZ to be +ve */                                 \
 
730
                                                                                                                                                                \
 
731
        /* Measure the emissive refresh rate in Hz. */                                                          \
 
732
        /* (Available if cap2 & inst2_emis_refr_meas) */                                                        \
 
733
        /* Returns: */                                                                                                                          \
 
734
        /* inst_unsupported - if this instrument doesn't suport this measuremet */      \
 
735
        /*                    or not in an emissive measurement mode */                         \
 
736
        /* inst_misread     - if no refresh rate could be determined */                         \
 
737
        /* inst_ok          - on returning a valid reading */                                           \
 
738
        inst_code (*read_refrate)(                                                                                              \
 
739
                struct _inst *p,                                                                                                                \
 
740
                double *ref_rate);              /* Return the Hz */                                                             \
 
741
                                                                                                                                                                \
 
742
        /* Determine if a calibration is needed. Returns inst_calt_none if not */       \
 
743
        /* or unknown, or a mask of the needed calibrations. */                                         \
 
744
        /* This call checks if calibrations are invalid or have timed out. */           \
 
745
        /* With the exception of instruments with automated calibration */                      \
 
746
        /* (ie. SpectroScan), an instrument will typically */                                           \
 
747
        /* not check for calibration timout any other way. */                                           \
 
748
        /* [What's returned is the same as get_n_a_cals() [ needed_calibrations.] */\
639
749
        inst_cal_type (*needs_calibration)(                                                                                     \
640
750
                struct _inst *p);                                                                                                               \
641
751
                                                                                                                                                                \
 
752
        /* Return combined mask of needed and available inst_cal_type's */                      \
 
753
        /* for the current mode. */                                                                                                     \
 
754
        inst_code (*get_n_a_cals)(                                                                                                      \
 
755
                struct _inst *p,                                                                                                                \
 
756
                inst_cal_type *needed_calibrations,                                                                             \
 
757
                inst_cal_type *available_calibrations);                                                                 \
 
758
                                                                                                                                                                \
642
759
        /* Request an instrument calibration. */                                                                        \
643
760
        /* This is use if the user decides they want to do a calibration */                     \
644
761
        /* in anticipation of a calibration (needs_calibration()) to avoid */           \
645
762
        /* requiring one during measurement, or in response to measuring */                     \
646
 
        /* returning inst_needs_cal, before retrying the measurement. */                        \
 
763
        /* returning inst_needs_cal before retrying the measurement, */                         \
 
764
        /* or to do one or more re-calibrations. */                                                                     \
647
765
                                                                                                                                                                \
648
 
        /* An initial inst_cal_cond of inst_calc_none may be used to do the */          \
649
 
        /* default or necessary calibration, or a specific calibration supported */     \
650
 
        /* by the instrument may be chosen. */                                                                          \
 
766
        /* *calt should contain the mask of calibrations to be performed, */            \
 
767
        /* with *calc set to the current calibration condition. */                                      \
 
768
        /* Alternately, one of the psudo-calibration types inst_calt_all, */            \
 
769
        /* inst_calt_needed or inst_calt_available can be used, */                      \
 
770
        /* and/or the *calc of inst_calc_none to get calibrate() */                                     \
 
771
        /* to determine the required calibration types and conditions. */                       \
 
772
        /* (The corresponding calibration types will be used & returned. */                     \
651
773
                                                                                                                                                                \
652
774
        /* If no error is returned to the first call to calibrate() with */                     \
653
 
        /* inst_calc_none, then the instrument was capable of calibrating */            \
654
 
        /* without user or application intervention. If on the other hand */            \
655
 
        /* calibrate() returns inst_cal_setup, then the appropriate action */           \
656
 
        /* indicated by the value returned in *calc should be taken by the */           \
657
 
        /* user or application, before retrying calibration() with the */                       \
658
 
        /* current setup indicated by *calc. If several different calibrations */       \
659
 
        /* are being performed, then several retries may be needed with */                      \
660
 
        /* different setups, untill calibrate() returns inst_ok. */                                     \
 
775
        /* then the instrument was capable of calibrating without user or */            \
 
776
        /* application intervention. If on the other hand calibrate() returns */        \
 
777
        /* inst_cal_setup, then the appropriate action indicated by the value */        \
 
778
        /* returned in *calc should be taken by the user or application, */                     \
 
779
        /* before retrying calibration() with the current setup indicated */            \
 
780
        /* by *calc. If more than one calibration type is requested, then */            \
 
781
        /* several retries may be needed with different calibration conditions. */      \
 
782
        /* Each call to calibrate() will update *calt to reflect the remaining */       \
 
783
        /* calibration to be performed.  calibrate() returns inst_ok when no */         \
 
784
        /* more calibrations remain. */                                                                                         \
661
785
                                                                                                                                                                \
662
786
        /* DOESN'T use the trigger mode */                                                                                      \
663
 
        /* Return inst_unsupported if calibration type is not appropriate. */           \
 
787
        /* Return inst_unsupported if *calt is not appropriate, */                                      \
 
788
        /* inst_cal_setup if *calc is not appropriate. */                                                       \
664
789
        inst_code (*calibrate)(                                                                                                         \
665
790
                struct _inst *p,                                                                                                                \
666
 
                inst_cal_type calt,             /* Calibration type. inst_calt_all for all neeeded */ \
 
791
                inst_cal_type *calt,    /* Calibration type to do/remaining */                  \
667
792
                inst_cal_cond *calc,    /* Current condition/desired condition */               \
668
 
                char id[CALIDLEN]);             /* Condition identifier (ie. white reference ID, */     \
669
 
                                        /* filter ID) */                                                                \
 
793
                char id[CALIDLEN]);             /* Condition identifier (ie. white */                   \
 
794
                                                                /* reference ID, filter ID) */                                  \
 
795
                                                                                                                                                                \
 
796
        /* Measure a display update delay. It is assumed that a */                              \
 
797
        /* White to black change has been made to the displayed color, */               \
 
798
        /* and this will measure the time it took for the update to */              \
 
799
        /* be noticed by the instrument, up to 1.0 seconds. */                          \
 
800
        /* inst_misread will be returned on failure to find a transition to black. */ \
 
801
        inst_code (*meas_delay)(                                                                                                \
 
802
                struct _inst *p,                                                                                                                \
 
803
                int *msecdelay);                /* Return the number of msec */                                 \
 
804
                                                                                                                                                                \
 
805
        /* Return the last calibrated refresh rate in Hz. Returns: */                           \
 
806
        /* inst_unsupported - if this instrument doesn't suport a refresh mode */       \
 
807
        /*                    or is unable to retrieve the refresh rate */                      \
 
808
        /* inst_needs_cal   - if the refresh rate value is not valid */                         \
 
809
        /* inst_misread     - if no refresh rate could be determined */                         \
 
810
        /* inst_ok          - on returning a valid reading */                                           \
 
811
        inst_code (*get_refr_rate)(                                                                                             \
 
812
                struct _inst *p,                                                                                                                \
 
813
                double *ref_rate);              /* Return the Hz */                                                             \
 
814
                                                                                                                                                                \
 
815
        /* Set the calibrated refresh rate in Hz. */                                                            \
 
816
        /* Set refresh rate to 0.0 to mark it as invalid */                                                     \
 
817
        /* Rates outside the range 5.0 to 150.0 Hz will return an error */                      \
 
818
        /* Note that not all instruments that can return a refresh rate, */                     \
 
819
        /* will permit one to be set (ie., DTP92) */                                                            \
 
820
        inst_code (*set_refr_rate)(                                                                                             \
 
821
                struct _inst *p,                                                                                                                \
 
822
                double ref_rate);               /* Rate in Hz */                                                                \
670
823
                                                                                                                                                                \
671
824
        /* Insert a compensation filter in the instrument readings */                           \
672
825
        /* This is typically needed if an adapter is being used, that alters */     \
677
830
                char *filtername);              /* File containing compensating filter */               \
678
831
                                                                                                                                                                \
679
832
        /* Insert a colorimetric correction matrix in the instrument XYZ readings */ \
680
 
        /* This is only valid for colorimetric instruments. */                                          \
681
 
        /* To remove the matrix, pass NULL for the matrix */                                            \
 
833
        /* This is only valid for colorimetric instruments, and can only be */          \
 
834
        /* applied over a base calibration display type. Setting a display */           \
 
835
        /* type will clear the matrix. */                                                                                       \
 
836
        /* To clear the matrix, pass NULL for the matrix */                                                     \
682
837
        inst_code (*col_cor_mat)(                                                                                               \
683
838
                struct _inst *p,                                                                                                                \
684
839
                double mtx[3][3]);              /* XYZ matrix */                                                                \
686
841
        /* Use a Colorimeter Calibration Spectral Set (ccss) to set the */                      \
687
842
        /* instrumen calibration. This will affect emissive readings. */                        \
688
843
        /* An alternate observer may also be set, and this will affect both */          \
689
 
        /* emmissive and ambient readings. */                                                                           \
 
844
        /* emissive and ambient readings. */                                                                            \
690
845
        /* This is only valid for colorimetric instruments. */                                          \
691
846
        /* To set calibration back to default, pass NULL for sets, and */                       \
692
847
        /* icxOT_default for the observer. */                                                                           \
693
848
        inst_code (*col_cal_spec_set)(                                                                                          \
694
849
                struct _inst *p,                                                                                                                \
695
 
                icxObserverType obType, /* Observer */                                                                  \
696
 
                xspect custObserver[3], /* Optional custom observer */                                  \
697
850
                xspect *sets,                   /* Set of sample spectra */                                             \
698
851
                int no_sets);                   /* Number on set */                                                             \
699
852
                                                                                                                                                                \
700
 
        /* Send a message to the user. */                                                                                       \
701
 
        inst_code (*message_user)(struct _inst *p, char *fmt, ...);                                     \
 
853
        /* Supply a user interaction callback function.                                                         \
 
854
         * This is called for one of three different purposes:                                          \
 
855
         *      To signal that the instrument measurement has been triggered.                   \
 
856
         *      To poll for a abort while waiting to trigger.                                                   \
 
857
         *      To poll for a user abort during measurement.                                                    \
 
858
         *                                                                                                                                                      \
 
859
         * The callback function will have the purpose paramater appropriately.         \
 
860
         *                                                                                                                                                      \
 
861
     * For inst_negcoms, the return value of inst_user_abort                                    \
 
862
         * will abort the communication negotiation                                                                     \
 
863
         *                                                                                                                                                      \
 
864
         * For inst_triggered, the return value of the callback is ignored.                     \
 
865
         *                                                                                                                                                      \
 
866
         * For inst_armed return value should be one of:                                                        \
 
867
         * inst_ok to do nothing, inst_user_abort to abort the measurement,                     \
 
868
         * or inst_user_trig to trigger the measurement.                                                        \
 
869
         *                                                                                                                                                      \
 
870
         * For inst_measuring the return value should be one of:                                        \
 
871
         * inst_ok to do nothing, inst_user_abort to abort the measurement.                     \
 
872
         *                                                                                                                                                      \
 
873
         * NULL can be set to disable the callback.                                                                     \
 
874
         */                                                                                                                                                     \
 
875
        void (*set_uicallback)(struct _inst *p,                                                                         \
 
876
                inst_code (*uicallback)(void *cntx, inst_ui_purp purp),                                 \
 
877
                void *cntx);                                                                                                                    \
702
878
                                                                                                                                                                \
703
 
        /* Poll for a user abort, terminate, trigger or command. */                                     \
704
 
        /* Wait for a key rather than polling, if wait != 0 */                                          \
705
 
        /* Return: */                                                                                                                           \
706
 
        /* inst_ok if no key has been hit, */                                                                           \
707
 
        /* inst_user_abort if User abort has been hit, */                                                       \
708
 
        /* inst_user_term if User terminate has been hit. */                                            \
709
 
        /* inst_user_trig if User trigger has been hit */                                                       \
710
 
        /* inst_user_cmnd if User command has been hit */                                                       \
711
 
        inst_code (*poll_user)(struct _inst *p, int wait);                                                      \
 
879
        /* Supply an aynchronous event callback function.                                                       \
 
880
         * This is called from a thread with the following possible events:                     \
 
881
         *                                                                                                                                                      \
 
882
         * inst_event_switch: Instrument measure/calibrate switch pressed                       \
 
883
         * inst_event_mconf: The measurement configuration has changed (ie. sensor position)    \
 
884
         *                                                                                                                                                      \
 
885
         * NULL can be set to disable the callback.                                                                     \
 
886
         */                                                                                                                                                     \
 
887
        void (*set_event_callback)(struct _inst *p,                                                                     \
 
888
                void (*eventcallback)(void *cntx, inst_event_type event),                               \
 
889
                void *cntx);                                                                                                                    \
712
890
                                                                                                                                                                \
713
891
        /* Generic inst error codes interpretation */                                                           \
714
892
        char * (*inst_interp_error)(struct _inst *p, inst_code ec);                                     \
716
894
        /* Instrument specific error codes interpretation */                                            \
717
895
        char * (*interp_error)(struct _inst *p, int ec);                                                        \
718
896
                                                                                                                                                                \
719
 
        /* Return the last communication error code */                                                          \
720
 
        int (*last_comerr)(struct _inst *p);                                                                            \
 
897
        /* Convert instrument specific inst_wrong_config error to inst_config enum */   \
 
898
        inst_config (*config_enum)(struct _inst *p, int ec);                                                    \
 
899
                                                                                                                                                                \
 
900
        /* Return the last serial communication error code */                                           \
 
901
        /* (This is used for deciding fallback/retry strategies) */                                     \
 
902
        int (*last_scomerr)(struct _inst *p);                                                                           \
721
903
                                                                                                                                                                \
722
904
        /* Destroy ourselves */                                                                                                         \
723
905
        void (*del)(struct _inst *p);                                                                                           \
730
912
/* Virtual constructor. */
731
913
/* Return NULL for unknown instrument, */
732
914
/* or serial instrument if nocoms == 0. */
 
915
/* (Doesn't copy icompaths log!) */
 
916
/* If uicallback is provided, it will be set in the resulting inst */
733
917
extern inst *new_inst(
734
 
        int comport,            /* icom communication port number */
 
918
        icompath *path,         /* Device path this instrument */
735
919
        int nocoms,                     /* Don't open if communications are needed to establish inst type */
736
 
        int debug,                      /* Debug level, 0 = off */
737
 
        int verb                        /* Verbose level, 0  = off */
738
 
);
739
 
 
740
 
/* ======================================================================= */
741
 
 
742
 
/* Opaque type as far as inst.h is concerned. */
743
 
typedef struct _disp_win_info disp_win_info;
744
 
 
745
 
/* A default calibration user interaction handler using the console. */
746
 
/* This handles both normal and display based calibration interaction */
747
 
/* with the instrument, if a disp_setup function and pointer to disp_win_info */
748
 
/* is provided. */
749
 
inst_code inst_handle_calibrate(
750
 
        inst *p,
751
 
        inst_cal_type calt,             /* type of calibration to do. inst_calt_all for all */
752
 
        inst_cal_cond calc,             /* Current condition. inst_calc_none for not setup */
753
 
        inst_code (*disp_setup) (inst *p, inst_cal_cond calc, disp_win_info *dwi),
754
 
                                                        /* Callback for handling a display calibration - May be NULL */
755
 
        disp_win_info *dwi              /* Information to be able to open a display test patch - May be NULL */
756
 
);
757
 
 
758
 
/* ============================================================================= */
759
 
 
760
 
/* A helper function to display -y flag usage for each instrument type available */
761
 
/* Return accumulated capabilities of all the instruments */
762
 
inst_capability inst_show_disptype_options(FILE *fp, char *oline, icoms *icom);
763
 
 
764
 
/* A helper function to turn a -y flag into a selection index */
765
 
/* Return 0 on error */
766
 
int inst_get_disptype_index(inst *it, int c);
 
920
        a1log *log,                     /* Log to use */
 
921
        inst_code (*uicallback)(void *cntx, inst_ui_purp purp),         /* optional uicallback */
 
922
        void *cntx                      /* Context for callback */
 
923
);
 
924
 
 
925
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 
926
/* Implementation functions used by drivers */
 
927
 
 
928
/* Get a status or set or get an option (default implementation) */
 
929
inst_code inst_get_set_opt_def(
 
930
inst *p,
 
931
inst_opt_type m,        /* Option type */
 
932
va_list args);          /* Option parameters */                             
 
933
 
 
934
/* - - - - - - - - - - - - - - - - - - -- */
 
935
 
 
936
/* Create the display type list */
 
937
inst_code inst_creat_disptype_list(inst *p,
 
938
int *pndtlist,                                  /* Number in returned list */
 
939
inst_disptypesel **pdtlist,             /* Returned list */
 
940
inst_disptypesel *sdtlist,              /* Static list */
 
941
int doccss,                                             /* Add installed ccss files */
 
942
int doccmx                                              /* Add matching installed ccmx files */
 
943
);
 
944
 
 
945
/* Free a display type list */
 
946
void inst_del_disptype_list(inst_disptypesel *list, int no);
 
947
 
 
948
 
 
949
/* - - - - - - - - - - - - - - - - - - -- */
 
950
/* CCMX support */
 
951
 
 
952
typedef struct {
 
953
        char *path;                     /* Path to the file */
 
954
        char *desc;                     /* Technology + display description */
 
955
        int cbid;               /* Calibration display type base ID */
 
956
        int  refr;                      /* Refresh mode flag */
 
957
        char *sel;                      /* UI selector characters (may be NULL) */
 
958
        double mat[3][3];       /* The matrix values */
 
959
} iccmx;
 
960
 
 
961
/* return a list of installed ccmx files. */
 
962
/* if inst != NULL, return those that match the given instrument. */
 
963
/* The list is sorted by description and terminated by a NULL entry. */
 
964
/* If no is != NULL, return the number in the list */
 
965
/* Return NULL and -1 if there is a malloc error */
 
966
iccmx *list_iccmx(char *inst, int *no);
 
967
 
 
968
/* Free up a iccmx list */
 
969
void free_iccmx(iccmx *list);
 
970
 
 
971
/* - - - - - - - - - - - - - - - - - - -- */
 
972
/* CCSS support */
 
973
 
 
974
typedef struct {
 
975
        char *path;                     /* Path to the file */
 
976
        char *desc;                     /* Technology + display description */
 
977
        int  refr;                      /* Refresh mode flag */
 
978
        char *sel;                      /* UI selector characters (may be NULL) */
 
979
        xspect *sets;           /* Set of sample spectra */
 
980
        int no_sets;            /* Number on set */
 
981
} iccss;
 
982
 
 
983
/* return a list of installed ccss files. */
 
984
/* The list is sorted by description and terminated by a NULL entry. */
 
985
/* If no is != NULL, return the number in the list */
 
986
/* Return NULL and -1 if there is a malloc error */
 
987
iccss *list_iccss(int *no);
 
988
 
 
989
/* Free up a iccss list */
 
990
void free_iccss(iccss *list);
 
991
 
 
992
/* - - - - - - - - - - - - - - - - - - -- */
767
993
 
768
994
#ifdef __cplusplus
769
995
        }