Skip to content

Commit

Permalink
v2.3.2 - Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
MickMake committed Oct 19, 2022
1 parent 02151a6 commit 371e2d6
Show file tree
Hide file tree
Showing 26 changed files with 792 additions and 1,006 deletions.
172 changes: 68 additions & 104 deletions .idea/workspace.xml

Large diffs are not rendered by default.

30 changes: 7 additions & 23 deletions iSolarCloud/AppService/findPsType/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,18 @@ 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)
for _, d := range e.Response.ResultData {
name := fmt.Sprintf("%s.%s", pkg, e.Request.PsId.String())
entries.StructToPoints(d, name, e.Request.PsId.String(), valueTypes.NewDateTime(""))
}
dt := valueTypes.NewDateTime(valueTypes.Now)
entries.StructToPoints(e.Response.ResultData, pkg, "", dt)

// for _, d := range e.Response.ResultData {
// name := fmt.Sprintf("%s.%s", pkg, e.Request.PsId.String())
// entries.StructToPoints(d, name, e.Request.PsId.String(), dt)
// }
}

return entries
Expand Down
27 changes: 3 additions & 24 deletions iSolarCloud/AppService/getAllDeviceByPsId/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,13 @@ 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)
// for _, d := range e.Response.ResultData {
// name := fmt.Sprintf("findPsType.%s", e.Request.PsId.String())
// entries.StructToPoints(d, name, e.Request.PsId.String(), valueTypes.NewDateTime(""))
// }
pkg := apiReflect.GetName("", *e)
dt := valueTypes.NewDateTime(valueTypes.Now)
entries.StructToPoints(e.Response.ResultData, pkg, "", dt)
}

return entries
Expand Down
28 changes: 16 additions & 12 deletions iSolarCloud/AppService/getDeviceList/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (rd RequestData) Help() string {

type ResultData struct {
PageList []struct {
AttrID valueTypes.Integer `json:"attr_id"`
AttrId valueTypes.Integer `json:"attr_id"`
ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id"`
CommandStatus valueTypes.Integer `json:"command_status"`
ConnectState valueTypes.Integer `json:"connect_state"`
Expand All @@ -41,9 +41,9 @@ type ResultData struct {
DeviceID valueTypes.Integer `json:"device_id"`
DeviceModel valueTypes.String `json:"device_model"`
DeviceModelCode valueTypes.String `json:"device_model_code"`
DeviceModelID valueTypes.Integer `json:"device_model_id"`
DeviceModelId valueTypes.Integer `json:"device_model_id"`
DeviceName valueTypes.String `json:"device_name"`
DeviceProSn valueTypes.String `json:"device_pro_sn"`
DeviceProSn valueTypes.String `json:"device_pro_sn" PointName:"Device Serial Number"`
DeviceState valueTypes.Integer `json:"device_state"`
DeviceSubType interface{} `json:"device_sub_type"`
DeviceSubTypeName interface{} `json:"device_sub_type_name"`
Expand All @@ -65,14 +65,14 @@ type ResultData struct {
P24 interface{} `json:"p24"`
Posx interface{} `json:"posx"`
Posy interface{} `json:"posy"`
PsID valueTypes.Integer `json:"ps_id"`
PsId valueTypes.Integer `json:"ps_id"`
PsKey valueTypes.PsKey `json:"ps_key"`
RelState valueTypes.Integer `json:"rel_state"`
Sn valueTypes.String `json:"sn" PointName:"Serial Number"`
TypeName valueTypes.String `json:"type_name"`
UUID valueTypes.Integer `json:"uuid"`
} `json:"pageList"`
RowCount valueTypes.Integer `json:"rowCount"`
} `json:"pageList" PointNameFromChild:"PsKey"`
RowCount valueTypes.Integer `json:"rowCount" PointIgnore:"true"`
}

func (e *ResultData) IsValid() error {
Expand Down Expand Up @@ -110,14 +110,14 @@ func (e *EndPoint) GetDevices() Devices {
ret = append(ret, Device{
Vendor: d.FactoryName,
PsKey: d.PsKey,
PsId: d.PsID,
PsId: d.PsId,
DeviceType: d.DeviceType,
DeviceCode: d.DeviceCode,
ChannelId: d.ChannelId,
TypeName: d.TypeName,
DeviceProSn: d.DeviceProSn,
DeviceModel: d.DeviceModel,
DeviceModelID: d.DeviceModelID,
DeviceModelID: d.DeviceModelId,
DeviceName: d.DeviceName,
DeviceState: d.DeviceState,
DevStatus: d.DevStatus,
Expand Down Expand Up @@ -264,10 +264,14 @@ func (e *EndPoint) GetData() api.DataMap {

for range Only.Once {
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(""))
}
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(""))
// }
}

return entries
Expand Down
Loading

0 comments on commit 371e2d6

Please sign in to comment.