Skip to content

Commit

Permalink
v3.0.0-alpha - tidy up.
Browse files Browse the repository at this point in the history
  • Loading branch information
MickMake committed Dec 6, 2022
1 parent 73160f9 commit 0531cb9
Show file tree
Hide file tree
Showing 14 changed files with 363 additions and 899 deletions.
194 changes: 62 additions & 132 deletions .idea/workspace.xml

Large diffs are not rendered by default.

66 changes: 65 additions & 1 deletion iSolarCloud/api/GoStruct/legacy.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
package GoStruct


// -------------------------------------------------------------------------------- //
// From struct_reflect.go
//
// func (r *Reflect) ConvertToState() {
// for range Only.Once {
// var ok bool
//
// switch {
// case r.Value.First().ValueFloat() > 0:
// ok = true
// case r.Value.First().ValueFloat() < 0:
// ok = true
// case r.Value.First().ValueInt() > 0:
// ok = true
// case r.Value.First().ValueInt() < 0:
// ok = true
// }
// r.Value = valueTypes.SetUnitValueBool(ok)
// }
// }
//
// func (r *Reflect) SetValues(values ...interface{}) {
// for range Only.Once {
// r.InterfaceValue = values
// var uvs valueTypes.UnitValues
// for _, value := range values {
// var uvs2 valueTypes.UnitValues
// uvs2, r.IsNil, r.IsOk = valueTypes.AnyToUnitValue(
// value, "", r.DataStructure.PointUnit,
// r.DataStructure.PointValueType, r.DataStructure.PointNameDateFormat)
// uvs.AddUnitValues(uvs2)
// }
// }
// }


// func FindStart(fieldName string, Parent *Reflect, Current *Reflect, name EndPointPath) *Reflect {
// var ret Reflect
//
Expand Down Expand Up @@ -104,7 +140,6 @@ package GoStruct
// -------------------------------------------------------------------------------- //
// From structmap.go
//
//
// func (sm *StructMap) GetTables() StructTables {
// var ret StructTables
//
Expand Down Expand Up @@ -349,4 +384,33 @@ package GoStruct
// return ret
// }
//
//
// func (sm *StructMap) SaveGoStructOptions(Child *Reflect) bool {
// var yes bool
//
// for range Only.Once {
// var ds DataTags
// ds = Child.DataStructure
// ds.Json = ""
// ds.PointId = ""
// ds.PointName = ""
// ds.ValueType = ""
// ds.ValueKind = ""
// ds.Endpoint.Clear()
//
// sm.GoStructOptions = &ds
// sm.GoStructOptionCurrent = Child.CurrentReflect.CurrentReflect // @TODO - Need to sort out this mess.
// if Child.IsTable() {
// sm.GoStructOptionCurrent = Child.CurrentReflect.CurrentReflect
// }
// Child.CurrentReflect.CurrentReflect.GoStruct = &ds
// }
//
// return yes
// }
//
// func (sm *StructMap) ClearGoStructOptions() {
// sm.GoStructOptions = nil
// sm.GoStructOptionCurrent = nil
// }

25 changes: 2 additions & 23 deletions iSolarCloud/api/GoStruct/output/file.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package output

import (
"github.com/MickMake/GoUnify/Only"
"encoding/json"
"errors"
"fmt"
"github.com/MickMake/GoUnify/Only"
"io/ioutil"
"os"
)
Expand All @@ -13,6 +13,7 @@ import (
// FileRead Retrieves data from a local file.
func FileRead(fn string, ref interface{}) error {
var err error

for range Only.Once {
if fn == "" {
err = errors.New("empty file")
Expand All @@ -34,18 +35,6 @@ func FileRead(fn string, ref interface{}) error {
err = json.NewDecoder(f).Decode(&ref)
}

// for range Only.Once {
// fn := ep.GetFilename()
// if err != nil {
// break
// }
//
// ret, err = os.FileRead(fn)
// if err != nil {
// break
// }
// }

return err
}

Expand All @@ -68,16 +57,6 @@ func FileWrite(fn string, ref interface{}, perm os.FileMode) error {
//goland:noinspection GoUnhandledErrorResult,GoDeferInLoop
defer f.Close()
err = json.NewEncoder(f).Encode(ref)

// fn := ep.GetFilename()
// if err != nil {
// break
// }
//
// err = os.FileWrite(fn, data, perm)
// if err != nil {
// break
// }
}

return err
Expand Down
140 changes: 140 additions & 0 deletions iSolarCloud/api/GoStruct/output/legacy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
package output

// type SearchStrings map[string]int
// func (t *Table) FindSearchStrings() error {
// for range Only.Once {
// t.graph.otherSearch = make(SearchStrings)
//
// for row := 0; row < t.RowLength(); row++ {
// // Get the search column
// var cell interface{}
// // cell, t.Error = t.table.CellAt(tabular.CellLocation{Row: row, Column: *t.graph.req.SearchColumn})
// cell, t.Error = t.GetCell(row, *t.graph.req.SearchColumn)
// if t.Error != nil {
// continue
// }
// if _, ok := t.graph.otherSearch[cell.(string)]; ok {
// t.graph.otherSearch[cell.(string)] += 1
// } else {
// t.graph.otherSearch[cell.(string)] = 0
// }
// }
// }
//
// return t.Error
// }
//
// func (t *Table) SearchStrings() SearchStrings {
// return t.graph.otherSearch
// }
//
// func (t *Table) CreateGraphAll() error {
// return t.graph.Generate()
// }
//
// func Randy(min int, max int) float64 {
// r := rand.Intn(max - min) + min
// return float64(r)
// }
//
// func Test() {
// 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)
// }
//
// var zero = float64(0)
//
// var lock sync.Mutex
// var graph *chart.Chart
// var ts *chart.TimeSeries
//
// func addData(t time.Time, e time.Duration) {
// lock.Lock()
// ts.XValues = append(ts.XValues, t)
// ts.YValues = append(ts.YValues, chart.TimeMillis(e))
// lock.Unlock()
// }
//
// func drawChart(res http.ResponseWriter, req *http.Request) {
// start := time.Now()
// defer func() {
// addData(start, time.Since(start))
// }()
// if len(ts.XValues) == 0 {
// http.Error(res, "no data (yet)", http.StatusBadRequest)
// return
// }
// res.Header().Set("Content-Type", "image/png")
// if err := graph.Render(chart.PNG, res); err != nil {
// log.Printf("%v", err)
// }
// }
//
//
// func Server() {
// ts = &chart.TimeSeries{
// XValues: []time.Time{},
// YValues: []float64{},
// }
// graph = &chart.Chart{
// Series: []chart.Series{ts},
// }
// http.HandleFunc("/", drawChart)
// log.Fatal(http.ListenAndServe(":8080", nil))
// }
//
// 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 ""
// }
//
// func (t *Table) GetSearchColumn() SearchStrings {
// return t.graph.otherSearch
// }
//
// func SetInteger(v int) *int {
// return &v
// }
//
// func SetString(v string) *string {
// return &v
// }
//
// func SetFloat(v float64) *float64 {
// return &v
// }
//

0 comments on commit 0531cb9

Please sign in to comment.