...
|
...
|
@@ -135,7 +135,7 @@ func (d *DeviceRunningRecordInfo) AddDeviceRunningData(t time.Time, data *Device |
|
|
if len(d.DeviceType) == 0 {
|
|
|
d.DeviceType = data.DeviceType
|
|
|
}
|
|
|
d.CurrentStatus = data.StartupStatus | (1 << data.ComStatus)
|
|
|
d.CurrentStatus = data.StartupStatus | (data.ComStatus << 1) | (data.Alarm << 2)
|
|
|
d.ResetUpTime()
|
|
|
d.Count += data.Count
|
|
|
//d.Temp = data.FrontTemp
|
...
|
...
|
@@ -165,6 +165,7 @@ func (d *DeviceRunningRecordInfo) AddTimeLineDeviceStatus(t time.Time, data *Dev |
|
|
}
|
|
|
v.UpdateUp(t, data.StartupStatus)
|
|
|
v.UpdateCom(t, data.ComStatus)
|
|
|
v.UpdateAlarm(t, data.Alarm)
|
|
|
}
|
|
|
|
|
|
// 重置运行时长
|
...
|
...
|
@@ -199,9 +200,14 @@ func (d *DeviceRunningRecordInfo) HourDeviceStatusDetail(endTime int) map[string |
|
|
err := make([][]int, 0)
|
|
|
var begin, end int = 0, 0
|
|
|
/*
|
|
|
1.故障: 1 0 \ 0 0
|
|
|
2.正常: 1 1
|
|
|
3.停机:0 1
|
|
|
旧: 1.故障: 1 0 \ 0 0
|
|
|
2.正常: 1 1
|
|
|
3.停机:0 1
|
|
|
|
|
|
新: 只要未开机,就是待机中状态
|
|
|
1.故障: 1 0 0 / 1 0 1 / 1 1 1 / 1/5/7
|
|
|
2.正常: 1 1 0 3
|
|
|
3.停机:0 0 0 / 0 1 0 / 0 0 1 / 0 1 1 0/2/4/6
|
|
|
*/
|
|
|
var status = 1
|
|
|
// 添加数据
|
...
|
...
|
@@ -227,13 +233,13 @@ func (d *DeviceRunningRecordInfo) HourDeviceStatusDetail(endTime int) map[string |
|
|
if com&index > 0 {
|
|
|
val |= 2
|
|
|
}
|
|
|
if val == 1 {
|
|
|
if val == 1 || val == 5 || val == 7 {
|
|
|
return 1 //故障
|
|
|
}
|
|
|
if val == 3 {
|
|
|
return 2 //正常
|
|
|
}
|
|
|
if val == 2 || val == 0 {
|
|
|
if val == 0 || val == 2 || val == 4 || val == 6 {
|
|
|
return 3 //停机
|
|
|
}
|
|
|
return 3 // 停机
|
...
|
...
|
@@ -294,6 +300,8 @@ type HourDeviceStatus struct { |
|
|
Up int `json:"up"`
|
|
|
// 通讯
|
|
|
Com int `json:"com"`
|
|
|
// 报警
|
|
|
Alarm int `json:"alarm"`
|
|
|
}
|
|
|
|
|
|
// 更新启动状态
|
...
|
...
|
@@ -324,6 +332,20 @@ func (d *HourDeviceStatus) UpdateCom(t time.Time, c int) { |
|
|
return
|
|
|
}
|
|
|
|
|
|
// 更新报警状态
|
|
|
func (d *HourDeviceStatus) UpdateAlarm(t time.Time, c int) {
|
|
|
m := t.Minute()
|
|
|
bit := 1 << (m / d.Window)
|
|
|
if c&1 == 0 {
|
|
|
return
|
|
|
}
|
|
|
if d.Alarm&bit > 0 {
|
|
|
return
|
|
|
}
|
|
|
d.Alarm |= bit
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 计算状态持续的时间
|
|
|
func (d *HourDeviceStatus) CountTime(v int) time.Duration {
|
|
|
l := 60 / d.Window
|
...
|
...
|
@@ -346,5 +368,6 @@ func NewHourDeviceStatus() *HourDeviceStatus { |
|
|
Window: DefaultTimeWindow,
|
|
|
Up: 0,
|
|
|
Com: 0,
|
|
|
Alarm: 0,
|
|
|
}
|
|
|
} |
...
|
...
|
|