v3.0.0-alpha - Better CLI

This commit is contained in:
MickMake 2022-12-08 14:02:58 +11:00
parent 0531cb9af0
commit b847cbbd2c
46 changed files with 2606 additions and 1093 deletions

499
.idea/workspace.xml generated
View File

@ -5,19 +5,46 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="76adadc9-ae71-42a6-82a1-66dbc8ecb14c" name="Changes" comment=""> <list default="true" id="76adadc9-ae71-42a6-82a1-66dbc8ecb14c" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/iSolarCloud/highlevel_meta.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/legacy.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/legacy.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/cmd/cmd_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/file.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/file.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/cmd/cmd_data.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/cmd_info.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_info.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/cmd_show.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_show.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/cmd_show_device.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_show_device.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/cmd_show_point.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_show_point.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/cmd_show_psid.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_show_psid.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/cmd_show_template.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_show_template.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/commands.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/commands.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/getDeviceList/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/getDeviceList/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/getPsList/funcs.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/getPsList/funcs.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceInfo/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceInfo/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceInfoForApp/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceInfoForApp/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceList/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceList/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceRealTimeDataByPsKeys/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceRealTimeDataByPsKeys/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/queryMutiPointDataList/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/queryMutiPointDataList/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/Common/images.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/Common/images.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/MttvScreenService/getPsDeviceListValue/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/MttvScreenService/getPsDeviceListValue/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/WebAppService/getDevicePointAttrs/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/WebAppService/getDevicePointAttrs/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/WebAppService/getPsTree/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/WebAppService/getPsTree/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/WebIscmAppService/queryDeviceListForBackSys/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/WebIscmAppService/queryDeviceListForBackSys/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_tables.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_tables.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/reflection/funcs.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/reflection/funcs.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/reflection/legacy.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/reflection/legacy.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_data.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_table.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_table.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_table.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_table.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/datetime.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/datetime.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/integers.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/integers.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/point.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/point.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/struct_data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/struct_data.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/iSolarCloud/api/struct_data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/struct_data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/web.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/web.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/data.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/iSolarCloud/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/data_request.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/data_request.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/highlevel.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/highlevel.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/highlevel_device.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/highlevel_device.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/highlevel_point.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/highlevel_point.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/highlevel_ps.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/highlevel_ps.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/highlevel_template.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/highlevel_template.go" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -91,7 +118,7 @@
<configuration name="GoSungrow" type="GoApplicationRunConfiguration" factoryName="Go Application"> <configuration name="GoSungrow" type="GoApplicationRunConfiguration" factoryName="Go Application">
<module name="GoSungrow" /> <module name="GoSungrow" />
<working_directory value="$PROJECT_DIR$" /> <working_directory value="$PROJECT_DIR$" />
<parameters value="data graph AppService.queryMutiPointDataList MinuteInterval:5 StartTimeStamp:20221001000000 EndTimeStamp:20221001235900 Points:1129147_14_1_1.p13145" /> <parameters value="show device points 43" />
<envs> <envs>
<env name="GOCACHE" value="/Volumes/Media/GoCache" /> <env name="GOCACHE" value="/Volumes/Media/GoCache" />
</envs> </envs>
@ -142,7 +169,7 @@
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceList/data.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceList/data.go</url>
<line>186</line> <line>189</line>
<option name="timeStamp" value="202" /> <option name="timeStamp" value="202" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
@ -157,7 +184,7 @@
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
<line>349</line> <line>350</line>
<option name="timeStamp" value="838" /> <option name="timeStamp" value="838" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
@ -167,22 +194,22 @@
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
<line>40</line> <line>39</line>
<option name="timeStamp" value="881" /> <option name="timeStamp" value="881" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
<line>217</line> <line>218</line>
<option name="timeStamp" value="920" /> <option name="timeStamp" value="920" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
<line>221</line> <line>222</line>
<option name="timeStamp" value="921" /> <option name="timeStamp" value="921" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
<line>149</line> <line>148</line>
<option name="timeStamp" value="1355" /> <option name="timeStamp" value="1355" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
@ -207,7 +234,7 @@
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
<line>128</line> <line>127</line>
<option name="timeStamp" value="4110" /> <option name="timeStamp" value="4110" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
@ -222,27 +249,27 @@
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go</url>
<line>602</line> <line>603</line>
<option name="timeStamp" value="4194" /> <option name="timeStamp" value="4194" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go</url>
<line>613</line> <line>614</line>
<option name="timeStamp" value="4195" /> <option name="timeStamp" value="4195" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go</url>
<line>623</line> <line>624</line>
<option name="timeStamp" value="4196" /> <option name="timeStamp" value="4196" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go</url>
<line>633</line> <line>634</line>
<option name="timeStamp" value="4197" /> <option name="timeStamp" value="4197" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go</url>
<line>668</line> <line>669</line>
<option name="timeStamp" value="4201" /> <option name="timeStamp" value="4201" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
@ -255,11 +282,6 @@
<line>103</line> <line>103</line>
<option name="timeStamp" value="4693" /> <option name="timeStamp" value="4693" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/AppService/getPsList/data.go</url>
<line>161</line>
<option name="timeStamp" value="5177" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go</url>
<line>118</line> <line>118</line>
@ -277,12 +299,12 @@
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go</url>
<line>936</line> <line>945</line>
<option name="timeStamp" value="5785" /> <option name="timeStamp" value="5785" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go</url>
<line>947</line> <line>956</line>
<option name="timeStamp" value="5786" /> <option name="timeStamp" value="5786" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
@ -310,11 +332,6 @@
<line>409</line> <line>409</line>
<option name="timeStamp" value="6436" /> <option name="timeStamp" value="6436" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/web.go</url>
<line>129</line>
<option name="timeStamp" value="6459" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go</url>
<line>83</line> <line>83</line>
@ -325,11 +342,6 @@
<line>78</line> <line>78</line>
<option name="timeStamp" value="6495" /> <option name="timeStamp" value="6495" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/reflection/funcs.go</url>
<line>93</line>
<option name="timeStamp" value="6686" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go</url>
<line>91</line> <line>91</line>
@ -337,47 +349,42 @@
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go</url>
<line>818</line> <line>901</line>
<option name="timeStamp" value="6784" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go</url>
<line>874</line>
<option name="timeStamp" value="6789" /> <option name="timeStamp" value="6789" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go</url>
<line>851</line> <line>878</line>
<option name="timeStamp" value="6790" /> <option name="timeStamp" value="6790" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go</url>
<line>806</line> <line>811</line>
<option name="timeStamp" value="6792" /> <option name="timeStamp" value="6792" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go</url>
<line>761</line> <line>766</line>
<option name="timeStamp" value="6794" /> <option name="timeStamp" value="6794" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go</url>
<line>721</line> <line>726</line>
<option name="timeStamp" value="6796" /> <option name="timeStamp" value="6796" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go</url>
<line>717</line> <line>722</line>
<option name="timeStamp" value="6797" /> <option name="timeStamp" value="6797" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go</url>
<line>634</line> <line>640</line>
<option name="timeStamp" value="6800" /> <option name="timeStamp" value="6800" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go</url>
<line>1110</line> <line>1137</line>
<option name="timeStamp" value="6822" /> <option name="timeStamp" value="6822" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
@ -402,7 +409,7 @@
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go</url>
<line>568</line> <line>580</line>
<option name="timeStamp" value="7135" /> <option name="timeStamp" value="7135" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
@ -430,36 +437,16 @@
<line>141</line> <line>141</line>
<option name="timeStamp" value="7253" /> <option name="timeStamp" value="7253" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceList/data.go</url>
<line>201</line>
<option name="timeStamp" value="7254" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/point.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/point.go</url>
<line>467</line> <line>471</line>
<option name="timeStamp" value="7263" /> <option name="timeStamp" value="7263" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/point.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/point.go</url>
<line>366</line> <line>370</line>
<option name="timeStamp" value="7267" /> <option name="timeStamp" value="7267" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceList/data.go</url>
<line>302</line>
<option name="timeStamp" value="7274" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceList/data.go</url>
<line>291</line>
<option name="timeStamp" value="7275" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go</url>
<line>160</line>
<option name="timeStamp" value="7276" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/WebAppService/getPsCBoxDetail/data.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/WebAppService/getPsCBoxDetail/data.go</url>
<line>20</line> <line>20</line>
@ -497,7 +484,7 @@
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go</url>
<line>902</line> <line>911</line>
<option name="timeStamp" value="7370" /> <option name="timeStamp" value="7370" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
@ -512,7 +499,7 @@
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/AppService/getDeviceList/data.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/AppService/getDeviceList/data.go</url>
<line>166</line> <line>167</line>
<option name="timeStamp" value="7465" /> <option name="timeStamp" value="7465" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
@ -520,56 +507,6 @@
<line>18</line> <line>18</line>
<option name="timeStamp" value="7467" /> <option name="timeStamp" value="7467" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_point.go</url>
<line>93</line>
<option name="timeStamp" value="7470" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/cmd/cmd_show_point.go</url>
<line>119</line>
<option name="timeStamp" value="7482" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_point.go</url>
<line>487</line>
<option name="timeStamp" value="7483" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_point.go</url>
<line>468</line>
<option name="timeStamp" value="7484" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/cmd/cmd_show_point.go</url>
<line>120</line>
<option name="timeStamp" value="7485" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_point.go</url>
<line>486</line>
<option name="timeStamp" value="7487" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_point.go</url>
<line>479</line>
<option name="timeStamp" value="7488" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_template.go</url>
<line>154</line>
<option name="timeStamp" value="7505" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_point.go</url>
<line>476</line>
<option name="timeStamp" value="7508" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_point.go</url>
<line>467</line>
<option name="timeStamp" value="7509" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_template.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/highlevel_template.go</url>
<line>147</line> <line>147</line>
@ -580,150 +517,235 @@
<line>817</line> <line>817</line>
<option name="timeStamp" value="7600" /> <option name="timeStamp" value="7600" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>433</line>
<option name="timeStamp" value="7619" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>573</line>
<option name="timeStamp" value="7622" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go</url>
<line>137</line> <line>168</line>
<option name="timeStamp" value="7644" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go</url>
<line>897</line>
<option name="timeStamp" value="7659" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>553</line>
<option name="timeStamp" value="7661" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>554</line>
<option name="timeStamp" value="7662" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>558</line>
<option name="timeStamp" value="7663" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>559</line>
<option name="timeStamp" value="7664" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go</url>
<line>836</line>
<option name="timeStamp" value="7666" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go</url>
<line>163</line>
<option name="timeStamp" value="7684" /> <option name="timeStamp" value="7684" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go</url>
<line>156</line> <line>161</line>
<option name="timeStamp" value="7685" /> <option name="timeStamp" value="7685" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go</url>
<line>754</line> <line>229</line>
<option name="timeStamp" value="7686" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go</url>
<line>753</line>
<option name="timeStamp" value="7688" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go</url>
<line>224</line>
<option name="timeStamp" value="7689" /> <option name="timeStamp" value="7689" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go</url>
<line>534</line> <line>757</line>
<option name="timeStamp" value="7691" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>464</line>
<option name="timeStamp" value="7714" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>444</line>
<option name="timeStamp" value="7715" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_table.go</url>
<line>314</line>
<option name="timeStamp" value="7718" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go</url>
<line>740</line>
<option name="timeStamp" value="7734" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go</url>
<line>711</line>
<option name="timeStamp" value="7735" /> <option name="timeStamp" value="7735" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go</url>
<line>540</line>
<option name="timeStamp" value="7736" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go</url>
<line>93</line>
<option name="timeStamp" value="7737" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go</url>
<line>479</line>
<option name="timeStamp" value="7738" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_table.go</url>
<line>100</line>
<option name="timeStamp" value="7739" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_table.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_table.go</url>
<line>107</line> <line>107</line>
<option name="timeStamp" value="7740" /> <option name="timeStamp" value="7740" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_table.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>122</line> <line>585</line>
<option name="timeStamp" value="7741" /> <option name="timeStamp" value="7744" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>488</line> <line>674</line>
<option name="timeStamp" value="7742" /> <option name="timeStamp" value="7753" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>673</line>
<option name="timeStamp" value="7754" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>637</line>
<option name="timeStamp" value="7771" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>594</line>
<option name="timeStamp" value="7772" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/cmd/cmd_show_point.go</url>
<line>74</line>
<option name="timeStamp" value="7800" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/WebIscmAppService/queryDeviceListForBackSys/data.go</url>
<line>55</line>
<option name="timeStamp" value="7821" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>549</line>
<option name="timeStamp" value="7883" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_point.go</url>
<line>665</line>
<option name="timeStamp" value="7893" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_point.go</url>
<line>643</line>
<option name="timeStamp" value="7902" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>791</line>
<option name="timeStamp" value="7919" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>782</line>
<option name="timeStamp" value="7921" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>777</line>
<option name="timeStamp" value="7935" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_table.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_table.go</url>
<line>94</line> <line>478</line>
<option name="timeStamp" value="7743" /> <option name="timeStamp" value="7956" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_table.go</url>
<line>506</line>
<option name="timeStamp" value="7958" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go</url>
<line>326</line>
<option name="timeStamp" value="7960" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go</url>
<line>675</line>
<option name="timeStamp" value="7962" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go</url>
<line>697</line>
<option name="timeStamp" value="7963" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go</url>
<line>462</line>
<option name="timeStamp" value="7975" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go</url>
<line>827</line>
<option name="timeStamp" value="7987" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_table.go</url>
<line>246</line>
<option name="timeStamp" value="8009" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_table.go</url>
<line>249</line>
<option name="timeStamp" value="8010" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_table.go</url>
<line>254</line>
<option name="timeStamp" value="8012" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_table.go</url>
<line>256</line>
<option name="timeStamp" value="8013" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_table.go</url>
<line>259</line>
<option name="timeStamp" value="8014" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_table.go</url>
<line>261</line>
<option name="timeStamp" value="8015" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_point.go</url>
<line>318</line>
<option name="timeStamp" value="8028" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/cmd/cmd_show_device.go</url>
<line>90</line>
<option name="timeStamp" value="8032" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/cmd/cmd_show_device.go</url>
<line>91</line>
<option name="timeStamp" value="8033" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/cmd/cmd_show_device.go</url>
<line>59</line>
<option name="timeStamp" value="8039" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>469</line> <line>795</line>
<option name="timeStamp" value="7744" /> <option name="timeStamp" value="8044" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>165</line>
<option name="timeStamp" value="8045" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>179</line>
<option name="timeStamp" value="8046" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>247</line>
<option name="timeStamp" value="8048" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>319</line>
<option name="timeStamp" value="8049" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>369</line>
<option name="timeStamp" value="8051" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>372</line>
<option name="timeStamp" value="8052" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_device.go</url>
<line>206</line>
<option name="timeStamp" value="8053" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_device.go</url>
<line>249</line>
<option name="timeStamp" value="8054" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_device.go</url>
<line>163</line>
<option name="timeStamp" value="8057" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_device.go</url>
<line>157</line>
<option name="timeStamp" value="8058" />
</line-breakpoint> </line-breakpoint>
</breakpoints> </breakpoints>
<default-breakpoints> <default-breakpoints>
@ -733,6 +755,7 @@
<watches-manager> <watches-manager>
<configuration name="GoApplicationRunConfiguration"> <configuration name="GoApplicationRunConfiguration">
<watch expression="Child.DataStructure.Endpoint" language="go" /> <watch expression="Child.DataStructure.Endpoint" language="go" />
<watch expression="cmds" language="go" />
</configuration> </configuration>
</watches-manager> </watches-manager>
</component> </component>

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -56,11 +56,11 @@ func NewCmdApi() *CmdApi {
cmd: nil, cmd: nil,
SelfCmd: nil, SelfCmd: nil,
}, },
ApiTimeout: defaultTimeout, ApiTimeout: iSolarCloud.DefaultTimeout,
Url: defaultHost, Url: iSolarCloud.DefaultHost,
Username: "", Username: "",
Password: "", Password: "",
AppKey: defaultApiAppKey, AppKey: iSolarCloud.DefaultApiAppKey,
LastLogin: "", LastLogin: "",
ApiToken: "", ApiToken: "",
ApiTokenFile: "", ApiTokenFile: "",
@ -240,13 +240,13 @@ func (c *CmdApi) AttachFlags(cmd *cobra.Command, viper *viper.Viper) {
viper.SetDefault(flagApiUsername, "") viper.SetDefault(flagApiUsername, "")
cmd.PersistentFlags().StringVarP(&c.Password, flagApiPassword, "p", "", fmt.Sprintf("SunGrow: api password.")) cmd.PersistentFlags().StringVarP(&c.Password, flagApiPassword, "p", "", fmt.Sprintf("SunGrow: api password."))
viper.SetDefault(flagApiPassword, "") viper.SetDefault(flagApiPassword, "")
cmd.PersistentFlags().StringVarP(&c.AppKey, flagApiAppKey, "", defaultApiAppKey, fmt.Sprintf("SunGrow: api application key.")) cmd.PersistentFlags().StringVarP(&c.AppKey, flagApiAppKey, "", iSolarCloud.DefaultApiAppKey, fmt.Sprintf("SunGrow: api application key."))
viper.SetDefault(flagApiAppKey, defaultApiAppKey) viper.SetDefault(flagApiAppKey, iSolarCloud.DefaultApiAppKey)
cmd.PersistentFlags().StringVarP(&c.Url, flagApiUrl, "", defaultHost, fmt.Sprintf("SunGrow: Provider API URL.")) cmd.PersistentFlags().StringVarP(&c.Url, flagApiUrl, "", iSolarCloud.DefaultHost, fmt.Sprintf("SunGrow: Provider API URL."))
viper.SetDefault(flagApiUrl, defaultHost) viper.SetDefault(flagApiUrl, iSolarCloud.DefaultHost)
// cmd.PersistentFlags().DurationVarP(&c.ApiTimeout, flagApiTimeout, "", defaultTimeout, fmt.Sprintf("SunGrow: API timeout.")) // cmd.PersistentFlags().DurationVarP(&c.ApiTimeout, flagApiTimeout, "", iSolarCloud.DefaultTimeout, fmt.Sprintf("SunGrow: API timeout."))
// viper.SetDefault(flagApiTimeout, defaultTimeout) // viper.SetDefault(flagApiTimeout, iSolarCloud.DefaultTimeout)
c.ApiTimeout = defaultTimeout c.ApiTimeout = iSolarCloud.DefaultTimeout
cmd.PersistentFlags().StringVar(&c.LastLogin, flagApiLastLogin, "", "SunGrow: last login.") cmd.PersistentFlags().StringVar(&c.LastLogin, flagApiLastLogin, "", "SunGrow: last login.")
viper.SetDefault(flagApiLastLogin, "") viper.SetDefault(flagApiLastLogin, "")
// _ = cmd.PersistentFlags().MarkHidden(flagApiLastLogin) // _ = cmd.PersistentFlags().MarkHidden(flagApiLastLogin)
@ -281,7 +281,7 @@ func (ca *Cmds) SunGrowArgs(cmd *cobra.Command, args []string) error {
ca.Api.SunGrow.SaveAsFile = ca.Api.SaveFile ca.Api.SunGrow.SaveAsFile = ca.Api.SaveFile
if ca.Api.AppKey == "" { if ca.Api.AppKey == "" {
ca.Api.AppKey = defaultApiAppKey ca.Api.AppKey = iSolarCloud.DefaultApiAppKey
} }
ca.Error = ca.Api.ApiLogin(false) ca.Error = ca.Api.ApiLogin(false)
@ -338,7 +338,7 @@ func (c *CmdApi) CmdApiList(cmd *cobra.Command, args []string) {
func (c *CmdApi) CmdApiGet(_ *cobra.Command, args []string) error { func (c *CmdApi) CmdApiGet(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
args = cmdConfig.FillArray(2, args) args = MinimumArraySize(2, args)
if args[0] == "all" { if args[0] == "all" {
c.Error = c.SunGrow.AllCritical() c.Error = c.SunGrow.AllCritical()
break break
@ -406,3 +406,21 @@ func (c *CmdApi) ApiLogin(force bool) error {
} }
return c.Error return c.Error
} }
func MinimumArraySize(count int, args []string) []string {
var ret []string
for range Only.Once {
ret = cmdConfig.FillArray(count, args)
for i, e := range args {
if e == "." {
e = ""
}
if e == "-" {
e = ""
}
ret[i] = e
}
}
return ret
}

View File

@ -5,7 +5,6 @@ import (
"GoSungrow/iSolarCloud/api/GoStruct/output" "GoSungrow/iSolarCloud/api/GoStruct/output"
"fmt" "fmt"
"github.com/MickMake/GoUnify/Only" "github.com/MickMake/GoUnify/Only"
"github.com/MickMake/GoUnify/cmdConfig"
"github.com/MickMake/GoUnify/cmdHelp" "github.com/MickMake/GoUnify/cmdHelp"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -209,7 +208,7 @@ func (c *CmdData) GetEndpoints(cmd *cobra.Command, args []string) error {
cmds.Api.SaveFile = true cmds.Api.SaveFile = true
} }
args = cmdConfig.FillArray(2, args) args = MinimumArraySize(2, args)
eps := iSolarCloud.SplitArg(args[0]) eps := iSolarCloud.SplitArg(args[0])
data := cmds.Api.SunGrow.NewSunGrowData() data := cmds.Api.SunGrow.NewSunGrowData()

View File

@ -4,7 +4,6 @@ import (
"GoSungrow/iSolarCloud/api/GoStruct/output" "GoSungrow/iSolarCloud/api/GoStruct/output"
"fmt" "fmt"
"github.com/MickMake/GoUnify/Only" "github.com/MickMake/GoUnify/Only"
"github.com/MickMake/GoUnify/cmdConfig"
"github.com/MickMake/GoUnify/cmdHelp" "github.com/MickMake/GoUnify/cmdHelp"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -176,7 +175,7 @@ func (c *CmdInfo) AttachCmdInfo(cmd *cobra.Command) *cobra.Command {
// for range Only.Once { // for range Only.Once {
// fmt.Println("Not yet implemented.") // fmt.Println("Not yet implemented.")
// // ca.Api.SunGrow.OutputType.SetFile() // // ca.Api.SunGrow.OutputType.SetFile()
// // args = cmdConfig.FillArray(2, args) // // args = MinimumArraySize(2, args)
// // c.Error = SunGrow.PutHighLevel(args[0], args[1]) // // c.Error = SunGrow.PutHighLevel(args[0], args[1])
// } // }
// } // }
@ -195,7 +194,7 @@ func (c *CmdInfo) AttachCmdInfoMqtt(cmd *cobra.Command) *cobra.Command {
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
_ = cmds.SetOutputType(cmd) _ = cmds.SetOutputType(cmd)
args = cmdConfig.FillArray(1, args) args = MinimumArraySize(1, args)
return cmds.Api.SunGrow.GetIsolarcloudMqtt(args[0]) return cmds.Api.SunGrow.GetIsolarcloudMqtt(args[0])
}, },
Args: cobra.RangeArgs(0, 1), Args: cobra.RangeArgs(0, 1),
@ -420,7 +419,7 @@ func (c *CmdInfo) AttachCmdInfoRealTime(cmd *cobra.Command) *cobra.Command {
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
_ = cmds.SetOutputType(cmd) _ = cmds.SetOutputType(cmd)
args = cmdConfig.FillArray(1, args) args = MinimumArraySize(1, args)
return cmds.Api.SunGrow.GetRealTimeData(args[0]) return cmds.Api.SunGrow.GetRealTimeData(args[0])
}, },
Args: cobra.RangeArgs(0, 1), Args: cobra.RangeArgs(0, 1),

View File

@ -7,23 +7,6 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
// type CmdShow struct {
// CmdDefault
// PsId CmdDefault
// Device CmdDefault
// Template CmdDefault
// }
//
// func NewCmdShow() *CmdShow {
// ret := &CmdShow {
// CmdDefault: CmdDefault {
// Error: nil,
// cmd: nil,
// SelfCmd: nil,
// },
// }
// return ret
// }
type CmdShow CmdDefault type CmdShow CmdDefault

View File

@ -14,8 +14,8 @@ func (c *CmdShow) AttachDevice(cmd *cobra.Command) *cobra.Command {
Use: "device", Use: "device",
Aliases: []string{}, Aliases: []string{},
Annotations: map[string]string{"group": "Device"}, Annotations: map[string]string{"group": "Device"},
Short: fmt.Sprintf("General iSolarCloud functions."), Short: fmt.Sprintf("Sungrow devices."),
Long: fmt.Sprintf("General iSolarCloud functions."), Long: fmt.Sprintf("Sungrow devices."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
@ -28,41 +28,137 @@ func (c *CmdShow) AttachDevice(cmd *cobra.Command) *cobra.Command {
self.Example = cmdHelp.PrintExamples(self, "") self.Example = cmdHelp.PrintExamples(self, "")
c.AttachDeviceList(self) c.AttachDeviceList(self)
c.AttachDevicePoints(self)
c.AttachDeviceModels(self) c.AttachDeviceModels(self)
} }
return c.SelfCmd return c.SelfCmd
} }
func (c *CmdShow) AttachDeviceList(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachDeviceList(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{ // ********************************************************************************
var c2 = &cobra.Command{
Use: "list", Use: "list",
Aliases: []string{"ls"}, Aliases: []string{"ls"},
Annotations: map[string]string{"group": "Device"}, Annotations: map[string]string{"group": "Device"},
Short: fmt.Sprintf("Show all devices on account."), Short: fmt.Sprintf("List all device types."),
Long: fmt.Sprintf("Show all devices on account."), Long: fmt.Sprintf("List all device types."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcAttachDeviceList, RunE: c.funcDeviceTypeList,
Args: cobra.MinimumNArgs(0), Args: cobra.MinimumNArgs(0),
} }
cmd.AddCommand(self) cmd.AddCommand(c2)
self.Example = cmdHelp.PrintExamples(self, "") c2.Example = cmdHelp.PrintExamples(c2, "")
return cmd return cmd
} }
func (c *CmdShow) funcAttachDeviceList(_ *cobra.Command, args []string) error { func (c *CmdShow) funcDeviceTypeList(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
var devices string cmds.Api.SunGrow.OutputType.SetTable()
devices, c.Error = cmds.Api.SunGrow.Devices(args...) ret := cmds.Api.SunGrow.DeviceTypeList()
if c.Error != nil { fmt.Println(ret)
break
}
fmt.Printf("%s\n", devices)
} }
return c.Error return c.Error
} }
func (c *CmdShow) AttachDevicePoints(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var c2 = &cobra.Command{
Use: "points <device_type ...>",
Aliases: []string{"point"},
Annotations: map[string]string{"group": "Device"},
Short: fmt.Sprintf("List data points used by a device."),
Long: fmt.Sprintf("List data points used by a device."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcDevicePoints,
Args: cobra.MinimumNArgs(1),
}
cmd.AddCommand(c2)
c2.Example = cmdHelp.PrintExamples(c2,
"1",
"11",
)
return cmd
}
func (c *CmdShow) funcDevicePoints(_ *cobra.Command, args []string) error {
for range Only.Once {
cmds.Api.SunGrow.OutputType.SetTable()
ret := cmds.Api.SunGrow.DevicePoints(args...)
fmt.Println(ret)
}
return c.Error
}
func (c *CmdShow) AttachDeviceData(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var self = &cobra.Command{
Use: "data <device_type> [start date] [end date] [interval]",
Annotations: map[string]string{"group": "Device"},
Short: fmt.Sprintf("Get data from report template."),
Long: fmt.Sprintf("Get data from report template."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcDeviceData,
Args: cobra.MinimumNArgs(1),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self,
"11 20221201 20221202 30",
"11 20221201 20221202 5",
"11 20221201 20221202",
"11 20221201",
"11",
)
return cmd
}
func (c *CmdShow) funcDeviceData(_ *cobra.Command, args []string) error {
for range Only.Once {
cmds.Api.SunGrow.OutputType.SetTable()
args = MinimumArraySize(4, args)
c.Error = cmds.Api.SunGrow.DeviceData(args[0], args[1], args[2], args[3])
}
return c.Error
}
func (c *CmdShow) AttachDeviceDataGraph(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var self = &cobra.Command{
Use: "data-graph <device_type> [start date] [end date] [interval]",
Annotations: map[string]string{"group": "Device"},
Short: fmt.Sprintf("Get data from report template."),
Long: fmt.Sprintf("Get data from report template."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcDeviceDataGraph,
Args: cobra.MinimumNArgs(1),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self,
"11 20221201 20221202 30",
"11 20221201 20221202 5",
"11 20221201 20221202",
"11 20221201",
"11",
)
return cmd
}
func (c *CmdShow) funcDeviceDataGraph(_ *cobra.Command, args []string) error {
for range Only.Once {
cmds.Api.SunGrow.OutputType.SetGraph()
args = MinimumArraySize(4, args)
c.Error = cmds.Api.SunGrow.DeviceData(args[0], args[1], args[2], args[3])
}
return c.Error
}
func (c *CmdShow) AttachDeviceModels(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachDeviceModels(cmd *cobra.Command) *cobra.Command {
// ******************************************************************************** // ********************************************************************************
@ -75,7 +171,7 @@ func (c *CmdShow) AttachDeviceModels(cmd *cobra.Command) *cobra.Command {
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcAttachDeviceModels, RunE: c.funcDeviceModels,
Args: cobra.MinimumNArgs(0), Args: cobra.MinimumNArgs(0),
} }
cmd.AddCommand(c2) cmd.AddCommand(c2)
@ -83,10 +179,10 @@ func (c *CmdShow) AttachDeviceModels(cmd *cobra.Command) *cobra.Command {
return cmd return cmd
} }
func (c *CmdShow) funcAttachDeviceModels(_ *cobra.Command, _ []string) error { func (c *CmdShow) funcDeviceModels(_ *cobra.Command, _ []string) error {
for range Only.Once { for range Only.Once {
// _ = cmds.SetOutputType(cmd) // _ = cmds.SetOutputType(cmd)
c.Error = cmds.Api.SunGrow.GetDeviceModelInfoList() c.Error = cmds.Api.SunGrow.DeviceModelInfoList()
} }
return c.Error return c.Error
} }

View File

@ -3,9 +3,9 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/MickMake/GoUnify/Only" "github.com/MickMake/GoUnify/Only"
"github.com/MickMake/GoUnify/cmdConfig"
"github.com/MickMake/GoUnify/cmdHelp" "github.com/MickMake/GoUnify/cmdHelp"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"strings"
) )
@ -28,36 +28,50 @@ func (c *CmdShow) AttachPoint(cmd *cobra.Command) *cobra.Command {
cmd.AddCommand(self) cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self, "") self.Example = cmdHelp.PrintExamples(self, "")
c.AttachPointNames(self) c.AttachPointPs(self)
c.AttachPointScan(self) c.AttachPointPsTable(self)
c.AttachPointData(self) c.AttachPointPsGraph(self)
c.AttachPointDevice(self)
c.AttachPointDeviceTable(self)
c.AttachPointDeviceGraph(self)
c.AttachPointTemplate(self) c.AttachPointTemplate(self)
c.AttachPointTemplateTable(self)
c.AttachPointTemplateGraph(self)
c.AttachPointData(self)
c.AttachPointDataGraph(self)
c.AttachPointScan(self)
} }
return c.SelfCmd return c.SelfCmd
} }
func (c *CmdShow) AttachPointNames(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachPointPs(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{ var self = &cobra.Command{
Use: "names [ps_id]", Use: "ps <ps_ids | .> [device_type]",
Aliases: []string{}, Aliases: []string{},
Annotations: map[string]string{"group": "Point"}, Annotations: map[string]string{"group": "Point"},
Short: fmt.Sprintf("Get point names for a given ps_id."), Short: fmt.Sprintf("List data points used by a given ps_id."),
Long: fmt.Sprintf("Get point names for a given ps_id."), Long: fmt.Sprintf("List data points used by a given ps_id."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcAttachPointNames, RunE: c.funcPointPs,
Args: cobra.MinimumNArgs(0), Args: cobra.MinimumNArgs(0),
} }
cmd.AddCommand(self) cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self, "") self.Example = cmdHelp.PrintExamples(self, "", "1171348", "1171348 14")
return cmd return cmd
} }
func (c *CmdShow) funcAttachPointNames(_ *cobra.Command, args []string) error { func (c *CmdShow) funcPointPs(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
points := cmds.Api.SunGrow.PointNames(args...) cmds.Api.SunGrow.OutputType.SetTable()
args = MinimumArraySize(2, args)
points := cmds.Api.SunGrow.PointNames(strings.Split(args[0], ","), args[1])
if c.Error != nil { if c.Error != nil {
break break
} }
@ -66,6 +80,225 @@ func (c *CmdShow) funcAttachPointNames(_ *cobra.Command, args []string) error {
return c.Error return c.Error
} }
func (c *CmdShow) AttachPointPsTable(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{
Use: "ps-table <ps_ids | .> <device_type | .> (start)<YYYYmmdd[HHMMSS]> (end)<YYYYmmdd[HHMMSS]> <interval_minutes | .>",
Aliases: []string{},
Annotations: map[string]string{"group": "Point"},
Short: fmt.Sprintf("Generate points table for a given ps_id."),
Long: fmt.Sprintf("Generate points table for a given ps_id."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcPointPsTable,
Args: cobra.MinimumNArgs(0),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self,
"1171348 43 20221201 20221202 10",
"1171348 43 20221201 20221202",
"1171348 43 20221201",
". . 20221201 20221202 60",
)
return cmd
}
func (c *CmdShow) funcPointPsTable(_ *cobra.Command, args []string) error {
for range Only.Once {
cmds.Api.SunGrow.OutputType.SetTable()
args = MinimumArraySize(5, args)
_ = cmds.Api.SunGrow.PointNamesData(strings.Split(args[0], ","), args[1], args[2], args[3], args[4])
if c.Error != nil {
break
}
}
return c.Error
}
func (c *CmdShow) AttachPointPsGraph(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{
Use: "ps-graph <ps_ids | .> <device_type | .> (start)<YYYYmmdd[HHMMSS]> (end)<YYYYmmdd[HHMMSS]> <interval_minutes | .>",
Aliases: []string{},
Annotations: map[string]string{"group": "Point"},
Short: fmt.Sprintf("Generate graphs of points for a given ps_id."),
Long: fmt.Sprintf("Generate graphs of points for a given ps_id."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcPointPsGraph,
Args: cobra.MinimumNArgs(0),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self,
"1171348 43 20221201 20221202 10",
"1171348 43 20221201 20221202",
"1171348 43 20221201",
". . 20221201 20221202 60",
)
return cmd
}
func (c *CmdShow) funcPointPsGraph(_ *cobra.Command, args []string) error {
for range Only.Once {
cmds.Api.SunGrow.OutputType.SetGraph()
args = MinimumArraySize(5, args)
_ = cmds.Api.SunGrow.PointNamesData(strings.Split(args[0], ","), args[1], args[2], args[3], args[4])
if c.Error != nil {
break
}
}
return c.Error
}
func (c *CmdShow) AttachPointTemplate(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var c2 = &cobra.Command{
Use: "template <template_id>",
Aliases: []string{},
Annotations: map[string]string{"group": "Point"},
Short: fmt.Sprintf("List data points used by a report template."),
Long: fmt.Sprintf("List data points used by a report template."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcTemplatePoints,
Args: cobra.ExactArgs(1),
}
cmd.AddCommand(c2)
c2.Example = cmdHelp.PrintExamples(c2,
"8042",
"8040",
)
return cmd
}
func (c *CmdShow) AttachPointTemplateTable(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var self = &cobra.Command{
Use: "template-data <template_id> [start date] [end date] [interval]",
Annotations: map[string]string{"group": "Template"},
Short: fmt.Sprintf("Generate points table for a given report template."),
Long: fmt.Sprintf("Generate points table for a given report template."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcTemplateData,
Args: cobra.MinimumNArgs(1),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self,
"8092 20221201 20221202 30",
"8092 20221201 20221202 5",
"8092 20221201 20221202",
"8092 20221201",
"8092",
)
return cmd
}
func (c *CmdShow) AttachPointTemplateGraph(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var self = &cobra.Command{
Use: "template-graph <template_id> [start date] [end date] [interval]",
Annotations: map[string]string{"group": "Template"},
Short: fmt.Sprintf("Generate graphs of points for a given report template."),
Long: fmt.Sprintf("Generate graphs of points for a given report template."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcTemplateData,
Args: cobra.MinimumNArgs(1),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self,
"8092 20221201 20221202 30",
"8092 20221201 20221202 5",
"8092 20221201 20221202",
"8092 20221201",
"8092",
)
return cmd
}
func (c *CmdShow) AttachPointDevice(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var c2 = &cobra.Command{
Use: "device <device_type ...>",
Aliases: []string{"devices"},
Annotations: map[string]string{"group": "Point"},
Short: fmt.Sprintf("List data points used by a device."),
Long: fmt.Sprintf("List data points used by a device."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcDevicePoints,
Args: cobra.ExactArgs(1),
}
cmd.AddCommand(c2)
c2.Example = cmdHelp.PrintExamples(c2,
"1",
"11",
)
return cmd
}
func (c *CmdShow) AttachPointDeviceTable(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var self = &cobra.Command{
Use: "device-data <device_id> [start date] [end date] [interval]",
Annotations: map[string]string{"group": "Template"},
Short: fmt.Sprintf("Generate points table for a given device."),
Long: fmt.Sprintf("Generate points table for a given device."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcDeviceData,
Args: cobra.MinimumNArgs(1),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self,
"8092 20221201 20221202 30",
"8092 20221201 20221202 5",
"8092 20221201 20221202",
"8092 20221201",
"8092",
)
return cmd
}
func (c *CmdShow) AttachPointDeviceGraph(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var self = &cobra.Command{
Use: "device-graph <template_id> [start date] [end date] [interval]",
Annotations: map[string]string{"group": "Template"},
Short: fmt.Sprintf("Generate graphs of points for a given device."),
Long: fmt.Sprintf("Generate graphs of points for a given device."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcDeviceData,
Args: cobra.MinimumNArgs(1),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self,
"8092 20221201 20221202 30",
"8092 20221201 20221202 5",
"8092 20221201 20221202",
"8092 20221201",
"8092",
)
return cmd
}
func (c *CmdShow) AttachPointScan(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachPointScan(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{ var self = &cobra.Command{
Use: "scan [min] [max]", Use: "scan [min] [max]",
@ -76,17 +309,20 @@ func (c *CmdShow) AttachPointScan(cmd *cobra.Command) *cobra.Command {
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcAttachPointScan, RunE: c.funcPointScan,
Args: cobra.MinimumNArgs(2), Args: cobra.MinimumNArgs(2),
} }
cmd.AddCommand(self) cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self, "") self.Example = cmdHelp.PrintExamples(self,
"1 1000",
)
return cmd return cmd
} }
func (c *CmdShow) funcAttachPointScan(_ *cobra.Command, args []string) error { func (c *CmdShow) funcPointScan(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
args = cmdConfig.FillArray(2, args) cmds.Api.SunGrow.OutputType.SetTable()
args = MinimumArraySize(2, args)
points := cmds.Api.SunGrow.PointScan(args[0], args[1]) points := cmds.Api.SunGrow.PointScan(args[0], args[1])
if c.Error != nil { if c.Error != nil {
break break
@ -96,9 +332,10 @@ func (c *CmdShow) funcAttachPointScan(_ *cobra.Command, args []string) error {
return c.Error return c.Error
} }
func (c *CmdShow) AttachPointData(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachPointData(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{ var self = &cobra.Command{
Use: "data <start:YYYYmmdd[HHMMSS]> <end:YYYYmmdd[HHMMSS]> <interval minutes> <points ...>", Use: "data (start)<YYYYmmdd[HHMMSS]> (end)<YYYYmmdd[HHMMSS]> <interval_minutes | .> <points ...>",
Aliases: []string{}, Aliases: []string{},
Annotations: map[string]string{"group": "Point"}, Annotations: map[string]string{"group": "Point"},
Short: fmt.Sprintf("Get data points."), Short: fmt.Sprintf("Get data points."),
@ -106,17 +343,21 @@ func (c *CmdShow) AttachPointData(cmd *cobra.Command) *cobra.Command {
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcAttachPointData, RunE: c.funcPointData,
Args: cobra.MinimumNArgs(4), Args: cobra.MinimumNArgs(4),
} }
cmd.AddCommand(self) cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self, "") self.Example = cmdHelp.PrintExamples(self,
"20221101 20221104 5 1171348_11_0_0.p83033,1171348_11_0_0.p83072,1171348_11_0_0.p83128",
"20221101 20221104 . 1171348_11_0_0.p83033 1171348_11_0_0.p83072 1171348_11_0_0.p83128",
)
return cmd return cmd
} }
func (c *CmdShow) funcAttachPointData(_ *cobra.Command, args []string) error { func (c *CmdShow) funcPointData(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
args = cmdConfig.FillArray(4, args) cmds.Api.SunGrow.OutputType.SetTable()
args = MinimumArraySize(4, args)
cmds.Api.SunGrow.PointData(args[0], args[1], args[2], args[3:]...) cmds.Api.SunGrow.PointData(args[0], args[1], args[2], args[3:]...)
if c.Error != nil { if c.Error != nil {
break break
@ -125,29 +366,35 @@ func (c *CmdShow) funcAttachPointData(_ *cobra.Command, args []string) error {
return c.Error return c.Error
} }
func (c *CmdShow) AttachPointTemplate(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachPointDataGraph(cmd *cobra.Command) *cobra.Command {
// ******************************************************************************** var self = &cobra.Command{
var c2 = &cobra.Command{ Use: "data-graph (start)<YYYYmmdd[HHMMSS]> (end)<YYYYmmdd[HHMMSS]> <interval_minutes | .> <points ...>",
Use: "template <template_id>",
Aliases: []string{}, Aliases: []string{},
Annotations: map[string]string{"group": "Point"}, Annotations: map[string]string{"group": "Point"},
Short: fmt.Sprintf("List data points used in report template."), Short: fmt.Sprintf("Get data points."),
Long: fmt.Sprintf("List data points used in report template."), Long: fmt.Sprintf("Get data points."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcAttachPointTemplate, RunE: c.funcPointDataGraph,
Args: cobra.ExactArgs(1), Args: cobra.MinimumNArgs(4),
} }
cmd.AddCommand(c2) cmd.AddCommand(self)
c2.Example = cmdHelp.PrintExamples(c2, "8042", "8040") self.Example = cmdHelp.PrintExamples(self,
"20221101 20221104 5 1171348_11_0_0.p83033,1171348_11_0_0.p83072,1171348_11_0_0.p83128",
"20221101 20221104 . 1171348_11_0_0.p83033 1171348_11_0_0.p83072 1171348_11_0_0.p83128",
)
return cmd return cmd
} }
func (c *CmdShow) funcAttachPointTemplate(_ *cobra.Command, args []string) error { func (c *CmdShow) funcPointDataGraph(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
// _ = cmds.SetOutputType(cmd) cmds.Api.SunGrow.OutputType.SetGraph()
c.Error = cmds.Api.SunGrow.TemplatePoints(args[0]) args = MinimumArraySize(4, args)
cmds.Api.SunGrow.PointData(args[0], args[1], args[2], args[3:]...)
if c.Error != nil {
break
}
} }
return c.Error return c.Error
} }

View File

@ -6,6 +6,7 @@ import (
"github.com/MickMake/GoUnify/Only" "github.com/MickMake/GoUnify/Only"
"github.com/MickMake/GoUnify/cmdHelp" "github.com/MickMake/GoUnify/cmdHelp"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"strings"
) )
@ -39,13 +40,13 @@ func (c *CmdShow) AttachPsIdList(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{ var self = &cobra.Command{
Use: "list", Use: "list",
Aliases: []string{"ls"}, Aliases: []string{"ls"},
Annotations: map[string]string{"group": "PsId"}, Annotations: map[string]string{"group": "Device"},
Short: fmt.Sprintf("Show all available PS."), Short: fmt.Sprintf("Show all devices on account."),
Long: fmt.Sprintf("Show all available PS."), Long: fmt.Sprintf("Show all devices on account."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcAttachPsIdList, RunE: c.funcPsIdListList,
Args: cobra.MinimumNArgs(0), Args: cobra.MinimumNArgs(0),
} }
cmd.AddCommand(self) cmd.AddCommand(self)
@ -53,7 +54,37 @@ func (c *CmdShow) AttachPsIdList(cmd *cobra.Command) *cobra.Command {
return cmd return cmd
} }
func (c *CmdShow) funcAttachPsIdList(_ *cobra.Command, args []string) error { func (c *CmdShow) funcPsIdListList(_ *cobra.Command, args []string) error {
for range Only.Once {
var devices string
devices, c.Error = cmds.Api.SunGrow.Devices(args...)
if c.Error != nil {
break
}
fmt.Printf("%s\n", devices)
}
return c.Error
}
func (c *CmdShow) AttachPsIdList2(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{
Use: "list",
Aliases: []string{"ls"},
Annotations: map[string]string{"group": "PsId"},
Short: fmt.Sprintf("Show all available PS."),
Long: fmt.Sprintf("Show all available PS."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcAttachPsIdList2,
Args: cobra.MinimumNArgs(0),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self, "")
return cmd
}
func (c *CmdShow) funcAttachPsIdList2(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
pids := cmds.Api.SunGrow.SetPsIds(args...) pids := cmds.Api.SunGrow.SetPsIds(args...)
if c.Error != nil { if c.Error != nil {
@ -96,8 +127,8 @@ func (c *CmdShow) funcAttachPsTree(_ *cobra.Command, args []string) error {
func (c *CmdShow) AttachPsPoints(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachPsPoints(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{ var self = &cobra.Command{
Use: "points", Use: "points <ps_ids | .> [device_type]",
Aliases: []string{}, Aliases: []string{"point"},
Annotations: map[string]string{"group": "PsId"}, Annotations: map[string]string{"group": "PsId"},
Short: fmt.Sprintf("Show available PS points."), Short: fmt.Sprintf("Show available PS points."),
Long: fmt.Sprintf("Show available PS points."), Long: fmt.Sprintf("Show available PS points."),
@ -114,7 +145,8 @@ func (c *CmdShow) AttachPsPoints(cmd *cobra.Command) *cobra.Command {
} }
func (c *CmdShow) funcAttachPsPoints(_ *cobra.Command, args []string) error { func (c *CmdShow) funcAttachPsPoints(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
points := cmds.Api.SunGrow.PointNames(args...) args = MinimumArraySize(2, args)
points := cmds.Api.SunGrow.PointNames(strings.Split(args[0], ","), args[1])
if cmds.Api.SunGrow.Error != nil { if cmds.Api.SunGrow.Error != nil {
c.Error = cmds.Api.SunGrow.Error c.Error = cmds.Api.SunGrow.Error
break break

View File

@ -3,7 +3,6 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/MickMake/GoUnify/Only" "github.com/MickMake/GoUnify/Only"
"github.com/MickMake/GoUnify/cmdConfig"
"github.com/MickMake/GoUnify/cmdHelp" "github.com/MickMake/GoUnify/cmdHelp"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -31,6 +30,7 @@ func (c *CmdShow) AttachTemplate(cmd *cobra.Command) *cobra.Command {
c.AttachTemplateList(self) c.AttachTemplateList(self)
c.AttachTemplatePoints(self) c.AttachTemplatePoints(self)
c.AttachTemplateData(self) c.AttachTemplateData(self)
c.AttachTemplateDataGraph(self)
} }
return c.SelfCmd return c.SelfCmd
} }
@ -46,7 +46,7 @@ func (c *CmdShow) AttachTemplateList(cmd *cobra.Command) *cobra.Command {
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcAttachTemplateList, RunE: c.funcTemplateList,
Args: cobra.ExactArgs(0), Args: cobra.ExactArgs(0),
} }
cmd.AddCommand(self) cmd.AddCommand(self)
@ -54,9 +54,9 @@ func (c *CmdShow) AttachTemplateList(cmd *cobra.Command) *cobra.Command {
return cmd return cmd
} }
func (c *CmdShow) funcAttachTemplateList(_ *cobra.Command, _ []string) error { func (c *CmdShow) funcTemplateList(_ *cobra.Command, _ []string) error {
for range Only.Once { for range Only.Once {
// _ = cmds.SetOutputType(cmd) cmds.Api.SunGrow.OutputType.SetTable()
c.Error = cmds.Api.SunGrow.TemplateList() c.Error = cmds.Api.SunGrow.TemplateList()
} }
return c.Error return c.Error
@ -73,17 +73,17 @@ func (c *CmdShow) AttachTemplatePoints(cmd *cobra.Command) *cobra.Command {
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcAttachTemplatePoints, RunE: c.funcTemplatePoints,
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
} }
cmd.AddCommand(self) cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self, "") self.Example = cmdHelp.PrintExamples(self, "8092")
return cmd return cmd
} }
func (c *CmdShow) funcAttachTemplatePoints(_ *cobra.Command, args []string) error { func (c *CmdShow) funcTemplatePoints(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
// _ = cmds.SetOutputType(cmd) cmds.Api.SunGrow.OutputType.SetTable()
c.Error = cmds.Api.SunGrow.TemplatePoints(args[0]) c.Error = cmds.Api.SunGrow.TemplatePoints(args[0])
} }
return c.Error return c.Error
@ -99,20 +99,58 @@ func (c *CmdShow) AttachTemplateData(cmd *cobra.Command) *cobra.Command {
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcAttachTemplateData, RunE: c.funcTemplateData,
Args: cobra.MinimumNArgs(1), Args: cobra.MinimumNArgs(1),
} }
cmd.AddCommand(self) cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self, "8042 20220212", "8042 20220212 '{\"search_string\":\"p83106\",\"min_left_axis\":-6000,\"max_left_axis\":12000}'") self.Example = cmdHelp.PrintExamples(self,
"8092 20221201 20221202 30",
"8092 20221201 20221202 5",
"8092 20221201 20221202",
"8092 20221201",
"8092",
)
return cmd return cmd
} }
func (c *CmdShow) funcAttachTemplateData(_ *cobra.Command, args []string) error { func (c *CmdShow) funcTemplateData(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
// _ = cmds.SetOutputType(cmd) cmds.Api.SunGrow.OutputType.SetTable()
args = cmdConfig.FillArray(4, args) args = MinimumArraySize(4, args)
c.Error = cmds.Api.SunGrow.TemplateData(args[0], args[1], args[2], args[3]) c.Error = cmds.Api.SunGrow.TemplateData(args[0], args[1], args[2], args[3])
} }
return c.Error return c.Error
} }
func (c *CmdShow) AttachTemplateDataGraph(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var self = &cobra.Command{
Use: "data-graph <template_id> [start date] [end date] [interval]",
Annotations: map[string]string{"group": "Template"},
Short: fmt.Sprintf("Get data from report template."),
Long: fmt.Sprintf("Get data from report template."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcTemplateDataGraph,
Args: cobra.MinimumNArgs(1),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self,
"8092 20221201 20221202 30",
"8092 20221201 20221202 5",
"8092 20221201 20221202",
"8092 20221201",
"8092",
)
return cmd
}
func (c *CmdShow) funcTemplateDataGraph(_ *cobra.Command, args []string) error {
for range Only.Once {
cmds.Api.SunGrow.OutputType.SetGraph()
args = MinimumArraySize(4, args)
c.Error = cmds.Api.SunGrow.TemplateData(args[0], args[1], args[2], args[3])
}
return c.Error
}

View File

@ -5,18 +5,9 @@ import (
"github.com/MickMake/GoUnify/Only" "github.com/MickMake/GoUnify/Only"
"github.com/MickMake/GoUnify/Unify" "github.com/MickMake/GoUnify/Unify"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"time"
) )
//goland:noinspection SpellCheckingInspection
const (
defaultHost = "https://augateway.isolarcloud.com"
defaultApiAppKey = "93D72E60331ABDCDC7B39ADC2D1F32B3"
defaultTimeout = time.Second * 30
)
type Cmds struct { type Cmds struct {
Unify *Unify.Unify Unify *Unify.Unify
Api *CmdApi Api *CmdApi

352
example/example.go Normal file
View File

@ -0,0 +1,352 @@
package example
import (
"GoSungrow/iSolarCloud"
"GoSungrow/iSolarCloud/AppService/login"
"GoSungrow/iSolarCloud/AppService/queryMutiPointDataList"
"GoSungrow/iSolarCloud/api/GoStruct/output"
"GoSungrow/iSolarCloud/api/GoStruct/valueTypes"
"fmt"
"github.com/MickMake/GoUnify/Only"
"log"
"os"
"strings"
"time"
)
// Example1 - GoSungrow API example
func Example1(startDate string, endDate string, interval string, points []string) error {
var err error
for range Only.Once {
// -------------------------------------------------------------------------------- //
// Initial setup.
url := "https://augateway.isolarcloud.com"
appKey := iSolarCloud.DefaultApiAppKey
user := "mick"
password := "password"
token := "tokenfile.json"
sg := iSolarCloud.NewSunGro(url, "./cache")
if sg.Error != nil {
err = sg.Error
break
}
err = sg.Init()
if err != nil {
break
}
auth := login.SunGrowAuth {
AppKey: appKey,
UserAccount: user,
UserPassword: password,
TokenFile: token,
Force: true,
}
err = sg.Login(auth)
if err != nil {
break
}
// -------------------------------------------------------------------------------- //
// Produce output.
data := sg.NewSunGrowData()
startDate = valueTypes.NewDateTime(startDate).Format(valueTypes.DateTimeLayoutSecond)
endDate = valueTypes.NewDateTime(endDate).Format(valueTypes.DateTimeLayoutSecond)
fmt.Printf("Points: %s\n", strings.Join(points, ","))
data.SetArgs(
"StartTimeStamp:" + startDate,
"EndTimeStamp:" + endDate,
"MinuteInterval:" + interval,
"Points:" + strings.Join(points, ","),
)
data.SetEndpoints(queryMutiPointDataList.EndPointName)
sg.Error = data.GetData()
if sg.Error != nil {
// break
}
sg.SetOutputType(output.StringTypeTable)
sg.SaveAsFile = false
sg.Error = data.OutputDataTables()
if sg.Error != nil {
break
}
}
return err
}
// Example2 - GoSungrow API example
func Example2(startDate string, endDate string, interval string, points []string) error {
var err error
for range Only.Once {
// -------------------------------------------------------------------------------- //
// Setup values.
p := valueTypes.SetPointIdsString(points...)
if len(p.PointIds) == 0 {
break
}
psids := p.PsIds()
if len(psids) == 0 {
break
}
psId := psids[0]
i := valueTypes.SetIntegerString(interval)
if !i.Valid {
i.SetValue(5)
}
sd := valueTypes.SetDateTimeString(startDate)
if sd.IsZero() {
sd.SetValue(time.Now())
sd.SetDayStart()
}
sd.SetDateType(valueTypes.DateTimeLayoutSecond)
ed := valueTypes.SetDateTimeString(endDate)
if ed.IsZero() {
ed.SetValue(sd.Value())
ed.SetDayEnd()
}
ed.SetDateType(valueTypes.DateTimeLayoutSecond)
// -------------------------------------------------------------------------------- //
// Initial setup.
url := "https://augateway.isolarcloud.com"
appKey := iSolarCloud.DefaultApiAppKey
user := "mick"
password := "password"
token := "tokenfile.json"
sg := iSolarCloud.NewSunGro(url, "./cache")
if sg.Error != nil {
err = sg.Error
break
}
err = sg.Init()
if err != nil {
break
}
auth := login.SunGrowAuth {
AppKey: appKey,
UserAccount: user,
UserPassword: password,
TokenFile: token,
Force: true,
}
err = sg.Login(auth)
if err != nil {
break
}
// -------------------------------------------------------------------------------- //
// Produce output.
ep := sg.GetByStruct(
"AppService.queryMutiPointDataList",
queryMutiPointDataList.RequestData {
PsId: psId,
StartTimeStamp: sd,
EndTimeStamp: ed,
MinuteInterval: i,
PsKeys: *p.PsKeys(),
Points: p,
},
time.Hour * 24,
)
if sg.IsError() {
break
}
var response iSolarCloud.SunGrowDataResponse
response.Data = ep.GetEndPointData()
response.Data.ProcessMap()
if response.Data.Error != nil {
sg.Error = response.Data.Error
break
}
table := response.Data.CreateResultTable(false)
table.OutputType = output.TypeTable
table.SetSaveFile(false)
sg.Error = table.Output()
if sg.Error != nil {
break
}
response.Options = iSolarCloud.OutputOptions {
OutputType: output.TypeTable,
SaveAsFile: false,
GraphRequest: output.GraphRequest{},
}
sg.Error = response.OutputDataTables()
if sg.IsError() {
break
}
}
return err
}
func Example3(startDate valueTypes.DateTime, endDate valueTypes.DateTime, interval valueTypes.Integer, points valueTypes.PointIds) error {
var err error
for range Only.Once {
// -------------------------------------------------------------------------------- //
// Setup values.
if len(points.PointIds) == 0 {
break
}
psids := points.PsIds()
if len(psids) == 0 {
break
}
psId := psids[0]
if !interval.Valid {
interval.SetValue(5)
}
if startDate.IsZero() {
startDate.SetValue(time.Now())
startDate.SetDayStart()
}
startDate.SetDateType(valueTypes.DateTimeLayoutSecond)
if endDate.IsZero() {
endDate.SetValue(startDate.Value())
endDate.SetDayEnd()
}
endDate.SetDateType(valueTypes.DateTimeLayoutSecond)
if !interval.Valid {
interval.SetValue(5)
}
// -------------------------------------------------------------------------------- //
// Initial setup.
url := "https://augateway.isolarcloud.com"
appKey := iSolarCloud.DefaultApiAppKey
user := "mick"
password := "password"
token := "tokenfile.json"
sg := iSolarCloud.NewSunGro(url, "./cache")
if sg.Error != nil {
err = sg.Error
break
}
err = sg.Init()
if err != nil {
break
}
auth := login.SunGrowAuth {
AppKey: appKey,
UserAccount: user,
UserPassword: password,
TokenFile: token,
Force: true,
}
err = sg.Login(auth)
if err != nil {
break
}
// -------------------------------------------------------------------------------- //
// Produce output.
ep := sg.GetByStruct(
"AppService.queryMutiPointDataList",
queryMutiPointDataList.RequestData {
PsId: psId,
StartTimeStamp: startDate,
EndTimeStamp: endDate,
MinuteInterval: interval,
PsKeys: *points.PsKeys(),
Points: points,
},
time.Hour * 24,
)
if sg.IsError() {
break
}
var response iSolarCloud.SunGrowDataResponse
response.Data = ep.GetEndPointData()
response.Data.ProcessMap()
if response.Data.Error != nil {
sg.Error = response.Data.Error
break
}
response.Options = iSolarCloud.OutputOptions {
OutputType: output.TypeGraph,
SaveAsFile: false,
GraphRequest: output.GraphRequest{},
}
sg.Error = response.OutputDataTables()
if sg.IsError() {
break
}
}
return err
}
func main() {
var err error
startDate := "20220701"
endDate := "20220701"
interval := "5"
points := []string{"Points:1171348_43_2_2.p58603", "1171348_43_2_2.p58604", "1171348_43_2_2.p58605", "1171348_43_2_2.p58606"}
err = Example1(startDate, endDate, interval, points)
if err != nil {
log.Fatalf("Error: %s", err)
os.Exit(1)
}
err = Example2(startDate, endDate, interval, points)
if err != nil {
log.Fatalf("Error: %s", err)
os.Exit(1)
}
err = Example3(valueTypes.SetDateTimeString(startDate), valueTypes.SetDateTimeString(endDate),
valueTypes.SetIntegerString(interval), valueTypes.SetPointIdsString(points...))
if err != nil {
log.Fatalf("Error: %s", err)
os.Exit(1)
}
os.Exit(0)
}

View File

@ -40,6 +40,7 @@ type Device struct {
DeviceType valueTypes.Integer `json:"device_type"` DeviceType valueTypes.Integer `json:"device_type"`
DeviceCode valueTypes.Integer `json:"device_code"` DeviceCode valueTypes.Integer `json:"device_code"`
ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id"` ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id"`
Sn valueTypes.String `json:"sn" PointName:"Serial Number"` Sn valueTypes.String `json:"sn" PointName:"Serial Number"`
FactoryName valueTypes.String `json:"factory_name"` FactoryName valueTypes.String `json:"factory_name"`

View File

@ -31,6 +31,7 @@ func (e *ResultData) GetPsIds() []valueTypes.PsId {
break break
} }
for _, p := range e.PageList { for _, p := range e.PageList {
// fmt.Printf("%s_%s_%s\n", p.PsId, p.)
if p.PsId.Value() != 0 { if p.PsId.Value() != 0 {
ret = append(ret, p.PsId) ret = append(ret, p.PsId)
} }

View File

@ -44,14 +44,17 @@ type ResultData struct {
UUID valueTypes.String `json:"uuid"` UUID valueTypes.String `json:"uuid"`
} `json:"devicePropertyValueList" PointId:"device_property_value_list" DataTable:"true"` } `json:"devicePropertyValueList" PointId:"device_property_value_list" DataTable:"true"`
PsId valueTypes.PsId `json:"ps_id"`
PsKey valueTypes.String `json:"ps_key"` PsKey valueTypes.String `json:"ps_key"`
PsId valueTypes.PsId `json:"ps_id"`
DeviceType valueTypes.Integer `json:"device_type"`
DeviceCode valueTypes.Integer `json:"device_code"`
ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id"`
PsName valueTypes.String `json:"ps_name"` PsName valueTypes.String `json:"ps_name"`
PsShortName valueTypes.String `json:"ps_short_name"` PsShortName valueTypes.String `json:"ps_short_name"`
ArmVersion interface{} `json:"arm_version"` ArmVersion interface{} `json:"arm_version"`
BatVersion valueTypes.String `json:"bat_version"` BatVersion valueTypes.String `json:"bat_version"`
BatteryVersion interface{} `json:"battery_version"` BatteryVersion interface{} `json:"battery_version"`
ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id"`
CommandStatus valueTypes.Integer `json:"command_status"` CommandStatus valueTypes.Integer `json:"command_status"`
CommunicationDevUUID valueTypes.Integer `json:"communication_dev_uuid"` CommunicationDevUUID valueTypes.Integer `json:"communication_dev_uuid"`
CountryId valueTypes.Integer `json:"country_id"` CountryId valueTypes.Integer `json:"country_id"`
@ -61,7 +64,6 @@ type ResultData struct {
DevStatus valueTypes.Integer `json:"dev_status"` DevStatus valueTypes.Integer `json:"dev_status"`
DeviceArea valueTypes.String `json:"device_area"` DeviceArea valueTypes.String `json:"device_area"`
DeviceAreaName valueTypes.String `json:"device_area_name"` DeviceAreaName valueTypes.String `json:"device_area_name"`
DeviceCode valueTypes.Integer `json:"device_code"`
DeviceFactoryId interface{} `json:"device_factory_id"` DeviceFactoryId interface{} `json:"device_factory_id"`
DeviceModel valueTypes.String `json:"device_model"` DeviceModel valueTypes.String `json:"device_model"`
DeviceModelCode valueTypes.String `json:"device_model_code"` DeviceModelCode valueTypes.String `json:"device_model_code"`
@ -69,7 +71,6 @@ type ResultData struct {
DeviceName valueTypes.String `json:"device_name"` DeviceName valueTypes.String `json:"device_name"`
DeviceProSn valueTypes.String `json:"device_pro_sn"` DeviceProSn valueTypes.String `json:"device_pro_sn"`
DeviceStatus valueTypes.Integer `json:"device_status"` DeviceStatus valueTypes.Integer `json:"device_status"`
DeviceType valueTypes.Integer `json:"device_type"`
FactoryName valueTypes.String `json:"factory_name"` FactoryName valueTypes.String `json:"factory_name"`
GridTypeId valueTypes.Float `json:"grid_type_id"` GridTypeId valueTypes.Float `json:"grid_type_id"`
InstallerDevFaultStatus valueTypes.Float `json:"installer_dev_fault_status"` InstallerDevFaultStatus valueTypes.Float `json:"installer_dev_fault_status"`

View File

@ -47,14 +47,16 @@ type ResultData struct {
CodeTypeName valueTypes.String `json:"code_type_name"` CodeTypeName valueTypes.String `json:"code_type_name"`
} `json:"subTypeList" PointId:"sub_type_list" PointArrayFlatten:"false" DataTable:"true"` } `json:"subTypeList" PointId:"sub_type_list" PointArrayFlatten:"false" DataTable:"true"`
PsId valueTypes.PsId `json:"ps_id"`
PsKey valueTypes.String `json:"ps_key"` PsKey valueTypes.String `json:"ps_key"`
PsName valueTypes.String `json:"ps_name"` PsId valueTypes.PsId `json:"ps_id"`
DeviceType valueTypes.Integer `json:"device_type"`
DeviceCode valueTypes.Integer `json:"device_code"`
ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id"`
PsName valueTypes.String `json:"ps_name"`
ArmVersion interface{} `json:"arm_version"` ArmVersion interface{} `json:"arm_version"`
BatVersion valueTypes.String `json:"bat_version"` BatVersion valueTypes.String `json:"bat_version"`
BatteryVersion interface{} `json:"battery_version"` BatteryVersion interface{} `json:"battery_version"`
ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id"`
CommandStatus valueTypes.Integer `json:"command_status"` CommandStatus valueTypes.Integer `json:"command_status"`
CommunicationDevUUID valueTypes.Integer `json:"communication_dev_uuid"` CommunicationDevUUID valueTypes.Integer `json:"communication_dev_uuid"`
CountryId valueTypes.Integer `json:"country_id"` CountryId valueTypes.Integer `json:"country_id"`
@ -64,7 +66,6 @@ type ResultData struct {
DevStatus valueTypes.Integer `json:"dev_status"` DevStatus valueTypes.Integer `json:"dev_status"`
DeviceArea valueTypes.String `json:"device_area"` DeviceArea valueTypes.String `json:"device_area"`
DeviceAreaName valueTypes.String `json:"device_area_name"` DeviceAreaName valueTypes.String `json:"device_area_name"`
DeviceCode valueTypes.Integer `json:"device_code"`
DeviceFactoryId interface{} `json:"device_factory_id"` DeviceFactoryId interface{} `json:"device_factory_id"`
DeviceModel valueTypes.String `json:"device_model"` DeviceModel valueTypes.String `json:"device_model"`
DeviceModelCode valueTypes.String `json:"device_model_code"` DeviceModelCode valueTypes.String `json:"device_model_code"`
@ -72,7 +73,6 @@ type ResultData struct {
DeviceName valueTypes.String `json:"device_name"` DeviceName valueTypes.String `json:"device_name"`
DeviceProSn valueTypes.String `json:"device_pro_sn"` DeviceProSn valueTypes.String `json:"device_pro_sn"`
DeviceStatus valueTypes.Integer `json:"device_status"` DeviceStatus valueTypes.Integer `json:"device_status"`
DeviceType valueTypes.Integer `json:"device_type"`
FactoryName valueTypes.String `json:"factory_name"` FactoryName valueTypes.String `json:"factory_name"`
GridTypeId valueTypes.Float `json:"grid_type_id"` GridTypeId valueTypes.Float `json:"grid_type_id"`
InstallerDevFaultStatus valueTypes.Float `json:"installer_dev_fault_status"` InstallerDevFaultStatus valueTypes.Float `json:"installer_dev_fault_status"`

View File

@ -27,57 +27,7 @@ func (rd RequestData) Help() string {
} }
type ResultData struct { type ResultData struct {
PageList []struct { PageList []Device `json:"pageList" PointId:"devices"`
GoStruct GoStruct.GoStruct `json:"-" PointIdFrom:"PsKey" PointIdReplace:"true" PointDeviceFrom:"PsKey"`
PointData []PointStruct `json:"point_data" PointId:"data" PointIdReplace:"true" DataTable:"true"` // PointIdFromChild:"PointId" PointIdReplace:"true" PointId:"data" DataTable:"true"`
PsTimezoneInfo struct {
IsDst valueTypes.Bool `json:"is_dst" PointUpdateFreq:"UpdateFreqInstant"`
TimeZone valueTypes.String `json:"time_zone" PointUpdateFreq:"UpdateFreqInstant"`
} `json:"psTimezoneInfo" PointId:"ps_timezone_info"`
AlarmCount valueTypes.Count `json:"alarm_count" PointId:"alarm_count" PointUpdateFreq:"UpdateFreqTotal"`
ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id" PointUpdateFreq:"UpdateFreqBoot"`
CommandStatus valueTypes.Integer `json:"command_status" PointId:"command_status" PointUpdateFreq:"UpdateFreqInstant"`
ComponentAmount valueTypes.Integer `json:"component_amount" PointId:"component_amount"`
DataFlag valueTypes.Integer `json:"data_flag" PointId:"data_flag" PointUpdateFreq:"UpdateFreqBoot"`
DataFlagDetail valueTypes.Integer `json:"data_flag_detail" PointId:"data_flag_detail"`
DeviceArea valueTypes.Integer `json:"device_area" PointId:"device_area" PointUpdateFreq:"UpdateFreqBoot"` // References UUID and referenced by UUIDIndexCode
DeviceAreaName valueTypes.String `json:"device_area_name" PointId:"device_area_name" PointUpdateFreq:"UpdateFreqBoot"`
DeviceCode valueTypes.Integer `json:"device_code" PointId:"device_code" PointUpdateFreq:"UpdateFreqBoot"`
DeviceId valueTypes.Integer `json:"device_id" PointId:"device_id" PointUpdateFreq:"UpdateFreqBoot"`
DeviceModelCode valueTypes.String `json:"device_model_code" PointId:"device_model_code" PointUpdateFreq:"UpdateFreqBoot"`
DeviceModelId valueTypes.Integer `json:"device_model_id" PointId:"device_model_id" PointUpdateFreq:"UpdateFreqBoot"`
DeviceName valueTypes.String `json:"device_name" PointId:"device_name" PointUpdateFreq:"UpdateFreqBoot"`
DeviceStatus valueTypes.Bool `json:"device_status" PointId:"device_status" PointUpdateFreq:"UpdateFreqInstant"`
DeviceType valueTypes.Integer `json:"device_type" PointId:"device_type" PointUpdateFreq:"UpdateFreqBoot"`
FaultCount valueTypes.Count `json:"fault_count" PointId:"fault_count" PointUpdateFreq:"UpdateFreqTotal"`
FaultStatus valueTypes.String `json:"fault_status" PointId:"fault_status" PointUpdateFreq:"UpdateFreqInstant"`
FunctionEnum valueTypes.String `json:"function_enum" PointId:"function_enum" PointUpdateFreq:"UpdateFreqInstant"`
InstallerAlarmCount valueTypes.Count `json:"installer_alarm_count" PointId:"installer_alarm_count" PointUpdateFreq:"UpdateFreqTotal"`
InstallerDevFaultStatus valueTypes.Integer `json:"installer_dev_fault_status" PointId:"installer_dev_fault_status" PointUpdateFreq:"UpdateFreqInstant"`
InstallerFaultCount valueTypes.Count `json:"installer_fault_count" PointId:"installer_fault_count" PointUpdateFreq:"UpdateFreqTotal"`
InverterModelType valueTypes.Integer `json:"inverter_model_type" PointId:"inverter_model_type" PointUpdateFreq:"UpdateFreqBoot"`
IsDeveloper valueTypes.Bool `json:"is_developer" PointId:"is_developer" PointUpdateFreq:"UpdateFreqBoot"`
IsG2point5Module valueTypes.Bool `json:"is_g2point5_module" PointId:"is_g2point5_module" PointUpdateFreq:"UpdateFreqBoot"`
IsInit valueTypes.Bool `json:"is_init" PointId:"is_init" PointUpdateFreq:"UpdateFreqBoot"`
IsSecond valueTypes.Bool `json:"is_second" PointId:"is_second" PointUpdateFreq:"UpdateFreqBoot"`
IsSupportParamset valueTypes.Bool `json:"is_support_paramset" PointId:"is_support_paramset" PointUpdateFreq:"UpdateFreqBoot"`
NodeTimestamps interface{} `json:"node_timestamps" PointId:"node_timestamps"`
OwnerAlarmCount valueTypes.Count `json:"owner_alarm_count" PointId:"owner_alarm_count" PointUpdateFreq:"UpdateFreqTotal"`
OwnerDevFaultStatus valueTypes.Integer `json:"owner_dev_fault_status" PointId:"owner_dev_fault_status" PointUpdateFreq:"UpdateFreqInstant"`
OwnerFaultCount valueTypes.Count `json:"owner_fault_count" PointId:"owner_fault_count" PointUpdateFreq:"UpdateFreqTotal"`
Points interface{} `json:"points" PointId:"points"`
PsId valueTypes.PsId `json:"ps_id" PointId:"ps_id" PointUpdateFreq:"UpdateFreqBoot"`
PsKey valueTypes.PsKey `json:"ps_key" PointId:"ps_key" PointUpdateFreq:"UpdateFreqBoot"`
RelState valueTypes.Integer `json:"rel_state" PointId:"rel_state" PointUpdateFreq:"UpdateFreqInstant"`
Sn valueTypes.String `json:"sn" PointId:"sn" PointName:"Serial Number" PointUpdateFreq:"UpdateFreqBoot"`
StringAmount valueTypes.Integer `json:"string_amount" PointId:"string_amount"`
TypeName valueTypes.String `json:"type_name" PointId:"type_name" PointUpdateFreq:"UpdateFreqBoot"`
UnitName valueTypes.String `json:"unit_name" PointId:"unit_name" PointUpdateFreq:"UpdateFreqBoot"`
UUID valueTypes.Integer `json:"uuid" PointId:"uuid" PointUpdateFreq:"UpdateFreqBoot"` // Referenced by DeviceArea
UUIDIndexCode valueTypes.String `json:"uuid_index_code" PointId:"uuid_index_code" PointUpdateFreq:"UpdateFreqBoot"` // Referenced by DeviceArea
} `json:"pageList" PointId:"devices"`
DevCountByStatusMap struct { DevCountByStatusMap struct {
FaultCount valueTypes.Count `json:"fault_count" PointId:"fault_count" PointUpdateFreq:"UpdateFreqTotal"` FaultCount valueTypes.Count `json:"fault_count" PointId:"fault_count" PointUpdateFreq:"UpdateFreqTotal"`
@ -86,7 +36,7 @@ type ResultData struct {
WarningCount valueTypes.Count `json:"warning_count" PointId:"warning_count" PointUpdateFreq:"UpdateFreqTotal"` WarningCount valueTypes.Count `json:"warning_count" PointId:"warning_count" PointUpdateFreq:"UpdateFreqTotal"`
} `json:"dev_count_by_status_map" PointId:"device_status_count"` } `json:"dev_count_by_status_map" PointId:"device_status_count"`
DevCountByTypeMap map[string]valueTypes.Integer `json:"dev_count_by_type_map" PointId:"device_type_count" PointUpdateFreq:"UpdateFreqBoot"` DevCountByTypeMap map[string]valueTypes.Integer `json:"dev_count_by_type_map" PointId:"device_type_count" PointUpdateFreq:"UpdateFreqBoot"`
DevTypeDefinition map[string]valueTypes.String `json:"dev_type_definition" PointId:"device_types" PointUpdateFreq:"UpdateFreqBoot"` DevTypeDefinition map[string]valueTypes.String `json:"dev_type_definition" PointId:"device_types" PointUpdateFreq:"UpdateFreqBoot"` // DataTable:"true"`
RowCount valueTypes.Integer `json:"rowCount" PointId:"row_count"` RowCount valueTypes.Integer `json:"rowCount" PointId:"row_count"`
} }
// DevCountByTypeMap struct { // DevCountByTypeMap struct {
@ -144,6 +94,59 @@ type ResultData struct {
// Nine9 valueTypes.String `json:"99"` // Nine9 valueTypes.String `json:"99"`
// } `json:"dev_type_definition"` // } `json:"dev_type_definition"`
type Device struct {
GoStruct GoStruct.GoStruct `json:"-" PointIdFrom:"PsKey" PointIdReplace:"true" PointDeviceFrom:"PsKey"`
PsKey valueTypes.PsKey `json:"ps_key" PointId:"ps_key" PointUpdateFreq:"UpdateFreqBoot"`
PsId valueTypes.PsId `json:"ps_id" PointId:"ps_id" PointUpdateFreq:"UpdateFreqBoot"`
DeviceType valueTypes.Integer `json:"device_type" PointId:"device_type" PointUpdateFreq:"UpdateFreqBoot"`
DeviceCode valueTypes.Integer `json:"device_code" PointId:"device_code" PointUpdateFreq:"UpdateFreqBoot"`
ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id" PointUpdateFreq:"UpdateFreqBoot"`
Sn valueTypes.String `json:"sn" PointId:"sn" PointName:"Serial Number" PointUpdateFreq:"UpdateFreqBoot"`
AlarmCount valueTypes.Count `json:"alarm_count" PointId:"alarm_count" PointUpdateFreq:"UpdateFreqTotal"`
CommandStatus valueTypes.Integer `json:"command_status" PointId:"command_status" PointUpdateFreq:"UpdateFreqInstant"`
ComponentAmount valueTypes.Integer `json:"component_amount" PointId:"component_amount"`
DataFlag valueTypes.Integer `json:"data_flag" PointId:"data_flag" PointUpdateFreq:"UpdateFreqBoot"`
DataFlagDetail valueTypes.Integer `json:"data_flag_detail" PointId:"data_flag_detail"`
DeviceArea valueTypes.Integer `json:"device_area" PointId:"device_area" PointUpdateFreq:"UpdateFreqBoot"` // References UUID and referenced by UUIDIndexCode
DeviceAreaName valueTypes.String `json:"device_area_name" PointId:"device_area_name" PointUpdateFreq:"UpdateFreqBoot"`
DeviceId valueTypes.Integer `json:"device_id" PointId:"device_id" PointUpdateFreq:"UpdateFreqBoot"`
DeviceModelCode valueTypes.String `json:"device_model_code" PointId:"device_model_code" PointUpdateFreq:"UpdateFreqBoot"`
DeviceModelId valueTypes.Integer `json:"device_model_id" PointId:"device_model_id" PointUpdateFreq:"UpdateFreqBoot"`
DeviceName valueTypes.String `json:"device_name" PointId:"device_name" PointUpdateFreq:"UpdateFreqBoot"`
DeviceStatus valueTypes.Bool `json:"device_status" PointId:"device_status" PointUpdateFreq:"UpdateFreqInstant"`
FaultCount valueTypes.Count `json:"fault_count" PointId:"fault_count" PointUpdateFreq:"UpdateFreqTotal"`
FaultStatus valueTypes.String `json:"fault_status" PointId:"fault_status" PointUpdateFreq:"UpdateFreqInstant"`
FunctionEnum valueTypes.String `json:"function_enum" PointId:"function_enum" PointUpdateFreq:"UpdateFreqInstant"`
InstallerAlarmCount valueTypes.Count `json:"installer_alarm_count" PointId:"installer_alarm_count" PointUpdateFreq:"UpdateFreqTotal"`
InstallerDevFaultStatus valueTypes.Integer `json:"installer_dev_fault_status" PointId:"installer_dev_fault_status" PointUpdateFreq:"UpdateFreqInstant"`
InstallerFaultCount valueTypes.Count `json:"installer_fault_count" PointId:"installer_fault_count" PointUpdateFreq:"UpdateFreqTotal"`
InverterModelType valueTypes.Integer `json:"inverter_model_type" PointId:"inverter_model_type" PointUpdateFreq:"UpdateFreqBoot"`
IsDeveloper valueTypes.Bool `json:"is_developer" PointId:"is_developer" PointUpdateFreq:"UpdateFreqBoot"`
IsG2point5Module valueTypes.Bool `json:"is_g2point5_module" PointId:"is_g2point5_module" PointUpdateFreq:"UpdateFreqBoot"`
IsInit valueTypes.Bool `json:"is_init" PointId:"is_init" PointUpdateFreq:"UpdateFreqBoot"`
IsSecond valueTypes.Bool `json:"is_second" PointId:"is_second" PointUpdateFreq:"UpdateFreqBoot"`
IsSupportParamset valueTypes.Bool `json:"is_support_paramset" PointId:"is_support_paramset" PointUpdateFreq:"UpdateFreqBoot"`
NodeTimestamps interface{} `json:"node_timestamps" PointId:"node_timestamps"`
OwnerAlarmCount valueTypes.Count `json:"owner_alarm_count" PointId:"owner_alarm_count" PointUpdateFreq:"UpdateFreqTotal"`
OwnerDevFaultStatus valueTypes.Integer `json:"owner_dev_fault_status" PointId:"owner_dev_fault_status" PointUpdateFreq:"UpdateFreqInstant"`
OwnerFaultCount valueTypes.Count `json:"owner_fault_count" PointId:"owner_fault_count" PointUpdateFreq:"UpdateFreqTotal"`
Points interface{} `json:"points" PointId:"points"`
RelState valueTypes.Integer `json:"rel_state" PointId:"rel_state" PointUpdateFreq:"UpdateFreqInstant"`
StringAmount valueTypes.Integer `json:"string_amount" PointId:"string_amount"`
TypeName valueTypes.String `json:"type_name" PointId:"type_name" PointUpdateFreq:"UpdateFreqBoot"`
UnitName valueTypes.String `json:"unit_name" PointId:"unit_name" PointUpdateFreq:"UpdateFreqBoot"`
UUID valueTypes.Integer `json:"uuid" PointId:"uuid" PointUpdateFreq:"UpdateFreqBoot"` // Referenced by DeviceArea
UUIDIndexCode valueTypes.String `json:"uuid_index_code" PointId:"uuid_index_code" PointUpdateFreq:"UpdateFreqBoot"` // Referenced by DeviceArea
PointData []PointStruct `json:"point_data" PointId:"data" PointIdReplace:"true" DataTable:"true"` // PointIdFromChild:"PointId" PointIdReplace:"true" PointId:"data" DataTable:"true"`
PsTimezoneInfo struct {
IsDst valueTypes.Bool `json:"is_dst" PointUpdateFreq:"UpdateFreqInstant"`
TimeZone valueTypes.String `json:"time_zone" PointUpdateFreq:"UpdateFreqInstant"`
} `json:"psTimezoneInfo" PointId:"ps_timezone_info"`
}
type PointStruct struct { type PointStruct struct {
GoStruct GoStruct.GoStruct `json:"-" PointIdFrom:"PointId" PointIdReplace:"true" PointTimestampFrom:"TimeStamp" PointDeviceFromParent:"PsKey"` GoStruct GoStruct.GoStruct `json:"-" PointIdFrom:"PointId" PointIdReplace:"true" PointTimestampFrom:"TimeStamp" PointDeviceFromParent:"PsKey"`
// GoStruct GoStruct.GoStruct `json:"-" PointDeviceFromParent:"PsKey"` // GoStruct GoStruct.GoStruct `json:"-" PointDeviceFromParent:"PsKey"`

View File

@ -17,8 +17,9 @@ type RequestData struct {
PsKeyList valueTypes.String `json:"ps_key_list" required:"true"` PsKeyList valueTypes.String `json:"ps_key_list" required:"true"`
} }
func (rd RequestData) IsValid() error { func (rd *RequestData) IsValid() error {
return GoStruct.VerifyOptionsRequired(rd) rd.PsKeyList = valueTypes.SetStringValue("1171348_11_0_0")
return GoStruct.VerifyOptionsRequired(*rd)
} }
func (rd RequestData) Help() string { func (rd RequestData) Help() string {

View File

@ -19,7 +19,7 @@ type RequestData struct {
StartTimeStamp valueTypes.DateTime `json:"start_time_stamp" required:"true"` StartTimeStamp valueTypes.DateTime `json:"start_time_stamp" required:"true"`
EndTimeStamp valueTypes.DateTime `json:"end_time_stamp" required:"true"` EndTimeStamp valueTypes.DateTime `json:"end_time_stamp" required:"true"`
MinuteInterval valueTypes.Integer `json:"minute_interval" required:"true"` MinuteInterval valueTypes.Integer `json:"minute_interval" required:"true"`
PsKeys valueTypes.PsKey `json:"ps_key" required:"true"` PsKeys valueTypes.PsKeys `json:"ps_key" required:"true"`
Points valueTypes.PointIds `json:"points" required:"true"` Points valueTypes.PointIds `json:"points" required:"true"`
} }
@ -39,8 +39,8 @@ type ResultData struct {
type Data map[valueTypes.DateTime]Value type Data map[valueTypes.DateTime]Value
type Value struct { type Value struct {
GoStructParent GoStruct.GoStructParent `json:"-" PointIdFrom:"PsKey.Timestamp" PointIdReplace:"true"` GoStructParent GoStruct.GoStructParent `json:"-" PointIdFrom:"PsKey.Timestamp" PointIdReplace:"true" PointDeviceFrom:"PsKey"`
// GoStruct GoStruct.GoStruct `json:"-" PointIdFrom:"PsKey" PointIdReplace:"false" PointDeviceFrom:"PsKey"` // GoStruct GoStruct.GoStruct `json:"-" PointDeviceFrom:"PsKey"`
Timestamp valueTypes.DateTime `json:"timestamp" PointNameDateFormat:"2006-01-02 15:04:05"` Timestamp valueTypes.DateTime `json:"timestamp" PointNameDateFormat:"2006-01-02 15:04:05"`
PsKey valueTypes.PsKey `json:"ps_key"` PsKey valueTypes.PsKey `json:"ps_key"`

View File

@ -8,7 +8,13 @@ import (
type Device struct { type Device struct {
GoStruct GoStruct.GoStruct `json:"GoStruct" PointIdFrom:"PsId" PointIdReplace:"true" PointDeviceFrom:"PsId"` GoStruct GoStruct.GoStruct `json:"GoStruct" PointIdFrom:"PsId" PointIdReplace:"true" PointDeviceFrom:"PsId"`
PsId valueTypes.PsId `json:"ps_id"`
PsKey valueTypes.PsKey `json:"ps_key" PointId:"ps_key" PointUpdateFreq:"UpdateFreqBoot"`
PsId valueTypes.PsId `json:"ps_id" PointId:"ps_id" PointUpdateFreq:"UpdateFreqBoot"`
DeviceType valueTypes.Integer `json:"device_type" PointId:"device_type" PointUpdateFreq:"UpdateFreqBoot"`
DeviceCode valueTypes.Integer `json:"device_code" PointId:"device_code" PointUpdateFreq:"UpdateFreqBoot"`
ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id" PointUpdateFreq:"UpdateFreqBoot"`
PsName valueTypes.String `json:"ps_name"` PsName valueTypes.String `json:"ps_name"`
PsStatus valueTypes.Bool `json:"ps_status"` PsStatus valueTypes.Bool `json:"ps_status"`
PsIsNotInit valueTypes.Bool `json:"ps_is_not_init"` PsIsNotInit valueTypes.Bool `json:"ps_is_not_init"`

View File

@ -31,8 +31,8 @@ type ResultData struct {
PsKey valueTypes.String `json:"pskey" PointId:"ps_key"` PsKey valueTypes.String `json:"pskey" PointId:"ps_key"`
PsId valueTypes.Integer `json:"ps_id"` PsId valueTypes.Integer `json:"ps_id"`
DeviceType valueTypes.Integer `json:"device_type"` DeviceType valueTypes.Integer `json:"device_type"`
// DeviceCode valueTypes.Integer `json:"device_code"` DeviceCode valueTypes.Integer `json:"device_code"`
// ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id"` ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id"`
AttrId valueTypes.Integer `json:"attr_id"` AttrId valueTypes.Integer `json:"attr_id"`
ComponentAmount valueTypes.Integer `json:"component_amount"` ComponentAmount valueTypes.Integer `json:"component_amount"`

View File

@ -27,21 +27,24 @@ func (rd RequestData) Help() string {
return ret return ret
} }
type ResultData []Points type ResultData []Point
type Points struct { // type Points []Point
type Point struct {
GoStruct.GoStructParent `json:"-" DataTable:"true" DataTableSortOn:"Id"` GoStruct.GoStructParent `json:"-" DataTable:"true" DataTableSortOn:"Id"`
// GoStruct.GoStruct `json:"-" PointIdFrom:"PsId" PointIdReplace:"false"` // GoStruct.GoStruct `json:"-" PointIdFrom:"PsId" PointIdReplace:"false"`
PsId valueTypes.Integer `json:"psid" PointId:"ps_id"` PsId valueTypes.Integer `json:"psid" PointId:"ps_id"`
DeviceType valueTypes.Integer `json:"pid" PointId:"device_type"` DeviceType valueTypes.Integer `json:"pid" PointId:"device_type"`
ChannelId valueTypes.Integer `json:"chnnlid" PointId:"channel_id"`
StationName valueTypes.String `json:"stationname" PointId:"station_name"` StationName valueTypes.String `json:"stationname" PointId:"station_name"`
StationShortName valueTypes.String `json:"stationshortname" PointId:"station_short_name"` StationShortName valueTypes.String `json:"stationshortname" PointId:"station_short_name"`
IsParent valueTypes.Bool `json:"isparent" PointId:"is_parent"` IsParent valueTypes.Bool `json:"isparent" PointId:"is_parent"`
DeviceModelId valueTypes.Integer `json:"device_model_id"` DeviceModelId valueTypes.Integer `json:"device_model_id"`
DeviceName valueTypes.String `json:"devicename" PointId:"device_name"` DeviceName valueTypes.String `json:"devicename" PointId:"device_name"`
AType valueTypes.Integer `json:"atype" PointId:"a_type"` AType valueTypes.Integer `json:"atype" PointId:"a_type"`
ChannelId valueTypes.Integer `json:"chnnlid" PointId:"channel_id"`
CodeId valueTypes.Integer `json:"code_id"` CodeId valueTypes.Integer `json:"code_id"`
CType valueTypes.Integer `json:"ctype" PointId:"c_type"` CType valueTypes.Integer `json:"ctype" PointId:"c_type"`
@ -68,6 +71,6 @@ func (e *EndPoint) GetData() api.DataMap {
return entries return entries
} }
func (e *EndPoint) Points() []Points { func (e *EndPoint) Points() []Point {
return e.Response.ResultData return e.Response.ResultData
} }

View File

@ -26,13 +26,13 @@ func (rd RequestData) Help() string {
} }
type ResultData []struct { type ResultData []struct {
GoStructParent GoStruct.GoStructParent `json:"-" PointIdFromChild:"PsId" PointIdReplace:"true" DataTable:"true" DataTableSortOn:"PsId"` GoStruct.GoStructParent `json:"-" DataTable:"true" DataTableSortOn:"PsId"` // PointIdFrom:"PsId" PointIdReplace:"true"`
GoStruct GoStruct.GoStruct `json:"-" PointDeviceFrom:"PsId"`
PsId valueTypes.Integer `json:"psid" PointId:"ps_id"` PsId valueTypes.Integer `json:"psid" PointId:"ps_id"`
Id valueTypes.Integer `json:"id"` Id valueTypes.Integer `json:"id"`
ChannelId valueTypes.Integer `json:"chnnlid" PointId:"channel_id"` ChannelId valueTypes.Integer `json:"chnnlid" PointId:"channel_id"`
Pid valueTypes.Integer `json:"pid"` Pid valueTypes.Integer `json:"pid"`
Name valueTypes.String `json:"name"` Name valueTypes.String `json:"name"`
IsParent valueTypes.Bool `json:"isparent" PointId:"is_parent"` IsParent valueTypes.Bool `json:"isparent" PointId:"is_parent"`
Level valueTypes.Integer `json:"level"` Level valueTypes.Integer `json:"level"`

View File

@ -25,14 +25,18 @@ func (rd RequestData) Help() string {
return ret return ret
} }
type ResultData []struct { type ResultData []Device
type Device struct {
GoStructParent GoStruct.GoStructParent `json:"-" DataTable:"true" DataTableSortOn:"UUID"` GoStructParent GoStruct.GoStructParent `json:"-" DataTable:"true" DataTableSortOn:"UUID"`
UUID valueTypes.Integer `json:"uuid"` UUID valueTypes.Integer `json:"uuid"`
DeviceCode valueTypes.Integer `json:"device_code"` DeviceCode valueTypes.Integer `json:"device_code"`
DeviceType valueTypes.Integer `json:"device_type"` DeviceType valueTypes.Integer `json:"device_type"`
ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id"` ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id"`
DeviceId valueTypes.Integer `json:"device_id"` DeviceId valueTypes.Integer `json:"device_id"`
TypeName valueTypes.String `json:"type_name"` TypeName valueTypes.String `json:"type_name"`
DeviceName valueTypes.String `json:"device_name"` DeviceName valueTypes.String `json:"device_name"`
IsPublic valueTypes.Bool `json:"is_public"` IsPublic valueTypes.Bool `json:"is_public"`

View File

@ -18,6 +18,7 @@ import (
type GraphRequest struct { type GraphRequest struct {
Title string `json:"title"` Title string `json:"title"`
SubTitle string `json:"sub_title"`
TimeColumn *string `json:"time_column"` TimeColumn *string `json:"time_column"`
DataColumn *string `json:"value_column"` DataColumn *string `json:"value_column"`
@ -107,6 +108,10 @@ func (t *Table) SetGraph(req GraphRequest) error {
func (t *Table) SetGraphFromJson(j Json) error { func (t *Table) SetGraphFromJson(j Json) error {
for range Only.Once { for range Only.Once {
if j == "" {
break
}
gr := JsonToGraphRequest(j) gr := JsonToGraphRequest(j)
if gr.Error != nil { if gr.Error != nil {
t.Error = gr.Error t.Error = gr.Error
@ -272,9 +277,7 @@ func (t *Table) CreateGraph() error {
type Chart struct { type Chart struct {
Error error `json:"-"` Error error `json:"-"`
// otherSearch SearchStrings
searchName string searchName string
title string
req GraphRequest req GraphRequest
filename string filename string
timeSeries1 chart.TimeSeries timeSeries1 chart.TimeSeries
@ -515,10 +518,7 @@ func (c *Chart) ProcessGraphData(table *Table) error {
// } // }
} }
var filename string c.Error = c.SetFilename(table.filePrefix)
// filename = fmt.Sprintf("%s-%s.png", t.filePrefix, strings.ReplaceAll(t.graph.searchName, " ", ""))
filename = fmt.Sprintf("%s.png", table.filePrefix)
c.Error = c.SetFilename(filename)
if c.Error != nil { if c.Error != nil {
break break
} }
@ -536,6 +536,50 @@ func (c *Chart) ProcessGraphData(table *Table) error {
if c.Error != nil { if c.Error != nil {
break break
} }
c.timeSeries1.Style = chart.Style {
StrokeColor: drawing.ColorBlue,
FillColor: drawing.ColorBlue.WithAlpha(64),
}
c.minSeries = &chart.MinSeries {
Name: "Min",
Style: chart.Style {
// StrokeColor: chart.ColorAlternateGray,
// StrokeColor: drawing.ColorBlue,
// FillColor: drawing.ColorBlue.WithAlpha(50),
StrokeColor: drawing.ColorBlue,
StrokeDashArray: []float64{5.0, 5.0},
DotWidth: 0.5,
},
InnerSeries: c.timeSeries1,
}
c.maxSeries = &chart.MaxSeries {
Name: "Max",
Style: chart.Style {
// StrokeColor: chart.ColorAlternateGray,
// StrokeColor: drawing.ColorGreen,
// FillColor: drawing.ColorGreen.WithAlpha(64),
StrokeColor: drawing.ColorBlue,
StrokeDashArray: []float64{5.0, 5.0},
DotWidth: 1.0,
},
InnerSeries: c.timeSeries1,
}
c.graph.Series = []chart.Series {
c.timeSeries1,
// c.annotation,
c.minSeries,
c.maxSeries,
chart.LastValueAnnotationSeries(c.minSeries),
chart.LastValueAnnotationSeries(c.maxSeries),
// c.timeSeries2,
}
c.graph.DPI = 150
c.graph.Elements = []chart.Renderable{chart.Legend(&c.graph)}
} }
return c.Error return c.Error
@ -576,8 +620,10 @@ func (c *Chart) SetFilename(fn string) error {
c.Error = errors.New("empty filename") c.Error = errors.New("empty filename")
break break
} }
fn = strings.TrimSuffix(fn, ".png") fn = strings.TrimSuffix(fn, ".png")
fn = strings.TrimSuffix(fn, ".PNG") fn = strings.TrimSuffix(fn, ".PNG")
fn = strings.ReplaceAll(fn, " ", "_")
c.filename = fn + ".png" c.filename = fn + ".png"
} }
return c.Error return c.Error
@ -585,7 +631,7 @@ func (c *Chart) SetFilename(fn string) error {
func (c *Chart) SetTitle(title string) error { func (c *Chart) SetTitle(title string) error {
c.graph.Title = title c.graph.Title = title
// c.req.Title = title // c.title = title
return c.Error return c.Error
} }
@ -752,7 +798,7 @@ func (c *Chart) SetY(name string, values ...float64) error {
} }
if (c.req.DataMin == nil) && (c.req.DataMax == nil) { if (c.req.DataMin == nil) && (c.req.DataMax == nil) {
rng := ((maxY - minY) / 2) * 0.5 rng := ((maxY - minY) / 2) * 0.25
nMin := minY - rng nMin := minY - rng
if (nMin < 0.0) && (minY >= 0.0) { if (nMin < 0.0) && (minY >= 0.0) {
// If the subtraction has sent us negative. // If the subtraction has sent us negative.
@ -839,61 +885,6 @@ func (c *Chart) Generate() error {
break break
} }
c.timeSeries1.Style = chart.Style {
StrokeColor: drawing.ColorBlue,
FillColor: drawing.ColorBlue.WithAlpha(64),
}
c.minSeries = &chart.MinSeries {
Name: "Min",
Style: chart.Style {
// StrokeColor: chart.ColorAlternateGray,
// StrokeColor: drawing.ColorBlue,
// FillColor: drawing.ColorBlue.WithAlpha(50),
StrokeColor: drawing.ColorBlue,
StrokeDashArray: []float64{5.0, 5.0},
DotWidth: 0.5,
},
InnerSeries: c.timeSeries1,
}
c.maxSeries = &chart.MaxSeries {
Name: "Max",
Style: chart.Style {
// StrokeColor: chart.ColorAlternateGray,
// StrokeColor: drawing.ColorGreen,
// FillColor: drawing.ColorGreen.WithAlpha(64),
StrokeColor: drawing.ColorBlue,
StrokeDashArray: []float64{5.0, 5.0},
DotWidth: 1.0,
},
InnerSeries: c.timeSeries1,
}
c.graph.Series = []chart.Series {
c.timeSeries1,
// c.annotation,
c.minSeries,
c.maxSeries,
chart.LastValueAnnotationSeries(c.minSeries),
chart.LastValueAnnotationSeries(c.maxSeries),
// c.timeSeries2,
}
c.graph.DPI = 150
c.graph.Elements = []chart.Renderable{chart.Legend(&c.graph)}
for range Only.Once {
if c.req.Title != "" {
c.graph.Title = c.req.Title
break
}
if c.title != "" {
c.graph.Title = c.title
break
}
}
fmt.Printf("Creating graph file '%s'\n", c.filename) fmt.Printf("Creating graph file '%s'\n", c.filename)
var f *os.File var f *os.File
f, c.Error = os.Create(c.filename) f, c.Error = os.Create(c.filename)

View File

@ -651,6 +651,8 @@ func (r *Reflect) Init(parent interface{}, current interface{}, name EndPointPat
r.Value, r.IsNil, r.IsOk = valueTypes.AnyToUnitValue( r.Value, r.IsNil, r.IsOk = valueTypes.AnyToUnitValue(
r.InterfaceValue, "", r.DataStructure.PointUnit, r.InterfaceValue, "", r.DataStructure.PointUnit,
r.DataStructure.PointValueType, r.DataStructure.PointNameDateFormat) r.DataStructure.PointValueType, r.DataStructure.PointNameDateFormat)
r.SetUnit()
r.Value.SetDeviceId(r.DataStructure.PointDevice)
case reflect.Slice: case reflect.Slice:
fallthrough fallthrough
@ -671,6 +673,8 @@ func (r *Reflect) Init(parent interface{}, current interface{}, name EndPointPat
r.Value, r.IsNil, r.IsOk = valueTypes.AnyToUnitValue( r.Value, r.IsNil, r.IsOk = valueTypes.AnyToUnitValue(
r.InterfaceValue, "", r.DataStructure.PointUnit, r.InterfaceValue, "", r.DataStructure.PointUnit,
r.DataStructure.PointValueType, r.DataStructure.PointNameDateFormat) r.DataStructure.PointValueType, r.DataStructure.PointNameDateFormat)
r.SetUnit()
r.Value.SetDeviceId(r.DataStructure.PointDevice)
case reflect.Map: case reflect.Map:
r.Length = len(r.ValueOf.MapKeys()) r.Length = len(r.ValueOf.MapKeys())
@ -691,6 +695,8 @@ func (r *Reflect) Init(parent interface{}, current interface{}, name EndPointPat
r.Value, r.IsNil, r.IsOk = valueTypes.AnyToUnitValue( r.Value, r.IsNil, r.IsOk = valueTypes.AnyToUnitValue(
r.InterfaceValue, "", r.DataStructure.PointUnit, r.InterfaceValue, "", r.DataStructure.PointUnit,
r.DataStructure.PointValueType, r.DataStructure.PointNameDateFormat) r.DataStructure.PointValueType, r.DataStructure.PointNameDateFormat)
r.SetUnit()
r.Value.SetDeviceId(r.DataStructure.PointDevice)
} }
// r.SetGoStructOptions() // r.SetGoStructOptions()
@ -798,6 +804,7 @@ func (r *Reflect) SetByIndex(parent *Reflect, current *Reflect, index int, index
r.InterfaceValue, "", r.DataStructure.PointUnit, r.InterfaceValue, "", r.DataStructure.PointUnit,
r.DataStructure.PointValueType, r.DataStructure.PointNameDateFormat) r.DataStructure.PointValueType, r.DataStructure.PointNameDateFormat)
r.SetUnit() r.SetUnit()
r.Value.SetDeviceId(r.DataStructure.PointDevice)
case reflect.Slice: case reflect.Slice:
fallthrough fallthrough
@ -851,6 +858,7 @@ func (r *Reflect) SetByIndex(parent *Reflect, current *Reflect, index int, index
r.InterfaceValue, "", r.DataStructure.PointUnit, r.InterfaceValue, "", r.DataStructure.PointUnit,
r.DataStructure.PointValueType, r.DataStructure.PointNameDateFormat) r.DataStructure.PointValueType, r.DataStructure.PointNameDateFormat)
r.SetUnit() r.SetUnit()
r.Value.SetDeviceId(r.DataStructure.PointDevice)
case reflect.Map: case reflect.Map:
r.FieldTo = reflect.StructField{} r.FieldTo = reflect.StructField{}
@ -897,6 +905,7 @@ func (r *Reflect) SetByIndex(parent *Reflect, current *Reflect, index int, index
r.InterfaceValue, "", r.DataStructure.PointUnit, r.InterfaceValue, "", r.DataStructure.PointUnit,
r.DataStructure.PointValueType, r.DataStructure.PointNameDateFormat) r.DataStructure.PointValueType, r.DataStructure.PointNameDateFormat)
r.SetUnit() r.SetUnit()
r.Value.SetDeviceId(r.DataStructure.PointDevice)
default: default:

View File

@ -228,20 +228,74 @@ func (ta *StructTable) GetValues() StructValues {
var colName = func(sub *Reflect, value *valueTypes.UnitValue, length int) string { var colName = func(sub *Reflect, value *valueTypes.UnitValue, length int) string {
name := sub.DataStructure.PointName name := sub.DataStructure.PointName
if value.ValueKey() == "" { var pointName bool
if name == "" { if sub.DataStructure.PointName != "" {
name = "Column " + strconv.Itoa(length) pointName = true
}
} else {
name += " " + value.ValueKey()
} }
var deviceId bool
if value.DeviceId() != "" {
deviceId = true
}
var valueKey bool
if value.ValueKey() != "" {
valueKey = true
}
switch {
case pointName == true && deviceId == true && valueKey == true:
name = value.DeviceId() + "." + value.ValueKey()
case pointName == true && deviceId == true && valueKey == false:
name = value.DeviceId() + "." + sub.DataStructure.PointName
case pointName == true && deviceId == false && valueKey == true:
name = value.ValueKey()
case pointName == true && deviceId == false && valueKey == false:
name = sub.DataStructure.PointName
case pointName == false && deviceId == true && valueKey == true:
name = value.DeviceId() + "." + value.ValueKey()
case pointName == false && deviceId == true && valueKey == false:
name = "Column " + strconv.Itoa(length)
case pointName == false && deviceId == false && valueKey == true:
name = value.ValueKey()
case pointName == false && deviceId == false && valueKey == false:
name = "Column " + strconv.Itoa(length)
}
// if value.DeviceId() != "" {
// if name != "" {
// // Prepend DeviceId to PointName.
// name = value.DeviceId() + "." + sub.DataStructure.PointName
// } else {
// name = value.DeviceId()
// }
// }
// if value.ValueKey() != "" {
// if name != "" {
// name += "." + value.ValueKey()
// } else {
// name = value.ValueKey()
// }
// } else {
// if name == "" {
// name = "Column " + strconv.Itoa(length)
// }
// }
// if value.ValueKey() == "" {
// if name == "" {
// name = "Column " + strconv.Itoa(length)
// }
// } else {
// name += " " + value.ValueKey()
// }
switch value.Unit() { switch value.Unit() {
case "--": case "--":
case "": case "":
default: default:
if !sub.DataStructure.PointVariableUnit { if !sub.DataStructure.PointVariableUnit {
name += " (" + value.Unit() + ")" name += " (" + value.Unit() + ")"
} }
} }
return name return name
} }
@ -334,10 +388,10 @@ func (ta *StructTable) GetValues() StructValues {
name := sub.DataStructure.PointName name := sub.DataStructure.PointName
if !sub.DataStructure.PointVariableUnit { if !sub.DataStructure.PointVariableUnit {
switch sub.Value.GetUnit() { switch sub.Value.GetUnit() {
case "--": case "--":
case "": case "":
default: default:
name += " (" + sub.Value.GetUnit() + ")" name += " (" + sub.Value.GetUnit() + ")"
} }
addCol(name) addCol(name)
} else { } else {
@ -459,8 +513,7 @@ func (ta *StructTable) GetValues() StructValues {
} }
ta.Columns = sortMapByValues(colOrder) ta.Columns = sortMapByValues(colOrder)
// @TODO - Add row sorting capability here.
// @TODO - Add sorting capability here.
} }
return ta.Values return ta.Values

View File

@ -86,9 +86,9 @@ func (dt *DateTime) UnmarshalJSON(data []byte) error {
for _, f := range inputDateLayout { for _, f := range inputDateLayout {
dt.Time, dt.Error = time.Parse(f, string(data)) dt.Time, dt.Error = time.Parse(f, string(data))
if dt.Error == nil { if dt.Error == nil {
dt.SetDateType(string(data))
dt.format = f dt.format = f
dt.string = dt.Time.Format(DateTimeLayout) dt.string = dt.Time.Format(DateTimeLayout)
dt.SetDateType(string(data))
break break
} }
} }
@ -158,9 +158,9 @@ func (dt *DateTime) SetString(value string) DateTime {
for _, f := range inputDateLayout { for _, f := range inputDateLayout {
dt.Time, dt.Error = time.Parse(f, value) dt.Time, dt.Error = time.Parse(f, value)
if dt.Error == nil { if dt.Error == nil {
dt.SetDateType(value)
dt.format = f dt.format = f
dt.string = dt.Time.Format(f) dt.string = dt.Time.Format(f)
dt.SetDateType(value)
break break
} }
} }
@ -182,8 +182,8 @@ func (dt *DateTime) SetValue(value time.Time) DateTime {
break break
} }
dt.string = value.Format(DateTimeLayout)
dt.format = DateTimeLayout dt.format = DateTimeLayout
dt.string = value.Format(dt.format)
dt.DateType = "3" dt.DateType = "3"
} }
@ -191,23 +191,35 @@ func (dt *DateTime) SetValue(value time.Time) DateTime {
} }
func (dt *DateTime) SetDateType(value string) { func (dt *DateTime) SetDateType(value string) {
switch { for range Only.Once {
case len(value) == len(DateTimeLayout): l := len(value)
dt.DateType = "1" switch {
case len(value) == len(DateTimeLayoutYear): case l == len(DateTimeLayout):
dt.DateType = "3" dt.DateType = "1"
case len(value) == len(DateTimeLayoutMonth): dt.format = DateTimeLayout
dt.DateType = "2" case l == len(DateTimeLayoutYear):
case len(value) == len(DateTimeLayoutDay): dt.DateType = "3"
dt.DateType = "1" dt.format = DateTimeLayoutYear
case len(value) == len(DateTimeLayoutHour): case l == len(DateTimeLayoutMonth):
dt.DateType = "1" dt.DateType = "2"
case len(value) == len(DateTimeLayoutMinute): dt.format = DateTimeLayoutMonth
dt.DateType = "1" case l == len(DateTimeLayoutDay):
case len(value) == len(DateTimeLayoutSecond): dt.DateType = "1"
dt.DateType = "1" dt.format = DateTimeLayoutDay
case value == "total": case l == len(DateTimeLayoutHour):
dt.DateType = "4" dt.DateType = "1"
dt.format = DateTimeLayoutHour
case l == len(DateTimeLayoutMinute):
dt.DateType = "1"
dt.format = DateTimeLayoutMinute
case l == len(DateTimeLayoutSecond):
dt.DateType = "1"
dt.format = DateTimeLayoutSecond
case value == "total":
dt.DateType = "4"
dt.format = DateTimeLayoutYear
}
dt.string = dt.Time.Format(dt.format)
} }
} }
@ -231,6 +243,7 @@ func (dt *DateTime) GetDayStartTimestamp() string {
func (dt *DateTime) SetDayStart() { func (dt *DateTime) SetDayStart() {
dt.Time = dt.Time.Round(time.Hour * 24) dt.Time = dt.Time.Round(time.Hour * 24)
dt.string = dt.Time.Format(dt.format)
} }
func (dt *DateTime) GetDayEndTimestamp() string { func (dt *DateTime) GetDayEndTimestamp() string {
@ -242,7 +255,8 @@ func (dt *DateTime) GetDayEndTimestamp() string {
} }
func (dt *DateTime) SetDayEnd() { func (dt *DateTime) SetDayEnd() {
dt.Time = dt.Time.Round(time.Hour * 24).Add(time.Hour * 24) dt.Time = dt.Time.Truncate(time.Hour * 24).Add(time.Hour * 24)
dt.string = dt.Time.Format(dt.format)
} }
func (dt DateTime) PrintFull() string { func (dt DateTime) PrintFull() string {
@ -293,9 +307,9 @@ func NewDateTime(value string) DateTime {
for _, f := range inputDateLayout { for _, f := range inputDateLayout {
ret.Time, ret.Error = time.Parse(f, value) ret.Time, ret.Error = time.Parse(f, value)
if ret.Error == nil { if ret.Error == nil {
ret.format = f
ret.SetValue(ret.Time) ret.SetValue(ret.Time)
ret.SetDateType(value) ret.SetDateType(value)
ret.format = f
break break
} }
} }

View File

@ -75,6 +75,16 @@ func (t Integer) Match(comp int64) bool {
return false return false
} }
func (t Integer) MatchString(comp string) bool {
if comp == "" {
return false
}
if t.string == comp {
return true
}
return false
}
func (t *Integer) SetString(value string) Integer { func (t *Integer) SetString(value string) Integer {
for range Only.Once { for range Only.Once {
t.string = value t.string = value

View File

@ -90,6 +90,10 @@ func (t PsKey) String() string {
return a[0] return a[0]
} }
func (t *PsKey) PsIdDeviceType() string {
return t.PsId + "_" + t.DeviceType
}
func (t *PsKey) Match(comp string) bool { func (t *PsKey) Match(comp string) bool {
if t.string == comp { if t.string == comp {
return true return true
@ -112,14 +116,14 @@ func (t *PsKey) SetValue(value string) PsKey {
s := strings.Split(value, "_") s := strings.Split(value, "_")
switch { switch {
case len(s) <= 1: case len(s) == 1:
t.PsId = s[0] t.PsId = s[0]
t.Valid = true t.Valid = true
case len(s) == 2: case len(s) == 2:
t.PsId = s[0] t.PsId = s[0]
t.DeviceType = s[1] t.DeviceType = s[1]
t.Valid = true t.Valid = true
case len(s) >= 3: case len(s) == 3:
t.PsId = s[0] t.PsId = s[0]
t.DeviceType = s[1] t.DeviceType = s[1]
t.DeviceCode = s[2] t.DeviceCode = s[2]
@ -565,6 +569,18 @@ func (t PsKeys) String() string {
return ret return ret
} }
func (t *PsKeys) Join(sep string) string {
return strings.Join(t.Strings(), sep)
}
func (t *PsKeys) Strings() []string {
var ret []string
for _, pskey := range t.PsKeys {
ret = append(ret, pskey.String())
}
return ret
}
func (t *PsKeys) Set(values ...string) PsKeys { func (t *PsKeys) Set(values ...string) PsKeys {
for _, value := range values { for _, value := range values {
for _, v := range strings.Split(value, ",") { for _, v := range strings.Split(value, ",") {
@ -577,6 +593,43 @@ func (t *PsKeys) Set(values ...string) PsKeys {
return *t return *t
} }
func (t *PsKeys) Match(pskey PsKey) bool {
var yes bool
for _, value := range t.PsKeys {
if pskey.String() == value.String() {
yes = true
break
}
}
return yes
}
func (t *PsKeys) MatchPsIdDeviceType(psid string, deviceType string) PsKey {
var ret PsKey
for _, value := range t.PsKeys {
if value.PsId != psid {
continue
}
if value.DeviceType != deviceType {
continue
}
ret = value
break
}
return ret
}
func (t *PsKeys) MatchString(pskey string) bool {
var yes bool
for _, value := range t.PsKeys {
if pskey == value.String() {
yes = true
break
}
}
return yes
}
func SetPsKeysString(values string) PsKeys { func SetPsKeysString(values string) PsKeys {
var t PsKeys var t PsKeys
t.Set(strings.Split(values, ",")...) t.Set(strings.Split(values, ",")...)
@ -651,14 +704,14 @@ func (t *PointIds) Set(values ...string) PointIds {
return *t return *t
} }
func (t *PointIds) PsKeys() PsKeys { func (t *PointIds) PsKeys() *PsKeys {
var ret PsKeys var ret PsKeys
var psks []string var psks []string
for _, pskey := range t.PointIds { for _, pskey := range t.PointIds {
psks = append(psks, pskey.PsKey.String()) psks = append(psks, pskey.PsKey.String())
} }
ret = SetPsKeysString(strings.Join(psks, ",")) ret = SetPsKeysString(strings.Join(psks, ","))
return ret return &ret
} }
func (t *PointIds) PsIds() PsIds { func (t *PointIds) PsIds() PsIds {
@ -671,8 +724,12 @@ func (t *PointIds) PsIds() PsIds {
return ret return ret
} }
func SetPointIdsString(values string) PointIds { func SetPointIdsString(values ...string) PointIds {
var t PointIds var t PointIds
t.Set(strings.Split(values, ",")...) var vals []string
for _, value := range values {
vals = append(vals, strings.Split(value, ",")...)
}
t.Set(vals...)
return t return t
} }

View File

@ -316,6 +316,7 @@ func AnyToUnitValue(ref interface{}, key string, unit string, typeString string,
uv, isNil, ok = AnyToUnitValue(val, key, unit, typeString, dateFormat) // uvs.AddUnitValue(ref.(UnitValue)) uv, isNil, ok = AnyToUnitValue(val, key, unit, typeString, dateFormat) // uvs.AddUnitValue(ref.(UnitValue))
uvs.AddUnitValues(key, uv) uvs.AddUnitValues(key, uv)
} }
// uvs.SetUnit(unit)
break break
} }

View File

@ -524,7 +524,7 @@ func (t *UnitValue) SetBoolString(value string) UnitValue {
func (t *UnitValue) SetUnit(unit string) UnitValue { func (t *UnitValue) SetUnit(unit string) UnitValue {
for range Only.Once { for range Only.Once {
t.UnitValue = unit t.UnitValue = unit
t.TypeValue = UnitValueType(unit) t.SetType(UnitValueType(unit))
} }
return *t return *t
@ -532,6 +532,9 @@ func (t *UnitValue) SetUnit(unit string) UnitValue {
func (t *UnitValue) SetType(Type string) UnitValue { func (t *UnitValue) SetType(Type string) UnitValue {
for range Only.Once { for range Only.Once {
if Type == "" {
break
}
t.TypeValue = Type t.TypeValue = Type
} }
@ -540,6 +543,9 @@ func (t *UnitValue) SetType(Type string) UnitValue {
func (t *UnitValue) SetDeviceId(deviceId string) UnitValue { func (t *UnitValue) SetDeviceId(deviceId string) UnitValue {
for range Only.Once { for range Only.Once {
if deviceId == "" {
break
}
t.deviceId = deviceId t.deviceId = deviceId
} }
@ -622,8 +628,8 @@ func SetUnitValueBool(value bool) UnitValue {
type UnitValues struct { type UnitValues struct {
arrayValues []UnitValue arrayValues []*UnitValue
mapValues map[string]UnitValue mapValues map[string]*UnitValue
mapOrder []string mapOrder []string
Unit string `json:"unit"` Unit string `json:"unit"`
@ -704,8 +710,7 @@ func (t *UnitValues) GetUnit() string {
if t.IsMap() { if t.IsMap() {
for _, k := range t.mapOrder { for _, k := range t.mapOrder {
m := t.mapValues[k] ret = t.mapValues[k].Unit()
ret = m.Unit()
break break
} }
break break
@ -714,11 +719,11 @@ func (t *UnitValues) GetUnit() string {
return ret return ret
} }
func (t *UnitValues) GetmapValues() map[string]UnitValue { func (t *UnitValues) GetmapValues() map[string]*UnitValue {
return t.mapValues return t.mapValues
} }
func (t *UnitValues) GetarrayValues() []UnitValue { func (t *UnitValues) GetarrayValues() []*UnitValue {
return t.arrayValues return t.arrayValues
} }
@ -729,7 +734,7 @@ func (t *UnitValues) Range(loadOrder bool) []UnitValue {
for range Only.Once { for range Only.Once {
if t.IsArray() { if t.IsArray() {
for _, k := range t.arrayValues { for _, k := range t.arrayValues {
ret = append(ret, k) ret = append(ret, *k)
} }
break break
} }
@ -737,7 +742,7 @@ func (t *UnitValues) Range(loadOrder bool) []UnitValue {
if t.IsMap() { if t.IsMap() {
if loadOrder { if loadOrder {
for _, k := range t.mapOrder { for _, k := range t.mapOrder {
ret = append(ret, t.mapValues[k]) ret = append(ret, *t.mapValues[k])
} }
break break
} }
@ -748,7 +753,7 @@ func (t *UnitValues) Range(loadOrder bool) []UnitValue {
} }
sort.Strings(keys) sort.Strings(keys)
for _, k := range keys { for _, k := range keys {
ret = append(ret, t.mapValues[k]) ret = append(ret, *t.mapValues[k])
} }
break break
} }
@ -805,6 +810,10 @@ func (t *UnitValues) Type() string {
func (t *UnitValues) SetType(Type string) *UnitValues { func (t *UnitValues) SetType(Type string) *UnitValues {
for range Only.Once { for range Only.Once {
if Type == "" {
break
}
t.TypeValue = Type t.TypeValue = Type
if t.IsArray() { if t.IsArray() {
@ -816,8 +825,7 @@ func (t *UnitValues) SetType(Type string) *UnitValues {
if t.IsMap() { if t.IsMap() {
for k := range t.mapValues { for k := range t.mapValues {
m := t.mapValues[k] t.mapValues[k].SetType(Type)
m.SetType(Type)
} }
break break
} }
@ -838,8 +846,7 @@ func (t *UnitValues) SetUnit(unit string) *UnitValues {
if t.IsMap() { if t.IsMap() {
for k := range t.mapValues { for k := range t.mapValues {
m := t.mapValues[k] t.mapValues[k].SetUnit(unit)
m.SetUnit(unit)
} }
break break
} }
@ -847,8 +854,28 @@ func (t *UnitValues) SetUnit(unit string) *UnitValues {
return t return t
} }
func (t *UnitValues) GetIndex(index int) UnitValue { func (t *UnitValues) SetDeviceId(deviceId string) *UnitValues {
var ret UnitValue for range Only.Once {
if t.IsArray() {
for k := range t.arrayValues {
t.arrayValues[k].SetDeviceId(deviceId)
}
break
}
if t.IsMap() {
for k := range t.mapValues {
t.mapValues[k].SetDeviceId(deviceId)
}
break
}
}
return t
}
func (t *UnitValues) GetIndex(index int) *UnitValue {
var ret *UnitValue
for range Only.Once { for range Only.Once {
if t.IsArray() { if t.IsArray() {
if index >= len(t.arrayValues) { if index >= len(t.arrayValues) {
@ -870,8 +897,8 @@ func (t *UnitValues) GetIndex(index int) UnitValue {
return ret return ret
} }
func (t *UnitValues) GetKey(key string) UnitValue { func (t *UnitValues) GetKey(key string) *UnitValue {
var ret UnitValue var ret *UnitValue
for range Only.Once { for range Only.Once {
if t.IsArray() { if t.IsArray() {
// Doesn't make sense to return anything. // Doesn't make sense to return anything.
@ -889,7 +916,7 @@ func (t *UnitValues) GetKey(key string) UnitValue {
} }
func (t *UnitValues) First() *UnitValue { func (t *UnitValues) First() *UnitValue {
var ret UnitValue var ret *UnitValue
for range Only.Once { for range Only.Once {
if t.IsArray() { if t.IsArray() {
if len(t.arrayValues) == 0 { if len(t.arrayValues) == 0 {
@ -908,11 +935,11 @@ func (t *UnitValues) First() *UnitValue {
break break
} }
} }
return &ret return ret
} }
func (t *UnitValues) Last() *UnitValue { func (t *UnitValues) Last() *UnitValue {
var ret UnitValue var ret *UnitValue
for range Only.Once { for range Only.Once {
if t.IsArray() { if t.IsArray() {
if len(t.arrayValues) == 0 { if len(t.arrayValues) == 0 {
@ -931,7 +958,7 @@ func (t *UnitValues) Last() *UnitValue {
break break
} }
} }
return &ret return ret
} }
@ -953,12 +980,12 @@ func (t *UnitValues) addMap(key string, value UnitValue) *UnitValues {
t.mapOrder = append(t.mapOrder, key) // Keep track of the order. t.mapOrder = append(t.mapOrder, key) // Keep track of the order.
if t.mapValues == nil { if t.mapValues == nil {
t.mapValues = make(map[string]UnitValue) t.mapValues = make(map[string]*UnitValue)
} }
if value.key == "" { if value.key == "" {
value.key = key value.key = key
} }
t.mapValues[key] = value t.mapValues[key] = &value
} }
return t return t
} }
@ -969,7 +996,7 @@ func (t *UnitValues) setupMap() bool {
if !t.IsInit() { if !t.IsInit() {
break break
} }
t.mapValues = make(map[string]UnitValue) t.mapValues = make(map[string]*UnitValue)
t.mapOrder = make([]string, 0) t.mapOrder = make([]string, 0)
yes = true yes = true
} }
@ -1067,12 +1094,12 @@ func (t *UnitValues) appendArray(value UnitValue) *UnitValues {
} }
if t.arrayValues == nil { if t.arrayValues == nil {
t.arrayValues = make([]UnitValue, 0) t.arrayValues = make([]*UnitValue, 0)
} }
if value.key == "" { if value.key == "" {
value.key = strconv.Itoa(len(t.arrayValues)) value.key = strconv.Itoa(len(t.arrayValues))
} }
t.arrayValues = append(t.arrayValues, value) t.arrayValues = append(t.arrayValues, &value)
} }
return t return t
} }
@ -1083,7 +1110,7 @@ func (t *UnitValues) setupArray() bool {
if !t.IsInit() { if !t.IsInit() {
break break
} }
t.arrayValues = make([]UnitValue, 0) t.arrayValues = make([]*UnitValue, 0)
yes = true yes = true
} }
return yes return yes

View File

@ -51,7 +51,7 @@ func (dm *DataMap) StructToDataMap(endpoint EndPoint, parentDeviceId string, nam
StartAt: "ResultData", StartAt: "ResultData",
Name: name, Name: name,
TimeStamp: dm.TimeStamp, TimeStamp: dm.TimeStamp,
Debug: false, Debug: dm.Debug,
AddUnexported: false, AddUnexported: false,
AddUnsupported: false, AddUnsupported: false,
AddInvalid: false, AddInvalid: false,
@ -83,6 +83,12 @@ func (dm *DataMap) AddPointUnitValues(Current *GoStruct.Reflect, parentDeviceId
point.UpdateFreq = Current.DataStructure.PointUpdateFreq point.UpdateFreq = Current.DataStructure.PointUpdateFreq
point.SetName(Current.DataStructure.PointName) point.SetName(Current.DataStructure.PointName)
// if Current.Value.DeviceId() != "" {
// parentDeviceId = Current.Value.DeviceId()
// } else {
// Current.Value.SetDeviceId(parentDeviceId)
// }
if Current.Value.GetUnit() != point.Unit { if Current.Value.GetUnit() != point.Unit {
if dm.Debug { if dm.Debug {
_, _ = fmt.Fprintf(os.Stderr, "OOOPS FP['%s'] - Point/Value unit mismatch - Point:%s != Value:%s (%f)\n", _, _ = fmt.Fprintf(os.Stderr, "OOOPS FP['%s'] - Point/Value unit mismatch - Point:%s != Value:%s (%f)\n",
@ -91,13 +97,6 @@ func (dm *DataMap) AddPointUnitValues(Current *GoStruct.Reflect, parentDeviceId
point.Unit = Current.Value.GetUnit() point.Unit = Current.Value.GetUnit()
} }
// Add arrays as multiple entries.
if Current.Value.Length() > 1 {
entries := CreatePointDataEntries(Current, parentDeviceId, point, date)
dm.Add(entries.Entries...)
break
}
if Current.Value.Length() == 0 { if Current.Value.Length() == 0 {
if dm.Debug { if dm.Debug {
_, _ = fmt.Fprintf(os.Stderr, "OOOPS FP['%s'] - UVS is nil\n", Current.FieldPath.String()) _, _ = fmt.Fprintf(os.Stderr, "OOOPS FP['%s'] - UVS is nil\n", Current.FieldPath.String())
@ -105,6 +104,13 @@ func (dm *DataMap) AddPointUnitValues(Current *GoStruct.Reflect, parentDeviceId
break break
} }
// Add arrays as multiple entries.
if Current.Value.Length() > 1 {
entries := CreatePointDataEntries(Current, parentDeviceId, point, date)
dm.Add(entries.Entries...)
break
}
de := CreatePointDataEntry(Current, parentDeviceId, point, date, *Current.Value.First()) de := CreatePointDataEntry(Current, parentDeviceId, point, date, *Current.Value.First())
dm.Add(de) dm.Add(de)
@ -286,12 +292,12 @@ func (dm *DataMap) ProcessMap() {
when = valueTypes.SetDateTimeValue(dm.TimeStamp) when = valueTypes.SetDateTimeValue(dm.TimeStamp)
} }
pdi := dm.parentDeviceId // pdi := dm.parentDeviceId
if Child.DataStructure.PointDevice != "" { // if Child.DataStructure.PointDevice != "" {
pdi = Child.DataStructure.PointDevice // pdi = Child.DataStructure.PointDevice
} // }
dm.AddPointUnitValues(Child, pdi, when) dm.AddPointUnitValues(Child, dm.parentDeviceId, when)
} }
// Convert Struct.VirtualMap to DataMap // Convert Struct.VirtualMap to DataMap
@ -307,10 +313,10 @@ func (dm *DataMap) ProcessMap() {
when = valueTypes.SetDateTimeValue(dm.TimeStamp) when = valueTypes.SetDateTimeValue(dm.TimeStamp)
} }
pdi := dm.parentDeviceId // pdi := dm.parentDeviceId
if Child.DataStructure.PointDevice != "" { // if Child.DataStructure.PointDevice != "" {
pdi = Child.DataStructure.PointDevice // pdi = Child.DataStructure.PointDevice
} // }
if Child.DataStructure.PointVirtualShift > 0 { if Child.DataStructure.PointVirtualShift > 0 {
Child.DataStructure.Endpoint.ShiftLeft(Child.DataStructure.PointVirtualShift) Child.DataStructure.Endpoint.ShiftLeft(Child.DataStructure.PointVirtualShift)
@ -318,7 +324,7 @@ func (dm *DataMap) ProcessMap() {
} else { } else {
Child.DataStructure.Endpoint.ReplaceFirst("virtual") Child.DataStructure.Endpoint.ReplaceFirst("virtual")
} }
dm.AddPointUnitValues(Child, pdi, when) dm.AddPointUnitValues(Child, dm.parentDeviceId, when)
} }
} }
} }
@ -536,6 +542,12 @@ func CreatePointDataEntry(Current *GoStruct.Reflect, parentDeviceId string, poin
// CreatePointDataEntry(Current, Current.EndPointPath().String(), parentDeviceId, point, date, *Current.Value.First()) // CreatePointDataEntry(Current, Current.EndPointPath().String(), parentDeviceId, point, date, *Current.Value.First())
var ret DataEntry var ret DataEntry
for range Only.Once { for range Only.Once {
if uv.DeviceId() != "" {
parentDeviceId = uv.DeviceId()
} else {
uv.SetDeviceId(parentDeviceId)
}
ret = DataEntry { ret = DataEntry {
Current: Current, Current: Current,
EndPoint: Current.EndPointPath().String(), EndPoint: Current.EndPointPath().String(),
@ -571,6 +583,12 @@ func CreatePointDataEntries(Current *GoStruct.Reflect, parentDeviceId string, po
epn = JoinWithDots(res, valueTypes.DateTimeLayoutDay, Current.EndPointPath().String(), uv.ValueKey()) epn = JoinWithDots(res, valueTypes.DateTimeLayoutDay, Current.EndPointPath().String(), uv.ValueKey())
} }
if uv.DeviceId() != "" {
parentDeviceId = uv.DeviceId()
} else {
uv.SetDeviceId(parentDeviceId)
}
ret.Entries = append(ret.Entries, DataEntry{ ret.Entries = append(ret.Entries, DataEntry{
Current: Current, Current: Current,
EndPoint: epn, // Current.EndPointPath().String(), EndPoint: epn, // Current.EndPointPath().String(),

View File

@ -1,10 +1,11 @@
package api package api
import ( import (
"github.com/MickMake/GoUnify/Only"
"GoSungrow/iSolarCloud/api/GoStruct" "GoSungrow/iSolarCloud/api/GoStruct"
"GoSungrow/iSolarCloud/api/GoStruct/output" "GoSungrow/iSolarCloud/api/GoStruct/output"
"github.com/MickMake/GoUnify/Only"
"github.com/MickMake/GoUnify/cmdPath" "github.com/MickMake/GoUnify/cmdPath"
"io"
"path/filepath" "path/filepath"
"time" "time"
@ -12,7 +13,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"net/http" "net/http"
) )
@ -151,7 +151,7 @@ func (w *Web) getApi(endpoint EndPoint) ([]byte, error) {
break break
} }
w.Body, w.Error = ioutil.ReadAll(w.httpResponse.Body) w.Body, w.Error = io.ReadAll(w.httpResponse.Body)
if w.Error != nil { if w.Error != nil {
break break
} }

11
iSolarCloud/const.go Normal file
View File

@ -0,0 +1,11 @@
package iSolarCloud
import "time"
//goland:noinspection SpellCheckingInspection
const (
DefaultHost = "https://augateway.isolarcloud.com"
DefaultApiAppKey = "93D72E60331ABDCDC7B39ADC2D1F32B3"
DefaultTimeout = time.Second * 30
)

View File

@ -8,6 +8,8 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/MickMake/GoUnify/Only" "github.com/MickMake/GoUnify/Only"
"os"
"sort"
"strings" "strings"
) )
@ -58,9 +60,15 @@ type SunGrowData struct {
sunGrow *SunGrow sunGrow *SunGrow
outputType output.OutputType outputType output.OutputType
saveAsFile bool saveAsFile bool
Debug bool
Error error Error error
} }
func (sgd *SunGrowData) PrintDebug(format string, args ...interface{}) {
if sgd.Debug { _, _ = fmt.Fprintf(os.Stderr, format, args...) }
}
func (sgd *SunGrowData) New(ref *SunGrow) { func (sgd *SunGrowData) New(ref *SunGrow) {
for range Only.Once { for range Only.Once {
sgd.sunGrow = ref sgd.sunGrow = ref
@ -164,10 +172,10 @@ func (sgd *SunGrowData) CallEndpoint(endpoint api.EndPoint, request SunGrowDataR
var req []byte var req []byte
req, sgd.Error = json.Marshal(request) req, sgd.Error = json.Marshal(request)
if sgd.Error != nil { if sgd.Error != nil {
fmt.Printf("GetEndpoint - ERR: %s\n", sgd.Error) fmt.Printf("GetEndPoint - Error: %s\n", sgd.Error)
break break
} }
// fmt.Printf("%s\n", req) // fmt.Printf("Request: %s\n", req)
if string(req) != "" { if string(req) != "" {
endpoint = endpoint.SetRequestByJson(output.Json(req)) endpoint = endpoint.SetRequestByJson(output.Json(req))
@ -177,7 +185,7 @@ func (sgd *SunGrowData) CallEndpoint(endpoint api.EndPoint, request SunGrowDataR
break break
} }
} }
// fmt.Printf("%s\n", endpoint.GetRequestJson()) sgd.PrintDebug("Request: %s\n", endpoint.GetRequestJson())
endpoint = endpoint.Call() endpoint = endpoint.Call()
sgd.Error = endpoint.GetError() sgd.Error = endpoint.GetError()
@ -187,26 +195,36 @@ func (sgd *SunGrowData) CallEndpoint(endpoint api.EndPoint, request SunGrowDataR
break break
} }
fmt.Println(endpoint.Help()) fmt.Println(endpoint.Help())
sgd.PrintDebug("Error response[%s]: %s\n", sgd.Error, endpoint.GetResponseJson())
break break
} }
sgd.PrintDebug("Response: %s\n", endpoint.GetResponseJson())
response.Data = endpoint.GetEndPointData() response.Data = endpoint.GetEndPointData()
args := request.GetArgs(response.Data.EndPoint) args := request.GetArgs(response.Data.EndPoint)
name := endpoint.GetArea().String() + "." + endpoint.GetName().String() name := endpoint.GetArea().String() + "." + endpoint.GetName().String()
var title string
var file string // + " - " + request.RequestAsFilePrefix(),
key := request.GetPrimaryArg()
if key != "" {
title = key
file = key
}
response.Options = OutputOptions { response.Options = OutputOptions {
Name: endpoint.GetName().String(), Name: name,
OutputType: sgd.sunGrow.OutputType, OutputType: sgd.sunGrow.OutputType,
FileSuffix: request.GetPrimaryArg(), // + " - " + request.RequestAsFilePrefix(), PrimaryKey: key,
FileSuffix: file,
SaveAsFile: sgd.sunGrow.SaveAsFile, SaveAsFile: sgd.sunGrow.SaveAsFile,
TitleSuffix: args, TitleSuffix: args,
GraphRequest: output.GraphRequest { GraphRequest: output.GraphRequest {
Title: name + " - " + args, Title: title,
SubTitle: args,
TimeColumn: nil, TimeColumn: nil,
DataColumn: nil, DataColumn: nil,
UnitsColumn: nil, UnitsColumn: nil,
NameColumn: nil, NameColumn: nil,
// DataColumn: nil,
DataMin: nil, DataMin: nil,
DataMax: nil, DataMax: nil,
Width: nil, Width: nil,
@ -214,6 +232,7 @@ func (sgd *SunGrowData) CallEndpoint(endpoint api.EndPoint, request SunGrowDataR
Error: nil, Error: nil,
}, },
} }
sgd.PrintDebug("OutputOptions: %v\n", response.Options)
} }
return response return response
@ -227,55 +246,151 @@ func (sgd *SunGrowData) GetData() error {
} }
for _, endpoint := range sgd.endPoints { for _, endpoint := range sgd.endPoints {
// Lookup endpoint interface from string. sgd.Error = sgd.GetDataSingle(endpoint)
ep := sgd.sunGrow.GetEndpoint(endpoint)
if sgd.sunGrow.IsError() {
sgd.Error = sgd.sunGrow.Error
break
}
sgd.Request.SetRequired(ep.GetRequestArgNames())
sgd.Request.SetArgs(sgd.Args...)
// PsId not required.
if sgd.Request.IsPsIdNotRequired() {
var result SunGrowDataResult
result.EndPointArea = ep.GetArea()
result.EndPointName = ep.GetName()
result.EndPoint = ep
result.Request = sgd.Request
result.Response = sgd.CallEndpoint(ep, result.Request)
sgd.Results[result.EndPointName.String()] = result
break
}
// PsId required and not set.
if len(sgd.Request.aPsId) == 0 {
sgd.SetPsIds()
if sgd.Error != nil {
break
}
}
// PsId required.
for _, psId := range sgd.Request.aPsId {
var result SunGrowDataResult
result.Request = sgd.Request
result.Request.SetPsId(psId.String())
result.EndPointArea = ep.GetArea()
result.EndPointName = ep.GetName()
result.EndPoint = ep
result.Response = sgd.CallEndpoint(ep, result.Request)
if sgd.Error != nil {
break
}
sgd.Results[result.EndPointName.String() + "/" + psId.String()] = result
}
if sgd.Error != nil { if sgd.Error != nil {
break break
} }
// // Lookup endpoint interface from string.
// ep := sgd.sunGrow.GetEndpoint(endpoint)
// if sgd.sunGrow.IsError() {
// sgd.Error = sgd.sunGrow.Error
// break
// }
// sgd.Request.SetRequired(ep.GetRequestArgNames())
// sgd.Request.SetArgs(sgd.Args...)
//
// // PsId not required.
// if sgd.Request.IsPsIdNotRequired() {
// var result SunGrowDataResult
//
// result.EndPointArea = ep.GetArea()
// result.EndPointName = ep.GetName()
// result.EndPoint = ep
// result.Request = sgd.Request
// result.Response = sgd.CallEndpoint(ep, result.Request)
// sgd.Results[result.EndPointName.String()] = result
// break
// }
//
// // PsId required and not set.
// if len(sgd.Request.aPsId) == 0 {
// sgd.SetPsIds()
// if sgd.Error != nil {
// break
// }
// }
//
// // PsId required.
// for _, psId := range sgd.Request.aPsId {
// var result SunGrowDataResult
// result.Request = sgd.Request
// result.Request.SetPsId(psId.String())
//
// result.EndPointArea = ep.GetArea()
// result.EndPointName = ep.GetName()
// result.EndPoint = ep
// result.Response = sgd.CallEndpoint(ep, result.Request)
// if sgd.Error != nil {
// break
// }
// sgd.Results[result.EndPointName.String() + "/" + psId.String()] = result
// }
//
// if sgd.Error != nil {
// break
// }
}
if sgd.Error != nil {
break
}
sgd.Error = sgd.Process()
if sgd.Error != nil {
break
}
}
return sgd.Error
}
func (sgd *SunGrowData) GetDataSingle(endpoint string) error {
for range Only.Once {
// Lookup endpoint interface from string.
ep := sgd.sunGrow.GetEndpoint(endpoint)
if sgd.sunGrow.IsError() {
sgd.Error = sgd.sunGrow.Error
break
}
sgd.Request.SetRequired(ep.GetRequestArgNames())
sgd.Request.SetArgs(sgd.Args...)
// PsId not required.
if sgd.Request.IsPsIdNotRequired() {
sgd.Error = sgd.getDataSinglePsIdNotRequired(ep)
break
}
// PsId required.
if sgd.Request.IsPsIdRequired() {
sgd.Error = sgd.getDataSinglePsIdRequired(ep)
break
}
}
return sgd.Error
}
func (sgd *SunGrowData) getDataSinglePsIdNotRequired(ep api.EndPoint) error {
for range Only.Once {
var result SunGrowDataResult
result.EndPointArea = ep.GetArea()
result.EndPointName = ep.GetName()
result.EndPoint = ep
result.Request = sgd.Request
result.Response = sgd.CallEndpoint(ep, result.Request)
if sgd.Error != nil {
break
}
sgd.Results[result.EndPointName.String()] = result
sgd.Error = sgd.Process()
if sgd.Error != nil {
break
}
}
return sgd.Error
}
func (sgd *SunGrowData) getDataSinglePsIdRequired(ep api.EndPoint) error {
for range Only.Once {
if sgd.Request.aPsId == nil {
sgd.SetPsIds()
}
for _, psId := range sgd.Request.aPsId {
var result SunGrowDataResult
result.Request = sgd.Request
result.Request.SetPsId(psId.String())
result.EndPointArea = ep.GetArea()
result.EndPointName = ep.GetName()
result.EndPoint = ep
result.Response = sgd.CallEndpoint(ep, result.Request)
if sgd.Error != nil {
break
}
sgd.Results[result.EndPointName.String() + "/" + psId.String()] = result
}
if sgd.Error != nil {
break
}
sgd.Error = sgd.Process()
if sgd.Error != nil {
break
} }
} }
@ -348,7 +463,7 @@ type SunGrowDataResult struct {
Error error Error error
} }
func (sgd *SunGrowDataResult) ProcessMap() error { func (sgd *SunGrowDataResult) Process() error {
sgd.Response.Data.ProcessMap() sgd.Response.Data.ProcessMap()
sgd.Error = sgd.Response.Data.Error sgd.Error = sgd.Response.Data.Error
return sgd.Error return sgd.Error
@ -360,17 +475,17 @@ func (sgd *SunGrowDataResult) ProcessMapForMqtt() error {
return sgd.Error return sgd.Error
} }
func (sgd *SunGrowDataResult) CreateResultTable(full bool) output.Table { // func (sgd *SunGrowDataResult) CreateResultTable(full bool) output.Table {
ret := sgd.Response.CreateResultTable(full) // ret := sgd.Response.CreateResultTable(full)
sgd.Error = sgd.Response.Data.Error // sgd.Error = sgd.Response.Data.Error
return ret // return ret
} // }
func (sgd *SunGrowDataResult) CreateDataTables() api.Tables { // func (sgd *SunGrowDataResult) CreateDataTables() api.Tables {
tables := sgd.Response.CreateDataTables() // tables := sgd.Response.CreateDataTables()
sgd.Error = sgd.Response.Data.Error // sgd.Error = sgd.Response.Data.Error
return tables // return tables
} // }
func (sgd *SunGrowDataResult) Sort() []string { func (sgd *SunGrowDataResult) Sort() []string {
return sgd.Response.Data.Sort() return sgd.Response.Data.Sort()
@ -382,11 +497,12 @@ func (sgd *SunGrowDataResult) Print() {
type OutputOptions struct { type OutputOptions struct {
Name string Name string
TitleSuffix string TitleSuffix string
OutputType output.OutputType OutputType output.OutputType
FileSuffix string PrimaryKey string
SaveAsFile bool FileSuffix string
SaveAsFile bool
GraphRequest output.GraphRequest GraphRequest output.GraphRequest
// table.InitGraph(output.GraphRequest { // table.InitGraph(output.GraphRequest {
@ -410,17 +526,17 @@ type SunGrowDataResponse struct {
Error error Error error
} }
func (sgd *SunGrowDataResponse) CreateResultTable(full bool) output.Table { // func (sgd *SunGrowDataResponse) CreateResultTable(full bool) output.Table {
ret := sgd.Data.CreateResultTable(full) // ret := sgd.Data.CreateResultTable(full)
sgd.Error = sgd.Data.Error // sgd.Error = sgd.Data.Error
return ret // return ret
} // }
func (sgd *SunGrowDataResponse) CreateDataTables() api.Tables { // func (sgd *SunGrowDataResponse) CreateDataTables() api.Tables {
tables := sgd.Data.CreateDataTables() // tables := sgd.Data.CreateDataTables()
sgd.Error = sgd.Data.Error // sgd.Error = sgd.Data.Error
return tables // return tables
} // }
func (sgd *SunGrowDataResponse) Output() error { func (sgd *SunGrowDataResponse) Output() error {
for range Only.Once { for range Only.Once {
@ -463,28 +579,121 @@ func (sgd *SunGrowDataResponse) OutputDataTables() error {
} }
// @iSolarCloud/api/struct_data.go:420 // @iSolarCloud/api/struct_data.go:420
if sgd.Options.OutputType.IsGraph() { // if sgd.Options.OutputType.IsGraph() {
for _, data := range tables { // for _, data := range tables {
// if !data.IsValid {
// fmt.Printf("# %s.%s - has no graphable data.\n", data.Area, data.Name)
// continue
// }
//
// if sgd.Options.TitleSuffix == "" {
// sgd.Options.TitleSuffix = data.Table.GetTitle()
// }
// data.Table.OutputType = sgd.Options.OutputType
// data.Table.SetSaveFile(true) // sgd.Options.SaveAsFile
// data.Table.AppendTitle(" - %s", sgd.Options.TitleSuffix)
// data.Table.AppendFilePrefix(sgd.Options.FileSuffix)
//
// if sgd.Options.GraphRequest.TimeColumn == nil {
// for _, col := range data.Table.GetHeaders() {
// val := data.Values.GetCell(0, col)
// if val.IsTypeDateTime() {
// sgd.Options.GraphRequest.TimeColumn = &col
// break
// }
// }
// }
// if sgd.Options.GraphRequest.TimeColumn == nil {
// // No time column - abort.
// break
// }
//
// if sgd.Options.GraphRequest.UnitsColumn != nil {
// for _, col := range data.Table.GetHeaders() {
// if *sgd.Options.GraphRequest.UnitsColumn != col {
// continue
// }
// val := data.Values.GetCell(0, col)
// unit := val.Unit()
// if unit != "" {
// continue
// }
// sgd.Options.GraphRequest.UnitsColumn = &col
// sgd.Options.GraphRequest.DataUnit = &unit
// break
// }
// }
//
// if sgd.Options.GraphRequest.NameColumn == nil {
// }
//
// // if sgd.Options.GraphRequest.Width == nil {
// // }
//
// // if sgd.Options.GraphRequest.Height == nil {
// // }
//
// var values []string
// if sgd.Options.GraphRequest.DataColumn == nil {
// fmt.Println("Finding points to graph...")
// fmt.Printf("Table Headers: %s\n", strings.Join(data.Table.GetHeaders(), ", "))
// fmt.Printf("Table rows: %d\n", data.Rows)
// // We don't have any DataColumn defined - find them.
// for _, col := range data.Table.GetHeaders() {
// val := data.Values.GetCell(0, col)
// if val.IsNumber() {
// values = append(values, col)
// }
// }
// fmt.Printf("Found %d points:\n", len(values))
// }
//
// // title := data.Table.GetTitle()
// // file := data.Table.GetFilePrefix()
// var title string
// var file string
// if sgd.Options.PrimaryKey == "" {
// title = fmt.Sprintf("%s.%s", data.Area, data.Name)
// file = fmt.Sprintf("%s.%ss", data.Area, data.Name)
// } else {
// title = fmt.Sprintf("%s.%s - %s", data.Area, data.Name, sgd.Options.PrimaryKey)
// file = fmt.Sprintf("%s.%s-%s", data.Area, data.Name, sgd.Options.PrimaryKey)
// }
//
// for _, value := range values {
// sgd.Options.GraphRequest.DataColumn = &value
// data.Table.SetTitle("%s - %s", title, value)
// sgd.Options.GraphRequest.Title = data.Table.GetTitle()
// data.Table.SetFilePrefix("%s-%s", file, value)
//
// sgd.Error = data.Table.SetGraph(sgd.Options.GraphRequest)
// if sgd.Error != nil {
// break
// }
//
// sgd.Error = data.Table.Output()
// if sgd.Error != nil {
// break
// }
// }
// }
// break
// }
for _, data := range tables {
if sgd.Options.TitleSuffix == "" {
sgd.Options.TitleSuffix = data.Table.GetTitle()
}
data.Table.OutputType = sgd.Options.OutputType
data.Table.SetSaveFile(sgd.Options.SaveAsFile) // sgd.Options.SaveAsFile
if sgd.Options.OutputType.IsGraph() {
if !data.IsValid { if !data.IsValid {
fmt.Printf("# %s.%s - has no data.\n", data.Area, data.Name) fmt.Printf("# %s.%s - has no graphable data.\n", data.Area, data.Name)
continue continue
} }
// table := tables[name]
// table.OutputType = sgd.Options.OutputType
// table.SetSaveFile(sgd.Options.SaveAsFile)
// table.SetFilePrefix("%s", sgd.Options.Filename)
// value := values[name]
// fmt.Printf("Writing (%d)\n", len(value))
// fmt.Printf("%v\n", table.GetHeaders())
if sgd.Options.TitleSuffix == "" {
sgd.Options.TitleSuffix = data.Table.GetTitle()
}
data.Table.OutputType = sgd.Options.OutputType
data.Table.SetSaveFile(true) data.Table.SetSaveFile(true)
data.Table.AppendTitle(" - %s", sgd.Options.TitleSuffix)
data.Table.AppendFilePrefix(sgd.Options.FileSuffix)
if sgd.Options.GraphRequest.TimeColumn == nil { if sgd.Options.GraphRequest.TimeColumn == nil {
for _, col := range data.Table.GetHeaders() { for _, col := range data.Table.GetHeaders() {
@ -495,25 +704,9 @@ func (sgd *SunGrowDataResponse) OutputDataTables() error {
} }
} }
} }
if sgd.Options.GraphRequest.TimeColumn == nil {
// if sgd.Options.GraphRequest.DataColumn == nil { // No time column - abort.
// for _, col := range data.Table.GetHeaders() { break
// val := data.Values.GetCell(0, col)
// if val.IsNumber() {
// sgd.Options.GraphRequest.DataColumn = &col
// break
// }
// }
// }
if sgd.Options.GraphRequest.DataColumn == nil {
for _, col := range data.Table.GetHeaders() {
val := data.Values.GetCell(0, col)
if val.IsNumber() {
sgd.Options.GraphRequest.DataColumn = &col
break
}
}
} }
if sgd.Options.GraphRequest.UnitsColumn != nil { if sgd.Options.GraphRequest.UnitsColumn != nil {
@ -535,42 +728,70 @@ func (sgd *SunGrowDataResponse) OutputDataTables() error {
if sgd.Options.GraphRequest.NameColumn == nil { if sgd.Options.GraphRequest.NameColumn == nil {
} }
// if sgd.Options.GraphRequest.DataMin == nil {
// zero := 0.0
// sgd.Options.GraphRequest.DataMin = &zero
// }
// if sgd.Options.GraphRequest.DataMax == nil {
// zero := 0.0
// sgd.Options.GraphRequest.DataMax = &zero
// }
// if sgd.Options.GraphRequest.Width == nil { // if sgd.Options.GraphRequest.Width == nil {
// } // }
// if sgd.Options.GraphRequest.Height == nil { // if sgd.Options.GraphRequest.Height == nil {
// } // }
sgd.Error = data.Table.SetGraph(sgd.Options.GraphRequest) var values []string
if sgd.Error != nil { if sgd.Options.GraphRequest.DataColumn == nil {
break fmt.Println("Finding points to graph...")
fmt.Printf("Table Headers: %s\n", strings.Join(data.Table.GetHeaders(), ", "))
fmt.Printf("Table rows: %d\n", data.Rows)
// We don't have any DataColumn defined - find them.
for _, col := range data.Table.GetHeaders() {
val := data.Values.GetCell(0, col)
if !val.IsNumber() {
continue
}
values = append(values, col)
// if val.ValueKey() == "" {
// values = append(values, col)
// continue
// }
// if val.DeviceId() == "" {
// values = append(values, val.ValueKey())
// continue
// }
// values = append(values, val.DeviceId() + "." + val.ValueKey())
}
fmt.Printf("Found %d points.\n", len(values))
} }
sgd.Error = data.Table.Output() title := data.Table.GetTitle()
if sgd.Error != nil { file := data.Table.GetFilePrefix()
break
sort.Strings(values)
for _, value := range values {
// @TODO - Lookup pointIds here.
sgd.Options.GraphRequest.DataColumn = &value
if sgd.Options.PrimaryKey != "" {
data.Table.SetTitle("%s - %s - %s", title, sgd.Options.PrimaryKey, value)
data.Table.SetFilePrefix("%s-%s-%s", file, sgd.Options.PrimaryKey, value)
} else {
data.Table.SetTitle("%s - %s", title, value)
data.Table.SetFilePrefix("%s-%s", file, value)
}
sgd.Options.GraphRequest.Title = data.Table.GetTitle()
sgd.Error = data.Table.SetGraph(sgd.Options.GraphRequest)
if sgd.Error != nil {
break
}
sgd.Error = data.Table.Output()
if sgd.Error != nil {
break
}
} }
break
} }
break
}
for _, data := range tables {
fmt.Println()
data.Table.OutputType = sgd.Options.OutputType
data.Table.SetSaveFile(sgd.Options.SaveAsFile)
data.Table.AppendTitle(" - %s", sgd.Options.TitleSuffix) data.Table.AppendTitle(" - %s", sgd.Options.TitleSuffix)
data.Table.AppendFilePrefix(sgd.Options.FileSuffix) data.Table.AppendFilePrefix(sgd.Options.FileSuffix)
fmt.Println()
sgd.Error = data.Table.Output() sgd.Error = data.Table.Output()
if sgd.Error != nil { if sgd.Error != nil {
break break
@ -581,6 +802,10 @@ func (sgd *SunGrowDataResponse) OutputDataTables() error {
return sgd.Error return sgd.Error
} }
func (sgd *SunGrowDataResponse) LookUpPointId() {
}
func (sgd *SunGrowDataResponse) Print() { func (sgd *SunGrowDataResponse) Print() {
sgd.Data.Print() sgd.Data.Print()
} }

View File

@ -833,6 +833,7 @@ func (sgd *SunGrowDataRequest) SetDateId(date string) {
sgd.args.DateId = &did sgd.args.DateId = &did
if sgd.args.DateId.IsZero() { if sgd.args.DateId.IsZero() {
did = valueTypes.NewDateTime(valueTypes.Now) did = valueTypes.NewDateTime(valueTypes.Now)
did.DateType = "4"
sgd.args.DateId = &did sgd.args.DateId = &did
} }
@ -1111,7 +1112,7 @@ func (sgd *SunGrowDataRequest) SetPoints(points string) {
} }
} }
if sgd.IsRequired(NamePsKeys) { if sgd.IsRequired(NamePsKeys) {
sgd.args.PsKeys = &psk sgd.args.PsKeys = psk
} }
} }
} }

View File

@ -18,7 +18,6 @@ import (
"GoSungrow/iSolarCloud/api/GoStruct/valueTypes" "GoSungrow/iSolarCloud/api/GoStruct/valueTypes"
"fmt" "fmt"
"github.com/MickMake/GoUnify/Only" "github.com/MickMake/GoUnify/Only"
"strings"
"time" "time"
) )
@ -206,14 +205,16 @@ func (sg *SunGrow) GetIsolarcloudMqtt(appKey string) error {
func (sg *SunGrow) GetRealTimeData(psKey string) error { func (sg *SunGrow) GetRealTimeData(psKey string) error {
for range Only.Once { for range Only.Once {
if psKey == "" { if psKey == "" {
var psKeys []string // var psKeys []string
psKeys, sg.Error = sg.GetPsKeys() // psKeys, sg.Error = sg.GetPsKeys()
if sg.IsError() { // if sg.IsError() {
break // break
} // }
fmt.Printf("psKeys: %v\n", psKeys) // fmt.Printf("psKeys: %v\n", psKeys)
psKey = strings.Join(psKeys, ",") // psKey = strings.Join(psKeys, ",")
} }
fmt.Println("TO FIX")
break
ep := sg.GetByStruct(queryDeviceRealTimeDataByPsKeys.EndPointName, ep := sg.GetByStruct(queryDeviceRealTimeDataByPsKeys.EndPointName,
queryDeviceRealTimeDataByPsKeys.RequestData{PsKeyList: valueTypes.SetStringValue(psKey)}, queryDeviceRealTimeDataByPsKeys.RequestData{PsKeyList: valueTypes.SetStringValue(psKey)},
@ -489,7 +490,7 @@ func (sg *SunGrow) GetPsModels() ([]string, error) {
for range Only.Once { for range Only.Once {
var psIds valueTypes.PsIds var psIds valueTypes.PsIds
psIds, sg.Error = sg.PsIds() psIds, sg.Error = sg.GetPsIds()
if sg.Error != nil { if sg.Error != nil {
break break
} }
@ -516,7 +517,7 @@ func (sg *SunGrow) GetPsSerials() ([]string, error) {
for range Only.Once { for range Only.Once {
var psIds valueTypes.PsIds var psIds valueTypes.PsIds
psIds, sg.Error = sg.PsIds() psIds, sg.Error = sg.GetPsIds()
if sg.Error != nil { if sg.Error != nil {
break break
} }
@ -537,30 +538,3 @@ func (sg *SunGrow) GetPsSerials() ([]string, error) {
return ret, sg.Error return ret, sg.Error
} }
func (sg *SunGrow) GetPsKeys() ([]string, error) {
var ret []string
for range Only.Once {
var psIds valueTypes.PsIds
psIds, sg.Error = sg.PsIds()
if sg.Error != nil {
break
}
for _, psId := range psIds {
ep := sg.GetByStruct(getPsDetailWithPsType.EndPointName,
// getPsDetailWithPsType.RequestData{PsId: strconv.FormatInt(psId, 10)},
getPsDetailWithPsType.RequestData{PsId: psId},
DefaultCacheTimeout)
if sg.IsError() {
break
}
data := getPsDetailWithPsType.Assert(ep)
ret = append(ret, data.GetPsKeys()...)
}
}
return ret, sg.Error
}

View File

@ -4,18 +4,21 @@ import (
"GoSungrow/iSolarCloud/AppService/getDeviceList" "GoSungrow/iSolarCloud/AppService/getDeviceList"
"GoSungrow/iSolarCloud/AppService/getDeviceModelInfoList" "GoSungrow/iSolarCloud/AppService/getDeviceModelInfoList"
"GoSungrow/iSolarCloud/AppService/getPowerDevicePointNames" "GoSungrow/iSolarCloud/AppService/getPowerDevicePointNames"
"GoSungrow/iSolarCloud/AppService/queryDeviceList"
"GoSungrow/iSolarCloud/api/GoStruct/valueTypes" "GoSungrow/iSolarCloud/api/GoStruct/valueTypes"
"errors"
"fmt" "fmt"
"github.com/MickMake/GoUnify/Only" "github.com/MickMake/GoUnify/Only"
datatable "go.pennock.tech/tabular/auto" datatable "go.pennock.tech/tabular/auto"
"sort"
"strings" "strings"
"time" "time"
) )
// GetDeviceList - AppService.getDeviceList // GetDeviceList - AppService.getDeviceList
func (sg *SunGrow) GetDeviceList(psIds ...string) (getDeviceList.Devices, error) { func (sg *SunGrow) GetDeviceList(psIds ...string) ([]getDeviceList.Device, error) {
var ret getDeviceList.Devices var ret []getDeviceList.Device
for range Only.Once { for range Only.Once {
pids := sg.SetPsIds(psIds...) pids := sg.SetPsIds(psIds...)
@ -42,6 +45,35 @@ func (sg *SunGrow) GetDeviceList(psIds ...string) (getDeviceList.Devices, error)
return ret, sg.Error return ret, sg.Error
} }
// QueryDeviceList - AppService.queryDeviceList
func (sg *SunGrow) QueryDeviceList(psIds ...string) ([]queryDeviceList.Device, error) {
var ret []queryDeviceList.Device
for range Only.Once {
pids := sg.SetPsIds(psIds...)
if sg.Error != nil {
break
}
for _, psId := range pids {
ep := sg.GetByStruct(queryDeviceList.EndPointName,
queryDeviceList.RequestData {
PsId: psId,
},
time.Hour*24,
)
if sg.IsError() {
break
}
data := queryDeviceList.Assert(ep)
ret = append(ret, data.Response.ResultData.PageList...)
}
}
return ret, sg.Error
}
func (sg *SunGrow) Devices(psIds ...string) (string, error) { func (sg *SunGrow) Devices(psIds ...string) (string, error) {
var ret string var ret string
@ -54,7 +86,7 @@ func (sg *SunGrow) Devices(psIds ...string) (string, error) {
ret += fmt.Sprintf("# Devices on ps_id %s:\n", strings.Join(psIds, ", ")) ret += fmt.Sprintf("# Devices on ps_id %s:\n", strings.Join(psIds, ", "))
table := datatable.New("utf8-heavy") table := datatable.New("utf8-heavy")
table.AddHeaders("Ps Key", "Ps Id", "Device Type", "Device Code", "Channel Id", "Serial #", "Factory Name") table.AddHeaders("Ps Key", "Ps Id", "Device Type", "Device Code", "Channel Id", "Serial #", "Factory Name", "Device Model")
for _, device := range devices { for _, device := range devices {
table.AddRowItems(device.PsKey, device.PsId, device.DeviceType, device.DeviceCode, device.ChannelId, device.Sn, device.FactoryName, device.DeviceModel) table.AddRowItems(device.PsKey, device.PsId, device.DeviceType, device.DeviceCode, device.ChannelId, device.Sn, device.FactoryName, device.DeviceModel)
} }
@ -68,7 +100,167 @@ func (sg *SunGrow) Devices(psIds ...string) (string, error) {
return ret, sg.Error return ret, sg.Error
} }
func (sg *SunGrow) GetDevicePointNames(device valueTypes.Integer) ([]getPowerDevicePointNames.Point, error) {
// DeviceData -
func (sg *SunGrow) DeviceData(deviceType string, startDate string, endDate string, interval string) error {
for range Only.Once {
if deviceType == "" {
sg.Error = errors.New("no template defined")
break
}
fmt.Println("NOT YET IMPLEMENTED.")
// data := sg.QueryUserCurveDeviceData(deviceType)
// if sg.IsError() {
// break
// }
//
// var points []string
// for an := range data.PointsData.Devices {
// // fmt.Println(an)
// for _, b := range data.PointsData.Devices[an].Points {
// points = append(points, b.PointId.Full())
// // fmt.Println(bn)
// // fmt.Printf("%v\n", b)
// }
// }
//
// sg.PointData(startDate, endDate, interval, points...)
// if sg.Error != nil {
// break
// }
}
return sg.Error
}
// DevicePoints - Return all points associated a device_type.
func (sg *SunGrow) DevicePoints(deviceTypes ...string) string {
var ret string
for range Only.Once {
if len(deviceTypes) == 0 {
break
}
table := datatable.New("utf8-heavy")
table.AddHeaders("Device Type", "Point Id", "Name", "Cal Type")
var points []getPowerDevicePointNames.Point
for _, deviceType := range deviceTypes {
ep := sg.GetByStruct(getPowerDevicePointNames.EndPointName,
getPowerDevicePointNames.RequestData{ DeviceType: valueTypes.SetIntegerString(deviceType) },
DefaultCacheTimeout,
)
if sg.IsError() {
break
}
data := getPowerDevicePointNames.Assert(ep)
points = append(points, data.Response.ResultData...)
// Sort table based on PointId
pn := map[string]int{}
for index, point := range points {
pn[point.PointId.String()] = index
}
var names []string
for point := range pn {
names = append(names, point)
}
sort.Strings(names)
for _, name := range names {
index := pn[name]
point := points[index]
table.AddRowItems(deviceType, point.PointId, point.PointName, point.PointCalType)
}
}
if sg.IsError() {
break
}
var r string
r, sg.Error = table.Render()
if sg.Error != nil {
break
}
ret += fmt.Sprintln("# Available points:")
ret += r
}
return ret
}
// DeviceTypeList - Return all device_types.
func (sg *SunGrow) DeviceTypeList(psIds ...string) string {
var ret string
for range Only.Once {
pids := sg.SetPsIds(psIds...)
if sg.Error != nil {
break
}
if len(pids) == 0 {
break
}
// data := sg.NewSunGrowData()
// data.SetEndpoints(queryDeviceList.EndPointName)
// data.SetArgs(
// "PsId:" + pids.Strings()[0],
// )
// sg.Error = data.GetData()
// if sg.Error != nil {
// break
// }
//
// sg.Error = data.OutputDataTables()
// if sg.Error != nil {
// break
// }
table := datatable.New("utf8-heavy")
table.AddHeaders("Device Type", "Name")
ep := sg.GetByStruct(queryDeviceList.EndPointName,
queryDeviceList.RequestData{ PsId: pids[0] },
DefaultCacheTimeout,
)
if sg.IsError() {
break
}
data := queryDeviceList.Assert(ep)
// Sort table based on PointId
var names []string
for name := range data.Response.ResultData.DevTypeDefinition {
names = append(names, name)
}
sort.Strings(names)
for _, name := range names {
table.AddRowItems(name, data.Response.ResultData.DevTypeDefinition[name])
}
var r string
r, sg.Error = table.Render()
if sg.Error != nil {
break
}
ret += fmt.Sprintln("# Available points:")
ret += r
}
return ret
}
func (sg *SunGrow) GetPowerDevicePointNames(device valueTypes.Integer) ([]getPowerDevicePointNames.Point, error) {
var ret []getPowerDevicePointNames.Point var ret []getPowerDevicePointNames.Point
for range Only.Once { for range Only.Once {
ep := sg.GetByStruct(getPowerDevicePointNames.EndPointName, ep := sg.GetByStruct(getPowerDevicePointNames.EndPointName,
@ -86,7 +278,8 @@ func (sg *SunGrow) GetDevicePointNames(device valueTypes.Integer) ([]getPowerDev
return ret, sg.Error return ret, sg.Error
} }
func (sg *SunGrow) GetDeviceModelInfoList() error {
func (sg *SunGrow) DeviceModelInfoList() error {
for range Only.Once { for range Only.Once {
ep := sg.GetByStruct(getDeviceModelInfoList.EndPointName, ep := sg.GetByStruct(getDeviceModelInfoList.EndPointName,
getDeviceModelInfoList.RequestData{}, getDeviceModelInfoList.RequestData{},

View File

@ -0,0 +1,2 @@
package iSolarCloud

View File

@ -19,46 +19,12 @@ import (
datatable "go.pennock.tech/tabular/auto" datatable "go.pennock.tech/tabular/auto"
"math" "math"
"os" "os"
"sort"
"strings" "strings"
"time" "time"
) )
// GetDevicePointAttrs - WebAppService.getDevicePointAttrs Uuid: PsId: DeviceType
func (sg *SunGrow) GetDevicePointAttrs(psId valueTypes.PsId) ([]getDevicePointAttrs.Points, error) {
var ret []getDevicePointAttrs.Points
for range Only.Once {
var tree PsTree
tree, sg.Error = sg.PsTreeMenu(psId.String())
if sg.Error != nil {
break
}
for _, pid := range tree.Devices {
ep := sg.GetByStruct(getDevicePointAttrs.EndPointName,
getDevicePointAttrs.RequestData {
Uuid: pid.UUID,
PsId2: pid.PsId,
DeviceType2: pid.DeviceType,
},
time.Hour * 24,
)
if sg.IsError() {
break
}
data := getDevicePointAttrs.Assert(ep)
ret = append(ret, data.Points()...)
// more := sg.GetDevicePointNames(pid.DeviceType)
}
}
return ret, sg.Error
}
// GetPowerDevicePointInfo - AppService.getPowerDevicePointInfo // GetPowerDevicePointInfo - AppService.getPowerDevicePointInfo
func (sg *SunGrow) GetPowerDevicePointInfo(min valueTypes.Integer, max valueTypes.Integer) ([]getPowerDevicePointInfo.ResultData, error) { func (sg *SunGrow) GetPowerDevicePointInfo(min valueTypes.Integer, max valueTypes.Integer) ([]getPowerDevicePointInfo.ResultData, error) {
var ret []getPowerDevicePointInfo.ResultData var ret []getPowerDevicePointInfo.ResultData
@ -86,124 +52,6 @@ func (sg *SunGrow) GetPowerDevicePointInfo(min valueTypes.Integer, max valueType
return ret, sg.Error return ret, sg.Error
} }
// // QueryMultiPointDataList - AppService.queryMutiPointDataList MinuteInterval:5 StartTimeStamp:20221001000000 EndTimeStamp:20221001235900 PsId:1129147 Points:1129147_14_1_1.p13148,1129147_14_1_1.p13147,1129147_14_1_1.p13146,1129147_14_1_1.p13145,1129147_14_1_1.p13144,1129147_14_1_1.p13143
// func (sg *SunGrow) QueryMultiPointDataList(startDate valueTypes.DateTime, endDate valueTypes.DateTime, interval valueTypes.Integer, points valueTypes.PointIds) (queryMutiPointDataList.Data, error) {
// var ret queryMutiPointDataList.Data
// for range Only.Once {
// if len(points.PointIds) == 0 {
// break
// }
//
// var psId valueTypes.PsId
// psids := points.PsIds()
// if len(psids) != 1 {
// // Should only have one ps_id.
// break
// }
// psId := psids[0]
//
// if !psId.Valid {
// interval.SetValue(5)
// }
//
// if startDate.IsZero() {
// startDate.SetValue(time.Now())
// startDate.SetDayStart()
// }
//
// if endDate.IsZero() {
// endDate.SetValue(startDate.Value())
// endDate.SetDayEnd()
// }
//
// if !interval.Valid {
// interval.SetValue(5)
// }
//
// ep := sg.GetByStruct(
// "WebAppService.queryMutiPointDataList",
// queryMutiPointDataList.RequestData {
// PsId: psId,
// StartTimeStamp: startDate,
// EndTimeStamp: endDate,
// MinuteInterval: interval,
// PsKeys: (points.PsKeys().String()),
// Points: points,
// },
// time.Hour * 24,
// )
// if sg.IsError() {
// break
// }
//
// data := queryMutiPointDataList.Assert(ep)
// ret = data.Response.ResultData.Data
//
// // tables := data.GetEndPointDataTables()
// // for _, table := range tables {
// // table.OutputType = sg.OutputType
// // table.Output()
// // }
// //
// // // ret = data.Response.ResultData
// // //
// // // table := output.NewTable(
// // // "Date/Time",
// // // "Point Id",
// // // "Point Name",
// // // "Value",
// // // "Units",
// // // )
// // // table.SetTitle("")
// // //
// // // t := data.Request.RequestData.StartTimeStamp
// // // data.SetFilenamePrefix(t.String())
// // // table.SetFilePrefix(t.String())
// // //
// // // for deviceName, deviceRef := range data.Response.ResultData.Data {
// // // for pointId, pointRef := range deviceRef.Points {
// // // for _, tim := range pointRef.Times {
// // // gp := points.GetPoint(deviceName, pointId)
// // // sg.Error = table.AddRow(tim.Key.PrintFull(),
// // // fmt.Sprintf("%s.%s", deviceName, pointId),
// // // gp.Name,
// // // tim.Value,
// // // gp.Unit,
// // // )
// // // if sg.Error != nil {
// // // continue
// // // }
// // // }
// // // }
// // // }
// // //
// // // table.InitGraph(output.GraphRequest {
// // // Title: "",
// // // TimeColumn: output.SetString("Date/Time"),
// // // SearchColumn: output.SetString("Point Id"),
// // // NameColumn: output.SetString("Point Name"),
// // // ValueColumn: output.SetString("Value"),
// // // UnitsColumn: output.SetString("Units"),
// // // SearchString: output.SetString(""),
// // // MinLeftAxis: output.SetFloat(0),
// // // MaxLeftAxis: output.SetFloat(0),
// // // })
// // //
// // // table.SetTitle("Point Data %s", psId)
// // // table.SetFilePrefix(data.SetFilenamePrefix("%d", psId))
// // // table.SetGraphFilter("")
// // // table.SetSaveFile(sg.SaveAsFile)
// // // table.OutputType = sg.OutputType
// // // sg.Error = table.Output()
// // if sg.IsError() {
// // break
// // }
//
// }
//
// return ret, sg.Error
// }
func (sg *SunGrow) GetAllPointsData(psIds ...string) error { func (sg *SunGrow) GetAllPointsData(psIds ...string) error {
for range Only.Once { for range Only.Once {
var points api.DataMap var points api.DataMap
@ -410,10 +258,125 @@ func (sg *SunGrow) GetAllPointsData(psIds ...string) error {
return sg.Error return sg.Error
} }
// PointNames - Return all points associated with psIds.
func (sg *SunGrow) PointNames(psIds ...string) string { // PointNamesData - Return all points associated with psIds and device_type filter.
func (sg *SunGrow) PointNamesData(psIds []string, deviceType string, startDate string, endDate string, interval string) string {
var ret string var ret string
for range Only.Once {
pskeys := sg.GetPsKeys()
_, _ = fmt.Fprintf(os.Stderr, "Found ps_keys: %s\n", pskeys)
points := sg.PsPointNames(psIds, deviceType)
var ps []string
for _, pid := range points {
match := pskeys.MatchPsIdDeviceType(pid.PsId.String(), pid.DeviceType.String())
if match.Valid {
ps = append(ps, fmt.Sprintf("%s.%s", match, pid.Id))
}
}
// _, _ = fmt.Fprintf(os.Stderr, "Found points: %s\n", strings.Join(ps, " "))
sg.PointData(startDate, endDate, interval, ps...)
}
return ret
}
// PointNames - Return all points associated with psIds and device_type filter.
func (sg *SunGrow) PointNames(psIds []string, deviceType string) string {
var ret string
for range Only.Once {
points := sg.PsPointNames(psIds, deviceType)
// Sort table based on PsId + DeviceType + Id
pn := map[string]int{}
for index, point := range points {
pn[point.PsId.String()+"."+point.DeviceType.String()+"."+point.Id.String()] = index
}
var names []string
for point := range pn {
names = append(names, point)
}
sort.Strings(names)
table := datatable.New("utf8-heavy")
table.AddHeaders("Id", "Name", "Unit", "Unit Type", "Ps Id", "Device Type", "Device Name")
for _, name := range names {
index := pn[name]
point := points[index]
table.AddRowItems(point.Id, point.Name, point.Unit, point.UnitType, point.PsId, point.DeviceType, point.DeviceName)
}
// PsKey
// PsId
// DeviceType
// DeviceCode
// ChannelId
var r string
r, sg.Error = table.Render()
if sg.Error != nil {
break
}
ret += fmt.Sprintln("# Available points:")
ret += r
// var pids valueTypes.PsIds
// pids = sg.SetPsIds(psIds...)
// if sg.Error != nil {
// break
// }
//
// for _, pid := range pids {
// var points []getDevicePointAttrs.Points
// points, sg.Error = sg.GetDevicePointAttrs(pid)
// if sg.Error != nil {
// break
// }
//
// if len(points) == 0 {
// continue
// }
//
// ret += fmt.Sprintf("# Available points for ps_id %s:\n", pid.String())
// table := datatable.New("utf8-heavy")
// table.AddHeaders("Id", "Name", "Unit", "UnitType", "PsId", "DeviceType", "DeviceName")
// for _, point := range points {
// if (deviceType != "") && point.DeviceType.MatchString(deviceType) {
// continue
// }
// table.AddRowItems(point.Id, point.Name, point.Unit, point.UnitType, point.PsId, point.DeviceType, point.DeviceName)
// }
//
// var r string
// r, sg.Error = table.Render()
// if sg.Error != nil {
// break
// }
// ret += r
//
// // @TODO - Include AppService.getPowerDevicePointNames
// // points2 := cmds.Api.SunGrow.GetDevicePointNames(pid)
// // if c.Error != nil {
// // break
// // }
// // if len(points) == 0 {
// // continue
// // }
//
// }
}
return ret
}
// PsPointNames - Return all points associated with psIds and device_type filter.
func (sg *SunGrow) PsPointNames(psIds []string, deviceType string) []getDevicePointAttrs.Point {
var points []getDevicePointAttrs.Point
for range Only.Once { for range Only.Once {
var pids valueTypes.PsIds var pids valueTypes.PsIds
pids = sg.SetPsIds(psIds...) pids = sg.SetPsIds(psIds...)
@ -422,30 +385,23 @@ func (sg *SunGrow) PointNames(psIds ...string) string {
} }
for _, pid := range pids { for _, pid := range pids {
var points []getDevicePointAttrs.Points var p []getDevicePointAttrs.Point
points, sg.Error = sg.GetDevicePointAttrs(pid) p, sg.Error = sg.GetDevicePointAttrs(pid)
if sg.Error != nil { if sg.Error != nil {
break break
} }
if len(points) == 0 { for _, point := range p {
continue if deviceType == "" {
points = append(points, point)
continue
}
if point.DeviceType.MatchString(deviceType) {
points = append(points, point)
continue
}
} }
ret += fmt.Sprintf("# Available points for ps_id %s:\n", pid.String())
table := datatable.New("utf8-heavy")
table.AddHeaders("Id", "Name", "Unit", "UnitType", "PsId", "DeviceType", "DeviceName")
for _, point := range points {
table.AddRowItems(point.Id, point.Name, point.Unit, point.UnitType, point.PsId, point.DeviceType, point.DeviceName)
}
var r string
r, sg.Error = table.Render()
if sg.Error != nil {
break
}
ret += r
// @TODO - Include AppService.getPowerDevicePointNames // @TODO - Include AppService.getPowerDevicePointNames
// points2 := cmds.Api.SunGrow.GetDevicePointNames(pid) // points2 := cmds.Api.SunGrow.GetDevicePointNames(pid)
// if c.Error != nil { // if c.Error != nil {
@ -454,149 +410,95 @@ func (sg *SunGrow) PointNames(psIds ...string) string {
// if len(points) == 0 { // if len(points) == 0 {
// continue // continue
// } // }
}
if sg.Error != nil {
break
} }
} }
return ret return points
} }
// GetDevicePointAttrs - WebAppService.getDevicePointAttrs Uuid: PsId: DeviceType
func (sg *SunGrow) GetDevicePointAttrs(psId valueTypes.PsId) ([]getDevicePointAttrs.Point, error) {
var ret []getDevicePointAttrs.Point
for range Only.Once {
var tree PsTree
tree, sg.Error = sg.PsTreeMenu(psId.String())
if sg.Error != nil {
break
}
for _, pid := range tree.Devices {
ep := sg.GetByStruct(getDevicePointAttrs.EndPointName,
getDevicePointAttrs.RequestData {
Uuid: pid.UUID,
PsId2: pid.PsId,
DeviceType2: pid.DeviceType,
},
time.Hour * 24,
)
if sg.IsError() {
break
}
data := getDevicePointAttrs.Assert(ep)
ret = append(ret, data.Points()...)
// more := sg.GetDevicePointNames(pid.DeviceType)
}
}
return ret, sg.Error
}
func (sg *SunGrow) PointData(startDate string, endDate string, interval string, points ...string) string { func (sg *SunGrow) PointData(startDate string, endDate string, interval string, points ...string) string {
var ret string var ret string
for range Only.Once { for range Only.Once {
// _, _ = sg.QueryMultiPointDataList(
// valueTypes.SetDateTimeString(startDate),
// valueTypes.SetDateTimeString(endDate),
// valueTypes.SetIntegerString(interval),
// valueTypes.SetPointIdsString(points...),
// )
data := sg.NewSunGrowData() data := sg.NewSunGrowData()
data.SetEndpoints(queryMutiPointDataList.EndPointName) // req := iSolarCloud.RequestArgs {
// req := iSolarCloud.RequestArgs{
// StartTimeStamp: startDate, // StartTimeStamp: startDate,
// EndTimeStamp: endDate, // EndTimeStamp: endDate,
// } // }
// var req iSolarCloud.RequestArgs // var req iSolarCloud.RequestArgs
// data.Request.SetPoints(points) // data.Request.SetPoints(points)
startDate = valueTypes.NewDateTime(startDate).Format(valueTypes.DateTimeLayoutSecond) sd := valueTypes.NewDateTime(startDate)
endDate = valueTypes.NewDateTime(endDate).Format(valueTypes.DateTimeLayoutSecond) var ed valueTypes.DateTime
if endDate == "" {
ed = sd
ed.SetDayEnd()
} else {
ed = valueTypes.NewDateTime(endDate)
}
// _, _ = fmt.Fprintf(os.Stderr,"Points: %s\n", strings.Join(points, " "))
data.SetArgs( data.SetArgs(
"StartTimeStamp:" + startDate, "StartTimeStamp:" + sd.Format(valueTypes.DateTimeLayoutSecond),
"EndTimeStamp:" + endDate, "EndTimeStamp:" + ed.Format(valueTypes.DateTimeLayoutSecond),
"MinuteInterval:" + interval, "MinuteInterval:" + interval,
"Points:" + strings.Join(points, ","), "Points:" + strings.Join(points, ","),
) )
data.SetEndpoints(queryMutiPointDataList.EndPointName)
sg.Error = data.GetData() sg.Error = data.GetData()
if sg.Error != nil { if sg.Error != nil {
break break
} }
sg.Error = data.Process()
if sg.Error != nil {
break
}
sg.Error = data.OutputDataTables() sg.Error = data.OutputDataTables()
if sg.Error != nil { if sg.Error != nil {
break break
} }
// var argStartDate valueTypes.DateTime
// switch {
// case startDate == valueTypes.Now:
// fallthrough
// case startDate == "":
// fallthrough
// case startDate == ".":
// argStartDate = valueTypes.NewDateTime(valueTypes.Now)
// argStartDate.SetDayStart()
// default:
// argStartDate = valueTypes.NewDateTime(startDate)
// }
// if argStartDate.Error != nil {
// c.Error = argStartDate.Error
// break
// }
//
// var argEndDate valueTypes.DateTime
// switch {
// case endDate == valueTypes.Now:
// fallthrough
// case endDate == "":
// fallthrough
// case endDate == ".":
// argEndDate = valueTypes.NewDateTime(valueTypes.Now)
// argEndDate.SetDayEnd()
// default:
// argEndDate = valueTypes.NewDateTime(endDate)
// }
// if argEndDate.Error != nil {
// c.Error = argEndDate.Error
// break
// }
//
// var argInterval valueTypes.Integer
// switch {
// case endDate == "":
// fallthrough
// case endDate == ".":
// argInterval = valueTypes.SetIntegerString("5")
// default:
// argInterval = valueTypes.SetIntegerString(interval)
// }
// if argInterval.Error != nil {
// c.Error = argInterval.Error
// break
// }
//
// argPsId := valueTypes.SetPsIdString(psId)
// if argPsId.Error != nil {
// c.Error = argPsId.Error
// break
// }
//
// var argPsKey valueTypes.PsKey
// argPsKey = valueTypes.SetPsKeyString(psKey)
// if argPsKey.Error != nil {
// c.Error = argPsKey.Error
// break
// }
//
// var argPoints valueTypes.PointIds
// argPoints.Set(points...)
// if argPoints.Error != nil {
// c.Error = argPoints.Error
// break
// }
// var data queryMutiPointDataList.Data
// data, c.Error = cmds.Api.SunGrow.QueryMultiPointDataList(argStartDate, argEndDate, argInterval, argPsId, argPsKey, argPoints)
// if c.Error != nil {
// break
// }
//
// table := output.NewTable(
// "Timestamp",
// "Ps Key",
// "Key",
// "Value",
// )
//
// for _, d := range data {
// for k, v := range d.Points {
// c.Error = table.AddRow(
// d.Timestamp.String(),
// d.PsKey.String(),
// k,
// v.String(),
// )
// if c.Error != nil {
// break
// }
// }
// }
// if c.Error != nil {
// break
// }
//
// ret = table.String()
} }
return ret return ret
@ -682,3 +584,91 @@ func PrintPause(index int64, max int) {
} }
} }
} }
// QueryMultiPointDataList - AppService.queryMutiPointDataList MinuteInterval:5 StartTimeStamp:20221001000000 EndTimeStamp:20221001235900 PsId:1129147 Points:1129147_14_1_1.p13148,1129147_14_1_1.p13147,1129147_14_1_1.p13146,1129147_14_1_1.p13145,1129147_14_1_1.p13144,1129147_14_1_1.p13143
func (sg *SunGrow) QueryMultiPointDataList(startDate valueTypes.DateTime, endDate valueTypes.DateTime, interval valueTypes.Integer, points valueTypes.PointIds) (queryMutiPointDataList.Data, error) {
var ret queryMutiPointDataList.Data
for range Only.Once {
if len(points.PointIds) == 0 {
break
}
psids := points.PsIds()
if len(psids) == 0 {
break
}
psId := psids[0]
if !interval.Valid {
interval.SetValue(5)
}
if startDate.IsZero() {
startDate.SetValue(time.Now())
startDate.SetDayStart()
}
startDate.SetDateType(valueTypes.DateTimeLayoutSecond)
if endDate.IsZero() {
endDate.SetValue(startDate.Value())
endDate.SetDayEnd()
}
endDate.SetDateType(valueTypes.DateTimeLayoutSecond)
if !interval.Valid {
interval.SetValue(5)
}
ep := sg.GetByStruct(
"AppService.queryMutiPointDataList",
queryMutiPointDataList.RequestData {
PsId: psId,
StartTimeStamp: startDate,
EndTimeStamp: endDate,
MinuteInterval: interval,
PsKeys: *points.PsKeys(),
Points: points,
},
time.Hour * 24,
)
if sg.IsError() {
break
}
var response SunGrowDataResponse
response.Data = ep.GetEndPointData()
response.Data.ProcessMap()
if response.Data.Error != nil {
sg.Error = response.Data.Error
break
}
response.Options = OutputOptions {
OutputType: sg.OutputType,
SaveAsFile: sg.SaveAsFile,
GraphRequest: output.GraphRequest{},
}
// // Outputs that can drop through to DataTables.
// if sg.OutputType.IsTable() || sg.OutputType.IsXLSX() || sg.OutputType.IsCsv() || sg.OutputType.IsXML() {
// table := response.Data.CreateResultTable(false)
// table.OutputType = sg.OutputType
// table.SetSaveFile(sg.SaveAsFile)
// // table.AppendTitle(" - %s", sg.TitleSuffix)
// // table.AppendFilePrefix(sg.FileSuffix)
// sg.Error = table.Output()
// if sg.Error != nil {
// break
// }
// }
sg.Error = response.OutputDataTables()
if sg.IsError() {
break
}
}
return ret, sg.Error
}

View File

@ -24,7 +24,6 @@ import (
"GoSungrow/iSolarCloud/AppService/psForcastInfo" "GoSungrow/iSolarCloud/AppService/psForcastInfo"
"GoSungrow/iSolarCloud/AppService/psHourPointsValue" "GoSungrow/iSolarCloud/AppService/psHourPointsValue"
"GoSungrow/iSolarCloud/AppService/queryAllPsIdAndName" "GoSungrow/iSolarCloud/AppService/queryAllPsIdAndName"
"GoSungrow/iSolarCloud/AppService/queryDeviceList"
"GoSungrow/iSolarCloud/AppService/queryDeviceListForApp" "GoSungrow/iSolarCloud/AppService/queryDeviceListForApp"
"GoSungrow/iSolarCloud/AppService/queryPowerStationInfo" "GoSungrow/iSolarCloud/AppService/queryPowerStationInfo"
"GoSungrow/iSolarCloud/AppService/queryPsIdList" "GoSungrow/iSolarCloud/AppService/queryPsIdList"
@ -32,6 +31,7 @@ import (
"GoSungrow/iSolarCloud/AppService/queryPsStructureList" "GoSungrow/iSolarCloud/AppService/queryPsStructureList"
"GoSungrow/iSolarCloud/AppService/querySysAdvancedParam" "GoSungrow/iSolarCloud/AppService/querySysAdvancedParam"
"GoSungrow/iSolarCloud/AppService/reportList" "GoSungrow/iSolarCloud/AppService/reportList"
"GoSungrow/iSolarCloud/Common"
"GoSungrow/iSolarCloud/MttvScreenService/getPsDeviceListValue" "GoSungrow/iSolarCloud/MttvScreenService/getPsDeviceListValue"
"GoSungrow/iSolarCloud/MttvScreenService/getPsKpiForHoursByPsId" "GoSungrow/iSolarCloud/MttvScreenService/getPsKpiForHoursByPsId"
"GoSungrow/iSolarCloud/WebAppService/getPsIdState" "GoSungrow/iSolarCloud/WebAppService/getPsIdState"
@ -39,6 +39,7 @@ import (
"GoSungrow/iSolarCloud/WebAppService/showPSView" "GoSungrow/iSolarCloud/WebAppService/showPSView"
"GoSungrow/iSolarCloud/WebIscmAppService/getMaxDeviceIdByPsId" "GoSungrow/iSolarCloud/WebIscmAppService/getMaxDeviceIdByPsId"
"GoSungrow/iSolarCloud/WebIscmAppService/getPsTreeMenu" "GoSungrow/iSolarCloud/WebIscmAppService/getPsTreeMenu"
"GoSungrow/iSolarCloud/WebIscmAppService/queryDeviceListForBackSys"
"GoSungrow/iSolarCloud/api/GoStruct/valueTypes" "GoSungrow/iSolarCloud/api/GoStruct/valueTypes"
"fmt" "fmt"
"github.com/MickMake/GoUnify/Only" "github.com/MickMake/GoUnify/Only"
@ -47,6 +48,131 @@ import (
) )
func (sg *SunGrow) GetPsKeys() valueTypes.PsKeys {
var ret valueTypes.PsKeys
for range Only.Once {
// PsKey valueTypes.PsKey `json:"ps_key" PointId:"ps_key" PointUpdateFreq:"UpdateFreqBoot"`
// PsId valueTypes.PsId `json:"ps_id" PointId:"ps_id" PointUpdateFreq:"UpdateFreqBoot"`
// DeviceType valueTypes.Integer `json:"device_type" PointId:"device_type" PointUpdateFreq:"UpdateFreqBoot"`
// DeviceCode valueTypes.Integer `json:"device_code" PointId:"device_code" PointUpdateFreq:"UpdateFreqBoot"`
// ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id" PointUpdateFreq:"UpdateFreqBoot"`
var pskeys []string
// Different methods to obtain all pskeys.
// queryDeviceInfo - DEAD
// AppService.queryDeviceInfoForApp DeviceSn:B2281302388 - Needs UUID.
// // WebIscmAppService.queryDeviceListForBackSys - Missing values.
// pids := sg.GetDevices()
// if sg.Error != nil {
// break
// }
// fmt.Printf("%v\n", pids)
// for _, pid := range pids {
// fmt.Printf("%s_%s_%s_%s\n", "UUID", pid.DeviceType, pid.DeviceCode, pid.ChannelId)
// }
// AppService.getDeviceList - Around 7kB
pids2, _ := sg.GetDeviceList()
if sg.Error != nil {
break
}
// fmt.Printf("%v\n", pids2)
for _, pid := range pids2 {
pskey := fmt.Sprintf("%s_%s_%s_%s", pid.PsId, pid.DeviceType, pid.DeviceCode, pid.ChannelId)
pskeys = append(pskeys, pskey)
}
if len(pskeys) > 0 {
ret.Set(pskeys...)
break
}
// // AppService.getPsList - Around 8.5kB - Doesn't return any pid.DeviceType, pid.DeviceCode, pid.ChannelId
// pids4, _ := sg.GetPsList()
// if sg.Error != nil {
// break
// }
// // fmt.Printf("%v\n", pids4)
// for _, pid := range pids4 {
// pskey := fmt.Sprintf("%s_%s_%s_%s\n", pid.PsId, pid.DeviceType, pid.DeviceCode, pid.ChannelId)
// pskeys = append(pskeys, pskey)
// fmt.Printf("(%s) %s\n", pid.PsKey, pskey)
// }
// if len(pskeys) > 0 {
// ret.Set(pskeys...)
// break
// }
// AppService.queryDeviceList - Around 118kB
pids3, _ := sg.QueryDeviceList()
if sg.Error != nil {
break
}
// fmt.Printf("%v\n", pids3)
for _, pid := range pids3 {
pskey := fmt.Sprintf("%s_%s_%s_%s", pid.PsId, pid.DeviceType, pid.DeviceCode, pid.ChannelId)
pskeys = append(pskeys, pskey)
}
if len(pskeys) > 0 {
ret.Set(pskeys...)
break
}
}
return ret
}
// func (sg *SunGrow) GetPsKeys() ([]string, error) {
// var ret []string
//
// for range Only.Once {
// var psIds valueTypes.PsIds
// psIds, sg.Error = sg.GetPsIds()
// if sg.Error != nil {
// break
// }
//
// for _, psId := range psIds {
// ep := sg.GetByStruct(getPsDetailWithPsType.EndPointName,
// // getPsDetailWithPsType.RequestData{PsId: strconv.FormatInt(psId, 10)},
// getPsDetailWithPsType.RequestData{PsId: psId},
// DefaultCacheTimeout)
// if sg.IsError() {
// break
// }
//
// data := getPsDetailWithPsType.Assert(ep)
// ret = append(ret, data.GetPsKeys()...)
// }
// }
//
// return ret, sg.Error
// }
func (sg *SunGrow) GetDevices() []queryDeviceListForBackSys.Device {
var ret []queryDeviceListForBackSys.Device
for range Only.Once {
var pids valueTypes.PsIds
pids, sg.Error = sg.GetPsIds()
if sg.Error != nil {
break
}
for _, pid := range pids {
var devices []queryDeviceListForBackSys.Device
devices, sg.Error = sg.QueryDeviceListForBackSys(pid.String())
if sg.Error != nil {
break
}
ret = append(ret, devices...)
}
}
return ret
}
func (sg *SunGrow) SetPsIds(args ...string) valueTypes.PsIds { func (sg *SunGrow) SetPsIds(args ...string) valueTypes.PsIds {
var pids valueTypes.PsIds var pids valueTypes.PsIds
for range Only.Once { for range Only.Once {
@ -55,7 +181,7 @@ func (sg *SunGrow) SetPsIds(args ...string) valueTypes.PsIds {
break break
} }
pids, sg.Error = sg.PsIds() pids, sg.Error = sg.GetPsIds()
if sg.Error != nil { if sg.Error != nil {
break break
} }
@ -63,6 +189,23 @@ func (sg *SunGrow) SetPsIds(args ...string) valueTypes.PsIds {
return pids return pids
} }
func (sg *SunGrow) GetPsIds() (valueTypes.PsIds, error) {
var ret valueTypes.PsIds
for range Only.Once {
ep := sg.GetByStruct(getPsList.EndPointName, nil, DefaultCacheTimeout)
if sg.IsError() {
break
}
data := getPsList.AssertResultData(ep)
ret = data.GetPsIds()
}
return ret, sg.Error
}
// func (sg *SunGrow) GetPsId() (valueTypes.PsId, error) { // func (sg *SunGrow) GetPsId() (valueTypes.PsId, error) {
// var ret valueTypes.PsId // var ret valueTypes.PsId
// //
@ -85,8 +228,35 @@ func (sg *SunGrow) SetPsIds(args ...string) valueTypes.PsIds {
// return ret, sg.Error // return ret, sg.Error
// } // }
func (sg *SunGrow) PsIds() (valueTypes.PsIds, error) {
var ret valueTypes.PsIds // QueryDeviceListForBackSys - WebIscmAppService.queryDeviceListForBackSys
func (sg *SunGrow) QueryDeviceListForBackSys(psId string) ([]queryDeviceListForBackSys.Device, error) {
var ret []queryDeviceListForBackSys.Device
for range Only.Once {
pid := valueTypes.SetPsIdString(psId)
if !pid.Valid {
sg.Error = pid.Error
break
}
ep := sg.GetByStruct(queryDeviceListForBackSys.EndPointName,
queryDeviceListForBackSys.RequestData{ PsId: pid },
DefaultCacheTimeout)
if sg.IsError() {
break
}
ret = queryDeviceListForBackSys.AssertResultData(ep)
}
return ret, sg.Error
}
// GetPsList - AppService.getPsList
func (sg *SunGrow) GetPsList() ([]Common.Device, error) {
var ret []Common.Device
for range Only.Once { for range Only.Once {
ep := sg.GetByStruct(getPsList.EndPointName, nil, DefaultCacheTimeout) ep := sg.GetByStruct(getPsList.EndPointName, nil, DefaultCacheTimeout)
@ -94,8 +264,8 @@ func (sg *SunGrow) PsIds() (valueTypes.PsIds, error) {
break break
} }
_getPsList := getPsList.AssertResultData(ep) data := getPsList.AssertResultData(ep)
ret = _getPsList.GetPsIds() ret = data.PageList
} }
return ret, sg.Error return ret, sg.Error
@ -749,27 +919,6 @@ func (sg *SunGrow) GetPsHourPointsValue(psId valueTypes.PsId) (psHourPointsValue
return ret, sg.Error return ret, sg.Error
} }
// QueryDeviceList - AppService.queryDeviceList
func (sg *SunGrow) QueryDeviceList(psId valueTypes.PsId) (queryDeviceList.ResultData, error) {
var ret queryDeviceList.ResultData
for range Only.Once {
ep := sg.GetByStruct(queryDeviceList.EndPointName,
queryDeviceList.RequestData {
PsId: psId,
},
time.Hour * 24,
)
if sg.IsError() {
break
}
data := queryDeviceList.Assert(ep)
ret = data.Response.ResultData
}
return ret, sg.Error
}
// QueryDeviceListForApp - AppService.queryDeviceListForApp // QueryDeviceListForApp - AppService.queryDeviceListForApp
func (sg *SunGrow) QueryDeviceListForApp(psId valueTypes.PsId) (queryDeviceListForApp.ResultData, error) { func (sg *SunGrow) QueryDeviceListForApp(psId valueTypes.PsId) (queryDeviceListForApp.ResultData, error) {
var ret queryDeviceListForApp.ResultData var ret queryDeviceListForApp.ResultData

View File

@ -152,6 +152,7 @@ func (sg *SunGrow) TemplateData(template string, startDate string, endDate strin
// @TODO - Figure out a way to push the Unit values from QueryUserCurveTemplateData to this table. // @TODO - Figure out a way to push the Unit values from QueryUserCurveTemplateData to this table.
// @TODO - Maybe use a point cache?! // @TODO - Maybe use a point cache?!
// sg.OutputType.SetTable()
sg.PointData(startDate, endDate, interval, points...) sg.PointData(startDate, endDate, interval, points...)
if sg.Error != nil { if sg.Error != nil {
break break
@ -161,7 +162,6 @@ func (sg *SunGrow) TemplateData(template string, startDate string, endDate strin
return sg.Error return sg.Error
} }
func (sg *SunGrow) TemplatePoints(template string) error { func (sg *SunGrow) TemplatePoints(template string) error {
for range Only.Once { for range Only.Once {
if template == "" { if template == "" {
@ -188,11 +188,6 @@ func (sg *SunGrow) TemplatePoints(template string) error {
break break
} }
sg.Error = data.Process()
if sg.Error != nil {
break
}
sg.Error = data.OutputDataTables() sg.Error = data.OutputDataTables()
if sg.Error != nil { if sg.Error != nil {
break break
@ -248,11 +243,6 @@ func (sg *SunGrow) TemplateList() error {
break break
} }
sg.Error = data.Process()
if sg.Error != nil {
break
}
sg.Error = data.OutputDataTables() sg.Error = data.OutputDataTables()
if sg.Error != nil { if sg.Error != nil {
break break