Skip to content

Commit

Permalink
v1.3.1 datetime fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MickMake committed Feb 28, 2022
1 parent eff4d6f commit b36a272
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 132 deletions.
60 changes: 24 additions & 36 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Get mains power frequency variation graph from template id 8041 on date 2022/02/
```
./bin/GoSungrow data graph template 8041 20220228 '{"search_string":"p13007","min_left_axis":49,"max_left_axis":51}'
```
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService_queryMutiPointDataList-20220228-8041.png?raw=true)
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService_queryMutiPointDataList-20220228-8041-GridFrequency.png?raw=true)


### Using the API instead.
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions iSolarCloud/api/datetime.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package api

import (
"fmt"
"time"
)

Expand Down Expand Up @@ -51,11 +50,19 @@ func NewDateTime(date string) DateTime {
}

func (dt *DateTime) GetDayStartTimestamp() string {
return fmt.Sprintf("%s000000", dt.Time.Format(DtLayoutDay))
var ret string
f1 := dt.Time.Round(time.Hour * 24)
ret = f1.Format(DtLayoutSecond)
return ret
// return fmt.Sprintf("%s000000", dt.Time.Format(DtLayoutDay))
}

func (dt *DateTime) GetDayEndTimestamp() string {
return fmt.Sprintf("%s235900", dt.Time.Format(DtLayoutDay))
var ret string
f1 := dt.Time.Round(time.Hour * 24).Add(time.Hour * 24)
ret = f1.Format(DtLayoutSecond)
return ret
// return fmt.Sprintf("%s235900", dt.Time.Format(DtLayoutDay))
}

func (dt DateTime) String() string {
Expand Down
14 changes: 14 additions & 0 deletions iSolarCloud/api/output/struct_graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,20 @@ func (c *Chart) Generate() error {
}


// TimeValueFormatterWithFormat is a ValueFormatter for timestamps with a given format.
func formatTime(v interface{}, dateFormat string) string {
if typed, isTyped := v.(time.Time); isTyped {
return typed.Format(dateFormat)
}
if typed, isTyped := v.(int64); isTyped {
return time.Unix(0, typed).Format(dateFormat)
}
if typed, isTyped := v.(float64); isTyped {
return time.Unix(0, int64(typed)).Format(dateFormat)
}
return ""
}


// var lock sync.Mutex
// var graph *chart.Chart
Expand Down
92 changes: 0 additions & 92 deletions iSolarCloud/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,6 @@ func (sg *SunGrow) GetCurrentStats() error {
if sg.Error != nil {
break
}

// if sg.OutputType.IsHuman() {
// _queryDeviceList := queryDeviceList.AssertResultData(ep)
// points := _queryDeviceList.GetDataByName("SH10RT")
// // @TODO - Improve output of this!
// fmt.Printf("%v", points)
// }
}

return sg.Error
Expand Down Expand Up @@ -343,53 +336,6 @@ func (sg *SunGrow) GetPointData(date string, pointNames api.TemplatePoints) erro
if sg.Error != nil {
break
}

//
// csv := api.NewCsv()
// sg.Error = csv.SetHeader([]string{
// "Date/Time",
// "PointId Name",
// "Point Name",
// "Value",
// "Units",
// })
//
// data := queryMutiPointDataList.AssertResultData(ep)
// for deviceName, deviceRef := range data.Devices {
// for pointId, pointRef := range deviceRef.Points {
// for _, tim := range pointRef.Times {
// gp := pointNames.GetPoint(deviceName, pointId)
// _ = csv.AddRow([]string {
// tim.Key.PrintFull(),
// deviceName,
// fmt.Sprintf("%s (%s)", gp.Description, pointId),
// tim.Value,
// gp.Unit,
// })
// }
// }
// }
//
// switch {
// case sg.OutputType.IsNone():
//
// case sg.OutputType.IsHuman():
// table.Print()
//
// case sg.OutputType.IsFile():
// // a := queryMutiPointDataList.Assert(ep)
// // suffix := fmt.Sprintf("%s-%s", when, "data")
// // fn := a.GetCsvFilename()
// sg.Error = table.WriteCsvFile()
//
// case sg.OutputType.IsRaw():
// fmt.Println(ep.GetJsonData(true))
//
// case sg.OutputType.IsJson():
// fmt.Println(ep.GetJsonData(false))
//
// default:
// }
}

return sg.Error
Expand Down Expand Up @@ -460,9 +406,6 @@ func (sg *SunGrow) Output(endpoint api.EndPoint, table output.Table, graphFilter
table.Print()

case sg.OutputType.IsFile():
// a := queryMutiPointDataList.Assert(endpoint)
// suffix := fmt.Sprintf("%s-%s", when, "data")
// fn := a.GetCsvFilename()
sg.Error = table.WriteCsvFile()

case sg.OutputType.IsRaw():
Expand All @@ -480,7 +423,6 @@ func (sg *SunGrow) Output(endpoint api.EndPoint, table output.Table, graphFilter
if sg.Error != nil {
break
}
//

default:
}
Expand All @@ -492,11 +434,8 @@ func (sg *SunGrow) Output(endpoint api.EndPoint, table output.Table, graphFilter
func (sg *SunGrow) GetPsId() int64 {
var ret int64

// sOut := sg.OutputType
for range Only.Once {
// sg.OutputType.SetNone()

// ep := sg.GetByJson("AppService.getPsList", "")
ep := sg.GetByStruct("AppService.getPsList", nil, DefaultCacheTimeout)
if ep.IsError() {
sg.Error = ep.GetError()
Expand All @@ -506,7 +445,6 @@ func (sg *SunGrow) GetPsId() int64 {
_getPsList := getPsList.AssertResultData(ep)
ret = _getPsList.GetPsId()
}
// sg.OutputType = sOut

return ret
}
Expand All @@ -524,33 +462,3 @@ func fillArray(count int, args []string) []string {
}
return ret
}

// func (sg *SunGrow) Graph(csv api.Table, timeCol int, ) {
// foo := New("Testing 1. 2. 3.")
//
// err := foo.SetFilename("HelloWorld.png")
// fmt.Println(err)
//
// now := time.Now()
// var times []time.Time
// for i := 0; i < 16; i++ {
// now = now.Add(time.Minute * 5)
// times = append(times, now)
// }
// err = foo.SetX("Date", times...)
// fmt.Println(err)
//
// var values []float64
// for i := 0; i < 16; i++ {
// then := (float64(i) * Randy(-200, 500)) + Randy(-5000, 10000)
// values = append(values, then)
// }
//
// err = foo.SetY("Power", values...)
// fmt.Println(err)
//
// foo.SetRangeY(-6000, 12000)
//
// err = foo.Generate()
// fmt.Println(err)
// }

0 comments on commit b36a272

Please sign in to comment.