Skip to content

Commit

Permalink
fixed missing outout file
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronSaikovski committed Apr 2, 2024
1 parent ecd4a4e commit 4f23937
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 16 deletions.
Binary file modified .DS_Store
Binary file not shown.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ dist/
bin/

# ignore output files
output*.*
out*.*
output.txt
out.txt

.idea/
13 changes: 8 additions & 5 deletions cmd/gogoodwe/powerstation/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ import (

// FetchData fetches data based on user account credentials and power station ID, and can retrieve daily summary if specified.
// Parameters:
// Account string - user account
// Password string - account password
// PowerStationID string - ID of the power station
// DailySummary bool - whether to retrieve daily summary
//
// Account string - user account
// Password string - account password
// PowerStationID string - ID of the power station
// DailySummary bool - whether to retrieve daily summary
//
// Return type:
// error
//
// error
func FetchData(Account string, Password string, PowerStationID string, DailySummary bool) error {

// User account struct
Expand Down
9 changes: 0 additions & 9 deletions cmd/gogoodwe/powerstation/monitordetails.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ import (
"github.com/AaronSaikovski/gogoodwe/cmd/gogoodwe/utils"
)


// func getMonitorDatav2[T interfaces.ISemsDataConstraint](LoginCredentials *types.LoginCredentials, LoginApiResponse *types.LoginResponse, InverterOutput *T) (T, error) {

// var someValue T

// return someValue, nil

// }

// Generic function to retrieve data from the API via an ISemsDataConstraint Interface of defined structs
func getMonitorData[T interfaces.ISemsDataConstraint](LoginCredentials *types.LoginCredentials, LoginApiResponse *types.LoginResponse, InverterOutput *T) error {

Expand Down
30 changes: 30 additions & 0 deletions cmd/gogoodwe/powerstation/output.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package powerstation

import (
"errors"
"fmt"

"github.com/AaronSaikovski/gogoodwe/cmd/gogoodwe/utils"
"github.com/logrusorgru/aurora"
"github.com/valyala/fastjson"
)

// parseOutput parses the JSON output from the provided byte slice.
//
// It takes a byte slice as input and returns a *fastjson.Value and an error.
func parseOutput(dataOutput []byte) (*fastjson.Value, error) {
//parse JSON output
var parser fastjson.Parser
output, err := parser.Parse(string(dataOutput))
if err != nil {
utils.HandleError(errors.New("error: parsing powerstation data"))
return nil, err
}

return output, nil

}

func printOutput(output *fastjson.Value) {
fmt.Println(aurora.BrightYellow(output))
}

0 comments on commit 4f23937

Please sign in to comment.