-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
927 additions
and
1,460 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,95 @@ | ||
package cmd | ||
|
||
import ( | ||
"GoSungrow/Only" | ||
"GoSungrow/iSolarCloud/api" | ||
"fmt" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
|
||
// ******************************************************************************** | ||
var cmdDataStats = &cobra.Command{ | ||
Use: "stats", | ||
// Aliases: []string{""}, | ||
Short: fmt.Sprintf("Get live data from iSolarCloud"), | ||
Long: fmt.Sprintf("Get live data from iSolarCloud"), | ||
DisableFlagParsing: false, | ||
DisableFlagsInUseLine: false, | ||
PreRunE: Cmd.SunGrowArgs, | ||
Run: cmdDataStatsFunc, | ||
Args: cobra.MinimumNArgs(1), | ||
func AttachCmdDataTemplatePoints(cmd *cobra.Command) *cobra.Command { | ||
// ******************************************************************************** | ||
var cmdDataTemplatePoints = &cobra.Command{ | ||
Use: "template-points <template_id>", | ||
Aliases: []string{""}, | ||
Short: fmt.Sprintf("List data points used in report template."), | ||
Long: fmt.Sprintf("List data points used in report template."), | ||
DisableFlagParsing: false, | ||
DisableFlagsInUseLine: false, | ||
PreRunE: Cmd.SunGrowArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
_ = SwitchOutput(cmd) | ||
return Cmd.SunGrow.GetTemplatePoints(args[0]) | ||
}, | ||
Args: cobra.ExactArgs(1), | ||
} | ||
cmd.AddCommand(cmdDataTemplatePoints) | ||
cmdDataTemplatePoints.Example = PrintExamples(cmdDataTemplatePoints, "8042", "8040") | ||
|
||
return cmd | ||
} | ||
|
||
func cmdDataStatsFunc(_ *cobra.Command, args []string) { | ||
for range Only.Once { | ||
Cmd.SunGrow.OutputType.SetFile() | ||
func AttachCmdDataTemplate(cmd *cobra.Command) *cobra.Command { | ||
// ******************************************************************************** | ||
var cmdDataGetTemplate = &cobra.Command{ | ||
Use: "template <template_id> <date> [filter]", | ||
Short: fmt.Sprintf("Get data from report template."), | ||
Long: fmt.Sprintf("Get data from report template."), | ||
DisableFlagParsing: false, | ||
DisableFlagsInUseLine: false, | ||
PreRunE: Cmd.SunGrowArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
_ = SwitchOutput(cmd) | ||
return Cmd.SunGrow.GetTemplateData(args[0], args[1], args[2]) | ||
}, | ||
Args: cobra.MinimumNArgs(2), | ||
} | ||
cmd.AddCommand(cmdDataGetTemplate) | ||
cmdDataGetTemplate.Example = PrintExamples(cmdDataGetTemplate, "8042 20220212", "8042 20220212 '{\"search_string\":\"p83106\",\"min_left_axis\":-6000,\"max_left_axis\":12000}'") | ||
|
||
return cmd | ||
} | ||
|
||
Cmd.Error = Cmd.SunGrow.GetCurrentStats() | ||
func AttachCmdDataStats(cmd *cobra.Command) *cobra.Command { | ||
// ******************************************************************************** | ||
var cmdDataStats = &cobra.Command{ | ||
Use: "stats", | ||
Aliases: []string{""}, | ||
Short: fmt.Sprintf("Get current inverter stats, (last 5 minutes)."), | ||
Long: fmt.Sprintf("Get current inverter stats, (last 5 minutes)."), | ||
DisableFlagParsing: false, | ||
DisableFlagsInUseLine: false, | ||
PreRunE: Cmd.SunGrowArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
_ = SwitchOutput(cmd) | ||
return Cmd.SunGrow.GetCurrentStats() | ||
}, | ||
Args: cobra.ExactArgs(0), | ||
} | ||
cmd.AddCommand(cmdDataStats) | ||
cmdDataStats.Example = PrintExamples(cmdDataStats, "") | ||
|
||
return cmd | ||
} | ||
|
||
func AttachCmdDataPoints(cmd *cobra.Command) *cobra.Command { | ||
// ******************************************************************************** | ||
var cmdDataStats = &cobra.Command{ | ||
Use: "points <date> <device_id.point_id> ...", | ||
Aliases: []string{""}, | ||
Short: fmt.Sprintf("Get points data for a specific date."), | ||
Long: fmt.Sprintf("Get points data for a specific date."), | ||
DisableFlagParsing: false, | ||
DisableFlagsInUseLine: false, | ||
PreRunE: Cmd.SunGrowArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
_ = SwitchOutput(cmd) | ||
return Cmd.SunGrow.GetPointData(args[0], api.CreatePoints(args[1:])) | ||
}, | ||
Args: cobra.MinimumNArgs(2), | ||
} | ||
cmd.AddCommand(cmdDataStats) | ||
cmdDataStats.Example = PrintExamples(cmdDataStats, "20220202 1129147.p13019 1129147.p83106") | ||
|
||
return cmd | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.