/
device.go
75 lines (65 loc) · 1.47 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package models
import (
"github.com/fsuhrau/automationhub/device"
"gorm.io/gorm"
)
type DeviceType int
const (
DeviceTypePhone DeviceType = iota
DeviceTypeTablet
DeviceTypeDesktop
DeviceTypeUnityEditor
)
type ConnectionType int
const (
ConnectionTypeUSB ConnectionType = iota
ConnectionTypeRemote
)
type Devices []*Device
type Device struct {
gorm.Model
CompanyID uint
DeviceIdentifier string
DeviceType DeviceType
Name string
Manager string
HardwareModel string
RAM float32
SOC string
DisplaySize string
DPI float32
OS string
OSVersion string
OSInfos string
GPU string
ABI string
OpenGLESVersion float32
Parameter []DeviceParameter
StatusLog []DeviceLog
ConnectionParameter ConnectionParameter
IsAcknowledged bool
Status device.State `gorm:"-"`
Dev interface{} `gorm:"-"`
Connection interface{} `gorm:"-"`
}
type ConnectionParameter struct {
gorm.Model
DeviceID uint
ConnectionType ConnectionType
IP string
Port int
}
type DeviceParameter struct {
gorm.Model
DeviceID uint
Key string
Value string
}
func (d *Device) GetAttribute(key string) string {
for i := range d.Parameter {
if d.Parameter[i].Key == key {
return d.Parameter[i].Value
}
}
return ""
}