mirror of
https://github.com/MickMake/GoSungrow.git
synced 2025-04-11 21:29:19 +02:00
v2.3.2 - Refactor #2
This commit is contained in:
parent
19351d5f16
commit
671138274e
1317
.idea/workspace.xml
generated
1317
.idea/workspace.xml
generated
File diff suppressed because it is too large
Load Diff
@ -3,9 +3,7 @@ package cmd
|
||||
import (
|
||||
"GoSungrow/Only"
|
||||
"GoSungrow/iSolarCloud/api/output"
|
||||
"GoSungrow/iSolarCloud/api/valueTypes"
|
||||
"fmt"
|
||||
"github.com/MickMake/GoUnify/cmdConfig"
|
||||
"github.com/MickMake/GoUnify/cmdHelp"
|
||||
"github.com/spf13/cobra"
|
||||
"strings"
|
||||
@ -222,41 +220,17 @@ const (
|
||||
func (c *CmdData) GetEndpoints(cmd *cobra.Command, args []string) error {
|
||||
// endpoints string, psIds string, date string
|
||||
for range Only.Once {
|
||||
cmds.Api.SunGrow.SetOutputType(cmd.Use)
|
||||
args = cmdConfig.FillArray(5, args)
|
||||
cmds.Api.SunGrow.SetOutputType(cmd.Name())
|
||||
|
||||
for i := range args {
|
||||
if args[i] == "." {
|
||||
args[i] = ""
|
||||
}
|
||||
}
|
||||
|
||||
var e []string
|
||||
if args[argEndpoints] != "" {
|
||||
e = SplitArg(args[argEndpoints])
|
||||
}
|
||||
|
||||
var p []valueTypes.Integer
|
||||
for _, psId := range SplitArg(args[argPsIds]) {
|
||||
if psId == "" {
|
||||
continue
|
||||
}
|
||||
p = append(p, valueTypes.SetIntegerString(psId))
|
||||
}
|
||||
|
||||
d := valueTypes.SetDateTimeString(args[argDate])
|
||||
|
||||
rt := args[argReportType]
|
||||
if rt == "" {
|
||||
rt = "1"
|
||||
}
|
||||
|
||||
ftc := args[argFaultTypeCode]
|
||||
// if ftc == "" {
|
||||
// ftc = "1"
|
||||
// args = cmdConfig.FillArray(5, args)
|
||||
// for i := range args {
|
||||
// if args[i] == "." {
|
||||
// args[i] = ""
|
||||
// }
|
||||
// }
|
||||
// c.Error = cmds.Api.SunGrow.GetEndpoints(SplitArg(args[argEndpoints]), SplitArg(args[argPsIds]), args[argDate], args[argReportType], args[argFaultTypeCode])
|
||||
|
||||
c.Error = cmds.Api.SunGrow.GetEndpoints(e, p, *d, rt, ftc)
|
||||
c.Error = cmds.Api.SunGrow.GetEndpoints(SplitArg(args[argEndpoints]), args[1:]...)
|
||||
}
|
||||
|
||||
return c.Error
|
||||
|
@ -353,7 +353,7 @@ func (ca *Cmds) MqttCron() error {
|
||||
}
|
||||
|
||||
for _, endpoint := range All {
|
||||
response := data.GetByApi(endpoint, iSolarCloud.SunGrowDataRequest{ PsId: psId })
|
||||
response := data.GetByEndPointName(endpoint, iSolarCloud.SunGrowDataRequest{ PsId: &psId })
|
||||
ca.Error = ca.Update(endpoint, response.Data, newDay)
|
||||
if ca.Error != nil {
|
||||
break
|
||||
|
@ -12,7 +12,7 @@ const Url = "/v1/commonService/findCodeValueList"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
CodeType string `json:"code_type" required:"true"`
|
||||
CodeType valueTypes.String `json:"code_type" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
|
@ -12,7 +12,7 @@ const Url = "/v1/powerStationService/findPsType"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -46,12 +46,8 @@ func (e *EndPoint) GetData() api.DataMap {
|
||||
for range Only.Once {
|
||||
pkg := apiReflect.GetName("", *e)
|
||||
dt := valueTypes.NewDateTime(valueTypes.Now)
|
||||
entries.StructToPoints(e.Response.ResultData, pkg, e.Request.PsId.String(), dt)
|
||||
|
||||
// for _, d := range e.Response.ResultData {
|
||||
// name := fmt.Sprintf("%s.%s", pkg, e.Request.PsId.String())
|
||||
// entries.StructToPoints(d, name, e.Request.PsId.String(), dt)
|
||||
// }
|
||||
name := pkg + "." + e.Request.PsId.String()
|
||||
entries.StructToPoints(e.Response.ResultData, name, e.Request.PsId.String(), dt)
|
||||
}
|
||||
|
||||
return entries
|
||||
|
@ -13,7 +13,7 @@ const Url = "/v1/devService/getAllDeviceByPsId"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
|
@ -25,7 +25,7 @@ func (rd RequestData) Help() string {
|
||||
|
||||
type ResultData []struct {
|
||||
Remark string `json:"remark"`
|
||||
SetID valueTypes.Integer `json:"set_id"`
|
||||
SetId valueTypes.Integer `json:"set_id"`
|
||||
SetName string `json:"set_name"`
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ type ResultData struct {
|
||||
FaultStationCount valueTypes.Integer `json:"fault_station_count"`
|
||||
IsHaveEsPs valueTypes.Bool `json:"is_have_es_ps"`
|
||||
IsLeaf valueTypes.Bool `json:"is_leaf"`
|
||||
OrgID valueTypes.Integer `json:"org_id"`
|
||||
OrgId valueTypes.Integer `json:"org_id"`
|
||||
OrgName valueTypes.String `json:"org_name"`
|
||||
P83048 valueTypes.UnitValue `json:"p83048"`
|
||||
P83049 valueTypes.UnitValue `json:"p83049"`
|
||||
@ -38,7 +38,7 @@ type ResultData struct {
|
||||
StationCount valueTypes.Integer `json:"station_count"`
|
||||
TodayEnergy valueTypes.UnitValue `json:"today_energy"`
|
||||
TotalEnergy valueTypes.UnitValue `json:"total_energy"`
|
||||
} `json:"pageList" PointId:"page_list" PointNameFromChild:"OrgID" PointNameFromAppend:"false"`
|
||||
} `json:"pageList" PointId:"page_list" PointNameFromChild:"OrgId" PointNameFromAppend:"false"`
|
||||
RowCount valueTypes.Integer `json:"rowCount" PointIgnore:"true"`
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ const Url = "/v1/devService/getChnnlListByPsId"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
|
@ -25,10 +25,10 @@ func (rd RequestData) Help() string {
|
||||
|
||||
type ResultData struct {
|
||||
CloudList []struct {
|
||||
CloudID valueTypes.Integer `json:"cloud_id"`
|
||||
CloudId valueTypes.Integer `json:"cloud_id"`
|
||||
CloudName string `json:"cloud_name"`
|
||||
GatewayURL string `json:"gateway_url"`
|
||||
OrderID valueTypes.Integer `json:"order_id"`
|
||||
OrderId valueTypes.Integer `json:"order_id"`
|
||||
ServiceURL string `json:"service_url"`
|
||||
Value string `json:"value"`
|
||||
ValueDeDe string `json:"value_de_de"`
|
||||
@ -49,10 +49,10 @@ type ResultData struct {
|
||||
WebURL string `json:"web_url"`
|
||||
} `json:"cloud_list"`
|
||||
CurrentCloud struct {
|
||||
CloudID valueTypes.Integer `json:"cloud_id"`
|
||||
CloudId valueTypes.Integer `json:"cloud_id"`
|
||||
CloudName string `json:"cloud_name"`
|
||||
GatewayURL string `json:"gateway_url"`
|
||||
OrderID valueTypes.Integer `json:"order_id"`
|
||||
OrderId valueTypes.Integer `json:"order_id"`
|
||||
ServiceURL string `json:"service_url"`
|
||||
Value string `json:"value"`
|
||||
ValueDeDe string `json:"value_de_de"`
|
||||
|
@ -13,7 +13,7 @@ const Url = "/v1/devService/getDeviceList"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -38,7 +38,7 @@ type ResultData struct {
|
||||
DeviceArea valueTypes.Integer `json:"device_area"`
|
||||
DeviceCode valueTypes.Integer `json:"device_code"`
|
||||
DeviceFactoryDate valueTypes.DateTime `json:"device_factory_date"`
|
||||
DeviceID valueTypes.Integer `json:"device_id"`
|
||||
DeviceId valueTypes.Integer `json:"device_id"`
|
||||
DeviceModel valueTypes.String `json:"device_model"`
|
||||
DeviceModelCode valueTypes.String `json:"device_model_code"`
|
||||
DeviceModelId valueTypes.Integer `json:"device_model_id"`
|
||||
@ -65,7 +65,7 @@ type ResultData struct {
|
||||
P24 interface{} `json:"p24"`
|
||||
Posx interface{} `json:"posx"`
|
||||
Posy interface{} `json:"posy"`
|
||||
PsId valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
PsKey valueTypes.PsKey `json:"ps_key"`
|
||||
RelState valueTypes.Integer `json:"rel_state"`
|
||||
Sn valueTypes.String `json:"sn" PointName:"Serial Number"`
|
||||
@ -88,7 +88,7 @@ func (e *ResultData) IsValid() error {
|
||||
|
||||
type Device struct {
|
||||
Vendor valueTypes.String
|
||||
PsId valueTypes.Integer
|
||||
PsId valueTypes.PsId
|
||||
PsKey valueTypes.PsKey
|
||||
DeviceName valueTypes.String
|
||||
DeviceProSn valueTypes.String
|
||||
@ -96,7 +96,7 @@ type Device struct {
|
||||
DeviceType valueTypes.Integer
|
||||
DeviceCode valueTypes.Integer
|
||||
ChannelId valueTypes.Integer
|
||||
DeviceModelID valueTypes.Integer
|
||||
DeviceModelId valueTypes.Integer
|
||||
TypeName valueTypes.String
|
||||
DeviceState valueTypes.Integer
|
||||
DevStatus valueTypes.Integer
|
||||
@ -117,7 +117,7 @@ func (e *EndPoint) GetDevices() Devices {
|
||||
TypeName: d.TypeName,
|
||||
DeviceProSn: d.DeviceProSn,
|
||||
DeviceModel: d.DeviceModel,
|
||||
DeviceModelID: d.DeviceModelId,
|
||||
DeviceModelId: d.DeviceModelId,
|
||||
DeviceName: d.DeviceName,
|
||||
DeviceState: d.DeviceState,
|
||||
DevStatus: d.DevStatus,
|
||||
@ -153,14 +153,14 @@ func (e *EndPoint) GetDevicesTable() output.Table {
|
||||
// for _, d := range e.Response.ResultData.PageList {
|
||||
// _ = table.AddRow(
|
||||
// d.PsKey.Value(),
|
||||
// d.PsID.Value(),
|
||||
// d.PsId.Value(),
|
||||
// d.DeviceType.Value(),
|
||||
// d.DeviceCode.Value(),
|
||||
// d.ChannelId.Value(),
|
||||
// d.TypeName.Value(),
|
||||
// d.DeviceProSn.Value(),
|
||||
// d.DeviceModel.Value(),
|
||||
// d.DeviceModelID.Value(),
|
||||
// d.DeviceModelId.Value(),
|
||||
// d.DeviceName.Value(),
|
||||
// d.DeviceState,
|
||||
// d.DevStatus,
|
||||
@ -200,14 +200,14 @@ func GetDevicesTable(data Devices) output.Table {
|
||||
// for _, d := range e.Response.ResultData.PageList {
|
||||
// _ = table.AddRow(
|
||||
// d.PsKey.Value(),
|
||||
// d.PsID.Value(),
|
||||
// d.PsId.Value(),
|
||||
// d.DeviceType.Value(),
|
||||
// d.DeviceCode.Value(),
|
||||
// d.ChannelId.Value(),
|
||||
// d.TypeName.Value(),
|
||||
// d.DeviceProSn.Value(),
|
||||
// d.DeviceModel.Value(),
|
||||
// d.DeviceModelID.Value(),
|
||||
// d.DeviceModelId.Value(),
|
||||
// d.DeviceName.Value(),
|
||||
// d.DeviceState,
|
||||
// d.DevStatus,
|
||||
@ -247,7 +247,7 @@ func GetDevicesTable(data Devices) output.Table {
|
||||
d.TypeName.Value(),
|
||||
d.DeviceProSn.Value(),
|
||||
d.DeviceModel.Value(),
|
||||
d.DeviceModelID.Value(),
|
||||
d.DeviceModelId.Value(),
|
||||
d.DeviceName.Value(),
|
||||
d.DeviceState,
|
||||
d.DevStatus,
|
||||
|
@ -3,8 +3,8 @@ package getDeviceModelInfoList
|
||||
import (
|
||||
"GoSungrow/iSolarCloud/api"
|
||||
"GoSungrow/iSolarCloud/api/apiReflect"
|
||||
"GoSungrow/iSolarCloud/api/valueTypes"
|
||||
"GoSungrow/iSolarCloud/api/output"
|
||||
"GoSungrow/iSolarCloud/api/valueTypes"
|
||||
"fmt"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
)
|
||||
@ -27,11 +27,11 @@ func (rd RequestData) Help() string {
|
||||
|
||||
type ResultData []struct {
|
||||
ComType string `json:"com_type"`
|
||||
DeviceFactoryID string `json:"device_factory_id"`
|
||||
DeviceFactoryId string `json:"device_factory_id"`
|
||||
DeviceFactoryName string `json:"device_factory_name"`
|
||||
DeviceModel string `json:"device_model"`
|
||||
DeviceModelCode string `json:"device_model_code"`
|
||||
DeviceModelID valueTypes.Integer `json:"device_model_id"`
|
||||
DeviceModelId valueTypes.Integer `json:"device_model_id"`
|
||||
DeviceType valueTypes.Integer `json:"device_type"`
|
||||
IsRemoteUpgrade valueTypes.Bool `json:"is_remote_upgrade"`
|
||||
}
|
||||
@ -89,10 +89,10 @@ func (e *EndPoint) GetPointDataTable() output.Table {
|
||||
d.DeviceModelCode = ""
|
||||
}
|
||||
_ = table.AddRow(
|
||||
d.DeviceModelID,
|
||||
d.DeviceModelId,
|
||||
d.DeviceType,
|
||||
d.ComType,
|
||||
d.DeviceFactoryID,
|
||||
d.DeviceFactoryId,
|
||||
d.DeviceFactoryName,
|
||||
d.DeviceModel,
|
||||
d.DeviceModelCode,
|
||||
|
@ -25,7 +25,7 @@ func (rd RequestData) Help() string {
|
||||
|
||||
type ResultData struct {
|
||||
DeviceTypeList []struct {
|
||||
DevListOrderID valueTypes.Integer `json:"dev_list_order_id"`
|
||||
DevListOrderId valueTypes.Integer `json:"dev_list_order_id"`
|
||||
DeviceType valueTypes.Integer `json:"device_type"`
|
||||
TypeName valueTypes.String `json:"type_name"`
|
||||
} `json:"deviceTypeList"`
|
||||
|
@ -32,8 +32,8 @@ type ResultData []struct {
|
||||
FaultReason valueTypes.String `json:"fault_reason"`
|
||||
FaultType valueTypes.Integer `json:"fault_type"`
|
||||
FaultTypeCode valueTypes.Integer `json:"fault_type_code"`
|
||||
ID valueTypes.Integer `json:"id"`
|
||||
PsID valueTypes.Integer `json:"ps_id"`
|
||||
Id valueTypes.Integer `json:"id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
PsKey valueTypes.PsKey `json:"ps_key"`
|
||||
UUID valueTypes.Integer `json:"uuid"`
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
DateType string `json:"date_type" required:"true"`
|
||||
DateID string `json:"date_id" required:"true"`
|
||||
DateId string `json:"date_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
|
@ -14,9 +14,9 @@ const Url = "/v1/powerStationService/getHouseholdStoragePsReport"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
DateID string `json:"date_id" required:"true"`
|
||||
DateId string `json:"date_id" required:"true"`
|
||||
DateType string `json:"date_type" required:"true"`
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -123,7 +123,7 @@ type MonthData struct {
|
||||
ZjzzMap valueTypes.UnitValue `json:"zjzz_map"`
|
||||
ZjzzMapVirgin valueTypes.UnitValue `json:"zjzz_map_virgin" PointIgnore:"true"`
|
||||
MonthDataDayList []struct {
|
||||
DateID valueTypes.Integer `json:"date_id"`
|
||||
DateId valueTypes.Integer `json:"date_id"`
|
||||
Jthd valueTypes.Float `json:"jthd" PointUnitFrom:"JthdUnit" PointTimestampFrom:"TimeStamp"`
|
||||
JthdUnit valueTypes.String `json:"jthd_unit" PointIgnore:"true"`
|
||||
Jtyd valueTypes.Float `json:"jtyd" PointUnitFrom:"JtydUnit" PointTimestampFrom:"TimeStamp"`
|
||||
@ -148,7 +148,7 @@ type MonthData struct {
|
||||
P83120 valueTypes.Float `json:"p83120" PointId:"p83120" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqMonth"`
|
||||
P83121 valueTypes.Float `json:"p83121" PointId:"p83121" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqMonth"`
|
||||
P83122 valueTypes.Float `json:"p83122" PointId:"p83122" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqMonth"`
|
||||
PsID valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
SelfConsumptionYield valueTypes.Float `json:"self_consumption_yield" PointUnitFrom:"SelfConsumptionYieldUnit" PointTimestampFrom:"TimeStamp"`
|
||||
SelfConsumptionYieldUnit valueTypes.String `json:"self_consumption_yield_unit" PointIgnore:"true"`
|
||||
TimeStamp valueTypes.DateTime `json:"time_stamp"`
|
||||
@ -185,7 +185,7 @@ type YearData struct {
|
||||
ZjzzMap valueTypes.UnitValue `json:"zjzz_map"`
|
||||
ZjzzMapVirgin valueTypes.UnitValue `json:"zjzz_map_virgin" PointIgnore:"true"`
|
||||
YearDataMonthList []struct {
|
||||
DateID valueTypes.Integer `json:"date_id"`
|
||||
DateId valueTypes.Integer `json:"date_id"`
|
||||
Jthd valueTypes.Float `json:"jthd" PointUnitFrom:"JthdUnit" PointTimestampFrom:"TimeStamp"`
|
||||
JthdUnit valueTypes.String `json:"jthd_unit" PointIgnore:"true"`
|
||||
Jtyd valueTypes.Float `json:"jtyd" PointUnitFrom:"JtydUnit" PointTimestampFrom:"TimeStamp"`
|
||||
@ -210,7 +210,7 @@ type YearData struct {
|
||||
P83120 valueTypes.Float `json:"p83120" PointId:"p83120" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqYear"`
|
||||
P83121 valueTypes.Float `json:"p83121" PointId:"p83121" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqYear"`
|
||||
P83122 valueTypes.Float `json:"p83122" PointId:"p83122" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqYear"`
|
||||
PsID valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
SelfConsumptionYield valueTypes.Float `json:"self_consumption_yield" PointUnitFrom:"SelfConsumptionYieldUnit" PointTimestampFrom:"TimeStamp"`
|
||||
SelfConsumptionYieldUnit valueTypes.String `json:"self_consumption_yield_unit" PointIgnore:"true"`
|
||||
TimeStamp valueTypes.DateTime `json:"time_stamp"`
|
||||
@ -245,7 +245,7 @@ type TotalData struct {
|
||||
ZjzzMap valueTypes.UnitValue `json:"zjzz_map"`
|
||||
ZjzzMapVirgin valueTypes.UnitValue `json:"zjzz_map_virgin" PointIgnore:"true"`
|
||||
TotalDataYearList []struct {
|
||||
DateID valueTypes.Integer `json:"date_id"`
|
||||
DateId valueTypes.Integer `json:"date_id"`
|
||||
Jthd valueTypes.Float `json:"jthd" PointUnitFrom:"JthdUnit" PointTimestampFrom:"TimeStamp"`
|
||||
JthdUnit valueTypes.String `json:"jthd_unit" PointIgnore:"true"`
|
||||
Jtyd valueTypes.Float `json:"jtyd" PointUnitFrom:"JtydUnit" PointTimestampFrom:"TimeStamp"`
|
||||
@ -270,7 +270,7 @@ type TotalData struct {
|
||||
P83120 valueTypes.Float `json:"p83120" PointId:"p83120" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqTotal"`
|
||||
P83121 valueTypes.Float `json:"p83121" PointId:"p83121" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqTotal"`
|
||||
P83122 valueTypes.Float `json:"p83122" PointId:"p83122" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqTotal"`
|
||||
PsID valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
SelfConsumptionYield valueTypes.Float `json:"self_consumption_yield" PointUnitFrom:"SelfConsumptionYieldUnit" PointTimestampFrom:"TimeStamp"`
|
||||
SelfConsumptionYieldUnit valueTypes.String `json:"self_consumption_yield_unit" PointIgnore:"true"`
|
||||
TimeStamp valueTypes.DateTime `json:"time_stamp"`
|
||||
@ -344,53 +344,9 @@ func (e *EndPoint) GetData() api.DataMap {
|
||||
|
||||
for range Only.Once {
|
||||
pkg := apiReflect.GetName("", *e)
|
||||
name := api.JoinWithDots(0, "", pkg, e.Request.PsId)
|
||||
entries.StructToPoints(e.Response.ResultData, name, e.Request.PsId.String(), valueTypes.NewDateTime(valueTypes.Now))
|
||||
break
|
||||
|
||||
// if e.Response.ResultData.DayData != nil {
|
||||
// name := api.JoinWithDots(0, "", pkg, e.Request.PsId, "Day")
|
||||
// entries.StructToPoints(*e.Response.ResultData.DayData, name, e.Request.PsId.String(), valueTypes.NewDateTime(valueTypes.Now))
|
||||
//
|
||||
// // s := valueTypes.SizeOfArrayLength(e.Response.ResultData.DayData.PointData15List)
|
||||
// // for i, d := range e.Response.ResultData.DayData.PointData15List {
|
||||
// // name2 := api.JoinWithDots(s, "", name, i)
|
||||
// // entries.StructToPoints(*e.Response.ResultData.DayData, name2, e.Request.PsId.String(), d.TimeStamp)
|
||||
// // }
|
||||
// }
|
||||
//
|
||||
// if e.Response.ResultData.MonthData != nil {
|
||||
// name := api.JoinWithDots(0, "", pkg, e.Request.PsId, "Month")
|
||||
// entries.StructToPoints(*e.Response.ResultData.MonthData, name, e.Request.PsId.String(), valueTypes.NewDateTime(valueTypes.Now))
|
||||
//
|
||||
// // s := valueTypes.SizeOfArrayLength(e.Response.ResultData.MonthData.MonthDataDayList)
|
||||
// // for i, d := range e.Response.ResultData.MonthData.MonthDataDayList {
|
||||
// // name2 := api.JoinWithDots(s, "", name, i)
|
||||
// // entries.StructToPoints(*e.Response.ResultData.MonthData, name2, e.Request.PsId.String(), d.TimeStamp)
|
||||
// // }
|
||||
// }
|
||||
//
|
||||
// if e.Response.ResultData.YearData != nil {
|
||||
// name := api.JoinWithDots(0, "", pkg, e.Request.PsId, "Year")
|
||||
// entries.StructToPoints(*e.Response.ResultData.YearData, name, e.Request.PsId.String(), valueTypes.NewDateTime(valueTypes.Now))
|
||||
//
|
||||
// // s := valueTypes.SizeOfArrayLength(e.Response.ResultData.YearData.YearDataMonthList)
|
||||
// // for i, d := range e.Response.ResultData.YearData.YearDataMonthList {
|
||||
// // name2 := api.JoinWithDots(s, "", name, i)
|
||||
// // entries.StructToPoints(*e.Response.ResultData.YearData, name2, e.Request.PsId.String(), d.TimeStamp)
|
||||
// // }
|
||||
// }
|
||||
//
|
||||
// if e.Response.ResultData.TotalData != nil {
|
||||
// name := api.JoinWithDots(0, "", pkg, e.Request.PsId, "Total")
|
||||
// entries.StructToPoints(*e.Response.ResultData.TotalData, name, e.Request.PsId.String(), valueTypes.NewDateTime(valueTypes.Now))
|
||||
//
|
||||
// // s := valueTypes.SizeOfArrayLength(e.Response.ResultData.TotalData.TotalDataYearList)
|
||||
// // for i, d := range e.Response.ResultData.TotalData.TotalDataYearList {
|
||||
// // name2 := api.JoinWithDots(s, "", name, i)
|
||||
// // entries.StructToPoints(*e.Response.ResultData.TotalData, name2, e.Request.PsId.String(), d.TimeStamp)
|
||||
// // }
|
||||
// }
|
||||
dt := valueTypes.NewDateTime(valueTypes.Now)
|
||||
name := pkg + "." + e.Request.PsId.String()
|
||||
entries.StructToPoints(e.Response.ResultData, name, e.Request.PsId.String(), dt)
|
||||
}
|
||||
|
||||
return entries
|
||||
|
@ -373,7 +373,8 @@ func (e EndPoint) GetEndPointDataTable() output.Table {
|
||||
|
||||
// SetFilenamePrefix - Produce filename based on area and endpoint name.
|
||||
func (e EndPoint) SetFilenamePrefix(format string, args ...interface{}) string {
|
||||
return e.ApiSetFilenamePrefix(format, args...)
|
||||
return e.ApiSetFilenamePrefix2(e.Request.RequestData, format, args...)
|
||||
// return e.ApiSetFilenamePrefix(format, args...)
|
||||
}
|
||||
|
||||
// GetRequestArgNames -
|
||||
|
@ -12,7 +12,7 @@ const Url = "/v1/powerStationService/getIncomeSettingInfos"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -33,14 +33,14 @@ type ResultData struct {
|
||||
CodeType valueTypes.Integer `json:"code_type"`
|
||||
CountyAllowanceMoney interface{} `json:"county_allowance_money"`
|
||||
DefaultCharge valueTypes.Float `json:"default_charge"`
|
||||
ElectricChargeID valueTypes.Integer `json:"electric_charge_id"`
|
||||
ElectricChargeId valueTypes.Integer `json:"electric_charge_id"`
|
||||
EndTime valueTypes.DateTime `json:"end_time"`
|
||||
IncomeStyle interface{} `json:"income_style"`
|
||||
IntervalTimeCharge interface{} `json:"interval_time_charge"`
|
||||
NationAllowanceMoney interface{} `json:"nation_allowance_money"`
|
||||
ParamIncomeUnit valueTypes.Integer `json:"param_income_unit"`
|
||||
ProvinceAllowanceMoney interface{} `json:"province_allowance_money"`
|
||||
PsId valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
StartTime valueTypes.DateTime `json:"start_time"`
|
||||
UseSharpPeekValleyFlat interface{} `json:"use_sharp_peek_valley_flat"`
|
||||
ValidFlag valueTypes.Bool `json:"valid_flag"`
|
||||
@ -51,11 +51,11 @@ type ResultData struct {
|
||||
EndTime valueTypes.DateTime `json:"end_time"`
|
||||
IntervalTimeCharge valueTypes.String `json:"interval_time_charge"`
|
||||
OnlineElectricityPercent valueTypes.Float `json:"online_electricity_percent" PointUnit:"%"`
|
||||
PsID valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
StartTime valueTypes.DateTime `json:"start_time"`
|
||||
UseElectricityDiscount valueTypes.Float `json:"use_electricity_discount" PointUnit:"%"`
|
||||
} `json:"powerSelfUseTimesChargeMap" PointId:"power_selfuse_times_charge_map"`
|
||||
PsId valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
}
|
||||
|
||||
func (e *ResultData) IsValid() error {
|
||||
@ -75,7 +75,8 @@ func (e *EndPoint) GetData() api.DataMap {
|
||||
for range Only.Once {
|
||||
pkg := apiReflect.GetName("", *e)
|
||||
dt := valueTypes.NewDateTime(valueTypes.Now)
|
||||
entries.StructToPoints(e.Response.ResultData, pkg, e.Request.PsId.String(), dt)
|
||||
name := pkg + "." + e.Request.PsId.String()
|
||||
entries.StructToPoints(e.Response.ResultData, name, e.Request.PsId.String(), dt)
|
||||
}
|
||||
|
||||
return entries
|
||||
|
@ -29,7 +29,7 @@ type ResultData []struct {
|
||||
Installer string `json:"installer"`
|
||||
InstallerEmail string `json:"installer_email"`
|
||||
InstallerPhone string `json:"installer_phone"`
|
||||
OrgID string `json:"org_id"`
|
||||
OrgId string `json:"org_id"`
|
||||
PsNames []string `json:"ps_names"`
|
||||
}
|
||||
|
||||
|
@ -34,9 +34,9 @@ type ResultData struct {
|
||||
InstallerEmail string `json:"installer_email"`
|
||||
InstallerPhone string `json:"installer_phone"`
|
||||
MobleTel interface{} `json:"moble_tel"`
|
||||
OrgID valueTypes.Integer `json:"org_id"`
|
||||
OrgId valueTypes.Integer `json:"org_id"`
|
||||
OrgName string `json:"org_name"`
|
||||
UserID valueTypes.Integer `json:"user_id"`
|
||||
UserId valueTypes.Integer `json:"user_id"`
|
||||
UserName string `json:"user_name"`
|
||||
UserTelNationCode interface{} `json:"user_tel_nation_code"`
|
||||
} `json:"user_info_list"`
|
||||
|
@ -27,17 +27,17 @@ type ResultData struct {
|
||||
CurPage valueTypes.Integer `json:"curPage"`
|
||||
IsMore valueTypes.Bool `json:"isMore"`
|
||||
PageList []struct {
|
||||
BatchID valueTypes.String `json:"batch_id"`
|
||||
BatchId valueTypes.String `json:"batch_id"`
|
||||
CommandStatus valueTypes.Integer `json:"command_status"`
|
||||
CommandType valueTypes.Integer `json:"command_type"`
|
||||
CreateTime valueTypes.DateTime `json:"create_time"`
|
||||
DeviceCode valueTypes.Integer `json:"device_code"`
|
||||
DeviceModel valueTypes.String `json:"device_model"`
|
||||
DeviceModelID valueTypes.String `json:"device_model_id"`
|
||||
DeviceModelId valueTypes.String `json:"device_model_id"`
|
||||
ExpireSecond valueTypes.Integer `json:"expire_second"`
|
||||
LogType valueTypes.Integer `json:"log_type"`
|
||||
LoggerCode valueTypes.Integer `json:"logger_code"`
|
||||
OperateUserID valueTypes.Integer `json:"operate_user_id"`
|
||||
OperateUserId valueTypes.Integer `json:"operate_user_id"`
|
||||
OverTime valueTypes.DateTime `json:"over_time"`
|
||||
Remark valueTypes.String `json:"remark"`
|
||||
SetCancelNum valueTypes.Integer `json:"set_cancel_num"`
|
||||
@ -47,7 +47,7 @@ type ResultData struct {
|
||||
SetSuccessNum valueTypes.Integer `json:"set_success_num"`
|
||||
SetTotalNum valueTypes.Integer `json:"set_total_num"`
|
||||
Sn valueTypes.String `json:"sn"`
|
||||
TaskID valueTypes.Integer `json:"task_id"`
|
||||
TaskId valueTypes.Integer `json:"task_id"`
|
||||
TaskName valueTypes.Integer `json:"task_name"`
|
||||
UpdateTime valueTypes.DateTime `json:"update_time"`
|
||||
} `json:"pageList"`
|
||||
|
@ -26,7 +26,7 @@ func (rd RequestData) Help() string {
|
||||
|
||||
type ResultData []struct {
|
||||
IsLeaf valueTypes.Bool `json:"is_leaf"`
|
||||
OrgID valueTypes.Integer `json:"org_id"`
|
||||
OrgId valueTypes.Integer `json:"org_id"`
|
||||
OrgName valueTypes.String `json:"org_name"`
|
||||
}
|
||||
|
||||
|
@ -27,16 +27,16 @@ func (rd RequestData) Help() string {
|
||||
type ResultData []struct {
|
||||
GcjLatitude valueTypes.Float `json:"gcj_latitude"`
|
||||
GcjLongitude valueTypes.Float `json:"gcj_longitude"`
|
||||
ID valueTypes.Integer `json:"id"`
|
||||
Id valueTypes.Integer `json:"id"`
|
||||
IsLeaf valueTypes.Bool `json:"is_leaf"`
|
||||
MapLevel interface{} `json:"map_level"`
|
||||
OrgID valueTypes.Integer `json:"org_id"`
|
||||
OrgId valueTypes.Integer `json:"org_id"`
|
||||
OrgIndexCode valueTypes.String `json:"org_index_code"`
|
||||
OrgIsShow valueTypes.Integer `json:"org_is_show"`
|
||||
OrgLevel valueTypes.Integer `json:"org_level"`
|
||||
OrgName valueTypes.String `json:"org_name"`
|
||||
SizeChild valueTypes.Integer `json:"size_child"`
|
||||
UpOrgID valueTypes.Integer `json:"up_org_id"`
|
||||
UpOrgId valueTypes.Integer `json:"up_org_id"`
|
||||
Wgs84Latitude valueTypes.Float `json:"wgs84_latitude"`
|
||||
Wgs84Longitude valueTypes.Float `json:"wgs84_longitude"`
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ const Url = "/v1/powerStationService/getPowerChargeSettingInfo"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -35,7 +35,7 @@ type ResultData struct {
|
||||
DefaultCharge valueTypes.Float `json:"default_charge" PointUnitFrom:"ParamIncomeUnitName"`
|
||||
IntervalTimeCharge string `json:"interval_time_charge"`
|
||||
} `json:"powerSelfUseTimesChargeMap" PointName:"power_self_use_charge_map"`
|
||||
PsID valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
}
|
||||
|
||||
func (e *ResultData) IsValid() error {
|
||||
|
@ -61,7 +61,7 @@ func (rd RequestData) Help() string {
|
||||
}
|
||||
|
||||
type ResultData []struct {
|
||||
CodeID valueTypes.Integer `json:"code_id"`
|
||||
CodeId valueTypes.Integer `json:"code_id"`
|
||||
CodeName string `json:"code_name"`
|
||||
CodeValue string `json:"code_value"`
|
||||
DefaultValue interface{} `json:"default_value"`
|
||||
|
@ -3,8 +3,8 @@ package getPowerDevicePointInfo
|
||||
import (
|
||||
"GoSungrow/iSolarCloud/api"
|
||||
"GoSungrow/iSolarCloud/api/apiReflect"
|
||||
"GoSungrow/iSolarCloud/api/valueTypes"
|
||||
"GoSungrow/iSolarCloud/api/output"
|
||||
"GoSungrow/iSolarCloud/api/valueTypes"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
|
||||
"fmt"
|
||||
@ -14,7 +14,7 @@ const Url = "/v1/reportService/getPowerDevicePointInfo"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
Id valueTypes.Integer `json:"id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"id" required:"true"`
|
||||
// Id string `json:"id"`
|
||||
}
|
||||
|
||||
@ -30,12 +30,12 @@ func (rd RequestData) Help() string {
|
||||
|
||||
type ResultData struct {
|
||||
DeviceType valueTypes.Integer `json:"device_type" PointId:"device_type" PointValueType:"" PointUpdateFreq:""`
|
||||
ID valueTypes.Integer `json:"id" PointId:"id" PointValueType:"" PointUpdateFreq:""`
|
||||
Id valueTypes.Integer `json:"id" PointId:"id" PointValueType:"" PointUpdateFreq:""`
|
||||
Period valueTypes.Integer `json:"period" PointId:"period" PointValueType:"" PointUpdateFreq:""`
|
||||
PointID valueTypes.Integer `json:"point_id" PointId:"point_id" PointValueType:"" PointUpdateFreq:""`
|
||||
PointId valueTypes.Integer `json:"point_id" PointId:"point_id" PointValueType:"" PointUpdateFreq:""`
|
||||
PointName string `json:"point_name" PointId:"point_name" PointValueType:"" PointUpdateFreq:""`
|
||||
ShowPointName string `json:"show_point_name" PointId:"show_point_name" PointValueType:"" PointUpdateFreq:""`
|
||||
TranslationID valueTypes.Integer `json:"translation_id" PointId:"translation_id" PointValueType:"" PointUpdateFreq:""`
|
||||
TranslationId valueTypes.Integer `json:"translation_id" PointId:"translation_id" PointValueType:"" PointUpdateFreq:""`
|
||||
}
|
||||
|
||||
func (e *ResultData) IsValid() error {
|
||||
@ -71,10 +71,10 @@ func (e *EndPoint) AddDataTable(table output.Table) output.Table {
|
||||
for range Only.Once {
|
||||
rd := e.Response.ResultData
|
||||
|
||||
if rd.ID.Value() == 0 {
|
||||
if rd.Id.Value() == 0 {
|
||||
break
|
||||
}
|
||||
_ = table.AddRow(rd.DeviceType, rd.ID, rd.Period, rd.PointID,rd.PointName, rd.ShowPointName, rd.TranslationID)
|
||||
_ = table.AddRow(rd.DeviceType, rd.Id, rd.Period, rd.PointId,rd.PointName, rd.ShowPointName, rd.TranslationId)
|
||||
}
|
||||
return table
|
||||
}
|
||||
@ -97,7 +97,7 @@ func (e *EndPoint) GetPointDataTable() output.Table {
|
||||
"Translation Id",
|
||||
)
|
||||
rd := e.Response.ResultData
|
||||
_ = table.AddRow(rd.DeviceType, rd.ID, rd.Period, rd.PointID,rd.PointName, rd.ShowPointName, rd.TranslationID)
|
||||
_ = table.AddRow(rd.DeviceType, rd.Id, rd.Period, rd.PointId,rd.PointName, rd.ShowPointName, rd.TranslationId)
|
||||
}
|
||||
return table
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ func (rd RequestData) Help() string {
|
||||
|
||||
type ResultData []struct {
|
||||
PointCalType valueTypes.Integer `json:"point_cal_type"`
|
||||
PointID valueTypes.Integer `json:"point_id"`
|
||||
PointId valueTypes.Integer `json:"point_id"`
|
||||
PointName string `json:"point_name"`
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ func (e *EndPoint) GetPointDataTable() output.Table {
|
||||
_ = table.AddRow(
|
||||
e.Request.DeviceType,
|
||||
p.PointCalType,
|
||||
p.PointID,
|
||||
p.PointId,
|
||||
p.PointName,
|
||||
)
|
||||
if table.Error != nil {
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"GoSungrow/iSolarCloud/api"
|
||||
"GoSungrow/iSolarCloud/api/apiReflect"
|
||||
"GoSungrow/iSolarCloud/api/valueTypes"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
"fmt"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
)
|
||||
|
||||
const Url = "/v1/devService/getPowerDeviceSetTaskList"
|
||||
@ -27,28 +27,28 @@ func (rd RequestData) Help() string {
|
||||
|
||||
type ResultData struct {
|
||||
PageList []struct {
|
||||
CommandStatus valueTypes.Integer `json:"command_status"`
|
||||
CommandType valueTypes.Integer `json:"command_type"`
|
||||
CreateTime string `json:"create_time"`
|
||||
OperateUserID valueTypes.Integer `json:"operate_user_id"`
|
||||
OverTime string `json:"over_time"`
|
||||
PsID valueTypes.Integer `json:"ps_id"`
|
||||
SetCancelNum valueTypes.Integer `json:"set_cancel_num"`
|
||||
SetFailNum valueTypes.Integer `json:"set_fail_num"`
|
||||
SetFinishNum valueTypes.Integer `json:"set_finish_num"`
|
||||
SetOvertimeNum valueTypes.Integer `json:"set_overtime_num"`
|
||||
SetSuccessNum valueTypes.Integer `json:"set_success_num"`
|
||||
SetTotalNum valueTypes.Integer `json:"set_total_num"`
|
||||
SweepDevParamSetType valueTypes.Integer `json:"sweep_dev_param_set_type"`
|
||||
TaskID valueTypes.Integer `json:"task_id"`
|
||||
TaskName string `json:"task_name"`
|
||||
TaskType valueTypes.Integer `json:"task_type"`
|
||||
TemplateType valueTypes.Integer `json:"template_type"`
|
||||
UpdateTime string `json:"update_time"`
|
||||
UserEnglishName interface{} `json:"user_english_name"`
|
||||
UserName string `json:"user_name"`
|
||||
UUID valueTypes.Integer `json:"uuid"`
|
||||
} `json:"pageList"`
|
||||
CommandStatus valueTypes.Integer `json:"command_status"`
|
||||
CommandType valueTypes.Integer `json:"command_type"`
|
||||
CreateTime valueTypes.DateTime `json:"create_time"`
|
||||
OperateUserId valueTypes.Integer `json:"operate_user_id"`
|
||||
OverTime valueTypes.DateTime `json:"over_time"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
SetCancelNum valueTypes.Count `json:"set_cancel_num"`
|
||||
SetFailNum valueTypes.Count `json:"set_fail_num"`
|
||||
SetFinishNum valueTypes.Count `json:"set_finish_num"`
|
||||
SetOvertimeNum valueTypes.Count `json:"set_overtime_num"`
|
||||
SetSuccessNum valueTypes.Count `json:"set_success_num"`
|
||||
SetTotalNum valueTypes.Count `json:"set_total_num"`
|
||||
SweepDevParamSetType valueTypes.Integer `json:"sweep_dev_param_set_type"`
|
||||
TaskId valueTypes.Integer `json:"task_id"`
|
||||
TaskName valueTypes.String `json:"task_name"`
|
||||
TaskType valueTypes.Integer `json:"task_type"`
|
||||
TemplateType valueTypes.Integer `json:"template_type"`
|
||||
UpdateTime valueTypes.DateTime `json:"update_time"`
|
||||
UserEnglishName interface{} `json:"user_english_name"`
|
||||
UserName valueTypes.String `json:"user_name"`
|
||||
UUID valueTypes.Integer `json:"uuid"`
|
||||
} `json:"pageList" PointId:"page_list" PointNameFromChild:"PsId.CreateTime" PointNameFromAppend:"false"`
|
||||
RowCount valueTypes.Integer `json:"rowCount"`
|
||||
}
|
||||
|
||||
@ -63,30 +63,14 @@ func (e *ResultData) IsValid() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// type DecodeResultData ResultData
|
||||
//
|
||||
// func (e *ResultData) UnmarshalJSON(data []byte) error {
|
||||
// var err error
|
||||
//
|
||||
// for range Only.Once {
|
||||
// if len(data) == 0 {
|
||||
// break
|
||||
// }
|
||||
// var pd DecodeResultData
|
||||
//
|
||||
// // Store ResultData
|
||||
// _ = json.Unmarshal(data, &pd)
|
||||
// e.Dummy = pd.Dummy
|
||||
// }
|
||||
//
|
||||
// return err
|
||||
// }
|
||||
|
||||
func (e *EndPoint) GetData() api.DataMap {
|
||||
entries := api.NewDataMap()
|
||||
|
||||
for range Only.Once {
|
||||
entries.StructToPoints(e.Response.ResultData, apiReflect.GetName("", *e), "system", valueTypes.NewDateTime(""))
|
||||
pkg := apiReflect.GetName("", *e)
|
||||
dt := valueTypes.NewDateTime(valueTypes.Now)
|
||||
// name := pkg + "." + e.Request.PsId.String()
|
||||
entries.StructToPoints(e.Response.ResultData, pkg, "system", dt)
|
||||
}
|
||||
|
||||
return entries
|
||||
|
@ -12,7 +12,7 @@ const Url = "/v1/powerStationService/getPowerStationBasicInfo"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -24,47 +24,46 @@ func (rd RequestData) Help() string {
|
||||
return ret
|
||||
}
|
||||
|
||||
|
||||
type ResultData struct {
|
||||
AreaID interface{} `json:"area_id"`
|
||||
ConnectType valueTypes.Integer `json:"connect_type"`
|
||||
County interface{} `json:"county"`
|
||||
CountyCode interface{} `json:"county_code"`
|
||||
DesignCapacity valueTypes.Integer `json:"design_capacity"`
|
||||
Email string `json:"email"`
|
||||
EnergyScheme interface{} `json:"energy_scheme"`
|
||||
ExpectInstallDate valueTypes.DateTime `json:"expect_install_date"`
|
||||
FaultSendType interface{} `json:"fault_send_type"`
|
||||
GcjLatitude valueTypes.Float `json:"gcj_latitude"`
|
||||
GcjLongitude valueTypes.Float `json:"gcj_longitude"`
|
||||
Latitude valueTypes.Float `json:"latitude"`
|
||||
Longitude valueTypes.Float `json:"longitude"`
|
||||
Name interface{} `json:"name"`
|
||||
NameCode interface{} `json:"name_code"`
|
||||
Nation interface{} `json:"nation"`
|
||||
NationCode interface{} `json:"nation_code"`
|
||||
ParamIncome valueTypes.Integer `json:"param_income"`
|
||||
Prov interface{} `json:"prov"`
|
||||
ProvCode interface{} `json:"prov_code"`
|
||||
PsBuildDate valueTypes.DateTime `json:"ps_build_date"`
|
||||
PsCountryID valueTypes.Integer `json:"ps_country_id"`
|
||||
PsDesc interface{} `json:"ps_desc"`
|
||||
PsHolder string `json:"ps_holder"`
|
||||
PsID valueTypes.Integer `json:"ps_id"`
|
||||
PsLocation string `json:"ps_location"`
|
||||
PsName string `json:"ps_name"`
|
||||
PsType valueTypes.Integer `json:"ps_type"`
|
||||
RecoreCreateTime string `json:"recore_create_time"`
|
||||
ReportType interface{} `json:"report_type"`
|
||||
ShippingAddress string `json:"shipping_address"`
|
||||
ShippingZipCode string `json:"shipping_zip_code"`
|
||||
TimeZoneID valueTypes.Integer `json:"time_zone_id"`
|
||||
ValidFlag valueTypes.Integer `json:"valid_flag"`
|
||||
Village interface{} `json:"village"`
|
||||
VillageCode interface{} `json:"village_code"`
|
||||
WgsLatitude valueTypes.Float `json:"wgs_latitude"`
|
||||
WgsLongitude valueTypes.Float `json:"wgs_longitude"`
|
||||
ZipCode string `json:"zip_code"`
|
||||
type ResultData struct {
|
||||
AreaId interface{} `json:"area_id"`
|
||||
ConnectType valueTypes.Integer `json:"connect_type"`
|
||||
County interface{} `json:"county"`
|
||||
CountyCode interface{} `json:"county_code"`
|
||||
DesignCapacity valueTypes.Float `json:"design_capacity"`
|
||||
Email valueTypes.String `json:"email"`
|
||||
EnergyScheme interface{} `json:"energy_scheme"`
|
||||
ExpectInstallDate valueTypes.DateTime `json:"expect_install_date"`
|
||||
FaultSendType interface{} `json:"fault_send_type"`
|
||||
GcjLatitude valueTypes.Float `json:"gcj_latitude"`
|
||||
GcjLongitude valueTypes.Float `json:"gcj_longitude"`
|
||||
Latitude valueTypes.Float `json:"latitude"`
|
||||
Longitude valueTypes.Float `json:"longitude"`
|
||||
Name interface{} `json:"name"`
|
||||
NameCode interface{} `json:"name_code"`
|
||||
Nation interface{} `json:"nation"`
|
||||
NationCode interface{} `json:"nation_code"`
|
||||
ParamIncome valueTypes.Float `json:"param_income"`
|
||||
Prov interface{} `json:"prov"`
|
||||
ProvCode interface{} `json:"prov_code"`
|
||||
PsBuildDate valueTypes.DateTime `json:"ps_build_date"`
|
||||
PsCountryId valueTypes.Integer `json:"ps_country_id"`
|
||||
PsDesc interface{} `json:"ps_desc"`
|
||||
PsHolder valueTypes.String `json:"ps_holder"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
PsLocation valueTypes.String `json:"ps_location"`
|
||||
PsName valueTypes.String `json:"ps_name"`
|
||||
PsType valueTypes.Integer `json:"ps_type"`
|
||||
RecordCreateTime string `json:"recore_create_time"`
|
||||
ReportType interface{} `json:"report_type"`
|
||||
ShippingAddress valueTypes.String `json:"shipping_address"`
|
||||
ShippingZipCode valueTypes.String `json:"shipping_zip_code"`
|
||||
TimeZoneId valueTypes.Integer `json:"time_zone_id"`
|
||||
ValidFlag valueTypes.Bool `json:"valid_flag"`
|
||||
Village interface{} `json:"village"`
|
||||
VillageCode interface{} `json:"village_code"`
|
||||
WgsLatitude valueTypes.Float `json:"wgs_latitude"`
|
||||
WgsLongitude valueTypes.Float `json:"wgs_longitude"`
|
||||
ZipCode valueTypes.String `json:"zip_code"`
|
||||
}
|
||||
|
||||
func (e *ResultData) IsValid() error {
|
||||
@ -78,30 +77,14 @@ func (e *ResultData) IsValid() error {
|
||||
return err
|
||||
}
|
||||
|
||||
//type DecodeResultData ResultData
|
||||
//
|
||||
//func (e *ResultData) UnmarshalJSON(data []byte) error {
|
||||
// var err error
|
||||
//
|
||||
// for range Only.Once {
|
||||
// if len(data) == 0 {
|
||||
// break
|
||||
// }
|
||||
// var pd DecodeResultData
|
||||
//
|
||||
// // Store ResultData
|
||||
// _ = json.Unmarshal(data, &pd)
|
||||
// e.Dummy = pd.Dummy
|
||||
// }
|
||||
//
|
||||
// return err
|
||||
//}
|
||||
|
||||
func (e *EndPoint) GetData() api.DataMap {
|
||||
entries := api.NewDataMap()
|
||||
|
||||
for range Only.Once {
|
||||
entries.StructToPoints(e.Response.ResultData, apiReflect.GetName("", *e), "system", valueTypes.NewDateTime(""))
|
||||
pkg := apiReflect.GetName("", *e)
|
||||
dt := valueTypes.NewDateTime(valueTypes.Now)
|
||||
name := pkg + "." + e.Request.PsId.String()
|
||||
entries.StructToPoints(e.Response.ResultData, name, e.Request.PsId.String(), dt)
|
||||
}
|
||||
|
||||
return entries
|
||||
|
@ -12,8 +12,8 @@ const Url = "/v1/powerStationService/getPowerStationData"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
DateID string `json:"date_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
DateId string `json:"date_id" required:"true"`
|
||||
DateType string `json:"date_type" required:"true"`
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ const Url = "/v1/powerStationService/getPowerStationForHousehold"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -25,10 +25,10 @@ func (rd RequestData) Help() string {
|
||||
}
|
||||
|
||||
type ResultData struct {
|
||||
LbsAreaCode valueTypes.String `json:"LbsAreaCode"`
|
||||
LbsCountry valueTypes.String `json:"LbsCountry"`
|
||||
LbsAreaCode valueTypes.String `json:"LbsAreaCode" PointId:"lbs_area_code"`
|
||||
LbsCountry valueTypes.String `json:"LbsCountry" PointId:"lbs_country"`
|
||||
AccessType interface{} `json:"access_type"`
|
||||
AreaID interface{} `json:"area_id"`
|
||||
AreaId interface{} `json:"area_id"`
|
||||
ArrearsStatus valueTypes.Integer `json:"arrears_status"`
|
||||
BatteryType valueTypes.Integer `json:"battery_type"`
|
||||
CityCode valueTypes.String `json:"city_code"`
|
||||
@ -38,7 +38,7 @@ type ResultData struct {
|
||||
ConnectType valueTypes.Integer `json:"connect_type"`
|
||||
ConnectTypeDesc valueTypes.String `json:"connect_type_desc"`
|
||||
ContactName valueTypes.String `json:"contact_name"`
|
||||
CountryID valueTypes.Integer `json:"country_id"`
|
||||
CountryId valueTypes.Integer `json:"country_id"`
|
||||
Description valueTypes.String `json:"description"`
|
||||
DesignCapacity valueTypes.Float `json:"design_capacity" PointUnit:"W"`
|
||||
DesignCapacityBattery valueTypes.Float `json:"design_capacity_battery" PointUnit:"W"`
|
||||
@ -53,7 +53,15 @@ type ResultData struct {
|
||||
GprsLatitude valueTypes.Float `json:"gprs_latitude"`
|
||||
GprsLongitude valueTypes.Float `json:"gprs_longitude"`
|
||||
GridLevel interface{} `json:"grid_level"`
|
||||
Images []valueTypes.String `json:"images"`
|
||||
Images []struct {
|
||||
FileID valueTypes.Integer `json:"file_id"`
|
||||
ID valueTypes.Integer `json:"id"`
|
||||
PicLanguage valueTypes.Integer `json:"pic_language"`
|
||||
PicType valueTypes.Integer `json:"pic_type"`
|
||||
PictureName valueTypes.String `json:"picture_name"`
|
||||
PictureURL valueTypes.String `json:"picture_url"`
|
||||
PsUnitUUID interface{} `json:"ps_unit_uuid"`
|
||||
} `json:"images"`
|
||||
InstallDate valueTypes.DateTime `json:"install_date"`
|
||||
InstallDateZone valueTypes.DateTime `json:"install_date_zone"`
|
||||
InverterCount valueTypes.Integer `json:"inverter_count"`
|
||||
@ -75,7 +83,7 @@ type ResultData struct {
|
||||
MlpeFlag valueTypes.Bool `json:"mlpe_flag"`
|
||||
MobileTel valueTypes.String `json:"moble_tel"`
|
||||
MobileTelBak valueTypes.String `json:"moble_tel_bak"`
|
||||
ModuleModelID interface{} `json:"module_model_id"`
|
||||
ModuleModelId interface{} `json:"module_model_id"`
|
||||
ModuleModelName valueTypes.String `json:"module_model_name"`
|
||||
Nmi valueTypes.String `json:"nmi"`
|
||||
OperationBusName valueTypes.String `json:"operation_bus_name"`
|
||||
@ -86,16 +94,16 @@ type ResultData struct {
|
||||
ProvinceCode valueTypes.String `json:"province_code"`
|
||||
ProvinceName valueTypes.String `json:"province_name"`
|
||||
PsBuildDate valueTypes.DateTime `json:"ps_build_date"`
|
||||
PsCountryID valueTypes.Integer `json:"ps_country_id"`
|
||||
PsCreateUserID valueTypes.Integer `json:"ps_create_user_id"`
|
||||
PsCountryId valueTypes.Integer `json:"ps_country_id"`
|
||||
PsCreateUserId valueTypes.Integer `json:"ps_create_user_id"`
|
||||
PsCurrentTimeZone valueTypes.String `json:"ps_current_time_zone"`
|
||||
PsDirectOrgList []struct {
|
||||
OrgID valueTypes.Integer `json:"org_id"`
|
||||
OrgId valueTypes.Integer `json:"org_id"`
|
||||
OrgIndexCode valueTypes.String `json:"org_index_code"`
|
||||
OrgName valueTypes.String `json:"org_name"`
|
||||
} `json:"ps_direct_org_list"`
|
||||
PsHolder valueTypes.String `json:"ps_holder"`
|
||||
PsID valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
PsInstalledPower valueTypes.Float `json:"ps_installed_power" PointUnit:"W"`
|
||||
PsKey valueTypes.PsKey `json:"ps_key"`
|
||||
PsLocation valueTypes.String `json:"ps_location"`
|
||||
@ -105,22 +113,22 @@ type ResultData struct {
|
||||
Installer valueTypes.String `json:"installer"`
|
||||
InstallerEmail valueTypes.String `json:"installer_email"`
|
||||
InstallerPhone valueTypes.String `json:"installer_phone"`
|
||||
OrgID valueTypes.Integer `json:"org_id"`
|
||||
OrgId valueTypes.Integer `json:"org_id"`
|
||||
OrgIndexCode valueTypes.String `json:"org_index_code"`
|
||||
OrgName valueTypes.String `json:"org_name"`
|
||||
PsDealerOrgCode valueTypes.String `json:"ps_dealer_org_code"`
|
||||
UpOrgID valueTypes.Integer `json:"up_org_id"`
|
||||
UpOrgId valueTypes.Integer `json:"up_org_id"`
|
||||
} `json:"ps_org_info"`
|
||||
PsPrice valueTypes.Float `json:"ps_price" PointUnitFrom:"ParamIncomeUnitName"`
|
||||
PsPriceKwh valueTypes.Float `json:"ps_price_kwh" PointUnitFrom:"ParamIncomeUnitName"`
|
||||
PsType valueTypes.Integer `json:"ps_type"`
|
||||
PsTypeDesc valueTypes.String `json:"ps_type_desc"`
|
||||
PsTypeName valueTypes.String `json:"ps_type_name"`
|
||||
PsUserID valueTypes.Integer `json:"ps_user_id"`
|
||||
PsUserId valueTypes.Integer `json:"ps_user_id"`
|
||||
RecordCreateTime valueTypes.DateTime `json:"recore_create_time" PointId:"record_create_time"`
|
||||
SafeStartDate valueTypes.DateTime `json:"safe_start_date"`
|
||||
SelectedOrgList []struct {
|
||||
OrgID valueTypes.Integer `json:"org_id"`
|
||||
OrgId valueTypes.Integer `json:"org_id"`
|
||||
OrgIndexCode valueTypes.String `json:"org_index_code"`
|
||||
OrgName valueTypes.String `json:"org_name"`
|
||||
} `json:"selectedOrgList" PointId:"selected_org_list"`
|
||||
@ -133,14 +141,14 @@ type ResultData struct {
|
||||
SnDetailList []struct {
|
||||
CommunicateDeviceType valueTypes.Integer `json:"communicate_device_type"`
|
||||
CommunicateDeviceTypeName valueTypes.String `json:"communicate_device_type_name"`
|
||||
ID valueTypes.Integer `json:"id"`
|
||||
Id valueTypes.Integer `json:"id"`
|
||||
IsEnable valueTypes.Bool `json:"is_enable"`
|
||||
Sn valueTypes.String `json:"sn" PointName:"Serial Number"`
|
||||
} `json:"sn_detail_list"`
|
||||
SummerTimeState valueTypes.Bool `json:"summer_time_state"`
|
||||
SummerTimeZone valueTypes.String `json:"summer_time_zone"`
|
||||
SummerTimeZoneID valueTypes.Integer `json:"summer_time_zone_id"`
|
||||
TimeZoneID valueTypes.Integer `json:"time_zone_id"`
|
||||
SummerTimeZoneId valueTypes.Integer `json:"summer_time_zone_id"`
|
||||
TimeZoneId valueTypes.Integer `json:"time_zone_id"`
|
||||
Timezone valueTypes.String `json:"timezone"`
|
||||
UserAccount valueTypes.String `json:"user_account"`
|
||||
UserCapacityStatus valueTypes.Integer `json:"user_capacity_status"`
|
||||
|
@ -12,7 +12,7 @@ const Url = "/v1/powerStationService/getPowerStationInfo"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -29,7 +29,7 @@ type ResultData struct {
|
||||
RemindType interface{} `json:"remindType" PointId:"remind_type"`
|
||||
|
||||
PowerStationMap struct {
|
||||
AreaID interface{} `json:"area_id"`
|
||||
AreaId interface{} `json:"area_id"`
|
||||
ConnectType valueTypes.Integer `json:"connect_type"`
|
||||
County interface{} `json:"county"`
|
||||
CountyCode interface{} `json:"county_code"`
|
||||
@ -51,10 +51,10 @@ type ResultData struct {
|
||||
Prov interface{} `json:"prov"`
|
||||
ProvCode interface{} `json:"prov_code"`
|
||||
PsBuildDate valueTypes.DateTime `json:"ps_build_date"`
|
||||
PsCountryID valueTypes.Integer `json:"ps_country_id"`
|
||||
PsCountryId valueTypes.Integer `json:"ps_country_id"`
|
||||
PsDesc interface{} `json:"ps_desc"`
|
||||
PsHolder valueTypes.String `json:"ps_holder"`
|
||||
PsID valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
PsLocation valueTypes.String `json:"ps_location"`
|
||||
PsName valueTypes.String `json:"ps_name"`
|
||||
PsType valueTypes.Integer `json:"ps_type"`
|
||||
@ -62,7 +62,7 @@ type ResultData struct {
|
||||
ReportType interface{} `json:"report_type"`
|
||||
ShippingAddress valueTypes.String `json:"shipping_address"`
|
||||
ShippingZipCode valueTypes.String `json:"shipping_zip_code"`
|
||||
TimeZoneID valueTypes.Integer `json:"time_zone_id"`
|
||||
TimeZoneId valueTypes.Integer `json:"time_zone_id"`
|
||||
ValidFlag valueTypes.Integer `json:"valid_flag"`
|
||||
Village interface{} `json:"village"`
|
||||
VillageCode interface{} `json:"village_code"`
|
||||
@ -76,19 +76,19 @@ type ResultData struct {
|
||||
InstallerEmail valueTypes.String `json:"installer_email"`
|
||||
InstallerPhone valueTypes.String `json:"installer_phone"`
|
||||
OrgURL interface{} `json:"org_url"`
|
||||
UpOrgID valueTypes.Integer `json:"up_org_id"`
|
||||
UpOrgId valueTypes.Integer `json:"up_org_id"`
|
||||
} `json:"installProviderInfo" PointId:"install_provider_info"`
|
||||
PowerChargeDataMap struct {
|
||||
CodeType valueTypes.Integer `json:"code_type"`
|
||||
DefaultCharge valueTypes.Float `json:"default_charge"`
|
||||
ElectricChargeID valueTypes.Integer `json:"electric_charge_id"`
|
||||
ElectricChargeId valueTypes.Integer `json:"electric_charge_id"`
|
||||
EndTime valueTypes.DateTime `json:"end_time"`
|
||||
IntervalTimeCharge interface{} `json:"interval_time_charge"`
|
||||
ParamIncomeUnitName valueTypes.String `json:"param_income_unit_name"`
|
||||
StartTime valueTypes.DateTime `json:"start_time"`
|
||||
} `json:"powerChargeDataMap" PointId:"power_charge_data_map"`
|
||||
SysTimeZones []struct {
|
||||
ID valueTypes.Integer `json:"id"`
|
||||
Id valueTypes.Integer `json:"id"`
|
||||
TimezoneName valueTypes.String `json:"timezone_name"`
|
||||
TimezoneUtc valueTypes.String `json:"timezone_utc"`
|
||||
} `json:"sysTimeZones" PointId:"sys_time_zones"`
|
||||
|
@ -12,7 +12,7 @@ const Url = "/v1/powerStationService/getPowerStatistics"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -25,7 +25,7 @@ func (rd RequestData) Help() string {
|
||||
}
|
||||
|
||||
type ResultData struct {
|
||||
City interface{} `json:"city"`
|
||||
City valueTypes.String `json:"city"`
|
||||
PsName valueTypes.String `json:"ps_name"`
|
||||
PsShortName valueTypes.String `json:"ps_short_name"`
|
||||
Status1 valueTypes.Integer `json:"status1"`
|
||||
|
@ -12,7 +12,7 @@ const Url = "/v1/powerStationService/getPsDetail"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -27,8 +27,8 @@ func (rd RequestData) Help() string {
|
||||
type ResultData struct {
|
||||
ActualEnergy []valueTypes.Float `json:"actual_energy" PointId:"actual_energy" PointName:"Actual Energy" PointUnitFrom:"ActualEnergyUnit"`
|
||||
ActualEnergyUnit valueTypes.String `json:"actual_energy_unit" PointId:"actual_energy_unit" PointIgnore:"true"`
|
||||
AlarmCount valueTypes.Integer `json:"alarm_count"`
|
||||
AreaID interface{} `json:"area_id"`
|
||||
AlarmCount valueTypes.Count `json:"alarm_count"`
|
||||
AreaId interface{} `json:"area_id"`
|
||||
AreaType valueTypes.Integer `json:"area_type"`
|
||||
BuildDate valueTypes.DateTime `json:"build_date"`
|
||||
Co2Reduce valueTypes.UnitValue `json:"co2_reduce"`
|
||||
@ -47,7 +47,7 @@ type ResultData struct {
|
||||
DiagramURL valueTypes.String `json:"diagram_url"`
|
||||
EnergyScheme interface{} `json:"energy_scheme"`
|
||||
ExpectInstallDate valueTypes.DateTime `json:"expect_install_date"`
|
||||
FaultCount valueTypes.Integer `json:"fault_count"`
|
||||
FaultCount valueTypes.Count `json:"fault_count"`
|
||||
FaultSendType string `json:"fault_send_type"`
|
||||
GcjLatitude valueTypes.Float `json:"gcj_latitude"`
|
||||
GcjLongitude valueTypes.Float `json:"gcj_longitude"`
|
||||
@ -159,7 +159,7 @@ type ResultData struct {
|
||||
PowderReduceTotal valueTypes.UnitValue `json:"powder_reduce_total" PointId:"powder_reduce_total" PointUpdateFreq:"UpdateFreqTotal"`
|
||||
PowerChargeSetted valueTypes.Bool `json:"power_charge_setted" PointId:"power_charge_set" PointUpdateFreq:"UpdateFreqTotal"`
|
||||
Producer string `json:"producer"`
|
||||
PsCountryID valueTypes.Integer `json:"ps_country_id"`
|
||||
PsCountryId valueTypes.Integer `json:"ps_country_id"`
|
||||
PsFaultStatus valueTypes.Integer `json:"ps_fault_status"`
|
||||
PsHealthStatus valueTypes.Integer `json:"ps_health_status"`
|
||||
PsHolder valueTypes.String `json:"ps_holder"`
|
||||
@ -180,7 +180,7 @@ type ResultData struct {
|
||||
So2Reduce valueTypes.UnitValue `json:"so2_reduce"`
|
||||
So2ReduceTotal valueTypes.UnitValue `json:"so2_reduce_total" PointId:"so2_reduce_total" PointUpdateFreq:"UpdateFreqTotal"`
|
||||
SysScheme valueTypes.Integer `json:"sys_scheme"`
|
||||
TimeZoneID valueTypes.Integer `json:"time_zone_id"`
|
||||
TimeZoneId valueTypes.Integer `json:"time_zone_id"`
|
||||
Timezone valueTypes.String `json:"timezone"`
|
||||
TodayEnergy valueTypes.UnitValue `json:"today_energy" PointId:"today_energy" PointUpdateFreq:"UpdateFreqDay"`
|
||||
TodayEnergyVirgin valueTypes.UnitValue `json:"today_energy_virgin" PointIgnore:"true"`
|
||||
@ -193,7 +193,7 @@ type ResultData struct {
|
||||
TreeReduceTotal valueTypes.UnitValue `json:"tree_reduce_total" PointId:"tree_reduce_total" PointUpdateFreq:"UpdateFreqTotal"`
|
||||
TuvLevel string `json:"tuv_level"`
|
||||
ValidFlag valueTypes.Bool `json:"valid_flag"`
|
||||
WaitAssignOrderCount valueTypes.Integer `json:"wait_assign_order_count"`
|
||||
WaitAssignOrderCount valueTypes.Count `json:"wait_assign_order_count"`
|
||||
WaterReduce valueTypes.UnitValue `json:"water_reduce"`
|
||||
WaterReduceTotal valueTypes.UnitValue `json:"water_reduce_total" PointId:"water_reduce_total" PointUpdateFreq:"UpdateFreqTotal"`
|
||||
WgsLatitude valueTypes.Float `json:"wgs_latitude"`
|
||||
@ -210,8 +210,8 @@ type ResultData struct {
|
||||
SweepCapacity valueTypes.Float `json:"sweep_capacity"`
|
||||
} `json:"robot_num_sweep_capacity"`
|
||||
Images []struct {
|
||||
FileID valueTypes.Integer `json:"file_id"`
|
||||
ID valueTypes.Integer `json:"id"`
|
||||
FileId valueTypes.Integer `json:"file_id"`
|
||||
Id valueTypes.Integer `json:"id"`
|
||||
PicLanguage valueTypes.Integer `json:"pic_language"`
|
||||
PicType valueTypes.Integer `json:"pic_type"`
|
||||
PictureName valueTypes.String `json:"picture_name"`
|
||||
|
@ -13,7 +13,7 @@ const Url = "/v1/powerStationService/getPsDetailWithPsType"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -75,7 +75,7 @@ type ResultData struct {
|
||||
PowerChargeSetted valueTypes.Bool `json:"power_charge_setted" PointId:"power_charge_set" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
PowerGridPowerMap valueTypes.UnitValue `json:"power_grid_power_map" PointId:"power_grid_power_map" PointUpdateFreq:"UpdateFreq5Mins"`
|
||||
PowerGridPowerMapVirgin valueTypes.UnitValue `json:"power_grid_power_map_virgin" PointIgnore:"true"`
|
||||
PsCountryID valueTypes.Integer `json:"ps_country_id" PointId:"ps_country_id" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
PsCountryId valueTypes.Integer `json:"ps_country_id" PointId:"ps_country_id" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
PsDeviceType valueTypes.Integer `json:"ps_device_type" PointId:"ps_device_type" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
PsFaultStatus valueTypes.Integer `json:"ps_fault_status" PointId:"ps_fault_status" PointUpdateFreq:"UpdateFreqInstant"`
|
||||
PsHealthStatus valueTypes.Integer `json:"ps_health_status" PointId:"ps_health_status" PointUpdateFreq:"UpdateFreqInstant"`
|
||||
|
@ -12,7 +12,7 @@ const Url = "/v1/powerStationService/getPsHealthState"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
|
@ -26,10 +26,10 @@ func (rd RequestData) Help() string {
|
||||
|
||||
type ResultData struct {
|
||||
PageList []struct {
|
||||
AlarmCount valueTypes.Integer `json:"alarm_count" PointId:"alarm_count" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
AlarmDevCount valueTypes.Integer `json:"alarm_dev_count" PointId:"alarm_dev_count" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
AreaID interface{} `json:"area_id" PointId:"area_id"`
|
||||
AreaType interface{} `json:"area_type" PointId:"area_type"`
|
||||
AlarmCount valueTypes.Count `json:"alarm_count" PointId:"alarm_count" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
AlarmDevCount valueTypes.Count `json:"alarm_dev_count" PointId:"alarm_dev_count" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
AreaId interface{} `json:"area_id" PointId:"area_id"`
|
||||
AreaType valueTypes.Integer `json:"area_type" PointId:"area_type"`
|
||||
ArrearsStatus valueTypes.Integer `json:"arrears_status" PointId:"arrears_status"`
|
||||
BuildDate valueTypes.DateTime `json:"build_date" PointId:"build_date" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
BuildStatus valueTypes.Integer `json:"build_status" PointId:"build_status" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
@ -48,28 +48,28 @@ type ResultData struct {
|
||||
EsTotalDischargeEnergy valueTypes.UnitValue `json:"es_total_disenergy" PointId:"p83095" PointName:"ES Total Discharge Energy" PointUpdateFreq:"UpdateFreqTotal"`
|
||||
EsTotalEnergy valueTypes.UnitValue `json:"es_total_energy" PointId:"p83127" PointName:"ES Total Energy" PointUpdateFreq:"UpdateFreqTotal"`
|
||||
ExpectInstallDate valueTypes.DateTime `json:"expect_install_date" PointId:"expect_install_date"`
|
||||
FaultAlarmOfflineDevCount valueTypes.Integer `json:"fault_alarm_offline_dev_count" PointId:"fault_alarm_offline_dev_count"`
|
||||
FaultCount valueTypes.Integer `json:"fault_count" PointId:"fault_count"`
|
||||
FaultDevCount valueTypes.Integer `json:"fault_dev_count" PointId:"fault_dev_count"`
|
||||
FaultAlarmOfflineDevCount valueTypes.Count `json:"fault_alarm_offline_dev_count" PointId:"fault_alarm_offline_dev_count"`
|
||||
FaultCount valueTypes.Count `json:"fault_count" PointId:"fault_count"`
|
||||
FaultDevCount valueTypes.Count `json:"fault_dev_count" PointId:"fault_dev_count"`
|
||||
GcjLatitude valueTypes.Float `json:"gcj_latitude" PointId:"gcj_latitude"`
|
||||
GcjLongitude valueTypes.Float `json:"gcj_longitude" PointId:"gcj_longitude"`
|
||||
GprsLatitude valueTypes.Float `json:"gprs_latitude" PointId:"gprs_latitude"`
|
||||
GprsLongitude valueTypes.Float `json:"gprs_longitude" PointId:"gprs_longitude"`
|
||||
Images []struct {
|
||||
FileID valueTypes.Integer `json:"file_id"`
|
||||
ID valueTypes.Integer `json:"id"`
|
||||
FileId valueTypes.Integer `json:"file_id"`
|
||||
Id valueTypes.Integer `json:"id"`
|
||||
PicLanguage valueTypes.Integer `json:"pic_language"`
|
||||
PicType valueTypes.Integer `json:"pic_type"`
|
||||
PictureName valueTypes.String `json:"picture_name"`
|
||||
PictureURL valueTypes.String `json:"picture_url"`
|
||||
PsID valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
PsUnitUUID interface{} `json:"ps_unit_uuid"`
|
||||
} `json:"images" PointName:"Images"`
|
||||
InstallDate valueTypes.DateTime `json:"install_date" PointId:"install_date"`
|
||||
InstalledPowerMap valueTypes.UnitValue `json:"installed_power_map" PointId:"installed_power_map"`
|
||||
InstalledPowerVirgin valueTypes.Float `json:"installed_power_virgin" PointIgnore:"true"`
|
||||
InstallerAlarmCount valueTypes.Integer `json:"installer_alarm_count" PointId:"installer_alarm_count"`
|
||||
InstallerFaultCount valueTypes.Integer `json:"installer_fault_count" PointId:"installer_fault_count"`
|
||||
InstallerAlarmCount valueTypes.Count `json:"installer_alarm_count" PointId:"installer_alarm_count"`
|
||||
InstallerFaultCount valueTypes.Count `json:"installer_fault_count" PointId:"installer_fault_count"`
|
||||
InstallerPsFaultStatus valueTypes.Integer `json:"installer_ps_fault_status" PointId:"installer_ps_fault_status"`
|
||||
IsBankPs valueTypes.Bool `json:"is_bank_ps" PointId:"is_bank_ps"`
|
||||
IsTuv valueTypes.Bool `json:"is_tuv" PointId:"is_tuv"`
|
||||
@ -81,11 +81,11 @@ type ResultData struct {
|
||||
MapLongitude valueTypes.Float `json:"map_longitude" PointId:"map_longitude"`
|
||||
MlpeFlag valueTypes.Integer `json:"mlpe_flag" PointId:"mlpe_flag"`
|
||||
Nmi valueTypes.String `json:"nmi" PointId:"nmi"`
|
||||
OfflineDevCount valueTypes.Integer `json:"offline_dev_count" PointId:"offline_dev_count"`
|
||||
OfflineDevCount valueTypes.Count `json:"offline_dev_count" PointId:"offline_dev_count"`
|
||||
OperateYear interface{} `json:"operate_year" PointId:"operate_year"`
|
||||
OperationBusName valueTypes.String `json:"operation_bus_name" PointId:"operation_bus_name"`
|
||||
OwnerAlarmCount valueTypes.Integer `json:"owner_alarm_count" PointId:"owner_alarm_count"`
|
||||
OwnerFaultCount valueTypes.Integer `json:"owner_fault_count" PointId:"owner_fault_count"`
|
||||
OwnerAlarmCount valueTypes.Count `json:"owner_alarm_count" PointId:"owner_alarm_count"`
|
||||
OwnerFaultCount valueTypes.Count `json:"owner_fault_count" PointId:"owner_fault_count"`
|
||||
OwnerPsFaultStatus valueTypes.Integer `json:"owner_ps_fault_status" PointId:"owner_ps_fault_status"`
|
||||
P83022y valueTypes.String `json:"p83022y" PointId:"p83022" PointUpdateFreq:"UpdateFreq5Mins"`
|
||||
P83046 valueTypes.Float `json:"p83046" PointId:"p83046" PointUpdateFreq:"UpdateFreq5Mins"`
|
||||
@ -116,11 +116,11 @@ type ResultData struct {
|
||||
ParamWater valueTypes.Float `json:"param_water" PointId:"param_water"`
|
||||
PrScale string `json:"pr_scale" PointId:"pr_scale"`
|
||||
Producer interface{} `json:"producer" PointId:"producer"`
|
||||
PsCountryID valueTypes.Integer `json:"ps_country_id" PointId:"ps_country_id"`
|
||||
PsCountryId valueTypes.Integer `json:"ps_country_id" PointId:"ps_country_id"`
|
||||
PsFaultStatus valueTypes.Integer `json:"ps_fault_status" PointId:"ps_fault_status"`
|
||||
PsHealthStatus valueTypes.Integer `json:"ps_health_status" PointId:"ps_health_status"`
|
||||
PsHolder valueTypes.String `json:"ps_holder" PointId:"ps_holder"`
|
||||
PsId valueTypes.Integer `json:"ps_id" PointId:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id" PointId:"ps_id"`
|
||||
PsIsNotInit valueTypes.Bool `json:"ps_is_not_init" PointId:"ps_is_not_init"`
|
||||
PsName valueTypes.String `json:"ps_name" PointId:"ps_name"`
|
||||
PsShortName valueTypes.String `json:"ps_short_name" PointId:"ps_short_name"`
|
||||
@ -150,7 +150,7 @@ type ResultData struct {
|
||||
WgsLongitude valueTypes.Float `json:"wgs_longitude" PointId:"wgs_longitude"`
|
||||
ZipCode valueTypes.String `json:"zip_code" PointId:"zip_code"`
|
||||
} `json:"pageList" PointNameFromChild:"PsId"`
|
||||
RowCount valueTypes.Integer `json:"rowCount" PointIgnore:"true"`
|
||||
RowCount valueTypes.Count `json:"rowCount" PointIgnore:"true"`
|
||||
}
|
||||
|
||||
func (e *ResultData) IsValid() error {
|
||||
@ -180,7 +180,7 @@ type Device struct {
|
||||
PsFaultStatus valueTypes.Integer
|
||||
PsHealthStatus valueTypes.Integer
|
||||
PsHolder valueTypes.String
|
||||
PsID valueTypes.Integer
|
||||
PsId valueTypes.PsId
|
||||
PsName valueTypes.String
|
||||
PsShortName valueTypes.String
|
||||
PsStatus valueTypes.Integer
|
||||
@ -195,7 +195,7 @@ func (e *ResultData) GetPsDevices() Devices {
|
||||
PsFaultStatus: d.PsFaultStatus,
|
||||
PsHealthStatus: d.PsHealthStatus,
|
||||
PsHolder: d.PsHolder,
|
||||
PsID: d.PsId,
|
||||
PsId: d.PsId,
|
||||
PsName: d.PsName,
|
||||
PsShortName: d.PsShortName,
|
||||
PsStatus: d.PsStatus,
|
||||
@ -205,8 +205,8 @@ func (e *ResultData) GetPsDevices() Devices {
|
||||
return ret
|
||||
}
|
||||
|
||||
func (e *ResultData) GetPsIds() []valueTypes.Integer {
|
||||
var ret []valueTypes.Integer
|
||||
func (e *ResultData) GetPsIds() []valueTypes.PsId {
|
||||
var ret []valueTypes.PsId
|
||||
for range Only.Once {
|
||||
i := len(e.PageList)
|
||||
if i == 0 {
|
||||
@ -253,6 +253,6 @@ func (e *ResultData) GetPsSerial() []string {
|
||||
return ret
|
||||
}
|
||||
|
||||
func (e *EndPoint) GetPsIds() []valueTypes.Integer {
|
||||
func (e *EndPoint) GetPsIds() []valueTypes.PsId {
|
||||
return e.Response.ResultData.GetPsIds()
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"GoSungrow/iSolarCloud/api"
|
||||
"GoSungrow/iSolarCloud/api/apiReflect"
|
||||
"GoSungrow/iSolarCloud/api/valueTypes"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
"fmt"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
)
|
||||
|
||||
const Url = "/v1/powerStationService/getPsListByName"
|
||||
@ -25,12 +25,12 @@ func (rd RequestData) Help() string {
|
||||
}
|
||||
|
||||
type ResultData []struct {
|
||||
PsID valueTypes.Integer `json:"ps_id"`
|
||||
PsName valueTypes.String `json:"ps_name"`
|
||||
PsShortName valueTypes.String `json:"ps_short_name"`
|
||||
PsTimezone valueTypes.String `json:"ps_timezone"`
|
||||
PsTimezoneID valueTypes.Integer `json:"ps_timezone_id"`
|
||||
ShareType string `json:"share_type"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
PsName valueTypes.String `json:"ps_name"`
|
||||
PsShortName valueTypes.String `json:"ps_short_name"`
|
||||
PsTimezone valueTypes.String `json:"ps_timezone"`
|
||||
PsTimezoneId valueTypes.Integer `json:"ps_timezone_id"`
|
||||
ShareType valueTypes.Integer `json:"share_type"`
|
||||
}
|
||||
|
||||
func (e *ResultData) IsValid() error {
|
||||
@ -44,30 +44,14 @@ func (e *ResultData) IsValid() error {
|
||||
return err
|
||||
}
|
||||
|
||||
//type DecodeResultData ResultData
|
||||
//
|
||||
//func (e *ResultData) UnmarshalJSON(data []byte) error {
|
||||
// var err error
|
||||
//
|
||||
// for range Only.Once {
|
||||
// if len(data) == 0 {
|
||||
// break
|
||||
// }
|
||||
// var pd DecodeResultData
|
||||
//
|
||||
// // Store ResultData
|
||||
// _ = json.Unmarshal(data, &pd)
|
||||
// e.Dummy = pd.Dummy
|
||||
// }
|
||||
//
|
||||
// return err
|
||||
//}
|
||||
|
||||
func (e *EndPoint) GetData() api.DataMap {
|
||||
entries := api.NewDataMap()
|
||||
|
||||
for range Only.Once {
|
||||
entries.StructToPoints(e.Response.ResultData, apiReflect.GetName("", *e), "system", valueTypes.NewDateTime(""))
|
||||
pkg := apiReflect.GetName("", *e)
|
||||
dt := valueTypes.NewDateTime(valueTypes.Now)
|
||||
// name := pkg + "." + e.Request.PsId.String()
|
||||
entries.StructToPoints(e.Response.ResultData, pkg, "system", dt)
|
||||
}
|
||||
|
||||
return entries
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"GoSungrow/iSolarCloud/api"
|
||||
"GoSungrow/iSolarCloud/api/apiReflect"
|
||||
"GoSungrow/iSolarCloud/api/valueTypes"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
"fmt"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
)
|
||||
|
||||
const Url = "/v1/powerStationService/getPsListStaticData"
|
||||
@ -26,27 +26,27 @@ func (rd RequestData) Help() string {
|
||||
|
||||
type ResultData struct {
|
||||
PageList []struct {
|
||||
AreaID interface{} `json:"area_id"`
|
||||
DesignCapacity valueTypes.Float `json:"design_capacity"`
|
||||
GprsLatitude valueTypes.Float `json:"gprs_latitude"`
|
||||
GprsLongitude valueTypes.Float `json:"gprs_longitude"`
|
||||
InstallDate valueTypes.DateTime `json:"install_date"`
|
||||
InstallerPsFaultStatus valueTypes.Integer `json:"installer_ps_fault_status"`
|
||||
Latitude valueTypes.Float `json:"latitude"`
|
||||
Location valueTypes.String `json:"location"`
|
||||
Longitude valueTypes.Float `json:"longitude"`
|
||||
MapLatitude valueTypes.Float `json:"map_latitude"`
|
||||
MapLongitude valueTypes.Float `json:"map_longitude"`
|
||||
OwnerPsFaultStatus valueTypes.Integer `json:"owner_ps_fault_status"`
|
||||
PsFaultStatus valueTypes.Integer `json:"ps_fault_status"`
|
||||
PsID valueTypes.Integer `json:"ps_id"`
|
||||
PsName valueTypes.String `json:"ps_name"`
|
||||
PsShortName valueTypes.String `json:"ps_short_name"`
|
||||
PsStatus valueTypes.Integer `json:"ps_status"`
|
||||
PsType valueTypes.Integer `json:"ps_type"`
|
||||
ValidFlag valueTypes.Integer `json:"valid_flag"`
|
||||
WaitAssignOrderCount valueTypes.Integer `json:"wait_assign_order_count"`
|
||||
} `json:"pageList"`
|
||||
AreaId interface{} `json:"area_id"`
|
||||
DesignCapacity valueTypes.Float `json:"design_capacity" PointUnit:"W"`
|
||||
GprsLatitude valueTypes.Float `json:"gprs_latitude"`
|
||||
GprsLongitude valueTypes.Float `json:"gprs_longitude"`
|
||||
InstallDate valueTypes.DateTime `json:"install_date"`
|
||||
InstallerPsFaultStatus valueTypes.Integer `json:"installer_ps_fault_status"`
|
||||
Latitude valueTypes.Float `json:"latitude"`
|
||||
Location valueTypes.String `json:"location"`
|
||||
Longitude valueTypes.Float `json:"longitude"`
|
||||
MapLatitude valueTypes.Float `json:"map_latitude"`
|
||||
MapLongitude valueTypes.Float `json:"map_longitude"`
|
||||
OwnerPsFaultStatus valueTypes.Integer `json:"owner_ps_fault_status"`
|
||||
PsFaultStatus valueTypes.Integer `json:"ps_fault_status"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
PsName valueTypes.String `json:"ps_name"`
|
||||
PsShortName valueTypes.String `json:"ps_short_name"`
|
||||
PsStatus valueTypes.Integer `json:"ps_status"`
|
||||
PsType valueTypes.Integer `json:"ps_type"`
|
||||
ValidFlag valueTypes.Bool `json:"valid_flag"`
|
||||
WaitAssignOrderCount valueTypes.Integer `json:"wait_assign_order_count"`
|
||||
} `json:"pageList" PointId:"page_list" PointNameFromChild:"PsId" PointNameFromAppend:"false"`
|
||||
RowCount valueTypes.Integer `json:"rowCount"`
|
||||
}
|
||||
|
||||
@ -61,30 +61,14 @@ func (e *ResultData) IsValid() error {
|
||||
return err
|
||||
}
|
||||
|
||||
//type DecodeResultData ResultData
|
||||
//
|
||||
//func (e *ResultData) UnmarshalJSON(data []byte) error {
|
||||
// var err error
|
||||
//
|
||||
// for range Only.Once {
|
||||
// if len(data) == 0 {
|
||||
// break
|
||||
// }
|
||||
// var pd DecodeResultData
|
||||
//
|
||||
// // Store ResultData
|
||||
// _ = json.Unmarshal(data, &pd)
|
||||
// e.Dummy = pd.Dummy
|
||||
// }
|
||||
//
|
||||
// return err
|
||||
//}
|
||||
|
||||
func (e *EndPoint) GetData() api.DataMap {
|
||||
entries := api.NewDataMap()
|
||||
|
||||
for range Only.Once {
|
||||
entries.StructToPoints(e.Response.ResultData, apiReflect.GetName("", *e), "system", valueTypes.NewDateTime(""))
|
||||
pkg := apiReflect.GetName("", *e)
|
||||
dt := valueTypes.NewDateTime(valueTypes.Now)
|
||||
// name := pkg + "." + e.Request.PsId.String()
|
||||
entries.StructToPoints(e.Response.ResultData, pkg, "system", dt)
|
||||
}
|
||||
|
||||
return entries
|
||||
|
@ -4,16 +4,16 @@ import (
|
||||
"GoSungrow/iSolarCloud/api"
|
||||
"GoSungrow/iSolarCloud/api/apiReflect"
|
||||
"GoSungrow/iSolarCloud/api/valueTypes"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
"fmt"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
)
|
||||
|
||||
const Url = "/v1/reportService/getPsReport"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
ReportType string `json:"report_type" required:"true"`
|
||||
DateID string `json:"date_id" required:"true"`
|
||||
ReportType valueTypes.Integer `json:"report_type" required:"true"`
|
||||
DateId valueTypes.DateTime `json:"date_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -21,61 +21,57 @@ func (rd RequestData) IsValid() error {
|
||||
}
|
||||
|
||||
func (rd RequestData) Help() string {
|
||||
ret := fmt.Sprintf("")
|
||||
ret := fmt.Sprintf("report_type: One of 1, 2, 5")
|
||||
ret += api.HelpDataType()
|
||||
return ret
|
||||
}
|
||||
|
||||
type ResultData struct {
|
||||
PsDateRangeTotalData struct {
|
||||
Co2Reduce valueTypes.Float `json:"co2_reduce"`
|
||||
Co2ReduceMap valueTypes.UnitValue `json:"co2_reduce_map"`
|
||||
Co2ReduceOriginalUnit valueTypes.String `json:"co2_reduce_original_unit"`
|
||||
PowerQuantityTotal valueTypes.Float `json:"power_quantity_total"`
|
||||
PowerQuantityTotalMap valueTypes.UnitValue `json:"power_quantity_total_map"`
|
||||
PowerQuantityTotalOriginalUnit valueTypes.String `json:"power_quantity_total_original_unit"`
|
||||
ProfitList ProfitList `json:"profit_list"`
|
||||
TotalProfit valueTypes.Float `json:"total_profit"`
|
||||
} `json:"ps_date_range_total_data"`
|
||||
PsTotalData struct {
|
||||
Co2Reduce valueTypes.Float `json:"co2_reduce"`
|
||||
Co2ReduceMap valueTypes.UnitValue `json:"co2_reduce_map"`
|
||||
Co2ReduceOriginalUnit valueTypes.String `json:"co2_reduce_original_unit"`
|
||||
MinDateID valueTypes.DateTime `json:"min_date_id"`
|
||||
PowerQuantityTotal valueTypes.Float `json:"power_quantity_total"`
|
||||
PowerQuantityTotalMap valueTypes.UnitValue `json:"power_quantity_total_map"`
|
||||
PowerQuantityTotalOriginalUnit valueTypes.String `json:"power_quantity_total_original_unit"`
|
||||
ProfitList ProfitList `json:"profit_list"`
|
||||
TotalProfit valueTypes.Float `json:"total_profit"`
|
||||
} `json:"ps_total_data"`
|
||||
ReportListData struct {
|
||||
Co2ReduceUnit valueTypes.String `json:"co2_reduce_unit"`
|
||||
PsDateRangeTotalData TotalData `json:"ps_date_range_total_data"`
|
||||
PsTotalData TotalData `json:"ps_total_data"`
|
||||
ReportListData struct {
|
||||
PageList []struct {
|
||||
Co2Reduce valueTypes.Float `json:"co2_reduce"`
|
||||
IncomeUnitName valueTypes.String `json:"income_unit_name"`
|
||||
PowerQuantityTotal valueTypes.Float `json:"power_quantity_total"`
|
||||
PsID valueTypes.Integer`json:"ps_id"`
|
||||
PsInstalledPower valueTypes.Float `json:"ps_installed_power"`
|
||||
PsName valueTypes.String `json:"ps_name"`
|
||||
PsTotalCo2Reduce valueTypes.Float `json:"ps_total_co2_reduce"`
|
||||
PsTotalPower valueTypes.Float `json:"ps_total_power"`
|
||||
PsType valueTypes.Integer`json:"ps_type"`
|
||||
ShareType string `json:"share_type"`
|
||||
ProfitList ProfitList `json:"profit_list"`
|
||||
TotalProfit valueTypes.Float `json:"total_profit"`
|
||||
} `json:"pageList"`
|
||||
PowerQuantityTotalUnit valueTypes.String `json:"power_quantity_total_unit"`
|
||||
PsInstalledPowerUnit valueTypes.String `json:"ps_installed_power_unit"`
|
||||
PsTotalCo2ReduceUnit valueTypes.String `json:"ps_total_co2_reduce_unit"`
|
||||
PsTotalPowerUnit valueTypes.String `json:"ps_total_power_unit"`
|
||||
RowCount valueTypes.Integer `json:"rowCount"`
|
||||
} `json:"report_list_data"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
PsName valueTypes.String `json:"ps_name"`
|
||||
PsType valueTypes.Integer `json:"ps_type"`
|
||||
ShareType valueTypes.String `json:"share_type"`
|
||||
Co2Reduce valueTypes.Float `json:"co2_reduce" PointUnitFromParent:"PsTotalCo2ReduceUnit"`
|
||||
PowerQuantityTotal valueTypes.Float `json:"power_quantity_total" PointUnitFromParent:"PowerQuantityTotalUnit"`
|
||||
PsInstalledPower valueTypes.Float `json:"ps_installed_power" PointUnitFromParent:"PsInstalledPowerUnit"`
|
||||
PsTotalCo2Reduce valueTypes.Float `json:"ps_total_co2_reduce" PointUnitFromParent:"PsTotalCo2ReduceUnit"`
|
||||
PsTotalPower valueTypes.Float `json:"ps_total_power" PointUnitFromParent:"PsTotalPowerUnit"`
|
||||
TotalProfit valueTypes.Float `json:"total_profit" PointUnitFrom:"IncomeUnitName"`
|
||||
IncomeUnitName valueTypes.String `json:"income_unit_name" PointIgnore:"true"`
|
||||
ProfitList ProfitList `json:"profit_list"`
|
||||
} `json:"pageList" PointId:"page_list" PointNameFromChild:"PsId" PointNameFromAppend:"false"`
|
||||
Co2ReduceUnit valueTypes.String `json:"co2_reduce_unit" PointIgnore:"true"`
|
||||
PowerQuantityTotalUnit valueTypes.String `json:"power_quantity_total_unit" PointIgnore:"true"`
|
||||
PsInstalledPowerUnit valueTypes.String `json:"ps_installed_power_unit" PointIgnore:"true"`
|
||||
PsTotalCo2ReduceUnit valueTypes.String `json:"ps_total_co2_reduce_unit" PointIgnore:"true"`
|
||||
PsTotalPowerUnit valueTypes.String `json:"ps_total_power_unit" PointIgnore:"true"`
|
||||
RowCount valueTypes.Integer `json:"rowCount" PointId:"row_count"`
|
||||
} `json:"report_list_data" PointId:"total_by_ps" PointNameFromAppend:"false"`
|
||||
}
|
||||
|
||||
type TotalData struct {
|
||||
MinDateId valueTypes.DateTime `json:"min_date_id"`
|
||||
|
||||
Co2Reduce valueTypes.Float `json:"co2_reduce" PointUnitFrom:"Co2ReduceOriginalUnit"`
|
||||
Co2ReduceMap valueTypes.UnitValue `json:"co2_reduce_map"`
|
||||
Co2ReduceOriginalUnit valueTypes.String `json:"co2_reduce_original_unit" PointIgnore:"true"`
|
||||
|
||||
PowerQuantityTotal valueTypes.Float `json:"power_quantity_total" PointUnitFrom:"PowerQuantityTotalOriginalUnit"`
|
||||
PowerQuantityTotalMap valueTypes.UnitValue `json:"power_quantity_total_map"`
|
||||
PowerQuantityTotalOriginalUnit valueTypes.String `json:"power_quantity_total_original_unit" PointIgnore:"true"`
|
||||
|
||||
ProfitList ProfitList `json:"profit_list"`
|
||||
TotalProfit valueTypes.Float `json:"total_profit" PointUnitFrom:"IncomeUnitName"`
|
||||
}
|
||||
|
||||
type ProfitList []struct {
|
||||
IncomeUnitID valueTypes.Integer `json:"income_unit_id"`
|
||||
IncomeUnitName valueTypes.String `json:"income_unit_name"`
|
||||
TotalProfit valueTypes.Float `json:"total_profit"`
|
||||
IncomeUnitId valueTypes.Integer `json:"income_unit_id"`
|
||||
IncomeUnitName valueTypes.String `json:"income_unit_name" PointIgnore:"true"`
|
||||
TotalProfit valueTypes.Float `json:"total_profit" PointUnitFrom:"IncomeUnitName"`
|
||||
}
|
||||
|
||||
func (e *ResultData) IsValid() error {
|
||||
@ -89,30 +85,14 @@ func (e *ResultData) IsValid() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// type DecodeResultData ResultData
|
||||
//
|
||||
// func (e *ResultData) UnmarshalJSON(data []byte) error {
|
||||
// var err error
|
||||
//
|
||||
// for range Only.Once {
|
||||
// if len(data) == 0 {
|
||||
// break
|
||||
// }
|
||||
// var pd DecodeResultData
|
||||
//
|
||||
// // Store ResultData
|
||||
// _ = json.Unmarshal(data, &pd)
|
||||
// e.Dummy = pd.Dummy
|
||||
// }
|
||||
//
|
||||
// return err
|
||||
// }
|
||||
|
||||
func (e *EndPoint) GetData() api.DataMap {
|
||||
entries := api.NewDataMap()
|
||||
|
||||
for range Only.Once {
|
||||
entries.StructToPoints(e.Response.ResultData, apiReflect.GetName("", *e), "system", valueTypes.NewDateTime(""))
|
||||
pkg := apiReflect.GetName("", *e)
|
||||
dt := valueTypes.NewDateTime(valueTypes.Now)
|
||||
name := pkg + "." + e.Request.DateId.Format(valueTypes.DateTimeLayoutDay)
|
||||
entries.StructToPoints(e.Response.ResultData, name, e.Request.DateId.String(), dt)
|
||||
}
|
||||
|
||||
return entries
|
||||
|
@ -27,10 +27,10 @@ func (rd RequestData) Help() string {
|
||||
type ResultData struct {
|
||||
BackgroundColor valueTypes.Integer `json:"background_color"`
|
||||
BloodType valueTypes.String `json:"blood_type"`
|
||||
CountryID valueTypes.Integer `json:"country_id"`
|
||||
CountryId valueTypes.Integer `json:"country_id"`
|
||||
CountryName valueTypes.String `json:"country_name"`
|
||||
CreateDate valueTypes.DateTime `json:"create_date"`
|
||||
CreateUserID valueTypes.Integer `json:"create_user_id"`
|
||||
CreateUserId valueTypes.Integer `json:"create_user_id"`
|
||||
DiseaseHis valueTypes.String `json:"disease_his"`
|
||||
Email valueTypes.String `json:"email"`
|
||||
EnglishName valueTypes.String `json:"english_name"`
|
||||
@ -46,19 +46,19 @@ type ResultData struct {
|
||||
LackOfInformation valueTypes.Integer `json:"lack_of_information"`
|
||||
Language valueTypes.String `json:"language"`
|
||||
MobileTel valueTypes.String `json:"moble_tel"`
|
||||
OrgID valueTypes.Integer `json:"org_id"`
|
||||
PhotoID valueTypes.Integer `json:"photo_id"`
|
||||
OrgId valueTypes.Integer `json:"org_id"`
|
||||
PhotoId valueTypes.Integer `json:"photo_id"`
|
||||
PhotoURL valueTypes.String `json:"photo_url"`
|
||||
RootOrgID valueTypes.Integer `json:"root_org_id"`
|
||||
RootOrgId valueTypes.Integer `json:"root_org_id"`
|
||||
Sex valueTypes.String `json:"sex"`
|
||||
Stylename valueTypes.String `json:"stylename"`
|
||||
TimeZoneID valueTypes.Integer `json:"time_zone_id"`
|
||||
TimeZoneId valueTypes.Integer `json:"time_zone_id"`
|
||||
Timezone valueTypes.String `json:"timezone"`
|
||||
UserAccount valueTypes.String `json:"user_account"`
|
||||
UserAccountModifyCount valueTypes.Integer `json:"user_account_modify_count"`
|
||||
UserAccountModifyRemainTimes valueTypes.Integer `json:"user_account_modify_remain_times"`
|
||||
UserDealerOrgCode valueTypes.String `json:"user_dealer_org_code"`
|
||||
UserID valueTypes.Integer `json:"user_id"`
|
||||
UserId valueTypes.Integer `json:"user_id"`
|
||||
UserLanguage valueTypes.String `json:"user_language"`
|
||||
UserLevel valueTypes.Integer `json:"user_level"`
|
||||
UserName valueTypes.String `json:"user_name"`
|
||||
@ -70,7 +70,7 @@ type ResultData struct {
|
||||
InstallerPhone valueTypes.String `json:"installer_phone"`
|
||||
IsCountryDefaultDealerOrgCode valueTypes.Bool `json:"is_country_default_dealer_org_code"`
|
||||
MobileTel valueTypes.String `json:"moble_tel"`
|
||||
OrgID valueTypes.Integer `json:"org_id"`
|
||||
OrgId valueTypes.Integer `json:"org_id"`
|
||||
OrgIndexCode valueTypes.String `json:"org_index_code"`
|
||||
OrgName valueTypes.String `json:"org_name"`
|
||||
UpDealerEmail valueTypes.String `json:"up_dealer_email"`
|
||||
@ -81,7 +81,7 @@ type ResultData struct {
|
||||
UpDealerOrgInstallerPhone valueTypes.String `json:"up_dealer_org_installer_phone"`
|
||||
UpDealerUserName valueTypes.String `json:"up_dealer_user_name"`
|
||||
UpDealerUserTelNationCode valueTypes.String `json:"up_dealer_user_tel_nation_code"`
|
||||
UpOrgID valueTypes.Integer `json:"up_org_id"`
|
||||
UpOrgId valueTypes.Integer `json:"up_org_id"`
|
||||
UpOrgName valueTypes.String `json:"up_org_name"`
|
||||
UserName valueTypes.String `json:"user_name"`
|
||||
UserTelNationCode valueTypes.String `json:"user_tel_nation_code"`
|
||||
|
@ -12,7 +12,7 @@ const Url = "/v1/powerStationService/getPsWeatherList"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -28,7 +28,7 @@ type ResultData struct {
|
||||
WeatherList []struct {
|
||||
Chill valueTypes.Float `json:"chill"`
|
||||
Code valueTypes.Float `json:"code"`
|
||||
CodeName valueTypes.Float `json:"code_name"`
|
||||
CodeName valueTypes.String `json:"code_name"`
|
||||
DateTime valueTypes.DateTime `json:"date_time" PointIgnore:"true"`
|
||||
Direction valueTypes.Float `json:"direction"`
|
||||
High valueTypes.Float `json:"high" PointUnit:"F"`
|
||||
@ -37,7 +37,7 @@ type ResultData struct {
|
||||
Low valueTypes.Float `json:"low" PointUnit:"F"`
|
||||
Lowc valueTypes.Float `json:"lowc" PointUnit:"C"`
|
||||
Pressure valueTypes.Float `json:"pressure" PointUnit:"hPa"`
|
||||
PsID valueTypes.Float `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
Rising valueTypes.Float `json:"rising"`
|
||||
Speed valueTypes.Float `json:"speed"`
|
||||
Sunrise valueTypes.Time `json:"sunrise"`
|
||||
|
@ -28,14 +28,14 @@ func (rd RequestData) Help() string {
|
||||
type ResultData struct {
|
||||
ResultList []struct {
|
||||
Checked valueTypes.Bool `json:"checked"`
|
||||
ID valueTypes.String `json:"id"`
|
||||
Id valueTypes.String `json:"id"`
|
||||
IsFirstOrg valueTypes.Bool `json:"isFirstOrg"`
|
||||
IsParent valueTypes.Bool `json:"isParent"`
|
||||
Name valueTypes.String `json:"name"`
|
||||
Open valueTypes.Bool `json:"open"`
|
||||
OrgID valueTypes.Integer `json:"org_id"`
|
||||
PID valueTypes.Integer `json:"pId"`
|
||||
PsID valueTypes.Integer `json:"ps_id"`
|
||||
OrgId valueTypes.Integer `json:"org_id"`
|
||||
ParentId valueTypes.Integer `json:"pId"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
ShareType int64 `json:"share_type"`
|
||||
} `json:"resultList"`
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ const Url = "/v1/devService/getRemoteUpgradeTaskList"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsIdList string `json:"ps_id_list" required:"true"`
|
||||
PsIdList valueTypes.String `json:"ps_id_list" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
|
@ -12,7 +12,7 @@ const Url = "/v1/powerStationService/getReportData"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
ReportType string `json:"report_type" required:"true"`
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ type ResultData struct {
|
||||
InstallerPsFaultStatus valueTypes.Integer `json:"installer_ps_fault_status"`
|
||||
OwnerPsFaultStatus valueTypes.Integer `json:"owner_ps_fault_status"`
|
||||
PsFaultStatus valueTypes.Integer `json:"ps_fault_status"`
|
||||
PsId valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
PsName valueTypes.String `json:"ps_name"`
|
||||
PsStatus valueTypes.Integer `json:"ps_status"`
|
||||
PsType valueTypes.Integer `json:"ps_type"`
|
||||
@ -41,13 +41,13 @@ type ResultData struct {
|
||||
SysSchemeName valueTypes.String `json:"sys_scheme_name"`
|
||||
ValidFlag valueTypes.Bool `json:"valid_flag"`
|
||||
} `json:"info"`
|
||||
MinDateID interface{} `json:"min_date_id"`
|
||||
MinDateId interface{} `json:"min_date_id"`
|
||||
Total []DataList `json:"total" PointId:"total" PointIgnoreIfNilFromChild:"UpdateTime" PointNameFromChild:"DateId" PointNameDateFormat:"20060102" PointNameFromAppend:"true"`
|
||||
}
|
||||
type DataList struct {
|
||||
DateId valueTypes.DateTime `json:"date_id"`
|
||||
DeviceName interface{} `json:"device_name"`
|
||||
PsId valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
TimeStamp interface{} `json:"time_stamp"` // Sad that this alternates between string and valueTypes.Integer.
|
||||
UpdateTime valueTypes.DateTime `json:"update_time"`
|
||||
UUID interface{} `json:"uuid"`
|
||||
|
@ -30,23 +30,23 @@ type ResultData struct {
|
||||
Email valueTypes.String `json:"email"`
|
||||
ReportList []struct {
|
||||
CreateTime valueTypes.DateTime `json:"create_time"`
|
||||
CreateUserID valueTypes.Integer `json:"create_user_id"`
|
||||
CreateUserId valueTypes.Integer `json:"create_user_id"`
|
||||
EmailAddTime valueTypes.DateTime `json:"email_add_time"`
|
||||
ID valueTypes.Integer `json:"id"`
|
||||
Id valueTypes.Integer `json:"id"`
|
||||
IsAllowEmailSend valueTypes.Bool `json:"is_allow_email_send"`
|
||||
IsBank valueTypes.Bool `json:"is_bank"`
|
||||
IsCanRenewSendConfirmEmail valueTypes.Bool `json:"is_can_renew_send_confirm_email"`
|
||||
IsNewWeb valueTypes.Bool `json:"is_new_web"`
|
||||
OrderID valueTypes.Integer `json:"order_id"`
|
||||
OrderId valueTypes.Integer `json:"order_id"`
|
||||
ReSendConfirmEmailTime valueTypes.DateTime `json:"re_send_confirm_email_time"`
|
||||
ReportID valueTypes.Integer `json:"report_id"`
|
||||
ReportId valueTypes.Integer `json:"report_id"`
|
||||
ReportName valueTypes.String `json:"report_name"`
|
||||
SendEmail valueTypes.String `json:"send_email"`
|
||||
Status valueTypes.Bool `json:"status"`
|
||||
TimeDimension valueTypes.Integer `json:"time_dimension"`
|
||||
Type valueTypes.Integer `json:"type"`
|
||||
UpdateTime valueTypes.DateTime `json:"update_time"`
|
||||
UserID valueTypes.Integer `json:"user_id"`
|
||||
UserId valueTypes.Integer `json:"user_id"`
|
||||
} `json:"report_list"`
|
||||
} `json:"report_email_config_info_list"`
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ func (rd RequestData) Help() string {
|
||||
type ResultData []struct {
|
||||
AttachNames interface{} `json:"attach_names"`
|
||||
AttachPath interface{} `json:"attach_path"`
|
||||
BusinessID valueTypes.Integer `json:"business_id"`
|
||||
BusinessId valueTypes.Integer `json:"business_id"`
|
||||
ClickNum valueTypes.Integer `json:"click_num"`
|
||||
CreateTime valueTypes.DateTime `json:"create_time"`
|
||||
EndTime valueTypes.DateTime `json:"end_time"`
|
||||
@ -48,7 +48,7 @@ type ResultData []struct {
|
||||
MsgContentsTrTr valueTypes.String `json:"msg_contents_tr_tr"`
|
||||
MsgContentsViVn valueTypes.String `json:"msg_contents_vi_vn"`
|
||||
MsgContentsZhTw valueTypes.String `json:"msg_contents_zh_tw"`
|
||||
MsgID valueTypes.Integer `json:"msg_id"`
|
||||
MsgId valueTypes.Integer `json:"msg_id"`
|
||||
MsgLevel valueTypes.Integer `json:"msg_level"`
|
||||
MsgTitle valueTypes.String `json:"msg_title"`
|
||||
MsgTitleDeDe valueTypes.String `json:"msg_title_de_de"`
|
||||
@ -72,8 +72,8 @@ type ResultData []struct {
|
||||
PublishTime valueTypes.DateTime `json:"publish_time"`
|
||||
RemindType valueTypes.Integer `json:"remind_type"`
|
||||
StartTime valueTypes.DateTime `json:"start_time"`
|
||||
TypeID valueTypes.Integer `json:"type_id"`
|
||||
UserID valueTypes.Integer `json:"user_id"`
|
||||
TypeId valueTypes.Integer `json:"type_id"`
|
||||
UserId valueTypes.Integer `json:"user_id"`
|
||||
UserName valueTypes.String `json:"user_name"`
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ func (rd RequestData) Help() string {
|
||||
|
||||
type ResultData struct {
|
||||
PageList []struct {
|
||||
TemplateID valueTypes.Integer `json:"template_id"`
|
||||
TemplateId valueTypes.Integer `json:"template_id"`
|
||||
TemplateName valueTypes.String `json:"template_name"`
|
||||
UpdateTime valueTypes.DateTime `json:"update_time"`
|
||||
} `json:"pageList"`
|
||||
|
@ -29,10 +29,10 @@ type ResultData struct {
|
||||
PointTimeRelation []struct {
|
||||
Is24Hour valueTypes.Bool `json:"is_24_hour"`
|
||||
PointList []struct {
|
||||
PointID valueTypes.Integer `json:"point_id"`
|
||||
PointId valueTypes.Integer `json:"point_id"`
|
||||
TimeType valueTypes.Integer `json:"time_type"`
|
||||
} `json:"point_list"`
|
||||
UpTimePointID valueTypes.Integer `json:"up_time_point_id"`
|
||||
UpTimePointId valueTypes.Integer `json:"up_time_point_id"`
|
||||
} `json:"point_time_relation"`
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ func (e *EndPoint) Print() {
|
||||
fmt.Printf("Login Last IP:\t%s\n", e.LoginLastIP())
|
||||
fmt.Printf("Login State:\t%s\n", e.LoginState())
|
||||
fmt.Printf("User Account:\t%s\n", e.UserAccount())
|
||||
fmt.Printf("User Id:\t%s\n", e.UserID())
|
||||
fmt.Printf("User Id:\t%s\n", e.UserId())
|
||||
fmt.Printf("User Name:\t%s\n", e.UserName())
|
||||
fmt.Printf("Is Online:\t%v\n", e.IsOnline())
|
||||
fmt.Printf("Token:\t%s\n", e.Token())
|
||||
|
@ -35,13 +35,13 @@ type ResultData struct {
|
||||
|
||||
AcceptOrderNum valueTypes.Integer `json:"accept_order_num"`
|
||||
BackgroundColor valueTypes.Integer `json:"background_color"`
|
||||
Countryid string `json:"countryid"`
|
||||
Createdate string `json:"createdate"`
|
||||
Createuserid string `json:"createuserid"`
|
||||
CountryId string `json:"countryid"`
|
||||
CreateDate string `json:"createdate"`
|
||||
CreateUserId string `json:"createuserid"`
|
||||
CurrentOrderNum valueTypes.Integer `json:"current_order_num"`
|
||||
DisableTime string `json:"disable_time"`
|
||||
Email string `json:"email"`
|
||||
Englishname interface{} `json:"englishname"`
|
||||
EnglishName interface{} `json:"englishname"`
|
||||
GcjLatitude valueTypes.Float `json:"gcj_latitude"`
|
||||
GcjLongitude valueTypes.Float `json:"gcj_longitude"`
|
||||
ImToken interface{} `json:"im_token"`
|
||||
@ -74,14 +74,14 @@ type ResultData struct {
|
||||
MapType string `json:"map_type"`
|
||||
MinDate valueTypes.DateTime `json:"min_date"`
|
||||
MobileTel interface{} `json:"mobile_tel"`
|
||||
OrgID string `json:"org_id"`
|
||||
OrgId string `json:"org_id"`
|
||||
OrgName string `json:"org_name"`
|
||||
OrgTimezone string `json:"org_timezone"`
|
||||
PasswordIsSimple valueTypes.Integer `json:"password_is_simple"`
|
||||
PhotoID interface{} `json:"photo_id"`
|
||||
PhotoId interface{} `json:"photo_id"`
|
||||
PhotoURL interface{} `json:"photo_url"`
|
||||
Privileges []struct {
|
||||
FatherID valueTypes.Integer `json:"father_id"`
|
||||
FatherId valueTypes.Integer `json:"father_id"`
|
||||
IconURL interface{} `json:"icon_url"`
|
||||
IsOpen valueTypes.Bool `json:"is_open"`
|
||||
IsThirdPlatform valueTypes.Bool `json:"is_third_platform"`
|
||||
@ -91,13 +91,13 @@ type ResultData struct {
|
||||
MenuOrder interface{} `json:"menu_order"`
|
||||
MenuType string `json:"menu_type"`
|
||||
MenuURL string `json:"menu_url"`
|
||||
PrivilegeID valueTypes.Integer `json:"privilege_id"`
|
||||
RoleID valueTypes.Integer `json:"role_id"`
|
||||
PrivilegeId valueTypes.Integer `json:"privilege_id"`
|
||||
RoleId valueTypes.Integer `json:"role_id"`
|
||||
URLTarget string `json:"url_target"`
|
||||
VueIcon interface{} `json:"vue_icon"`
|
||||
VuePath interface{} `json:"vue_path"`
|
||||
} `json:"privileges"`
|
||||
RoleID string `json:"role_id"`
|
||||
RoleId string `json:"role_id"`
|
||||
SecondaryOrgIds []interface{} `json:"secondaryOrgIds"`
|
||||
ServerTel string `json:"server_tel"`
|
||||
ServiceVersion string `json:"service_version"`
|
||||
@ -114,14 +114,14 @@ type ResultData struct {
|
||||
UserAccountModifyCount valueTypes.Integer `json:"user_account_modify_count"`
|
||||
UserAccountModifyRemainTimes valueTypes.Integer `json:"user_account_modify_remain_times"`
|
||||
UserDealerOrgCode interface{} `json:"user_dealer_org_code"`
|
||||
UserID string `json:"user_id"`
|
||||
UserId string `json:"user_id"`
|
||||
UserLevel string `json:"user_level"`
|
||||
UserMasterOrgID string `json:"user_master_org_id"`
|
||||
UserMasterOrgId string `json:"user_master_org_id"`
|
||||
UserMasterOrgName string `json:"user_master_org_name"`
|
||||
UserMasterOrgTimeZoneID string `json:"user_master_org_time_zone_id"`
|
||||
UserMasterOrgTimeZoneId string `json:"user_master_org_time_zone_id"`
|
||||
UserMasterOrgTimeZoneName string `json:"user_master_org_time_zone_name"`
|
||||
UserName string `json:"user_name"`
|
||||
UserRoleIDList []string `json:"user_role_id_list"`
|
||||
UserRoleIdList []string `json:"user_role_id_list"`
|
||||
UserTelNationCode interface{} `json:"user_tel_nation_code"`
|
||||
UserauthorURL []interface{} `json:"userauthorURL"`
|
||||
Userauthorbutto []string `json:"userauthorbutto"`
|
||||
@ -156,15 +156,11 @@ func (e *EndPoint) AppKey() string {
|
||||
return e.Request.RequestCommon.Appkey
|
||||
}
|
||||
|
||||
func (e *EndPoint) UserId() string {
|
||||
return e.Response.ResultData.UserID
|
||||
}
|
||||
|
||||
func (e *EndPoint) Email() string {
|
||||
return e.Response.ResultData.Email
|
||||
}
|
||||
func (e *EndPoint) CreateDate() string {
|
||||
return e.Response.ResultData.Createdate
|
||||
return e.Response.ResultData.CreateDate
|
||||
}
|
||||
func (e *EndPoint) IsOnline() bool {
|
||||
return e.Response.ResultData.IsOnline.Value()
|
||||
@ -184,8 +180,8 @@ func (e *EndPoint) Token() string {
|
||||
func (e *EndPoint) UserAccount() string {
|
||||
return e.Response.ResultData.UserAccount
|
||||
}
|
||||
func (e *EndPoint) UserID() string {
|
||||
return e.Response.ResultData.UserID
|
||||
func (e *EndPoint) UserId() string {
|
||||
return e.Response.ResultData.UserId
|
||||
}
|
||||
func (e *EndPoint) UserName() string {
|
||||
return e.Response.ResultData.UserName
|
||||
|
@ -28,9 +28,9 @@ type ResultData struct {
|
||||
PageDataList []struct {
|
||||
CreateTime valueTypes.DateTime `json:"create_time" PointIgnore:"true"`
|
||||
DeviceType valueTypes.Integer `json:"device_type"`
|
||||
ID valueTypes.Integer `json:"id"`
|
||||
Id valueTypes.Integer `json:"id"`
|
||||
Period valueTypes.Integer `json:"period"` // 0, 1, 2, 3, 4
|
||||
PointID valueTypes.PointId `json:"point_id"`
|
||||
PointId valueTypes.PointId `json:"point_id"`
|
||||
PointName valueTypes.String `json:"point_name" PointIgnore:"true"` // Old name of point.
|
||||
PointNameNew valueTypes.String `json:"point_name_new" PointId:"name"`
|
||||
TypeName valueTypes.String `json:"type_name"`
|
||||
|
@ -13,7 +13,7 @@ const Url = "/v1/powerStationService/psForcastInfo"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -28,7 +28,7 @@ func (rd RequestData) Help() string {
|
||||
|
||||
type ResultData struct {
|
||||
AreaForcastList []struct {
|
||||
Chill valueTypes.String `json:"chill"`
|
||||
Chill valueTypes.Float `json:"chill"`
|
||||
City valueTypes.String `json:"city"`
|
||||
Code valueTypes.Integer `json:"code"`
|
||||
CodeName valueTypes.String `json:"code_name"`
|
||||
@ -57,7 +57,7 @@ type ResultData struct {
|
||||
} `json:"areaForcastList" PointNameFromChild:"DateTime" PointNameDateFormat:"20060102"`
|
||||
StationsCityCode []struct {
|
||||
City valueTypes.String `json:"city"`
|
||||
PsID valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
PsName valueTypes.String `json:"ps_name"`
|
||||
} `json:"stationsCityCode"`
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func (rd RequestData) Help() string {
|
||||
|
||||
type ResultData struct {
|
||||
PageList []struct {
|
||||
PsId valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
PsName valueTypes.String `json:"ps_name"`
|
||||
} `json:"pageList" PointNameFromChild:"PsId" PointNameFromAppend:"false"`
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ type ResultData struct {
|
||||
ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id"`
|
||||
CommandStatus valueTypes.Integer `json:"command_status"`
|
||||
CommunicationDevUUID valueTypes.Integer `json:"communication_dev_uuid"`
|
||||
CountryID interface{} `json:"country_id"`
|
||||
CountryId interface{} `json:"country_id"`
|
||||
CpldVersion interface{} `json:"cpld_version"`
|
||||
DataFlagDetail valueTypes.Integer `json:"data_flag_detail"`
|
||||
DevFaultStatus string `json:"dev_fault_status"`
|
||||
@ -53,16 +53,16 @@ type ResultData struct {
|
||||
DeviceArea valueTypes.String `json:"device_area"`
|
||||
DeviceAreaName valueTypes.String `json:"device_area_name"`
|
||||
DeviceCode valueTypes.Integer `json:"device_code"`
|
||||
DeviceFactoryID interface{} `json:"device_factory_id"`
|
||||
DeviceFactoryId interface{} `json:"device_factory_id"`
|
||||
DeviceModel valueTypes.String `json:"device_model"`
|
||||
DeviceModelCode valueTypes.String `json:"device_model_code"`
|
||||
DeviceModelID valueTypes.Integer `json:"device_model_id"`
|
||||
DeviceModelId valueTypes.Integer `json:"device_model_id"`
|
||||
DeviceName valueTypes.String `json:"device_name"`
|
||||
DeviceProSn valueTypes.String `json:"device_pro_sn"`
|
||||
DeviceStatus int64 `json:"device_status"`
|
||||
DeviceType int64 `json:"device_type"`
|
||||
FactoryName valueTypes.String `json:"factory_name"`
|
||||
GridTypeID interface{} `json:"grid_type_id"`
|
||||
GridTypeId interface{} `json:"grid_type_id"`
|
||||
InstallerDevFaultStatus interface{} `json:"installer_dev_fault_status"`
|
||||
InverterModelType int64 `json:"inverter_model_type"`
|
||||
IsCountryCheck valueTypes.Bool `json:"is_country_check"`
|
||||
@ -91,7 +91,7 @@ type ResultData struct {
|
||||
OwnerDevFaultStatus interface{} `json:"owner_dev_fault_status"`
|
||||
P2 interface{} `json:"p2"`
|
||||
P24 interface{} `json:"p24"`
|
||||
PsID valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
PsKey valueTypes.String `json:"ps_key"`
|
||||
PsName valueTypes.String `json:"ps_name"`
|
||||
PsShortName valueTypes.String `json:"ps_short_name"`
|
||||
|
@ -32,7 +32,7 @@ type ResultData struct {
|
||||
ChannelId valueTypes.Integer `json:"chnnl_id"`
|
||||
CommandStatus valueTypes.Integer `json:"command_status"`
|
||||
CommunicationDevUUID valueTypes.Integer `json:"communication_dev_uuid"`
|
||||
CountryID interface{} `json:"country_id"`
|
||||
CountryId interface{} `json:"country_id"`
|
||||
CpldVersion interface{} `json:"cpld_version"`
|
||||
DataFlagDetail valueTypes.Integer `json:"data_flag_detail"`
|
||||
DevFaultStatus string `json:"dev_fault_status"`
|
||||
@ -40,7 +40,7 @@ type ResultData struct {
|
||||
DeviceModelList []struct {
|
||||
DeviceModel valueTypes.String `json:"device_model"`
|
||||
DeviceModelCode valueTypes.String `json:"device_model_code"`
|
||||
ModelID valueTypes.Integer `json:"model_id"`
|
||||
ModelId valueTypes.Integer `json:"model_id"`
|
||||
} `json:"deviceModelList"`
|
||||
DevicePropertyValueList []struct {
|
||||
DeviceType valueTypes.Integer `json:"device_type"`
|
||||
@ -53,16 +53,16 @@ type ResultData struct {
|
||||
DeviceArea valueTypes.String `json:"device_area"`
|
||||
DeviceAreaName valueTypes.String `json:"device_area_name"`
|
||||
DeviceCode valueTypes.Integer `json:"device_code"`
|
||||
DeviceFactoryID interface{} `json:"device_factory_id"`
|
||||
DeviceFactoryId interface{} `json:"device_factory_id"`
|
||||
DeviceModel valueTypes.String `json:"device_model"`
|
||||
DeviceModelCode valueTypes.String `json:"device_model_code"`
|
||||
DeviceModelID valueTypes.Integer `json:"device_model_id"`
|
||||
DeviceModelId valueTypes.Integer `json:"device_model_id"`
|
||||
DeviceName valueTypes.String `json:"device_name"`
|
||||
DeviceProSn valueTypes.String `json:"device_pro_sn"`
|
||||
DeviceStatus int64 `json:"device_status"`
|
||||
DeviceType int64 `json:"device_type"`
|
||||
FactoryName valueTypes.String `json:"factory_name"`
|
||||
GridTypeID interface{} `json:"grid_type_id"`
|
||||
GridTypeId interface{} `json:"grid_type_id"`
|
||||
InstallerDevFaultStatus interface{} `json:"installer_dev_fault_status"`
|
||||
InverterModelType int64 `json:"inverter_model_type"`
|
||||
IsCountryCheck valueTypes.Bool `json:"is_country_check"`
|
||||
@ -91,7 +91,7 @@ type ResultData struct {
|
||||
OwnerDevFaultStatus interface{} `json:"owner_dev_fault_status"`
|
||||
P2 interface{} `json:"p2"`
|
||||
P24 interface{} `json:"p24"`
|
||||
PsID valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
PsKey valueTypes.String `json:"ps_key"`
|
||||
PsName valueTypes.String `json:"ps_name"`
|
||||
PsShortName valueTypes.String `json:"ps_short_name"`
|
||||
|
@ -13,7 +13,7 @@ const Url = "/v1/devService/queryDeviceList"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -98,9 +98,9 @@ type ResultData struct {
|
||||
DeviceArea valueTypes.Integer `json:"device_area" PointId:"device_area" PointUpdateFreq:"UpdateFreqBoot"` // References UUID and referenced by UUIDIndexCode
|
||||
DeviceAreaName valueTypes.String `json:"device_area_name" PointId:"device_area_name" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
DeviceCode valueTypes.Integer `json:"device_code" PointId:"device_code" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
DeviceID valueTypes.Integer `json:"device_id" PointId:"device_id" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
DeviceId valueTypes.Integer `json:"device_id" PointId:"device_id" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
DeviceModelCode valueTypes.String `json:"device_model_code" PointId:"device_model_code" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
DeviceModelID valueTypes.Integer `json:"device_model_id" PointId:"device_model_id" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
DeviceModelId valueTypes.Integer `json:"device_model_id" PointId:"device_model_id" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
DeviceName valueTypes.String `json:"device_name" PointId:"device_name" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
DeviceStatus valueTypes.Bool `json:"device_status" PointId:"device_status" PointUpdateFreq:"UpdateFreqInstant"`
|
||||
DeviceType valueTypes.Integer `json:"device_type" PointId:"device_type" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
@ -120,13 +120,13 @@ type ResultData struct {
|
||||
OwnerAlarmCount valueTypes.Count `json:"owner_alarm_count" PointId:"owner_alarm_count" PointUpdateFreq:"UpdateFreqTotal"`
|
||||
OwnerDevFaultStatus valueTypes.Integer `json:"owner_dev_fault_status" PointId:"owner_dev_fault_status" PointUpdateFreq:"UpdateFreqInstant"`
|
||||
OwnerFaultCount valueTypes.Count `json:"owner_fault_count" PointId:"owner_fault_count" PointUpdateFreq:"UpdateFreqTotal"`
|
||||
PointData []PointStruct `json:"point_data" PointNameFromChild:"PointID"`
|
||||
PointData []PointStruct `json:"point_data" PointNameFromChild:"PointId"`
|
||||
Points interface{} `json:"points" PointId:"points"`
|
||||
PsTimezoneInfo struct {
|
||||
IsDst valueTypes.Bool `json:"is_dst" PointUpdateFreq:"UpdateFreqInstant"`
|
||||
TimeZone valueTypes.String `json:"time_zone" PointUpdateFreq:"UpdateFreqInstant"`
|
||||
} `json:"psTimezoneInfo"`
|
||||
PsID valueTypes.Integer `json:"ps_id" PointId:"ps_id" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
PsId valueTypes.PsId `json:"ps_id" PointId:"ps_id" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
PsKey valueTypes.PsKey `json:"ps_key" PointId:"ps_key" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
RelState valueTypes.Integer `json:"rel_state" PointId:"rel_state" PointUpdateFreq:"UpdateFreqInstant"`
|
||||
Sn valueTypes.String `json:"sn" PointId:"sn" PointName:"Serial Number" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
@ -140,16 +140,16 @@ type ResultData struct {
|
||||
}
|
||||
|
||||
type PointStruct struct {
|
||||
CodeID valueTypes.Integer `json:"code_id" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
CodeIDOrderID valueTypes.String `json:"code_id_order_id" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
CodeId valueTypes.Integer `json:"code_id" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
CodeIdOrderId valueTypes.String `json:"code_id_order_id" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
CodeName valueTypes.String `json:"code_name" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
DevPointLastUpdateTime valueTypes.DateTime `json:"dev_point_last_update_time" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreq5Mins"`
|
||||
IsPlatformDefaultUnit valueTypes.Bool `json:"is_platform_default_unit" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
IsShow valueTypes.Bool `json:"is_show" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
OrderID valueTypes.Integer `json:"order_id" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
OrderId valueTypes.Integer `json:"order_id" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
OrderNum valueTypes.Integer `json:"order_num" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
PointGroupID valueTypes.Integer `json:"point_group_id" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
PointGroupIDOrderID valueTypes.Integer `json:"point_group_id_order_id" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
PointGroupId valueTypes.Integer `json:"point_group_id" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
PointGroupIdOrderId valueTypes.Integer `json:"point_group_id_order_id" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
PointName valueTypes.String `json:"point_name" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
PointSign valueTypes.String `json:"point_sign" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
Relate valueTypes.Integer `json:"relate" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
@ -158,7 +158,7 @@ type PointStruct struct {
|
||||
Value valueTypes.Float `json:"value" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUnitFrom:"Unit" PointUpdateFreq:"UpdateFreq5Mins"`
|
||||
ValueDescription valueTypes.String `json:"value_description" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
|
||||
PointID valueTypes.PointId `json:"point_id" PointIgnore:"true" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
PointId valueTypes.PointId `json:"point_id" PointIgnore:"true" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
PointGroupName valueTypes.String `json:"point_group_name" PointIgnore:"true" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
TimeStamp valueTypes.DateTime `json:"time_stamp" PointIgnore:"true" PointUpdateFreq:"UpdateFreq5Mins"`
|
||||
Unit valueTypes.String `json:"unit" PointIgnore:"true" PointUpdateFreq:"UpdateFreqBoot"`
|
||||
@ -236,9 +236,9 @@ func (e *EndPoint) GetData() api.DataMap {
|
||||
// var TotalEnergyConsumption VirtualPointStruct
|
||||
|
||||
pkg := apiReflect.GetName("", *e)
|
||||
// name := api.JoinWithDots(0, "", pkg) // , e.Request.PsId)
|
||||
name := api.JoinWithDots(0, "", pkg, e.Request.PsId)
|
||||
dt := valueTypes.NewDateTime(valueTypes.Now)
|
||||
entries.StructToPoints(e.Response.ResultData, pkg, e.Request.PsId.String(), dt)
|
||||
entries.StructToPoints(e.Response.ResultData, name, e.Request.PsId.String(), dt)
|
||||
|
||||
if len(entries.Map) == 0 {
|
||||
break
|
||||
@ -319,9 +319,7 @@ func (e *EndPoint) GetEnergyStorageSystem(entries api.DataMap) {
|
||||
// Only looking for a Solar Storage System.
|
||||
continue
|
||||
}
|
||||
devices = append(devices, device.PsKey.String())
|
||||
// if p.PointID.Match(13003) {
|
||||
// }
|
||||
devices = append(devices, api.JoinWithDots(0, "", device.PsId, device.PsKey))
|
||||
}
|
||||
|
||||
// Points are in an array. So manually add virtuals instead of using the structure.
|
||||
@ -453,190 +451,6 @@ func (e *EndPoint) GetEnergyStorageSystem(entries api.DataMap) {
|
||||
power_load_active := entries.CopyDataEntries(*power_load, dstEndpoint, "power_load_active", "")
|
||||
power_load_active.FloatToState(power_load_active.GetFloat())
|
||||
}
|
||||
|
||||
// for _, d := range e.Response.ResultData.PageList {
|
||||
// name2 := api.JoinWithDots(0, "", pkg, d.PsKey)
|
||||
// entries.StructToPoints(d, name2, d.PsKey.Value(), valueTypes.NewDateTime(""))
|
||||
//
|
||||
// for _, p := range d.PointData {
|
||||
// pid := valueTypes.SetPointIdValue(p.PointID.Value())
|
||||
// uv := valueTypes.SetUnitValueFloat(p.Value.Value(), p.Unit.Value(), "")
|
||||
// // name2 := fmt.Sprintf("%s.PointData.%s", name, pid)
|
||||
// // name3 := fmt.Sprintf("%s.PointData", name2)
|
||||
// entries.AddUnitValue(name2, d.PsKey.Value(), pid, p.PointName.Value(), p.PointGroupName.Value(), p.TimeStamp, uv)
|
||||
//
|
||||
// // Handle virtual results.
|
||||
// // switch pid {
|
||||
// // case "13126":
|
||||
// // // BatteryChargingPower
|
||||
// // entries["PVPowerToBattery"] = entries[pid]
|
||||
// // case "13150":
|
||||
// // // BatteryDischargingPower
|
||||
// // entries["BatteryPowerToLoad"] = entries[pid]
|
||||
// // case "13121":
|
||||
// // // TotalExportActivePower
|
||||
// // entries["PVPowerToGrid"] = entries[pid]
|
||||
// // case "13149":
|
||||
// // // PurchasedPower
|
||||
// // entries["GridPowerToLoad"] = entries[pid]
|
||||
// // case "13003":
|
||||
// // // TotalDcPower
|
||||
// // entries["PVPower"] = addVirtualAlias(entries[pid], "pv_power", "PV Power")
|
||||
// // case "13119":
|
||||
// // // TotalLoadActivePower
|
||||
// // entries["LoadPower"] = addVirtualAlias(entries[pid], "load_power", "Load Power")
|
||||
// //
|
||||
// // // addVirtualAlias(entries[pid], "FOO", "FOO")
|
||||
// //
|
||||
// // case "13112":
|
||||
// // // Daily PV Yield
|
||||
// // entries["DailyPvEnergy"] = addVirtualAlias(entries["DailyPvEnergy"], "daily_pv_energy", "Daily PV Energy")
|
||||
// // case "13174":
|
||||
// // // DailyBatteryChargingEnergyFromPv
|
||||
// // entries["YieldBatteryCharge"] = addVirtualAlias(entries[pid], "pv_battery_charge", "PV Battery Charge")
|
||||
// // case "13029":
|
||||
// // // DailyBatteryDischargingEnergy
|
||||
// // entries["DailyBatteryDischargingEnergy"] = entries[pid]
|
||||
// // case "13122":
|
||||
// // // entries["DailyFeedInEnergy"] = addVirtualAlias(entries[pid], "pv_feed_in", "PV Feed In")
|
||||
// // // @TODO - This may differ from DailyFeedInEnergyPv
|
||||
// // case "13173":
|
||||
// // // DailyFeedInEnergyPv
|
||||
// // entries["YieldFeedIn"] = addVirtualAlias(entries[pid], "pv_feed_in", "PV Feed In")
|
||||
// // case "13147":
|
||||
// // // DailyPurchasedEnergy
|
||||
// // entries["DailyPurchasedEnergy"] = addVirtualAlias(entries[pid], "daily_purchased_energy", "Daily Purchased Energy")
|
||||
// //
|
||||
// // case "13116":
|
||||
// // // DailyLoadEnergyConsumptionFromPv
|
||||
// // entries["YieldSelfConsumption"] = addVirtualAlias(entries[pid], "pv_self_consumption", "PV Self Consumption")
|
||||
// // case "13134":
|
||||
// // // TotalPvYield
|
||||
// // entries["TotalPvYield"] = addVirtualAlias(entries[pid], "pv_total_yield", "PV Total Yield")
|
||||
// //
|
||||
// // case "13199":
|
||||
// // // Daily Load Energy Consumption
|
||||
// // entries["DailyTotalLoad"] = addVirtualAlias(entries[pid], "daily_total_energy", "Daily Total Energy")
|
||||
// //
|
||||
// // case "13130":
|
||||
// // // Total Load Energy Consumption
|
||||
// // entries["TotalEnergyConsumption"] = addVirtualAlias(entries[pid], "total_energy_consumption", "Total Energy Consumption"
|
||||
// // }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // TotalDcPower
|
||||
// entries.FromRefAddAlias(pkg + ".1171348_14_1_2.p13003.value", api.VirtualPsId, "power_pv", "")
|
||||
// // BatteryChargingPower
|
||||
// entries.FromRefAddAlias("p13126", api.VirtualPsId, "battery_charge_power", "")
|
||||
// // BatteryDischargingPower
|
||||
// entries.FromRefAddAlias("13150", api.VirtualPsId, "battery_discharge_power", "")
|
||||
// // TotalExportActivePower
|
||||
// entries.FromRefAddAlias("13121", api.VirtualPsId, "power_pv_to_grid", "")
|
||||
// // TotalLoadActivePower
|
||||
// entries.FromRefAddAlias("13119", api.VirtualPsId, "power_load", "")
|
||||
// // PurchasedPower
|
||||
// entries.FromRefAddAlias("13149", api.VirtualPsId, "power_grid_to_load", "")
|
||||
// // Daily PV Yield
|
||||
// entries.FromRefAddAlias("13112", api.VirtualPsId, "daily_pv_energy", "")
|
||||
// DailyPvEnergy := entries.getFloatValue("DailyTotalLoad") - entries.getFloatValue("DailyPurchasedEnergy")
|
||||
// // DailyBatteryChargingEnergyFromPv
|
||||
// entries.FromRefAddAlias("13174", api.VirtualPsId, "pv_battery_charge_energy", "")
|
||||
// // DailyBatteryDischargingEnergy
|
||||
// entries.FromRefAddAlias("13029", api.VirtualPsId, "battery_discharge", "")
|
||||
//
|
||||
// @TODO - This may differ from DailyFeedInEnergyPv
|
||||
// entries["DailyFeedInEnergy"] = entries.AddVirtualAliasFromRef("13122", "pv_feed_in", "PV Feed In")
|
||||
//
|
||||
// // DailyFeedInEnergyPv
|
||||
// entries.FromRefAddAlias("13173", api.VirtualPsId, "pv_feed_in", "")
|
||||
// // DailyPurchasedEnergy
|
||||
// entries.FromRefAddAlias("13147", api.VirtualPsId, "daily_purchased_energy", "")
|
||||
// // DailyLoadEnergyConsumptionFromPv
|
||||
// entries.FromRefAddAlias("13116", api.VirtualPsId, "pv_self_consumption", "")
|
||||
// // TotalPvYield
|
||||
// entries.FromRefAddAlias("13134", api.VirtualPsId, "pv_total_yield", "")
|
||||
// // Daily Load Energy Consumption
|
||||
// entries.FromRefAddAlias("13199", api.VirtualPsId, "daily_total_energy", "")
|
||||
// // Total Load Energy Consumption
|
||||
// entries.FromRefAddAlias("13130", api.VirtualPsId, "total_energy_consumption", "")
|
||||
// // entries.AddPointFromRef(api.Point{ Id:"queryDeviceList.p13130" }, api.Point{ PsKey:api.VirtualPsId, Id:"total_energy_consumption" })
|
||||
//
|
||||
// entries.CopyEntry("p13130").CreateAlias()
|
||||
// entries.GetEntry(api.Point{PsKey:psId, Id:"total_income", Unit:p.TotalIncome.Unit, Type:api.PointTypeTotal}, now, p.TotalIncome.Value)
|
||||
//
|
||||
// entries.FromRefAddFloat("pv_self_consumption",
|
||||
// api.VirtualPsId,"pv_daily_yield", "",
|
||||
// entries.GetFloatValue("pv_self_consumption", api.LastEntry) + entries.GetFloatValue("pv_battery_charge_energy", api.LastEntry) + entries.GetFloatValue("pv_feed_in", api.LastEntry))
|
||||
//
|
||||
// entries.FromRefAddFloat("daily_pv_energy",
|
||||
// api.VirtualPsId,"pv_self_consumption_percent", "",
|
||||
// entries.GetPercent("pv_self_consumption", "daily_pv_energy", api.LastEntry))
|
||||
// entries.FromRefAddFloat("daily_pv_energy",
|
||||
// api.VirtualPsId,"pv_battery_charge_percent", "",
|
||||
// entries.GetPercent("pv_battery_charge_energy", "daily_pv_energy", api.LastEntry))
|
||||
// entries.FromRefAddFloat("daily_pv_energy",
|
||||
// api.VirtualPsId,"pv_feed_in_percent", "",
|
||||
// entries.GetPercent("pv_feed_in", "daily_pv_energy", api.LastEntry))
|
||||
//
|
||||
// // // @TODO - Add this calculation.
|
||||
// DailyPvEnergy := entries.GetFloatValue("daily_total_energy", api.LastEntry) - entries.GetFloatValue("daily_purchased_energy", api.LastEntry)
|
||||
// // fmt.Sprintf("%f", DailyPvEnergy)
|
||||
// entries.FromRefAddFloat("daily_total_energy",
|
||||
// api.VirtualPsId,"daily_pv_energy_percent", "",
|
||||
// api.GetPercent(DailyPvEnergy, entries.GetValue("daily_total_energy", api.LastEntry)))
|
||||
// entries.FromRefAddFloat("daily_total_energy",
|
||||
// api.VirtualPsId,"daily_purchased_energy_percent", "",
|
||||
// entries.GetPercent("daily_purchased_energy", "daily_total_energy", api.LastEntry))
|
||||
//
|
||||
// entries.FromRefAddFloat("power_pv",
|
||||
// api.VirtualPsId,"power_pv_to_load", "",
|
||||
// entries.GetFloatValue("power_pv", api.LastEntry) - entries.GetFloatValue("battery_charge_power", api.LastEntry) - entries.GetFloatValue("power_pv_to_grid", api.LastEntry))
|
||||
//
|
||||
// // Battery
|
||||
// entries.FromRefAddFloat("battery_charge_power",
|
||||
// api.VirtualPsId,"power_battery", "",
|
||||
// entries.LowerUpper("battery_discharge_power", "battery_charge_power", api.LastEntry))
|
||||
// entries.FromRefAddFloat("battery_charge_power",
|
||||
// api.VirtualPsId,"power_pv_to_battery", "",
|
||||
// entries.GetFloatValue("battery_charge_power", api.LastEntry))
|
||||
// entries.FromRefAddFloat("battery_discharge_power",
|
||||
// api.VirtualPsId,"power_battery_to_load", "",
|
||||
// entries.GetFloatValue("battery_charge_power", api.LastEntry))
|
||||
// entries.FromRefAddFloat("battery_charge_power",
|
||||
// api.VirtualPsId,"power_battery_to_grid", "",
|
||||
// 0.0)
|
||||
//
|
||||
// // Grid
|
||||
// entries.FromRefAddFloat("power_grid_to_load",
|
||||
// api.VirtualPsId,"power_grid", "",
|
||||
// entries.LowerUpper("power_pv_to_grid", "power_grid_to_load", api.LastEntry))
|
||||
// entries.FromRefAddFloat("power_grid_to_load",
|
||||
// api.VirtualPsId,"power_grid_to_battery", "",
|
||||
// 0.0)
|
||||
//
|
||||
// entries.FromRefAddFloat("pv_battery_charge_energy",
|
||||
// api.VirtualPsId, "battery_energy", "",
|
||||
// entries.LowerUpper("pv_battery_charge_energy", "battery_discharge", api.LastEntry))
|
||||
//
|
||||
// entries.FromRefAddFloat("pv_feed_in",
|
||||
// api.VirtualPsId,"grid_energy", "",
|
||||
// entries.LowerUpper("pv_feed_in", "daily_purchased_energy", api.LastEntry))
|
||||
//
|
||||
// entries.FromRefAddState("power_pv", api.VirtualPsId,"power_pv_active", "")
|
||||
// entries.FromRefAddState("power_battery", api.VirtualPsId,"power_battery_active", "")
|
||||
// entries.FromRefAddState("power_grid", api.VirtualPsId,"power_grid_active", "")
|
||||
// entries.FromRefAddState("power_load", api.VirtualPsId,"power_load_active", "")
|
||||
//
|
||||
// entries.FromRefAddState("power_pv_to_battery", api.VirtualPsId,"power_pv_to_battery_active", "")
|
||||
// entries.FromRefAddState("power_pv_to_load", api.VirtualPsId,"power_pv_to_load_active", "")
|
||||
// entries.FromRefAddState("power_pv_to_grid", api.VirtualPsId,"power_pv_to_grid_active", "")
|
||||
//
|
||||
// entries.FromRefAddState("power_battery_to_load", api.VirtualPsId,"power_battery_to_load_active", "")
|
||||
// entries.FromRefAddState("power_battery_to_grid", api.VirtualPsId,"power_battery_to_grid_active", "")
|
||||
//
|
||||
// entries.FromRefAddState("power_grid_to_load", api.VirtualPsId,"power_grid_to_load_active", "")
|
||||
// entries.FromRefAddState("power_grid_to_battery", api.VirtualPsId,"power_grid_to_battery_active", "")
|
||||
}
|
||||
}
|
||||
|
||||
@ -651,7 +465,7 @@ func (e *EndPoint) GetCommunicationModule(entries api.DataMap) {
|
||||
// Only looking for a Communication Module.
|
||||
continue
|
||||
}
|
||||
devices = append(devices, device.PsKey.String())
|
||||
devices = append(devices, api.JoinWithDots(0, "", device.PsId, device.PsKey))
|
||||
}
|
||||
|
||||
// Points are in an array. So manually add virtuals instead of using the structure.
|
||||
@ -677,7 +491,7 @@ func (e *EndPoint) GetBattery(entries api.DataMap) {
|
||||
// Only looking for a Battery.
|
||||
continue
|
||||
}
|
||||
devices = append(devices, device.PsKey.String())
|
||||
devices = append(devices, api.JoinWithDots(0, "", device.PsId, device.PsKey))
|
||||
}
|
||||
|
||||
// Points are in an array. So manually add virtuals instead of using the structure.
|
||||
|
@ -12,7 +12,7 @@ const Url = "/v1/devService/queryDeviceListForApp"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -26,21 +26,21 @@ func (rd RequestData) Help() string {
|
||||
|
||||
type ResultData struct {
|
||||
PageList []struct {
|
||||
AttrID valueTypes.Integer `json:"attr_id"`
|
||||
AttrId valueTypes.Integer `json:"attr_id"`
|
||||
ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id"`
|
||||
CommandStatus valueTypes.Integer `json:"command_status"`
|
||||
ConnectState valueTypes.Integer `json:"connect_state"`
|
||||
DataFlag valueTypes.Integer `json:"data_flag"`
|
||||
DataFlagDetail valueTypes.Integer `json:"data_flag_detail"`
|
||||
DevFaultStatus valueTypes.Integer `json:"dev_fault_status"`
|
||||
DevStatus valueTypes.Integer `json:"dev_status"`
|
||||
DevStatus valueTypes.Bool `json:"dev_status"`
|
||||
DeviceArea valueTypes.String `json:"device_area"`
|
||||
DeviceCode valueTypes.Integer `json:"device_code"`
|
||||
DeviceFactoryDate valueTypes.DateTime `json:"device_factory_date"`
|
||||
DeviceID valueTypes.Integer `json:"device_id"`
|
||||
DeviceId valueTypes.Integer `json:"device_id"`
|
||||
DeviceModel valueTypes.String `json:"device_model"`
|
||||
DeviceModelCode valueTypes.String `json:"device_model_code"`
|
||||
DeviceModelID valueTypes.Integer `json:"device_model_id"`
|
||||
DeviceModelId valueTypes.Integer `json:"device_model_id"`
|
||||
DeviceName valueTypes.String `json:"device_name"`
|
||||
DeviceProSn valueTypes.String `json:"device_pro_sn"`
|
||||
DeviceState valueTypes.Integer `json:"device_state"`
|
||||
@ -64,7 +64,7 @@ type ResultData struct {
|
||||
P24 interface{} `json:"p24"`
|
||||
Posx interface{} `json:"posx"`
|
||||
Posy interface{} `json:"posy"`
|
||||
PsId valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
PsKey valueTypes.PsKey `json:"ps_key"`
|
||||
RelState valueTypes.Integer `json:"rel_state"`
|
||||
Sn valueTypes.String `json:"sn" PointName:"Serial Number"`
|
||||
|
@ -16,7 +16,7 @@ const Url = "/v1/commonService/queryMutiPointDataList"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsID valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
PsKey valueTypes.PsKey `json:"ps_key" required:"true"`
|
||||
Points string `json:"points" required:"true"`
|
||||
MinuteInterval string `json:"minute_interval" required:"true"`
|
||||
|
@ -12,7 +12,7 @@ const Url = "/v1/powerStationService/queryPowerStationInfo"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
Sn valueTypes.String `json:"sn"`
|
||||
}
|
||||
|
||||
@ -26,20 +26,20 @@ func (rd RequestData) Help() string {
|
||||
}
|
||||
|
||||
type ResultData struct {
|
||||
LbsAreaCode interface{} `json:"LbsAreaCode"`
|
||||
LbsCountry interface{} `json:"LbsCountry"`
|
||||
LbsAreaCode interface{} `json:"LbsAreaCode" PointId:"lbs_area_code"`
|
||||
LbsCountry interface{} `json:"LbsCountry" PointId:"lbs_country"`
|
||||
AccessType interface{} `json:"access_type"`
|
||||
AreaID interface{} `json:"area_id"`
|
||||
AreaId interface{} `json:"area_id"`
|
||||
ArrearsStatus valueTypes.Integer `json:"arrears_status"`
|
||||
BatteryType valueTypes.String `json:"battery_type"`
|
||||
CityCode interface{} `json:"city_code"`
|
||||
CityName interface{} `json:"city_name"`
|
||||
CityCode valueTypes.String `json:"city_code"`
|
||||
CityName valueTypes.String `json:"city_name"`
|
||||
ComponentArea interface{} `json:"component_area"`
|
||||
ComponentStatus valueTypes.Integer `json:"component_status"`
|
||||
ConnectType valueTypes.Integer `json:"connect_type"`
|
||||
ConnectTypeDesc valueTypes.String `json:"connect_type_desc"`
|
||||
ContactName valueTypes.String `json:"contact_name"`
|
||||
CountryID valueTypes.Integer `json:"country_id"`
|
||||
CountryId valueTypes.Integer `json:"country_id"`
|
||||
Description interface{} `json:"description"`
|
||||
DesignCapacity valueTypes.Float `json:"design_capacity" PointUnit:"W"` // @TODO - When this is set to valueTypes.Integer, we get a failure.
|
||||
DesignCapacityBattery valueTypes.Float `json:"design_capacity_battery" PointUnit:"W"`
|
||||
@ -74,9 +74,9 @@ type ResultData struct {
|
||||
MapLatitude valueTypes.Float `json:"map_latitude"`
|
||||
MapLongitude valueTypes.Float `json:"map_longitude"`
|
||||
MlpeFlag valueTypes.Bool `json:"mlpe_flag"`
|
||||
MobleTel interface{} `json:"moble_tel"`
|
||||
MobleTelBak interface{} `json:"moble_tel_bak"`
|
||||
ModuleModelID interface{} `json:"module_model_id"`
|
||||
MobileTel interface{} `json:"moble_tel" PointId:"mobile_tel"`
|
||||
MobileTelBak interface{} `json:"moble_tel_bak" PointId:"mobile_tel_bak"`
|
||||
ModuleModelId interface{} `json:"module_model_id"`
|
||||
ModuleModelName interface{} `json:"module_model_name"`
|
||||
Nmi valueTypes.String `json:"nmi"`
|
||||
OperationBusName interface{} `json:"operation_bus_name"`
|
||||
@ -87,16 +87,16 @@ type ResultData struct {
|
||||
ProvinceCode interface{} `json:"province_code"`
|
||||
ProvinceName interface{} `json:"province_name"`
|
||||
PsBuildDate valueTypes.DateTime `json:"ps_build_date"`
|
||||
PsCountryID valueTypes.Integer `json:"ps_country_id"`
|
||||
PsCreateUserID valueTypes.Integer `json:"ps_create_user_id"`
|
||||
PsCountryId valueTypes.Integer `json:"ps_country_id"`
|
||||
PsCreateUserId valueTypes.Integer `json:"ps_create_user_id"`
|
||||
PsCurrentTimeZone valueTypes.String `json:"ps_current_time_zone"`
|
||||
PsDirectOrgList []struct {
|
||||
OrgID valueTypes.Integer `json:"org_id"`
|
||||
OrgId valueTypes.Integer `json:"org_id"`
|
||||
OrgIndexCode valueTypes.String `json:"org_index_code"`
|
||||
OrgName valueTypes.String `json:"org_name"`
|
||||
} `json:"ps_direct_org_list"`
|
||||
PsHolder valueTypes.String `json:"ps_holder"`
|
||||
PsID valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
PsInstalledPower valueTypes.Float `json:"ps_installed_power"`
|
||||
PsKey valueTypes.PsKey `json:"ps_key"`
|
||||
PsLocation valueTypes.String `json:"ps_location"`
|
||||
@ -106,48 +106,48 @@ type ResultData struct {
|
||||
Installer valueTypes.String `json:"installer"`
|
||||
InstallerEmail valueTypes.String `json:"installer_email"`
|
||||
InstallerPhone valueTypes.String `json:"installer_phone"`
|
||||
OrgID valueTypes.Integer `json:"org_id"`
|
||||
OrgId valueTypes.Integer `json:"org_id"`
|
||||
OrgIndexCode valueTypes.String `json:"org_index_code"`
|
||||
OrgName valueTypes.String `json:"org_name"`
|
||||
PsDealerOrgCode valueTypes.String `json:"ps_dealer_org_code"`
|
||||
UpOrgID valueTypes.Integer `json:"up_org_id"`
|
||||
UpOrgId valueTypes.Integer `json:"up_org_id"`
|
||||
} `json:"ps_org_info"`
|
||||
PsPrice valueTypes.Float `json:"ps_price"`
|
||||
PsPriceKwh valueTypes.Float `json:"ps_price_kwh"`
|
||||
PsPrice valueTypes.Float `json:"ps_price" PointUnitFrom:"ParamIncomeUnitName"`
|
||||
PsPriceKwh valueTypes.Float `json:"ps_price_kwh" PointUnitFrom:"ParamIncomeUnitName"`
|
||||
PsType valueTypes.Integer `json:"ps_type"`
|
||||
PsTypeDesc valueTypes.String `json:"ps_type_desc"`
|
||||
PsTypeName valueTypes.String `json:"ps_type_name"`
|
||||
PsUserID valueTypes.Integer `json:"ps_user_id"`
|
||||
RecoreCreateTime valueTypes.DateTime `json:"recore_create_time"`
|
||||
PsUserId valueTypes.Integer `json:"ps_user_id"`
|
||||
RecordCreateTime valueTypes.DateTime `json:"recore_create_time" PointId:"record_create_time"`
|
||||
SafeStartDate valueTypes.DateTime `json:"safe_start_date"`
|
||||
SelectedOrgList []struct {
|
||||
OrgID valueTypes.Integer `json:"org_id"`
|
||||
OrgId valueTypes.Integer `json:"org_id"`
|
||||
OrgIndexCode valueTypes.String `json:"org_index_code"`
|
||||
OrgName valueTypes.String `json:"org_name"`
|
||||
} `json:"selectedOrgList"`
|
||||
} `json:"selectedOrgList" PointId:"selected_org_list"`
|
||||
SetUserOrg valueTypes.Integer `json:"set_user_org"`
|
||||
ShareType valueTypes.Integer `json:"share_type"`
|
||||
ShareUserType interface{} `json:"share_user_type"`
|
||||
ShippingAddress valueTypes.String `json:"shipping_address"`
|
||||
ShippingZipCode valueTypes.String `json:"shipping_zip_code"`
|
||||
Sn valueTypes.String `json:"sn"`
|
||||
Sn valueTypes.String `json:"sn" PointName:"Serial Number"`
|
||||
SnDetailList []struct {
|
||||
CommunicateDeviceType valueTypes.Integer `json:"communicate_device_type"`
|
||||
CommunicateDeviceTypeName valueTypes.String `json:"communicate_device_type_name"`
|
||||
ID valueTypes.Integer `json:"id"`
|
||||
Id valueTypes.Integer `json:"id"`
|
||||
IsEnable valueTypes.Bool `json:"is_enable"`
|
||||
Sn valueTypes.String `json:"sn"`
|
||||
} `json:"sn_detail_list"`
|
||||
SummerTimeState valueTypes.Bool `json:"summer_time_state"`
|
||||
SummerTimeZone valueTypes.String `json:"summer_time_zone"`
|
||||
SummerTimeZoneID valueTypes.Integer `json:"summer_time_zone_id"`
|
||||
TimeZoneID valueTypes.Integer `json:"time_zone_id"`
|
||||
SummerTimeZoneId valueTypes.Integer `json:"summer_time_zone_id"`
|
||||
TimeZoneId valueTypes.Integer `json:"time_zone_id"`
|
||||
Timezone valueTypes.String `json:"timezone"`
|
||||
UserAccount valueTypes.String `json:"user_account"`
|
||||
UserCapacityStatus valueTypes.Integer `json:"user_capacity_status"`
|
||||
UserEnglishName interface{} `json:"user_english_name"`
|
||||
UserLanguage valueTypes.String `json:"user_language"`
|
||||
UserMobleTel interface{} `json:"user_moble_tel"`
|
||||
UserMobileTel interface{} `json:"user_moble_tel" PointId:"user_mobile_tel"`
|
||||
UserName valueTypes.String `json:"user_name"`
|
||||
UserTelNationCode interface{} `json:"user_tel_nation_code"`
|
||||
ValidFlag valueTypes.Bool `json:"valid_flag"`
|
||||
|
@ -13,7 +13,7 @@ const Url = "/v1/devService/queryPsNameByPsId"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
|
@ -12,8 +12,8 @@ const Url = "/v1/powerStationService/queryPsProfit"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
DateID string `json:"date_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
DateId string `json:"date_id" required:"true"`
|
||||
DateType string `json:"date_type" required:"true"`
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ type ResultData struct {
|
||||
CuspNetPowerQuantity interface{} `json:"cusp_net_power_quantity"`
|
||||
CuspPowerQuantity interface{} `json:"cusp_power_quantity"`
|
||||
CuspUsePowerQuantity interface{} `json:"cusp_use_power_quantity"`
|
||||
DateID valueTypes.DateTime `json:"date_id"`
|
||||
DateId valueTypes.DateTime `json:"date_id"`
|
||||
FlatNetPowerQuantity valueTypes.Float `json:"flat_net_power_quantity"`
|
||||
FlatPowerQuantity valueTypes.Float `json:"flat_power_quantity"`
|
||||
FlatUsePowerQuantity valueTypes.Float `json:"flat_use_power_quantity"`
|
||||
|
@ -335,22 +335,6 @@ func (e EndPoint) CacheFilename() string {
|
||||
return e.ApiCacheFilename(e.Request.RequestData)
|
||||
}
|
||||
|
||||
// // CheckCache - Check if a cache file exists for this EndPoint.
|
||||
// func (e EndPoint) CheckCache() bool {
|
||||
// return e.ApiCheckCache(e.Request.RequestData)
|
||||
// }
|
||||
//
|
||||
// // ReadCache - Read a cache file and return it as an EndPoint structure.
|
||||
// func (e EndPoint) ReadCache() api.EndPoint {
|
||||
// e.Error = e.ApiReadCache(e.Request.RequestData, &e)
|
||||
// return e
|
||||
// }
|
||||
//
|
||||
// // WriteCache - Write this EndPoint structure out to a cache file.
|
||||
// func (e EndPoint) WriteCache() error {
|
||||
// return e.ApiWriteCache(e.Request.RequestData, e)
|
||||
// }
|
||||
|
||||
// SetCacheTimeout - Set the cache timeout for this EndPoint. (Defaults to 1 hour.)
|
||||
func (e EndPoint) SetCacheTimeout(duration time.Duration) api.EndPoint {
|
||||
e.ApiRoot.SetCacheTimeout(duration)
|
||||
|
@ -27,7 +27,7 @@ func (rd RequestData) Help() string {
|
||||
type ResultData []struct {
|
||||
IsBasicUnit valueTypes.Bool `json:"is_basic_unit"`
|
||||
TargetUnit string `json:"target_unit"`
|
||||
UnitConverID valueTypes.Integer `json:"unit_conver_id"`
|
||||
UnitConverId valueTypes.Integer `json:"unit_conver_id"`
|
||||
UnitName string `json:"unit_name"`
|
||||
UnitType valueTypes.Integer `json:"unit_type"`
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ func (rd RequestData) Help() string {
|
||||
}
|
||||
|
||||
type ResultData []struct {
|
||||
UserID valueTypes.Integer `json:"user_id"`
|
||||
UserId valueTypes.Integer `json:"user_id"`
|
||||
UserName string `json:"user_name"`
|
||||
}
|
||||
|
||||
|
@ -12,10 +12,8 @@ const Url = "/v1/powerStationService/reportList"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id"`
|
||||
ReportType string `json:"report_type"`
|
||||
// DateID string `json:"date_id,omitempty"`
|
||||
// DateType string `json:"date_type,omitempty"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
ReportType string `json:"report_type" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -23,7 +21,11 @@ func (rd RequestData) IsValid() error {
|
||||
}
|
||||
|
||||
func (rd RequestData) Help() string {
|
||||
ret := fmt.Sprintf("report_type: ")
|
||||
ret := fmt.Sprintf("report_type is from 1-4")
|
||||
ret += fmt.Sprintf("1: Day Report.")
|
||||
ret += fmt.Sprintf("2: Month Report.")
|
||||
ret += fmt.Sprintf("3: Year Report.")
|
||||
ret += fmt.Sprintf("4: Total Report.")
|
||||
return ret
|
||||
}
|
||||
|
||||
@ -34,7 +36,7 @@ type ResultData struct {
|
||||
InstallerPsFaultStatus valueTypes.Integer `json:"installer_ps_fault_status"`
|
||||
OwnerPsFaultStatus valueTypes.Integer `json:"owner_ps_fault_status"`
|
||||
PsFaultStatus valueTypes.Integer `json:"ps_fault_status"`
|
||||
PsId valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
PsName valueTypes.String `json:"ps_name"`
|
||||
PsStatus valueTypes.Integer `json:"ps_status"`
|
||||
PsType valueTypes.Integer `json:"ps_type"`
|
||||
@ -43,14 +45,14 @@ type ResultData struct {
|
||||
SysSchemeName valueTypes.String `json:"sys_scheme_name"`
|
||||
ValidFlag valueTypes.Bool `json:"valid_flag"`
|
||||
} `json:"info"`
|
||||
MinDateID interface{} `json:"min_date_id"`
|
||||
Total []DataList `json:"total" PointId:"total" PointIgnoreIfNilFromChild:"UpdateTime" PointNameFromChild:"DateId" PointNameDateFormat:"20060102" PointNameFromAppend:"true"`
|
||||
MinDateId interface{} `json:"min_date_id"`
|
||||
Total []DataList `json:"total" PointId:"total" PointIgnoreIfNilFromChild:"UpdateTime" PointNameFromChild:"UpdateTime" PointNameDateFormat:"20060102" PointNameFromAppend:"true"`
|
||||
}
|
||||
|
||||
type DataList struct {
|
||||
DateId valueTypes.DateTime `json:"date_id"`
|
||||
DeviceName interface{} `json:"device_name"`
|
||||
PsId valueTypes.Integer `json:"ps_id"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
TimeStamp interface{} `json:"time_stamp"` // Sad that this alternates between string and valueTypes.Integer.
|
||||
UpdateTime valueTypes.DateTime `json:"update_time"`
|
||||
UUID interface{} `json:"uuid"`
|
||||
|
@ -12,7 +12,7 @@ const Url = "/v1/powerStationService/getPsIdState"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
|
@ -4,16 +4,15 @@ import (
|
||||
"GoSungrow/iSolarCloud/api"
|
||||
"GoSungrow/iSolarCloud/api/apiReflect"
|
||||
"GoSungrow/iSolarCloud/api/valueTypes"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
)
|
||||
|
||||
const Url = "/v1/reportService/getReportInfoByReportId"
|
||||
const Disabled = true
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
// DeviceType string `json:"device_type" required:"true"`
|
||||
ReportId valueTypes.String `json:"report_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -25,46 +24,43 @@ func (rd RequestData) Help() string {
|
||||
return ret
|
||||
}
|
||||
|
||||
|
||||
type ResultData struct {
|
||||
Dummy string `json:"dummy"`
|
||||
type ResultData []struct {
|
||||
CreateUserID valueTypes.Integer `json:"create_user_id"`
|
||||
ID valueTypes.Integer `json:"id"`
|
||||
ReportID valueTypes.Integer `json:"report_id"`
|
||||
ReportName valueTypes.String `json:"report_name"`
|
||||
ReportPsType valueTypes.Integer `json:"report_ps_type"`
|
||||
ReportTemplatePeriod valueTypes.Integer `json:"report_template_period"`
|
||||
ReportTemplateType valueTypes.Integer `json:"report_template_type"`
|
||||
PsIDList interface{} `json:"ps_id_list"`
|
||||
SamplingPeriod interface{} `json:"sampling_period"`
|
||||
TimeDimension valueTypes.Integer `json:"time_dimension"`
|
||||
UserIds valueTypes.Integer `json:"user_ids"`
|
||||
PointColumn valueTypes.String `json:"point_column" PointSplitOn:","`
|
||||
PointName valueTypes.String `json:"point_name" PointSplitOn:","`
|
||||
Ratio valueTypes.String `json:"ratio" PointSplitOn:","`
|
||||
ReportTemplatePoint valueTypes.String `json:"report_template_point" PointSplitOn:","`
|
||||
}
|
||||
|
||||
func (e *ResultData) IsValid() error {
|
||||
var err error
|
||||
switch {
|
||||
case e.Dummy == "":
|
||||
break
|
||||
default:
|
||||
err = errors.New(fmt.Sprintf("unknown error '%s'", e.Dummy))
|
||||
}
|
||||
// switch {
|
||||
// case e.Dummy == "":
|
||||
// break
|
||||
// default:
|
||||
// err = errors.New(fmt.Sprintf("unknown error '%s'", e.Dummy))
|
||||
// }
|
||||
return err
|
||||
}
|
||||
|
||||
//type DecodeResultData ResultData
|
||||
//
|
||||
//func (e *ResultData) UnmarshalJSON(data []byte) error {
|
||||
// var err error
|
||||
//
|
||||
// for range Only.Once {
|
||||
// if len(data) == 0 {
|
||||
// break
|
||||
// }
|
||||
// var pd DecodeResultData
|
||||
//
|
||||
// // Store ResultData
|
||||
// _ = json.Unmarshal(data, &pd)
|
||||
// e.Dummy = pd.Dummy
|
||||
// }
|
||||
//
|
||||
// return err
|
||||
//}
|
||||
|
||||
func (e *EndPoint) GetData() api.DataMap {
|
||||
entries := api.NewDataMap()
|
||||
|
||||
for range Only.Once {
|
||||
entries.StructToPoints(e.Response.ResultData, apiReflect.GetName("", *e), "system", valueTypes.NewDateTime(""))
|
||||
pkg := apiReflect.GetName("", *e)
|
||||
dt := valueTypes.NewDateTime(valueTypes.Now)
|
||||
name := pkg + "." + e.Request.ReportId.String()
|
||||
entries.StructToPoints(e.Response.ResultData, name, e.Request.ReportId.String(), dt)
|
||||
}
|
||||
|
||||
return entries
|
||||
|
@ -4,13 +4,12 @@ import (
|
||||
"GoSungrow/iSolarCloud/api"
|
||||
"GoSungrow/iSolarCloud/api/apiReflect"
|
||||
"GoSungrow/iSolarCloud/api/valueTypes"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
)
|
||||
|
||||
const Url = "/v1/reportService/getReportListByType"
|
||||
const Disabled = true
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
// DeviceType string `json:"device_type" required:"true"`
|
||||
@ -26,45 +25,37 @@ func (rd RequestData) Help() string {
|
||||
}
|
||||
|
||||
|
||||
type ResultData struct {
|
||||
Dummy string `json:"dummy"`
|
||||
type ResultData []struct {
|
||||
CreateTime valueTypes.DateTime `json:"create_time"`
|
||||
Cycle valueTypes.Integer `json:"cycle"`
|
||||
ID valueTypes.Integer `json:"id"`
|
||||
MonthDate valueTypes.String `json:"month_date"`
|
||||
PsID valueTypes.PsId `json:"ps_id"`
|
||||
ReportName valueTypes.String `json:"report_name"`
|
||||
ReportType valueTypes.Integer `json:"report_type"`
|
||||
Status valueTypes.Bool `json:"status"`
|
||||
UpdateTime valueTypes.DateTime `json:"update_time"`
|
||||
}
|
||||
|
||||
func (e *ResultData) IsValid() error {
|
||||
var err error
|
||||
switch {
|
||||
case e.Dummy == "":
|
||||
break
|
||||
default:
|
||||
err = errors.New(fmt.Sprintf("unknown error '%s'", e.Dummy))
|
||||
}
|
||||
// switch {
|
||||
// case e.Dummy == "":
|
||||
// break
|
||||
// default:
|
||||
// err = errors.New(fmt.Sprintf("unknown error '%s'", e.Dummy))
|
||||
// }
|
||||
return err
|
||||
}
|
||||
|
||||
//type DecodeResultData ResultData
|
||||
//
|
||||
//func (e *ResultData) UnmarshalJSON(data []byte) error {
|
||||
// var err error
|
||||
//
|
||||
// for range Only.Once {
|
||||
// if len(data) == 0 {
|
||||
// break
|
||||
// }
|
||||
// var pd DecodeResultData
|
||||
//
|
||||
// // Store ResultData
|
||||
// _ = json.Unmarshal(data, &pd)
|
||||
// e.Dummy = pd.Dummy
|
||||
// }
|
||||
//
|
||||
// return err
|
||||
//}
|
||||
|
||||
func (e *EndPoint) GetData() api.DataMap {
|
||||
entries := api.NewDataMap()
|
||||
|
||||
for range Only.Once {
|
||||
entries.StructToPoints(e.Response.ResultData, apiReflect.GetName("", *e), "system", valueTypes.NewDateTime(""))
|
||||
pkg := apiReflect.GetName("", *e)
|
||||
dt := valueTypes.NewDateTime(valueTypes.Now)
|
||||
// name := pkg + "." + e.Request.DateId.Format(valueTypes.DateTimeLayoutDay)
|
||||
entries.StructToPoints(e.Response.ResultData, pkg, "system", dt)
|
||||
}
|
||||
|
||||
return entries
|
||||
|
@ -4,16 +4,16 @@ import (
|
||||
"GoSungrow/iSolarCloud/api"
|
||||
"GoSungrow/iSolarCloud/api/apiReflect"
|
||||
"GoSungrow/iSolarCloud/api/valueTypes"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
)
|
||||
|
||||
const Url = "/v1/reportService/getReportPsTree"
|
||||
const Disabled = true
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
// DeviceType string `json:"device_type" required:"true"`
|
||||
DeviceType string `json:"device_type" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -41,30 +41,14 @@ func (e *ResultData) IsValid() error {
|
||||
return err
|
||||
}
|
||||
|
||||
//type DecodeResultData ResultData
|
||||
//
|
||||
//func (e *ResultData) UnmarshalJSON(data []byte) error {
|
||||
// var err error
|
||||
//
|
||||
// for range Only.Once {
|
||||
// if len(data) == 0 {
|
||||
// break
|
||||
// }
|
||||
// var pd DecodeResultData
|
||||
//
|
||||
// // Store ResultData
|
||||
// _ = json.Unmarshal(data, &pd)
|
||||
// e.Dummy = pd.Dummy
|
||||
// }
|
||||
//
|
||||
// return err
|
||||
//}
|
||||
|
||||
func (e *EndPoint) GetData() api.DataMap {
|
||||
entries := api.NewDataMap()
|
||||
|
||||
for range Only.Once {
|
||||
entries.StructToPoints(e.Response.ResultData, apiReflect.GetName("", *e), "system", valueTypes.NewDateTime(""))
|
||||
pkg := apiReflect.GetName("", *e)
|
||||
dt := valueTypes.NewDateTime(valueTypes.Now)
|
||||
// name := pkg + "." + e.Request.DateId.Format(valueTypes.DateTimeLayoutDay)
|
||||
entries.StructToPoints(e.Response.ResultData, pkg, "system", dt)
|
||||
}
|
||||
|
||||
return entries
|
||||
|
@ -15,7 +15,7 @@ const Disabled = false
|
||||
|
||||
// {"template_id":"","date_type":"","start_time":"","end_time":""}
|
||||
type RequestData struct {
|
||||
TemplateID string `json:"template_id" required:"true"`
|
||||
TemplateId string `json:"template_id" required:"true"`
|
||||
// DateType string `json:"date_type" required:"true"`
|
||||
// StartTime string `json:"start_time" required:"true"`
|
||||
// EndTime string `json:"end_time" required:"true"`
|
||||
@ -48,7 +48,7 @@ type ResultData struct {
|
||||
OpenTime string `json:"open_time"`
|
||||
PointsData PointsData `json:"points_data"`
|
||||
StartTime string `json:"start_time"`
|
||||
TemplateID string `json:"template_id"`
|
||||
TemplateId string `json:"template_id"`
|
||||
TemplateName string `json:"template_name"`
|
||||
UpdateTime string `json:"update_time"`
|
||||
}
|
||||
@ -116,7 +116,7 @@ func (p *DeviceData) UnmarshalJSON(data []byte) error {
|
||||
// Store DeviceData.Points
|
||||
_ = json.Unmarshal(data, &dd.Points)
|
||||
for i, k := range dd.Points {
|
||||
if k.PointID.String() == "" {
|
||||
if k.PointId.String() == "" {
|
||||
delete(dd.Points, i)
|
||||
continue
|
||||
}
|
||||
@ -135,11 +135,11 @@ type Point struct {
|
||||
TimeStamp string `json:"time_stamp"`
|
||||
Value string `json:"value"`
|
||||
} `json:"data_list"`
|
||||
DetailID string `json:"detail_id"`
|
||||
PointID valueTypes.PointId `json:"point_id"`
|
||||
DetailId string `json:"detail_id"`
|
||||
PointId valueTypes.PointId `json:"point_id"`
|
||||
PointName string `json:"point_name"`
|
||||
PsID string `json:"ps_id"`
|
||||
PsKey string `json:"ps_key"`
|
||||
PsId valueTypes.PsId `json:"ps_id"`
|
||||
PsKey valueTypes.PsKey `json:"ps_key"`
|
||||
PsName string `json:"ps_name"`
|
||||
Statistics string `json:"statistics"`
|
||||
Style string `json:"style"`
|
||||
|
@ -12,7 +12,7 @@ const Url = "/v1/powerStationService/showPSView"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
|
@ -12,7 +12,7 @@ const Url = "/v1/devService/getMaxDeviceIdByPsId"
|
||||
const Disabled = false
|
||||
|
||||
type RequestData struct {
|
||||
PsId valueTypes.Integer `json:"ps_id" required:"true"`
|
||||
PsId valueTypes.PsId `json:"ps_id" required:"true"`
|
||||
}
|
||||
|
||||
func (rd RequestData) IsValid() error {
|
||||
@ -26,7 +26,7 @@ func (rd RequestData) Help() string {
|
||||
|
||||
|
||||
type ResultData struct {
|
||||
MaxDeviceID valueTypes.Integer `json:"max_device_id"`
|
||||
MaxDeviceId valueTypes.Integer `json:"max_device_id"`
|
||||
}
|
||||
|
||||
func (e *ResultData) IsValid() error {
|
||||
|
@ -19,42 +19,45 @@ import (
|
||||
|
||||
|
||||
const (
|
||||
PointId = "PointId" // Point id in the form p\d+ or \d+
|
||||
PointParentId = "PointParentId" // Associated parent of point.
|
||||
PointUpdateFreq = "PointUpdateFreq" // Point update frequency - Total, Yearly, Monthly, Day.
|
||||
PointValueType = "PointValueType" // Value type of point: energy, date, battery, temperature.
|
||||
PointIgnore = "PointIgnore" // Ignore this point.
|
||||
PointIgnoreIfNil = "PointIgnoreIfNil" // Ignore this point if a child is nil or empty.
|
||||
PointId = "PointId" // Point id in the form p\d+ or \d+
|
||||
PointParentId = "PointParentId" // Associated parent of point.
|
||||
PointUpdateFreq = "PointUpdateFreq" // Point update frequency - Total, Yearly, Monthly, Day.
|
||||
PointValueType = "PointValueType" // Value type of point: energy, date, battery, temperature.
|
||||
PointIgnore = "PointIgnore" // Ignore this point.
|
||||
PointIgnoreIfNil = "PointIgnoreIfNil" // Ignore this point if a child is nil or empty.
|
||||
PointIgnoreIfNilFromChild = "PointIgnoreIfNilFromChild" // Ignore this point if a child is nil or empty.
|
||||
|
||||
PointAliasTo = "PointAliasTo" // Alias this point to another point.
|
||||
PointAliasFrom = "PointAliasFrom" // Alias this point from another point.
|
||||
PointAliasTo = "PointAliasTo" // Alias this point to another point.
|
||||
PointAliasFrom = "PointAliasFrom" // Alias this point from another point.
|
||||
|
||||
PointUnit = "PointUnit" // Units: Wh, kWh, C, h.
|
||||
PointUnitFrom = "PointUnitFrom" // Get PointUnit from another field structure.
|
||||
PointUnitFromParent = "PointUnitFromParent" // Get PointUnit from another parent field structure.
|
||||
|
||||
PointGroupName = "PointGroupName" // Point group name.
|
||||
PointGroupNameFrom = "PointGroupNameFrom" // Get PointGroupName from another field structure.
|
||||
PointGroupName = "PointGroupName" // Point group name.
|
||||
PointGroupNameFrom = "PointGroupNameFrom" // Get PointGroupName from another field structure.
|
||||
|
||||
PointName = "PointName" // Human-readable name of point.
|
||||
PointNameFromChild = "PointNameFromChild" // Searches child for field value to use for naming when hitting a slice, (as opposed to using an index).
|
||||
PointNameFromParent = "PointNameFromParent" // Searches child for field value to use for naming when hitting a slice, (as opposed to using an index).
|
||||
PointNameDateFormat = "PointNameDateFormat" // Date format when using PointNameFrom, (if the field is a time.Time type).
|
||||
PointNameFromAppend = "PointNameFromAppend" // Append PointNameFrom instead of replace.
|
||||
PointNameFromAppend = "PointNameFromAppend" // Append PointNameFrom instead of replace.
|
||||
|
||||
PointArrayFlatten = "PointArrayFlatten" // Flatten an array into a string. EG: ["one", "two", "three"]
|
||||
PointIgnoreZero = "PointIgnoreZero" // Ignore arrays with zero size, (default true).
|
||||
PointArrayFlatten = "PointArrayFlatten" // Flatten an array into a string. EG: ["one", "two", "three"]
|
||||
PointSplitOn = "PointSplitOn" // Split a point into an array separating by defined string.
|
||||
PointSplitOnType = "PointSplitOnType" // What valueTypes will be used for a split.
|
||||
PointIgnoreZero = "PointIgnoreZero" // Ignore arrays with zero size, (default true).
|
||||
|
||||
PointTimestampFrom = "PointTimestampFrom" // Pull timestamp from another field structure.
|
||||
PointTimestampFrom = "PointTimestampFrom" // Pull timestamp from another field structure.
|
||||
)
|
||||
|
||||
const (
|
||||
UpdateFreqInstant = "instant"
|
||||
UpdateFreq5Mins = "5mins"
|
||||
UpdateFreqBoot = "boot"
|
||||
UpdateFreqDay = "daily"
|
||||
UpdateFreqMonth = "monthly"
|
||||
UpdateFreqYear = "yearly"
|
||||
UpdateFreqDay = "daily"
|
||||
UpdateFreqMonth = "monthly"
|
||||
UpdateFreqYear = "yearly"
|
||||
UpdateFreqTotal = "total"
|
||||
)
|
||||
|
||||
@ -62,6 +65,7 @@ const (
|
||||
type Reflect struct {
|
||||
Valid bool
|
||||
DataStructure DataStructure
|
||||
Parent interface{}
|
||||
Interface interface{}
|
||||
IsNil bool
|
||||
IsExported bool
|
||||
@ -76,14 +80,15 @@ type Reflect struct {
|
||||
FieldVo reflect.Value
|
||||
}
|
||||
|
||||
func (r *Reflect) SetByFieldName(parent interface{}, ref interface{}, fieldName string) { // , fieldTo reflect.StructField, fieldVo reflect.Value) {
|
||||
func (r *Reflect) SetByFieldName(parent interface{}, current interface{}, fieldName string) { // , fieldTo reflect.StructField, fieldVo reflect.Value) {
|
||||
for range Only.Once {
|
||||
r.Valid = true
|
||||
r.Interface = ref
|
||||
r.IsNil = valueTypes.IsNil(ref)
|
||||
r.IsUnknown = valueTypes.IsUnknownStruct(ref)
|
||||
r.TypeOf = reflect.TypeOf(ref)
|
||||
r.ValueOf = reflect.ValueOf(ref)
|
||||
r.Parent = parent
|
||||
r.Interface = current
|
||||
r.IsNil = valueTypes.IsNil(current)
|
||||
r.IsUnknown = valueTypes.IsUnknownStruct(current)
|
||||
r.TypeOf = reflect.TypeOf(current)
|
||||
r.ValueOf = reflect.ValueOf(current)
|
||||
r.Kind = r.TypeOf.Kind()
|
||||
r.FieldName = fieldName
|
||||
|
||||
@ -103,16 +108,41 @@ func (r *Reflect) SetByFieldName(parent interface{}, ref interface{}, fieldName
|
||||
r.Length = len(r.ValueOf.MapKeys())
|
||||
}
|
||||
|
||||
r.SetFieldName(parent, fieldName)
|
||||
r.SetFieldName(parent, current, fieldName)
|
||||
// r.DataStructure = r.DataStructure.Set(ref, r.FieldTo, r.FieldVo)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Reflect) SetByIndex(parent interface{}, fieldIndex int) {
|
||||
func (r *Reflect) SetFieldName(parent interface{}, current interface{}, fieldName string) { // , fieldTo reflect.StructField, fieldVo reflect.Value) {
|
||||
for range Only.Once {
|
||||
if fieldName == "" {
|
||||
break
|
||||
}
|
||||
|
||||
p := reflect.TypeOf(current)
|
||||
if p.Kind() != reflect.Struct {
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
sf, ok := p.FieldByName(fieldName)
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
|
||||
r.FieldTo = sf
|
||||
r.IsExported = r.FieldTo.IsExported()
|
||||
r.FieldVo = reflect.ValueOf(current).FieldByName(fieldName)
|
||||
|
||||
r.DataStructure = r.DataStructure.Set(parent, current, r.FieldTo, r.FieldVo)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Reflect) SetByIndex(parent interface{}, current interface{}, fieldIndex int) {
|
||||
for range Only.Once {
|
||||
// Get child interface from parent.
|
||||
pt := reflect.TypeOf(parent)
|
||||
pv := reflect.ValueOf(parent)
|
||||
pt := reflect.TypeOf(current)
|
||||
pv := reflect.ValueOf(current)
|
||||
pk := pt.Kind()
|
||||
switch pk {
|
||||
case reflect.Struct:
|
||||
@ -127,6 +157,7 @@ func (r *Reflect) SetByIndex(parent interface{}, fieldIndex int) {
|
||||
}
|
||||
|
||||
r.Valid = true
|
||||
r.Parent = parent
|
||||
r.IsNil = valueTypes.IsNil(r.Interface)
|
||||
r.IsUnknown = valueTypes.IsUnknownStruct(r.Interface)
|
||||
r.TypeOf = reflect.TypeOf(r.Interface)
|
||||
@ -151,63 +182,38 @@ func (r *Reflect) SetByIndex(parent interface{}, fieldIndex int) {
|
||||
r.Length = len(r.ValueOf.MapKeys())
|
||||
}
|
||||
|
||||
r.SetFieldNameByIndex(parent, fieldIndex)
|
||||
r.SetFieldNameByIndex(parent, current, fieldIndex)
|
||||
// r.DataStructure = r.DataStructure.Set(ref, r.FieldTo, r.FieldVo)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Reflect) SetFieldName(parent interface{}, fieldName string) { // , fieldTo reflect.StructField, fieldVo reflect.Value) {
|
||||
func (r *Reflect) SetFieldNameByIndex(parent interface{}, current interface{}, fieldIndex int) { // , fieldTo reflect.StructField, fieldVo reflect.Value) {
|
||||
for range Only.Once {
|
||||
if fieldName == "" {
|
||||
break
|
||||
}
|
||||
|
||||
p := reflect.TypeOf(parent)
|
||||
if p.Kind() != reflect.Struct {
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
sf, ok := p.FieldByName(fieldName)
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
|
||||
r.FieldTo = sf
|
||||
r.IsExported = r.FieldTo.IsExported()
|
||||
r.FieldVo = reflect.ValueOf(parent).FieldByName(fieldName)
|
||||
|
||||
r.DataStructure = r.DataStructure.Set(parent, r.FieldTo, r.FieldVo)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Reflect) SetFieldNameByIndex(parent interface{}, fieldIndex int) { // , fieldTo reflect.StructField, fieldVo reflect.Value) {
|
||||
for range Only.Once {
|
||||
p := reflect.TypeOf(parent)
|
||||
p := reflect.TypeOf(current)
|
||||
if p.Kind() == reflect.Struct {
|
||||
r.FieldTo = p.Field(fieldIndex)
|
||||
r.IsExported = r.FieldTo.IsExported()
|
||||
r.FieldVo = reflect.ValueOf(parent).Field(fieldIndex)
|
||||
r.FieldVo = reflect.ValueOf(current).Field(fieldIndex)
|
||||
r.FieldName = r.FieldTo.Name
|
||||
|
||||
r.DataStructure = r.DataStructure.Set(parent, r.FieldTo, r.FieldVo)
|
||||
r.DataStructure = r.DataStructure.Set(parent, current, r.FieldTo, r.FieldVo)
|
||||
break
|
||||
}
|
||||
|
||||
if p.Kind() == reflect.Array {
|
||||
r.FieldTo = p.Field(fieldIndex)
|
||||
r.IsExported = r.FieldTo.IsExported()
|
||||
r.FieldVo = reflect.ValueOf(parent).Field(fieldIndex)
|
||||
r.FieldVo = reflect.ValueOf(current).Field(fieldIndex)
|
||||
r.FieldName = r.FieldTo.Name
|
||||
|
||||
r.DataStructure = r.DataStructure.Set(parent, r.FieldTo, r.FieldVo)
|
||||
r.DataStructure = r.DataStructure.Set(parent, current, r.FieldTo, r.FieldVo)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// setPointName - Are we using an index number for name or field key value?
|
||||
func (r *Reflect) setPointName(parentRef interface{}, childRef interface{}, name []string, index int) []string {
|
||||
func (r *Reflect) setPointName(parent interface{}, current interface{}, name []string, index int) []string {
|
||||
for range Only.Once {
|
||||
// pointTimestamp := time.Now()
|
||||
// pointTimestampFrom := fieldTo.Tag.Get(PointTimestampFrom)
|
||||
@ -222,7 +228,7 @@ func (r *Reflect) setPointName(parentRef interface{}, childRef interface{}, name
|
||||
switch {
|
||||
case r.DataStructure.PointNameFromChild != "":
|
||||
// PointNameFromChild - In this case points to a field within a CHILD struct.
|
||||
pn = GetPointNameFrom(childRef, r.DataStructure.PointNameFromChild, intSize, r.DataStructure.PointNameDateFormat)
|
||||
pn = GetPointNameFrom(current, r.DataStructure.PointNameFromChild, intSize, r.DataStructure.PointNameDateFormat)
|
||||
if r.DataStructure.PointNameFromAppend == "true" {
|
||||
name = append(name, pn)
|
||||
} else {
|
||||
@ -231,7 +237,7 @@ func (r *Reflect) setPointName(parentRef interface{}, childRef interface{}, name
|
||||
|
||||
case r.DataStructure.PointNameFromParent != "":
|
||||
// PointNameFromChild - In this case points to a field within a CHILD struct.
|
||||
pn = GetPointNameFrom(parentRef, r.DataStructure.PointNameFromParent, intSize, r.DataStructure.PointNameDateFormat)
|
||||
pn = GetPointNameFrom(parent, r.DataStructure.PointNameFromParent, intSize, r.DataStructure.PointNameDateFormat)
|
||||
if r.DataStructure.PointNameFromAppend == "true" {
|
||||
name = append(name, pn)
|
||||
} else {
|
||||
@ -248,44 +254,53 @@ func (r *Reflect) setPointName(parentRef interface{}, childRef interface{}, name
|
||||
|
||||
|
||||
type DataStructure struct {
|
||||
// PointType string
|
||||
Required bool
|
||||
Json string
|
||||
PointId string
|
||||
PointParentId string
|
||||
PointUnit string
|
||||
PointUnitFrom string
|
||||
PointTimestamp time.Time
|
||||
PointName string
|
||||
PointUpdateFreq string
|
||||
PointValueType string
|
||||
PointAliasTo string
|
||||
PointIgnore bool
|
||||
PointIgnoreIfNil string
|
||||
PointIgnoreIfNilFromChild string
|
||||
PointGroupName string
|
||||
PointGroupNameFrom string
|
||||
|
||||
PointTimestamp time.Time
|
||||
PointTimestampFrom string
|
||||
PointArrayFlatten string
|
||||
PointIgnoreZero bool
|
||||
|
||||
PointUnit string
|
||||
PointUnitFrom string
|
||||
PointUnitFromParent string
|
||||
|
||||
PointName string
|
||||
PointNameFromAppend string
|
||||
PointNameFromChild string
|
||||
PointNameFromParent string
|
||||
PointNameDateFormat string
|
||||
|
||||
Value interface{}
|
||||
ValueType string
|
||||
ValueKind string
|
||||
Endpoint string
|
||||
PointIgnore bool
|
||||
PointIgnoreZero bool
|
||||
PointIgnoreIfNil string
|
||||
PointIgnoreIfNilFromChild string
|
||||
|
||||
PointGroupName string
|
||||
PointGroupNameFrom string
|
||||
|
||||
PointArrayFlatten string
|
||||
PointSplitOn string
|
||||
PointSplitOnType string
|
||||
|
||||
Value interface{}
|
||||
ValueType string
|
||||
ValueKind string
|
||||
Endpoint string
|
||||
}
|
||||
|
||||
func (ds *DataStructure) Set(parentRef interface{}, fieldTo reflect.StructField, fieldVo reflect.Value) DataStructure {
|
||||
func (ds *DataStructure) Set(parent interface{}, current interface{}, fieldTo reflect.StructField, fieldVo reflect.Value) DataStructure {
|
||||
for range Only.Once {
|
||||
// sf, ok := reflect.TypeOf(parentRef).FieldByName(fieldName)
|
||||
// sf, ok := reflect.TypeOf(current).FieldByName(fieldName)
|
||||
// if !ok {
|
||||
// break
|
||||
// }
|
||||
// fieldTo := sf
|
||||
// fieldVo := reflect.ValueOf(parentRef).FieldByName(fieldName)
|
||||
// fieldVo := reflect.ValueOf(current).FieldByName(fieldName)
|
||||
|
||||
ignore := false
|
||||
if fieldTo.Tag.Get(PointIgnore) != "" {
|
||||
@ -294,7 +309,7 @@ func (ds *DataStructure) Set(parentRef interface{}, fieldTo reflect.StructField,
|
||||
|
||||
pointIgnoreIfNil := fieldTo.Tag.Get(PointIgnoreIfNil)
|
||||
if pointIgnoreIfNil != "" {
|
||||
ret := GetStringFrom(parentRef, pointIgnoreIfNil)
|
||||
ret := GetStringFrom(current, pointIgnoreIfNil)
|
||||
if (ret == "") || (ret == "--") {
|
||||
ignore = true
|
||||
}
|
||||
@ -330,20 +345,24 @@ func (ds *DataStructure) Set(parentRef interface{}, fieldTo reflect.StructField,
|
||||
|
||||
pointUnit := fieldTo.Tag.Get(PointUnit)
|
||||
pointUnitFrom := fieldTo.Tag.Get(PointUnitFrom)
|
||||
pointUnitFromParent := fieldTo.Tag.Get(PointUnitFromParent)
|
||||
if pointUnitFrom != "" {
|
||||
pointUnit = GetStringFrom(parentRef, pointUnitFrom)
|
||||
pointUnit = GetStringFrom(current, pointUnitFrom)
|
||||
}
|
||||
if pointUnitFromParent != "" {
|
||||
pointUnit = GetStringFrom(parent, pointUnitFromParent)
|
||||
}
|
||||
|
||||
pointGroupName := fieldTo.Tag.Get(PointGroupName)
|
||||
pointGroupNameFrom := fieldTo.Tag.Get(PointGroupNameFrom)
|
||||
if pointGroupNameFrom != "" {
|
||||
pointGroupName = GetStringFrom(parentRef, pointGroupNameFrom)
|
||||
pointGroupName = GetStringFrom(current, pointGroupNameFrom)
|
||||
}
|
||||
|
||||
pointTimestamp := time.Now()
|
||||
pointTimestampFrom := fieldTo.Tag.Get(PointTimestampFrom)
|
||||
if pointTimestampFrom != "" {
|
||||
pointTimestamp = GetTimestampFrom(parentRef, pointTimestampFrom, valueTypes.DateTimeLayout)
|
||||
pointTimestamp = GetTimestampFrom(current, pointTimestampFrom, valueTypes.DateTimeLayout)
|
||||
}
|
||||
|
||||
var valueType string
|
||||
@ -379,13 +398,21 @@ func (ds *DataStructure) Set(parentRef interface{}, fieldTo reflect.StructField,
|
||||
pointUpdateFreq = UpdateFreqTotal
|
||||
}
|
||||
|
||||
var required bool
|
||||
req := fieldTo.Tag.Get("required")
|
||||
if req == "true" {
|
||||
required = true
|
||||
}
|
||||
|
||||
*ds = DataStructure {
|
||||
Required: required,
|
||||
Json: pointJson,
|
||||
PointId: pointId,
|
||||
PointParentId: fieldTo.Tag.Get(PointParentId),
|
||||
|
||||
PointUnit: pointUnit,
|
||||
PointUnitFrom: pointUnitFrom,
|
||||
PointUnit: pointUnit,
|
||||
PointUnitFrom: pointUnitFrom,
|
||||
PointUnitFromParent: pointUnitFromParent,
|
||||
|
||||
PointTimestamp: pointTimestamp,
|
||||
PointTimestampFrom: pointTimestampFrom,
|
||||
@ -406,6 +433,8 @@ func (ds *DataStructure) Set(parentRef interface{}, fieldTo reflect.StructField,
|
||||
PointIgnoreIfNil: pointIgnoreIfNil,
|
||||
PointIgnoreIfNilFromChild: fieldTo.Tag.Get(PointIgnoreIfNilFromChild),
|
||||
PointArrayFlatten: fieldTo.Tag.Get(PointArrayFlatten),
|
||||
PointSplitOn: fieldTo.Tag.Get(PointSplitOn),
|
||||
PointSplitOnType: fieldTo.Tag.Get(PointSplitOnType),
|
||||
PointIgnoreZero: pointIgnoreZero,
|
||||
|
||||
Value: nil,
|
||||
@ -512,7 +541,7 @@ func (dss *DataStructures) GetPointTags(Parent Reflect, Current Reflect, name ..
|
||||
// @TODO - Need to cover types other than struct that may be referenced.
|
||||
|
||||
var Child Reflect
|
||||
Child.SetByIndex(Current.Interface, si)
|
||||
Child.SetByIndex(Parent.Interface, Current.Interface, si)
|
||||
name3 := Current.setPointName(Parent.Interface, Child.Interface, name, si)
|
||||
dss.GetPointTags(Current, Child, name3...)
|
||||
}
|
||||
@ -554,7 +583,7 @@ func (dss *DataStructures) GetPointTags(Parent Reflect, Current Reflect, name ..
|
||||
// @TODO - Need to cover types other than struct that may be referenced.
|
||||
|
||||
var Child Reflect
|
||||
Child.SetByIndex(Current.Interface, si)
|
||||
Child.SetByIndex(Parent.Interface, Current.Interface, si)
|
||||
name3 := Current.setPointName(Parent.Interface, Child.Interface, name, si)
|
||||
dss.GetPointTags(Current, Child, name3...)
|
||||
}
|
||||
@ -582,7 +611,7 @@ func (dss *DataStructures) GetPointTags(Parent Reflect, Current Reflect, name ..
|
||||
}
|
||||
}
|
||||
|
||||
Parent.SetByFieldName(Parent.Interface, Current.Interface, "")
|
||||
// Parent.SetByFieldName(Parent.Interface, Current.Interface, "")
|
||||
// n2 := append(name, Current.DataStructure.PointId)
|
||||
for _, key := range Current.FieldVo.MapKeys() {
|
||||
// @TODO - Implement pointNameFromChild / pointNameFromParent.
|
||||
@ -591,17 +620,26 @@ func (dss *DataStructures) GetPointTags(Parent Reflect, Current Reflect, name ..
|
||||
val := Current.FieldVo.MapIndex(key)
|
||||
Current.DataStructure.Value = val.Interface()
|
||||
Current.DataStructure.Endpoint = strings.Join(name, ".") + "." + Current.DataStructure.PointId
|
||||
|
||||
// @TODO - For integers, it'd be nice to format them with a 0 prefix.
|
||||
// ft := valueTypes.GetIntFormatForPrintf(r.Length)
|
||||
// pn := fmt.Sprintf(ft, index)
|
||||
// intSize := valueTypes.SizeOfInt(r.Length)
|
||||
// name3 := Current.setPointName(Parent.Interface, Current.Interface, name, si)
|
||||
// fmt.Printf("DEBUG: %s / %s\n", Current.DataStructure.Endpoint, name3)
|
||||
|
||||
// @TODO - Need to look at other types, besides known types.
|
||||
|
||||
dss.Add(Current.DataStructure)
|
||||
|
||||
if Current.DataStructure.PointSplitOn != "" {
|
||||
// We want to split a string into separate points - currently only handles string types.
|
||||
// @TODO - Fix this up! - Use PointSplitOnType
|
||||
soEP := Current.DataStructure.Endpoint
|
||||
soVal := valueTypes.AnyToValueString(Current.FieldVo.Interface(), 0, "")
|
||||
for soI, soV := range strings.Split(soVal, Current.DataStructure.PointSplitOn) {
|
||||
Current.DataStructure.Value = soV
|
||||
Current.DataStructure.Endpoint = fmt.Sprintf("%s.%d", soEP, soI)
|
||||
dss.Add(Current.DataStructure)
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
@ -620,11 +658,11 @@ func (dss *DataStructures) GetPointTags(Parent Reflect, Current Reflect, name ..
|
||||
}
|
||||
}
|
||||
|
||||
Parent.SetByFieldName(Parent.Interface, Current.Interface, "")
|
||||
// Parent.SetByFieldName(Parent.Interface, Current.Interface, "")
|
||||
// Iterate over all available fields and read the tag value
|
||||
for i := 0; i < Current.Length; i++ {
|
||||
var Child Reflect
|
||||
Child.SetByIndex(Current.Interface, i)
|
||||
Child.SetByIndex(Current.Parent, Current.Interface, i)
|
||||
name2 := append(name, Child.DataStructure.PointId)
|
||||
|
||||
if !Child.IsExported {
|
||||
@ -649,6 +687,18 @@ func (dss *DataStructures) GetPointTags(Parent Reflect, Current Reflect, name ..
|
||||
Child.DataStructure.Value = Child.Interface
|
||||
Child.DataStructure.Endpoint = strings.Join(name, ".") + "." + Child.DataStructure.PointId
|
||||
dss.Add(Child.DataStructure)
|
||||
|
||||
if Child.DataStructure.PointSplitOn != "" {
|
||||
// We want to split a string into separate points - currently only handles string types.
|
||||
// @TODO - Fix this up! - Use PointSplitOnType
|
||||
soEP := Child.DataStructure.Endpoint
|
||||
soVal := valueTypes.AnyToValueString(Child.FieldVo.Interface(), 0, "")
|
||||
for soI, soV := range strings.Split(soVal, Child.DataStructure.PointSplitOn) {
|
||||
Child.DataStructure.Value = soV
|
||||
Child.DataStructure.Endpoint = fmt.Sprintf("%s.%d", soEP, soI)
|
||||
dss.Add(Child.DataStructure)
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
@ -673,7 +723,6 @@ func (dss *DataStructures) GetPointTags(Parent Reflect, Current Reflect, name ..
|
||||
fallthrough
|
||||
case reflect.UnsafePointer:
|
||||
dss.GetPointTags(Current, Child, name2...)
|
||||
continue
|
||||
|
||||
default:
|
||||
// @TODO - Need to fix this!
|
||||
@ -681,6 +730,18 @@ func (dss *DataStructures) GetPointTags(Parent Reflect, Current Reflect, name ..
|
||||
Child.DataStructure.Value = Child.Interface
|
||||
Child.DataStructure.Endpoint = strings.Join(name, ".") + "." + Child.DataStructure.PointId
|
||||
dss.Add(Child.DataStructure)
|
||||
|
||||
if Child.DataStructure.PointSplitOn != "" {
|
||||
// We want to split a string into separate points - currently only handles string types.
|
||||
// @TODO - Fix this up! - Use PointSplitOnType
|
||||
soEP := Current.DataStructure.Endpoint
|
||||
soVal := valueTypes.AnyToValueString(Child.FieldVo.Interface(), 0, "")
|
||||
for soI, soV := range strings.Split(soVal, Child.DataStructure.PointSplitOn) {
|
||||
Child.DataStructure.Value = soV
|
||||
Child.DataStructure.Endpoint = fmt.Sprintf("%s.%d", soEP, soI)
|
||||
dss.Add(Child.DataStructure)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
@ -710,14 +771,14 @@ func GetStructFields(ref interface{}) map[string]string {
|
||||
// Iterate over all available fields and read the tag value
|
||||
for i := 0; i < Ref.Length; i++ {
|
||||
var Child Reflect
|
||||
Child.SetByIndex(Ref.Interface, i)
|
||||
Child.SetByIndex(Ref.Interface, Ref.Interface, i)
|
||||
// SetFieldNameByIndex
|
||||
|
||||
if !Child.IsExported {
|
||||
continue
|
||||
}
|
||||
|
||||
ret[Child.FieldName] = Child.DataStructure.Json
|
||||
ret[Child.FieldName] = fmt.Sprintf("%v", Child.DataStructure.Required)
|
||||
}
|
||||
break
|
||||
}
|
||||
@ -726,6 +787,70 @@ func GetStructFields(ref interface{}) map[string]string {
|
||||
return ret
|
||||
}
|
||||
|
||||
func GetStructFieldsAsArray(ref interface{}) []string {
|
||||
var ret []string
|
||||
|
||||
for range Only.Once {
|
||||
var Ref Reflect
|
||||
Ref.SetByFieldName(ref, ref, "")
|
||||
|
||||
if Ref.Kind == reflect.Struct {
|
||||
if Ref.Length == 0 {
|
||||
if Ref.DataStructure.PointIgnoreZero {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate over all available fields and read the tag value
|
||||
for i := 0; i < Ref.Length; i++ {
|
||||
var Child Reflect
|
||||
Child.SetByIndex(Ref.Interface, Ref.Interface, i)
|
||||
// SetFieldNameByIndex
|
||||
|
||||
if !Child.IsExported {
|
||||
continue
|
||||
}
|
||||
|
||||
ret = append(ret, Child.FieldName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func GetStructValuesAsArray(ref interface{}) []string {
|
||||
var ret []string
|
||||
|
||||
for range Only.Once {
|
||||
var Ref Reflect
|
||||
Ref.SetByFieldName(ref, ref, "")
|
||||
|
||||
if Ref.Kind == reflect.Struct {
|
||||
if Ref.Length == 0 {
|
||||
if Ref.DataStructure.PointIgnoreZero {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate over all available fields and read the tag value
|
||||
for i := 0; i < Ref.Length; i++ {
|
||||
var Child Reflect
|
||||
Child.SetByIndex(Ref.Interface, Ref.Interface, i)
|
||||
// SetFieldNameByIndex
|
||||
|
||||
if !Child.IsExported {
|
||||
continue
|
||||
}
|
||||
|
||||
ret = append(ret, fmt.Sprintf("%v", Child.Interface))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func GetStringFrom(ref interface{}, name string) string {
|
||||
var ret string
|
||||
for range Only.Once {
|
||||
@ -803,7 +928,8 @@ func GetPointNameFrom(ref interface{}, name string, intSize int, dateFormat stri
|
||||
for _, pnf := range strings.Split(name, ".") {
|
||||
// Iterate over all available fields, looking for the field name.
|
||||
for i := 0; i < vo.NumField(); i++ {
|
||||
if vo.Type().Field(i).Name == pnf {
|
||||
fn := vo.Type().Field(i).Name
|
||||
if fn == pnf {
|
||||
ra = append(ra, valueTypes.AnyToValueString(vo.Field(i).Interface(), intSize, dateFormat))
|
||||
break
|
||||
}
|
||||
@ -812,7 +938,7 @@ func GetPointNameFrom(ref interface{}, name string, intSize int, dateFormat stri
|
||||
|
||||
case reflect.Map:
|
||||
for _, pnf := range strings.Split(name, ".") {
|
||||
// Iterate over all available fields, looking for the field name.
|
||||
// Iterate over all available keys, looking for the key name.
|
||||
for _, key := range vo.MapKeys() {
|
||||
if key.String() == pnf {
|
||||
ra = append(ra, valueTypes.AnyToValueString(vo.MapIndex(key).Interface(), intSize, dateFormat))
|
||||
@ -1305,6 +1431,7 @@ func VerifyOptionsRequired(ref interface{}) error {
|
||||
var err error
|
||||
|
||||
for range Only.Once {
|
||||
// @TODO - Move over to using Reflect structure.
|
||||
// required := GetOptionsRequired(ref)
|
||||
|
||||
vo := reflect.ValueOf(ref)
|
||||
|
@ -9,9 +9,23 @@ import (
|
||||
"github.com/MickMake/GoUnify/cmdPath"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
||||
func (ep *EndPointStruct) ApiSetFilenamePrefix2(ref interface{}, format string, args ...interface{}) string {
|
||||
f := strings.Join(apiReflect.GetStructValuesAsArray(ref), "-")
|
||||
fmt.Printf("[%s]\n", f)
|
||||
if format != "" {
|
||||
ep.FileNamePrefix = fmt.Sprintf(format, args...)
|
||||
// ep.FileNamePrefix = fmt.Sprintf("%s_%s-%s", ep.Area, ep.Name, ep.FileNamePrefix)
|
||||
ep.FileNamePrefix = string(ep.Area) + "_" + string(ep.Name) + "-" + ep.FileNamePrefix
|
||||
} else {
|
||||
ep.FileNamePrefix = string(ep.Area) + "_" + string(ep.Name)
|
||||
}
|
||||
return ep.FileNamePrefix
|
||||
}
|
||||
|
||||
func (ep *EndPointStruct) ApiSetFilenamePrefix(format string, args ...interface{}) string {
|
||||
if format != "" {
|
||||
ep.FileNamePrefix = fmt.Sprintf(format, args...)
|
||||
|
@ -1,76 +0,0 @@
|
||||
package nullEndpoint
|
||||
|
||||
import (
|
||||
"GoSungrow/iSolarCloud/api"
|
||||
"GoSungrow/iSolarCloud/api/apiReflect"
|
||||
"GoSungrow/iSolarCloud/api/valueTypes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
)
|
||||
|
||||
|
||||
const Url = "%URL%"
|
||||
const Disabled = true
|
||||
|
||||
type RequestData struct {
|
||||
// DeviceType string `json:"device_type" required:"true"`
|
||||
}
|
||||
|
||||
// IsValid Checks for validity of results data.
|
||||
func (rd RequestData) IsValid() error {
|
||||
return apiReflect.VerifyOptionsRequired(rd)
|
||||
}
|
||||
|
||||
// Help provides more info to the user on request JSON fields.
|
||||
func (rd RequestData) Help() string {
|
||||
ret := fmt.Sprintf("")
|
||||
return ret
|
||||
}
|
||||
|
||||
// ResultData holds data returned from the API.
|
||||
type ResultData struct {
|
||||
Dummy string `json:"dummy"`
|
||||
}
|
||||
|
||||
// IsValid Checks for validity of results data.
|
||||
func (e *ResultData) IsValid() error {
|
||||
var err error
|
||||
switch {
|
||||
case e.Dummy == "":
|
||||
break
|
||||
default:
|
||||
err = errors.New(fmt.Sprintf("unknown error '%s'", e.Dummy))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// type DecodeResultData ResultData
|
||||
//
|
||||
// func (e *ResultData) UnmarshalJSON(data []byte) error {
|
||||
// var err error
|
||||
//
|
||||
// for range Only.Once {
|
||||
// if len(data) == 0 {
|
||||
// break
|
||||
// }
|
||||
// var pd DecodeResultData
|
||||
//
|
||||
// // Store ResultData
|
||||
// _ = json.Unmarshal(data, &pd)
|
||||
// e.Dummy = pd.Dummy
|
||||
// }
|
||||
//
|
||||
// return err
|
||||
// }
|
||||
|
||||
|
||||
func (e *EndPoint) GetData() api.DataMap {
|
||||
entries := api.NewDataMap()
|
||||
|
||||
for range Only.Once {
|
||||
entries.StructToPoints(e.Response.ResultData, apiReflect.GetName("", *e), "system", valueTypes.NewDateTime(""))
|
||||
}
|
||||
|
||||
return entries
|
||||
}
|
@ -1,434 +0,0 @@
|
||||
// Package nullEndpoint
|
||||
// - This file is auto-generated from the update_all.sh script.
|
||||
// Do not modify anything here. Any changes to this EndPoint should be made in the data.go file.
|
||||
// The only exception is the AppService.login package.
|
||||
package nullEndpoint
|
||||
|
||||
import (
|
||||
"GoSungrow/Only"
|
||||
"GoSungrow/iSolarCloud/api"
|
||||
"GoSungrow/iSolarCloud/api/apiReflect"
|
||||
"GoSungrow/iSolarCloud/api/output"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
||||
// api.EndPoint - Import API endpoint interface
|
||||
var _ api.EndPoint = (*EndPoint)(nil)
|
||||
|
||||
// EndPoint - Holds the request, response and web method structures.
|
||||
type EndPoint struct {
|
||||
api.EndPointStruct
|
||||
Request Request
|
||||
Response Response
|
||||
RawResponse []byte
|
||||
}
|
||||
|
||||
// Request - Holds the api.RequestCommon and user RequestData structures. See data.go for request fields.
|
||||
type Request struct {
|
||||
api.RequestCommon
|
||||
RequestData
|
||||
}
|
||||
|
||||
// Response - Holds the api.ResponseCommon and endpoint specific ResultData structures. See data.go for response fields.
|
||||
type Response struct {
|
||||
api.ResponseCommon
|
||||
ResultData ResultData `json:"result_data"`
|
||||
}
|
||||
|
||||
// Init - Used to initialize a new endpoint instance. Usually called from an area.
|
||||
func Init(apiRoot api.Web) EndPoint {
|
||||
return EndPoint{
|
||||
EndPointStruct: api.EndPointStruct{
|
||||
ApiRoot: apiRoot,
|
||||
Area: api.GetArea(EndPoint{}),
|
||||
Name: api.GetName(EndPoint{}),
|
||||
Url: api.SetUrl(Url),
|
||||
Request: Request{},
|
||||
Response: Response{},
|
||||
Error: nil,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ******************************************************************************** //
|
||||
|
||||
// Methods not scoped by api.EndPoint interface type
|
||||
|
||||
// Init - If the endpoint needs to be re-initialized.
|
||||
func (e EndPoint) Init(apiRoot api.Web) *EndPoint {
|
||||
ret := Init(apiRoot)
|
||||
return &ret
|
||||
}
|
||||
|
||||
// GetRequest - Get the Request structure as scoped by this endpoint.
|
||||
func (e EndPoint) GetRequest() Request {
|
||||
return e.Request
|
||||
}
|
||||
|
||||
// GetResponse - Get the Response structure as scoped by this endpoint.
|
||||
func (e EndPoint) GetResponse() Response {
|
||||
return e.Response
|
||||
}
|
||||
|
||||
// Assert - Used to obtain locally scoped EndPoint methods, (not visible from api.EndPoint).
|
||||
//goland:noinspection GoUnusedExportedFunction
|
||||
func Assert(e api.EndPoint) EndPoint {
|
||||
return e.(EndPoint)
|
||||
}
|
||||
|
||||
// AssertResultData - Used to obtain locally scoped ResultData methods, (not visible from api.EndPoint).
|
||||
//goland:noinspection GoUnusedExportedFunction
|
||||
func AssertResultData(e api.EndPoint) ResultData {
|
||||
return e.(EndPoint).Response.ResultData
|
||||
}
|
||||
|
||||
|
||||
// ******************************************************************************** //
|
||||
|
||||
// Methods defined by api.EndPoint interface type
|
||||
|
||||
// Help - Return help information on the JSON structure used to populate RequestData.
|
||||
func (e EndPoint) Help() string {
|
||||
ret := apiReflect.HelpOptions(e.Request.RequestData)
|
||||
ret += fmt.Sprintf("JSON request:\t%s\n", e.GetRequestJson())
|
||||
ret += e.Request.Help()
|
||||
return ret
|
||||
}
|
||||
|
||||
// IsDisabled - Is this endpoint disabled? See data.go Disabled constant.
|
||||
func (e EndPoint) IsDisabled() bool {
|
||||
return Disabled
|
||||
}
|
||||
|
||||
// GetArea - Returns the API area that this EndPoint is located.
|
||||
func (e EndPoint) GetArea() api.AreaName {
|
||||
return e.Area
|
||||
}
|
||||
|
||||
// GetName - Returns the API EndPoint name.
|
||||
func (e EndPoint) GetName() api.EndPointName {
|
||||
return e.Name
|
||||
}
|
||||
|
||||
// GetUrl - Returns the API EndPoint url.
|
||||
func (e EndPoint) GetUrl() api.EndPointUrl {
|
||||
return e.Url
|
||||
}
|
||||
|
||||
// Call - Once RequestData is populated, this will access the iSolarCloud API and populate ResultData.
|
||||
func (e EndPoint) Call() api.EndPoint {
|
||||
return e.ApiRoot.Get(e)
|
||||
}
|
||||
|
||||
// GetJsonData - Get the JSON representation of ResultData, either as condensed or "pretty".
|
||||
func (e EndPoint) GetJsonData(raw bool) output.Json {
|
||||
if raw {
|
||||
// return output.GetAsPrettyJson(string(e.RawResponse))
|
||||
return output.Json(e.RawResponse)
|
||||
} else {
|
||||
return output.GetAsPrettyJson(e.Response.ResultData)
|
||||
}
|
||||
}
|
||||
|
||||
// SetError - Set the error code for this EndPoint.
|
||||
func (e EndPoint) SetError(format string, a ...interface{}) api.EndPoint {
|
||||
e.EndPointStruct.Error = errors.New(fmt.Sprintf(format, a...))
|
||||
return e
|
||||
}
|
||||
|
||||
// GetError - Get the error code for this EndPoint.
|
||||
func (e EndPoint) GetError() error {
|
||||
return e.EndPointStruct.Error
|
||||
}
|
||||
|
||||
// IsError - Is there an error?
|
||||
func (e EndPoint) IsError() bool {
|
||||
if e.Error != nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ReadDataFile - Read a JSON file and populate the ResultData structure.
|
||||
// (File names will default to AREA-ENDPOINT.json )
|
||||
func (e EndPoint) ReadDataFile() error {
|
||||
// return e.FileRead("", &e.Response.ResultData)
|
||||
return e.ApiReadDataFile(&e.Response.ResultData)
|
||||
}
|
||||
|
||||
// WriteDataFile - Write to a file, the contents of ResultData as JSON.
|
||||
// (File names will default to AREA-ENDPOINT.json )
|
||||
func (e EndPoint) WriteDataFile() error {
|
||||
// return e.FileWrite("", e.Response.ResultData, output.DefaultFileMode)
|
||||
return e.ApiWriteDataFile(e.Response.ResultData)
|
||||
}
|
||||
|
||||
|
||||
// ********************************************************************************
|
||||
|
||||
// SetRequest - Save an interface reference as either api.RequestCommon or RequestData.
|
||||
func (e EndPoint) SetRequest(ref interface{}) api.EndPoint {
|
||||
for range Only.Once {
|
||||
if apiReflect.GetPkgType(ref) == "api.RequestCommon" {
|
||||
e.Request.RequestCommon = ref.(api.RequestCommon)
|
||||
break
|
||||
}
|
||||
|
||||
if apiReflect.GetType(ref) == "RequestData" {
|
||||
e.Request.RequestData = ref.(RequestData)
|
||||
e.Error = e.IsRequestValid()
|
||||
break
|
||||
}
|
||||
|
||||
e.Error = apiReflect.DoPkgTypesMatch(e.Request, ref)
|
||||
if e.Error != nil {
|
||||
break
|
||||
}
|
||||
|
||||
e.Request = ref.(Request)
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// SetRequestByJson - Save RequestData from a JSON string.
|
||||
func (e EndPoint) SetRequestByJson(j output.Json) api.EndPoint {
|
||||
for range Only.Once {
|
||||
e.Error = json.Unmarshal([]byte(j), &e.Request.RequestData)
|
||||
if e.Error != nil {
|
||||
break
|
||||
}
|
||||
e.Error = e.IsRequestValid()
|
||||
if e.Error != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// RequestRef - Return the locally scoped Request structure.
|
||||
func (e EndPoint) RequestRef() interface{} {
|
||||
return e.Request
|
||||
}
|
||||
|
||||
// GetRequestJson - Return the Request structure as a JSON string.
|
||||
func (e EndPoint) GetRequestJson() output.Json {
|
||||
return output.GetAsJson(e.Request.RequestData)
|
||||
}
|
||||
|
||||
// // GetFingerprint - Used to formulate cache filenames.
|
||||
// func (e EndPoint) GetFingerprint() string {
|
||||
// return apiReflect.GetFingerprint(e.Request.RequestData)
|
||||
// }
|
||||
|
||||
// IsRequestValid - Is api.RequestCommon and RequestData valid?
|
||||
func (e EndPoint) IsRequestValid() error {
|
||||
for range Only.Once {
|
||||
// req := e.GetRequest()
|
||||
// req := e.Request.RequestCommon
|
||||
e.Error = e.Request.RequestCommon.IsValid()
|
||||
if e.Error != nil {
|
||||
break
|
||||
}
|
||||
e.Error = e.Request.RequestData.IsValid()
|
||||
if e.Error != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
return e.Error
|
||||
}
|
||||
|
||||
|
||||
// ********************************************************************************
|
||||
|
||||
// SetResponse - Save a JSON string to the Response structure.
|
||||
// (Used by the web call method.)
|
||||
func (e EndPoint) SetResponse(ref []byte) api.EndPoint {
|
||||
for range Only.Once {
|
||||
e.RawResponse = ref
|
||||
e.Error = json.Unmarshal(ref, &e.Response)
|
||||
if e.Error != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// GetResponseJson - Return the Response structure as a JSON string.
|
||||
func (e EndPoint) GetResponseJson() output.Json {
|
||||
return output.GetAsPrettyJson(e.Response)
|
||||
}
|
||||
|
||||
// ResponseRef - Return the locally scoped Response structure.
|
||||
func (e EndPoint) ResponseRef() interface{} {
|
||||
return e.Response
|
||||
}
|
||||
|
||||
// IsResponseValid - Is api.ResponseCommon and ResultData valid?
|
||||
func (e EndPoint) IsResponseValid() error {
|
||||
for range Only.Once {
|
||||
e.Error = e.Response.ResponseCommon.IsValid()
|
||||
if e.Error != nil {
|
||||
break
|
||||
}
|
||||
e.Error = e.Response.ResultData.IsValid()
|
||||
if e.Error != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
return e.Error
|
||||
}
|
||||
|
||||
// String - Stringer method for this EndPoint.
|
||||
func (e EndPoint) String() string {
|
||||
return output.GetEndPointString(e)
|
||||
}
|
||||
|
||||
// RequestString - Return the Request structure as a human-readable string.
|
||||
func (e EndPoint) RequestString() string {
|
||||
return output.GetRequestString(e.Request)
|
||||
}
|
||||
|
||||
// ResponseString - Return the Response structure as a human-readable string.
|
||||
func (e EndPoint) ResponseString() string {
|
||||
return output.GetRequestString(e.Response)
|
||||
}
|
||||
|
||||
|
||||
// ********************************************************************************
|
||||
|
||||
// MarshalJSON - Marshall the EndPoint.
|
||||
func (e EndPoint) MarshalJSON() ([]byte, error) {
|
||||
return api.MarshalJSON(e)
|
||||
|
||||
// return json.Marshal(&struct {
|
||||
// Area string `json:"area"`
|
||||
// EndPoint string `json:"endpoint"`
|
||||
// Host string `json:"api_host"`
|
||||
// Url string `json:"endpoint_url"`
|
||||
// Request interface{} `json:"request"`
|
||||
// Response interface{} `json:"response"`
|
||||
// }{
|
||||
// Area: string(e.Area),
|
||||
// EndPoint: string(e.Name),
|
||||
// Host: e.ApiRoot.Url.String(),
|
||||
// Url: e.Url.String(),
|
||||
// Request: e.Request,
|
||||
// Response: e.Response,
|
||||
// })
|
||||
}
|
||||
|
||||
|
||||
// ********************************************************************************
|
||||
|
||||
// RequestFingerprint - Check if a cache file exists for this EndPoint.
|
||||
func (e EndPoint) RequestFingerprint() string {
|
||||
return e.ApiFingerprint(e.Request.RequestData)
|
||||
}
|
||||
|
||||
// CacheFilename - Check if a cache file exists for this EndPoint.
|
||||
func (e EndPoint) CacheFilename() string {
|
||||
return e.ApiCacheFilename(e.Request.RequestData)
|
||||
}
|
||||
|
||||
// // CheckCache - Check if a cache file exists for this EndPoint.
|
||||
// func (e EndPoint) CheckCache() bool {
|
||||
// return e.ApiCheckCache(e.Request.RequestData)
|
||||
// }
|
||||
//
|
||||
// // ReadCache - Read a cache file and return it as an EndPoint structure.
|
||||
// func (e EndPoint) ReadCache() api.EndPoint {
|
||||
// e.Error = e.ApiReadCache(e.Request.RequestData, &e)
|
||||
// return e
|
||||
// }
|
||||
//
|
||||
// // WriteCache - Write this EndPoint structure out to a cache file.
|
||||
// func (e EndPoint) WriteCache() error {
|
||||
// return e.ApiWriteCache(e.Request.RequestData, e)
|
||||
// }
|
||||
|
||||
// SetCacheTimeout - Set the cache timeout for this EndPoint. (Defaults to 1 hour.)
|
||||
func (e EndPoint) SetCacheTimeout(duration time.Duration) api.EndPoint {
|
||||
e.ApiRoot.SetCacheTimeout(duration)
|
||||
return e
|
||||
}
|
||||
|
||||
// GetCacheTimeout - Return the cache timeout for this EndPoint.
|
||||
func (e EndPoint) GetCacheTimeout() time.Duration {
|
||||
return e.ApiRoot.GetCacheTimeout()
|
||||
}
|
||||
|
||||
func (e EndPoint) GetDataTable() output.Table {
|
||||
var table output.Table
|
||||
for range Only.Once {
|
||||
table = output.NewTable()
|
||||
table.SetTitle("")
|
||||
table.SetJson([]byte(e.GetJsonData(false)))
|
||||
table.SetRaw([]byte(e.GetJsonData(true)))
|
||||
|
||||
_ = table.SetHeader(
|
||||
"Date",
|
||||
"Point Id",
|
||||
"Value",
|
||||
"Unit",
|
||||
"Group Name",
|
||||
"Description",
|
||||
)
|
||||
|
||||
data := e.GetData()
|
||||
var sorted []string
|
||||
for p := range data.Map {
|
||||
sorted = append(sorted, string(p))
|
||||
}
|
||||
sort.Strings(sorted)
|
||||
|
||||
for _, p := range sorted {
|
||||
entries := data.Map[api.PointId(p)]
|
||||
for _, de := range entries {
|
||||
if de.Hide {
|
||||
continue
|
||||
}
|
||||
|
||||
_ = table.AddRow(
|
||||
de.Date.Format(api.DtLayout),
|
||||
// api.NameDevicePointInt(de.Point.Parents, p.PointID.Value()),
|
||||
// de.Point.Id,
|
||||
p,
|
||||
// de.Point.Parents.String(),
|
||||
de.Value,
|
||||
de.Point.Unit,
|
||||
de.Point.GroupName,
|
||||
de.Point.Name,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// table.InitGraph(output.GraphRequest {
|
||||
// Title: "",
|
||||
// TimeColumn: output.SetInteger(1),
|
||||
// SearchColumn: output.SetInteger(2),
|
||||
// NameColumn: output.SetInteger(4),
|
||||
// ValueColumn: output.SetInteger(5),
|
||||
// UnitsColumn: output.SetInteger(6),
|
||||
// SearchString: output.SetString(""),
|
||||
// MinLeftAxis: output.SetFloat(0),
|
||||
// MaxLeftAxis: output.SetFloat(0),
|
||||
// })
|
||||
}
|
||||
return table
|
||||
}
|
||||
|
||||
// SetFilenamePrefix - Produce filename based on area and endpoint name.
|
||||
func (e EndPoint) SetFilenamePrefix(format string, args ...interface{}) string {
|
||||
return e.ApiSetFilenamePrefix(format, args...)
|
||||
}
|
||||
|
||||
// GetRequestArgNames -
|
||||
func (e EndPoint) GetRequestArgNames() map[string]string {
|
||||
return e.ApiGetRequestArgNames(e.Request.RequestData)
|
||||
}
|
@ -1,5 +1,8 @@
|
||||
package output
|
||||
|
||||
import (
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
)
|
||||
|
||||
const (
|
||||
TypeNone = iota
|
||||
@ -132,18 +135,28 @@ func (out *OutputType) IsStrGraph(t string) bool {
|
||||
|
||||
|
||||
func (out *OutputType) Set(outputType string) {
|
||||
switch outputType {
|
||||
case StringTypeJson:
|
||||
out.SetJson()
|
||||
case StringTypeCsv:
|
||||
out.SetCsv()
|
||||
case StringTypeRaw:
|
||||
out.SetRaw()
|
||||
case StringTypeGraph:
|
||||
out.SetGraph()
|
||||
case StringTypeTable:
|
||||
fallthrough
|
||||
default:
|
||||
out.SetTable()
|
||||
for range Only.Once {
|
||||
// re := regexp.MustCompile(`^(\w+)\s`)
|
||||
// ot := re.FindStringSubmatch(outputType)
|
||||
// if len(ot) == 0 {
|
||||
// break
|
||||
// }
|
||||
// fmt.Printf("%s\n", ot[0])
|
||||
//
|
||||
// switch strings.ToLower(ot[0]) {
|
||||
switch outputType {
|
||||
case StringTypeJson:
|
||||
out.SetJson()
|
||||
case StringTypeCsv:
|
||||
out.SetCsv()
|
||||
case StringTypeRaw:
|
||||
out.SetRaw()
|
||||
case StringTypeGraph:
|
||||
out.SetGraph()
|
||||
case StringTypeTable:
|
||||
fallthrough
|
||||
default:
|
||||
out.SetTable()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,6 +69,10 @@ func (t *Table) SetRaw(data []byte) {
|
||||
t.raw = data
|
||||
}
|
||||
|
||||
func (t *Table) AppendRaw(data []byte) {
|
||||
t.raw = append(t.raw, data...)
|
||||
}
|
||||
|
||||
func (t *Table) SetJson(data []byte) {
|
||||
t.json = data
|
||||
}
|
||||
@ -130,6 +134,43 @@ func (t *Table) Output() error {
|
||||
if t == nil {
|
||||
break
|
||||
}
|
||||
|
||||
// switch {
|
||||
// case sg.OutputType.IsNone():
|
||||
// if sg.Error != nil {
|
||||
// fmt.Println(ret.Help())
|
||||
// break
|
||||
// }
|
||||
//
|
||||
// case sg.OutputType.IsRaw():
|
||||
// // if sg.Error != nil {
|
||||
// // fmt.Println(ret.Help())
|
||||
// // break
|
||||
// // }
|
||||
// if sg.SaveAsFile {
|
||||
// sg.Error = ret.WriteDataFile()
|
||||
// break
|
||||
// }
|
||||
// fmt.Println(ret.GetJsonData(true))
|
||||
//
|
||||
// case sg.OutputType.IsJson():
|
||||
// if sg.Error != nil {
|
||||
// fmt.Println(ret.Help())
|
||||
// break
|
||||
// }
|
||||
// if sg.SaveAsFile {
|
||||
// sg.Error = ret.WriteDataFile()
|
||||
// break
|
||||
// }
|
||||
// fmt.Println(ret.GetJsonData(false))
|
||||
//
|
||||
// default:
|
||||
// if sg.Error != nil {
|
||||
// fmt.Println(ret.Help())
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
|
||||
switch {
|
||||
case t.OutputType.IsNone():
|
||||
|
||||
@ -240,6 +281,10 @@ func (t *Table) GetRaw() string {
|
||||
return string(t.json)
|
||||
}
|
||||
|
||||
func (t *Table) GetRawBytes() []byte {
|
||||
return t.json
|
||||
}
|
||||
|
||||
func (t *Table) WriteRaw() error {
|
||||
if t.saveAsFile {
|
||||
return t.writeFile(t.filePrefix+".raw", string(t.raw), DefaultFileMode)
|
||||
|
@ -42,6 +42,8 @@ func (dm *DataMap) StructToPoints(ref interface{}, endpoint string, parentId str
|
||||
endpoint = apiReflect.GetCallerPackage(2)
|
||||
}
|
||||
|
||||
now := valueTypes.SetDateTimeValue(time.Now().Round(5 * time.Minute))
|
||||
|
||||
// Iterate over all available fields and read the tag values
|
||||
var tp apiReflect.DataStructures
|
||||
var Ref apiReflect.Reflect
|
||||
@ -71,31 +73,14 @@ func (dm *DataMap) StructToPoints(ref interface{}, endpoint string, parentId str
|
||||
continue
|
||||
}
|
||||
|
||||
// switch f.PointUpdateFreq {
|
||||
// case "UpdateFreqInstant":
|
||||
// f.PointUpdateFreq = UpdateFreqInstant
|
||||
// case "UpdateFreq5Mins":
|
||||
// f.PointUpdateFreq = UpdateFreq5Mins
|
||||
// case "UpdateFreqBoot":
|
||||
// f.PointUpdateFreq = UpdateFreqBoot
|
||||
// case "UpdateFreqDay":
|
||||
// f.PointUpdateFreq = UpdateFreqDay
|
||||
// case "UpdateFreqMonth":
|
||||
// f.PointUpdateFreq = UpdateFreqMonth
|
||||
// case "UpdateFreqYear":
|
||||
// f.PointUpdateFreq = UpdateFreqYear
|
||||
// case "UpdateFreqTotal":
|
||||
// f.PointUpdateFreq = UpdateFreqTotal
|
||||
// }
|
||||
|
||||
var when valueTypes.DateTime
|
||||
if !f.PointTimestamp.IsZero() {
|
||||
dt := valueTypes.SetDateTimeValue(f.PointTimestamp)
|
||||
when = *dt
|
||||
// dt := valueTypes.SetDateTimeValue(f.PointTimestamp)
|
||||
when = valueTypes.SetDateTimeValue(f.PointTimestamp)
|
||||
} else {
|
||||
if timestamp.IsZero() {
|
||||
dt := valueTypes.SetDateTimeValue(time.Now().Round(5 * time.Minute))
|
||||
when = *dt
|
||||
// dt := valueTypes.SetDateTimeValue(time.Now().Round(5 * time.Minute))
|
||||
when = now
|
||||
} else {
|
||||
when = timestamp
|
||||
}
|
||||
@ -149,54 +134,6 @@ func (dm *DataMap) AddPointUnitValue(endpoint string, parentId string, point Poi
|
||||
}
|
||||
}
|
||||
|
||||
func CreatePointDataEntry(endpoint string, parentId string, point Point, dateTime valueTypes.DateTime, uv valueTypes.UnitValue) DataEntry {
|
||||
var ret DataEntry
|
||||
for range Only.Once {
|
||||
ret = DataEntry {
|
||||
EndPoint: endpoint,
|
||||
Point: &point,
|
||||
Parent: NewParentDevice(parentId),
|
||||
Date: dateTime,
|
||||
Value: uv,
|
||||
Valid: true,
|
||||
Hide: false,
|
||||
Index: 0,
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func CreatePoint(parentId string, pid valueTypes.PointId, name string, groupName string, unit string, Type string, timeSpan string) Point {
|
||||
var point Point
|
||||
for range Only.Once {
|
||||
if name == "" {
|
||||
name = pid.PointToName()
|
||||
}
|
||||
|
||||
var parent ParentDevice
|
||||
parent.Set(parentId)
|
||||
var parents ParentDevices
|
||||
parents.Add(parent)
|
||||
|
||||
point = Point {
|
||||
Parents: parents,
|
||||
Id: pid,
|
||||
GroupName: groupName,
|
||||
Description: name,
|
||||
Unit: unit,
|
||||
UpdateFreq: timeSpan,
|
||||
ValueType: Type,
|
||||
Valid: true,
|
||||
States: nil,
|
||||
}
|
||||
point.FixUnitType()
|
||||
}
|
||||
|
||||
return point
|
||||
}
|
||||
|
||||
|
||||
func (dm *DataMap) CopyPoint(refEndpoint string, endpoint string, pointId string, name string) *DataEntries {
|
||||
var ret *DataEntries
|
||||
for range Only.Once {
|
||||
@ -397,32 +334,6 @@ func (dm *DataMap) CreateTable() output.Table {
|
||||
return table
|
||||
}
|
||||
|
||||
|
||||
|
||||
func GetPercent(value float64, max float64) float64 {
|
||||
if max == 0 {
|
||||
return 0
|
||||
}
|
||||
return (value / max) * 100
|
||||
}
|
||||
|
||||
func JoinWithDots(intSize int, dateFormat string, args ...interface{}) string {
|
||||
var ret string
|
||||
for range Only.Once {
|
||||
var a []string
|
||||
for _, e := range args {
|
||||
v := valueTypes.TypeToString(intSize, dateFormat, e)
|
||||
if v == "" {
|
||||
continue
|
||||
}
|
||||
a = append(a, v)
|
||||
}
|
||||
ret = strings.Join(a, ".")
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
|
||||
func (dm *DataMap) AddAny(endpoint string, parentId string, pid valueTypes.PointId, name string, groupName string, date valueTypes.DateTime, value interface{}, unit string, Type string, timeSpan string) {
|
||||
|
||||
for range Only.Once {
|
||||
@ -515,6 +426,79 @@ func (dm *DataMap) AddUnitValue(endpoint string, parentId string, pid valueTypes
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func CreatePointDataEntry(endpoint string, parentId string, point Point, dateTime valueTypes.DateTime, uv valueTypes.UnitValue) DataEntry {
|
||||
var ret DataEntry
|
||||
for range Only.Once {
|
||||
ret = DataEntry {
|
||||
EndPoint: endpoint,
|
||||
Point: &point,
|
||||
Parent: NewParentDevice(parentId),
|
||||
Date: dateTime,
|
||||
Value: uv,
|
||||
Valid: true,
|
||||
Hide: false,
|
||||
Index: 0,
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func CreatePoint(parentId string, pid valueTypes.PointId, name string, groupName string, unit string, Type string, timeSpan string) Point {
|
||||
var point Point
|
||||
for range Only.Once {
|
||||
if name == "" {
|
||||
name = pid.PointToName()
|
||||
}
|
||||
|
||||
var parent ParentDevice
|
||||
parent.Set(parentId)
|
||||
var parents ParentDevices
|
||||
parents.Add(parent)
|
||||
|
||||
point = Point {
|
||||
Parents: parents,
|
||||
Id: pid,
|
||||
GroupName: groupName,
|
||||
Description: name,
|
||||
Unit: unit,
|
||||
UpdateFreq: timeSpan,
|
||||
ValueType: Type,
|
||||
Valid: true,
|
||||
States: nil,
|
||||
}
|
||||
point.FixUnitType()
|
||||
}
|
||||
|
||||
return point
|
||||
}
|
||||
|
||||
func GetPercent(value float64, max float64) float64 {
|
||||
if max == 0 {
|
||||
return 0
|
||||
}
|
||||
return (value / max) * 100
|
||||
}
|
||||
|
||||
func JoinWithDots(intSize int, dateFormat string, args ...interface{}) string {
|
||||
var ret string
|
||||
for range Only.Once {
|
||||
var a []string
|
||||
for _, ref := range args {
|
||||
v := valueTypes.AnyToValueString(ref, intSize, dateFormat)
|
||||
if v == "" {
|
||||
continue
|
||||
}
|
||||
v = strings.Trim(v, ".")
|
||||
a = append(a, v)
|
||||
}
|
||||
ret = strings.Join(a, ".")
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
|
||||
// func CreateDataEntry(endpoint string, parentId string, pid valueTypes.PointId, name string, groupName string, dateTime valueTypes.DateTime, uv valueTypes.UnitValue, timeSpan string) DataEntry {
|
||||
// var ret DataEntry
|
||||
// for range Only.Once {
|
||||
|
@ -15,63 +15,16 @@ type Point struct {
|
||||
Id valueTypes.PointId `json:"id,omitempty"`
|
||||
GroupName string `json:"group_name,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Unit string `json:"unit,omitempty"`
|
||||
UpdateFreq string `json:"time_span,omitempty"`
|
||||
ValueType string `json:"value_type,omitempty"`
|
||||
Unit string `json:"unit,omitempty"`
|
||||
UpdateFreq string `json:"time_span,omitempty"`
|
||||
ValueType string `json:"value_type,omitempty"`
|
||||
Valid bool `json:"valid,omitempty"`
|
||||
States map[string]string `json:"states,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
func (p *Point) FixUnitType() Point {
|
||||
for range Only.Once {
|
||||
switch p.Unit {
|
||||
case "Wh":
|
||||
fallthrough
|
||||
case "kWh":
|
||||
fallthrough
|
||||
case "MWh":
|
||||
p.ValueType = "Energy"
|
||||
|
||||
case "kWp":
|
||||
fallthrough
|
||||
case "W":
|
||||
fallthrough
|
||||
case "kW":
|
||||
fallthrough
|
||||
case "MW":
|
||||
p.ValueType = "Power"
|
||||
|
||||
case "AUD":
|
||||
p.ValueType = "Currency"
|
||||
|
||||
case "kg":
|
||||
p.ValueType = "Weight"
|
||||
|
||||
case "mV":
|
||||
fallthrough
|
||||
case "V":
|
||||
p.ValueType = "Voltage"
|
||||
|
||||
case "A":
|
||||
p.ValueType = "Current"
|
||||
|
||||
case "Hz":
|
||||
p.ValueType = "Frequency"
|
||||
|
||||
case "kvar":
|
||||
p.ValueType = "Reactive Power"
|
||||
|
||||
case "kΩ":
|
||||
p.ValueType = "Resistance"
|
||||
|
||||
case "%":
|
||||
p.ValueType = "Percent"
|
||||
|
||||
case "℃":
|
||||
p.ValueType = "Temperature"
|
||||
}
|
||||
}
|
||||
p.ValueType = valueTypes.UnitValueType(p.Unit)
|
||||
return *p
|
||||
}
|
||||
|
||||
|
@ -10,15 +10,14 @@ import (
|
||||
func (e *Web) GetDataTable(endpoint EndPoint) output.Table {
|
||||
var table output.Table
|
||||
for range Only.Once {
|
||||
table = output.NewTable()
|
||||
// table = output.NewTable()
|
||||
data := endpoint.GetEndPointData()
|
||||
table = data.CreateTable()
|
||||
table.SetTitle(fmt.Sprintf("Data Request %s.%s", endpoint.GetArea(), endpoint.GetName()))
|
||||
table.SetFilePrefix(fmt.Sprintf("%s_%s", endpoint.GetArea(), endpoint.GetName()))
|
||||
table.SetJson([]byte(endpoint.GetJsonData(false)))
|
||||
table.SetRaw([]byte(endpoint.GetJsonData(true)))
|
||||
|
||||
data := endpoint.GetEndPointData()
|
||||
table = data.CreateTable()
|
||||
|
||||
// table.InitGraph(output.GraphRequest {
|
||||
// Title: "",
|
||||
// TimeColumn: output.SetInteger(1),
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
|
||||
|
||||
var inputDateLayout = []string{
|
||||
DateTimeFullLayout,
|
||||
DateTimeLayout,
|
||||
"2006/01/02 15:04:05",
|
||||
DateLayout,
|
||||
@ -19,9 +20,11 @@ var inputDateLayout = []string{
|
||||
DateTimeLayoutDay,
|
||||
DateTimeLayoutMonth,
|
||||
DateTimeLayoutYear,
|
||||
DateTimeLayoutYear,
|
||||
}
|
||||
|
||||
const (
|
||||
DateTimeFullLayout = time.RFC3339
|
||||
DateTimeLayout = DateLayout + " " + TimeLayout
|
||||
DateTimeAltLayout = DateLayoutDay + "-" + TimeLayoutSecond
|
||||
DateTimeLayoutZeroSeconds = DateLayout + " " + TimeLayoutZeroSeconds
|
||||
@ -63,14 +66,14 @@ func (dt *DateTime) UnmarshalJSON(data []byte) error {
|
||||
// Store result from string
|
||||
dt.Error = json.Unmarshal(data, &dt.string)
|
||||
if dt.Error == nil {
|
||||
dt = dt.SetString(dt.string)
|
||||
dt.SetString(dt.string)
|
||||
break
|
||||
}
|
||||
|
||||
// Store result from time
|
||||
dt.Error = json.Unmarshal(data, &dt.Time)
|
||||
if dt.Error == nil {
|
||||
dt = dt.SetValue(dt.Time)
|
||||
dt.SetValue(dt.Time)
|
||||
break
|
||||
}
|
||||
|
||||
@ -96,11 +99,8 @@ func (dt DateTime) MarshalJSON() ([]byte, error) {
|
||||
var data []byte
|
||||
|
||||
for range Only.Once {
|
||||
// data, dt.Error = json.Marshal(dt.string)
|
||||
// if dt.Error != nil {
|
||||
// break
|
||||
// }
|
||||
data = []byte("\"" + dt.Time.Format(DateTimeLayout) + "\"")
|
||||
// data = []byte("\"" + dt.Time.Format(DateTimeLayout) + "\"")
|
||||
data = []byte("\"" + dt.string + "\"")
|
||||
}
|
||||
|
||||
return data, dt.Error
|
||||
@ -122,7 +122,7 @@ func (dt DateTime) Match(comp time.Time) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (dt *DateTime) SetString(value string) *DateTime {
|
||||
func (dt *DateTime) SetString(value string) DateTime {
|
||||
for range Only.Once {
|
||||
dt.string = value
|
||||
dt.Time = time.Time{}
|
||||
@ -139,7 +139,7 @@ func (dt *DateTime) SetString(value string) *DateTime {
|
||||
for _, f := range inputDateLayout {
|
||||
dt.Time, dt.Error = time.Parse(f, value)
|
||||
if dt.Error == nil {
|
||||
dt.string = dt.Time.Format(DateTimeLayout)
|
||||
dt.string = dt.Time.Format(f)
|
||||
dt.SetDateType(value)
|
||||
break
|
||||
}
|
||||
@ -150,10 +150,10 @@ func (dt *DateTime) SetString(value string) *DateTime {
|
||||
}
|
||||
}
|
||||
|
||||
return dt
|
||||
return *dt
|
||||
}
|
||||
|
||||
func (dt *DateTime) SetValue(value time.Time) *DateTime {
|
||||
func (dt *DateTime) SetValue(value time.Time) DateTime {
|
||||
for range Only.Once {
|
||||
dt.string = ""
|
||||
dt.Time = value
|
||||
@ -166,7 +166,7 @@ func (dt *DateTime) SetValue(value time.Time) *DateTime {
|
||||
dt.DateType = "3"
|
||||
}
|
||||
|
||||
return dt
|
||||
return *dt
|
||||
}
|
||||
|
||||
func (dt *DateTime) SetDateType(value string) {
|
||||
@ -188,12 +188,12 @@ func (dt *DateTime) SetDateType(value string) {
|
||||
}
|
||||
}
|
||||
|
||||
func SetDateTimeString(value string) *DateTime {
|
||||
func SetDateTimeString(value string) DateTime {
|
||||
var t DateTime
|
||||
return t.SetString(value)
|
||||
}
|
||||
|
||||
func SetDateTimeValue(value time.Time) *DateTime {
|
||||
func SetDateTimeValue(value time.Time) DateTime {
|
||||
var t DateTime
|
||||
return t.SetValue(value)
|
||||
}
|
||||
@ -235,20 +235,25 @@ const Now = "now"
|
||||
|
||||
func NewDateTime(value string) DateTime {
|
||||
var ret DateTime
|
||||
if (value == Now) || (value == "") {
|
||||
value = time.Now().Format(DateTimeLayout)
|
||||
}
|
||||
for _, f := range inputDateLayout {
|
||||
ret.Time, ret.Error = time.Parse(f, value)
|
||||
if ret.Error == nil {
|
||||
ret.SetValue(ret.Time)
|
||||
ret.SetDateType(value)
|
||||
for range Only.Once {
|
||||
if (value == Now) || (value == "") {
|
||||
// value = time.Now().Format(DateTimeLayout)
|
||||
ret.SetValue(time.Now())
|
||||
ret.SetDateType(ret.string)
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, f := range inputDateLayout {
|
||||
ret.Time, ret.Error = time.Parse(f, value)
|
||||
if ret.Error == nil {
|
||||
ret.SetValue(ret.Time)
|
||||
ret.SetDateType(value)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if ret.Error != nil {
|
||||
fmt.Printf("Error:NewDateTime DateTime(%s) - %s\n", value, ret.Error)
|
||||
if ret.Error != nil {
|
||||
fmt.Printf("Error:NewDateTime DateTime(%s) - %s\n", value, ret.Error)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
@ -92,7 +92,9 @@ func (t *Float) SetString(value string) Float {
|
||||
}
|
||||
|
||||
t.float64, t.Error = strconv.ParseFloat(t.string, 64)
|
||||
if t.Error == nil {
|
||||
if t.Error != nil {
|
||||
// @TODO - Figure out a good way to handle fields that *could be* float, but aren't always.
|
||||
t.Error = nil
|
||||
break
|
||||
}
|
||||
t.Valid = true
|
||||
|
167
iSolarCloud/api/valueTypes/ps_id.go
Normal file
167
iSolarCloud/api/valueTypes/ps_id.go
Normal file
@ -0,0 +1,167 @@
|
||||
package valueTypes
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
|
||||
type PsId struct {
|
||||
string `json:"string,omitempty"`
|
||||
int64 `json:"integer,omitempty"`
|
||||
Valid bool `json:"valid"`
|
||||
Error error `json:"-"`
|
||||
}
|
||||
|
||||
// UnmarshalJSON - Convert JSON to value
|
||||
func (t *PsId) UnmarshalJSON(data []byte) error {
|
||||
for range Only.Once {
|
||||
t.Valid = false
|
||||
|
||||
if len(data) == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
// Store result from int
|
||||
t.Error = json.Unmarshal(data, &t.int64)
|
||||
if t.Error == nil {
|
||||
t.SetValue(t.int64)
|
||||
break
|
||||
}
|
||||
|
||||
// Store result from string
|
||||
t.Error = json.Unmarshal(data, &t.string)
|
||||
if t.Error == nil {
|
||||
t.SetString(t.string)
|
||||
break
|
||||
}
|
||||
|
||||
t.SetString(string(data))
|
||||
}
|
||||
|
||||
return t.Error
|
||||
}
|
||||
|
||||
// MarshalJSON - Convert value to JSON
|
||||
func (t PsId) MarshalJSON() ([]byte, error) {
|
||||
var data []byte
|
||||
for range Only.Once {
|
||||
t.Valid = false
|
||||
|
||||
data, t.Error = json.Marshal(t.int64)
|
||||
if t.Error != nil {
|
||||
break
|
||||
}
|
||||
t.Valid = true
|
||||
// t.string = strconv.FormatInt(t.int64, 10)
|
||||
}
|
||||
|
||||
return data, t.Error
|
||||
}
|
||||
|
||||
func (t PsId) Value() int64 {
|
||||
return t.int64
|
||||
}
|
||||
|
||||
func (t PsId) String() string {
|
||||
return t.string
|
||||
}
|
||||
|
||||
func (t PsId) Match(comp int64) bool {
|
||||
if t.int64 == comp {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (t *PsId) SetString(value string) PsId {
|
||||
for range Only.Once {
|
||||
t.string = value
|
||||
t.int64 = 0
|
||||
t.Valid = false
|
||||
|
||||
if value == "" {
|
||||
break
|
||||
}
|
||||
|
||||
if value == "--" {
|
||||
// value = ""
|
||||
break
|
||||
}
|
||||
|
||||
var v int
|
||||
v, t.Error = strconv.Atoi(t.string)
|
||||
if t.Error != nil {
|
||||
break
|
||||
}
|
||||
t.int64 = int64(v)
|
||||
t.Valid = true
|
||||
}
|
||||
|
||||
return *t
|
||||
}
|
||||
|
||||
func (t *PsId) SetValue(value int64) PsId {
|
||||
for range Only.Once {
|
||||
t.string = ""
|
||||
t.int64 = value
|
||||
t.Valid = true
|
||||
t.string = strconv.FormatInt(t.int64, 10)
|
||||
}
|
||||
|
||||
return *t
|
||||
}
|
||||
|
||||
|
||||
func SetPsIdString(value string) PsId {
|
||||
var t PsId
|
||||
return t.SetString(value)
|
||||
}
|
||||
|
||||
func SetPsIdValue(value int64) PsId {
|
||||
var t PsId
|
||||
return t.SetValue(value)
|
||||
}
|
||||
|
||||
func SetPsIdStrings(values []string) PsIds {
|
||||
var t PsIds
|
||||
for range Only.Once {
|
||||
// sgd.PsId = valueTypes.SetPsIdString(psId)
|
||||
for _, psId := range values {
|
||||
if psId == "" {
|
||||
continue
|
||||
}
|
||||
t = append(t, SetPsIdString(psId))
|
||||
}
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
func SetPsIdValues(values []int64) PsIds {
|
||||
var t PsIds
|
||||
for range Only.Once {
|
||||
// sgd.PsId = valueTypes.SetPsIdString(psId)
|
||||
for _, psId := range values {
|
||||
if psId == 0 {
|
||||
continue
|
||||
}
|
||||
t = append(t, SetPsIdValue(psId))
|
||||
}
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
|
||||
type PsIds []PsId
|
||||
|
||||
func (t *PsIds) Strings() []string {
|
||||
var ret []string
|
||||
for range Only.Once {
|
||||
// sgd.PsId = valueTypes.SetPsIdString(psId)
|
||||
for _, psId := range *t {
|
||||
ret = append(ret, psId.String())
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,7 @@ package valueTypes
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
"sort"
|
||||
"strconv"
|
||||
@ -33,6 +34,8 @@ func (t *UnitValue) UnitValueFix() UnitValue {
|
||||
}
|
||||
|
||||
switch t.UnitValue {
|
||||
case "g":
|
||||
fallthrough
|
||||
case "Wp":
|
||||
fallthrough
|
||||
case "Wh":
|
||||
@ -53,6 +56,67 @@ func (t *UnitValue) UnitValueFix() UnitValue {
|
||||
return *t
|
||||
}
|
||||
|
||||
func UnitValueType(unit string) string {
|
||||
var ret string
|
||||
switch unit {
|
||||
case "Wh":
|
||||
fallthrough
|
||||
case "kWh":
|
||||
fallthrough
|
||||
case "MWh":
|
||||
ret = "Energy"
|
||||
|
||||
case "kWp":
|
||||
fallthrough
|
||||
case "W":
|
||||
fallthrough
|
||||
case "kW":
|
||||
fallthrough
|
||||
case "MW":
|
||||
ret = "Power"
|
||||
|
||||
case "AUD":
|
||||
ret = "Currency"
|
||||
|
||||
case "g":
|
||||
fallthrough
|
||||
case "kg":
|
||||
ret = "Weight"
|
||||
|
||||
case "mV":
|
||||
fallthrough
|
||||
case "V":
|
||||
ret = "Voltage"
|
||||
|
||||
case "mA":
|
||||
fallthrough
|
||||
case "A":
|
||||
ret = "Current"
|
||||
|
||||
case "Hz":
|
||||
ret = "Frequency"
|
||||
|
||||
case "kvar":
|
||||
ret = "Reactive Power"
|
||||
|
||||
case "Ω":
|
||||
fallthrough
|
||||
case "kΩ":
|
||||
ret = "Resistance"
|
||||
|
||||
case "%":
|
||||
ret = "Percent"
|
||||
|
||||
case "F":
|
||||
fallthrough
|
||||
case "C":
|
||||
fallthrough
|
||||
case "℃":
|
||||
ret = "Temperature"
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// UnmarshalJSON - Convert JSON to value
|
||||
func (t *UnitValue) UnmarshalJSON(data []byte) error {
|
||||
for range Only.Once {
|
||||
@ -157,6 +221,8 @@ func (t UnitValue) MarshalJSON() ([]byte, error) {
|
||||
}
|
||||
}
|
||||
|
||||
data = []byte(fmt.Sprintf(`{"unit":"%s","value":"--"}`, t.UnitValue))
|
||||
|
||||
t.Valid = true
|
||||
}
|
||||
|
||||
@ -402,6 +468,7 @@ func (t *UnitValue) SetBoolString(value string) UnitValue {
|
||||
func (t *UnitValue) SetUnit(unit string) UnitValue {
|
||||
for range Only.Once {
|
||||
t.UnitValue = unit
|
||||
t.TypeValue = UnitValueType(unit)
|
||||
}
|
||||
|
||||
return *t
|
||||
|
@ -75,6 +75,11 @@ func (w *Web) Get(endpoint EndPoint) EndPoint {
|
||||
break
|
||||
}
|
||||
endpoint = endpoint.SetResponse(w.Body)
|
||||
if endpoint.GetError() != nil {
|
||||
w.Error = endpoint.GetError()
|
||||
break
|
||||
}
|
||||
|
||||
w.Error = endpoint.IsResponseValid()
|
||||
if w.Error != nil {
|
||||
_ = w.WebCacheRemove(endpoint)
|
||||
|
@ -17,9 +17,12 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
||||
// ****************************************************** //
|
||||
|
||||
func (sg *SunGrow) GetEndpoints(endpoints []string, psIds []valueTypes.Integer, date valueTypes.DateTime, reportType string, faultTypeCode string) error {
|
||||
// func (sg *SunGrow) GetEndpoints(endpoints []string, psIds []string, date string, reportType string, faultTypeCode string) error {
|
||||
|
||||
func (sg *SunGrow) GetEndpoints(endpoints []string, args ...string) error {
|
||||
for range Only.Once {
|
||||
var data SunGrowData
|
||||
data.New(sg)
|
||||
@ -37,24 +40,22 @@ func (sg *SunGrow) GetEndpoints(endpoints []string, psIds []valueTypes.Integer,
|
||||
endpoints = data.GetAllEndPoints()
|
||||
}
|
||||
|
||||
if len(psIds) == 0 {
|
||||
psIds, sg.Error = sg.GetPsIds()
|
||||
var request SunGrowDataRequest
|
||||
request = request.Set(args...)
|
||||
|
||||
for _, endpoint := range endpoints {
|
||||
ep := sg.GetEndpoint(endpoint)
|
||||
sg.Error = ep.GetError()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if date.IsZero() {
|
||||
date = valueTypes.NewDateTime(valueTypes.Now)
|
||||
}
|
||||
rargs := ep.GetRequestArgNames()
|
||||
// fmt.Printf("args:%s\n", rargs)
|
||||
|
||||
for _, endpoint := range endpoints {
|
||||
args := sg.RequestArgs(endpoint)
|
||||
fmt.Printf("args:%s\n", args)
|
||||
if len(args) == 0 {
|
||||
// We don't have any request args.
|
||||
req := SunGrowDataRequest {}
|
||||
response := data.GetByApi(endpoint, req)
|
||||
if _, ok := rargs[NamePsId]; !ok {
|
||||
// We don't have any request PsId args.
|
||||
response := data.GetByApi(ep, request)
|
||||
if response.Error != nil {
|
||||
sg.Error = response.Error
|
||||
break
|
||||
@ -63,62 +64,29 @@ func (sg *SunGrow) GetEndpoints(endpoints []string, psIds []valueTypes.Integer,
|
||||
sg.Error = data.Error
|
||||
break
|
||||
}
|
||||
response.Table.SetFilePrefix(request.GetFilename(endpoint))
|
||||
sg.Error = response.Table.Output()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
if _, ok := args["PsId"]; !ok {
|
||||
// If we don't need a PsId
|
||||
req := SunGrowDataRequest {
|
||||
Date: date,
|
||||
ReportType: reportType,
|
||||
FaultTypeCode: faultTypeCode,
|
||||
}
|
||||
response := data.GetByApi(endpoint, req)
|
||||
if response.Error != nil {
|
||||
sg.Error = response.Error
|
||||
break
|
||||
}
|
||||
if data.Error != nil {
|
||||
sg.Error = data.Error
|
||||
break
|
||||
}
|
||||
sg.Error = response.Table.Output()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
if _, ok := args["PsId"]; ok {
|
||||
// This method merges all ps_ids
|
||||
if _, ok := rargs[NamePsId]; ok {
|
||||
var finalData api.DataMap
|
||||
finalFilename := endpoint + "_"
|
||||
var finalRaw []byte
|
||||
|
||||
for _, psId := range psIds {
|
||||
finalFilename += psId.String() + "-"
|
||||
var pids valueTypes.PsIds
|
||||
pids, sg.Error = sg.GetPsIds()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
request.SetPsIds(pids.Strings())
|
||||
|
||||
req := SunGrowDataRequest {
|
||||
PsId: psId,
|
||||
Date: date,
|
||||
ReportType: reportType,
|
||||
FaultTypeCode: faultTypeCode,
|
||||
}
|
||||
for _, psId := range pids {
|
||||
request.SetPsId(psId.String())
|
||||
|
||||
// if data.HasArgs(endpoint) {
|
||||
// }
|
||||
// _, ok := data.FuncExists(endpoint)
|
||||
// if ok {
|
||||
// response = data.GetByFunc(endpoint, req)
|
||||
// } else {
|
||||
// data.Error = nil
|
||||
// response = data.GetByApi(endpoint, req)
|
||||
// }
|
||||
response := data.GetByApi(endpoint, req)
|
||||
response := data.GetByApi(ep, request)
|
||||
if response.Error != nil {
|
||||
sg.Error = response.Error
|
||||
break
|
||||
@ -129,14 +97,21 @@ func (sg *SunGrow) GetEndpoints(endpoints []string, psIds []valueTypes.Integer,
|
||||
}
|
||||
|
||||
finalData.AppendMap(response.Data)
|
||||
finalRaw = append(finalRaw, response.Table.GetRawBytes()...)
|
||||
}
|
||||
|
||||
if sg.Error != nil {
|
||||
fmt.Printf("Error: %s\n", sg.Error)
|
||||
break
|
||||
}
|
||||
|
||||
request.SetPsId(strings.Join(request.aPsId.Strings(), "_")) // Hackety hack.
|
||||
finalTable := finalData.CreateTable()
|
||||
// response.Table.SetTitle(response.Title)
|
||||
finalFilename = strings.TrimSuffix(finalFilename, "-")
|
||||
finalTable.SetFilePrefix(finalFilename)
|
||||
finalTable.SetFilePrefix(request.GetFilename(endpoint))
|
||||
finalTable.SetGraphFilter("")
|
||||
finalTable.SetSaveFile(sg.SaveAsFile)
|
||||
finalTable.SetRaw(finalRaw)
|
||||
finalTable.OutputType = sg.OutputType
|
||||
|
||||
sg.Error = finalTable.Output()
|
||||
@ -144,6 +119,7 @@ func (sg *SunGrow) GetEndpoints(endpoints []string, psIds []valueTypes.Integer,
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,13 +127,6 @@ func (sg *SunGrow) GetEndpoints(endpoints []string, psIds []valueTypes.Integer,
|
||||
}
|
||||
|
||||
|
||||
type SunGrowData struct {
|
||||
EndPoint string
|
||||
EndPoints EndPoints
|
||||
SunGrow *SunGrow
|
||||
Error error
|
||||
}
|
||||
|
||||
type EndPoints map[string]EndPoint
|
||||
type EndPoint struct {
|
||||
Func SunGrowDataFunction
|
||||
@ -165,12 +134,363 @@ type EndPoint struct {
|
||||
}
|
||||
|
||||
type SunGrowDataFunction func(request SunGrowDataRequest) SunGrowDataResponse
|
||||
|
||||
// SunGrowDataRequest - Collection of all possible request args.
|
||||
type SunGrowDataRequest struct {
|
||||
PsId valueTypes.Integer `json:"ps_id,omitempty"`
|
||||
ReportType string `json:"report_type,omitempty"`
|
||||
Date valueTypes.DateTime `json:"date,omitempty"`
|
||||
FaultTypeCode string `json:"fault_type_code,omitempty"`
|
||||
PsId *valueTypes.PsId `json:"ps_id,omitempty"`
|
||||
ReportType *string `json:"report_type,omitempty"`
|
||||
DateId *valueTypes.DateTime `json:"date_id,omitempty"`
|
||||
DateType *string `json:"date_type,omitempty"`
|
||||
FaultTypeCode *string `json:"fault_type_code,omitempty"`
|
||||
Size *valueTypes.Integer `json:"page_size,omitempty"`
|
||||
CurPage *valueTypes.Integer `json:"cur_page,omitempty"`
|
||||
DeviceType *valueTypes.String `json:"device_type,omitempty"`
|
||||
ReportId *valueTypes.String `json:"report_id,omitempty"`
|
||||
CodeType *valueTypes.String `json:"code_type,omitempty"`
|
||||
OrgIds *valueTypes.String `json:"orgIds,omitempty"`
|
||||
PsIdList *valueTypes.String `json:"ps_id_list,omitempty"`
|
||||
|
||||
aPsId valueTypes.PsIds
|
||||
}
|
||||
|
||||
const (
|
||||
NamePsId = "PsId"
|
||||
NameReportType = "ReportType"
|
||||
NameDateId = "DateId"
|
||||
NameDateType = "DateType"
|
||||
NameFaultTypeCode = "FaultTypeCode"
|
||||
NameSize = "Size"
|
||||
NameCurPage = "CurPage"
|
||||
NameDeviceType = "DeviceType"
|
||||
NameReportId = "ReportId"
|
||||
NameCodeType = "CodeType"
|
||||
NameOrgIds = "OrgIds"
|
||||
NamePsIdList = "PsIdList"
|
||||
)
|
||||
|
||||
// MarshalJSON - Convert value to JSON
|
||||
func (sgd SunGrowDataRequest) MarshalJSON() ([]byte, error) {
|
||||
var data []byte
|
||||
var err error
|
||||
|
||||
for range Only.Once {
|
||||
var dt *string
|
||||
if sgd.DateId != nil {
|
||||
dt = &sgd.DateId.DateType
|
||||
}
|
||||
|
||||
type Parse SunGrowDataRequest
|
||||
// Store result from string
|
||||
data, err = json.Marshal(Parse {
|
||||
PsId: sgd.PsId,
|
||||
ReportType: sgd.ReportType,
|
||||
DateId: sgd.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,
|
||||
})
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return data, err
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) Set(args ...string) SunGrowDataRequest {
|
||||
var request SunGrowDataRequest
|
||||
for range Only.Once {
|
||||
for _, arg := range args {
|
||||
a := strings.Split(arg, ":")
|
||||
if len(a) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
if len(a) == 1 {
|
||||
a = append(a, "")
|
||||
}
|
||||
|
||||
switch a[0] {
|
||||
case NamePsId:
|
||||
request.aPsId = valueTypes.SetPsIdStrings(strings.Split(a[1], ","))
|
||||
|
||||
case NameReportType:
|
||||
request.ReportType = &a[1]
|
||||
|
||||
case NameDateId:
|
||||
val := valueTypes.SetDateTimeString(a[1])
|
||||
request.DateId = &val
|
||||
|
||||
case NameFaultTypeCode:
|
||||
request.FaultTypeCode = &a[1]
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
return request
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) Validate(endpoint api.EndPoint) bool {
|
||||
ok := true
|
||||
for range Only.Once {
|
||||
args := endpoint.GetRequestArgNames()
|
||||
for key, value := range args {
|
||||
if value != "true" {
|
||||
continue
|
||||
}
|
||||
switch key {
|
||||
case NamePsId:
|
||||
// if sgd.PsId == nil {
|
||||
// fmt.Printf("%s is required\n", key)
|
||||
// ok = false
|
||||
// }
|
||||
|
||||
case NameReportType:
|
||||
if sgd.ReportType == nil {
|
||||
fmt.Printf("%s is required\n", key)
|
||||
ok = false
|
||||
}
|
||||
|
||||
case NameDateId:
|
||||
if sgd.DateId == nil {
|
||||
fmt.Printf("%s is required\n", key)
|
||||
ok = false
|
||||
}
|
||||
|
||||
case NameFaultTypeCode:
|
||||
if sgd.FaultTypeCode == nil {
|
||||
fmt.Printf("%s is required\n", key)
|
||||
ok = false
|
||||
}
|
||||
|
||||
case NameSize:
|
||||
if sgd.Size == nil {
|
||||
fmt.Printf("%s is required\n", key)
|
||||
ok = false
|
||||
}
|
||||
|
||||
case NameCurPage:
|
||||
if sgd.CurPage == nil {
|
||||
fmt.Printf("%s is required\n", key)
|
||||
ok = false
|
||||
}
|
||||
|
||||
case NameDeviceType:
|
||||
if sgd.DeviceType == nil {
|
||||
fmt.Printf("%s is required\n", key)
|
||||
ok = false
|
||||
}
|
||||
|
||||
case NameReportId:
|
||||
if sgd.ReportId == nil {
|
||||
fmt.Printf("%s is required\n", key)
|
||||
ok = false
|
||||
}
|
||||
|
||||
case NameCodeType:
|
||||
if sgd.CodeType == nil {
|
||||
fmt.Printf("%s is required\n", key)
|
||||
ok = false
|
||||
}
|
||||
|
||||
case NameOrgIds:
|
||||
if sgd.OrgIds == nil {
|
||||
fmt.Printf("%s is required\n", key)
|
||||
ok = false
|
||||
}
|
||||
|
||||
case NamePsIdList:
|
||||
if sgd.PsIdList == nil {
|
||||
fmt.Printf("%s is required\n", key)
|
||||
ok = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok
|
||||
}
|
||||
|
||||
// func (sgd *SunGrowDataRequest) Create(endpoint api.EndPoint) SunGrowDataRequest {
|
||||
// var request SunGrowDataRequest
|
||||
// for range Only.Once {
|
||||
// args := endpoint.GetRequestArgNames()
|
||||
// for key, value := range args {
|
||||
// if value != "true" {
|
||||
// continue
|
||||
// }
|
||||
// switch key {
|
||||
// case NamePsId:
|
||||
// request.PsId = sgd.PsId
|
||||
//
|
||||
// case NameReportType:
|
||||
// request.ReportType = sgd.ReportType
|
||||
// if *request.ReportType == "" {
|
||||
// *request.ReportType = "1"
|
||||
// }
|
||||
//
|
||||
// case NameDateId:
|
||||
// request.DateId = sgd.DateId
|
||||
// if request.DateId.IsZero() {
|
||||
// did := valueTypes.SetDateTimeString(time.Now().Format(valueTypes.DateTimeLayoutDay))
|
||||
// request.DateId = &did
|
||||
// }
|
||||
//
|
||||
// case NameFaultTypeCode:
|
||||
// request.FaultTypeCode = sgd.FaultTypeCode
|
||||
//
|
||||
// case NameSize:
|
||||
// request.Size = sgd.Size
|
||||
// if request.Size.Value() == 0 {
|
||||
// request.Size.SetValue(100)
|
||||
// }
|
||||
//
|
||||
// case NameCurPage:
|
||||
// request.CurPage = sgd.CurPage
|
||||
// if request.CurPage.Value() == 0 {
|
||||
// request.CurPage.SetValue(1)
|
||||
// }
|
||||
//
|
||||
// case NameDeviceType:
|
||||
// request.DeviceType = sgd.DeviceType
|
||||
// // if request.DeviceType.String() == "" {
|
||||
// // request.DeviceType.SetValue("14") // @TODO - Need to lookup the first device_type.
|
||||
// // }
|
||||
//
|
||||
// case NameReportId:
|
||||
// request.ReportId = sgd.ReportId
|
||||
// // if request.ReportId.String() == "" {
|
||||
// // request.ReportId.SetValue("8042") // @TODO - Need to lookup the first device_type.
|
||||
// // }
|
||||
//
|
||||
// case NameCodeType:
|
||||
// request.CodeType = sgd.CodeType
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return request
|
||||
// }
|
||||
|
||||
func (sgd *SunGrowDataRequest) Help(endpoint api.EndPoint) {
|
||||
for range Only.Once {
|
||||
args := endpoint.GetRequestArgNames()
|
||||
for key, value := range args {
|
||||
if key == NamePsId {
|
||||
continue
|
||||
}
|
||||
|
||||
if key == NameDateType {
|
||||
continue
|
||||
}
|
||||
|
||||
if value != "true" {
|
||||
fmt.Printf("optional - %s:value\n", key)
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Printf("required - %s:value\n", key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) GetFilename(prefix string) string {
|
||||
var ret string
|
||||
for range Only.Once {
|
||||
var aret []string
|
||||
|
||||
aret = append(aret, prefix)
|
||||
if sgd.PsId != nil {
|
||||
if sgd.PsId.String() != "" {
|
||||
aret = append(aret, sgd.PsId.String())
|
||||
}
|
||||
}
|
||||
|
||||
if sgd.DateId != nil {
|
||||
if sgd.DateId.Original() != "" {
|
||||
aret = append(aret, sgd.DateId.Original())
|
||||
}
|
||||
}
|
||||
|
||||
if sgd.ReportType != nil {
|
||||
if *sgd.ReportType != "" {
|
||||
aret = append(aret, *sgd.ReportType)
|
||||
}
|
||||
}
|
||||
|
||||
if sgd.FaultTypeCode != nil {
|
||||
if *sgd.FaultTypeCode != "" {
|
||||
aret = append(aret, *sgd.FaultTypeCode)
|
||||
}
|
||||
}
|
||||
|
||||
ret = strings.Join(aret, "-")
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) SetFaultTypeCode(ftc string) {
|
||||
sgd.FaultTypeCode = &ftc
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) SetReportType(rt string) {
|
||||
sgd.ReportType = &rt
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) SetPsIds(psIds []string) {
|
||||
sgd.aPsId = valueTypes.SetPsIdStrings(psIds)
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) GetPsIds() valueTypes.PsIds {
|
||||
return sgd.aPsId
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataRequest) SetPsId(psId string) {
|
||||
pid := valueTypes.SetPsIdString(psId)
|
||||
sgd.PsId = &pid
|
||||
}
|
||||
|
||||
|
||||
type SunGrowDataResponse struct {
|
||||
Data api.DataMap
|
||||
Table output.Table
|
||||
@ -180,6 +500,13 @@ type SunGrowDataResponse struct {
|
||||
}
|
||||
|
||||
|
||||
type SunGrowData struct {
|
||||
// EndPoint string
|
||||
EndPoints EndPoints
|
||||
SunGrow *SunGrow
|
||||
Error error
|
||||
}
|
||||
|
||||
func (sgd *SunGrowData) New(ref *SunGrow) {
|
||||
for range Only.Once {
|
||||
sgd.SunGrow = ref
|
||||
@ -266,35 +593,97 @@ func (sgd *SunGrowData) GetByFunc(endpoint string, request SunGrowDataRequest) S
|
||||
return response
|
||||
}
|
||||
|
||||
func (sgd *SunGrowData) GetByApi(endpoint string, request SunGrowDataRequest) SunGrowDataResponse {
|
||||
func (sgd *SunGrowData) GetByEndPointName(endpoint string, request SunGrowDataRequest) SunGrowDataResponse {
|
||||
var response SunGrowDataResponse
|
||||
response.Table = output.NewTable()
|
||||
for range Only.Once {
|
||||
req, err := json.Marshal(request)
|
||||
if err != nil {
|
||||
fmt.Printf("GetByApi - ERR: %s\n", err)
|
||||
ep := sgd.SunGrow.GetEndpoint(endpoint)
|
||||
sgd.SunGrow.Error = ep.GetError()
|
||||
if sgd.SunGrow.Error != nil {
|
||||
break
|
||||
}
|
||||
response = sgd.GetByApi(ep, request)
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
data := sgd.SunGrow.GetByJson(endpoint, string(req))
|
||||
if data.IsError() {
|
||||
sgd.Error = data.GetError()
|
||||
func (sgd *SunGrowData) GetByApi(endpoint api.EndPoint, request SunGrowDataRequest) SunGrowDataResponse {
|
||||
var response SunGrowDataResponse
|
||||
response.Table = output.NewTable()
|
||||
for range Only.Once {
|
||||
|
||||
if !request.Validate(endpoint) {
|
||||
request.Help(endpoint)
|
||||
break
|
||||
}
|
||||
|
||||
fn := ""
|
||||
if request.PsId.String() != "" {
|
||||
fn += "-" + request.PsId.String()
|
||||
var req []byte
|
||||
req, sgd.Error = json.Marshal(request)
|
||||
if sgd.Error != nil {
|
||||
fmt.Printf("GetByApi - ERR: %s\n", sgd.Error)
|
||||
break
|
||||
}
|
||||
if !request.Date.IsZero() {
|
||||
fn += "-" + request.Date.Original()
|
||||
fmt.Printf("%s\n", req)
|
||||
|
||||
// newRequest := request.Create(endpoint)
|
||||
|
||||
if string(req) != "" {
|
||||
endpoint = endpoint.SetRequestByJson(output.Json(req))
|
||||
sgd.Error = endpoint.GetError()
|
||||
if sgd.Error != nil {
|
||||
fmt.Println(endpoint.Help())
|
||||
break
|
||||
}
|
||||
}
|
||||
response.Filename = data.SetFilenamePrefix(fn)
|
||||
fmt.Printf("%s\n", endpoint.GetRequestJson())
|
||||
|
||||
endpoint = endpoint.Call()
|
||||
sgd.Error = endpoint.GetError()
|
||||
if sgd.Error != nil {
|
||||
if strings.Contains(sgd.Error.Error(), "er_token_login_invalid") {
|
||||
sgd.SunGrow.Logout()
|
||||
break
|
||||
}
|
||||
fmt.Println(endpoint.Help())
|
||||
break
|
||||
}
|
||||
|
||||
// switch {
|
||||
// case sgd.SunGrow.OutputType.IsNone():
|
||||
//
|
||||
// case sgd.SunGrow.OutputType.IsRaw():
|
||||
// if sgd.SunGrow.SaveAsFile {
|
||||
// sgd.SunGrow.Error = ep.WriteDataFile()
|
||||
// break
|
||||
// }
|
||||
// fmt.Println(ep.GetJsonData(true))
|
||||
//
|
||||
// case sgd.SunGrow.OutputType.IsJson():
|
||||
// if sgd.SunGrow.SaveAsFile {
|
||||
// sgd.SunGrow.Error = ep.WriteDataFile()
|
||||
// break
|
||||
// }
|
||||
// fmt.Println(ep.GetJsonData(false))
|
||||
//
|
||||
// default:
|
||||
// }
|
||||
|
||||
// var fn []string
|
||||
// if request.PsId.String() != "" {
|
||||
// fn = append(fn, request.PsId.String())
|
||||
// }
|
||||
// if !request.DateId.IsZero() {
|
||||
// fn = append(fn, request.DateId.Original())
|
||||
// }
|
||||
response.Filename = request.GetFilename("")
|
||||
response.Filename = endpoint.SetFilenamePrefix(response.Filename)
|
||||
// response.Filename = request.CreateFilename(ep)
|
||||
if response.Title == "" {
|
||||
response.Title = fmt.Sprintf("Data Request %s", endpoint)
|
||||
}
|
||||
|
||||
response.Data = data.GetEndPointData()
|
||||
response.Table = data.GetEndPointDataTable()
|
||||
response.Data = endpoint.GetEndPointData()
|
||||
response.Table = endpoint.GetEndPointDataTable()
|
||||
// response.Table.SetTitle(response.Title)
|
||||
response.Table.SetFilePrefix(response.Filename)
|
||||
response.Table.SetGraphFilter("")
|
||||
@ -410,7 +799,7 @@ func (sgd *SunGrowData) findCodeValueList(request SunGrowDataRequest) SunGrowDat
|
||||
ep := sgd.SunGrow.GetByStruct(
|
||||
"AppService.findCodeValueList",
|
||||
// findCodeValueList.RequestData{ PsId: request.PsId },
|
||||
findCodeValueList.RequestData{ CodeType: "1" },
|
||||
findCodeValueList.RequestData{ CodeType: *request.CodeType },
|
||||
api.DefaultTimeout,
|
||||
)
|
||||
|
||||
|
@ -40,7 +40,7 @@ func (sg *SunGrow) GetPointNamesFromTemplate(template string) api.TemplatePoints
|
||||
|
||||
ep := sg.GetByStruct(
|
||||
"WebAppService.queryUserCurveTemplateData",
|
||||
queryUserCurveTemplateData.RequestData{TemplateID: template},
|
||||
queryUserCurveTemplateData.RequestData{TemplateId: template},
|
||||
time.Hour,
|
||||
)
|
||||
if sg.Error != nil {
|
||||
@ -55,7 +55,7 @@ func (sg *SunGrow) GetPointNamesFromTemplate(template string) api.TemplatePoints
|
||||
}
|
||||
ret = append(ret, api.TemplatePoint {
|
||||
PsKey: dn,
|
||||
PointId: pr.PointID,
|
||||
PointId: pr.PointId,
|
||||
Name: pr.PointName,
|
||||
Unit: pr.Unit,
|
||||
})
|
||||
@ -77,7 +77,7 @@ func (sg *SunGrow) GetTemplateData(template string, date string, filter string)
|
||||
}
|
||||
when := valueTypes.NewDateTime(date)
|
||||
|
||||
var psIds []valueTypes.Integer
|
||||
var psIds []valueTypes.PsId
|
||||
psIds, sg.Error = sg.StringToPids()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
@ -92,8 +92,8 @@ func (sg *SunGrow) GetTemplateData(template string, date string, filter string)
|
||||
ep := sg.GetByStruct(
|
||||
"AppService.queryMutiPointDataList",
|
||||
queryMutiPointDataList.RequestData {
|
||||
// PsID: api.SetIntegerValue(psId),
|
||||
PsID: psId,
|
||||
// PsId: api.SetIntegerValue(psId),
|
||||
PsId: psId,
|
||||
PsKey: valueTypes.SetPsKeyValue(pointNames.PrintKeys()),
|
||||
Points: pointNames.PrintPoints(),
|
||||
MinuteInterval: "5",
|
||||
@ -484,7 +484,7 @@ func (sg *SunGrow) GetRealTimeData(psKey string) error {
|
||||
return sg.Error
|
||||
}
|
||||
|
||||
func (sg *SunGrow) CmdDataPsDetail(psIds ...valueTypes.Integer) error {
|
||||
func (sg *SunGrow) CmdDataPsDetail(psIds ...valueTypes.PsId) error {
|
||||
for range Only.Once {
|
||||
if len(psIds) == 0 {
|
||||
psIds, sg.Error = sg.GetPsIds()
|
||||
@ -497,7 +497,7 @@ func (sg *SunGrow) CmdDataPsDetail(psIds ...valueTypes.Integer) error {
|
||||
data.New(sg)
|
||||
|
||||
for _, psId := range psIds {
|
||||
response := data.GetByApi("getPsDetail", SunGrowDataRequest{PsId: psId})
|
||||
response := data.GetByEndPointName("getPsDetail", SunGrowDataRequest{PsId: &psId})
|
||||
if response.Error != nil {
|
||||
break
|
||||
}
|
||||
@ -506,7 +506,7 @@ func (sg *SunGrow) CmdDataPsDetail(psIds ...valueTypes.Integer) error {
|
||||
break
|
||||
}
|
||||
|
||||
response = data.GetByApi("getPsDetailWithPsType", SunGrowDataRequest{PsId: psId})
|
||||
response = data.GetByEndPointName("getPsDetailWithPsType", SunGrowDataRequest{PsId: &psId})
|
||||
if response.Error != nil {
|
||||
break
|
||||
}
|
||||
@ -520,7 +520,7 @@ func (sg *SunGrow) CmdDataPsDetail(psIds ...valueTypes.Integer) error {
|
||||
return sg.Error
|
||||
}
|
||||
|
||||
func (sg *SunGrow) GetPointData(date string, pointNames api.TemplatePoints, psIds ...valueTypes.Integer) error {
|
||||
func (sg *SunGrow) GetPointData(date string, pointNames api.TemplatePoints, psIds ...valueTypes.PsId) error {
|
||||
for range Only.Once {
|
||||
if len(pointNames) == 0 {
|
||||
sg.Error = errors.New("no points defined")
|
||||
@ -543,7 +543,7 @@ func (sg *SunGrow) GetPointData(date string, pointNames api.TemplatePoints, psId
|
||||
ep := sg.GetByStruct(
|
||||
"AppService.queryMutiPointDataList",
|
||||
queryMutiPointDataList.RequestData{
|
||||
PsID: psId,
|
||||
PsId: psId,
|
||||
PsKey: valueTypes.SetPsKeyValue(pointNames.PrintKeys()),
|
||||
Points: pointNames.PrintPoints(),
|
||||
MinuteInterval: "5",
|
||||
@ -600,7 +600,7 @@ func (sg *SunGrow) SearchPointNames(pns ...string) error {
|
||||
ep := sg.GetByStruct(
|
||||
"AppService.getPowerDevicePointInfo",
|
||||
// getPowerDevicePointInfo.RequestData{Id: strconv.FormatInt(int64(pni), 10)},
|
||||
getPowerDevicePointInfo.RequestData{Id: valueTypes.SetIntegerValue(int64(pni)) },
|
||||
getPowerDevicePointInfo.RequestData{PsId: valueTypes.SetPsIdValue(int64(pni)) },
|
||||
DefaultCacheTimeout,
|
||||
)
|
||||
if sg.Error != nil {
|
||||
@ -620,7 +620,7 @@ func (sg *SunGrow) SearchPointNames(pns ...string) error {
|
||||
for _, pn := range pns {
|
||||
ep := sg.GetByStruct(
|
||||
"AppService.getPowerDevicePointInfo",
|
||||
getPowerDevicePointInfo.RequestData{Id: valueTypes.SetIntegerString(pn)},
|
||||
getPowerDevicePointInfo.RequestData{PsId: valueTypes.SetPsIdString(pn)},
|
||||
DefaultCacheTimeout,
|
||||
)
|
||||
if sg.Error != nil {
|
||||
@ -651,7 +651,7 @@ func (sg *SunGrow) SearchPointNames(pns ...string) error {
|
||||
return sg.Error
|
||||
}
|
||||
|
||||
func (sg *SunGrow) GetDeviceList(psIds ...valueTypes.Integer) error {
|
||||
func (sg *SunGrow) GetDeviceList(psIds ...valueTypes.PsId) error {
|
||||
for range Only.Once {
|
||||
if len(psIds) == 0 {
|
||||
psIds, sg.Error = sg.GetPsIds()
|
||||
@ -723,7 +723,7 @@ func (sg *SunGrow) GetDeviceModelInfoList() error {
|
||||
return sg.Error
|
||||
}
|
||||
|
||||
func (sg *SunGrow) GetDevicePoints(psIds ...valueTypes.Integer) error {
|
||||
func (sg *SunGrow) GetDevicePoints(psIds ...valueTypes.PsId) error {
|
||||
for range Only.Once {
|
||||
var points api.DataMap
|
||||
|
||||
@ -776,7 +776,7 @@ func (sg *SunGrow) GetDevicePoints(psIds ...valueTypes.Integer) error {
|
||||
|
||||
// getPowerStationData
|
||||
// api raw getPowerStationData '{"date_id":"20221007","date_type":"1","ps_id":"1171348"}'
|
||||
ep = sg.GetByStruct("AppService.getPowerStationData", getPowerStationData.RequestData{ PsId: psId, DateType: "1", DateID: "20221007"}, DefaultCacheTimeout)
|
||||
ep = sg.GetByStruct("AppService.getPowerStationData", getPowerStationData.RequestData{ PsId: psId, DateType: "1", DateId: "20221007"}, DefaultCacheTimeout)
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
@ -789,7 +789,7 @@ func (sg *SunGrow) GetDevicePoints(psIds ...valueTypes.Integer) error {
|
||||
points.AppendMap(data)
|
||||
|
||||
// api raw getPowerStationData '{"date_id":"202210","date_type":"2","ps_id":"1171348"}'
|
||||
ep = sg.GetByStruct("AppService.getPowerStationData", getPowerStationData.RequestData{ PsId: psId, DateType: "2", DateID: "202210"}, DefaultCacheTimeout)
|
||||
ep = sg.GetByStruct("AppService.getPowerStationData", getPowerStationData.RequestData{ PsId: psId, DateType: "2", DateId: "202210"}, DefaultCacheTimeout)
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
@ -802,7 +802,7 @@ func (sg *SunGrow) GetDevicePoints(psIds ...valueTypes.Integer) error {
|
||||
points.AppendMap(data)
|
||||
|
||||
// api raw getPowerStationData '{"date_id":"2022","date_type":"3","ps_id":"1171348"}'
|
||||
ep = sg.GetByStruct("AppService.getPowerStationData", getPowerStationData.RequestData{ PsId: psId, DateType: "3", DateID: "2022"}, DefaultCacheTimeout)
|
||||
ep = sg.GetByStruct("AppService.getPowerStationData", getPowerStationData.RequestData{ PsId: psId, DateType: "3", DateId: "2022"}, DefaultCacheTimeout)
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
@ -834,7 +834,7 @@ func (sg *SunGrow) GetDevicePoints(psIds ...valueTypes.Integer) error {
|
||||
// api get getHouseholdStoragePsReport '{"date_id":"20221001","date_type":"1","ps_id":"1129147"}'
|
||||
ep = sg.GetByStruct(
|
||||
"AppService.getHouseholdStoragePsReport",
|
||||
getHouseholdStoragePsReport.RequestData{ DateID: "20221001", DateType: "1", PsId: psId },
|
||||
getHouseholdStoragePsReport.RequestData{ DateId: "20221001", DateType: "1", PsId: psId },
|
||||
DefaultCacheTimeout,
|
||||
)
|
||||
if sg.Error != nil {
|
||||
@ -947,11 +947,11 @@ func PrintPause(index int, max int) {
|
||||
}
|
||||
}
|
||||
|
||||
func (sg *SunGrow) GetPointName(psIds valueTypes.Integer) error {
|
||||
func (sg *SunGrow) GetPointName(psId valueTypes.PsId) error {
|
||||
for range Only.Once {
|
||||
ep := sg.GetByStruct(
|
||||
"AppService.getPowerDevicePointInfo",
|
||||
getPowerDevicePointInfo.RequestData{Id: psIds},
|
||||
getPowerDevicePointInfo.RequestData{PsId: psId},
|
||||
DefaultCacheTimeout,
|
||||
)
|
||||
if sg.Error != nil {
|
||||
@ -968,7 +968,7 @@ func (sg *SunGrow) GetPointName(psIds valueTypes.Integer) error {
|
||||
// table2 := data.GetEndPointData()
|
||||
// fmt.Printf("%v\n", table2)
|
||||
|
||||
table.SetTitle("Point Name %s", psIds)
|
||||
table.SetTitle("Point Name %s", psId)
|
||||
table.SetFilePrefix(data.SetFilenamePrefix(""))
|
||||
table.SetGraphFilter("")
|
||||
table.SetSaveFile(sg.SaveAsFile)
|
||||
@ -983,8 +983,8 @@ func (sg *SunGrow) GetPointName(psIds valueTypes.Integer) error {
|
||||
}
|
||||
|
||||
|
||||
func (sg *SunGrow) GetPsIds() ([]valueTypes.Integer, error) {
|
||||
var ret []valueTypes.Integer
|
||||
func (sg *SunGrow) GetPsIds() ([]valueTypes.PsId, error) {
|
||||
var ret []valueTypes.PsId
|
||||
|
||||
for range Only.Once {
|
||||
ep := sg.GetByStruct("AppService.getPsList", nil, DefaultCacheTimeout)
|
||||
@ -1000,8 +1000,8 @@ func (sg *SunGrow) GetPsIds() ([]valueTypes.Integer, error) {
|
||||
return ret, sg.Error
|
||||
}
|
||||
|
||||
func (sg *SunGrow) GetPsId() (valueTypes.Integer, error) {
|
||||
var ret valueTypes.Integer
|
||||
func (sg *SunGrow) GetPsId() (valueTypes.PsId, error) {
|
||||
var ret valueTypes.PsId
|
||||
|
||||
for range Only.Once {
|
||||
|
||||
@ -1023,15 +1023,15 @@ func (sg *SunGrow) GetPsId() (valueTypes.Integer, error) {
|
||||
return ret, sg.Error
|
||||
}
|
||||
|
||||
func (sg *SunGrow) StringToPids(pids ...string) ([]valueTypes.Integer, error) {
|
||||
var psIds []valueTypes.Integer
|
||||
func (sg *SunGrow) StringToPids(pids ...string) ([]valueTypes.PsId, error) {
|
||||
var psIds []valueTypes.PsId
|
||||
for range Only.Once {
|
||||
for _, pid := range pids {
|
||||
// p, err := strconv.ParseInt(pid, 10, 64)
|
||||
// if err != nil {
|
||||
// continue
|
||||
// }
|
||||
psIds = append(psIds, valueTypes.SetIntegerString(pid))
|
||||
psIds = append(psIds, valueTypes.SetPsIdString(pid))
|
||||
}
|
||||
if len(psIds) == 0 {
|
||||
psIds, sg.Error = sg.GetPsIds()
|
||||
@ -1077,15 +1077,15 @@ func (sg *SunGrow) GetDevices(print bool) (getDeviceList.Devices, error) {
|
||||
for _, psId := range psIds {
|
||||
ret = append(ret, getDeviceList.Device{
|
||||
Vendor: valueTypes.SetStringValue(""),
|
||||
PsId: psId.PsID,
|
||||
PsKey: valueTypes.SetPsKeyValue(psId.PsID.String()),
|
||||
PsId: psId.PsId,
|
||||
PsKey: valueTypes.SetPsKeyValue(psId.PsId.String()),
|
||||
DeviceName: psId.PsName,
|
||||
DeviceProSn: psId.PsShortName,
|
||||
DeviceModel: valueTypes.SetStringValue(""),
|
||||
DeviceType: psId.PsType,
|
||||
DeviceCode: valueTypes.SetIntegerValue(0),
|
||||
ChannelId: valueTypes.SetIntegerValue(0),
|
||||
DeviceModelID: valueTypes.SetIntegerValue(0),
|
||||
DeviceModelId: valueTypes.SetIntegerValue(0),
|
||||
TypeName: valueTypes.SetStringValue("Ps Id"),
|
||||
DeviceState: psId.PsHealthStatus,
|
||||
DevStatus: psId.PsStatus,
|
||||
@ -1094,7 +1094,7 @@ func (sg *SunGrow) GetDevices(print bool) (getDeviceList.Devices, error) {
|
||||
// PsFaultStatus: d.PsFaultStatus,
|
||||
// PsHealthStatus: d.PsHealthStatus,
|
||||
// PsHolder: d.PsHolder,
|
||||
// PsID: d.PsID,
|
||||
// PsId: d.PsId,
|
||||
// PsName: d.PsName,
|
||||
// PsShortName: d.PsShortName,
|
||||
// PsStatus: d.PsStatus,
|
||||
@ -1104,7 +1104,7 @@ func (sg *SunGrow) GetDevices(print bool) (getDeviceList.Devices, error) {
|
||||
ep = sg.GetByStruct(
|
||||
"AppService.getDeviceList",
|
||||
// getDeviceList.RequestData{PsId: strconv.FormatInt(psId, 10)},
|
||||
getDeviceList.RequestData{PsId: psId.PsID},
|
||||
getDeviceList.RequestData{PsId: psId.PsId},
|
||||
DefaultCacheTimeout,
|
||||
)
|
||||
if sg.Error != nil {
|
||||
@ -1138,7 +1138,7 @@ func (sg *SunGrow) GetPsModels() ([]string, error) {
|
||||
var ret []string
|
||||
|
||||
for range Only.Once {
|
||||
var psIds []valueTypes.Integer
|
||||
var psIds []valueTypes.PsId
|
||||
psIds, sg.Error = sg.StringToPids()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
@ -1167,7 +1167,7 @@ func (sg *SunGrow) GetPsSerials() ([]string, error) {
|
||||
var ret []string
|
||||
|
||||
for range Only.Once {
|
||||
var psIds []valueTypes.Integer
|
||||
var psIds []valueTypes.PsId
|
||||
psIds, sg.Error = sg.StringToPids()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
@ -1196,7 +1196,7 @@ func (sg *SunGrow) GetPsKeys() ([]string, error) {
|
||||
var ret []string
|
||||
|
||||
for range Only.Once {
|
||||
var psIds []valueTypes.Integer
|
||||
var psIds []valueTypes.PsId
|
||||
psIds, sg.Error = sg.StringToPids()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
|
@ -117,9 +117,7 @@ func (sg *SunGrow) GetByJson(endpoint string, request string) api.EndPoint {
|
||||
sg.Error = ret.GetError()
|
||||
if sg.Error != nil {
|
||||
if strings.Contains(sg.Error.Error(), "er_token_login_invalid") {
|
||||
_ = sg.ApiRoot.WebCacheRemove(sg.Auth)
|
||||
_ = sg.Auth.RemoveToken()
|
||||
// _ = sg.Auth.ApiRemoveDataFile()
|
||||
sg.Logout()
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -192,9 +190,8 @@ func (sg *SunGrow) GetByStruct(endpoint string, request interface{}, cache time.
|
||||
|
||||
sg.Error = ret.GetError()
|
||||
if strings.Contains(sg.Error.Error(), "er_token_login_invalid") {
|
||||
_ = sg.ApiRoot.WebCacheRemove(sg.Auth)
|
||||
_ = sg.Auth.RemoveToken()
|
||||
// _ = sg.Auth.ApiRemoveDataFile()
|
||||
sg.Logout()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@ -285,6 +282,14 @@ func (sg *SunGrow) Login(auth login.SunGrowAuth) error {
|
||||
return sg.Error
|
||||
}
|
||||
|
||||
func (sg *SunGrow) Logout() {
|
||||
for range Only.Once {
|
||||
_ = sg.ApiRoot.WebCacheRemove(sg.Auth)
|
||||
_ = sg.Auth.RemoveToken()
|
||||
// _ = sg.Auth.ApiRemoveDataFile()
|
||||
}
|
||||
}
|
||||
|
||||
func (sg *SunGrow) GetToken() string {
|
||||
return sg.Auth.Token()
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ type Mqtt struct {
|
||||
clientOptions *mqtt.ClientOptions
|
||||
LastRefresh time.Time `json:"-"`
|
||||
SungrowDevices getDeviceList.Devices `json:"-"`
|
||||
SungrowPsIds map[valueTypes.Integer]bool
|
||||
SungrowPsIds map[valueTypes.PsId]bool
|
||||
|
||||
DeviceName string
|
||||
MqttDevices map[string]Device
|
||||
@ -63,7 +63,7 @@ func New(req Mqtt) *Mqtt {
|
||||
ret.binarySensorPrefix = "homeassistant/binary_sensor/" + req.ClientId
|
||||
|
||||
ret.MqttDevices = make(map[string]Device)
|
||||
ret.SungrowPsIds = make(map[valueTypes.Integer]bool)
|
||||
ret.SungrowPsIds = make(map[valueTypes.PsId]bool)
|
||||
}
|
||||
|
||||
return &ret
|
||||
|
Loading…
x
Reference in New Issue
Block a user