Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions config/app.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FileProcess=/Users/frezadev/Documents/watch
host=52.77.236.193:27123
database=wfdemo-oem
dbrealtime=ecostrorealtime
host=localhost:27123
database=ecwfdemo
dbrealtime=ecwfrealtime
username=
password=
hfdfolder=/data/ostrorealtime/data
hfdfolder=/mnt/data/ostrorealtime/data
ReadTimeLoc=Asia/Kolkata
6 changes: 3 additions & 3 deletions config/configurations.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"data": {
"db": "wfdemo-oem",
"driver": "mongo",
"host": "52.77.236.193:27123",
"host": "localhost:27123",
"pass": "",
"setting": {
"timeout": 3000
Expand All @@ -16,7 +16,7 @@
"data": {
"db": "wfdemo-oem",
"driver": "mongo",
"host": "52.77.236.193:27123",
"host": "localhost:27123",
"pass": "",
"setting": {
"timeout": 3000
Expand All @@ -35,4 +35,4 @@
{
"_id": "default_password",
"data": "Password.1"
}]
}]
27 changes: 26 additions & 1 deletion library/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import (
"strings"
"time"

"path/filepath"

"github.com/eaciit/orm"
tk "github.com/eaciit/toolkit"
"github.com/tealeg/xlsx"
"path/filepath"
// _ "github.com/tealeg/xlsx"

"github.com/eaciit/dbox"
Expand Down Expand Up @@ -566,3 +568,26 @@ func UpperFirstLetter(str string) string {

return str
}

func PopulateReducesAvailability(ctx *orm.DataContext) (brakeReducesAvailability map[string]bool, e error) {
csr, e := ctx.Connection.NewQuery().
From("AlarmBrake").
Order("alarmname").
Cursor(nil)

defer csr.Close()

if e != nil {
return
}

data := []tk.M{}
e = csr.Fetch(&data, 0, false)

brakeReducesAvailability = map[string]bool{}

for _, val := range data {
brakeReducesAvailability[val.GetString("alarmname")] = val.Get("reducesavailability").(bool)
}
return
}
43 changes: 22 additions & 21 deletions library/models/alarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,27 +110,28 @@ func (m *AlarmIncorrect) TableName() string {
}

type Alarm struct {
orm.ModelBase `bson:"-",json:"-"`
ID bson.ObjectId ` bson:"_id" , json:"_id" `
Farm string
StartDate time.Time
StartDateInfo DateInfo
EndDate time.Time
Duration float64 // duration in hours
Turbine string
AlertDescription string
BrakeType string // add by ams, regarding to add new req | 20170130
ExternalStop bool
GridDown bool
InternalGrid bool
MachineDown bool
AEbOK bool
Unknown bool
WeatherStop bool
Line int
ProjectName string
PowerLost float64
Detail []AlarmDetail
orm.ModelBase `bson:"-",json:"-"`
ID bson.ObjectId ` bson:"_id" , json:"_id" `
Farm string
StartDate time.Time
StartDateInfo DateInfo
EndDate time.Time
Duration float64 // duration in hours
Turbine string
AlertDescription string
BrakeType string // add by ams, regarding to add new req | 20170130
ExternalStop bool
GridDown bool
InternalGrid bool
MachineDown bool
AEbOK bool
Unknown bool
WeatherStop bool
Line int
ProjectName string
PowerLost float64
Detail []AlarmDetail
ReduceAvailability bool
}

func (m *Alarm) New() *Alarm {
Expand Down
15 changes: 8 additions & 7 deletions library/models/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ type EventDown struct {
TimeEndInt int64
DateInfoEnd DateInfo
// DateInfoEndUTC DateInfo
AlarmDescription string
BrakeType string // add by ams, regarding to add new req | 20170130
Duration float64
Detail []EventDownDetail
DownGrid bool
DownEnvironment bool
DownMachine bool
AlarmDescription string
BrakeType string // add by ams, regarding to add new req | 20170130
Duration float64
Detail []EventDownDetail
DownGrid bool
DownEnvironment bool
DownMachine bool
ReduceAvailability bool
}

type EventDownDetail struct {
Expand Down
5 changes: 3 additions & 2 deletions library/models/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ func (m *ProjectMaster) TableName() string {
}

type TurbineOut struct {
Project string
Turbine string
Project string
Turbine string
Capacity float64
}

type ProjectOut struct {
Expand Down
6 changes: 6 additions & 0 deletions library/models/scadaData.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ type ScadaData struct {
AlarmWeatherStop float64
ExternalStopTime float64
GridDownTime float64
GridDownTimeAll float64
GridOkSecs float64
InternalLineDown float64
MachineDownTime float64
MachineDownTimeAll float64
OkSecs float64
OkTime float64
UnknownTime float64
UnknownTimeAll float64
WeatherStopTime float64
GeneratorRPM float64
NacelleYawPositionUntwist float64
Expand Down Expand Up @@ -69,6 +72,9 @@ type ScadaData struct {
TotalAvail float64 // new added on Sep 27, 2016 by ams
MachineAvail float64 // new added on Sep 27, 2016 by ams
GridAvail float64 // new added on Sep 27, 2016 by ams
TotalAvailAll float64 // new added on May 12, 2017 by fr
MachineAvailAll float64 // new added on May 12, 2017 by fr
GridAvailAll float64 // new added on May 12, 2017 by fr
DenPcDeviation float64 // new added on Sep 27, 2016 by ams
DenDeviationPct float64 // new added on Sep 27, 2016 by ams
DenPcValue float64 // new added on Sep 27, 2016 by ams
Expand Down
62 changes: 34 additions & 28 deletions library/models/scadaDataOem.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,34 +167,40 @@ type ScadaDataOEM struct {
AI_YawBrake_TempRise4 float64
AI_intern_NacelleDrill_at_NorthPosSensor float64

Energy float64 // new added on Sep 14, 2016 by ams
EnergyLost float64 // new added on Sep 14, 2016 by ams
TurbineElevation float64 // new added on Sep 14, 2016 by ams
DenValue float64 // new added on Sep 14, 2016 by ams
DenPh float64 // new added on Sep 14, 2016 by ams
DenWindSpeed float64 // new added on Sep 14, 2016 by ams
DenAdjWindSpeed float64 // new added on Sep 14, 2016 by ams
DenPower float64 // new added on Sep 14, 2016 by ams
DenEnergy float64 // new added on Sep 14, 2016 by ams
PCValue float64 // new added on Sep 15, 2016 by ams
PCValueAdj float64 // new added on Sep 15, 2016 by ams
PCDeviation float64 // new added on Sep 15, 2016 by ams
WSAdjForPC float64 // new added on Sep 16, 2016 by ams
WSAvgForPC float64 // new added on Sep 16, 2016 by ams
TotalAvail float64 // new added on Sep 27, 2016 by ams
MachineAvail float64 // new added on Sep 27, 2016 by ams
GridAvail float64 // new added on Sep 27, 2016 by ams
DenPcDeviation float64 // new added on Sep 27, 2016 by ams
DenDeviationPct float64 // new added on Sep 27, 2016 by ams
DenPcValue float64 // new added on Sep 27, 2016 by ams
DeviationPct float64 // new added on Sep 27, 2016 by ams
MTTR float64
MTTF float64
PerformanceIndex float64
PowerLost float64
GridDowntime float64
MachineDowntime float64
UnknownDowntime float64
Energy float64 // new added on Sep 14, 2016 by ams
EnergyLost float64 // new added on Sep 14, 2016 by ams
TurbineElevation float64 // new added on Sep 14, 2016 by ams
DenValue float64 // new added on Sep 14, 2016 by ams
DenPh float64 // new added on Sep 14, 2016 by ams
DenWindSpeed float64 // new added on Sep 14, 2016 by ams
DenAdjWindSpeed float64 // new added on Sep 14, 2016 by ams
DenPower float64 // new added on Sep 14, 2016 by ams
DenEnergy float64 // new added on Sep 14, 2016 by ams
PCValue float64 // new added on Sep 15, 2016 by ams
PCValueAdj float64 // new added on Sep 15, 2016 by ams
PCDeviation float64 // new added on Sep 15, 2016 by ams
WSAdjForPC float64 // new added on Sep 16, 2016 by ams
WSAvgForPC float64 // new added on Sep 16, 2016 by ams
TotalAvail float64 // new added on Sep 27, 2016 by ams
MachineAvail float64 // new added on Sep 27, 2016 by ams
GridAvail float64 // new added on Sep 27, 2016 by ams
TotalAvailAll float64 // new added on May 12, 2017 by fr
MachineAvailAll float64 // new added on May 12, 2017 by fr
GridAvailAll float64 // new added on May 12, 2017 by fr
DenPcDeviation float64 // new added on Sep 27, 2016 by ams
DenDeviationPct float64 // new added on Sep 27, 2016 by ams
DenPcValue float64 // new added on Sep 27, 2016 by ams
DeviationPct float64 // new added on Sep 27, 2016 by ams
MTTR float64
MTTF float64
PerformanceIndex float64
PowerLost float64
GridDowntime float64
MachineDowntime float64
UnknownDowntime float64
GridDowntimeAll float64
MachineDowntimeAll float64
UnknownDowntimeAll float64
}

func (m *ScadaDataOEM) New() *ScadaDataOEM {
Expand Down
48 changes: 31 additions & 17 deletions processapp/eventConverter/conversion/convertToDown.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"
"time"

// . "eaciit/wfdemo-git/library/helper"
. "eaciit/wfdemo-git/library/helper"
. "eaciit/wfdemo-git/library/models"

_ "github.com/eaciit/dbox/dbc/mongo"
Expand All @@ -17,9 +17,10 @@ import (
)

var (
separator = string(os.PathSeparator)
mutex = &sync.Mutex{}
countPerProcess = 1
separator = string(os.PathSeparator)
mutex = &sync.Mutex{}
countPerProcess = 1
brakeReducesAvailability = map[string]bool{}
)

type GroupResult struct {
Expand All @@ -45,19 +46,29 @@ func NewDownConversion(ctx *orm.DataContext, filePath string) *DownConversion {
func (ev *DownConversion) Run() {
log.Println("===================== Starting EVENT DOWN")
// _ = ev.getLatest()
var wg sync.WaitGroup
loops := ev.getLatest()
counter := 0
for _, loop := range loops {
counter++
// if loop.Turbine == "SSE017" {
// log.Printf("loop: %v | %v \n", loop.Turbine, loop.LatestProcessTime)
wg.Add(1)
go ev.processTurbine(loop, &wg)
// }

if counter%5 == 0 || len(loops) == counter {
wg.Wait()

// get brakeReducesAvailability
var e error
brakeReducesAvailability, e = PopulateReducesAvailability(ev.Ctx)

if e != nil {
log.Printf("Error Generating Event Down: %v \n", e.Error())
} else {

var wg sync.WaitGroup
loops := ev.getLatest()
counter := 0
for _, loop := range loops {
counter++
// if loop.Turbine == "SSE017" {
// log.Printf("loop: %v | %v \n", loop.Turbine, loop.LatestProcessTime)
wg.Add(1)
go ev.processTurbine(loop, &wg)
// }

if counter%5 == 0 || len(loops) == counter {
wg.Wait()
}
}
}

Expand Down Expand Up @@ -501,6 +512,9 @@ func (ev *DownConversion) insertEventDown(loop GroupResult, start EventRaw, end

if down.DateInfoStart.MonthId != 0 && down.TimeStart.UTC().Year() != 1 {
mutex.Lock()

down.ReduceAvailability = brakeReducesAvailability[down.AlarmDescription]

brakeType := start.BrakeType
if strings.Contains(strings.ToLower(brakeType), "grid") {
down.DownGrid = true
Expand Down
3 changes: 2 additions & 1 deletion processapp/summaryGenerator/controllers/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ func (b *BaseController) PrepareDataReff() {
b.RefTurbines.Set(t.TurbineId, tk.M{}.
Set("turbinename", t.TurbineName).
Set("turbineelevation", t.Elevation).
Set("topcorrelation", t.TopCorrelation))
Set("topcorrelation", t.TopCorrelation).
Set("project", t.Project))
}

tk.Printf("Turbines: %v \n", len(turbines))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func (ev *EventToAlarm) doConversion(event *EventDown) {
alarm.AEbOK = false
alarm.WeatherStop = false
alarm.Line = counterRow
alarm.ReduceAvailability = event.ReduceAvailability

timeStartWhr := event.TimeStart
timeEndWhr := event.TimeEnd.Add(10 * time.Minute)
Expand Down
Loading