/
eventhfd.go
72 lines (60 loc) · 2.01 KB
/
eventhfd.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
package models
import (
. "eaciit/wfdemo-git/library/helper"
"math/rand"
"time"
"github.com/eaciit/orm"
tk "github.com/eaciit/toolkit"
)
type EventRawHFD struct {
orm.ModelBase `bson:"-",json:"-"`
ID string ` bson:"_id" , json:"_id" `
ProjectName string
Turbine string //
TimeStamp time.Time
DateInfo DateInfo
EventType string // e.g.: Fast.AlarmCode
BrakeProgram int // alarmbrake > brakeprogram , put 999 if the alarmcode is not found in alarmbrake
AlarmDescription string // alarmbrake > alarmame
AlarmId int // alarmcode , put 999 if the alarmcode is empty / 999
// TurbineStatus string
// AlarmToggle bool
BrakeType string // AlarmBrake > type
}
func (m *EventRawHFD) New() *EventRawHFD {
timeStampStr := m.TimeStamp.Format("060102_150405")
m.ID = timeStampStr + "#" + m.ProjectName + "#" + m.Turbine + "#" + tk.ToString(m.AlarmId) + "#" + m.EventType + "#" + time.Now().Format("060102150405_000000000") + "_" + tk.ToString(rand.Intn(999999))
return m
}
func (m *EventRawHFD) TableName() string {
return "EventRawHFD"
}
type EventDownHFD struct {
orm.ModelBase `bson:"-",json:"-"`
ID string ` bson:"_id" , json:"_id" `
ProjectName string
Turbine string
TimeStart time.Time
DateInfoStart DateInfo
TimeEnd time.Time
DateInfoEnd DateInfo
GroupTimeStart time.Time
GroupTimeEnd time.Time
AlarmDescription string
Duration float64
DownGrid bool
DownEnvironment bool
DownMachine bool
AlarmID int
}
func (m *EventDownHFD) New() *EventDownHFD {
timeStampStr := m.TimeStart.Format("060102_150405")
m.ID = timeStampStr + "#" + m.ProjectName + "#" + m.Turbine + "#" + time.Now().Format("060102150405_000000000") + "_" + tk.ToString(rand.Intn(999999))
return m
}
func (m *EventDownHFD) RecordID() interface{} {
return m.ID
}
func (m *EventDownHFD) TableName() string {
return "EventDownHFD"
}