-
Notifications
You must be signed in to change notification settings - Fork 11
/
posreg.go
54 lines (48 loc) · 1.22 KB
/
posreg.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
package fanuc
import (
"fmt"
)
// TODO: refactor this ugliness!
type PositionRegister struct {
Position
}
func (p PositionRegister) Value() string {
switch p.Rep {
case Uninitialized:
return fmt.Sprintf(`[%d,%d] = '%s' Uninitialized`, p.Group, p.Id, p.Comment)
case Joint:
return fmt.Sprintf(`[%d,%d] = '%s' Group: %d
J1 = %f deg J2 = %f deg J3 = %f deg
J4 = %f deg J5 = %f deg J6 = %f deg`, p.Group, p.Id, p.Comment, p.Group, p.Joints[0], p.Joints[1], p.Joints[2], p.Joints[3], p.Joints[4], p.Joints[5])
default:
var cf string
if p.Config.Flip {
cf = "F"
} else {
cf = "N"
}
var cu string
if p.Config.Up {
cu = "U"
} else {
cu = "D"
}
var ct string
if p.Config.Top {
ct = "T"
} else {
ct = "B"
}
return fmt.Sprintf(`[%d,%d] = '%s'
Group: %d Config: %s %s %s, %d, %d, %d
X: %f Y: %f Z: %f
W: %f P: %f R: %f`, p.Group, p.Id, p.Comment, p.Group, cf, cu, ct, p.Config.TurnCounts[0], p.Config.TurnCounts[1], p.Config.TurnCounts[2], p.X, p.Y, p.Z, p.W, p.P, p.R)
}
}
func (p PositionRegister) String() string {
comment := p.Comment
if comment != "" {
comment = ":" + comment
}
return fmt.Sprintf("PR[%d%s]", p.Id, comment)
}