-
Notifications
You must be signed in to change notification settings - Fork 13
/
device.go
61 lines (49 loc) · 1.53 KB
/
device.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
package spine
import "github.com/enbility/eebus-go/spine/model"
type DeviceImpl struct {
address *model.AddressDeviceType
dType *model.DeviceTypeType
featureSet *model.NetworkManagementFeatureSetType
useCaseManager *UseCaseManager
}
// Initialize a new device
// Both values are required for a local device but provided as empty strings for a remote device
// as the address is only provided via detailed discovery response
func NewDeviceImpl(address *model.AddressDeviceType, dType *model.DeviceTypeType, featureSet *model.NetworkManagementFeatureSetType) *DeviceImpl {
deviceImpl := &DeviceImpl{
useCaseManager: NewUseCaseManager(),
}
if dType != nil {
deviceImpl.dType = dType
}
if address != nil {
deviceImpl.address = address
}
if featureSet != nil {
deviceImpl.featureSet = featureSet
}
return deviceImpl
}
func (r *DeviceImpl) Address() *model.AddressDeviceType {
return r.address
}
func (r *DeviceImpl) UseCaseManager() *UseCaseManager {
return r.useCaseManager
}
func (r *DeviceImpl) DeviceType() *model.DeviceTypeType {
return r.dType
}
func (r *DeviceImpl) FeatureSet() *model.NetworkManagementFeatureSetType {
return r.featureSet
}
func (r *DeviceImpl) DestinationData() model.NodeManagementDestinationDataType {
return model.NodeManagementDestinationDataType{
DeviceDescription: &model.NetworkManagementDeviceDescriptionDataType{
DeviceAddress: &model.DeviceAddressType{
Device: r.Address(),
},
DeviceType: r.DeviceType(),
NetworkFeatureSet: r.FeatureSet(),
},
}
}