forked from scylladb/care-pet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrand.go
49 lines (44 loc) · 974 Bytes
/
rand.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
package model
import "math/rand"
func RandOwner() *Owner {
return &Owner{
OwnerID: RandomUUID(),
Address: "home",
Name: RandomString(8),
}
}
func RandPet(o *Owner) *Pet {
return &Pet{
OwnerID: o.OwnerID,
PetID: RandomUUID(),
Age: 1 + rand.Intn(100),
Weight: float32(5 + rand.Intn(10)),
Address: "home",
Name: RandomString(8),
}
}
func RandSensor(o *Pet) *Sensor {
return &Sensor{
PetID: o.PetID,
SensorID: RandomUUID(),
Type: SensorTypes[rand.Intn(len(SensorTypes))],
}
}
func RandSensorData(s *Sensor) float32 {
switch s.Type {
case SensorTypeTemperature:
// average F
return float32(101 + rand.Intn(10) - 4)
case SensorTypePulse:
// average beat per minute
return float32(100 + rand.Intn(40) - 20)
case SensorTypeRespiration:
// average inhales per minute
return float32(35 + rand.Intn(5) - 2)
case SensorTypeLocation:
// distance from home
return 10 * rand.Float32()
default:
return 0.0
}
}