-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparameters.go
63 lines (58 loc) · 1.7 KB
/
parameters.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
package qualisys
import (
"fmt"
)
//go:generate stringer -type ParameterType -trimprefix ParameterType
type ParameterType int
const (
ParameterTypeAll ParameterType = iota
ParameterTypeGeneral
ParameterTypeCalibration
ParameterType3D
ParameterType6D
ParameterTypeAnalog
ParameterTypeForce
ParameterTypeImage
ParameterTypeGazeVector
ParameterTypeEyeTracker
ParameterTypeSkeleton
)
// GetParameters fetches xml settings from QTM for specified.
func (rt *Protocol) GetParameters(parameters ...ParameterType) (string, error) {
parametersToString := map[ParameterType]string{
ParameterTypeAll: "All",
ParameterTypeGeneral: "General",
ParameterTypeCalibration: "Calibration",
ParameterType3D: "3D",
ParameterType6D: "6D",
ParameterTypeAnalog: "Analog",
ParameterTypeForce: "Force",
ParameterTypeImage: "Image",
ParameterTypeGazeVector: "GazeVector",
ParameterTypeEyeTracker: "EyeTracker",
ParameterTypeSkeleton: "Skeleton",
}
if !rt.IsConnected() {
return "", fmt.Errorf("getparameters: not connected")
}
cmd := "GetParameters"
for _, p := range parameters {
cmd += " " + parametersToString[p]
}
if err := rt.sendCommand(cmd); err != nil {
return "", fmt.Errorf("getparameters sendcmd: %w", err)
}
p, err := rt.Receive()
if err != nil {
return "", fmt.Errorf("getparameters receive: %w", err)
}
return p.XMLResponse, nil
}
func (rt *Protocol) SetParameters(xml string) error {
s := "<QTM_Settings>" + xml + "</QTM_Settings>"
qtmResponses := []string{"Setting parameters succeeded"}
if err := rt.sendAndWaitForResponse(rt.sendXML, s, qtmResponses); err != nil {
return fmt.Errorf("setparameters sendcmd: %w", err)
}
return nil
}