-
Notifications
You must be signed in to change notification settings - Fork 3
/
transfer.go
94 lines (72 loc) · 2.78 KB
/
transfer.go
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
package sapera
/*
#include <stdlib.h>
#include "transfer.h"
#include "context.h"
*/
import "C"
import "unsafe"
// SapAcqToBuf is used to transfer data from the acquisition device to a provided buffer.
type SapAcqToBuf struct {
// C.SapAcqToBufWrapper
p unsafe.Pointer
}
func NewSapAcqToBuf(acq SapAcquisition, buf SapBuffer, context SapXferContext) SapAcqToBuf {
return SapAcqToBuf{p: unsafe.Pointer(C.SapAcqToBuf_New((C.SapAcquisitionWrapper)(acq.p), (C.SapBufferWrapper)(buf.p), (C.SapXferContextWrapper)(context.p)))}
}
func (trs *SapAcqToBuf) Create() bool {
return bool(C.SapAcqToBuf_Create((C.SapAcqToBufWrapper)(trs.p)))
}
func (trs *SapAcqToBuf) Delete() {
C.SapAcqToBuf_Delete((C.SapAcqToBufWrapper)(trs.p))
}
func (trs *SapAcqToBuf) Destroy() bool {
return bool(C.SapAcqToBuf_Destroy((C.SapAcqToBufWrapper)(trs.p)))
}
func (trs *SapAcqToBuf) Grab() bool {
return bool(C.SapAcqToBuf_Grab((C.SapAcqToBufWrapper)(trs.p)))
}
func (trs *SapAcqToBuf) Snap() bool {
return bool(C.SapAcqToBuf_Snap((C.SapAcqToBufWrapper)(trs.p)))
}
func (trs *SapAcqToBuf) IsGrabbing() bool {
return bool(C.SapAcqToBuf_IsGrabbing((C.SapAcqToBufWrapper)(trs.p)))
}
func (trs *SapAcqToBuf) Freeze() bool {
return bool(C.SapAcqToBuf_Freeze((C.SapAcqToBufWrapper)(trs.p)))
}
func (trs *SapAcqToBuf) Wait(ms int) bool {
return bool(C.SapAcqToBuf_Wait((C.SapAcqToBufWrapper)(trs.p), C.int(ms)))
}
func (trs *SapAcqToBuf) Abort() bool {
return bool(C.SapAcqToBuf_Abort((C.SapAcqToBufWrapper)(trs.p)))
}
func (trs *SapAcqToBuf) GetLastStatus() string {
return C.GoString(C.SapAcqToBuf_GetLastStatus((C.SapAcqToBufWrapper)(trs.p)))
}
// SapXferCallbackInfo is to pass context info to transfer callbacks.
type SapXferCallbackInfo struct {
p C.SapXferCallbackInfoWrapper
}
func (trs *SapAcqToBuf) SetCallbackHandler(hdl func(cb SapXferCallbackInfo), context SapXferContext) bool {
if len(xferCallbackHandler) == 0 {
xferCallbackHandler = append(xferCallbackHandler, hdl)
}
return bool(C.SapAcqToBuf_SetCallbackInfo((C.SapAcqToBufWrapper)(trs.p), (C.SapXferContextWrapper)(context.p)))
}
func (trs *SapAcqToBuf) UnregisterCallback() bool {
return bool(C.SapAcqToBuf_UnregisterCallback((C.SapAcqToBufWrapper)(trs.p)))
}
// SapXferFrameRateInfo is to retrieve frame rate stats for transfers. Does not seem to work yet.
type SapXferFrameRateInfo struct {
p C.SapXferFrameRateInfoWrapper
}
func (trs *SapAcqToBuf) GetFrameRateStatistics() SapXferFrameRateInfo {
return SapXferFrameRateInfo{p: C.SapAcqToBuf_GetFrameRateStatistics((C.SapAcqToBufWrapper)(trs.p))}
}
func (inf *SapXferFrameRateInfo) GetBufferFrameRate() int {
return int(C.SapXferFrameRateInfo_GetBufferFrameRate(inf.p))
}
func (cb SapXferCallbackInfo) GetContext() SapXferContext {
return SapXferContext{p: unsafe.Pointer(C.SapXferCallbackInfo_GetContext(cb.p))}
}