Documentation ¶
Index ¶
- Constants
- Variables
- func AppendUrl(host string, endpoint string) *url.URL
- func CheckString(name string, rc string) error
- func CleanString(s string) string
- func DivideByThousand(num string) (string, error)
- func DivideByThousandIfRequired(value string, unit string) (string, string)
- func Float32ToString(num float64) string
- func Float64ToString(num float64) string
- func GetPercent(value float64, max float64) float64
- func GetUrl(u string) *url.URL
- func HelpDataType() string
- func IsActive(value float64) bool
- func JoinDevicePoint(device string, point string) string
- func MarshalJSON(endpoint EndPoint) ([]byte, error)
- func NameDevicePoint(device string, point string) string
- func NameDevicePointInt(device string, point int64) string
- func PointToName(s string) string
- func SetPoint(point string) string
- func TimeNowString() string
- type Api
- type Area
- type AreaName
- type AreaNames
- type AreaStruct
- type Areas
- func (an *Areas) EndpointExists(area AreaName, name EndPointName) error
- func (an *Areas) Exists(area string) bool
- func (an *Areas) GetArea(area AreaName) *Area
- func (an *Areas) GetEndPoint(area AreaName, name EndPointName) EndPoint
- func (an *Areas) GetRequest(area AreaName, endpoint EndPointName) output.Json
- func (an *Areas) GetResponse(area AreaName, endpoint EndPointName) output.Json
- func (an Areas) ListAreas()
- func (an Areas) ListEndpoints(area string) error
- func (an *Areas) NotExists(area string) bool
- func (an *Areas) SetRequest(area AreaName, name EndPointName, ref interface{}) error
- func (an *Areas) SortAreas() AreaNames
- type DataEntry
- func CreateDataEntryActive(date DateTime, psId string, point string, name string, value float64) DataEntry
- func CreateDataEntryString(date DateTime, psId string, point string, name string, value string) DataEntry
- func CreateDataEntryUnitValue(date DateTime, psId string, point string, name string, value UnitValue) DataEntry
- func (de *DataEntry) CreateAlias(psId string, point string, name string) DataEntry
- func (de *DataEntry) CreateFloat(psId string, point string, name string, value float64) DataEntry
- func (de *DataEntry) CreateState(psId string, point string, name string) DataEntry
- func (de *DataEntry) UpdateMeta(date *DateTime, psId string, point string, name string)
- type DataMap
- func (dm *DataMap) Add(point string, de DataEntry)
- func (dm *DataMap) AddEntry(point Point, date DateTime, value string)
- func (dm *DataMap) AddEntryFromRef(refPoint Point, point Point, date DateTime, value string)
- func (dm *DataMap) AddFloat(psId string, point string, name string, date DateTime, value float64)
- func (dm *DataMap) AddInt(psId string, point string, name string, date DateTime, value int64)
- func (dm *DataMap) AddString(psId string, point string, name string, date DateTime, value string)
- func (dm *DataMap) AddUnitValue(endpoint string, psId string, point string, name string, date DateTime, ...)
- func (dm *DataMap) CopyEntry(entry string) *DataEntry
- func (dm *DataMap) CopyPoint(refname string, psId string, point string, name string, value float64)
- func (dm *DataMap) FromRefAddAlias(refname string, psId string, point string, name string)
- func (dm *DataMap) FromRefAddAlias2(refname string, psId string, point string, name string)
- func (dm *DataMap) FromRefAddFloat(refname string, psId string, point string, name string, value float64)
- func (dm *DataMap) FromRefAddState(refname string, psId string, point string, name string)
- func (dm *DataMap) GetEntry(entry string) DataEntry
- func (dm *DataMap) GetFloatValue(entry string) float64
- func (dm *DataMap) GetPercent(value string, max string) float64
- func (dm *DataMap) GetValue(refname string) float64
- func (dm *DataMap) LowerUpper(lower string, upper string) float64
- func (dm *DataMap) StructToPoints(endpoint string, ref interface{})
- type DateTime
- type EndPoint
- type EndPointName
- type EndPointStruct
- func (ep *EndPointStruct) ApiCacheFilename(request interface{}) string
- func (ep *EndPointStruct) ApiFingerprint(request interface{}) string
- func (ep *EndPointStruct) ApiReadDataFile(ref interface{}) error
- func (ep *EndPointStruct) ApiWriteDataFile(ref interface{}) error
- func (ep *EndPointStruct) Call() output.Json
- func (ep *EndPointStruct) FileExists(fn string) bool
- func (ep *EndPointStruct) GetArea() AreaName
- func (ep *EndPointStruct) GetCsvFilename() string
- func (ep *EndPointStruct) GetFilePath() string
- func (ep *EndPointStruct) GetImageFilename() string
- func (ep *EndPointStruct) GetJsonFilename() string
- func (ep *EndPointStruct) GetName() EndPointName
- func (ep *EndPointStruct) GetRequest() output.Json
- func (ep *EndPointStruct) GetResponse() output.Json
- func (ep *EndPointStruct) GetUrl() EndPointUrl
- func (ep *EndPointStruct) IsValid() error
- func (ep EndPointStruct) ResponseAsJson(raw bool, r interface{}) output.Json
- func (ep *EndPointStruct) SetFilenamePrefix(format string, args ...interface{}) string
- func (ep *EndPointStruct) SetRequest(ref interface{}) error
- func (ep EndPointStruct) String() string
- type EndPointUrl
- type Point
- type PointsMap
- type Request
- type RequestCommon
- type Response
- type ResponseCommon
- type TemplatePoint
- type TemplatePoints
- type TypeEndPoints
- func (ps TypeEndPoints) Exists(name EndPointName) error
- func (ps *TypeEndPoints) GetDisabled() TypeEndPoints
- func (ps *TypeEndPoints) GetEnabled() TypeEndPoints
- func (ps *TypeEndPoints) GetEndPoint(name EndPointName) EndPoint
- func (ps *TypeEndPoints) SortEndPoints() []EndPointName
- func (ps TypeEndPoints) String() string
- type UnitValue
- type UnitValueMap
- type UnitValues
- type Web
- func (w *Web) AppendUrl(endpoint string) EndPointUrl
- func (w *Web) CacheRead(endpoint EndPoint) ([]byte, error)
- func (w *Web) CacheRemove(endpoint EndPoint) error
- func (w *Web) CacheWrite(endpoint EndPoint, data []byte) error
- func (w *Web) CheckCache(endpoint EndPoint) bool
- func (w *Web) Get(endpoint EndPoint) EndPoint
- func (w *Web) GetCacheDir() string
- func (w *Web) GetCacheTimeout() time.Duration
- func (w *Web) SetCacheDir(basedir string) error
- func (w *Web) SetCacheTimeout(duration time.Duration)
- func (w *Web) SetUrl(u string) error
Constants ¶
View Source
const ( DtLayout = "2006-01-02 15:04:05" DtLayoutZeroSeconds = "2006-01-02 15:04:00" DtLayoutSecond = "20060102150405" DtLayoutMinute = "200601021504" DtLayoutHour = "2006010215" DtLayoutDay = "20060102" DtLayoutMonth = "200601" DtLayoutYear = "2006" )
View Source
const ( PointTypeInstant = "instant" PointTypeBoot = "boot" PointTypeDaily = "daily" PointTypeMonthly = "monthly" PointTypeYearly = "yearly" PointTypeTotal = "total" )
View Source
const NullEndPoint = "nullEndPoint"
View Source
const (
VirtualPsId = "virtual"
)
Variables ¶
View Source
var Points = PointsMap{}/* 104 elements not displayed */
Points Discovered points from the API
Functions ¶
func CleanString ¶
func DivideByThousand ¶
func DivideByThousandIfRequired ¶
DivideByThousandIfRequired Sigh.... Another dodgy one.
func Float32ToString ¶
func Float64ToString ¶
func GetPercent ¶
func HelpDataType ¶
func HelpDataType() string
func JoinDevicePoint ¶
func MarshalJSON ¶
func NameDevicePoint ¶
func NameDevicePointInt ¶
func PointToName ¶
func TimeNowString ¶
func TimeNowString() string
Types ¶
type Area ¶
type Area interface { Init(*Web) AreaStruct GetAreaName() AreaName GetEndPoints() TypeEndPoints Call(name EndPointName) output.Json SetRequest(name EndPointName, ref interface{}) error GetRequest(name EndPointName) output.Json GetResponse(name EndPointName) output.Json GetData(name EndPointName) output.Json IsValid(name EndPointName) error GetError(name EndPointName) error }
type AreaStruct ¶
type AreaStruct struct { ApiRoot interface{} // *web.Web Name AreaName EndPoints TypeEndPoints Error error }
func (AreaStruct) CountDisabled ¶
func (as AreaStruct) CountDisabled() int
func (AreaStruct) CountEnabled ¶
func (as AreaStruct) CountEnabled() int
func (AreaStruct) Exists ¶
func (as AreaStruct) Exists(name EndPointName) error
func (*AreaStruct) GetEndPoint ¶
func (as *AreaStruct) GetEndPoint(name EndPointName) EndPoint
func (AreaStruct) ListEndpoints ¶
func (as AreaStruct) ListEndpoints()
func (*AreaStruct) SortEndPoints ¶
func (as *AreaStruct) SortEndPoints() []EndPointName
type Areas ¶
type Areas map[AreaName]AreaStruct // TypeEndPoints // Map of EndPoints by area name.
func (*Areas) EndpointExists ¶
func (an *Areas) EndpointExists(area AreaName, name EndPointName) error
func (*Areas) GetEndPoint ¶
func (an *Areas) GetEndPoint(area AreaName, name EndPointName) EndPoint
func (*Areas) GetRequest ¶
func (an *Areas) GetRequest(area AreaName, endpoint EndPointName) output.Json
func (*Areas) GetResponse ¶
func (an *Areas) GetResponse(area AreaName, endpoint EndPointName) output.Json
func (Areas) ListEndpoints ¶
func (*Areas) SetRequest ¶
func (an *Areas) SetRequest(area AreaName, name EndPointName, ref interface{}) error
type DataEntry ¶
type DataEntry struct { EndPoint string `json:"endpoint"` Point *Point `json:"point"` Date DateTime `json:"date"` // Id string `json:"id"` // GroupName string `json:"group_name"` // Name string `json:"name"` // Unit string `json:"unit"` Value string `json:"value"` ValueFloat float64 `json:"value_float"` Index int `json:"index"` }
func CreateDataEntryActive ¶
func CreateDataEntryString ¶
func (*DataEntry) CreateAlias ¶
func (*DataEntry) CreateFloat ¶
func (*DataEntry) CreateState ¶
type DataMap ¶
func NewDataMap ¶
func NewDataMap() DataMap
func (*DataMap) AddEntryFromRef ¶
func (*DataMap) AddUnitValue ¶
func (*DataMap) FromRefAddAlias ¶
func (*DataMap) FromRefAddAlias2 ¶
func (*DataMap) FromRefAddFloat ¶
func (*DataMap) FromRefAddState ¶
func (*DataMap) GetFloatValue ¶
func (*DataMap) StructToPoints ¶
type DateTime ¶
type DateTime struct { time.Time DateType string Error error // contains filtered or unexported fields }
func NewDateTime ¶
func (*DateTime) GetDayEndTimestamp ¶
func (*DateTime) GetDayStartTimestamp ¶
type EndPoint ¶
type EndPoint interface { GetArea() AreaName GetName() EndPointName GetUrl() EndPointUrl IsDisabled() bool Help() string Call() EndPoint SetError(string, ...interface{}) EndPoint GetError() error IsError() bool MarshalJSON() ([]byte, error) ReadDataFile() error WriteDataFile() error String() string GetJsonData(bool) output.Json SetRequest(ref interface{}) EndPoint // EndPointStruct SetRequestByJson(j output.Json) EndPoint RequestRef() interface{} GetRequestJson() output.Json IsRequestValid() error RequestString() string RequestFingerprint() string SetResponse([]byte) EndPoint // EndPointStruct ResponseRef() interface{} GetResponseJson() output.Json IsResponseValid() error ResponseString() string // WriteCache() error // ReadCache() EndPoint // CheckCache() bool CacheFilename() string SetCacheTimeout(duration time.Duration) EndPoint GetCacheTimeout() time.Duration }
type EndPointName ¶
type EndPointName string
func GetName ¶
func GetName(v interface{}) EndPointName
type EndPointStruct ¶
type EndPointStruct struct { ApiRoot Web `json:"-"` RawResponse []byte Area AreaName `json:"area"` Name EndPointName `json:"name"` Url EndPointUrl `json:"url"` FileNamePrefix string Request interface{} `json:"-"` Response interface{} `json:"-"` Error error `json:"-"` }
func (*EndPointStruct) ApiCacheFilename ¶
func (ep *EndPointStruct) ApiCacheFilename(request interface{}) string
func (*EndPointStruct) ApiFingerprint ¶
func (ep *EndPointStruct) ApiFingerprint(request interface{}) string
func (*EndPointStruct) ApiReadDataFile ¶
func (ep *EndPointStruct) ApiReadDataFile(ref interface{}) error
FileRead Retrieves data from a local file.
func (*EndPointStruct) ApiWriteDataFile ¶
func (ep *EndPointStruct) ApiWriteDataFile(ref interface{}) error
FileWrite Saves data to a file path.
func (*EndPointStruct) Call ¶
func (ep *EndPointStruct) Call() output.Json
func (*EndPointStruct) FileExists ¶
func (ep *EndPointStruct) FileExists(fn string) bool
FileExists Checks for existance of a local file.
func (*EndPointStruct) GetArea ¶
func (ep *EndPointStruct) GetArea() AreaName
func (*EndPointStruct) GetCsvFilename ¶
func (ep *EndPointStruct) GetCsvFilename() string
func (*EndPointStruct) GetFilePath ¶
func (ep *EndPointStruct) GetFilePath() string
func (*EndPointStruct) GetImageFilename ¶
func (ep *EndPointStruct) GetImageFilename() string
func (*EndPointStruct) GetJsonFilename ¶
func (ep *EndPointStruct) GetJsonFilename() string
func (*EndPointStruct) GetName ¶
func (ep *EndPointStruct) GetName() EndPointName
func (*EndPointStruct) GetRequest ¶
func (ep *EndPointStruct) GetRequest() output.Json
func (*EndPointStruct) GetResponse ¶
func (ep *EndPointStruct) GetResponse() output.Json
func (*EndPointStruct) GetUrl ¶
func (ep *EndPointStruct) GetUrl() EndPointUrl
func (*EndPointStruct) IsValid ¶
func (ep *EndPointStruct) IsValid() error
func (EndPointStruct) ResponseAsJson ¶
func (ep EndPointStruct) ResponseAsJson(raw bool, r interface{}) output.Json
func (*EndPointStruct) SetFilenamePrefix ¶
func (ep *EndPointStruct) SetFilenamePrefix(format string, args ...interface{}) string
func (*EndPointStruct) SetRequest ¶
func (ep *EndPointStruct) SetRequest(ref interface{}) error
func (EndPointStruct) String ¶
func (ep EndPointStruct) String() string
type EndPointUrl ¶
func SetUrl ¶
func SetUrl(endpoint string) EndPointUrl
func (EndPointUrl) AppendPath ¶
func (u EndPointUrl) AppendPath(endpoint string) EndPointUrl
func (*EndPointUrl) IsValid ¶
func (u *EndPointUrl) IsValid() error
func (*EndPointUrl) MarshalJSON ¶
func (u *EndPointUrl) MarshalJSON() ([]byte, error)
func (EndPointUrl) String ¶
func (u EndPointUrl) String() string
func (*EndPointUrl) UnmarshalJSON ¶
func (u *EndPointUrl) UnmarshalJSON(data []byte) error
type Point ¶
type Point struct { EndPoint string `json:"endpoint"` FullId string `json:"full_id"` PsKey string `json:"ps_key"` Id string `json:"id"` GroupName string `json:"group_name"` Name string `json:"name"` Unit string `json:"unit"` Type string `json:"type"` Valid bool `json:"valid"` }
func GetDevicePoint ¶
func GetPointInt ¶
func ResolvePoint ¶
type PointsMap ¶
func (PointsMap) GetDevicePoint ¶
type Request ¶
type Request struct {
RequestCommon
}
type RequestCommon ¶
type RequestCommon struct { Appkey string `json:"appkey" required:"true"` Lang string `json:"lang"` SysCode string `json:"sys_code" required:"true"` Token string `json:"token"` UserID string `json:"user_id"` ValidFlag string `json:"valid_flag"` }
func (RequestCommon) IsValid ¶
func (req RequestCommon) IsValid() error
func (RequestCommon) String ¶
func (req RequestCommon) String() string
type Response ¶
type Response struct {
ResponseCommon
}
type ResponseCommon ¶
type ResponseCommon struct { ReqSerialNum string `json:"req_serial_num"` ResultCode string `json:"result_code"` ResultData []interface{} `json:"result_data"` ResultMsg string `json:"result_msg"` }
func (ResponseCommon) CheckResultCode ¶
func (req ResponseCommon) CheckResultCode() error
func (ResponseCommon) CheckResultMessage ¶
func (req ResponseCommon) CheckResultMessage() error
func (ResponseCommon) IsTokenInvalid ¶
func (req ResponseCommon) IsTokenInvalid() bool
func (ResponseCommon) IsTokenValid ¶
func (req ResponseCommon) IsTokenValid() bool
func (ResponseCommon) IsValid ¶
func (req ResponseCommon) IsValid() error
func (ResponseCommon) String ¶
func (req ResponseCommon) String() string
type TemplatePoint ¶
type TemplatePoints ¶
type TemplatePoints []TemplatePoint
func CreatePoints ¶
func CreatePoints(points []string) TemplatePoints
func (*TemplatePoints) GetPoint ¶
func (t *TemplatePoints) GetPoint(pskey string, point string) TemplatePoint
func (*TemplatePoints) PrintKeys ¶
func (t *TemplatePoints) PrintKeys() string
func (*TemplatePoints) PrintPoints ¶
func (t *TemplatePoints) PrintPoints() string
type TypeEndPoints ¶
type TypeEndPoints map[EndPointName]EndPoint // Map of EndPoints by endpoint name.
func (TypeEndPoints) Exists ¶
func (ps TypeEndPoints) Exists(name EndPointName) error
func (*TypeEndPoints) GetDisabled ¶
func (ps *TypeEndPoints) GetDisabled() TypeEndPoints
func (*TypeEndPoints) GetEnabled ¶
func (ps *TypeEndPoints) GetEnabled() TypeEndPoints
func (*TypeEndPoints) GetEndPoint ¶
func (ps *TypeEndPoints) GetEndPoint(name EndPointName) EndPoint
func (*TypeEndPoints) SortEndPoints ¶
func (ps *TypeEndPoints) SortEndPoints() []EndPointName
func (TypeEndPoints) String ¶
func (ps TypeEndPoints) String() string
type UnitValue ¶
type UnitValue struct { Unit string `json:"unit"` Value string `json:"value"` ValueFloat float64 `json:"value_float,omitempty"` ValueInt int64 `json:"value_int,omitempty"` }
func CreateUnitValue ¶
func JsonToUnitValue ¶
func (*UnitValue) UnitValueFix ¶
type UnitValueMap ¶
func GetStructKeys ¶
func GetStructKeys(ref interface{}, keys ...string) UnitValueMap
func (*UnitValueMap) Sort ¶
func (u *UnitValueMap) Sort() []string
type UnitValues ¶
type UnitValues []UnitValue
type Web ¶
type Web struct { Url EndPointUrl Body []byte Error error // contains filtered or unexported fields }
func (*Web) AppendUrl ¶
func (w *Web) AppendUrl(endpoint string) EndPointUrl
func (*Web) CacheRemove ¶
CacheRemove Removes a cache file.
func (*Web) CacheWrite ¶
CacheWrite Saves cache data to a file path.
func (*Web) CheckCache ¶
CheckCache Retrieves cache data from a local file.
func (*Web) GetCacheDir ¶
func (*Web) GetCacheTimeout ¶
func (*Web) SetCacheDir ¶
func (*Web) SetCacheTimeout ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package apiReflect - Snaffooed from https://github.com/fatih/structs
|
Package apiReflect - Snaffooed from https://github.com/fatih/structs |
Package nullEndPoint - This file is auto-generated from the update_all.sh script.
|
Package nullEndPoint - This file is auto-generated from the update_all.sh script. |
Click to show internal directories.
Click to hide internal directories.