diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index a600c6e0a..2a814438f 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -11,24 +11,19 @@
-
-
-
-
-
-
-
+
+
+
+
-
-
-
+
@@ -105,7 +100,7 @@
-
+
@@ -349,7 +344,7 @@
file://$PROJECT_DIR$/iSolarCloud/AppService/getDeviceList/data.go
- 272
+ 269
@@ -359,12 +354,12 @@
file://$PROJECT_DIR$/iSolarCloud/data.go
- 827
+ 828
file://$PROJECT_DIR$/iSolarCloud/data.go
- 833
+ 834
@@ -382,24 +377,14 @@
65
-
- file://$PROJECT_DIR$/iSolarCloud/AppService/getPsWeatherList/data.go
- 66
-
-
-
- file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go
- 126
-
-
file://$PROJECT_DIR$/iSolarCloud/api/valueTypes/types.go
- 702
+ 709
file://$PROJECT_DIR$/iSolarCloud/api/valueTypes/types.go
- 555
+ 562
@@ -409,7 +394,7 @@
file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go
- 315
+ 317
@@ -439,7 +424,7 @@
file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go
- 132
+ 134
@@ -468,59 +453,64 @@
- file://$PROJECT_DIR$/iSolarCloud/AppService/findPsType/data.go
- 48
-
+ file://$PROJECT_DIR$/iSolarCloud/api/valueTypes/types.go
+ 216
+
- file://$PROJECT_DIR$/iSolarCloud/api/apiReflect/reflect.go
- 113
-
+ file://$PROJECT_DIR$/iSolarCloud/api/valueTypes/types.go
+ 218
+
- file://$PROJECT_DIR$/iSolarCloud/api/apiReflect/reflect.go
- 121
-
+ file://$PROJECT_DIR$/iSolarCloud/api/valueTypes/types.go
+ 76
+
- file://$PROJECT_DIR$/iSolarCloud/api/apiReflect/reflect.go
- 312
-
+ file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go
+ 48
+
- file://$PROJECT_DIR$/iSolarCloud/api/apiReflect/reflect.go
- 323
-
+ file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go
+ 228
+
- file://$PROJECT_DIR$/iSolarCloud/api/valueTypes/types.go
- 209
-
+ file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go
+ 403
+
+
+
+ file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go
+ 468
+
file://$PROJECT_DIR$/iSolarCloud/api/valueTypes/types.go
- 211
-
+ 909
+
- file://$PROJECT_DIR$/iSolarCloud/api/apiReflect/reflect.go
- 248
-
+ file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go
+ 128
+
file://$PROJECT_DIR$/iSolarCloud/api/apiReflect/reflect.go
- 250
-
+ 868
+
- file://$PROJECT_DIR$/iSolarCloud/AppService/getHouseholdStoragePsReport/data.go
- 347
-
+ file://$PROJECT_DIR$/iSolarCloud/api/apiReflect/reflect.go
+ 772
+
file://$PROJECT_DIR$/iSolarCloud/api/apiReflect/reflect.go
- 129
-
+ 791
+
@@ -529,10 +519,18 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/iSolarCloud/AppService/findPsType/data.go b/iSolarCloud/AppService/findPsType/data.go
index ccd93f821..1d35eb991 100644
--- a/iSolarCloud/AppService/findPsType/data.go
+++ b/iSolarCloud/AppService/findPsType/data.go
@@ -46,7 +46,7 @@ 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, "", dt)
+ 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())
diff --git a/iSolarCloud/AppService/getAllDeviceByPsId/data.go b/iSolarCloud/AppService/getAllDeviceByPsId/data.go
index e0049fdae..879e72795 100644
--- a/iSolarCloud/AppService/getAllDeviceByPsId/data.go
+++ b/iSolarCloud/AppService/getAllDeviceByPsId/data.go
@@ -47,7 +47,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, "", dt)
+ name := pkg + "." + e.Request.PsId.String()
+ entries.StructToPoints(e.Response.ResultData, name, e.Request.PsId.String(), dt)
}
return entries
diff --git a/iSolarCloud/AppService/getDeviceList/data.go b/iSolarCloud/AppService/getDeviceList/data.go
index ebb035bff..6039d1e0c 100644
--- a/iSolarCloud/AppService/getDeviceList/data.go
+++ b/iSolarCloud/AppService/getDeviceList/data.go
@@ -265,13 +265,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, "", dt)
-
- // pkg := apiReflect.GetName("", *e)
- // for _, d := range e.Response.ResultData.PageList {
- // name := api.JoinWithDots(0, valueTypes.DateTimeLayoutDay, pkg, d.PsKey)
- // entries.StructToPoints(d, name, e.Request.PsId.String(), valueTypes.NewDateTime(""))
- // }
+ name := pkg + "." + e.Request.PsId.String()
+ entries.StructToPoints(e.Response.ResultData, name, e.Request.PsId.String(), dt)
}
return entries
diff --git a/iSolarCloud/AppService/getHouseholdStoragePsReport/data.go b/iSolarCloud/AppService/getHouseholdStoragePsReport/data.go
index d3f91d2fc..3ab3ec58f 100644
--- a/iSolarCloud/AppService/getHouseholdStoragePsReport/data.go
+++ b/iSolarCloud/AppService/getHouseholdStoragePsReport/data.go
@@ -35,10 +35,10 @@ type ResultData struct {
IsHaveEsInverter valueTypes.Bool `json:"is_have_es_inverter"`
IsTransformSystem valueTypes.Bool `json:"is_transform_system"`
- DayData *DayData `json:"day_data,omitempty" PointName:"Day"`
- MonthData *MonthData `json:"month_data,omitempty" PointName:"Month"`
- YearData *YearData `json:"year_data,omitempty" PointName:"Year"`
- TotalData *TotalData `json:"total_data,omitempty" PointName:"Total"`
+ DayData *DayData `json:"day_data,omitempty" PointId:"day"`
+ MonthData *MonthData `json:"month_data,omitempty" PointId:"month"`
+ YearData *YearData `json:"year_data,omitempty" PointId:"year"`
+ TotalData *TotalData `json:"total_data,omitempty" PointId:"total"`
}
type DayData struct {
@@ -64,8 +64,8 @@ type DayData struct {
P83119MapVirgin valueTypes.UnitValue `json:"p83119_map_virgin" PointIgnore:"true"`
P83120Map valueTypes.UnitValue `json:"p83120_map" PointId:"p83120" PointUpdateFreq:"UpdateFreqDay"`
P83120MapVirgin valueTypes.UnitValue `json:"p83120_map_virgin" PointIgnore:"true"`
- P83121 valueTypes.Float `json:"p83121" PointId:"p83121" PointUnitFrom:"FOO" PointUpdateFreq:"UpdateFreqDay"`
- P83122 valueTypes.Float `json:"p83122" PointId:"p83122" PointUnitFrom:"FOO" PointUpdateFreq:"UpdateFreqDay"`
+ P83121 valueTypes.Float `json:"p83121" PointId:"p83121" PointUpdateFreq:"UpdateFreqDay"`
+ P83122 valueTypes.Float `json:"p83122" PointId:"p83122" PointUpdateFreq:"UpdateFreqDay"`
PointData15List []struct {
P83076 valueTypes.Float `json:"p83076" PointId:"p83076" PointName:"PV Power" PointUnitFrom:"P83076Unit" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqDay"`
P83076Unit valueTypes.String `json:"p83076_unit" PointIgnore:"true"`
@@ -116,8 +116,8 @@ type MonthData struct {
P83119MapVirgin valueTypes.UnitValue `json:"p83119_map_virgin" PointIgnore:"true"`
P83120Map valueTypes.UnitValue `json:"p83120_map" PointId:"p83120" PointUpdateFreq:"UpdateFreqMonth"`
P83120MapVirgin valueTypes.UnitValue `json:"p83120_map_virgin" PointIgnore:"true"`
- P83121 valueTypes.Float `json:"p83121" PointId:"p83121" PointUnitFrom:"FOO" PointUpdateFreq:"UpdateFreqMonth"`
- P83122 valueTypes.Float `json:"p83122" PointId:"p83122" PointUnitFrom:"FOO" PointUpdateFreq:"UpdateFreqMonth"`
+ P83121 valueTypes.Float `json:"p83121" PointId:"p83121" PointUpdateFreq:"UpdateFreqMonth"`
+ P83122 valueTypes.Float `json:"p83122" PointId:"p83122" PointUpdateFreq:"UpdateFreqMonth"`
ZfzyMap valueTypes.UnitValue `json:"zfzy_map"`
ZfzyMapVirgin valueTypes.UnitValue `json:"zfzy_map_virgin" PointIgnore:"true"`
ZjzzMap valueTypes.UnitValue `json:"zjzz_map"`
@@ -178,8 +178,8 @@ type YearData struct {
P83119MapVirgin valueTypes.UnitValue `json:"p83119_map_virgin" PointIgnore:"true"`
P83120 valueTypes.UnitValue `json:"p83120_map" PointId:"p83120" PointUpdateFreq:"UpdateFreqYear"`
P83120MapVirgin valueTypes.UnitValue `json:"p83120_map_virgin" PointIgnore:"true"`
- P83121 valueTypes.Float `json:"p83121" PointId:"p83121" PointUnitFrom:"FOO" PointUpdateFreq:"UpdateFreqYear"`
- P83122 valueTypes.Float `json:"p83122" PointId:"p83122" PointUnitFrom:"FOO" PointUpdateFreq:"UpdateFreqYear"`
+ P83121 valueTypes.Float `json:"p83121" PointId:"p83121" PointUpdateFreq:"UpdateFreqYear"`
+ P83122 valueTypes.Float `json:"p83122" PointId:"p83122" PointUpdateFreq:"UpdateFreqYear"`
ZfzyMap valueTypes.UnitValue `json:"zfzy_map"`
ZfzyMapVirgin valueTypes.UnitValue `json:"zfzy_map_virgin" PointIgnore:"true"`
ZjzzMap valueTypes.UnitValue `json:"zjzz_map"`
@@ -236,8 +236,8 @@ type TotalData struct {
P83123MapVirgin valueTypes.UnitValue `json:"p83123_map_virgin" PointIgnore:"true"`
P83124 valueTypes.UnitValue `json:"p83124_map" PointId:"p83124" PointUpdateFreq:"UpdateFreqTotal"`
P83124MapVirgin valueTypes.UnitValue `json:"p83124_map_virgin" PointIgnore:"true"`
- P83125 valueTypes.Float `json:"p83125" PointId:"p83125" PointUnitFrom:"FOO" PointUpdateFreq:"UpdateFreqTotal"`
- P83126 valueTypes.Float `json:"p83126" PointId:"p83126" PointUnitFrom:"FOO" PointUpdateFreq:"UpdateFreqTotal"`
+ P83125 valueTypes.Float `json:"p83125" PointId:"p83125" PointUpdateFreq:"UpdateFreqTotal"`
+ P83126 valueTypes.Float `json:"p83126" PointId:"p83126" PointUpdateFreq:"UpdateFreqTotal"`
P83127 valueTypes.UnitValue `json:"p83127_map" PointId:"p83127" PointUpdateFreq:"UpdateFreqTotal"`
P83127MapVirgin valueTypes.UnitValue `json:"p83127_map_virgin" PointIgnore:"true"`
ZfzyMap valueTypes.UnitValue `json:"zfzy_map"`
diff --git a/iSolarCloud/AppService/getIncomeSettingInfos/data.go b/iSolarCloud/AppService/getIncomeSettingInfos/data.go
index 5325ea4b1..8495745cd 100644
--- a/iSolarCloud/AppService/getIncomeSettingInfos/data.go
+++ b/iSolarCloud/AppService/getIncomeSettingInfos/data.go
@@ -75,7 +75,7 @@ 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, "", dt)
+ entries.StructToPoints(e.Response.ResultData, pkg, e.Request.PsId.String(), dt)
}
return entries
diff --git a/iSolarCloud/AppService/getPowerStationInfo/data.go b/iSolarCloud/AppService/getPowerStationInfo/data.go
index 1884f4760..a2d9bc059 100644
--- a/iSolarCloud/AppService/getPowerStationInfo/data.go
+++ b/iSolarCloud/AppService/getPowerStationInfo/data.go
@@ -128,7 +128,7 @@ func (e *EndPoint) GetData() api.DataMap {
pkg := apiReflect.GetName("", *e)
dt := valueTypes.NewDateTime(valueTypes.Now)
name := pkg + "." + e.Request.PsId.String()
- entries.StructToPoints(e.Response.ResultData, name, "", dt)
+ entries.StructToPoints(e.Response.ResultData, name, e.Request.PsId.String(), dt)
}
return entries
diff --git a/iSolarCloud/AppService/getPowerStatistics/data.go b/iSolarCloud/AppService/getPowerStatistics/data.go
index f3d897c33..897c116b0 100644
--- a/iSolarCloud/AppService/getPowerStatistics/data.go
+++ b/iSolarCloud/AppService/getPowerStatistics/data.go
@@ -57,7 +57,7 @@ func (e *EndPoint) GetData() api.DataMap {
pkg := apiReflect.GetName("", *e)
dt := valueTypes.NewDateTime(valueTypes.Now)
name := pkg + "." + e.Request.PsId.String()
- entries.StructToPoints(e.Response.ResultData, name, "", dt)
+ entries.StructToPoints(e.Response.ResultData, name, e.Request.PsId.String(), dt)
}
return entries
diff --git a/iSolarCloud/AppService/getPsDetail/data.go b/iSolarCloud/AppService/getPsDetail/data.go
index 2cb202668..b29750e40 100644
--- a/iSolarCloud/AppService/getPsDetail/data.go
+++ b/iSolarCloud/AppService/getPsDetail/data.go
@@ -54,15 +54,6 @@ type ResultData struct {
GprsLatitude valueTypes.Float `json:"gprs_latitude"`
GprsLongitude valueTypes.Float `json:"gprs_longitude"`
HasAmmeter valueTypes.Bool `json:"has_ammeter"`
- 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" PointName:"Images"`
- } `json:"images" PointName:"Images"`
InstallDate valueTypes.DateTime `json:"install_date"`
InstallerPsFaultStatus valueTypes.Integer `json:"installer_ps_fault_status"`
IsHaveEsInverter valueTypes.Bool `json:"is_have_es_inverter"`
@@ -182,16 +173,51 @@ type ResultData struct {
PsWindPos string `json:"ps_wind_pos"`
RecordCreateTime valueTypes.DateTime `json:"recore_create_time"`
ReportType string `json:"report_type"`
- RobotNumSweepCapacity struct {
- Num valueTypes.Integer `json:"num"`
- SweepCapacity valueTypes.Float `json:"sweep_capacity"`
- } `json:"robot_num_sweep_capacity"`
SafeStartDate valueTypes.DateTime `json:"safe_start_date"`
SelfConsumptionOffsetReminder valueTypes.Integer `json:"self_consumption_offset_reminder"`
ShippingAddress valueTypes.String `json:"shipping_address"`
ShippingZipCode valueTypes.String `json:"shipping_zip_code"`
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"`
+ 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"`
+ TodayIncome valueTypes.UnitValue `json:"today_income" PointId:"today_income" PointUpdateFreq:"UpdateFreqDay"`
+ TotalEnergy valueTypes.UnitValue `json:"total_energy" PointId:"total_energy" PointUpdateFreq:"UpdateFreqTotal"`
+ TotalEnergyVirgin valueTypes.UnitValue `json:"total_energy_virgin" PointIgnore:"true"`
+ TotalEnergyYear valueTypes.UnitValue `json:"total_energy_year" PointId:"total_energy_year" PointUpdateFreq:"UpdateFreqTotal"`
+ TotalIncome valueTypes.UnitValue `json:"total_income" PointId:"total_income" PointUpdateFreq:"UpdateFreqTotal"`
+ TreeReduce valueTypes.UnitValue `json:"tree_reduce"`
+ 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"`
+ 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"`
+ WgsLongitude valueTypes.Float `json:"wgs_longitude"`
+ Year valueTypes.Integer `json:"year"`
+ ZfzyMap valueTypes.UnitValue `json:"zfzy_map"`
+ ZfzyMapVirgin valueTypes.UnitValue `json:"zfzy_map_virgin" PointIgnore:"true"`
+ ZipCode valueTypes.String `json:"zip_code"`
+ ZjzzMap valueTypes.UnitValue `json:"zjzz_map"`
+ ZjzzMapVirgin valueTypes.UnitValue `json:"zjzz_map_virgin" PointIgnore:"true"`
+
+ RobotNumSweepCapacity struct {
+ Num valueTypes.Integer `json:"num"`
+ SweepCapacity valueTypes.Float `json:"sweep_capacity"`
+ } `json:"robot_num_sweep_capacity"`
+ 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" PointName:"Images"`
+ } `json:"images" PointName:"Images"`
StorageInverterData []struct {
CommunicationDevSn valueTypes.String `json:"communication_dev_sn"`
DevFaultStatus valueTypes.Integer `json:"dev_fault_status"`
@@ -203,7 +229,7 @@ type ResultData struct {
DeviceType valueTypes.Integer `json:"device_type"`
DrmStatus valueTypes.Integer `json:"drm_status"`
DrmStatusName valueTypes.String `json:"drm_status_name"`
- EnergyFlow []valueTypes.Integer `json:"energy_flow" PointName:"Energy Flow"`
+ EnergyFlow []valueTypes.Integer `json:"energy_flow" PointName:"Energy Flow" PointIgnoreZero:"false"`
HasAmmeter valueTypes.Bool `json:"has_ammeter"`
InstallerDevFaultStatus valueTypes.Integer `json:"installer_dev_fault_status"`
InverterSn valueTypes.String `json:"inverter_sn"`
@@ -231,31 +257,6 @@ type ResultData struct {
UpdateTime valueTypes.DateTime `json:"update_time"`
UUID valueTypes.Integer `json:"uuid"`
} `json:"storage_inverter_data" PointNameFromChild:"PsKey"`
- SysScheme valueTypes.Integer `json:"sys_scheme"`
- 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"`
- TodayIncome valueTypes.UnitValue `json:"today_income" PointId:"today_income" PointUpdateFreq:"UpdateFreqDay"`
- TotalEnergy valueTypes.UnitValue `json:"total_energy" PointId:"total_energy" PointUpdateFreq:"UpdateFreqTotal"`
- TotalEnergyVirgin valueTypes.UnitValue `json:"total_energy_virgin" PointIgnore:"true"`
- TotalEnergyYear valueTypes.UnitValue `json:"total_energy_year" PointId:"total_energy_year" PointUpdateFreq:"UpdateFreqTotal"`
- TotalIncome valueTypes.UnitValue `json:"total_income" PointId:"total_income" PointUpdateFreq:"UpdateFreqTotal"`
- TreeReduce valueTypes.UnitValue `json:"tree_reduce"`
- 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"`
- 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"`
- WgsLongitude valueTypes.Float `json:"wgs_longitude"`
- Year valueTypes.Integer `json:"year"`
- ZfzyMap valueTypes.UnitValue `json:"zfzy_map"`
- ZfzyMapVirgin valueTypes.UnitValue `json:"zfzy_map_virgin" PointIgnore:"true"`
- ZipCode valueTypes.String `json:"zip_code"`
- ZjzzMap valueTypes.UnitValue `json:"zjzz_map"`
- ZjzzMapVirgin valueTypes.UnitValue `json:"zjzz_map_virgin" PointIgnore:"true"`
}
func (e *ResultData) IsValid() error {
@@ -276,16 +277,49 @@ 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)
- // pkg := apiReflect.GetName("", *e)
- // name := api.JoinWithDots(0, valueTypes.DateTimeLayoutDay, pkg, e.Request.PsId)
- // entries.StructToPoints(e.Response.ResultData, name, e.Request.PsId.String(), valueTypes.NewDateTime(""))
+ // dstEndpoint := "virtual." + e.Request.PsId.String()
+ // srcEndpoint := fmt.Sprintf("%s.%s", pkg, e.Request.PsId.String())
//
- // for _, sid := range e.Response.ResultData.StorageInverterData {
- // name = api.JoinWithDots(0, valueTypes.DateTimeLayoutDay, pkg, sid.PsKey)
- // entries.StructToPoints(sid, name, sid.PsKey.Value(), valueTypes.NewDateTime(""))
- // }
+ // someting := entries.CopyPoint(srcEndpoint + ".p8301", dstEndpoint, "p8301", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83012", dstEndpoint, "p83012", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83013", dstEndpoint, "p83013", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83016", dstEndpoint, "p83016", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83017", dstEndpoint, "p83017", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p8302", dstEndpoint, "p8302", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83023", dstEndpoint, "p83023", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83036", dstEndpoint, "p83036", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p8304", dstEndpoint, "p8304", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83072", dstEndpoint, "p83072", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83073", dstEndpoint, "p83073", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83074", dstEndpoint, "p83074", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83075", dstEndpoint, "p83075", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83076", dstEndpoint, "p83076", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83077", dstEndpoint, "p83077", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83078", dstEndpoint, "p83078", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83079", dstEndpoint, "p83079", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83080", dstEndpoint, "p83080", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83088", dstEndpoint, "p83088", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83089", dstEndpoint, "p83089", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83094", dstEndpoint, "p83094", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83095", dstEndpoint, "p83095", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83097", dstEndpoint, "p83097", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83100", dstEndpoint, "p83100", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83101", dstEndpoint, "p83101", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83102", dstEndpoint, "p83102", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83105", dstEndpoint, "p83105", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83106", dstEndpoint, "p83106", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83107", dstEndpoint, "p83107", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83118", dstEndpoint, "p83118", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83119", dstEndpoint, "p83119", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p8312", dstEndpoint, "p8312", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83120", dstEndpoint, "p83120", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83123", dstEndpoint, "p83123", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83124", dstEndpoint, "p83124", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83128", dstEndpoint, "p83128", "")
+ // someting := entries.CopyPoint(srcEndpoint + ".p83202", dstEndpoint, "p83202", "")
}
return entries
diff --git a/iSolarCloud/AppService/getPsHealthState/data.go b/iSolarCloud/AppService/getPsHealthState/data.go
index 2deecc218..fd87ea6c0 100644
--- a/iSolarCloud/AppService/getPsHealthState/data.go
+++ b/iSolarCloud/AppService/getPsHealthState/data.go
@@ -48,7 +48,7 @@ func (e *EndPoint) GetData() api.DataMap {
pkg := apiReflect.GetName("", *e)
dt := valueTypes.NewDateTime(valueTypes.Now)
name := pkg + "." + e.Request.PsId.String()
- entries.StructToPoints(e.Response.ResultData, name, "", dt)
+ entries.StructToPoints(e.Response.ResultData, name, e.Request.PsId.String(), dt)
}
return entries
diff --git a/iSolarCloud/AppService/getPsWeatherList/data.go b/iSolarCloud/AppService/getPsWeatherList/data.go
index 7028685f1..9c6408470 100644
--- a/iSolarCloud/AppService/getPsWeatherList/data.go
+++ b/iSolarCloud/AppService/getPsWeatherList/data.go
@@ -29,21 +29,21 @@ type ResultData struct {
Chill valueTypes.Float `json:"chill"`
Code valueTypes.Float `json:"code"`
CodeName valueTypes.Float `json:"code_name"`
- DateTime valueTypes.DateTime `json:"date_time"`
+ DateTime valueTypes.DateTime `json:"date_time" PointIgnore:"true"`
Direction valueTypes.Float `json:"direction"`
- High valueTypes.Float `json:"high"`
- Highc valueTypes.Float `json:"highc"`
+ High valueTypes.Float `json:"high" PointUnit:"F"`
+ Highc valueTypes.Float `json:"highc" PointUnit:"C"`
Humidity valueTypes.Float `json:"humidity"`
- Low valueTypes.Float `json:"low"`
- Lowc valueTypes.Float `json:"lowc"`
- Pressure valueTypes.Float `json:"pressure"`
+ 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"`
Rising valueTypes.Float `json:"rising"`
Speed valueTypes.Float `json:"speed"`
- Sunrise valueTypes.Float `json:"sunrise"`
- Sunset valueTypes.Float `json:"sunset"`
+ Sunrise valueTypes.Time `json:"sunrise"`
+ Sunset valueTypes.Time `json:"sunset"`
Visibility valueTypes.Float `json:"visibility"`
- } `json:"weather_list"`
+ } `json:"weather_list" PointNameFromChild:"DateTime" PointNameDateFormat:"20060102"`
}
func (e *ResultData) IsValid() error {
@@ -61,11 +61,10 @@ func (e *EndPoint) GetData() api.DataMap {
entries := api.NewDataMap()
for range Only.Once {
- pkg := api.JoinWithDots(0, "", apiReflect.GetName("", *e), e.Request.PsId)
- // entries.StructToPoints(e.Response.ResultData, pkg, e.Request.PsId.String(), valueTypes.NewDateTime(""))
- for _, v := range e.Response.ResultData.WeatherList {
- entries.StructToPoints(v, api.JoinWithDots(0, valueTypes.DateTimeLayoutDay, pkg, v.DateTime), e.Request.PsId.String(), 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
diff --git a/iSolarCloud/AppService/getRemoteUpgradeTaskList/data.go b/iSolarCloud/AppService/getRemoteUpgradeTaskList/data.go
index 5319f5e04..506484cad 100644
--- a/iSolarCloud/AppService/getRemoteUpgradeTaskList/data.go
+++ b/iSolarCloud/AppService/getRemoteUpgradeTaskList/data.go
@@ -40,31 +40,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 {
pkg := apiReflect.GetName("", *e)
- entries.StructToPoints(e.Response.ResultData, pkg, "system", valueTypes.NewDateTime(""))
+ dt := valueTypes.NewDateTime(valueTypes.Now)
+ // name := pkg + "." + e.Request.PsId.String()
+ entries.StructToPoints(e.Response.ResultData, pkg, "system", dt)
}
return entries
diff --git a/iSolarCloud/AppService/getReportData/data.go b/iSolarCloud/AppService/getReportData/data.go
index df668a372..ee95d6ddc 100644
--- a/iSolarCloud/AppService/getReportData/data.go
+++ b/iSolarCloud/AppService/getReportData/data.go
@@ -26,7 +26,7 @@ func (rd RequestData) Help() string {
}
type ResultData struct {
- DataList []DataList `json:"dataList"`
+ DataList []DataList `json:"dataList" PointId:"data_list" PointIgnoreIfNilFromChild:"UpdateTime" PointNameFromChild:"DateId" PointNameDateFormat:"20060102" PointNameFromAppend:"true"`
Info []struct {
DesignCapacity valueTypes.Float `json:"design_capacity" PointUnit:"W"`
InstallerPsFaultStatus valueTypes.Integer `json:"installer_ps_fault_status"`
@@ -42,145 +42,145 @@ type ResultData struct {
ValidFlag valueTypes.Bool `json:"valid_flag"`
} `json:"info"`
MinDateID interface{} `json:"min_date_id"`
- Total []DataList `json:"total"`
+ 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"`
+ DeviceName interface{} `json:"device_name"`
PsId valueTypes.Integer `json:"ps_id"`
- TimeStamp interface{} `json:"time_stamp"` // Sad that this alternates between string and valueTypes.Integer.
+ TimeStamp interface{} `json:"time_stamp"` // Sad that this alternates between string and valueTypes.Integer.
UpdateTime valueTypes.DateTime `json:"update_time"`
- UUID interface{} `json:"uuid"`
+ UUID interface{} `json:"uuid"`
Co2Reduce valueTypes.Float `json:"co2_reduce"`
- CitySubsidyCharge valueTypes.Float `json:"city_subsidy_charge" PointUnitFrom:"city_subsidy_charge_original_unit"`
- CitySubsidyChargeOriginalUnit string `json:"city_subsidy_charge_original_unit"`
- CitySubsidyChargeTran valueTypes.Float `json:"city_subsidy_charge_tran" PointUnitFrom:"city_subsidy_charge_unit" PointIgnore:"true"`
- CitySubsidyChargeUnit string `json:"city_subsidy_charge_unit" PointIgnore:"true"`
+ CitySubsidyCharge valueTypes.Float `json:"city_subsidy_charge" PointUnitFrom:"CitySubsidyChargeOriginalUnit"`
+ CitySubsidyChargeOriginalUnit valueTypes.String `json:"city_subsidy_charge_original_unit" PointIgnore:"true"`
+ CitySubsidyChargeTran valueTypes.Float `json:"city_subsidy_charge_tran" PointUnitFrom:"CitySubsidyChargeUnit" PointIgnore:"true"`
+ CitySubsidyChargeUnit valueTypes.String `json:"city_subsidy_charge_unit" PointIgnore:"true"`
- CountrySubsidyCharge valueTypes.Float `json:"country_subsidy_charge" PointUnitFrom:"country_subsidy_charge_original_unit"`
- CountrySubsidyChargeOriginalUnit string `json:"country_subsidy_charge_original_unit"`
- CountrySubsidyChargeTran valueTypes.Float `json:"country_subsidy_charge_tran" PointUnitFrom:"country_subsidy_charge_unit" PointIgnore:"true"`
- CountrySubsidyChargeUnit string `json:"country_subsidy_charge_unit" PointIgnore:"true"`
+ CountrySubsidyCharge valueTypes.Float `json:"country_subsidy_charge" PointUnitFrom:"CountrySubsidyChargeOriginalUnit"`
+ CountrySubsidyChargeOriginalUnit valueTypes.String `json:"country_subsidy_charge_original_unit" PointIgnore:"true"`
+ CountrySubsidyChargeTran valueTypes.Float `json:"country_subsidy_charge_tran" PointUnitFrom:"CountrySubsidyChargeUnit" PointIgnore:"true"`
+ CountrySubsidyChargeUnit valueTypes.String `json:"country_subsidy_charge_unit" PointIgnore:"true"`
- CountySubsidyCharge valueTypes.Float `json:"county_subsidy_charge" PointUnitFrom:"county_subsidy_charge_original_unit"`
- CountySubsidyChargeOriginalUnit string `json:"county_subsidy_charge_original_unit"`
- CountySubsidyChargeTran valueTypes.Float `json:"county_subsidy_charge_tran" PointUnitFrom:"county_subsidy_charge_unit" PointIgnore:"true"`
- CountySubsidyChargeUnit string `json:"county_subsidy_charge_unit" PointIgnore:"true"`
+ CountySubsidyCharge valueTypes.Float `json:"county_subsidy_charge" PointUnitFrom:"CountySubsidyChargeOriginalUnit"`
+ CountySubsidyChargeOriginalUnit valueTypes.String `json:"county_subsidy_charge_original_unit" PointIgnore:"true"`
+ CountySubsidyChargeTran valueTypes.Float `json:"county_subsidy_charge_tran" PointUnitFrom:"CountySubsidyChargeUnit" PointIgnore:"true"`
+ CountySubsidyChargeUnit valueTypes.String `json:"county_subsidy_charge_unit" PointIgnore:"true"`
- CuspCharge valueTypes.Float `json:"cusp_charge" PointUnitFrom:"cusp_charge_original_unit"`
- CuspChargeOriginalUnit string `json:"cusp_charge_original_unit"`
- CuspChargeTran valueTypes.Float `json:"cusp_charge_tran" PointUnitFrom:"cusp_charge_unit" PointIgnore:"true"`
- CuspChargeUnit string `json:"cusp_charge_unit" PointIgnore:"true"`
+ CuspCharge valueTypes.Float `json:"cusp_charge" PointUnitFrom:"CuspChargeOriginalUnit"`
+ CuspChargeOriginalUnit valueTypes.String `json:"cusp_charge_original_unit" PointIgnore:"true"`
+ CuspChargeTran valueTypes.Float `json:"cusp_charge_tran" PointUnitFrom:"CuspChargeUnit" PointIgnore:"true"`
+ CuspChargeUnit valueTypes.String `json:"cusp_charge_unit" PointIgnore:"true"`
- CuspNetPowerQuantity valueTypes.Float `json:"cusp_net_power_quantity" PointUnitFrom:"cusp_net_power_quantity_unit"`
- CuspNetPowerQuantityTran valueTypes.Float `json:"cusp_net_power_quantity_tran" PointUnitFrom:"cusp_net_power_quantity_unit" PointIgnore:"true"`
- CuspNetPowerQuantityUnit string `json:"cusp_net_power_quantity_unit"`
+ CuspNetPowerQuantity valueTypes.Float `json:"cusp_net_power_quantity" PointUnitFrom:"CuspNetPowerQuantityUnit"`
+ CuspNetPowerQuantityTran valueTypes.Float `json:"cusp_net_power_quantity_tran" PointUnitFrom:"CuspNetPowerQuantityUnit" PointIgnore:"true"`
+ CuspNetPowerQuantityUnit valueTypes.String `json:"cusp_net_power_quantity_unit" PointIgnore:"true"`
- CuspPowerQuantity valueTypes.Float `json:"cusp_power_quantity" PointUnitFrom:"cusp_power_quantity_unit"`
- CuspPowerQuantityTran valueTypes.Float `json:"cusp_power_quantity_tran" PointUnitFrom:"cusp_power_quantity_unit" PointIgnore:"true"`
- CuspPowerQuantityUnit string `json:"cusp_power_quantity_unit"`
+ CuspPowerQuantity valueTypes.Float `json:"cusp_power_quantity" PointUnitFrom:"CuspPowerQuantityUnit"`
+ CuspPowerQuantityTran valueTypes.Float `json:"cusp_power_quantity_tran" PointUnitFrom:"CuspPowerQuantityUnit" PointIgnore:"true"`
+ CuspPowerQuantityUnit valueTypes.String `json:"cusp_power_quantity_unit" PointIgnore:"true"`
- CuspUsePowerQuantity valueTypes.Float `json:"cusp_use_power_quantity" PointUnitFrom:"cusp_use_power_quantity_unit"`
- CuspUsePowerQuantityTran valueTypes.Float `json:"cusp_use_power_quantity_tran" PointUnitFrom:"cusp_use_power_quantity_unit" PointIgnore:"true"`
- CuspUsePowerQuantityUnit string `json:"cusp_use_power_quantity_unit"`
+ CuspUsePowerQuantity valueTypes.Float `json:"cusp_use_power_quantity" PointUnitFrom:"CuspUsePowerQuantityUnit"`
+ CuspUsePowerQuantityTran valueTypes.Float `json:"cusp_use_power_quantity_tran" PointUnitFrom:"CuspUsePowerQuantityUnit" PointIgnore:"true"`
+ CuspUsePowerQuantityUnit valueTypes.String `json:"cusp_use_power_quantity_unit" PointIgnore:"true"`
- FlatCharge valueTypes.Float `json:"flat_charge" PointUnitFrom:"flat_charge_original_unit"`
- FlatChargeOriginalUnit string `json:"flat_charge_original_unit"`
+ FlatCharge valueTypes.Float `json:"flat_charge" PointUnitFrom:"FlatChargeOriginalUnit"`
+ FlatChargeOriginalUnit valueTypes.String `json:"flat_charge_original_unit" PointIgnore:"true"`
- FlatChargeTran valueTypes.Float `json:"flat_charge_tran" PointUnitFrom:"flat_charge_unit"`
- FlatChargeUnit string `json:"flat_charge_unit"`
+ FlatChargeTran valueTypes.Float `json:"flat_charge_tran" PointUnitFrom:"FlatChargeUnit"`
+ FlatChargeUnit valueTypes.String `json:"flat_charge_unit" PointIgnore:"true"`
- FlatNetPowerQuantity valueTypes.Float `json:"flat_net_power_quantity" PointUnitFrom:"flat_net_power_quantity_unit"`
- FlatNetPowerQuantityTran valueTypes.Float `json:"flat_net_power_quantity_tran" PointUnitFrom:"flat_net_power_quantity_unit" PointIgnore:"true"`
- FlatNetPowerQuantityUnit string `json:"flat_net_power_quantity_unit"`
+ FlatNetPowerQuantity valueTypes.Float `json:"flat_net_power_quantity" PointUnitFrom:"FlatNetPowerQuantityUnit"`
+ FlatNetPowerQuantityTran valueTypes.Float `json:"flat_net_power_quantity_tran" PointUnitFrom:"FlatNetPowerQuantityUnit" PointIgnore:"true"`
+ FlatNetPowerQuantityUnit valueTypes.String `json:"flat_net_power_quantity_unit" PointIgnore:"true"`
- FlatPowerQuantity valueTypes.Float `json:"flat_power_quantity" PointUnitFrom:"flat_power_quantity_unit"`
- FlatPowerQuantityTran valueTypes.Float `json:"flat_power_quantity_tran" PointUnitFrom:"flat_power_quantity_unit" PointIgnore:"true"`
- FlatPowerQuantityUnit string `json:"flat_power_quantity_unit"`
+ FlatPowerQuantity valueTypes.Float `json:"flat_power_quantity" PointUnitFrom:"FlatPowerQuantityUnit"`
+ FlatPowerQuantityTran valueTypes.Float `json:"flat_power_quantity_tran" PointUnitFrom:"FlatPowerQuantityUnit" PointIgnore:"true"`
+ FlatPowerQuantityUnit valueTypes.String `json:"flat_power_quantity_unit" PointIgnore:"true"`
- FlatUsePowerQuantity valueTypes.Float `json:"flat_use_power_quantity" PointUnitFrom:"flat_use_power_quantity_unit"`
- FlatUsePowerQuantityTran valueTypes.Float `json:"flat_use_power_quantity_tran" PointUnitFrom:"flat_use_power_quantity_unit" PointIgnore:"true"`
- FlatUsePowerQuantityUnit string `json:"flat_use_power_quantity_unit"`
+ FlatUsePowerQuantity valueTypes.Float `json:"flat_use_power_quantity" PointUnitFrom:"FlatUsePowerQuantityUnit"`
+ FlatUsePowerQuantityTran valueTypes.Float `json:"flat_use_power_quantity_tran" PointUnitFrom:"FlatUsePowerQuantityUnit" PointIgnore:"true"`
+ FlatUsePowerQuantityUnit valueTypes.String `json:"flat_use_power_quantity_unit" PointIgnore:"true"`
- NetPowerProfit valueTypes.Float `json:"net_power_profit" PointUnitFrom:"net_power_profit_original_unit"`
- NetPowerProfitOriginalUnit string `json:"net_power_profit_original_unit"`
- NetPowerProfitTran valueTypes.Float `json:"net_power_profit_tran" PointUnitFrom:"net_power_profit_unit" PointIgnore:"true"`
- NetPowerProfitUnit string `json:"net_power_profit_unit" PointIgnore:"true"`
+ NetPowerProfit valueTypes.Float `json:"net_power_profit" PointUnitFrom:"NetPowerProfitOriginalUnit"`
+ NetPowerProfitOriginalUnit valueTypes.String `json:"net_power_profit_original_unit" PointIgnore:"true"`
+ NetPowerProfitTran valueTypes.Float `json:"net_power_profit_tran" PointUnitFrom:"NetPowerProfitUnit" PointIgnore:"true"`
+ NetPowerProfitUnit valueTypes.String `json:"net_power_profit_unit" PointIgnore:"true"`
- NetPowerQuantityTotal valueTypes.Float `json:"net_power_quantity_total" PointUnitFrom:"net_power_quantity_total_unit"`
- NetPowerQuantityTotalTran valueTypes.Float `json:"net_power_quantity_total_tran" PointUnitFrom:"net_power_quantity_total_unit" PointIgnore:"true"`
- NetPowerQuantityTotalUnit string `json:"net_power_quantity_total_unit"`
+ NetPowerQuantityTotal valueTypes.Float `json:"net_power_quantity_total" PointUnitFrom:"NetPowerQuantityTotalUnit"`
+ NetPowerQuantityTotalTran valueTypes.Float `json:"net_power_quantity_total_tran" PointUnitFrom:"NetPowerQuantityTotalUnit" PointIgnore:"true"`
+ NetPowerQuantityTotalUnit valueTypes.String `json:"net_power_quantity_total_unit" PointIgnore:"true"`
- PeakCharge valueTypes.Float `json:"peak_charge" PointUnitFrom:"peak_charge_original_unit"`
- PeakChargeOriginalUnit string `json:"peak_charge_original_unit"`
+ PeakCharge valueTypes.Float `json:"peak_charge" PointUnitFrom:"PeakChargeOriginalUnit"`
+ PeakChargeOriginalUnit valueTypes.String `json:"peak_charge_original_unit" PointIgnore:"true"`
- PeakChargeTran valueTypes.Float `json:"peak_charge_tran" PointUnitFrom:"peak_charge_unit"`
- PeakChargeUnit string `json:"peak_charge_unit"`
+ PeakChargeTran valueTypes.Float `json:"peak_charge_tran" PointUnitFrom:"PeakChargeUnit"`
+ PeakChargeUnit valueTypes.String `json:"peak_charge_unit" PointIgnore:"true"`
- PeakNetPowerQuantity valueTypes.Float `json:"peak_net_power_quantity" PointUnitFrom:"peak_net_power_quantity_unit"`
- PeakNetPowerQuantityTran valueTypes.Float `json:"peak_net_power_quantity_tran" PointUnitFrom:"peak_net_power_quantity_unit" PointIgnore:"true"`
- PeakNetPowerQuantityUnit string `json:"peak_net_power_quantity_unit"`
+ PeakNetPowerQuantity valueTypes.Float `json:"peak_net_power_quantity" PointUnitFrom:"PeakNetPowerQuantityUnit"`
+ PeakNetPowerQuantityTran valueTypes.Float `json:"peak_net_power_quantity_tran" PointUnitFrom:"PeakNetPowerQuantityUnit" PointIgnore:"true"`
+ PeakNetPowerQuantityUnit valueTypes.String `json:"peak_net_power_quantity_unit" PointIgnore:"true"`
- PeakPowerQuantity valueTypes.Float `json:"peak_power_quantity" PointUnitFrom:"peak_power_quantity_unit"`
- PeakPowerQuantityTran valueTypes.Float `json:"peak_power_quantity_tran" PointUnitFrom:"peak_power_quantity_unit" PointIgnore:"true"`
- PeakPowerQuantityUnit string `json:"peak_power_quantity_unit"`
+ PeakPowerQuantity valueTypes.Float `json:"peak_power_quantity" PointUnitFrom:"PeakPowerQuantityUnit"`
+ PeakPowerQuantityTran valueTypes.Float `json:"peak_power_quantity_tran" PointUnitFrom:"PeakPowerQuantityUnit" PointIgnore:"true"`
+ PeakPowerQuantityUnit valueTypes.String `json:"peak_power_quantity_unit" PointIgnore:"true"`
- PeakUsePowerQuantity valueTypes.Float `json:"peak_use_power_quantity" PointUnitFrom:"peak_use_power_quantity_unit"`
- PeakUsePowerQuantityTran valueTypes.Float `json:"peak_use_power_quantity_tran" PointUnitFrom:"peak_use_power_quantity_unit" PointIgnore:"true"`
- PeakUsePowerQuantityUnit string `json:"peak_use_power_quantity_unit"`
+ PeakUsePowerQuantity valueTypes.Float `json:"peak_use_power_quantity" PointUnitFrom:"PeakUsePowerQuantityUnit"`
+ PeakUsePowerQuantityTran valueTypes.Float `json:"peak_use_power_quantity_tran" PointUnitFrom:"PeakUsePowerQuantityUnit" PointIgnore:"true"`
+ PeakUsePowerQuantityUnit valueTypes.String `json:"peak_use_power_quantity_unit" PointIgnore:"true"`
- PowerQuantityTotal valueTypes.Float `json:"power_quantity_total" PointUnitFrom:"power_quantity_total_unit"`
- PowerQuantityTotalTran valueTypes.Float `json:"power_quantity_total_tran" PointUnitFrom:"power_quantity_total_unit" PointIgnore:"true"`
- PowerQuantityTotalUnit string `json:"power_quantity_total_unit"`
+ PowerQuantityTotal valueTypes.Float `json:"power_quantity_total" PointUnitFrom:"PowerQuantityTotalUnit"`
+ PowerQuantityTotalTran valueTypes.Float `json:"power_quantity_total_tran" PointUnitFrom:"PowerQuantityTotalUnit" PointIgnore:"true"`
+ PowerQuantityTotalUnit valueTypes.String `json:"power_quantity_total_unit" PointIgnore:"true"`
- ProvinceSubsidyCharge valueTypes.Float `json:"province_subsidy_charge" PointUnitFrom:"province_subsidy_charge_original_unit"`
- ProvinceSubsidyChargeOriginalUnit string `json:"province_subsidy_charge_original_unit"`
+ ProvinceSubsidyCharge valueTypes.Float `json:"province_subsidy_charge" PointUnitFrom:"ProvinceSubsidyChargeOriginalUnit"`
+ ProvinceSubsidyChargeOriginalUnit valueTypes.String `json:"province_subsidy_charge_original_unit" PointIgnore:"true"`
- ProvinceSubsidyChargeTran valueTypes.Float `json:"province_subsidy_charge_tran" PointUnitFrom:"province_subsidy_charge_unit"`
- ProvinceSubsidyChargeUnit string `json:"province_subsidy_charge_unit"`
+ ProvinceSubsidyChargeTran valueTypes.Float `json:"province_subsidy_charge_tran" PointUnitFrom:"ProvinceSubsidyChargeUnit"`
+ ProvinceSubsidyChargeUnit valueTypes.String `json:"province_subsidy_charge_unit" PointIgnore:"true"`
- SubsidyProfit valueTypes.Float `json:"subsidy_profit" PointUnitFrom:"subsidy_profit_original_unit"`
- SubsidyProfitOriginalUnit string `json:"subsidy_profit_original_unit"`
+ SubsidyProfit valueTypes.Float `json:"subsidy_profit" PointUnitFrom:"SubsidyProfitOriginalUnit"`
+ SubsidyProfitOriginalUnit valueTypes.String `json:"subsidy_profit_original_unit" PointIgnore:"true"`
- SubsidyProfitTran valueTypes.Float `json:"subsidy_profit_tran" PointUnitFrom:"subsidy_profit_unit"`
- SubsidyProfitUnit string `json:"subsidy_profit_unit"`
+ SubsidyProfitTran valueTypes.Float `json:"subsidy_profit_tran" PointUnitFrom:"SubsidyProfitUnit"`
+ SubsidyProfitUnit valueTypes.String `json:"subsidy_profit_unit" PointIgnore:"true"`
- TotalProfit valueTypes.Float `json:"total_profit" PointUnitFrom:"total_profit_original_unit"`
- TotalProfitOriginalUnit string `json:"total_profit_original_unit"`
- TotalProfitTran valueTypes.Float `json:"total_profit_tran" PointUnitFrom:"total_profit_unit" PointIgnore:"true"`
- TotalProfitUnit string `json:"total_profit_unit" PointIgnore:"true"`
+ TotalProfit valueTypes.Float `json:"total_profit" PointUnitFrom:"TotalProfitOriginalUnit"`
+ TotalProfitOriginalUnit valueTypes.String `json:"total_profit_original_unit" PointIgnore:"true"`
+ TotalProfitTran valueTypes.Float `json:"total_profit_tran" PointUnitFrom:"TotalProfitUnit" PointIgnore:"true"`
+ TotalProfitUnit valueTypes.String `json:"total_profit_unit" PointIgnore:"true"`
- UsePowerByDiscountProfit valueTypes.Float `json:"use_power_by_discount_profit" PointUnitFrom:"use_power_by_discount_profit_original_unit"`
- UsePowerByDiscountProfitOriginalUnit string `json:"use_power_by_discount_profit_original_unit"`
- UsePowerByDiscountProfitTran valueTypes.Float `json:"use_power_by_discount_profit_tran" PointUnitFrom:"use_power_by_discount_profit_unit" PointIgnore:"true"`
- UsePowerByDiscountProfitUnit string `json:"use_power_by_discount_profit_unit" PointIgnore:"true"`
+ UsePowerByDiscountProfit valueTypes.Float `json:"use_power_by_discount_profit" PointUnitFrom:"UsePowerByDiscountProfitOriginalUnit"`
+ UsePowerByDiscountProfitOriginalUnit valueTypes.String `json:"use_power_by_discount_profit_original_unit" PointIgnore:"true"`
+ UsePowerByDiscountProfitTran valueTypes.Float `json:"use_power_by_discount_profit_tran" PointUnitFrom:"UsePowerByDiscountProfitUnit" PointIgnore:"true"`
+ UsePowerByDiscountProfitUnit valueTypes.String `json:"use_power_by_discount_profit_unit" PointIgnore:"true"`
- UsePowerProfit valueTypes.Float `json:"use_power_profit" PointUnitFrom:"use_power_profit_original_unit"`
- UsePowerProfitOriginalUnit string `json:"use_power_profit_original_unit"`
- UsePowerProfitTran valueTypes.Float `json:"use_power_profit_tran" PointUnitFrom:"use_power_profit_unit" PointIgnore:"true"`
- UsePowerProfitUnit string `json:"use_power_profit_unit" PointIgnore:"true"`
+ UsePowerProfit valueTypes.Float `json:"use_power_profit" PointUnitFrom:"UsePowerProfitOriginalUnit"`
+ UsePowerProfitOriginalUnit valueTypes.String `json:"use_power_profit_original_unit" PointIgnore:"true"`
+ UsePowerProfitTran valueTypes.Float `json:"use_power_profit_tran" PointUnitFrom:"UsePowerProfitUnit" PointIgnore:"true"`
+ UsePowerProfitUnit valueTypes.String `json:"use_power_profit_unit" PointIgnore:"true"`
- UsePowerQuantityTotal valueTypes.Float `json:"use_power_quantity_total" PointUnitFrom:"use_power_quantity_total_unit"`
- UsePowerQuantityTotalTran valueTypes.Float `json:"use_power_quantity_total_tran" PointUnitFrom:"use_power_quantity_total_unit" PointIgnore:"true"`
- UsePowerQuantityTotalUnit string `json:"use_power_quantity_total_unit"`
+ UsePowerQuantityTotal valueTypes.Float `json:"use_power_quantity_total" PointUnitFrom:"UsePowerQuantityTotalUnit"`
+ UsePowerQuantityTotalTran valueTypes.Float `json:"use_power_quantity_total_tran" PointUnitFrom:"UsePowerQuantityTotalUnit" PointIgnore:"true"`
+ UsePowerQuantityTotalUnit valueTypes.String `json:"use_power_quantity_total_unit" PointIgnore:"true"`
- ValleyCharge valueTypes.Float `json:"valley_charge" PointUnitFrom:"valley_charge_original_unit"`
- ValleyChargeOriginalUnit string `json:"valley_charge_original_unit"`
- ValleyChargeTran valueTypes.Float `json:"valley_charge_tran" PointUnitFrom:"valley_charge_unit" PointIgnore:"true"`
- ValleyChargeUnit string `json:"valley_charge_unit" PointIgnore:"true"`
+ ValleyCharge valueTypes.Float `json:"valley_charge" PointUnitFrom:"ValleyChargeOriginalUnit"`
+ ValleyChargeOriginalUnit valueTypes.String `json:"valley_charge_original_unit" PointIgnore:"true"`
+ ValleyChargeTran valueTypes.Float `json:"valley_charge_tran" PointUnitFrom:"ValleyChargeUnit" PointIgnore:"true"`
+ ValleyChargeUnit valueTypes.String `json:"valley_charge_unit" PointIgnore:"true"`
- ValleyNetPowerQuantity valueTypes.Float `json:"valley_net_power_quantity" PointUnitFrom:"valley_net_power_quantity_unit"`
- ValleyNetPowerQuantityTran valueTypes.Float `json:"valley_net_power_quantity_tran" PointUnitFrom:"valley_net_power_quantity_unit" PointIgnore:"true"`
- ValleyNetPowerQuantityUnit string `json:"valley_net_power_quantity_unit"`
+ ValleyNetPowerQuantity valueTypes.Float `json:"valley_net_power_quantity" PointUnitFrom:"ValleyNetPowerQuantityUnit"`
+ ValleyNetPowerQuantityTran valueTypes.Float `json:"valley_net_power_quantity_tran" PointUnitFrom:"ValleyNetPowerQuantityUnit" PointIgnore:"true"`
+ ValleyNetPowerQuantityUnit valueTypes.String `json:"valley_net_power_quantity_unit" PointIgnore:"true"`
- ValleyPowerQuantity valueTypes.Float `json:"valley_power_quantity" PointUnitFrom:"valley_power_quantity_unit"`
- ValleyPowerQuantityTran valueTypes.Float `json:"valley_power_quantity_tran" PointUnitFrom:"valley_power_quantity_unit" PointIgnore:"true"`
- ValleyPowerQuantityUnit string `json:"valley_power_quantity_unit"`
+ ValleyPowerQuantity valueTypes.Float `json:"valley_power_quantity" PointUnitFrom:"ValleyPowerQuantityUnit"`
+ ValleyPowerQuantityTran valueTypes.Float `json:"valley_power_quantity_tran" PointUnitFrom:"ValleyPowerQuantityUnit" PointIgnore:"true"`
+ ValleyPowerQuantityUnit valueTypes.String `json:"valley_power_quantity_unit" PointIgnore:"true"`
- ValleyUsePowerQuantity valueTypes.Float `json:"valley_use_power_quantity" PointUnitFrom:"valley_use_power_quantity_unit"`
- ValleyUsePowerQuantityTran valueTypes.Float `json:"valley_use_power_quantity_tran" PointUnitFrom:"valley_use_power_quantity_unit" PointIgnore:"true"`
- ValleyUsePowerQuantityUnit string `json:"valley_use_power_quantity_unit"`
+ ValleyUsePowerQuantity valueTypes.Float `json:"valley_use_power_quantity" PointUnitFrom:"ValleyUsePowerQuantityUnit"`
+ ValleyUsePowerQuantityTran valueTypes.Float `json:"valley_use_power_quantity_tran" PointUnitFrom:"ValleyUsePowerQuantityUnit" PointIgnore:"true"`
+ ValleyUsePowerQuantityUnit valueTypes.String `json:"valley_use_power_quantity_unit" PointIgnore:"true"`
}
func (e *ResultData) IsValid() error {
@@ -194,46 +194,32 @@ 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 {
pkg := apiReflect.GetName("", *e)
- entries.StructToPoints(e.Response.ResultData, pkg, e.Request.PsId.String(), valueTypes.NewDateTime(""))
-
- s := valueTypes.SizeOfArrayLength(e.Response.ResultData.DataList)
- for _, v := range e.Response.ResultData.DataList {
- entries.StructToPoints(v, api.JoinWithDots(s, valueTypes.DateTimeLayoutDay, pkg, "DataList", v.PsId, v.DateId), v.PsId.String(), valueTypes.NewDateTime(""))
- }
-
- s = valueTypes.SizeOfArrayLength(e.Response.ResultData.Info)
- for i, v := range e.Response.ResultData.Info {
- entries.StructToPoints(v, api.JoinWithDots(s, valueTypes.DateTimeLayoutDay, pkg, "Info", v.PsId, i), v.PsId.String(), valueTypes.NewDateTime(""))
- }
-
- s = valueTypes.SizeOfArrayLength(e.Response.ResultData.Total)
- for i, v := range e.Response.ResultData.Total {
- entries.StructToPoints(v, api.JoinWithDots(s, valueTypes.DateTimeLayoutDay, pkg, "Total", v.PsId, i), v.PsId.String(), valueTypes.NewDateTime(""))
- }
+ dt := valueTypes.NewDateTime(valueTypes.Now)
+ name := pkg + "." + e.Request.PsId.String()
+ entries.StructToPoints(e.Response.ResultData, name, e.Request.PsId.String(), dt)
+
+ // pkg := apiReflect.GetName("", *e)
+ // entries.StructToPoints(e.Response.ResultData, pkg, e.Request.PsId.String(), valueTypes.NewDateTime(""))
+ //
+ // s := valueTypes.SizeOfArrayLength(e.Response.ResultData.DataList)
+ // for _, v := range e.Response.ResultData.DataList {
+ // entries.StructToPoints(v, api.JoinWithDots(s, valueTypes.DateTimeLayoutDay, pkg, "DataList", v.PsId, v.DateId), v.PsId.String(), valueTypes.NewDateTime(""))
+ // }
+ //
+ // s = valueTypes.SizeOfArrayLength(e.Response.ResultData.Info)
+ // for i, v := range e.Response.ResultData.Info {
+ // entries.StructToPoints(v, api.JoinWithDots(s, valueTypes.DateTimeLayoutDay, pkg, "Info", v.PsId, i), v.PsId.String(), valueTypes.NewDateTime(""))
+ // }
+ //
+ // s = valueTypes.SizeOfArrayLength(e.Response.ResultData.Total)
+ // for i, v := range e.Response.ResultData.Total {
+ // entries.StructToPoints(v, api.JoinWithDots(s, valueTypes.DateTimeLayoutDay, pkg, "Total", v.PsId, i), v.PsId.String(), valueTypes.NewDateTime(""))
+ // }
}
return entries
diff --git a/iSolarCloud/AppService/queryDeviceInfo/data.go b/iSolarCloud/AppService/queryDeviceInfo/data.go
index a88270be9..1d8674d61 100644
--- a/iSolarCloud/AppService/queryDeviceInfo/data.go
+++ b/iSolarCloud/AppService/queryDeviceInfo/data.go
@@ -135,9 +135,8 @@ func (e *EndPoint) GetData() api.DataMap {
for range Only.Once {
pkg := apiReflect.GetName("", *e)
dt := valueTypes.NewDateTime(valueTypes.Now)
+ // name := pkg + "." + e.Request.PsId.String()
entries.StructToPoints(e.Response.ResultData, pkg, "", dt)
-
- // entries.StructToPoints(e.Response.ResultData, apiReflect.GetName("", *e), "system", valueTypes.NewDateTime(""))
}
return entries
diff --git a/iSolarCloud/AppService/queryDeviceListForApp/data.go b/iSolarCloud/AppService/queryDeviceListForApp/data.go
index a8fac21b7..bdb0471aa 100644
--- a/iSolarCloud/AppService/queryDeviceListForApp/data.go
+++ b/iSolarCloud/AppService/queryDeviceListForApp/data.go
@@ -92,7 +92,7 @@ func (e *EndPoint) GetData() api.DataMap {
pkg := apiReflect.GetName("", *e)
dt := valueTypes.NewDateTime(valueTypes.Now)
// name := pkg + "." + e.Request.PsId.String()
- entries.StructToPoints(e.Response.ResultData, pkg, "", dt)
+ entries.StructToPoints(e.Response.ResultData, pkg, e.Request.PsId.String(), dt)
}
return entries
diff --git a/iSolarCloud/AppService/reportList/data.go b/iSolarCloud/AppService/reportList/data.go
index 10cad1529..eb6b3f787 100644
--- a/iSolarCloud/AppService/reportList/data.go
+++ b/iSolarCloud/AppService/reportList/data.go
@@ -28,7 +28,7 @@ func (rd RequestData) Help() string {
}
type ResultData struct {
- DataList []DataList `json:"dataList"`
+ DataList []DataList `json:"dataList" PointId:"data_list" PointIgnoreIfNilFromChild:"UpdateTime" PointNameFromChild:"DateId" PointNameDateFormat:"20060102" PointNameFromAppend:"true"`
Info []struct {
DesignCapacity valueTypes.Float `json:"design_capacity" PointUnit:"W"`
InstallerPsFaultStatus valueTypes.Integer `json:"installer_ps_fault_status"`
@@ -44,145 +44,146 @@ type ResultData struct {
ValidFlag valueTypes.Bool `json:"valid_flag"`
} `json:"info"`
MinDateID interface{} `json:"min_date_id"`
- Total []DataList `json:"total"`
+ 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"`
+ DeviceName interface{} `json:"device_name"`
PsId valueTypes.Integer `json:"ps_id"`
- TimeStamp interface{} `json:"time_stamp"` // Sad that this alternates between string and valueTypes.Integer.
+ TimeStamp interface{} `json:"time_stamp"` // Sad that this alternates between string and valueTypes.Integer.
UpdateTime valueTypes.DateTime `json:"update_time"`
- UUID interface{} `json:"uuid"`
+ UUID interface{} `json:"uuid"`
Co2Reduce valueTypes.Float `json:"co2_reduce"`
- CitySubsidyCharge valueTypes.Float `json:"city_subsidy_charge" PointUnitFrom:"city_subsidy_charge_original_unit"`
- CitySubsidyChargeOriginalUnit string `json:"city_subsidy_charge_original_unit"`
- CitySubsidyChargeTran valueTypes.Float `json:"city_subsidy_charge_tran" PointUnitFrom:"city_subsidy_charge_unit" PointIgnore:"true"`
- CitySubsidyChargeUnit string `json:"city_subsidy_charge_unit" PointIgnore:"true"`
+ CitySubsidyCharge valueTypes.Float `json:"city_subsidy_charge" PointUnitFrom:"CitySubsidyChargeOriginalUnit"`
+ CitySubsidyChargeOriginalUnit valueTypes.String `json:"city_subsidy_charge_original_unit" PointIgnore:"true"`
+ CitySubsidyChargeTran valueTypes.Float `json:"city_subsidy_charge_tran" PointUnitFrom:"CitySubsidyChargeUnit" PointIgnore:"true"`
+ CitySubsidyChargeUnit valueTypes.String `json:"city_subsidy_charge_unit" PointIgnore:"true"`
- CountrySubsidyCharge valueTypes.Float `json:"country_subsidy_charge" PointUnitFrom:"country_subsidy_charge_original_unit"`
- CountrySubsidyChargeOriginalUnit string `json:"country_subsidy_charge_original_unit"`
- CountrySubsidyChargeTran valueTypes.Float `json:"country_subsidy_charge_tran" PointUnitFrom:"country_subsidy_charge_unit" PointIgnore:"true"`
- CountrySubsidyChargeUnit string `json:"country_subsidy_charge_unit" PointIgnore:"true"`
+ CountrySubsidyCharge valueTypes.Float `json:"country_subsidy_charge" PointUnitFrom:"CountrySubsidyChargeOriginalUnit"`
+ CountrySubsidyChargeOriginalUnit valueTypes.String `json:"country_subsidy_charge_original_unit" PointIgnore:"true"`
+ CountrySubsidyChargeTran valueTypes.Float `json:"country_subsidy_charge_tran" PointUnitFrom:"CountrySubsidyChargeUnit" PointIgnore:"true"`
+ CountrySubsidyChargeUnit valueTypes.String `json:"country_subsidy_charge_unit" PointIgnore:"true"`
- CountySubsidyCharge valueTypes.Float `json:"county_subsidy_charge" PointUnitFrom:"county_subsidy_charge_original_unit"`
- CountySubsidyChargeOriginalUnit string `json:"county_subsidy_charge_original_unit"`
- CountySubsidyChargeTran valueTypes.Float `json:"county_subsidy_charge_tran" PointUnitFrom:"county_subsidy_charge_unit" PointIgnore:"true"`
- CountySubsidyChargeUnit string `json:"county_subsidy_charge_unit" PointIgnore:"true"`
+ CountySubsidyCharge valueTypes.Float `json:"county_subsidy_charge" PointUnitFrom:"CountySubsidyChargeOriginalUnit"`
+ CountySubsidyChargeOriginalUnit valueTypes.String `json:"county_subsidy_charge_original_unit" PointIgnore:"true"`
+ CountySubsidyChargeTran valueTypes.Float `json:"county_subsidy_charge_tran" PointUnitFrom:"CountySubsidyChargeUnit" PointIgnore:"true"`
+ CountySubsidyChargeUnit valueTypes.String `json:"county_subsidy_charge_unit" PointIgnore:"true"`
- CuspCharge valueTypes.Float `json:"cusp_charge" PointUnitFrom:"cusp_charge_original_unit"`
- CuspChargeOriginalUnit string `json:"cusp_charge_original_unit"`
- CuspChargeTran valueTypes.Float `json:"cusp_charge_tran" PointUnitFrom:"cusp_charge_unit" PointIgnore:"true"`
- CuspChargeUnit string `json:"cusp_charge_unit" PointIgnore:"true"`
+ CuspCharge valueTypes.Float `json:"cusp_charge" PointUnitFrom:"CuspChargeOriginalUnit"`
+ CuspChargeOriginalUnit valueTypes.String `json:"cusp_charge_original_unit" PointIgnore:"true"`
+ CuspChargeTran valueTypes.Float `json:"cusp_charge_tran" PointUnitFrom:"CuspChargeUnit" PointIgnore:"true"`
+ CuspChargeUnit valueTypes.String `json:"cusp_charge_unit" PointIgnore:"true"`
- CuspNetPowerQuantity valueTypes.Float `json:"cusp_net_power_quantity" PointUnitFrom:"cusp_net_power_quantity_unit"`
- CuspNetPowerQuantityTran valueTypes.Float `json:"cusp_net_power_quantity_tran" PointUnitFrom:"cusp_net_power_quantity_unit" PointIgnore:"true"`
- CuspNetPowerQuantityUnit string `json:"cusp_net_power_quantity_unit"`
+ CuspNetPowerQuantity valueTypes.Float `json:"cusp_net_power_quantity" PointUnitFrom:"CuspNetPowerQuantityUnit"`
+ CuspNetPowerQuantityTran valueTypes.Float `json:"cusp_net_power_quantity_tran" PointUnitFrom:"CuspNetPowerQuantityUnit" PointIgnore:"true"`
+ CuspNetPowerQuantityUnit valueTypes.String `json:"cusp_net_power_quantity_unit" PointIgnore:"true"`
- CuspPowerQuantity valueTypes.Float `json:"cusp_power_quantity" PointUnitFrom:"cusp_power_quantity_unit"`
- CuspPowerQuantityTran valueTypes.Float `json:"cusp_power_quantity_tran" PointUnitFrom:"cusp_power_quantity_unit" PointIgnore:"true"`
- CuspPowerQuantityUnit string `json:"cusp_power_quantity_unit"`
+ CuspPowerQuantity valueTypes.Float `json:"cusp_power_quantity" PointUnitFrom:"CuspPowerQuantityUnit"`
+ CuspPowerQuantityTran valueTypes.Float `json:"cusp_power_quantity_tran" PointUnitFrom:"CuspPowerQuantityUnit" PointIgnore:"true"`
+ CuspPowerQuantityUnit valueTypes.String `json:"cusp_power_quantity_unit" PointIgnore:"true"`
- CuspUsePowerQuantity valueTypes.Float `json:"cusp_use_power_quantity" PointUnitFrom:"cusp_use_power_quantity_unit"`
- CuspUsePowerQuantityTran valueTypes.Float `json:"cusp_use_power_quantity_tran" PointUnitFrom:"cusp_use_power_quantity_unit" PointIgnore:"true"`
- CuspUsePowerQuantityUnit string `json:"cusp_use_power_quantity_unit"`
+ CuspUsePowerQuantity valueTypes.Float `json:"cusp_use_power_quantity" PointUnitFrom:"CuspUsePowerQuantityUnit"`
+ CuspUsePowerQuantityTran valueTypes.Float `json:"cusp_use_power_quantity_tran" PointUnitFrom:"CuspUsePowerQuantityUnit" PointIgnore:"true"`
+ CuspUsePowerQuantityUnit valueTypes.String `json:"cusp_use_power_quantity_unit" PointIgnore:"true"`
- FlatCharge valueTypes.Float `json:"flat_charge" PointUnitFrom:"flat_charge_original_unit"`
- FlatChargeOriginalUnit string `json:"flat_charge_original_unit"`
+ FlatCharge valueTypes.Float `json:"flat_charge" PointUnitFrom:"FlatChargeOriginalUnit"`
+ FlatChargeOriginalUnit valueTypes.String `json:"flat_charge_original_unit" PointIgnore:"true"`
- FlatChargeTran valueTypes.Float `json:"flat_charge_tran" PointUnitFrom:"flat_charge_unit"`
- FlatChargeUnit string `json:"flat_charge_unit"`
+ FlatChargeTran valueTypes.Float `json:"flat_charge_tran" PointUnitFrom:"FlatChargeUnit"`
+ FlatChargeUnit valueTypes.String `json:"flat_charge_unit" PointIgnore:"true"`
- FlatNetPowerQuantity valueTypes.Float `json:"flat_net_power_quantity" PointUnitFrom:"flat_net_power_quantity_unit"`
- FlatNetPowerQuantityTran valueTypes.Float `json:"flat_net_power_quantity_tran" PointUnitFrom:"flat_net_power_quantity_unit" PointIgnore:"true"`
- FlatNetPowerQuantityUnit string `json:"flat_net_power_quantity_unit"`
+ FlatNetPowerQuantity valueTypes.Float `json:"flat_net_power_quantity" PointUnitFrom:"FlatNetPowerQuantityUnit"`
+ FlatNetPowerQuantityTran valueTypes.Float `json:"flat_net_power_quantity_tran" PointUnitFrom:"FlatNetPowerQuantityUnit" PointIgnore:"true"`
+ FlatNetPowerQuantityUnit valueTypes.String `json:"flat_net_power_quantity_unit" PointIgnore:"true"`
- FlatPowerQuantity valueTypes.Float `json:"flat_power_quantity" PointUnitFrom:"flat_power_quantity_unit"`
- FlatPowerQuantityTran valueTypes.Float `json:"flat_power_quantity_tran" PointUnitFrom:"flat_power_quantity_unit" PointIgnore:"true"`
- FlatPowerQuantityUnit string `json:"flat_power_quantity_unit"`
+ FlatPowerQuantity valueTypes.Float `json:"flat_power_quantity" PointUnitFrom:"FlatPowerQuantityUnit"`
+ FlatPowerQuantityTran valueTypes.Float `json:"flat_power_quantity_tran" PointUnitFrom:"FlatPowerQuantityUnit" PointIgnore:"true"`
+ FlatPowerQuantityUnit valueTypes.String `json:"flat_power_quantity_unit" PointIgnore:"true"`
- FlatUsePowerQuantity valueTypes.Float `json:"flat_use_power_quantity" PointUnitFrom:"flat_use_power_quantity_unit"`
- FlatUsePowerQuantityTran valueTypes.Float `json:"flat_use_power_quantity_tran" PointUnitFrom:"flat_use_power_quantity_unit" PointIgnore:"true"`
- FlatUsePowerQuantityUnit string `json:"flat_use_power_quantity_unit"`
+ FlatUsePowerQuantity valueTypes.Float `json:"flat_use_power_quantity" PointUnitFrom:"FlatUsePowerQuantityUnit"`
+ FlatUsePowerQuantityTran valueTypes.Float `json:"flat_use_power_quantity_tran" PointUnitFrom:"FlatUsePowerQuantityUnit" PointIgnore:"true"`
+ FlatUsePowerQuantityUnit valueTypes.String `json:"flat_use_power_quantity_unit" PointIgnore:"true"`
- NetPowerProfit valueTypes.Float `json:"net_power_profit" PointUnitFrom:"net_power_profit_original_unit"`
- NetPowerProfitOriginalUnit string `json:"net_power_profit_original_unit"`
- NetPowerProfitTran valueTypes.Float `json:"net_power_profit_tran" PointUnitFrom:"net_power_profit_unit" PointIgnore:"true"`
- NetPowerProfitUnit string `json:"net_power_profit_unit" PointIgnore:"true"`
+ NetPowerProfit valueTypes.Float `json:"net_power_profit" PointUnitFrom:"NetPowerProfitOriginalUnit"`
+ NetPowerProfitOriginalUnit valueTypes.String `json:"net_power_profit_original_unit" PointIgnore:"true"`
+ NetPowerProfitTran valueTypes.Float `json:"net_power_profit_tran" PointUnitFrom:"NetPowerProfitUnit" PointIgnore:"true"`
+ NetPowerProfitUnit valueTypes.String `json:"net_power_profit_unit" PointIgnore:"true"`
- NetPowerQuantityTotal valueTypes.Float `json:"net_power_quantity_total" PointUnitFrom:"net_power_quantity_total_unit"`
- NetPowerQuantityTotalTran valueTypes.Float `json:"net_power_quantity_total_tran" PointUnitFrom:"net_power_quantity_total_unit" PointIgnore:"true"`
- NetPowerQuantityTotalUnit string `json:"net_power_quantity_total_unit"`
+ NetPowerQuantityTotal valueTypes.Float `json:"net_power_quantity_total" PointUnitFrom:"NetPowerQuantityTotalUnit"`
+ NetPowerQuantityTotalTran valueTypes.Float `json:"net_power_quantity_total_tran" PointUnitFrom:"NetPowerQuantityTotalUnit" PointIgnore:"true"`
+ NetPowerQuantityTotalUnit valueTypes.String `json:"net_power_quantity_total_unit" PointIgnore:"true"`
- PeakCharge valueTypes.Float `json:"peak_charge" PointUnitFrom:"peak_charge_original_unit"`
- PeakChargeOriginalUnit string `json:"peak_charge_original_unit"`
+ PeakCharge valueTypes.Float `json:"peak_charge" PointUnitFrom:"PeakChargeOriginalUnit"`
+ PeakChargeOriginalUnit valueTypes.String `json:"peak_charge_original_unit" PointIgnore:"true"`
- PeakChargeTran valueTypes.Float `json:"peak_charge_tran" PointUnitFrom:"peak_charge_unit"`
- PeakChargeUnit string `json:"peak_charge_unit"`
+ PeakChargeTran valueTypes.Float `json:"peak_charge_tran" PointUnitFrom:"PeakChargeUnit"`
+ PeakChargeUnit valueTypes.String `json:"peak_charge_unit" PointIgnore:"true"`
- PeakNetPowerQuantity valueTypes.Float `json:"peak_net_power_quantity" PointUnitFrom:"peak_net_power_quantity_unit"`
- PeakNetPowerQuantityTran valueTypes.Float `json:"peak_net_power_quantity_tran" PointUnitFrom:"peak_net_power_quantity_unit" PointIgnore:"true"`
- PeakNetPowerQuantityUnit string `json:"peak_net_power_quantity_unit"`
+ PeakNetPowerQuantity valueTypes.Float `json:"peak_net_power_quantity" PointUnitFrom:"PeakNetPowerQuantityUnit"`
+ PeakNetPowerQuantityTran valueTypes.Float `json:"peak_net_power_quantity_tran" PointUnitFrom:"PeakNetPowerQuantityUnit" PointIgnore:"true"`
+ PeakNetPowerQuantityUnit valueTypes.String `json:"peak_net_power_quantity_unit" PointIgnore:"true"`
- PeakPowerQuantity valueTypes.Float `json:"peak_power_quantity" PointUnitFrom:"peak_power_quantity_unit"`
- PeakPowerQuantityTran valueTypes.Float `json:"peak_power_quantity_tran" PointUnitFrom:"peak_power_quantity_unit" PointIgnore:"true"`
- PeakPowerQuantityUnit string `json:"peak_power_quantity_unit"`
+ PeakPowerQuantity valueTypes.Float `json:"peak_power_quantity" PointUnitFrom:"PeakPowerQuantityUnit"`
+ PeakPowerQuantityTran valueTypes.Float `json:"peak_power_quantity_tran" PointUnitFrom:"PeakPowerQuantityUnit" PointIgnore:"true"`
+ PeakPowerQuantityUnit valueTypes.String `json:"peak_power_quantity_unit" PointIgnore:"true"`
- PeakUsePowerQuantity valueTypes.Float `json:"peak_use_power_quantity" PointUnitFrom:"peak_use_power_quantity_unit"`
- PeakUsePowerQuantityTran valueTypes.Float `json:"peak_use_power_quantity_tran" PointUnitFrom:"peak_use_power_quantity_unit" PointIgnore:"true"`
- PeakUsePowerQuantityUnit string `json:"peak_use_power_quantity_unit"`
+ PeakUsePowerQuantity valueTypes.Float `json:"peak_use_power_quantity" PointUnitFrom:"PeakUsePowerQuantityUnit"`
+ PeakUsePowerQuantityTran valueTypes.Float `json:"peak_use_power_quantity_tran" PointUnitFrom:"PeakUsePowerQuantityUnit" PointIgnore:"true"`
+ PeakUsePowerQuantityUnit valueTypes.String `json:"peak_use_power_quantity_unit" PointIgnore:"true"`
- PowerQuantityTotal valueTypes.Float `json:"power_quantity_total" PointUnitFrom:"power_quantity_total_unit"`
- PowerQuantityTotalTran valueTypes.Float `json:"power_quantity_total_tran" PointUnitFrom:"power_quantity_total_unit" PointIgnore:"true"`
- PowerQuantityTotalUnit string `json:"power_quantity_total_unit"`
+ PowerQuantityTotal valueTypes.Float `json:"power_quantity_total" PointUnitFrom:"PowerQuantityTotalUnit"`
+ PowerQuantityTotalTran valueTypes.Float `json:"power_quantity_total_tran" PointUnitFrom:"PowerQuantityTotalUnit" PointIgnore:"true"`
+ PowerQuantityTotalUnit valueTypes.String `json:"power_quantity_total_unit" PointIgnore:"true"`
- ProvinceSubsidyCharge valueTypes.Float `json:"province_subsidy_charge" PointUnitFrom:"province_subsidy_charge_original_unit"`
- ProvinceSubsidyChargeOriginalUnit string `json:"province_subsidy_charge_original_unit"`
+ ProvinceSubsidyCharge valueTypes.Float `json:"province_subsidy_charge" PointUnitFrom:"ProvinceSubsidyChargeOriginalUnit"`
+ ProvinceSubsidyChargeOriginalUnit valueTypes.String `json:"province_subsidy_charge_original_unit" PointIgnore:"true"`
- ProvinceSubsidyChargeTran valueTypes.Float `json:"province_subsidy_charge_tran" PointUnitFrom:"province_subsidy_charge_unit"`
- ProvinceSubsidyChargeUnit string `json:"province_subsidy_charge_unit"`
+ ProvinceSubsidyChargeTran valueTypes.Float `json:"province_subsidy_charge_tran" PointUnitFrom:"ProvinceSubsidyChargeUnit"`
+ ProvinceSubsidyChargeUnit valueTypes.String `json:"province_subsidy_charge_unit" PointIgnore:"true"`
- SubsidyProfit valueTypes.Float `json:"subsidy_profit" PointUnitFrom:"subsidy_profit_original_unit"`
- SubsidyProfitOriginalUnit string `json:"subsidy_profit_original_unit"`
+ SubsidyProfit valueTypes.Float `json:"subsidy_profit" PointUnitFrom:"SubsidyProfitOriginalUnit"`
+ SubsidyProfitOriginalUnit valueTypes.String `json:"subsidy_profit_original_unit" PointIgnore:"true"`
- SubsidyProfitTran valueTypes.Float `json:"subsidy_profit_tran" PointUnitFrom:"subsidy_profit_unit"`
- SubsidyProfitUnit string `json:"subsidy_profit_unit"`
+ SubsidyProfitTran valueTypes.Float `json:"subsidy_profit_tran" PointUnitFrom:"SubsidyProfitUnit"`
+ SubsidyProfitUnit valueTypes.String `json:"subsidy_profit_unit" PointIgnore:"true"`
- TotalProfit valueTypes.Float `json:"total_profit" PointUnitFrom:"total_profit_original_unit"`
- TotalProfitOriginalUnit string `json:"total_profit_original_unit"`
- TotalProfitTran valueTypes.Float `json:"total_profit_tran" PointUnitFrom:"total_profit_unit" PointIgnore:"true"`
- TotalProfitUnit string `json:"total_profit_unit" PointIgnore:"true"`
+ TotalProfit valueTypes.Float `json:"total_profit" PointUnitFrom:"TotalProfitOriginalUnit"`
+ TotalProfitOriginalUnit valueTypes.String `json:"total_profit_original_unit" PointIgnore:"true"`
+ TotalProfitTran valueTypes.Float `json:"total_profit_tran" PointUnitFrom:"TotalProfitUnit" PointIgnore:"true"`
+ TotalProfitUnit valueTypes.String `json:"total_profit_unit" PointIgnore:"true"`
- UsePowerByDiscountProfit valueTypes.Float `json:"use_power_by_discount_profit" PointUnitFrom:"use_power_by_discount_profit_original_unit"`
- UsePowerByDiscountProfitOriginalUnit string `json:"use_power_by_discount_profit_original_unit"`
- UsePowerByDiscountProfitTran valueTypes.Float `json:"use_power_by_discount_profit_tran" PointUnitFrom:"use_power_by_discount_profit_unit" PointIgnore:"true"`
- UsePowerByDiscountProfitUnit string `json:"use_power_by_discount_profit_unit" PointIgnore:"true"`
+ UsePowerByDiscountProfit valueTypes.Float `json:"use_power_by_discount_profit" PointUnitFrom:"UsePowerByDiscountProfitOriginalUnit"`
+ UsePowerByDiscountProfitOriginalUnit valueTypes.String `json:"use_power_by_discount_profit_original_unit" PointIgnore:"true"`
+ UsePowerByDiscountProfitTran valueTypes.Float `json:"use_power_by_discount_profit_tran" PointUnitFrom:"UsePowerByDiscountProfitUnit" PointIgnore:"true"`
+ UsePowerByDiscountProfitUnit valueTypes.String `json:"use_power_by_discount_profit_unit" PointIgnore:"true"`
- UsePowerProfit valueTypes.Float `json:"use_power_profit" PointUnitFrom:"use_power_profit_original_unit"`
- UsePowerProfitOriginalUnit string `json:"use_power_profit_original_unit"`
- UsePowerProfitTran valueTypes.Float `json:"use_power_profit_tran" PointUnitFrom:"use_power_profit_unit" PointIgnore:"true"`
- UsePowerProfitUnit string `json:"use_power_profit_unit" PointIgnore:"true"`
+ UsePowerProfit valueTypes.Float `json:"use_power_profit" PointUnitFrom:"UsePowerProfitOriginalUnit"`
+ UsePowerProfitOriginalUnit valueTypes.String `json:"use_power_profit_original_unit" PointIgnore:"true"`
+ UsePowerProfitTran valueTypes.Float `json:"use_power_profit_tran" PointUnitFrom:"UsePowerProfitUnit" PointIgnore:"true"`
+ UsePowerProfitUnit valueTypes.String `json:"use_power_profit_unit" PointIgnore:"true"`
- UsePowerQuantityTotal valueTypes.Float `json:"use_power_quantity_total" PointUnitFrom:"use_power_quantity_total_unit"`
- UsePowerQuantityTotalTran valueTypes.Float `json:"use_power_quantity_total_tran" PointUnitFrom:"use_power_quantity_total_unit" PointIgnore:"true"`
- UsePowerQuantityTotalUnit string `json:"use_power_quantity_total_unit"`
+ UsePowerQuantityTotal valueTypes.Float `json:"use_power_quantity_total" PointUnitFrom:"UsePowerQuantityTotalUnit"`
+ UsePowerQuantityTotalTran valueTypes.Float `json:"use_power_quantity_total_tran" PointUnitFrom:"UsePowerQuantityTotalUnit" PointIgnore:"true"`
+ UsePowerQuantityTotalUnit valueTypes.String `json:"use_power_quantity_total_unit" PointIgnore:"true"`
- ValleyCharge valueTypes.Float `json:"valley_charge" PointUnitFrom:"valley_charge_original_unit"`
- ValleyChargeOriginalUnit string `json:"valley_charge_original_unit"`
- ValleyChargeTran valueTypes.Float `json:"valley_charge_tran" PointUnitFrom:"valley_charge_unit" PointIgnore:"true"`
- ValleyChargeUnit string `json:"valley_charge_unit" PointIgnore:"true"`
+ ValleyCharge valueTypes.Float `json:"valley_charge" PointUnitFrom:"ValleyChargeOriginalUnit"`
+ ValleyChargeOriginalUnit valueTypes.String `json:"valley_charge_original_unit" PointIgnore:"true"`
+ ValleyChargeTran valueTypes.Float `json:"valley_charge_tran" PointUnitFrom:"ValleyChargeUnit" PointIgnore:"true"`
+ ValleyChargeUnit valueTypes.String `json:"valley_charge_unit" PointIgnore:"true"`
- ValleyNetPowerQuantity valueTypes.Float `json:"valley_net_power_quantity" PointUnitFrom:"valley_net_power_quantity_unit"`
- ValleyNetPowerQuantityTran valueTypes.Float `json:"valley_net_power_quantity_tran" PointUnitFrom:"valley_net_power_quantity_unit" PointIgnore:"true"`
- ValleyNetPowerQuantityUnit string `json:"valley_net_power_quantity_unit"`
+ ValleyNetPowerQuantity valueTypes.Float `json:"valley_net_power_quantity" PointUnitFrom:"ValleyNetPowerQuantityUnit"`
+ ValleyNetPowerQuantityTran valueTypes.Float `json:"valley_net_power_quantity_tran" PointUnitFrom:"ValleyNetPowerQuantityUnit" PointIgnore:"true"`
+ ValleyNetPowerQuantityUnit valueTypes.String `json:"valley_net_power_quantity_unit" PointIgnore:"true"`
- ValleyPowerQuantity valueTypes.Float `json:"valley_power_quantity" PointUnitFrom:"valley_power_quantity_unit"`
- ValleyPowerQuantityTran valueTypes.Float `json:"valley_power_quantity_tran" PointUnitFrom:"valley_power_quantity_unit" PointIgnore:"true"`
- ValleyPowerQuantityUnit string `json:"valley_power_quantity_unit"`
+ ValleyPowerQuantity valueTypes.Float `json:"valley_power_quantity" PointUnitFrom:"ValleyPowerQuantityUnit"`
+ ValleyPowerQuantityTran valueTypes.Float `json:"valley_power_quantity_tran" PointUnitFrom:"ValleyPowerQuantityUnit" PointIgnore:"true"`
+ ValleyPowerQuantityUnit valueTypes.String `json:"valley_power_quantity_unit" PointIgnore:"true"`
- ValleyUsePowerQuantity valueTypes.Float `json:"valley_use_power_quantity" PointUnitFrom:"valley_use_power_quantity_unit"`
- ValleyUsePowerQuantityTran valueTypes.Float `json:"valley_use_power_quantity_tran" PointUnitFrom:"valley_use_power_quantity_unit" PointIgnore:"true"`
- ValleyUsePowerQuantityUnit string `json:"valley_use_power_quantity_unit"`
+ ValleyUsePowerQuantity valueTypes.Float `json:"valley_use_power_quantity" PointUnitFrom:"ValleyUsePowerQuantityUnit" PointIgnore:"true"`
+ ValleyUsePowerQuantityTran valueTypes.Float `json:"valley_use_power_quantity_tran" PointUnitFrom:"ValleyUsePowerQuantityUnit" PointIgnore:"true"`
+ ValleyUsePowerQuantityUnit valueTypes.String `json:"valley_use_power_quantity_unit" PointIgnore:"true"`
}
func (e *ResultData) IsValid() error {
@@ -196,46 +197,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 {
pkg := apiReflect.GetName("", *e)
- entries.StructToPoints(e.Response.ResultData, pkg, e.Request.PsId.String(), valueTypes.NewDateTime(""))
-
- s := valueTypes.SizeOfArrayLength(e.Response.ResultData.DataList)
- for _, v := range e.Response.ResultData.DataList {
- entries.StructToPoints(v, api.JoinWithDots(s, valueTypes.DateTimeLayoutDay, pkg, "DataList", v.PsId, v.DateId), v.PsId.String(), valueTypes.NewDateTime(""))
- }
-
- s = valueTypes.SizeOfArrayLength(e.Response.ResultData.Info)
- for i, v := range e.Response.ResultData.Info {
- entries.StructToPoints(v, api.JoinWithDots(s, valueTypes.DateTimeLayoutDay, pkg, "Info", v.PsId, i), v.PsId.String(), valueTypes.NewDateTime(""))
- }
-
- s = valueTypes.SizeOfArrayLength(e.Response.ResultData.Total)
- for i, v := range e.Response.ResultData.Total {
- entries.StructToPoints(v, api.JoinWithDots(s, valueTypes.DateTimeLayoutDay, pkg, "Total", v.PsId, i), v.PsId.String(), valueTypes.NewDateTime(""))
- }
+ dt := valueTypes.NewDateTime(valueTypes.Now)
+ name := pkg + "." + e.Request.PsId.String()
+ entries.StructToPoints(e.Response.ResultData, name, e.Request.PsId.String(), dt)
}
return entries
diff --git a/iSolarCloud/api/apiReflect/reflect.go b/iSolarCloud/api/apiReflect/reflect.go
index 8299327a2..92e383abf 100644
--- a/iSolarCloud/api/apiReflect/reflect.go
+++ b/iSolarCloud/api/apiReflect/reflect.go
@@ -1,5 +1,6 @@
package apiReflect
+// import "C"
import (
"GoSungrow/Only"
"GoSungrow/iSolarCloud/api/valueTypes"
@@ -17,59 +18,401 @@ import (
)
-type DataStructures struct {
- Map map[string]DataStructure
-}
-type DataStructure struct {
- // PointType string
- Json string
- PointId string
- PointParentId string
- PointUnit string
- PointUnitFrom string
- PointTimestamp time.Time
- PointName string
- PointUpdateFreq string
- PointValueType string
- PointAliasTo string
- PointIgnore bool
- PointGroupName string
- PointGroupNameFrom string
- PointTimestampFrom string
-
- Value interface{}
- ValueType string
- ValueKind string
- Endpoint string
-}
-
const (
- PointId = "PointId" // Point id in the form p\d+ or \d+
- PointUnit = "PointUnit" // Units: Wh, kWh, C, h.
- PointUnitFrom = "PointUnitFrom" // Get PointUnit from another field structure.
- PointParentId = "PointParentId" // Associated parent of point.
- PointName = "PointName" // Human-readable name of point.
- PointUpdateFreq = "PointUpdateFreq" // Point update frequency - Total, Yearly, Monthly, Day.
- PointValueType = "PointValueType" // Value type of point: energy, date, battery, temperature.
+ 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.
- PointIgnore = "PointIgnore" // Ignore this point.
+
+ PointUnit = "PointUnit" // Units: Wh, kWh, C, h.
+ PointUnitFrom = "PointUnitFrom" // Get PointUnit 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.
+
PointArrayFlatten = "PointArrayFlatten" // Flatten an array into a string. EG: ["one", "two", "three"]
+ PointIgnoreZero = "PointIgnoreZero" // Ignore arrays with zero size, (default true).
+
PointTimestampFrom = "PointTimestampFrom" // Pull timestamp from another field structure.
)
-func (dss *DataStructures) Add(name string, ds DataStructure) {
+
+type Reflect struct {
+ Valid bool
+ DataStructure DataStructure
+ Interface interface{}
+ IsNil bool
+ IsExported bool
+ IsUnknown bool
+ Kind reflect.Kind
+ TypeOf reflect.Type
+ ValueOf reflect.Value
+
+ Length int
+ FieldName string
+ FieldTo reflect.StructField
+ FieldVo reflect.Value
+}
+
+func (r *Reflect) SetByFieldName(parent interface{}, ref 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.Kind = r.TypeOf.Kind()
+ r.FieldName = fieldName
+
+ if r.Kind == reflect.Struct {
+ r.Length = r.ValueOf.NumField()
+ }
+
+ if r.Kind == reflect.Slice {
+ r.Length = r.ValueOf.Len()
+ }
+
+ if r.Kind == reflect.Array {
+ r.Length = r.ValueOf.Len()
+ }
+
+ if r.Kind == reflect.Map {
+ r.Length = len(r.ValueOf.MapKeys())
+ }
+
+ r.SetFieldName(parent, fieldName)
+ // r.DataStructure = r.DataStructure.Set(ref, r.FieldTo, r.FieldVo)
+ }
+}
+
+func (r *Reflect) SetByIndex(parent interface{}, fieldIndex int) {
+ for range Only.Once {
+ // Get child interface from parent.
+ pt := reflect.TypeOf(parent)
+ pv := reflect.ValueOf(parent)
+ pk := pt.Kind()
+ switch pk {
+ case reflect.Struct:
+ r.Interface = pv.Field(fieldIndex).Interface()
+ case reflect.Slice:
+ r.Interface = pv.Index(fieldIndex).Interface()
+ case reflect.Array:
+ r.Interface = pv.Index(fieldIndex).Interface()
+ case reflect.Map:
+ mk := pv.MapKeys()
+ r.Interface = pv.MapIndex(mk[fieldIndex]).Interface()
+ }
+
+ r.Valid = true
+ r.IsNil = valueTypes.IsNil(r.Interface)
+ r.IsUnknown = valueTypes.IsUnknownStruct(r.Interface)
+ r.TypeOf = reflect.TypeOf(r.Interface)
+ r.ValueOf = reflect.ValueOf(r.Interface)
+ if r.IsNil {
+ r.Kind = reflect.Invalid
+ } else {
+ r.Kind = r.TypeOf.Kind()
+ }
+
+ r.Length = -1
+ if r.Kind == reflect.Struct {
+ r.Length = r.ValueOf.NumField()
+ }
+ if r.Kind == reflect.Slice {
+ r.Length = r.ValueOf.Len()
+ }
+ if r.Kind == reflect.Array {
+ r.Length = r.ValueOf.Len()
+ }
+ if r.Kind == reflect.Map {
+ r.Length = len(r.ValueOf.MapKeys())
+ }
+
+ r.SetFieldNameByIndex(parent, 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) {
+ 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)
+ if p.Kind() == reflect.Struct {
+ r.FieldTo = p.Field(fieldIndex)
+ r.IsExported = r.FieldTo.IsExported()
+ r.FieldVo = reflect.ValueOf(parent).Field(fieldIndex)
+ r.FieldName = r.FieldTo.Name
+
+ r.DataStructure = r.DataStructure.Set(parent, 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.FieldName = r.FieldTo.Name
+
+ r.DataStructure = r.DataStructure.Set(parent, 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 {
+ for range Only.Once {
+ // if !fieldTo.IsExported() {
+ // fmt.Printf("DEBUG: NOTEXPORTED(%s): %s\n", fieldTo.Name, getJsonTag(fieldTo))
+ // break
+ // }
+ //
+ // pointJson := getJsonTag(fieldTo)
+ // pointId := fieldTo.Tag.Get(PointId)
+ // if pointId == "" {
+ // pointId = pointJson
+ // }
+
+ // pointTimestamp := time.Now()
+ // pointTimestampFrom := fieldTo.Tag.Get(PointTimestampFrom)
+ // if pointTimestampFrom != "" {
+ // pointTimestamp = GetTimestampFrom(parentRef, pointTimestampFrom, valueTypes.DateTimeLayout)
+ // }
+
+ ft := valueTypes.GetIntFormatForPrintf(r.Length)
+ pn := fmt.Sprintf(ft, index)
+ intSize := valueTypes.SizeOfInt(r.Length)
+
+ 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)
+ if r.DataStructure.PointNameFromAppend == "true" {
+ name = append(name, pn)
+ } else {
+ name = append(name[:len(name) - 1], pn)
+ }
+
+ 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)
+ if r.DataStructure.PointNameFromAppend == "true" {
+ name = append(name, pn)
+ } else {
+ name = append(name[:len(name) - 1], pn)
+ }
+
+ default:
+ name = append(name, pn)
+ }
+ }
+
+ return name
+}
+
+
+type DataStructure struct {
+ // PointType string
+ 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
+ PointTimestampFrom string
+ PointArrayFlatten string
+ PointIgnoreZero bool
+ PointNameFromAppend string
+ PointNameFromChild string
+ PointNameFromParent string
+ PointNameDateFormat string
+
+ Value interface{}
+ ValueType string
+ ValueKind string
+ Endpoint string
+}
+
+func (ds *DataStructure) Set(parentRef interface{}, fieldTo reflect.StructField, fieldVo reflect.Value) DataStructure {
+ for range Only.Once {
+ // sf, ok := reflect.TypeOf(parentRef).FieldByName(fieldName)
+ // if !ok {
+ // break
+ // }
+ // fieldTo := sf
+ // fieldVo := reflect.ValueOf(parentRef).FieldByName(fieldName)
+
+ ignore := false
+ if fieldTo.Tag.Get(PointIgnore) != "" {
+ ignore = true
+ }
+
+ pointIgnoreIfNil := fieldTo.Tag.Get(PointIgnoreIfNil)
+ if pointIgnoreIfNil != "" {
+ ret := GetStringFrom(parentRef, pointIgnoreIfNil)
+ if (ret == "") || (ret == "--") {
+ ignore = true
+ }
+ }
+
+ // pointIgnoreIfNilFromChild := fieldTo.Tag.Get(PointIgnoreIfNilFromChild)
+ // if pointIgnoreIfNilFromChild != "" {
+ // ret := GetStringFrom(fieldVo.Interface(), pointIgnoreIfNilFromChild)
+ // if (ret == "") || (ret == "--") {
+ // ignore = true
+ // }
+ // }
+
+ var pointIgnoreZero bool
+ switch fieldTo.Tag.Get(PointIgnoreZero) {
+ case "false":
+ pointIgnoreZero = false
+ case "true":
+ pointIgnoreZero = true
+ default:
+ pointIgnoreZero = true
+ }
+
+ // if valueTypes.IsNil(ref) {
+ // pointValueType = "NIL"
+ // }
+
+ pointJson := getJsonTag(fieldTo)
+ pointId := fieldTo.Tag.Get(PointId)
+ if pointId == "" {
+ pointId = pointJson
+ }
+
+ pointUnit := fieldTo.Tag.Get(PointUnit)
+ pointUnitFrom := fieldTo.Tag.Get(PointUnitFrom)
+ if pointUnitFrom != "" {
+ pointUnit = GetStringFrom(parentRef, pointUnitFrom)
+ }
+
+ pointGroupName := fieldTo.Tag.Get(PointGroupName)
+ pointGroupNameFrom := fieldTo.Tag.Get(PointGroupNameFrom)
+ if pointGroupNameFrom != "" {
+ pointGroupName = GetStringFrom(parentRef, pointGroupNameFrom)
+ }
+
+ pointTimestamp := time.Now()
+ pointTimestampFrom := fieldTo.Tag.Get(PointTimestampFrom)
+ if pointTimestampFrom != "" {
+ pointTimestamp = GetTimestampFrom(parentRef, pointTimestampFrom, valueTypes.DateTimeLayout)
+ }
+
+ var valueType string
+ if fieldTo.Type != nil {
+ valueType = fieldTo.Type.String()
+ }
+
+ pointName := fieldTo.Tag.Get(PointName)
+ if pointName == "" {
+ pointName = valueTypes.PointToName(pointId)
+ }
+
+ pointNameDateFormat := fieldTo.Tag.Get(PointNameDateFormat)
+ if pointNameDateFormat == "" {
+ pointNameDateFormat = valueTypes.DateTimeAltLayout
+ }
+
+ *ds = DataStructure {
+ Json: pointJson,
+ PointId: pointId,
+ PointParentId: fieldTo.Tag.Get(PointParentId),
+
+ PointUnit: pointUnit,
+ PointUnitFrom: pointUnitFrom,
+
+ PointTimestamp: pointTimestamp,
+ PointTimestampFrom: pointTimestampFrom,
+
+ PointGroupName: pointGroupName,
+ PointGroupNameFrom: pointGroupNameFrom,
+
+ PointName: pointName,
+ PointNameFromAppend: fieldTo.Tag.Get(PointNameFromAppend),
+ PointNameFromChild: fieldTo.Tag.Get(PointNameFromChild),
+ PointNameFromParent: fieldTo.Tag.Get(PointNameFromParent),
+ PointNameDateFormat: pointNameDateFormat,
+
+ PointUpdateFreq: fieldTo.Tag.Get(PointUpdateFreq),
+ PointValueType: fieldTo.Tag.Get(PointValueType),
+ PointAliasTo: fieldTo.Tag.Get(PointAliasTo),
+ PointIgnore: ignore,
+ PointIgnoreIfNil: pointIgnoreIfNil,
+ PointIgnoreIfNilFromChild: fieldTo.Tag.Get(PointIgnoreIfNilFromChild),
+ PointArrayFlatten: fieldTo.Tag.Get(PointArrayFlatten),
+ PointIgnoreZero: pointIgnoreZero,
+
+ Value: nil,
+ ValueType: valueType,
+ ValueKind: fieldVo.Kind().String(),
+ Endpoint: "", // strings.TrimPrefix(strings.Join(name, "."), "."),
+ }
+
+ }
+ return *ds
+}
+
+
+type DataStructures struct {
+ Map map[string]DataStructure
+}
+
+func (dss *DataStructures) Add(ds DataStructure) {
for range Only.Once {
if dss.Map == nil {
dss.Map = make(map[string]DataStructure)
}
// fmt.Printf("DEBUG DataStructures.Add() %s - Kind:'%s' Type:'%s'\n", name, ds.ValueKind, ds.ValueType)
- dss.Map[name] = ds
+ dss.Map[ds.Endpoint] = ds
}
}
@@ -100,434 +443,538 @@ func (dss *DataStructures) Append(dsm DataStructures) {
}
}
+// func (dss *DataStructures) GetPointTags(parentRef interface{}, ref interface{}, name ...string) DataStructures {
+//
+// for range Only.Once {
+// to := reflect.TypeOf(ref)
+// vo := reflect.ValueOf(ref)
+//
+// if vo.Kind() == reflect.Slice {
+// fmt.Println("reflect.Slice")
+// if vo.Len() > 0 {
+// dss.GetPointTags(parentRef, vo.Index(0).Interface(), name...)
+// }
+// break
+// }
+//
+// if vo.Kind() == reflect.Array {
+// fmt.Println("reflect.Array")
+// if vo.Len() > 0 {
+// dss.GetPointTags(parentRef, vo.Index(0).Interface(), name...)
+// }
+// break
+// }
+//
+// if vo.Kind() == reflect.Map {
+// fmt.Println("reflect.Map")
+// mk := vo.MapKeys()
+// if len(mk) > 0 {
+// dss.GetPointTags(parentRef, vo.MapIndex(mk[0]).Interface(), name...)
+// }
+// break
+// }
+//
+// if vo.Kind() == reflect.Pointer {
+// // We're going to change the pointer to a proper object reference.
+// if valueTypes.IsNil(ref) {
+// break
+// }
+// ref = vo.Elem().Interface()
+// if valueTypes.IsNil(ref) {
+// break
+// }
+// to = reflect.TypeOf(ref)
+// vo = reflect.ValueOf(ref)
+// // Or we could just call ourselves - either way works.
+// // dss.GetPointTags(parentRef, fieldVo.Interface(), name...)
+// // continue
+// }
+//
+//
+// // Iterate over all available fields and read the tag value
+// for i := 0; i < vo.NumField(); i++ {
+// fieldTo := to.Field(i)
+// fieldVo := vo.Field(i)
+// // fmt.Printf("START:\nref: %v\nfieldTo: %v\nfieldVo: %v\n", ref, fieldTo, fieldVo)
+//
+// if fieldVo.Kind() == reflect.Pointer {
+// // We're going to change the pointer to a proper object reference.
+// if valueTypes.IsNil(fieldVo.Interface()) {
+// continue
+// }
+// ref = fieldVo.Elem().Interface()
+// if valueTypes.IsNil(ref) {
+// continue
+// }
+// to = reflect.TypeOf(ref)
+// vo = reflect.ValueOf(ref)
+// i = 0
+// fieldTo = to.Field(i)
+// fieldVo = vo.Field(i)
+// // Or we could just call ourselves - either way works.
+// // dss.GetPointTags(parentRef, fieldVo.Interface(), name...)
+// // continue
+// }
+//
+// if !fieldTo.IsExported() {
+// fmt.Printf("DEBUG: NOTEXPORTED(%s): Type %s\n", name, fieldTo.Name)
+// continue
+// }
+//
+// pointJson := getJsonTag(fieldTo)
+// pointId := fieldTo.Tag.Get(PointId)
+// if pointId == "" {
+// pointId = pointJson
+// }
+//
+// if pointId == "data_list" {
+// fmt.Sprintf("")
+// }
+//
+// // fmt.Printf("DEBUG[%d]: %s.%s: Key[%s]:\tKind:'%s' Type:'%s'\n",
+// // len(dss.Map),
+// // strings.Join(name, "."), pointId,
+// // fieldTo.Name,
+// // fieldVo.Kind(),
+// // fieldTo.Type.String(),
+// // )
+//
+// switch fieldVo.Kind() {
+// case reflect.Uintptr:
+// fallthrough
+// case reflect.Complex64:
+// fallthrough
+// case reflect.Complex128:
+// fallthrough
+// case reflect.Chan:
+// fallthrough
+// case reflect.Func:
+// fallthrough
+// case reflect.UnsafePointer:
+// fmt.Printf("Unsupported type: '%s.%s' (%s)\n", name, pointId, fieldVo.Type().String())
+// continue
+//
+// case reflect.Pointer:
+// if valueTypes.IsNil(fieldVo.Interface()) {
+// continue
+// }
+// // Convert pointer to object just be calling ourselves.
+// dss.GetPointTags(parentRef, fieldVo.Interface(), name...)
+//
+// case reflect.Array:
+// // @TODO - Handle arrays here.
+// fallthrough
+// case reflect.Slice:
+// // Handle slices here.
+// if fieldTo.Tag.Get(PointArrayFlatten) != "" {
+// // We want to flatten a slice down to EG "[1, 2, 3]"
+// endPointName, ds := makeDataStructure(parentRef, fieldTo, fieldVo, name)
+// ds.Value = valueTypes.AnyToValueString(fieldVo.Interface(), 0, "")
+// dss.Add(endPointName + "." + ds.PointId, ds)
+// continue
+// }
+//
+// if valueTypes.IsUnknownStruct(fieldVo.Interface()) {
+// name2 := append(name, pointId)
+// for si := 0; si < fieldVo.Len(); si++ {
+// // Are we using an index number for name or field key value?
+// name3 := setPointName(fieldVo.Interface(), fieldVo.Index(si).Interface(), fieldTo, fieldVo, name2, si)
+// dss.GetPointTags(fieldVo.Interface(), fieldVo.Index(si).Interface(), name3...)
+// // dss.GetPointTags(fieldVo.Index(si).Interface(), fieldVo.Index(si).Interface(), name3...)
+// }
+// continue
+// }
+//
+// // Flatten slice for []Integer / []Float objects.
+// endPointName, ds := makeDataStructure(parentRef, fieldTo, fieldVo, name)
+// ds.Value = valueTypes.AnyToValueString(fieldVo.Interface(), 0, "")
+// dss.Add(endPointName + "." + ds.PointId, ds)
+// continue
+//
+// case reflect.Map:
+// // fmt.Printf("Kind: %s ##########################################\n", fieldVo.Kind().String())
+// n2 := append(name, pointId)
+// // pointNameFromChild := fieldTo.Tag.Get(PointNameFromChild)
+// // pointNameFromParent := fieldTo.Tag.Get(PointNameFromParent)
+//
+// for _, key := range fieldVo.MapKeys() {
+// // @TODO - Implement this.
+// // if pointNameFromChild != "" {
+// // // PointNameFromChild - In this case points to a field within a CHILD struct.
+// // pn = GetPointNameFrom(fieldVo.Index(si).Interface(), pointNameFromChild, intSize, pointNameDateFormat)
+// // n3 = append(n2[:len(n2) - 1], pn)
+// // }
+// // if pointNameFromParent != "" {
+// // // PointNameFromChild - In this case points to a field within a CHILD struct.
+// // pn = GetPointNameFrom(fieldVo.Interface(), pointNameFromParent, intSize, pointNameDateFormat)
+// // n3 = append(n2[:len(n2) - 1], pn)
+// // }
+//
+// endPointName, ds := makeDataStructure(fieldVo.Interface(), fieldTo, fieldVo, n2)
+// ds.Json = key.String()
+// ds.PointId = key.String()
+// val := fieldVo.MapIndex(key)
+// ds.Value = val.Interface()
+// dss.Add(endPointName + "." + ds.PointId, ds)
+// }
+// continue
+//
+// case reflect.Struct:
+// // fmt.Printf("Kind: %s ##########################################\n", fieldVo.Kind().String())
+// if valueTypes.IsUnknownStruct(fieldVo.Interface()) {
+// n2 := append(name, pointId)
+// dss.GetPointTags(parentRef, fieldVo.Interface(), n2...)
+// continue
+// }
+//
+// // fmt.Printf("[%s.%s] => %v\n", strings.Join(name, "."), pointId, fieldVo.Interface())
+// endPointName, ds := makeDataStructure(parentRef, fieldTo, fieldVo, name)
+// ds.Value = fieldVo.Interface()
+// dss.Add(endPointName + "." + ds.PointId, ds)
+// continue
+//
+// default:
+// // endPointName, ds := makeDataStructure(parentRef, fieldTo, fieldVo, name)
+// // ds.Value = fieldVo.Interface()
+// // dss.Add(endPointName + "." + ds.PointId, ds)
+// }
+//
+// endPointName, ds := makeDataStructure(parentRef, fieldTo, fieldVo, name)
+// ds.Value = fieldVo.Interface()
+// dss.Add(endPointName + "." + ds.PointId, ds)
+// }
+// }
+//
+// return *dss
+// }
-func (dss *DataStructures) GetPointTags(parentRef interface{}, ref interface{}, name ...string) DataStructures {
- // var ret DataStructures
- // ret.Map = make(map[string]DataStructure)
+func (dss *DataStructures) GetPointTags(Parent Reflect, Current Reflect, name ...string) DataStructures {
for range Only.Once {
- to := reflect.TypeOf(ref)
- vo := reflect.ValueOf(ref)
+ // fmt.Printf("%s - Parent Kind: %s\tCurrent Kind: %s\n", strings.Join(name, "."), Parent.Kind, Current.Kind)
- if vo.Kind() == reflect.Slice {
- fmt.Println("reflect.Slice")
- if vo.Len() > 0 {
- dss.GetPointTags(parentRef, vo.Index(0).Interface(), name...)
+ if Current.Kind == reflect.Pointer {
+ // Special case:
+ // We're going to change the pointer to a proper object reference.
+ if Current.IsNil {
+ break
}
- break
+ ref2 := Current.ValueOf.Elem().Interface()
+ if valueTypes.IsNil(ref2) {
+ break
+ }
+ Current.SetByFieldName(Current.Interface, ref2, "")
+ if Current.IsNil {
+ break
+ }
+
+ // DO NOT BREAK!
+ // KEEP FIRST!
}
- if vo.Kind() == reflect.Array {
- fmt.Println("reflect.Array")
- if vo.Len() > 0 {
- dss.GetPointTags(parentRef, vo.Index(0).Interface(), name...)
+ if Current.Kind == reflect.Slice {
+ // Handle slices here.
+ if Current.Length == 0 {
+ if Current.DataStructure.PointIgnoreZero {
+ break
+ }
}
- break
- }
- if vo.Kind() == reflect.Map {
- fmt.Println("reflect.Map")
- mk := vo.MapKeys()
- if len(mk) > 0 {
- dss.GetPointTags(parentRef, vo.MapIndex(mk[0]).Interface(), name...)
+ if Parent.DataStructure.PointIgnoreIfNilFromChild != "" {
+ ret := GetStringFrom(Current.Interface, Parent.DataStructure.PointIgnoreIfNilFromChild)
+ if ret == "" {
+ break
+ }
}
- break
- }
- if vo.Kind() == reflect.Pointer {
- // We're going to change the pointer to a proper object reference.
- if valueTypes.IsNil(ref) {
+ if Current.DataStructure.PointArrayFlatten != "" {
+ // We want to flatten a slice down to EG "[1, 2, 3]"
+ Current.DataStructure.Value = valueTypes.AnyToValueString(Current.FieldVo.Interface(), 0, "")
+ Current.DataStructure.Endpoint = strings.Join(name, ".") // + "." + Current.DataStructure.PointId
+ dss.Add(Current.DataStructure)
break
}
- ref = vo.Elem().Interface()
- if valueTypes.IsNil(ref) {
+
+ if Current.IsUnknown {
+ for si := 0; si < Current.Length; si++ {
+ // @TODO - Need to cover types other than struct that may be referenced.
+
+ var Child Reflect
+ Child.SetByIndex(Current.Interface, si)
+ name3 := Current.setPointName(Parent.Interface, Child.Interface, name, si)
+ dss.GetPointTags(Current, Child, name3...)
+ }
break
}
- to = reflect.TypeOf(ref)
- vo = reflect.ValueOf(ref)
- // Or we could just call ourselves - either way works.
- // dss.GetPointTags(parentRef, fieldVo.Interface(), name...)
- // continue
- }
+ // Flatten slice for []Integer / []Float objects.
+ Current.DataStructure.Value = valueTypes.AnyToValueString(Current.Interface, 0, "")
+ Current.DataStructure.Endpoint = strings.Join(name, ".")
+ dss.Add(Current.DataStructure)
+ break
+ }
- // Iterate over all available fields and read the tag value
- for i := 0; i < vo.NumField(); i++ {
- fieldTo := to.Field(i)
- fieldVo := vo.Field(i)
- // fmt.Printf("START:\nref: %v\nfieldTo: %v\nfieldVo: %v\n", ref, fieldTo, fieldVo)
-
- if fieldVo.Kind() == reflect.Pointer {
- // We're going to change the pointer to a proper object reference.
- if valueTypes.IsNil(fieldVo.Interface()) {
- continue
+ if Current.Kind == reflect.Array {
+ // Handle arrays here.
+ if Current.Length == 0 {
+ if Current.DataStructure.PointIgnoreZero {
+ break
}
- ref = fieldVo.Elem().Interface()
- if valueTypes.IsNil(ref) {
- continue
- }
- to = reflect.TypeOf(ref)
- vo = reflect.ValueOf(ref)
- i = 0
- fieldTo = to.Field(i)
- fieldVo = vo.Field(i)
- // Or we could just call ourselves - either way works.
- // dss.GetPointTags(parentRef, fieldVo.Interface(), name...)
- // continue
}
- if !fieldTo.IsExported() {
- fmt.Printf("DEBUG: NOTEXPORTED(%s): Type %s\n", name, fieldTo.Name)
- continue
+ if Parent.DataStructure.PointIgnoreIfNilFromChild != "" {
+ ret := GetStringFrom(Current.Interface, Parent.DataStructure.PointIgnoreIfNilFromChild)
+ if ret == "" {
+ break
+ }
}
- pointJson := getJsonTag(fieldTo)
- pointId := fieldTo.Tag.Get(PointId)
- if pointId == "" {
- pointId = pointJson
+ if Current.DataStructure.PointArrayFlatten != "" {
+ // We want to flatten a slice down to EG "[1, 2, 3]"
+ Current.DataStructure.Value = valueTypes.AnyToValueString(Current.FieldVo.Interface(), 0, "")
+ Current.DataStructure.Endpoint = strings.Join(name, ".") // + "." + Current.DataStructure.PointId
+ dss.Add(Current.DataStructure)
+ break
}
- // fmt.Printf("DEBUG[%d]: %s.%s: Key[%s]:\tKind:'%s' Type:'%s'\n",
- // len(dss.Map),
- // strings.Join(name, "."), pointId,
- // fieldTo.Name,
- // fieldVo.Kind(),
- // fieldTo.Type.String(),
- // )
-
- switch fieldVo.Kind() {
- case reflect.Uintptr:
- fallthrough
- case reflect.Complex64:
- fallthrough
- case reflect.Complex128:
- fallthrough
- case reflect.Chan:
- fallthrough
- case reflect.Func:
- fallthrough
- case reflect.UnsafePointer:
- fmt.Printf("Unsupported type: '%s.%s' (%s)\n", name, pointId, fieldVo.Type().String())
- continue
+ if Current.IsUnknown {
+ for si := 0; si < Current.Length; si++ {
+ // @TODO - Need to cover types other than struct that may be referenced.
- case reflect.Pointer:
- if valueTypes.IsNil(fieldVo.Interface()) {
- continue
- }
- // Convert pointer to object just be calling ourselves.
- dss.GetPointTags(parentRef, fieldVo.Interface(), name...)
-
- case reflect.Slice:
- // Handle slices here.
- // Adds more Point* tags - PointNameFromChild, PointNameDateFormat
- // Replicates the JoinWithDots 1st and 2nd arguments.
- // intSize int, dateFormat string
- // fmt.Printf("Kind: %s ##########################################\n", fieldVo.Kind().String())
- pointNameFromChild := fieldTo.Tag.Get(PointNameFromChild)
- pointNameFromParent := fieldTo.Tag.Get(PointNameFromParent)
- pointNameDateFormat := fieldTo.Tag.Get(PointNameDateFormat)
- intSize := valueTypes.SizeOfInt(fieldVo.Len())
- ft := valueTypes.GetIntFormatForPrintf(fieldVo.Len())
- pointArrayFlatten := fieldTo.Tag.Get(PointArrayFlatten)
- n2 := append(name, pointId)
-
- if pointArrayFlatten != "" {
- // We want to flatten a slice down to EG "[1, 2, 3]"
- endPointName, ds := makeDataStructure(parentRef, fieldTo, fieldVo, name)
- ds.Value = valueTypes.AnyToValueString(fieldVo.Interface(), 0, "")
- dss.Add(endPointName + "." + ds.PointId, ds)
- continue
- }
+ var Child Reflect
+ Child.SetByIndex(Current.Interface, si)
+ name3 := Current.setPointName(Parent.Interface, Child.Interface, name, si)
+ dss.GetPointTags(Current, Child, name3...)
+ }
+ break
+ }
- if valueTypes.IsUnknownStruct(fieldVo.Interface()) {
- for si := 0; si < fieldVo.Len(); si++ {
- // Are we using an index number for name or field key value?
- pn := fmt.Sprintf(ft, si)
- n3 := append(n2, pn)
- if pointNameFromChild != "" {
- // PointNameFromChild - In this case points to a field within a CHILD struct.
- pn = GetPointNameFrom(fieldVo.Index(si).Interface(), pointNameFromChild, intSize, pointNameDateFormat)
- n3 = append(n2[:len(n2) - 1], pn)
- }
- if pointNameFromParent != "" {
- // PointNameFromChild - In this case points to a field within a CHILD struct.
- pn = GetPointNameFrom(fieldVo.Interface(), pointNameFromParent, intSize, pointNameDateFormat)
- n3 = append(n2[:len(n2) - 1], pn)
- }
-
- dss.GetPointTags(fieldVo.Index(si).Interface(), fieldVo.Index(si).Interface(), n3...)
- }
- continue
- }
+ // Flatten slice for []Integer / []Float objects.
+ Current.DataStructure.Value = valueTypes.AnyToValueString(Current.Interface, 0, "")
+ Current.DataStructure.Endpoint = strings.Join(name, ".")
+ dss.Add(Current.DataStructure)
+ break
+ }
- // Flatten slice for []Integer / []Float objects.
- endPointName, ds := makeDataStructure(parentRef, fieldTo, fieldVo, name)
- ds.Value = valueTypes.AnyToValueString(fieldVo.Interface(), 0, "")
- dss.Add(endPointName + "." + ds.PointId, ds)
-
- // This commented-out section can handle []Integer fields.
- // for si := 0; si < fieldVo.Len(); si++ {
- // // Are we using an index number for name or field key value?
- // pn := strconv.Itoa(si)
- // n3 := append(n2, pn)
- // if pointNameFromChild != "" {
- // // PointNameFromChild - In this case points to a field within a CHILD struct.
- // pn = GetPointNameFrom(fieldVo.Index(si).Interface(), pointNameFromChild, intSize, pointNameDateFormat)
- // n3 = append(n2[:len(n2) - 1], pn)
- // }
- // if pointNameFromParent != "" {
- // // PointNameFromChild - In this case points to a field within a CHILD struct.
- // pn = GetPointNameFrom(fieldVo.Interface(), pointNameFromParent, intSize, pointNameDateFormat)
- // n3 = append(n2[:len(n2) - 1], pn)
- // }
- //
- // if valueTypes.IsUnknownStruct(fieldVo.Index(si).Interface()) {
- // dss.GetPointTags(fieldVo.Index(si).Interface(), fieldVo.Index(si).Interface(), n3...)
- // continue
- // }
- //
- // // // We want to flatten a slice down to EG "[1, 2, 3]"
- // // endPointName, ds := makeDataStructure(parentRef, fieldTo, fieldVo, n2)
- // // ds.Value = valueTypes.AnyToValueString(fieldVo.Interface(), 0, "")
- // // dss.Add(endPointName + "." + pn, ds)
- // endPointName, ds := makeDataStructure(parentRef, fieldTo, fieldVo, n3)
- // // ds.Json = pointId + pn
- // ds.PointId = pn
- // val := fieldVo.Index(si)
- // ds.Value = val.Interface()
- // dss.Add(endPointName, ds)
- // }
- continue
+ if Current.Kind == reflect.Map {
+ if Current.Length == 0 {
+ if Current.DataStructure.PointIgnoreZero {
+ break
+ }
+ }
- case reflect.Array:
- // @TODO - Handle arrays here.
- // Adds more Point* tags - PointNameFromChild, PointNameDateFormat
- // Replicates the JoinWithDots 1st and 2nd arguments.
- // intSize int, dateFormat string
- // fmt.Printf("Kind: %s ##########################################\n", fieldVo.Kind().String())
- pointNameFromChild := fieldTo.Tag.Get(PointNameFromChild)
- pointNameFromParent := fieldTo.Tag.Get(PointNameFromParent)
- pointNameDateFormat := fieldTo.Tag.Get(PointNameDateFormat)
- intSize := valueTypes.SizeOfInt(fieldVo.Len())
- ft := valueTypes.GetIntFormatForPrintf(fieldVo.Len())
- pointArrayFlatten := fieldTo.Tag.Get(PointArrayFlatten)
- n2 := append(name, pointId)
-
- if pointArrayFlatten != "" {
- // We want to flatten a slice down to EG "[1, 2, 3]"
- endPointName, ds := makeDataStructure(parentRef, fieldTo, fieldVo, name)
- ds.Value = valueTypes.AnyToValueString(fieldVo.Interface(), 0, "")
- dss.Add(endPointName + "." + ds.PointId, ds)
- continue
- }
+ if Parent.DataStructure.PointIgnoreIfNilFromChild != "" {
+ ret := GetStringFrom(Current.Interface, Parent.DataStructure.PointIgnoreIfNilFromChild)
+ if ret == "" {
+ break
+ }
+ }
- for si := 0; si < fieldVo.Len(); si++ {
- // Are we using an index number for name or field key value?
- pn := fmt.Sprintf(ft, si)
- n3 := append(n2, pn)
- if pointNameFromChild != "" {
- // PointNameFromChild - In this case points to a field within a CHILD struct.
- pn = GetPointNameFrom(fieldVo.Index(si).Interface(), pointNameFromChild, intSize, pointNameDateFormat)
- n3 = append(n2[:len(n2) - 1], pn)
- }
- if pointNameFromParent != "" {
- // PointNameFromChild - In this case points to a field within a CHILD struct.
- pn = GetPointNameFrom(fieldVo.Interface(), pointNameFromParent, intSize, pointNameDateFormat)
- n3 = append(n2[:len(n2) - 1], pn)
- }
+ Parent.SetByFieldName(Parent.Interface, Current.Interface, "")
+ // n2 := append(name, Current.DataStructure.PointId)
+ for _, key := range Current.FieldVo.MapKeys() {
+ // @TODO - Implement pointNameFromChild / pointNameFromParent.
+ Current.DataStructure.Json = key.String()
+ Current.DataStructure.PointId = key.String()
+ 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)
+ }
+ break
+ }
- if valueTypes.IsUnknownStruct(fieldVo.Index(si).Interface()) {
- dss.GetPointTags(fieldVo.Index(si).Interface(), fieldVo.Index(si).Interface(), n3...)
- continue
- }
+ if Current.Kind == reflect.Struct {
+ if Current.Length == 0 {
+ if Current.DataStructure.PointIgnoreZero {
+ break
+ }
+ }
- // // We want to flatten a slice down to EG "[1, 2, 3]"
- // endPointName, ds := makeDataStructure(parentRef, fieldTo, fieldVo, n2)
- // ds.Value = valueTypes.AnyToValueString(fieldVo.Interface(), 0, "")
- // dss.Add(endPointName + "." + pn, ds)
- endPointName, ds := makeDataStructure(parentRef, fieldTo, fieldVo, n3)
- // ds.Json = pointId + pn
- ds.PointId = pointId + pn
- val := fieldVo.Index(si)
- ds.Value = val.Interface()
- dss.Add(endPointName, ds)
- }
+ if Parent.DataStructure.PointIgnoreIfNilFromChild != "" {
+ ret := GetStringFrom(Current.Interface, Parent.DataStructure.PointIgnoreIfNilFromChild)
+ if ret == "" {
+ break
+ }
+ }
- // @TODO - Can't quite figure out what to do here. So will just flatten the array.
- // for si := 0; si < fieldVo.Len(); si++ {
- // // Are we using an index number for name or field key value?
- // pn := strconv.Itoa(si)
- // n3 := append(name) // , pointId + pn)
- // if pointNameFrom != "" {
- // pn = GetPointNameFromChild(parentRef, pointNameFrom, intSize, pointNameDateFormat)
- // n3 = append(n2[:len(n2) - 1], pn)
- // }
- //
- // endPointName, ds := makeDataStructure(parentRef, fieldTo, fieldVo, n3)
- // // ds.Json = pointId + pn
- // ds.PointId = pointId + pn
- // val := fieldVo.Index(si)
- // ds.Value = val.Interface()
- // dss.Add(endPointName, ds)
- // }
- continue
+ 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)
+ name2 := append(name, Child.DataStructure.PointId)
- case reflect.Map:
- // fmt.Printf("Kind: %s ##########################################\n", fieldVo.Kind().String())
- n2 := append(name, pointId)
- // pointNameFromChild := fieldTo.Tag.Get(PointNameFromChild)
- // pointNameFromParent := fieldTo.Tag.Get(PointNameFromParent)
-
- for _, key := range fieldVo.MapKeys() {
- // @TODO - Implement this.
- // if pointNameFromChild != "" {
- // // PointNameFromChild - In this case points to a field within a CHILD struct.
- // pn = GetPointNameFrom(fieldVo.Index(si).Interface(), pointNameFromChild, intSize, pointNameDateFormat)
- // n3 = append(n2[:len(n2) - 1], pn)
- // }
- // if pointNameFromParent != "" {
- // // PointNameFromChild - In this case points to a field within a CHILD struct.
- // pn = GetPointNameFrom(fieldVo.Interface(), pointNameFromParent, intSize, pointNameDateFormat)
- // n3 = append(n2[:len(n2) - 1], pn)
- // }
-
- endPointName, ds := makeDataStructure(fieldVo.Interface(), fieldTo, fieldVo, n2)
- ds.Json = key.String()
- ds.PointId = key.String()
- val := fieldVo.MapIndex(key)
- ds.Value = val.Interface()
- dss.Add(endPointName + "." + ds.PointId, ds)
- }
+ if !Child.IsExported {
+ fmt.Printf("DEBUG: NOTEXPORTED(%s): Type %s\n", name, Child.FieldName)
continue
+ }
+
+ // fmt.Printf("DEBUG[%d]: %s.%s: Key[%s]:\tKind:'%s' Type:'%s'\n",
+ // len(dss.Map),
+ // strings.Join(name, "."), pointId,
+ // fieldTo.Name,
+ // fieldVo.Kind(),
+ // fieldTo.Type.String(),
+ // )
- case reflect.Struct:
- // fmt.Printf("Kind: %s ##########################################\n", fieldVo.Kind().String())
- if valueTypes.IsUnknownStruct(fieldVo.Interface()) {
- n2 := append(name, pointId)
- dss.GetPointTags(parentRef, fieldVo.Interface(), n2...)
+ if Child.Kind == reflect.Struct {
+ if Child.IsUnknown {
+ dss.GetPointTags(Current, Child, name2...)
continue
}
- // fmt.Printf("[%s.%s] => %v\n", strings.Join(name, "."), pointId, fieldVo.Interface())
- endPointName, ds := makeDataStructure(parentRef, fieldTo, fieldVo, name)
- ds.Value = fieldVo.Interface()
- dss.Add(endPointName + "." + ds.PointId, ds)
+ Child.DataStructure.Value = Child.Interface
+ Child.DataStructure.Endpoint = strings.Join(name, ".") + "." + Child.DataStructure.PointId
+ dss.Add(Child.DataStructure)
continue
+ }
- default:
- // endPointName, ds := makeDataStructure(parentRef, fieldTo, fieldVo, name)
- // ds.Value = fieldVo.Interface()
- // dss.Add(endPointName + "." + ds.PointId, ds)
- }
-
- endPointName, ds := makeDataStructure(parentRef, fieldTo, fieldVo, name)
- ds.Value = fieldVo.Interface()
- dss.Add(endPointName + "." + ds.PointId, ds)
- }
- }
-
- return *dss
-}
-
-func GetUnitFrom(ref interface{}, pointUnitFrom string) string {
- var ret string
- for range Only.Once {
- vo := reflect.ValueOf(ref)
- if vo.Kind() != reflect.Struct {
- break
- }
+ switch Child.Kind {
+ case reflect.Uintptr:
+ fallthrough
+ case reflect.Complex64:
+ fallthrough
+ case reflect.Complex128:
+ fallthrough
+ case reflect.Chan:
+ fallthrough
+ case reflect.Func:
+ fallthrough
+ case reflect.Map:
+ fallthrough
+ case reflect.Pointer:
+ fallthrough
+ case reflect.Slice:
+ fallthrough
+ case reflect.Array:
+ fallthrough
+ case reflect.UnsafePointer:
+ dss.GetPointTags(Current, Child, name2...)
+ continue
- // Iterate over all available fields, looking for the field name.
- for i := 0; i < vo.NumField(); i++ {
- if vo.Type().Field(i).Name != pointUnitFrom {
- continue
+ default:
+ // @TODO - Need to fix this!
+ // This parses ordinary builtin types.
+ Child.DataStructure.Value = Child.Interface
+ Child.DataStructure.Endpoint = strings.Join(name, ".") + "." + Child.DataStructure.PointId
+ dss.Add(Child.DataStructure)
+ }
}
-
- // fmt.Printf("GetUnitFrom: %v\n", fieldVo.Interface())
- ret = valueTypes.AnyToValueString(vo.Field(i).Interface(), 0, "")
break
}
+
+ fmt.Printf("ERROR: Unsupported type: '%s.%s' (%s)\n", name, Current.DataStructure.PointId, Current.FieldVo.Type().String())
}
- return ret
+ return *dss
}
-func GetGroupNameFrom(ref interface{}, pointGroupNameFrom string) string {
+
+func GetStringFrom(ref interface{}, name string) string {
var ret string
for range Only.Once {
vo := reflect.ValueOf(ref)
- if vo.Kind() != reflect.Struct {
- break
- }
- // Iterate over all available fields, looking for the field name.
- for i := 0; i < vo.NumField(); i++ {
- if vo.Type().Field(i).Name != pointGroupNameFrom {
- continue
- }
+ switch vo.Kind() {
+ case reflect.Struct:
+ // Iterate over all available fields, looking for the field name.
+ for i := 0; i < vo.NumField(); i++ {
+ if vo.Type().Field(i).Name == name {
+ ret = valueTypes.AnyToValueString(vo.Field(i).Interface(), 0, "")
+ break
+ }
+ }
- // fmt.Printf("GetGroupNameFrom: %v\n", fieldVo.Interface())
- ret = valueTypes.AnyToValueString(vo.Field(i).Interface(), 0, "")
- break
+ case reflect.Map:
+ // Iterate over all available fields, looking for the field name.
+ for _, key := range vo.MapKeys() {
+ if key.String() == name {
+ ret = valueTypes.AnyToValueString(vo.MapIndex(key).Interface(), 0, "")
+ break
+ }
+ }
}
}
return ret
}
-func GetTimestampFrom(ref interface{}, pointTimestampFrom string, dateFormat string) time.Time {
+func GetTimestampFrom(ref interface{}, name string, dateFormat string) time.Time {
var ret time.Time
for range Only.Once {
if dateFormat == "" {
dateFormat = valueTypes.DateTimeAltLayout
}
-
vo := reflect.ValueOf(ref)
- if vo.Kind() != reflect.Struct {
- break
- }
- // Iterate over all available fields, looking for the field name.
- for i := 0; i < vo.NumField(); i++ {
- if vo.Type().Field(i).Name != pointTimestampFrom {
- continue
- }
+ switch vo.Kind() {
+ case reflect.Struct:
+ // Iterate over all available fields, looking for the field name.
+ for i := 0; i < vo.NumField(); i++ {
+ if vo.Type().Field(i).Name == name {
+ v := fmt.Sprintf("%v", vo.Field(i).Interface())
+ ret = valueTypes.SetDateTimeString(v).Time
+ break
+ }
+ }
- // fmt.Printf("GetTimestampFrom: %v\n", fieldVo.Interface())
- foo2 := fmt.Sprintf("%v", vo.Field(i).Interface())
- ret = valueTypes.SetDateTimeString(foo2).Time
- break
+ case reflect.Map:
+ // Iterate over all available fields, looking for the field name.
+ for _, key := range vo.MapKeys() {
+ if key.String() == name {
+ v := fmt.Sprintf("%v", vo.MapIndex(key).Interface())
+ ret = valueTypes.SetDateTimeString(v).Time
+ break
+ }
+ }
}
}
return ret
}
-func GetPointNameFrom(ref interface{}, pointNameFrom string, intSize int, dateFormat string) string {
+func GetPointNameFrom(ref interface{}, name string, intSize int, dateFormat string) string {
var ret string
for range Only.Once {
if dateFormat == "" {
dateFormat = valueTypes.DateTimeAltLayout
}
vo := reflect.ValueOf(ref)
- if vo.Kind() != reflect.Struct {
- break
- }
var ra []string
- for _, pnf := range strings.Split(pointNameFrom, ".") {
- // Iterate over all available fields, looking for the field name.
- for i := 0; i < vo.NumField(); i++ {
- // fmt.Printf("GetPointNameFrom[%d]:%s\n", i, vo.Type().Field(i).Name)
- if vo.Type().Field(i).Name != pnf {
- continue
+ switch vo.Kind() {
+ case reflect.Struct:
+ 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 {
+ ra = append(ra, valueTypes.AnyToValueString(vo.Field(i).Interface(), intSize, dateFormat))
+ break
+ }
+ }
}
- // fmt.Printf("GetPointNameFrom: %v\n", fieldVo.Interface())
- ra = append(ra, valueTypes.AnyToValueString(vo.Field(i).Interface(), intSize, dateFormat))
- // fmt.Printf("GetPointNameFrom[%d] = %v\n", i, vo.Field(i).Interface())
- break
- }
+ case reflect.Map:
+ for _, pnf := range strings.Split(name, ".") {
+ // Iterate over all available fields, looking for the field name.
+ for _, key := range vo.MapKeys() {
+ if key.String() == pnf {
+ ra = append(ra, valueTypes.AnyToValueString(vo.MapIndex(key).Interface(), intSize, dateFormat))
+ break
+ }
+ }
+ }
}
ret = strings.Join(ra, ".")
}
@@ -547,108 +994,6 @@ func getJsonTag(fieldTo reflect.StructField) string {
return ret
}
-func makeDataStructure(parentRef interface{}, fieldTo reflect.StructField, fieldVo reflect.Value, name []string) (string, DataStructure) {
- var endpoint string
- var ds DataStructure
-
- for range Only.Once {
- if !fieldTo.IsExported() {
- fmt.Printf("DEBUG: NOTEXPORTED(%s): %s\n", fieldTo.Name, getJsonTag(fieldTo))
- break
- }
-
- ignore := false
- if fieldTo.Tag.Get(PointIgnore) != "" {
- ignore = true
- }
-
- // if valueTypes.IsNil(ref) {
- // pointValueType = "NIL"
- // }
-
- pointJson := getJsonTag(fieldTo)
- pointId := fieldTo.Tag.Get(PointId)
- if pointId == "" {
- pointId = pointJson
- }
-
- pointValueType := fieldTo.Tag.Get(PointValueType)
- if pointValueType == "" {
- // pointValueType = fieldVo.Kind().String()
- }
-
- pointUnit := fieldTo.Tag.Get(PointUnit)
- pointUnitFrom := fieldTo.Tag.Get(PointUnitFrom)
- if pointUnitFrom != "" {
- pointUnit = GetUnitFrom(parentRef, pointUnitFrom)
- }
-
- pointGroupName := fieldTo.Tag.Get(PointGroupName)
- pointGroupNameFrom := fieldTo.Tag.Get(PointGroupNameFrom)
- if pointGroupNameFrom != "" {
- pointGroupName = GetGroupNameFrom(parentRef, pointGroupNameFrom)
- }
-
- pointTimestamp := time.Now()
- pointTimestampFrom := fieldTo.Tag.Get(PointTimestampFrom)
- if pointTimestampFrom != "" {
- pointTimestamp = GetTimestampFrom(parentRef, pointTimestampFrom, valueTypes.DateTimeLayout)
- }
-
- endpoint = strings.TrimPrefix(strings.Join(name, "."), ".")
-
- ds = DataStructure {
- // PointType: fieldTo.Tag.Get(PointType),
- Json: pointJson,
- PointId: pointId,
- PointParentId: fieldTo.Tag.Get(PointParentId),
-
- PointUnit: pointUnit,
- PointUnitFrom: pointUnitFrom,
-
- PointTimestamp: pointTimestamp,
- PointTimestampFrom: pointTimestampFrom,
-
- PointGroupName: pointGroupName,
- PointGroupNameFrom: pointGroupNameFrom,
-
- PointName: fieldTo.Tag.Get(PointName),
- PointUpdateFreq: fieldTo.Tag.Get(PointUpdateFreq),
- PointValueType: pointValueType,
- PointAliasTo: fieldTo.Tag.Get(PointAliasTo),
- PointIgnore: ignore,
- Value: nil,
- ValueType: fieldTo.Type.String(),
- ValueKind: fieldVo.Kind().String(),
- Endpoint: endpoint,
- }
- }
-
- return endpoint, ds
-}
-
-// func (dss *DataStructures) GetUnitFrom(ref ...string) string {
-// var ret string
-// for range Only.Once {
-// r := strings.Join(ref, ".")
-// if s, ok := dss.Map[r]; ok {
-// ret = s.PointUnit
-// }
-// }
-// return ret
-// }
-//
-// func (dss *DataStructures) GetPointGroupNameFrom(ref ...string) string {
-// var ret string
-// for range Only.Once {
-// r := strings.Join(ref, ".")
-// if s, ok := dss.Map[r]; ok {
-// ret = s.PointUnit
-// }
-// }
-// return ret
-// }
-
// GetArea Return an Area name if we are given an Area or EndPoint struct.
func GetArea(trim string, v interface{}) string {
@@ -1254,8 +1599,23 @@ func hash(s string) uint32 {
return h.Sum32()
}
+
type Required []string
+func (r *Required) IsRequired(field string) bool {
+ var ok bool
+ for _, f := range *r {
+ if f == field {
+ ok = true
+ }
+ }
+ return ok
+}
+
+func (r *Required) IsNotRequired(field string) bool {
+ return !r.IsRequired(field)
+}
+
//goland:noinspection GoUnusedFunction,GoUnusedExportedFunction
func GetOptionsRequired(ref interface{}) Required {
var ret []string
@@ -1276,6 +1636,7 @@ func GetOptionsRequired(ref interface{}) Required {
return ret
}
+
type StructKey struct {
Name string
JsonName string
@@ -1340,17 +1701,3 @@ func GetStructKeys(ref interface{}, keys ...string) StructKeys {
return ret
}
-
-func (r *Required) IsRequired(field string) bool {
- var ok bool
- for _, f := range *r {
- if f == field {
- ok = true
- }
- }
- return ok
-}
-
-func (r *Required) IsNotRequired(field string) bool {
- return !r.IsRequired(field)
-}
diff --git a/iSolarCloud/api/struct_data.go b/iSolarCloud/api/struct_data.go
index cbda54e1a..bf27d1ece 100644
--- a/iSolarCloud/api/struct_data.go
+++ b/iSolarCloud/api/struct_data.go
@@ -42,7 +42,9 @@ func (dm *DataMap) StructToPoints(ref interface{}, endpoint string, parentId str
// Iterate over all available fields and read the tag values
var tp apiReflect.DataStructures
- tp.GetPointTags(ref, ref, endpoint)
+ var Ref apiReflect.Reflect
+ Ref.SetByFieldName(ref, ref, "")
+ tp.GetPointTags(Ref, Ref, endpoint)
for _, f := range tp.Map {
if f.PointIgnore {
@@ -224,7 +226,7 @@ func (dm *DataMap) CopyDataEntries(dep DataEntries, endpoint string, pointId str
dm.Add(des.Entries[i])
}
- epn := des.Entries[0].EndPoint + "." + des.Entries[0].Point.Id.String()
+ epn := des.Entries[0].EndPoint // + "." + des.Entries[0].Point.Id.String()
ret = dm.Map[epn]
}
return ret
diff --git a/iSolarCloud/api/struct_de.go b/iSolarCloud/api/struct_de.go
index 41c9b73cb..214a23b06 100644
--- a/iSolarCloud/api/struct_de.go
+++ b/iSolarCloud/api/struct_de.go
@@ -39,11 +39,11 @@ func (de *DataEntry) IsNotValid() bool {
}
func (de *DataEntry) FullId() string {
- return de.EndPoint + "." + de.Point.Id.String()
+ return de.EndPoint // + "." + de.Point.Id.String()
}
func (de *DataEntry) SetEndpoint(endpoint string, pointId string) {
- de.EndPoint = endpoint // + "." + pointId
+ de.EndPoint = endpoint + "." + pointId
de.Point.Id.SetString(pointId)
}
diff --git a/iSolarCloud/api/valueTypes/types.go b/iSolarCloud/api/valueTypes/types.go
index 7f0f6cb07..77d07bb92 100644
--- a/iSolarCloud/api/valueTypes/types.go
+++ b/iSolarCloud/api/valueTypes/types.go
@@ -57,6 +57,7 @@ const (
TypeValueTypesUnitValue = "valueTypes.UnitValue"
)
+
func IsUnknownStruct(ref interface{}) bool {
var ok bool
@@ -70,22 +71,28 @@ func IsUnknownStruct(ref interface{}) bool {
// fmt.Printf("fieldTo.Name(): %s\n", fieldTo.Name())
// fmt.Printf("fieldTo.Kind().String(): %s\n", fieldTo.Kind().String())
- // fmt.Printf("DEBUYg: K:%s / T:%s\n", fieldVo.Kind().String(), fieldVo.Type().String())
- if fieldVo.Kind() == reflect.Slice {
+ kindy := fieldVo.Kind()
+ // fmt.Printf("DEBUYg: K:%s / T:%v\n", kindy.String(), fieldVo)
+ if kindy == reflect.Interface {
+ ok = false
+ break
+ }
+
+ if kindy == reflect.Slice {
if fieldVo.Len() > 0 {
ok = IsUnknownStruct(fieldVo.Index(0).Interface())
}
break
}
- if fieldVo.Kind() == reflect.Array {
+ if kindy == reflect.Array {
if fieldVo.Len() > 0 {
ok = IsUnknownStruct(fieldVo.Index(0).Interface())
}
break
}
- if fieldVo.Kind() == reflect.Map {
+ if kindy == reflect.Map {
mk := fieldVo.MapKeys()
if len(mk) > 0 {
ok = IsUnknownStruct(fieldVo.MapIndex(mk[0]).Interface())
@@ -93,7 +100,7 @@ func IsUnknownStruct(ref interface{}) bool {
break
}
- if fieldVo.Kind() == reflect.Struct {
+ if kindy == reflect.Struct {
switch fieldVo.Type().String() {
case TypeBool:
case TypeCount:
@@ -879,7 +886,12 @@ func AnyToValueString(e interface{}, intSize int, dateFormat string) string {
case TypeValueTypesDateTime:
fallthrough
case TypeDateTime:
- ret = e.(DateTime).Format(dateFormat)
+ v := e.(DateTime)
+ if v.IsZero() {
+ ret = ""
+ break
+ }
+ ret = v.Format(dateFormat)
case TypeArrayValueTypesDateTime:
fallthrough
@@ -894,7 +906,12 @@ func AnyToValueString(e interface{}, intSize int, dateFormat string) string {
case TypeValueTypesTime:
fallthrough
case TypeTime:
- ret = e.(Time).Format(dateFormat)
+ v := e.(Time)
+ if v.IsZero() {
+ ret = ""
+ break
+ }
+ ret = v.Format(dateFormat)
default:
}
diff --git a/iSolarCloud/data.go b/iSolarCloud/data.go
index 4f435188f..73f10e11f 100644
--- a/iSolarCloud/data.go
+++ b/iSolarCloud/data.go
@@ -575,7 +575,7 @@ func (sg *SunGrowData) getHouseholdStoragePsReport(request SunGrowDataRequest) S
return response
}
-// @TODO -
+// @TODO - Not working
func (sg *SunGrowData) getPowerStationBasicInfo(request SunGrowDataRequest) SunGrowDataResponse {
var response SunGrowDataResponse
for range Only.Once {
@@ -711,6 +711,7 @@ func (sg *SunGrowData) getPsHealthState(request SunGrowDataRequest) SunGrowDataR
return response
}
+// @TODO - Figure out how to properly flatten some of these "two field" arrays.
func (sg *SunGrowData) powerDevicePointList(request SunGrowDataRequest) SunGrowDataResponse {
var response SunGrowDataResponse
for range Only.Once {
@@ -733,7 +734,6 @@ func (sg *SunGrowData) powerDevicePointList(request SunGrowDataRequest) SunGrowD
return response
}
-
func (sg *SunGrowData) getPsWeatherList(request SunGrowDataRequest) SunGrowDataResponse {
var response SunGrowDataResponse
for range Only.Once {
@@ -756,12 +756,13 @@ func (sg *SunGrowData) getPsWeatherList(request SunGrowDataRequest) SunGrowDataR
return response
}
+// @TODO - Not working
func (sg *SunGrowData) getRemoteUpgradeTaskList(request SunGrowDataRequest) SunGrowDataResponse {
var response SunGrowDataResponse
for range Only.Once {
ep := sg.SunGrow.GetByStruct(
"AppService.getRemoteUpgradeTaskList",
- getRemoteUpgradeTaskList.RequestData{ }, // PsId: request.PsId },
+ getRemoteUpgradeTaskList.RequestData{ PsIdList: "1171348,1121412"}, // PsId: request.PsId },
api.DefaultTimeout,
)