1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
|
#ifndef __PHLABVIEW
#define __PHLABVIEW
#include "cphidget.h"
#ifndef EXTERNALPROTO
#ifdef _WINDOWS
#include "windows/extcode.h"
#elif _LINUX
#include "extcode.h"
#elif _MACOSX
#include "macos/2010/extcode.h"
#endif
#else
typedef unsigned int LVUserEventRef;
#endif
#ifdef _WINDOWS
#define LABVIEW_STRUCT_PACK 1
//#define LABVIEW_EXPORT __declspec(dllexport)
#define LABVIEW_EXPORT
#pragma pack(push)
#pragma pack(show)
#else
#define LABVIEW_STRUCT_PACK 4
#define LABVIEW_EXPORT
#endif
#define LV_CFHANDLE_BODY(pname,param,structtype, ...) \
int CCONV CPhidget##pname##_On##param##_LaviewHandler(CPhidget##pname##Handle phid, __VA_ARGS__ ); \
LABVIEW_EXPORT int CCONV CPhidget##pname##_set_On##param##_LabviewHandler(CPhidget##pname##Handle phidA, LVUserEventRef *lvEventRef) \
{ \
CPhidget##pname##Handle phid = (CPhidget##pname##Handle)phidA; \
TESTPTR(phid); \
if(!lvEventRef || !*lvEventRef) \
{ \
phid->fptr##param = NULL; \
phid->fptr##param##ptr = NULL; \
} \
else \
{ \
phid->fptr##param = CPhidget##pname##_On##param##_LaviewHandler; \
phid->fptr##param##ptr = lvEventRef; \
} \
return EPHIDGET_OK; \
} \
int CCONV CPhidget##pname##_On##param##_LaviewHandler(CPhidget##pname##Handle phid, __VA_ARGS__ ) \
{ \
LVUserEventRef ev = *(LVUserEventRef *)userPtr; \
MgErr ret = 0; \
structtype *data; \
data = (structtype *)DSNewPtr(sizeof(structtype)); \
data->nothing = (int32)phid; \
#define LV_CFHANDLE_END \
ret = PostLVUserEvent(ev, data); \
DSDisposePtr(data); \
return EPHIDGET_OK; \
}
#define LV_CFHANDLE_0(pname,param,structtype) \
LV_CFHANDLE_BODY(pname,param,structtype,void *userPtr) \
LV_CFHANDLE_END
#define LV_CFHANDLE_1(pname,param,structtype,datatype1) \
LV_CFHANDLE_BODY(pname,param,structtype,void *userPtr,datatype1 val1) \
data->val1 = val1; \
LV_CFHANDLE_END
#define LV_CFHANDLE_2(pname,param,structtype,datatype1,datatype2) \
LV_CFHANDLE_BODY(pname,param,structtype,void *userPtr,datatype1 val1,datatype2 val2) \
data->val1 = val1; \
data->val2 = val2; \
LV_CFHANDLE_END
#define LV_CFHANDLE_3(pname,param,structtype,datatype1,datatype2,datatype3) \
LV_CFHANDLE_BODY(pname,param,structtype,void *userPtr,datatype1 val1,datatype2 val2,datatype3 val3) \
data->val1 = val1; \
data->val2 = val2; \
data->val3 = val3; \
LV_CFHANDLE_END
#define LV_CFHANDLE_4(pname,param,structtype,datatype1,datatype2,datatype3,datatype4) \
LV_CFHANDLE_BODY(pname,param,structtype,void *userPtr,datatype1 val1,datatype2 val2,datatype3 val3,datatype4 val4) \
data->val1 = val1; \
data->val2 = val2; \
data->val3 = val3; \
data->val4 = val4; \
LV_CFHANDLE_END
#define LV_CHDREVENT(pname,param) LABVIEW_EXPORT int CCONV CPhidget##pname##_set_On##param##_LabviewHandler(CPhidget##pname##Handle phid, LVUserEventRef *lvEventRef);
/** \defgroup phidlabview Phidget Labview Functions
* Calls specific to the Phidget Labview Support.
* @{
*/
/**
* Labview 1D int32 Array
*/
typedef struct {
int32 length; // Length of array
int32 data[1]; // Array
} lvArrInt32, *lvArrInt32H, **lvArrInt32DH;
/**
* Labview 1D uInt8 Array
*/
typedef struct {
int32 length; // Length of array
uInt8 data[1]; // Array
} lvArrUInt8, *lvArrUInt8H, **lvArrUInt8DH;
/* pack all of the following structures on Windows
* Note: Labview 64-bit seems to want double to be 8-byte aligned,
* but 32-bit wants them packed to presumably 4-byte
* ints, etc. need to be packed in close.
* mac/linux don't need anything special.
* http://zone.ni.com/reference/en-XX/help/371361G-01/lvconcepts/how_labview_stores_data_in_memory/
*/
#ifdef _WINDOWS
#pragma pack(LABVIEW_STRUCT_PACK)
#pragma pack(show)
#endif
/**
* Used for Labview events where only the event sender is returned
*/
typedef struct _lvNothing {
int32 nothing; /**< Not Used */
} lvNothing;
/**
* Used for Labview events that return an error code/string
*/
typedef struct _lvError {
int32 nothing; /**< Not Used */
int32 val1; /**< Error Code */
LStrHandle val2; /**< Error String */
} lvError;
/**
* Used for Labview events that return a double
*/
typedef struct _lvDouble {
//Labview 64-bit windows wants doubles on 8-byte boundaries
#ifdef _WINDOWS
size_t nothing; /**< Not Used */
#else
int32 nothing; /**< Not Used */
#endif
double val1; /**< Value */
} lvDouble;
/**
* Used for Labview events that return 3 doubles
*/
typedef struct _lvDoubleDoubleDouble {
//Labview 64-bit windows wants doubles on 8-byte boundaries
#ifdef _WINDOWS
size_t nothing; /**< Not Used */
#else
int32 nothing; /**< Not Used */
#endif
double val1; /**< Value 1 */
double val2; /**< Value 2 */
double val3; /**< Value 3 */
} lvDoubleDoubleDouble;
/**
* Used for Labview events that return an int32
*/
typedef struct _lvInt32 {
int32 nothing; /**< Not Used */
int32 val1; /**< Value */
} lvInt32;
/**
* Used for Labview events that return an indexed double
*/
typedef struct _lvIndexedDouble {
int32 nothing; /**< Not Used */
int32 val1; /**< Index */
double val2; /**< Value */
} lvIndexedDouble;
/**
* Used for Labview events that return an indexed int32
*/
typedef struct _lvIndexedInt32 {
int32 nothing; /**< Not Used */
int32 val1; /**< Index */
int32 val2; /**< Value */
} lvIndexedInt32;
/**
* Used for Labview events that return two indexed int32s
*/
typedef struct _lvIndexedInt32Int32 {
int32 nothing; /**< Not Used */
int32 val1; /**< Index */
int32 val2; /**< Value 1 */
int32 val3; /**< Value 2 */
} lvIndexedInt32Int32;
/**
* Used for Labview events that return an indexed int64
*/
typedef struct _lvIndexedInt64 {
int32 nothing; /**< Not Used */
int32 val1; /**< Index */
int64 val2; /**< Value */
} lvIndexedInt64;
/**
* Used for Labview events that return an int32 array
*/
typedef struct _lvInt32Array {
lvArrInt32DH val1; /**< Data */
int32 nothing; /**< Not Used */
} lvInt32Array;
/**
* Used for Labview events that return an uInt8 array
*/
typedef struct _lvUInt8Array {
lvArrUInt8DH val1; /**< Data */
int32 nothing; /**< Not Used */
} lvUInt8Array;
/**
* Used for Labview events that return an IR Code
*/
typedef struct _lvIRCode {
lvArrUInt8DH val1; /**< Code data */
int32 val2; /**< bit count */
int32 val3; /**< repeat */
int32 nothing; /**< Not Used */
} lvIRCode;
/**
* Used for Labview events that return IR Learn data
*/
typedef struct _lvIRLearn {
lvArrUInt8DH val1; /**< Code data */
CPhidgetIR_CodeInfo val2; /**< code parameters */
int32 nothing; /**< Not Used */
} lvIRLearn;
/**
* Used for Labview events that return an rfid tag (advanced)
*/
typedef struct _lvRFIDTagAdvanced {
int32 nothing; /**< Not Used */
LStrHandle val1; /**< Tag String */
CPhidgetRFID_TagInfo val2; /**< tag properties */
} lvRFIDTagAdvanced;
/**
* Used for Labview events that return spatial data
*/
typedef struct _lvSpatialData {
//Labview 64-bit windows wants doubles on 8-byte boundaries
#ifdef _WINDOWS
size_t nothing; /**< Not Used */
#else
int32 nothing; /**< Not Used */
#endif
CPhidgetSpatial_SpatialEventData val1; /**< Spatial Data */
} lvSpatialData;
/**
* Used for Labview manager attach and detach events
*/
typedef struct _lvManager {
__int64 val1; /**< Handle to a phidget */
} lvManager;
/**
* Used for Labview dictionary key change events
*/
typedef struct _lvDictionary {
LStrHandle val1; /**< key String */
LStrHandle val2; /**< value String */
CPhidgetDictionary_keyChangeReason val3; /**< key change reason */
} lvDictionary;
#ifdef _WINDOWS
//Restore default packing
#pragma pack(pop)
#pragma pack(show)
#endif
/**
* Sets up a Labview event callback for the Attach event.
* Event callback returns an \ref _lvNothing.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(,Attach)
/**
* Sets up a Labview event callback for the Detach event.
* Event callback returns an \ref _lvNothing.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(,Detach)
/**
* Sets up a Labview event callback for the ServerConnect event.
* Event callback returns an \ref _lvNothing.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(,ServerConnect)
/**
* Sets up a Labview event callback for the ServerDisconnect event.
* Event callback returns an \ref _lvNothing.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(,ServerDisconnect)
/**
* Sets up a Labview event callback for the Error event.
* Event callback returns an \ref _lvError.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(,Error)
/**
* Sets up a Labview event callback for the AccelerationChange event.
* Event callback returns an \ref _lvIndexedDouble.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(Accelerometer,AccelerationChange)
/**
* Sets up a Labview event callback for the PositionChange event.
* Event callback returns an \ref _lvIndexedDouble.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(AdvancedServo, PositionChange)
/**
* Sets up a Labview event callback for the VelocityChange event.
* Event callback returns an \ref _lvIndexedDouble.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(AdvancedServo, VelocityChange)
/**
* Sets up a Labview event callback for the CurrentChange event.
* Event callback returns an \ref _lvIndexedDouble.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(AdvancedServo, CurrentChange)
/**
* Sets up a Labview event callback for the BridgeData event.
* Event callback returns an \ref _lvIndexedDouble.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(Bridge, BridgeData)
/**
* Sets up a Labview event callback for the InputChange event.
* Event callback returns an \ref _lvIndexedInt32.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(Encoder, InputChange)
/**
* Sets up a Labview event callback for the PositionChange event.
* Event callback returns an \ref _lvIndexedInt32Int32.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(Encoder, PositionChange)
/**
* Sets up a Labview event callback for the Count event.
* Event callback returns an \ref _lvIndexedInt32Int32.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(FrequencyCounter, Count)
/**
* Sets up a Labview event callback for the PositionChange event.
* Event callback returns an \ref _lvDoubleDoubleDouble.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(GPS, PositionChange)
/**
* Sets up a Labview event callback for the PositionFixStatusChange event.
* Event callback returns an \ref _lvInt32.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(GPS, PositionFixStatusChange)
/**
* Sets up a Labview event callback for the InputChange event.
* Event callback returns an \ref _lvIndexedInt32.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(InterfaceKit, InputChange)
/**
* Sets up a Labview event callback for the OutputChange event.
* Event callback returns an \ref _lvIndexedInt32.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(InterfaceKit, OutputChange)
/**
* Sets up a Labview event callback for the SensorChange event.
* Event callback returns an \ref _lvIndexedInt32.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(InterfaceKit, SensorChange)
/**
* Sets up a Labview event callback for the Code event.
* Event callback returns an \ref _lvIRCode.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(IR, Code)
/**
* Sets up a Labview event callback for the RawData event.
* Event callback returns an \ref _lvIRRawData.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(IR, RawData)
/**
* Sets up a Labview event callback for the Learn event.
* Event callback returns an \ref _lvIRLearn.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(IR, Learn)
/**
* Sets up a Labview event callback for the InputChange event.
* Event callback returns an \ref _lvIndexedInt32.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(MotorControl, InputChange)
/**
* Sets up a Labview event callback for the VelocityChange event.
* Event callback returns an \ref _lvIndexedDouble.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(MotorControl, VelocityChange)
/**
* Sets up a Labview event callback for the CurrentChange event.
* Event callback returns an \ref _lvIndexedDouble.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(MotorControl, CurrentChange)
/**
* Sets up a Labview event callback for the EncoderPositionChange event.
* Event callback returns an \ref _lvIndexedInt32Int32.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(MotorControl, EncoderPositionChange)
/**
* Sets up a Labview event callback for the EncoderPositionUpdate event.
* Event callback returns an \ref _lvIndexedInt32.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(MotorControl, EncoderPositionUpdate)
/**
* Sets up a Labview event callback for the BackEMFUpdate event.
* Event callback returns an \ref _lvIndexedDouble.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(MotorControl, BackEMFUpdate)
/**
* Sets up a Labview event callback for the SensorUpdate event.
* Event callback returns an \ref _lvIndexedInt32.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(MotorControl, SensorUpdate)
/**
* Sets up a Labview event callback for the CurrentUpdate event.
* Event callback returns an \ref _lvIndexedDouble.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(MotorControl, CurrentUpdate)
/**
* Sets up a Labview event callback for the PHChange event.
* Event callback returns an \ref _lvDouble.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(PHSensor, PHChange)
/**
* Sets up a Labview event callback for the OutputChange event.
* Event callback returns an \ref _lvIndexedInt32.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(RFID, OutputChange)
/**
* Sets up a Labview event callback for the Tag event.
* Event callback returns an \ref _lvRFIDTag.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(RFID, Tag)
/**
* Sets up a Labview event callback for the TagLost event.
* Event callback returns an \ref _lvRFIDTag.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(RFID, TagLost)
/**
* Sets up a Labview event callback for the RawData event.
* Event callback returns an \ref _lvRFIDRawData.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(RFID, RawData)
/**
* Sets up a Labview event callback for the TagAdvanced event.
* Event callback returns an \ref _lvRFIDTagAdvanced.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(RFID, TagAdvanced)
/**
* Sets up a Labview event callback for the TagLostAdvanced event.
* Event callback returns an \ref _lvRFIDTagAdvanced.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(RFID, TagLostAdvanced)
/**
* Sets up a Labview event callback for the PositionChange event.
* Event callback returns an \ref _lvIndexedDouble.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(Servo, PositionChange)
/**
* Sets up a Labview event callback for the SpatialData event.
* Event callback returns an \ref _lvSpatialData.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(Spatial, SpatialData)
/**
* Sets up a Labview event callback for the InputChange event.
* Event callback returns an \ref _lvIndexedInt32.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(Stepper, InputChange)
/**
* Sets up a Labview event callback for the PositionChange event.
* Event callback returns an \ref _lvIndexedInt64.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(Stepper, PositionChange)
LV_CHDREVENT(Stepper, PositionChange32)
/**
* Sets up a Labview event callback for the VelocityChange event.
* Event callback returns an \ref _lvIndexedDouble.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(Stepper, VelocityChange)
/**
* Sets up a Labview event callback for the CurrentChange event.
* Event callback returns an \ref _lvIndexedDouble.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(Stepper, CurrentChange)
/**
* Sets up a Labview event callback for the TemperatureChange event.
* Event callback returns an \ref _lvIndexedDouble.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(TemperatureSensor, TemperatureChange)
/**
* Sets up a Labview event callback for the WeightChange event.
* Event callback returns an \ref _lvDouble.
* @param phid An attached phidget handle.
* @param lvEventRef Lavbiew user event ref
*/
LV_CHDREVENT(WeightSensor, WeightChange)
LV_CHDREVENT(Manager,Attach)
LV_CHDREVENT(Manager,Detach)
LV_CHDREVENT(Manager,ServerConnect)
LV_CHDREVENT(Manager,ServerDisconnect)
LV_CHDREVENT(Manager,Error)
LABVIEW_EXPORT int CCONV CPhidgetDictionary_set_OnKeyChange_LabviewHandler(CPhidgetDictionaryHandle dict, CPhidgetDictionaryListenerHandle *listen, const char *pattern, LVUserEventRef *lvEventRef);
LV_CHDREVENT(Dictionary,ServerConnect)
LV_CHDREVENT(Dictionary,ServerDisconnect)
LV_CHDREVENT(Dictionary,Error)
/** @} */
#endif
|