mirror of
https://github.com/MickMake/GoSungrow.git
synced 2025-03-26 17:41:42 +01:00
v2.3.6 - Rename GoStruct
This commit is contained in:
parent
260fd19728
commit
167c52254f
@ -1,7 +1,7 @@
|
||||
package Common
|
||||
|
||||
import (
|
||||
"GoSungrow/iSolarCloud/api/valueTypes"
|
||||
"GoSungrow/iSolarCloud/api/GoStruct/valueTypes"
|
||||
)
|
||||
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
package iSolarCloud
|
||||
|
@ -1,8 +0,0 @@
|
||||
package iSolarCloud
|
||||
|
||||
import "time"
|
||||
|
||||
|
||||
const (
|
||||
DefaultCacheTimeout = time.Minute * 5
|
||||
)
|
@ -2,8 +2,8 @@ package iSolarCloud
|
||||
|
||||
import (
|
||||
"GoSungrow/iSolarCloud/api"
|
||||
"GoSungrow/iSolarCloud/api/output"
|
||||
"GoSungrow/iSolarCloud/api/valueTypes"
|
||||
"GoSungrow/iSolarCloud/api/GoStruct/output"
|
||||
"GoSungrow/iSolarCloud/api/GoStruct/valueTypes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -14,114 +14,18 @@ import (
|
||||
|
||||
// ****************************************************** //
|
||||
|
||||
func (sg *SunGrow) GetEndpoints(endpoints string, args ...string) error {
|
||||
func (sg *SunGrow) NewSunGrowData() SunGrowData {
|
||||
var data SunGrowData
|
||||
for range Only.Once {
|
||||
var data SunGrowData
|
||||
data.New(sg)
|
||||
|
||||
var request SunGrowDataRequest
|
||||
request = request.Set(args...)
|
||||
|
||||
eps := SplitArg(endpoints)
|
||||
// if endpoints == "all" {
|
||||
// eps = data.GetAllEndPoints()
|
||||
// }
|
||||
|
||||
if endpoints == "" {
|
||||
// fmt.Println("Additional commands available, (on top of endpoints):")
|
||||
// for _, ep := range data.GetAllEndPoints() {
|
||||
// fmt.Printf("\t%s\n", ep)
|
||||
// }
|
||||
sg.Error = errors.New("need an endpoint")
|
||||
break
|
||||
}
|
||||
|
||||
for _, endpoint := range eps {
|
||||
ep := sg.GetEndpoint(endpoint)
|
||||
sg.Error = ep.GetError()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
|
||||
rargs := ep.GetRequestArgNames()
|
||||
// fmt.Printf("args:%s\n", rargs)
|
||||
|
||||
// getOrgList.ResultData
|
||||
if _, ok := rargs[NamePsId]; !ok {
|
||||
response := data.GetByApi(ep, request)
|
||||
if response.Error != nil {
|
||||
sg.Error = response.Error
|
||||
break
|
||||
}
|
||||
if data.Error != nil {
|
||||
sg.Error = data.Error
|
||||
break
|
||||
}
|
||||
|
||||
if sg.OutputType.IsTable() {
|
||||
if len(response.Data.DataTables) == 0 {
|
||||
fmt.Println("No data tables defined - try a get instead.")
|
||||
break
|
||||
}
|
||||
for _, t := range response.Data.DataTables {
|
||||
t.OutputType = sg.OutputType
|
||||
t.SetSaveFile(sg.SaveAsFile)
|
||||
sg.Error = t.Output()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
response.Data.Table.SetFilePrefix(request.GetFilename(endpoint))
|
||||
sg.Error = response.Data.Table.Output()
|
||||
break
|
||||
}
|
||||
|
||||
if len(request.aPsId) == 0 {
|
||||
var pids valueTypes.PsIds
|
||||
pids, sg.Error = sg.GetPsIds()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
request.SetPsIds(pids.Strings())
|
||||
}
|
||||
for _, psId := range request.aPsId {
|
||||
request.SetPsId(psId.String())
|
||||
|
||||
response := data.GetByApi(ep, request)
|
||||
if response.Error != nil {
|
||||
sg.Error = response.Error
|
||||
break
|
||||
}
|
||||
if data.Error != nil {
|
||||
sg.Error = data.Error
|
||||
break
|
||||
}
|
||||
|
||||
if sg.OutputType.IsTable() {
|
||||
for _, t := range response.Data.DataTables {
|
||||
t.OutputType = sg.OutputType
|
||||
t.SetSaveFile(sg.SaveAsFile)
|
||||
sg.Error = t.Output()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
response.Data.Table.SetFilePrefix(request.GetFilename(endpoint))
|
||||
sg.Error = response.Data.Table.Output()
|
||||
}
|
||||
break
|
||||
}
|
||||
data.SetOutputType(sg.OutputType)
|
||||
data.SetSaveAsFile(sg.SaveAsFile)
|
||||
}
|
||||
|
||||
return sg.Error
|
||||
return data
|
||||
}
|
||||
|
||||
|
||||
func SplitArg(arg string) []string {
|
||||
var ret []string
|
||||
for range Only.Once {
|
||||
@ -152,17 +56,60 @@ type SunGrowDataResponse struct {
|
||||
Title string
|
||||
Error error
|
||||
}
|
||||
type SunGrowDataResponses map[string]SunGrowDataResponse
|
||||
|
||||
func (sgd *SunGrowDataResponse) GetOutput(outputType output.OutputType, saveAsFile bool) error {
|
||||
for range Only.Once {
|
||||
if sgd.Data.Table.OutputType.IsTable() {
|
||||
var ok bool
|
||||
for _, t := range sgd.Data.DataTables {
|
||||
ok = true
|
||||
t.OutputType = outputType
|
||||
t.SetSaveFile(saveAsFile)
|
||||
sgd.Error = t.Output()
|
||||
if sgd.Error != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
if !ok {
|
||||
fmt.Printf("No data table results for '%s'", sgd.Title)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
sgd.Data.Table.OutputType = outputType
|
||||
sgd.Data.Table.SetSaveFile(saveAsFile)
|
||||
sgd.Error = sgd.Data.Table.Output()
|
||||
}
|
||||
|
||||
return sgd.Error
|
||||
}
|
||||
|
||||
|
||||
type SunGrowData struct {
|
||||
// EndPoints EndPoints
|
||||
SunGrow *SunGrow
|
||||
Error error
|
||||
endPoints []string
|
||||
request SunGrowDataRequest
|
||||
|
||||
results SunGrowDataResults
|
||||
|
||||
sunGrow *SunGrow
|
||||
outputType output.OutputType
|
||||
saveAsFile bool
|
||||
Error error
|
||||
}
|
||||
type SunGrowDataResult struct {
|
||||
EndPointName api.EndPointName
|
||||
EndPoint api.EndPoint
|
||||
Request SunGrowDataRequest
|
||||
Response SunGrowDataResponse
|
||||
}
|
||||
type SunGrowDataResults map[string]SunGrowDataResult
|
||||
|
||||
func (sgd *SunGrowData) New(ref *SunGrow) {
|
||||
for range Only.Once {
|
||||
sgd.SunGrow = ref
|
||||
sgd.sunGrow = ref
|
||||
sgd.results = make(SunGrowDataResults)
|
||||
|
||||
// sgd.EndPoints = make(EndPoints)
|
||||
// sgd.EndPoints["getPsList"] = EndPoint { Func: sgd.getPsList, HasArgs: false }
|
||||
// sgd.EndPoints["queryDeviceList"] = EndPoint { Func: sgd.queryDeviceList, HasArgs: true }
|
||||
@ -207,25 +154,143 @@ func (sgd *SunGrowData) New(ref *SunGrow) {
|
||||
}
|
||||
}
|
||||
|
||||
func (sgd *SunGrowData) GetByEndPointName(endpoint string, request SunGrowDataRequest) SunGrowDataResponse {
|
||||
var response SunGrowDataResponse
|
||||
response.Data.Table = output.NewTable()
|
||||
for range Only.Once {
|
||||
ep := sgd.SunGrow.GetEndpoint(endpoint)
|
||||
sgd.SunGrow.Error = ep.GetError()
|
||||
if sgd.SunGrow.Error != nil {
|
||||
break
|
||||
}
|
||||
response = sgd.GetByApi(ep, request)
|
||||
}
|
||||
return response
|
||||
func (sgd *SunGrowData) SetOutput(t string) {
|
||||
sgd.outputType.Set(t)
|
||||
}
|
||||
|
||||
func (sgd *SunGrowData) GetByApi(endpoint api.EndPoint, request SunGrowDataRequest) SunGrowDataResponse {
|
||||
var response SunGrowDataResponse
|
||||
// response.Table = output.NewTable()
|
||||
for range Only.Once {
|
||||
func (sgd *SunGrowData) SetOutputType(t output.OutputType) {
|
||||
sgd.outputType = t
|
||||
}
|
||||
|
||||
func (sgd *SunGrowData) SetSaveAsFile(yes bool) {
|
||||
sgd.saveAsFile = yes
|
||||
}
|
||||
|
||||
func (sgd *SunGrowData) SetEndpoints(endpoints ...string) {
|
||||
sgd.endPoints = endpoints
|
||||
}
|
||||
|
||||
func (sgd *SunGrowData) SetArgs(args ...string) {
|
||||
sgd.request.Set(args...)
|
||||
}
|
||||
|
||||
func (sgd *SunGrowData) SetPsIds(psids ...string) {
|
||||
for range Only.Once {
|
||||
if len(psids) == 0 {
|
||||
var pids valueTypes.PsIds
|
||||
pids, sgd.Error = sgd.sunGrow.GetPsIds()
|
||||
if sgd.Error != nil {
|
||||
break
|
||||
}
|
||||
sgd.request.SetPSIDs(pids.Strings())
|
||||
break
|
||||
}
|
||||
|
||||
sgd.request.SetPSIDs(psids)
|
||||
}
|
||||
}
|
||||
|
||||
func (sgd *SunGrowData) GetData() error {
|
||||
for range Only.Once {
|
||||
if len(sgd.endPoints) == 0 {
|
||||
sgd.Error = errors.New("need an endpoint")
|
||||
break
|
||||
}
|
||||
|
||||
for _, endpoint := range sgd.endPoints {
|
||||
// Lookup endpoint interface from string.
|
||||
ep := sgd.sunGrow.GetEndpoint(endpoint)
|
||||
sgd.sunGrow.Error = ep.GetError()
|
||||
if sgd.sunGrow.Error != nil {
|
||||
break
|
||||
}
|
||||
|
||||
sgd.request.SetRequired(ep.GetRequestArgNames())
|
||||
if sgd.request.IsNotRequired(NamePsId) {
|
||||
var result SunGrowDataResult
|
||||
|
||||
result.EndPointName = ep.GetName()
|
||||
result.EndPoint = ep
|
||||
result.Request = sgd.request
|
||||
result.Response = sgd.CallEndpoint(ep, result.Request)
|
||||
sgd.results[result.EndPointName.String()] = result
|
||||
break
|
||||
}
|
||||
|
||||
if len(sgd.request.aPsId) == 0 {
|
||||
sgd.SetPsIds()
|
||||
}
|
||||
for _, psId := range sgd.request.aPsId {
|
||||
var result SunGrowDataResult
|
||||
|
||||
result.Request = sgd.request
|
||||
if result.Request.IsRequired(NamePsId) {
|
||||
result.Request.SetPsId(psId.String())
|
||||
}
|
||||
if result.Request.IsRequired(NamePsIds) {
|
||||
result.Request.SetPsId(psId.String())
|
||||
}
|
||||
result.EndPointName = ep.GetName()
|
||||
result.EndPoint = ep
|
||||
result.Response = sgd.CallEndpoint(ep, result.Request)
|
||||
sgd.results[result.EndPointName.String()] = result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sgd.Error
|
||||
}
|
||||
|
||||
func (sgd *SunGrowData) GetOutput() error {
|
||||
for range Only.Once {
|
||||
if len(sgd.results) == 0 {
|
||||
fmt.Println("No results found.")
|
||||
break
|
||||
}
|
||||
for _, result := range sgd.results {
|
||||
sgd.Error = result.Response.GetOutput(sgd.sunGrow.OutputType, sgd.sunGrow.SaveAsFile)
|
||||
|
||||
// if result.Response.Data.Table.OutputType.IsTable() {
|
||||
// for _, t := range result.Response.Data.DataTables {
|
||||
// t.OutputType = sgd.sunGrow.OutputType
|
||||
// t.SetSaveFile(sgd.sunGrow.SaveAsFile)
|
||||
// sgd.Error = t.Output()
|
||||
// if sgd.Error != nil {
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// continue
|
||||
// }
|
||||
//
|
||||
// ok = true
|
||||
// sgd.Error = result.Response.Data.Table.Output()
|
||||
}
|
||||
}
|
||||
|
||||
return sgd.Error
|
||||
}
|
||||
|
||||
func (sgd *SunGrowData) GetResults() SunGrowDataResults {
|
||||
return sgd.results
|
||||
}
|
||||
|
||||
// func (sgd *SunGrowData) GetByEndPointName(endpoint string) SunGrowDataResponse {
|
||||
// var response SunGrowDataResponse
|
||||
// response.Data.Table = output.NewTable()
|
||||
// for range Only.Once {
|
||||
// ep := sgd.sunGrow.GetEndpoint(endpoint)
|
||||
// sgd.sunGrow.Error = ep.GetError()
|
||||
// if sgd.sunGrow.Error != nil {
|
||||
// break
|
||||
// }
|
||||
// response = sgd.GetEndpoint(ep)
|
||||
// }
|
||||
// return response
|
||||
// }
|
||||
|
||||
func (sgd *SunGrowData) CallEndpoint(endpoint api.EndPoint, request SunGrowDataRequest) SunGrowDataResponse {
|
||||
var response SunGrowDataResponse
|
||||
for range Only.Once {
|
||||
if !request.Validate(endpoint) {
|
||||
request.Help(endpoint)
|
||||
break
|
||||
@ -234,7 +299,7 @@ func (sgd *SunGrowData) GetByApi(endpoint api.EndPoint, request SunGrowDataReque
|
||||
var req []byte
|
||||
req, sgd.Error = json.Marshal(request)
|
||||
if sgd.Error != nil {
|
||||
fmt.Printf("GetByApi - ERR: %s\n", sgd.Error)
|
||||
fmt.Printf("GetEndpoint - ERR: %s\n", sgd.Error)
|
||||
break
|
||||
}
|
||||
// fmt.Printf("%s\n", req)
|
||||
@ -253,7 +318,7 @@ func (sgd *SunGrowData) GetByApi(endpoint api.EndPoint, request SunGrowDataReque
|
||||
sgd.Error = endpoint.GetError()
|
||||
if sgd.Error != nil {
|
||||
if strings.Contains(sgd.Error.Error(), "er_token_login_invalid") {
|
||||
sgd.SunGrow.Logout()
|
||||
sgd.sunGrow.Logout()
|
||||
break
|
||||
}
|
||||
fmt.Println(endpoint.Help())
|
||||
@ -271,11 +336,12 @@ func (sgd *SunGrowData) GetByApi(endpoint api.EndPoint, request SunGrowDataReque
|
||||
// endpoint.GetEndPointDataTables()
|
||||
// response.Table = endpoint.GetEndPointResultTable()
|
||||
// response.Table.SetTitle(response.Title)
|
||||
// response.Table.SetFilePrefix(response.Filename)
|
||||
// response.Data.Table.SetGraphFilter("")
|
||||
response.Data.Table.SetSaveFile(sgd.SunGrow.SaveAsFile)
|
||||
response.Data.Table.OutputType = sgd.SunGrow.OutputType
|
||||
response.Data.Table.SetFilePrefix(request.GetFilename(string(endpoint.GetName())))
|
||||
response.Data.Table.SetSaveFile(sgd.saveAsFile)
|
||||
response.Data.Table.OutputType = sgd.outputType
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
@ -312,8 +378,8 @@ func (sgd *SunGrowData) GetByApi(endpoint api.EndPoint, request SunGrowDataReque
|
||||
// response.Data.Table.SetTitle(response.Title)
|
||||
// response.Data.Table.SetFilePrefix(response.Filename)
|
||||
// response.Data.Table.SetGraphFilter("")
|
||||
// response.Data.Table.SetSaveFile(sgd.SunGrow.SaveAsFile)
|
||||
// response.Data.Table.OutputType = sgd.SunGrow.OutputType
|
||||
// response.Data.Table.SetSaveFile(sgd.sunGrow.SaveAsFile)
|
||||
// response.Data.Table.OutputType = sgd.sunGrow.OutputType
|
||||
// }
|
||||
// return response
|
||||
// }
|
||||
@ -340,7 +406,7 @@ func (sgd *SunGrowData) GetByApi(endpoint api.EndPoint, request SunGrowDataReque
|
||||
// break
|
||||
// }
|
||||
//
|
||||
// ok = sgd.SunGrow.RequestRequiresArgs(endpoint)
|
||||
// ok = sgd.sunGrow.RequestRequiresArgs(endpoint)
|
||||
// }
|
||||
// return yes
|
||||
// }
|
||||
@ -349,7 +415,7 @@ func (sgd *SunGrowData) GetByApi(endpoint api.EndPoint, request SunGrowDataReque
|
||||
// func (sgd *SunGrowData) energyTrend(request SunGrowDataRequest) SunGrowDataResponse {
|
||||
// var response SunGrowDataResponse
|
||||
// for range Only.Once {
|
||||
// ep := sgd.SunGrow.GetByStruct(
|
||||
// ep := sgd.sunGrow.GetByStruct(
|
||||
// "AppService.energyTrend",
|
||||
// // energyTrend.RequestData{ PsId: request.PsId },
|
||||
// energyTrend.RequestData{ },
|
||||
@ -372,7 +438,7 @@ func (sgd *SunGrowData) GetByApi(endpoint api.EndPoint, request SunGrowDataReque
|
||||
// func (sgd *SunGrowData) getAreaList(request SunGrowDataRequest) SunGrowDataResponse {
|
||||
// var response SunGrowDataResponse
|
||||
// for range Only.Once {
|
||||
// ep := sgd.SunGrow.GetByStruct(
|
||||
// ep := sgd.sunGrow.GetByStruct(
|
||||
// "AppService.getAreaList",
|
||||
// // energyTrend.RequestData{ PsId: request.PsId },
|
||||
// getAreaList.RequestData{ },
|
||||
@ -397,7 +463,7 @@ func (sgd *SunGrowData) GetByApi(endpoint api.EndPoint, request SunGrowDataReque
|
||||
// func (sgd *SunGrowData) getAllPsIdByOrgIds(request SunGrowDataRequest) SunGrowDataResponse {
|
||||
// var response SunGrowDataResponse
|
||||
// for range Only.Once {
|
||||
// ep := sgd.SunGrow.GetByStruct(
|
||||
// ep := sgd.sunGrow.GetByStruct(
|
||||
// "AppService.getAllPsIdByOrgIds",
|
||||
// // getAllPsIdByOrgIds.RequestData{ PsId: request.PsId },
|
||||
// getAllPsIdByOrgIds.RequestData{ OrgIds: valueTypes.SetStringValue("362245") },
|
||||
@ -421,7 +487,7 @@ func (sgd *SunGrowData) GetByApi(endpoint api.EndPoint, request SunGrowDataReque
|
||||
// func (sgd *SunGrowData) findCodeValueList(request SunGrowDataRequest) SunGrowDataResponse {
|
||||
// var response SunGrowDataResponse
|
||||
// for range Only.Once {
|
||||
// ep := sgd.SunGrow.GetByStruct(
|
||||
// ep := sgd.sunGrow.GetByStruct(
|
||||
// "AppService.findCodeValueList",
|
||||
// // findCodeValueList.RequestData{ PsId: request.PsId },
|
||||
// findCodeValueList.RequestData{ CodeType: *request.CodeType },
|
||||
@ -445,7 +511,7 @@ func (sgd *SunGrowData) GetByApi(endpoint api.EndPoint, request SunGrowDataReque
|
||||
// func (sgd *SunGrowData) queryFaultCodes(request SunGrowDataRequest) SunGrowDataResponse {
|
||||
// var response SunGrowDataResponse
|
||||
// for range Only.Once {
|
||||
// ep := sgd.SunGrow.GetByStruct(
|
||||
// ep := sgd.sunGrow.GetByStruct(
|
||||
// "WebAppService.queryFaultCodes",
|
||||
// // queryFaultCodes.RequestData{ PsId: request.PsId },
|
||||
// queryFaultCodes.RequestData{ FaultName: valueTypes.SetStringValue("417") },
|
||||
@ -468,7 +534,7 @@ func (sgd *SunGrowData) GetByApi(endpoint api.EndPoint, request SunGrowDataReque
|
||||
// func (sgd *SunGrowData) queryNounList(request SunGrowDataRequest) SunGrowDataResponse {
|
||||
// var response SunGrowDataResponse
|
||||
// for range Only.Once {
|
||||
// ep := sgd.SunGrow.GetByStruct(
|
||||
// ep := sgd.sunGrow.GetByStruct(
|
||||
// "WebAppService.queryNounList",
|
||||
// queryNounList.RequestData{ FaultTypeCode: valueTypes.SetStringValue("718") },
|
||||
// // queryNounList.RequestData{ },
|
||||
|
@ -2,7 +2,7 @@ package iSolarCloud
|
||||
|
||||
import (
|
||||
"GoSungrow/iSolarCloud/api"
|
||||
"GoSungrow/iSolarCloud/api/valueTypes"
|
||||
"GoSungrow/iSolarCloud/api/GoStruct/valueTypes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
@ -12,9 +12,17 @@ import (
|
||||
|
||||
// SunGrowDataRequest - Collection of all possible request args.
|
||||
type SunGrowDataRequest struct {
|
||||
args RequestArgs
|
||||
Required map[string]string
|
||||
aPsId valueTypes.PsIds
|
||||
}
|
||||
type SunGrowDataRequests map[string]SunGrowDataRequest
|
||||
|
||||
type RequestArgs struct {
|
||||
// Be careful with types. If you see a general "error' response,
|
||||
// then it's more likely a type mismatch.
|
||||
PsId *valueTypes.PsId `json:"ps_id,omitempty"`
|
||||
PsIds *valueTypes.PsIds `json:"psIds,omitempty"`
|
||||
ReportType *valueTypes.String `json:"report_type,omitempty"`
|
||||
DateId *valueTypes.DateTime `json:"date_id,omitempty"`
|
||||
DateType *string `json:"date_type,omitempty"`
|
||||
@ -81,12 +89,11 @@ type SunGrowDataRequest struct {
|
||||
// StartTimeStamp string `json:"start_time_stamp"`
|
||||
// Table string `json:"table"`
|
||||
// TaskId valueTypes.String `json:"task_id"`
|
||||
|
||||
aPsId valueTypes.PsIds
|
||||
}
|
||||
|
||||
const (
|
||||
NamePsId = "PsId"
|
||||
NamePsIds = "PsIds"
|
||||
NameReportType = "ReportType"
|
||||
NameDateId = "DateId"
|
||||
NameDateType = "DateType"
|
||||
@ -134,52 +141,53 @@ func (sgd SunGrowDataRequest) MarshalJSON() ([]byte, error) {
|
||||
|
||||
for range Only.Once {
|
||||
var dt *string
|
||||
if sgd.DateId != nil {
|
||||
dt = &sgd.DateId.DateType
|
||||
if sgd.args.DateId != nil {
|
||||
dt = &sgd.args.DateId.DateType
|
||||
}
|
||||
|
||||
type Parse SunGrowDataRequest
|
||||
type Parse RequestArgs
|
||||
// Store result from string
|
||||
data, err = json.Marshal(Parse {
|
||||
PsId: sgd.PsId,
|
||||
ReportType: sgd.ReportType,
|
||||
DateId: sgd.DateId,
|
||||
PsId: sgd.args.PsId,
|
||||
PsIds: sgd.args.PsIds,
|
||||
ReportType: sgd.args.ReportType,
|
||||
DateId: sgd.args.DateId,
|
||||
DateType: dt,
|
||||
FaultTypeCode: sgd.FaultTypeCode,
|
||||
Size: sgd.Size,
|
||||
CurPage: sgd.CurPage,
|
||||
DeviceType: sgd.DeviceType,
|
||||
ReportId: sgd.ReportId,
|
||||
CodeType: sgd.CodeType,
|
||||
OrgIds: sgd.OrgIds,
|
||||
PsIdList: sgd.PsIdList,
|
||||
Uuid: sgd.Uuid,
|
||||
TemplateId: sgd.TemplateId,
|
||||
DeviceModelId: sgd.DeviceModelId,
|
||||
PsKey: sgd.PsKey,
|
||||
FaultTypeCode: sgd.args.FaultTypeCode,
|
||||
Size: sgd.args.Size,
|
||||
CurPage: sgd.args.CurPage,
|
||||
DeviceType: sgd.args.DeviceType,
|
||||
ReportId: sgd.args.ReportId,
|
||||
CodeType: sgd.args.CodeType,
|
||||
OrgIds: sgd.args.OrgIds,
|
||||
PsIdList: sgd.args.PsIdList,
|
||||
Uuid: sgd.args.Uuid,
|
||||
TemplateId: sgd.args.TemplateId,
|
||||
DeviceModelId: sgd.args.DeviceModelId,
|
||||
PsKey: sgd.args.PsKey,
|
||||
|
||||
// UNVERIFIED
|
||||
AppKey: sgd.AppKey,
|
||||
BeginTime: sgd.BeginTime,
|
||||
DealerOrgCode: sgd.DealerOrgCode,
|
||||
DeviceSn: sgd.DeviceSn,
|
||||
EndTimeStamp: sgd.EndTimeStamp,
|
||||
FaultCode: sgd.FaultCode,
|
||||
FaultName: sgd.FaultName,
|
||||
Id: sgd.Id,
|
||||
MinuteInterval: sgd.MinuteInterval,
|
||||
OrderId: sgd.OrderId,
|
||||
OrgId: sgd.OrgId,
|
||||
PointId: sgd.PointId,
|
||||
Points: sgd.Points,
|
||||
Prefix: sgd.Prefix,
|
||||
PrimaryKey: sgd.PrimaryKey,
|
||||
PsKeyList: sgd.PsKeyList,
|
||||
QueryType: sgd.QueryType,
|
||||
Sn: sgd.Sn,
|
||||
StartTimeStamp: sgd.StartTimeStamp,
|
||||
Table: sgd.Table,
|
||||
TaskId: sgd.TaskId,
|
||||
AppKey: sgd.args.AppKey,
|
||||
BeginTime: sgd.args.BeginTime,
|
||||
DealerOrgCode: sgd.args.DealerOrgCode,
|
||||
DeviceSn: sgd.args.DeviceSn,
|
||||
EndTimeStamp: sgd.args.EndTimeStamp,
|
||||
FaultCode: sgd.args.FaultCode,
|
||||
FaultName: sgd.args.FaultName,
|
||||
Id: sgd.args.Id,
|
||||
MinuteInterval: sgd.args.MinuteInterval,
|
||||
OrderId: sgd.args.OrderId,
|
||||
OrgId: sgd.args.OrgId,
|
||||
PointId: sgd.args.PointId,
|
||||
Points: sgd.args.Points,
|
||||
Prefix: sgd.args.Prefix,
|
||||
PrimaryKey: sgd.args.PrimaryKey,
|
||||
PsKeyList: sgd.args.PsKeyList,
|
||||
QueryType: sgd.args.QueryType,
|
||||
Sn: sgd.args.Sn,
|
||||
StartTimeStamp: sgd.args.StartTimeStamp,
|
||||
Table: sgd.args.Table,
|
||||
TaskId: sgd.args.TaskId,
|
||||
})
|
||||
if err == nil {
|
||||
break
|
||||
@ -189,8 +197,7 @@ func (sgd SunGrowDataRequest) MarshalJSON() ([]byte, error) {
|
||||
return data, err
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) Set(args ...string) SunGrowDataRequest {
|
||||
var request SunGrowDataRequest
|
||||
func (sgd *SunGrowDataRequest) Set(args ...string) {
|
||||
for range Only.Once {
|
||||
for _, arg := range args {
|
||||
a := strings.Split(arg, ":")
|
||||
@ -203,85 +210,86 @@ func (sgd *SunGrowDataRequest) Set(args ...string) SunGrowDataRequest {
|
||||
}
|
||||
|
||||
switch a[0] {
|
||||
case NamePsId:
|
||||
request.aPsId = valueTypes.SetPsIdStrings(SplitArg(a[1])) // strings.Split(a[1], ","))
|
||||
case NameReportType:
|
||||
val := valueTypes.SetStringValue(a[1]); request.ReportType = &val
|
||||
case NameDateId:
|
||||
val := valueTypes.SetDateTimeString(a[1]); request.DateId = &val
|
||||
case NameFaultTypeCode:
|
||||
val := valueTypes.SetIntegerString(a[1]); request.FaultTypeCode = &val
|
||||
case NameSize:
|
||||
val := valueTypes.SetIntegerString(a[1]); request.Size = &val
|
||||
case NameCurPage:
|
||||
val := valueTypes.SetIntegerString(a[1]); request.CurPage = &val
|
||||
case NameDeviceType:
|
||||
val := valueTypes.SetStringValue(a[1]); request.DeviceType = &val
|
||||
case NameReportId:
|
||||
val := valueTypes.SetStringValue(a[1]); request.ReportId = &val
|
||||
case NameCodeType:
|
||||
val := valueTypes.SetStringValue(a[1]); request.CodeType = &val
|
||||
case NameOrgIds:
|
||||
val := valueTypes.SetStringValue(a[1]); request.OrgIds = &val
|
||||
case NamePsIdList:
|
||||
val := valueTypes.SetStringValue(a[1]); request.PsIdList = &val
|
||||
case NameUuid:
|
||||
val := valueTypes.SetStringValue(a[1]); request.Uuid = &val
|
||||
case NameTemplateId:
|
||||
val := valueTypes.SetStringValue(a[1]); request.TemplateId = &val
|
||||
case NameDeviceModelId:
|
||||
val := valueTypes.SetStringValue(a[1]); request.DeviceModelId = &val
|
||||
case NamePsKey:
|
||||
val := valueTypes.SetPsKeyValue(a[1]); request.PsKey = &val
|
||||
case NamePsId:
|
||||
sgd.aPsId = valueTypes.SetPsIdStrings(SplitArg(a[1])) // strings.Split(a[1], ","))
|
||||
// case NamePsIds:
|
||||
// sgd.aPsId = valueTypes.SetPsIdStrings(SplitArg(a[1])) // strings.Split(a[1], ","))
|
||||
case NameReportType:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.ReportType = &val
|
||||
case NameDateId:
|
||||
val := valueTypes.SetDateTimeString(a[1]); sgd.args.DateId = &val
|
||||
case NameFaultTypeCode:
|
||||
val := valueTypes.SetIntegerString(a[1]); sgd.args.FaultTypeCode = &val
|
||||
case NameSize:
|
||||
val := valueTypes.SetIntegerString(a[1]); sgd.args.Size = &val
|
||||
case NameCurPage:
|
||||
val := valueTypes.SetIntegerString(a[1]); sgd.args.CurPage = &val
|
||||
case NameDeviceType:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.DeviceType = &val
|
||||
case NameReportId:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.ReportId = &val
|
||||
case NameCodeType:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.CodeType = &val
|
||||
case NameOrgIds:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.OrgIds = &val
|
||||
case NamePsIdList:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.PsIdList = &val
|
||||
case NameUuid:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.Uuid = &val
|
||||
case NameTemplateId:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.TemplateId = &val
|
||||
case NameDeviceModelId:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.DeviceModelId = &val
|
||||
case NamePsKey:
|
||||
val := valueTypes.SetPsKeyValue(a[1]); sgd.args.PsKey = &val
|
||||
|
||||
|
||||
// UNVERIFIED
|
||||
case NameAppKey:
|
||||
val := valueTypes.SetStringValue(a[1]); request.AppKey = &val
|
||||
case NameBeginTime:
|
||||
val := valueTypes.SetDateTimeString(a[1]); request.BeginTime = &val
|
||||
case NameDealerOrgCode:
|
||||
val := valueTypes.SetStringValue(a[1]); request.DealerOrgCode = &val
|
||||
case NameDeviceSn:
|
||||
val := valueTypes.SetStringValue(a[1]); request.DeviceSn = &val
|
||||
case NameEndTimeStamp:
|
||||
val := valueTypes.SetDateTimeString(a[1]); request.EndTimeStamp = &val
|
||||
case NameFaultCode:
|
||||
val := valueTypes.SetIntegerString(a[1]); request.FaultCode = &val
|
||||
case NameFaultName:
|
||||
val := valueTypes.SetStringValue(a[1]); request.FaultName = &val
|
||||
case NameId:
|
||||
val := valueTypes.SetIntegerString(a[1]); request.Id = &val
|
||||
case NameMinuteInterval:
|
||||
val := valueTypes.SetIntegerString(a[1]); request.MinuteInterval = &val
|
||||
case NameOrderId:
|
||||
val := valueTypes.SetStringValue(a[1]); request.OrderId = &val
|
||||
case NameOrgId:
|
||||
val := valueTypes.SetStringValue(a[1]); request.OrgId = &val
|
||||
case NamePointId:
|
||||
val := valueTypes.SetPointIdString(a[1]); request.PointId = &val
|
||||
case NamePoints:
|
||||
val := valueTypes.SetIntegerString(a[1]); request.Points = &val
|
||||
case NamePrefix:
|
||||
val := valueTypes.SetStringValue(a[1]); request.Prefix = &val
|
||||
case NamePrimaryKey:
|
||||
val := valueTypes.SetStringValue(a[1]); request.PrimaryKey = &val
|
||||
case NamePsKeyList:
|
||||
val := valueTypes.SetStringValue(a[1]); request.PsKeyList = &val
|
||||
case NameQueryType:
|
||||
val := valueTypes.SetStringValue(a[1]); request.QueryType = &val
|
||||
case NameSn:
|
||||
val := valueTypes.SetStringValue(a[1]); request.Sn = &val
|
||||
case NameStartTimeStamp:
|
||||
val := valueTypes.SetDateTimeString(a[1]); request.StartTimeStamp = &val
|
||||
case NameTable:
|
||||
val := valueTypes.SetStringValue(a[1]); request.Table = &val
|
||||
case NameTaskId:
|
||||
val := valueTypes.SetStringValue(a[1]); request.TaskId = &val
|
||||
// UNVERIFIED
|
||||
case NameAppKey:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.AppKey = &val
|
||||
case NameBeginTime:
|
||||
val := valueTypes.SetDateTimeString(a[1]); sgd.args.BeginTime = &val
|
||||
case NameDealerOrgCode:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.DealerOrgCode = &val
|
||||
case NameDeviceSn:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.DeviceSn = &val
|
||||
case NameEndTimeStamp:
|
||||
val := valueTypes.SetDateTimeString(a[1]); sgd.args.EndTimeStamp = &val
|
||||
case NameFaultCode:
|
||||
val := valueTypes.SetIntegerString(a[1]); sgd.args.FaultCode = &val
|
||||
case NameFaultName:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.FaultName = &val
|
||||
case NameId:
|
||||
val := valueTypes.SetIntegerString(a[1]); sgd.args.Id = &val
|
||||
case NameMinuteInterval:
|
||||
val := valueTypes.SetIntegerString(a[1]); sgd.args.MinuteInterval = &val
|
||||
case NameOrderId:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.OrderId = &val
|
||||
case NameOrgId:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.OrgId = &val
|
||||
case NamePointId:
|
||||
val := valueTypes.SetPointIdString(a[1]); sgd.args.PointId = &val
|
||||
case NamePoints:
|
||||
val := valueTypes.SetIntegerString(a[1]); sgd.args.Points = &val
|
||||
case NamePrefix:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.Prefix = &val
|
||||
case NamePrimaryKey:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.PrimaryKey = &val
|
||||
case NamePsKeyList:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.PsKeyList = &val
|
||||
case NameQueryType:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.QueryType = &val
|
||||
case NameSn:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.Sn = &val
|
||||
case NameStartTimeStamp:
|
||||
val := valueTypes.SetDateTimeString(a[1]); sgd.args.StartTimeStamp = &val
|
||||
case NameTable:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.Table = &val
|
||||
case NameTaskId:
|
||||
val := valueTypes.SetStringValue(a[1]); sgd.args.TaskId = &val
|
||||
}
|
||||
}
|
||||
}
|
||||
return request
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) Validate(endpoint api.EndPoint) bool {
|
||||
@ -296,80 +304,82 @@ func (sgd *SunGrowDataRequest) Validate(endpoint api.EndPoint) bool {
|
||||
}
|
||||
switch key {
|
||||
case NamePsId:
|
||||
// if sgd.PsId == nil { fmt.Printf(msg); ok = false }
|
||||
// if sgd.args.PsId == nil { fmt.Printf(msg); ok = false }
|
||||
case NamePsIds:
|
||||
// if sgd.args.PsIds == nil { fmt.Printf(msg); ok = false }
|
||||
case NameReportType:
|
||||
if sgd.ReportType == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.ReportType == nil { fmt.Printf(msg); ok = false }
|
||||
case NameDateId:
|
||||
if sgd.DateId == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.DateId == nil { fmt.Printf(msg); ok = false }
|
||||
case NameFaultTypeCode:
|
||||
if sgd.FaultTypeCode == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.FaultTypeCode == nil { fmt.Printf(msg); ok = false }
|
||||
case NameSize:
|
||||
if sgd.Size == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.Size == nil { fmt.Printf(msg); ok = false }
|
||||
case NameCurPage:
|
||||
if sgd.CurPage == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.CurPage == nil { fmt.Printf(msg); ok = false }
|
||||
case NameDeviceType:
|
||||
if sgd.DeviceType == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.DeviceType == nil { fmt.Printf(msg); ok = false }
|
||||
case NameReportId:
|
||||
if sgd.ReportId == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.ReportId == nil { fmt.Printf(msg); ok = false }
|
||||
case NameCodeType:
|
||||
if sgd.CodeType == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.CodeType == nil { fmt.Printf(msg); ok = false }
|
||||
case NameOrgIds:
|
||||
if sgd.OrgIds == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.OrgIds == nil { fmt.Printf(msg); ok = false }
|
||||
case NamePsIdList:
|
||||
if sgd.PsIdList == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.PsIdList == nil { fmt.Printf(msg); ok = false }
|
||||
case NameUuid:
|
||||
if sgd.Uuid == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.Uuid == nil { fmt.Printf(msg); ok = false }
|
||||
case NameTemplateId:
|
||||
if sgd.TemplateId == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.TemplateId == nil { fmt.Printf(msg); ok = false }
|
||||
case NameDeviceModelId:
|
||||
if sgd.DeviceModelId == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.DeviceModelId == nil { fmt.Printf(msg); ok = false }
|
||||
case NamePsKey:
|
||||
if sgd.PsKey == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.PsKey == nil { fmt.Printf(msg); ok = false }
|
||||
|
||||
|
||||
// UNVERIFIED
|
||||
case NameAppKey:
|
||||
if sgd.AppKey == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.AppKey == nil { fmt.Printf(msg); ok = false }
|
||||
case NameBeginTime:
|
||||
if sgd.BeginTime == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.BeginTime == nil { fmt.Printf(msg); ok = false }
|
||||
case NameDealerOrgCode:
|
||||
if sgd.DealerOrgCode == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.DealerOrgCode == nil { fmt.Printf(msg); ok = false }
|
||||
case NameDeviceSn:
|
||||
if sgd.DeviceSn == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.DeviceSn == nil { fmt.Printf(msg); ok = false }
|
||||
case NameEndTimeStamp:
|
||||
if sgd.EndTimeStamp == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.EndTimeStamp == nil { fmt.Printf(msg); ok = false }
|
||||
case NameFaultCode:
|
||||
if sgd.FaultCode == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.FaultCode == nil { fmt.Printf(msg); ok = false }
|
||||
case NameFaultName:
|
||||
if sgd.FaultName == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.FaultName == nil { fmt.Printf(msg); ok = false }
|
||||
case NameId:
|
||||
if sgd.Id == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.Id == nil { fmt.Printf(msg); ok = false }
|
||||
case NameMinuteInterval:
|
||||
if sgd.MinuteInterval == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.MinuteInterval == nil { fmt.Printf(msg); ok = false }
|
||||
case NameOrderId:
|
||||
if sgd.OrderId == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.OrderId == nil { fmt.Printf(msg); ok = false }
|
||||
case NameOrgId:
|
||||
if sgd.OrgId == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.OrgId == nil { fmt.Printf(msg); ok = false }
|
||||
case NamePointId:
|
||||
if sgd.PointId == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.PointId == nil { fmt.Printf(msg); ok = false }
|
||||
case NamePoints:
|
||||
if sgd.Points == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.Points == nil { fmt.Printf(msg); ok = false }
|
||||
case NamePrefix:
|
||||
if sgd.Prefix == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.Prefix == nil { fmt.Printf(msg); ok = false }
|
||||
case NamePrimaryKey:
|
||||
if sgd.PrimaryKey == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.PrimaryKey == nil { fmt.Printf(msg); ok = false }
|
||||
case NamePsKeyList:
|
||||
if sgd.PsKeyList == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.PsKeyList == nil { fmt.Printf(msg); ok = false }
|
||||
case NameQueryType:
|
||||
if sgd.QueryType == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.QueryType == nil { fmt.Printf(msg); ok = false }
|
||||
case NameSn:
|
||||
if sgd.Sn == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.Sn == nil { fmt.Printf(msg); ok = false }
|
||||
case NameStartTimeStamp:
|
||||
if sgd.StartTimeStamp == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.StartTimeStamp == nil { fmt.Printf(msg); ok = false }
|
||||
case NameTable:
|
||||
if sgd.Table == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.Table == nil { fmt.Printf(msg); ok = false }
|
||||
case NameTaskId:
|
||||
if sgd.TaskId == nil { fmt.Printf(msg); ok = false }
|
||||
if sgd.args.TaskId == nil { fmt.Printf(msg); ok = false }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -383,6 +393,9 @@ func (sgd *SunGrowDataRequest) Help(endpoint api.EndPoint) {
|
||||
if key == NamePsId {
|
||||
continue
|
||||
}
|
||||
if key == NamePsIds {
|
||||
continue
|
||||
}
|
||||
|
||||
if key == NameDateType {
|
||||
continue
|
||||
@ -402,28 +415,28 @@ func (sgd *SunGrowDataRequest) GetFilename(prefix string) string {
|
||||
var ret string
|
||||
for range Only.Once {
|
||||
// aret := []string{ prefix }
|
||||
// if sgd.PsId != nil {
|
||||
// a := sgd.PsId.String()
|
||||
// if sgd.args.PsId != nil {
|
||||
// a := sgd.args.PsId.String()
|
||||
// if a != "" { aret = append(aret, a) }
|
||||
// }
|
||||
//
|
||||
// if sgd.DateId != nil {
|
||||
// a := sgd.DateId.Original()
|
||||
// if sgd.args.DateId != nil {
|
||||
// a := sgd.args.DateId.Original()
|
||||
// if a != "" { aret = append(aret, a) }
|
||||
// }
|
||||
//
|
||||
// if sgd.ReportType != nil {
|
||||
// a := sgd.ReportType.String()
|
||||
// if sgd.args.ReportType != nil {
|
||||
// a := sgd.args.ReportType.String()
|
||||
// if a != "" { aret = append(aret, a) }
|
||||
// }
|
||||
//
|
||||
// if sgd.FaultTypeCode != nil {
|
||||
// a := sgd.FaultTypeCode.String()
|
||||
// if sgd.args.FaultTypeCode != nil {
|
||||
// a := sgd.args.FaultTypeCode.String()
|
||||
// if a != "" { aret = append(aret, a) }
|
||||
// }
|
||||
//
|
||||
// if sgd.Uuid != nil {
|
||||
// a := sgd.Uuid.String()
|
||||
// if sgd.args.Uuid != nil {
|
||||
// a := sgd.args.Uuid.String()
|
||||
// if a != "" { aret = append(aret, a) }
|
||||
// }
|
||||
|
||||
@ -443,37 +456,74 @@ func (sgd *SunGrowDataRequest) GetFilename(prefix string) string {
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) SetDate(date string) {
|
||||
did := valueTypes.SetDateTimeString(date)
|
||||
sgd.DateId = &did
|
||||
if sgd.DateId.IsZero() {
|
||||
did = valueTypes.NewDateTime(valueTypes.Now)
|
||||
sgd.DateId = &did
|
||||
for range Only.Once {
|
||||
if sgd.IsNotRequired(NameDateId) {
|
||||
break
|
||||
}
|
||||
did := valueTypes.SetDateTimeString(date)
|
||||
sgd.args.DateId = &did
|
||||
if sgd.args.DateId.IsZero() {
|
||||
did = valueTypes.NewDateTime(valueTypes.Now)
|
||||
sgd.args.DateId = &did
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) SetFaultTypeCode(ftc string) {
|
||||
aftc := valueTypes.SetIntegerString(ftc)
|
||||
sgd.FaultTypeCode = &aftc
|
||||
for range Only.Once {
|
||||
if sgd.IsNotRequired(NameFaultTypeCode) {
|
||||
break
|
||||
}
|
||||
aftc := valueTypes.SetIntegerString(ftc)
|
||||
sgd.args.FaultTypeCode = &aftc
|
||||
}
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) SetReportType(rt string) {
|
||||
art := valueTypes.SetStringValue(rt)
|
||||
sgd.ReportType = &art
|
||||
for range Only.Once {
|
||||
if sgd.IsNotRequired(NameReportType) {
|
||||
break
|
||||
}
|
||||
art := valueTypes.SetStringValue(rt)
|
||||
sgd.args.ReportType = &art
|
||||
}
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) SetPsIds(psIds []string) {
|
||||
func (sgd *SunGrowDataRequest) SetPSIDs(psIds []string) {
|
||||
sgd.aPsId = valueTypes.SetPsIdStrings(psIds)
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) GetPsIds() valueTypes.PsIds {
|
||||
func (sgd *SunGrowDataRequest) GetPSIDs() valueTypes.PsIds {
|
||||
return sgd.aPsId
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) SetPsId(psId string) {
|
||||
if psId == "" {
|
||||
sgd.PsId = nil
|
||||
return
|
||||
}
|
||||
pid := valueTypes.SetPsIdString(psId)
|
||||
sgd.PsId = &pid
|
||||
func (sgd *SunGrowDataRequest) SetRequired(req map[string]string) {
|
||||
sgd.Required = req
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) SetPsId(psId string) {
|
||||
for range Only.Once {
|
||||
if sgd.IsNotRequired(NamePsId) {
|
||||
break
|
||||
}
|
||||
if psId == "" {
|
||||
sgd.args.PsId = nil
|
||||
break
|
||||
}
|
||||
|
||||
pid := valueTypes.SetPsIdString(psId)
|
||||
sgd.args.PsId = &pid
|
||||
}
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) IsRequired(req string) bool {
|
||||
var yes bool
|
||||
if _, ok := sgd.Required[req]; ok {
|
||||
yes = true
|
||||
}
|
||||
return yes
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) IsNotRequired(req string) bool {
|
||||
return !sgd.IsRequired(req)
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
package iSolarCloud
|
||||
|
||||
import (
|
||||
"GoSungrow/Only"
|
||||
)
|
||||
|
||||
|
||||
func fillArray(count int, args []string) []string {
|
||||
var ret []string
|
||||
for range Only.Once {
|
||||
if count < len(args) {
|
||||
count = len(args)
|
||||
}
|
||||
ret = make([]string, count)
|
||||
for i, e := range args {
|
||||
ret[i] = e
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
@ -19,8 +19,8 @@ import (
|
||||
"GoSungrow/iSolarCloud/WebAppService/getMqttConfigInfoByAppkey"
|
||||
"GoSungrow/iSolarCloud/WebAppService/queryUserCurveTemplateData"
|
||||
"GoSungrow/iSolarCloud/api"
|
||||
"GoSungrow/iSolarCloud/api/output"
|
||||
"GoSungrow/iSolarCloud/api/valueTypes"
|
||||
"GoSungrow/iSolarCloud/api/GoStruct/output"
|
||||
"GoSungrow/iSolarCloud/api/GoStruct/valueTypes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
@ -142,21 +142,23 @@ func (sg *SunGrow) GetTemplatePoints(template string) error {
|
||||
template = "8042"
|
||||
}
|
||||
|
||||
table := output.NewTable()
|
||||
sg.Error = table.SetHeader(
|
||||
table := output.NewTable(
|
||||
"PointStruct Id",
|
||||
"Description",
|
||||
"Unit",
|
||||
)
|
||||
)
|
||||
// sg.Error = table.SetHeader(
|
||||
// "PointStruct Id",
|
||||
// "Description",
|
||||
// "Unit",
|
||||
// )
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
|
||||
ss := sg.GetPointNamesFromTemplate(template)
|
||||
for _, s := range ss {
|
||||
sg.Error = table.AddRow(
|
||||
// api.NameDevicePoint(s.PsKey, s.PointId),
|
||||
s.PsKey + "." + s.PointId.String(),
|
||||
sg.Error = table.AddRow(s.PsKey + "." + s.PointId.String(),
|
||||
s.Name,
|
||||
s.Unit,
|
||||
)
|
||||
@ -491,36 +493,20 @@ func (sg *SunGrow) GetRealTimeData(psKey string) error {
|
||||
return sg.Error
|
||||
}
|
||||
|
||||
func (sg *SunGrow) CmdDataPsDetail(psIds ...valueTypes.PsId) error {
|
||||
func (sg *SunGrow) CmdDataPsDetail(psIds ...string) error {
|
||||
for range Only.Once {
|
||||
if len(psIds) == 0 {
|
||||
psIds, sg.Error = sg.GetPsIds()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
data := sg.NewSunGrowData()
|
||||
data.SetPsIds(psIds...)
|
||||
data.SetEndpoints("getPsDetail", "getPsDetailWithPsType")
|
||||
|
||||
sg.Error = data.GetData()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
|
||||
var data SunGrowData
|
||||
data.New(sg)
|
||||
|
||||
for _, psId := range psIds {
|
||||
response := data.GetByEndPointName("getPsDetail", SunGrowDataRequest{PsId: &psId})
|
||||
if response.Error != nil {
|
||||
break
|
||||
}
|
||||
sg.Error = response.Data.Table.Output()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
|
||||
response = data.GetByEndPointName("getPsDetailWithPsType", SunGrowDataRequest{PsId: &psId})
|
||||
if response.Error != nil {
|
||||
break
|
||||
}
|
||||
sg.Error = response.Data.Table.Output()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
sg.Error = data.GetOutput()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@ -587,9 +573,7 @@ func (sg *SunGrow) GetPointData(date string, pointNames api.TemplatePoints, psId
|
||||
|
||||
func (sg *SunGrow) SearchPointNames(pns ...string) error {
|
||||
for range Only.Once {
|
||||
table := output.NewTable()
|
||||
|
||||
_ = table.SetHeader(
|
||||
table := output.NewTable(
|
||||
"DeviceType",
|
||||
"Id",
|
||||
"Period",
|
||||
@ -599,6 +583,16 @@ func (sg *SunGrow) SearchPointNames(pns ...string) error {
|
||||
"Translation Id",
|
||||
)
|
||||
|
||||
// _ = table.SetHeader(
|
||||
// "DeviceType",
|
||||
// "Id",
|
||||
// "Period",
|
||||
// "Point Id",
|
||||
// "Point Name",
|
||||
// "Show Point Name",
|
||||
// "Translation Id",
|
||||
// )
|
||||
|
||||
if len(pns) == 0 {
|
||||
fmt.Println("Searching up to id 1000 within getPowerDevicePointInfo")
|
||||
for pni := 0; pni < 1000; pni++ {
|
||||
@ -658,41 +652,48 @@ func (sg *SunGrow) SearchPointNames(pns ...string) error {
|
||||
return sg.Error
|
||||
}
|
||||
|
||||
func (sg *SunGrow) GetDeviceList(psIds ...valueTypes.PsId) error {
|
||||
func (sg *SunGrow) GetDeviceList(psIds ...string) error {
|
||||
for range Only.Once {
|
||||
if len(psIds) == 0 {
|
||||
psIds, sg.Error = sg.GetPsIds()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
data := sg.NewSunGrowData()
|
||||
data.SetPsIds(psIds...)
|
||||
data.SetEndpoints("getDeviceList")
|
||||
|
||||
var ret getDeviceList.Devices
|
||||
for _, psId := range psIds {
|
||||
ep := sg.GetByStruct(
|
||||
"AppService.getDeviceList",
|
||||
// getDeviceList.RequestData{PsId: strconv.FormatInt(psId, 10)},
|
||||
getDeviceList.RequestData{PsId: psId},
|
||||
DefaultCacheTimeout,
|
||||
)
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
|
||||
data := getDeviceList.Assert(ep)
|
||||
ret = append(ret, data.GetDevices()...)
|
||||
}
|
||||
|
||||
table := getDeviceList.GetDevicesTable(ret)
|
||||
table.SetTitle("All Devices")
|
||||
table.SetFilePrefix("")
|
||||
table.SetGraphFilter("")
|
||||
table.SetSaveFile(sg.SaveAsFile)
|
||||
table.OutputType = sg.OutputType
|
||||
sg.Error = table.Output()
|
||||
sg.Error = data.GetData()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
|
||||
sg.Error = data.GetOutput()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
|
||||
// var ret getDeviceList.Devices
|
||||
// for _, psId := range psIds {
|
||||
// ep := sg.GetByStruct(
|
||||
// "AppService.getDeviceList",
|
||||
// // getDeviceList.RequestData{PsId: strconv.FormatInt(psId, 10)},
|
||||
// getDeviceList.RequestData{PsId: psId},
|
||||
// DefaultCacheTimeout,
|
||||
// )
|
||||
// if sg.Error != nil {
|
||||
// break
|
||||
// }
|
||||
//
|
||||
// data := getDeviceList.Assert(ep)
|
||||
// ret = append(ret, data.GetDevices()...)
|
||||
// }
|
||||
//
|
||||
// table := getDeviceList.GetDevicesTable(ret)
|
||||
// table.SetTitle("All Devices")
|
||||
// table.SetFilePrefix("")
|
||||
// table.SetGraphFilter("")
|
||||
// table.SetSaveFile(sg.SaveAsFile)
|
||||
// table.OutputType = sg.OutputType
|
||||
// sg.Error = table.Output()
|
||||
// if sg.Error != nil {
|
||||
// break
|
||||
// }
|
||||
}
|
||||
|
||||
return sg.Error
|
||||
|
@ -1 +0,0 @@
|
||||
package iSolarCloud
|
@ -11,7 +11,7 @@ import (
|
||||
"GoSungrow/iSolarCloud/WebAppService"
|
||||
"GoSungrow/iSolarCloud/WebIscmAppService"
|
||||
"GoSungrow/iSolarCloud/api"
|
||||
"GoSungrow/iSolarCloud/api/output"
|
||||
"GoSungrow/iSolarCloud/api/GoStruct/output"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
@ -19,6 +19,10 @@ import (
|
||||
)
|
||||
|
||||
|
||||
const (
|
||||
DefaultCacheTimeout = time.Minute * 5
|
||||
)
|
||||
|
||||
type SunGrow struct {
|
||||
ApiRoot api.Web
|
||||
Auth login.EndPoint
|
||||
|
@ -1,2 +0,0 @@
|
||||
package iSolarCloud
|
||||
|
Loading…
x
Reference in New Issue
Block a user