forked from wmnsk/go-m3ua
/
status.go
62 lines (51 loc) · 1.43 KB
/
status.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
// Copyright 2018-2020 go-m3ua authors. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
package params
// Status Type definitions.
const (
AsStateChange uint16 = iota + 1
Other
)
// Status Information definitions (StatusType==AsStateChange).
// Note that this contains the type.
const (
_ uint32 = uint32((0x01 << 16) | iota + 1)
AsStateInactive
AsStateActive
AsStatePending
)
// Status Information definitions (StatusType==Other).
// Note that this contains the type.
const (
InsufficientAspResources uint32 = uint32((0x02 << 16) | iota + 1)
AlternateAspActive
AspFailure
)
// NewStatus creates the Status Parameter.
// Note that this returns *Param, as no specific structure in this parameter.
// The argument typeInfo can be chosen from Status Information definitions above.
func NewStatus(typeInfo uint32) *Param {
return newUint32ValParam(Status, typeInfo)
}
// Status returns multiple Status from Param.
func (p *Param) Status() uint32 {
if p.Tag != Status {
return 0
}
return p.decodeUint32ValData()
}
// StatusType returns multiple StatusType from Param.
func (p *Param) StatusType() uint16 {
if p.Tag != Status {
return 0
}
return uint16(p.decodeUint32ValData() >> 16)
}
// StatusInfo returns multiple StatusInfo from Param.
func (p *Param) StatusInfo() uint16 {
if p.Tag != Status {
return 0
}
return uint16(p.decodeUint32ValData() & 0xffff)
}