Documentation
¶
Overview ¶
Package smartmeter provides an ECHONET Lite client for smart meters.
Index ¶
- Constants
- Variables
- type ClassCode
- type Device
- func (d *Device) Authenticate(opts ...Option) (err error)
- func (d *Device) GetInfo(opts ...Option) (info string, err error)
- func (d *Device) GetNeibourIP(opts ...Option) (ipAddr string, err error)
- func (d *Device) GetRegisterValue(regName string, opts ...Option) (registerValue string, err error)
- func (d *Device) GetVersion(opts ...Option) (version string, err error)
- func (d *Device) Join(opts ...Option) (err error)
- func (d *Device) QueryEchonetLite(req *Frame, opts ...Option) (res *Frame, err error)
- func (d *Device) QuerySKCommand(cmd string, opts ...Option) (res string, err error)
- func (d *Device) Scan(opts ...Option) (err error)
- func (d *Device) SetID(opts ...Option) (err error)
- func (d *Device) SetPassword(opts ...Option) (err error)
- func (d *Device) SetRegisterValue(regName string, regValue string, opts ...Option) (err error)
- type Frame
- type Option
- func Channel(channel string) Option
- func DualStackSK(v bool) Option
- func ID(id string) Option
- func IPAddr(ipAddr string) Option
- func Logger(logger *log.Logger) Option
- func Password(pw string) Option
- func Reader(callback func(string) (bool, error)) Option
- func Retry(count int) Option
- func RetryInterval(d time.Duration) Option
- func Timeout(d time.Duration) Option
- func Verbosity(v int) Option
- type Property
- type PropertyCode
- type ServiceCode
Constants ¶
const ( HeaderEchonetLite uint16 = 0x1081 // 0x10=ECHONET Lite, 0x81=電文形式1 Controller ClassCode = 0x05ff01 // コントローラ NodeProfile ClassCode = 0x0ef001 // ノードプロファイル LvSmartElectricEnergyMeter ClassCode = 0x028801 // 低圧スマート電力量メータ Get ServiceCode = 0x62 GetRes ServiceCode = 0x72 )
ECHONET Lite constants.
Variables ¶
var ErrRetryable = errors.New("retrying")
ErrRetryable marks an error that should trigger a retry.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
SerialPort string
ID string
Password string
Channel string
IPAddr string
DualStackSK bool
Verbosity int
// contains filtered or unexported fields
}
Device represents a smart meter connection and its settings.
func (*Device) Authenticate ¶
Authenticate performs scan, register configuration, and join.
func (*Device) GetNeibourIP ¶
GetNeibourIP returns the neighbor IP address from SKTABLE 2.
func (*Device) GetRegisterValue ¶
func (d *Device) GetRegisterValue( regName string, opts ...Option, ) (registerValue string, err error)
GetRegisterValue returns a register value from SKSREG.
func (*Device) GetVersion ¶
GetVersion returns the version string from SKVER.
func (*Device) QueryEchonetLite ¶
QueryEchonetLite sends an ECHONET Lite request and waits for the response.
func (*Device) QuerySKCommand ¶
QuerySKCommand sends an SK command and returns the response text.
func (*Device) Scan ¶
Scan performs an active scan and populates channel, PAN ID, MAC address, and IP address.
func (*Device) SetPassword ¶
SetPassword sets the B-route authentication password on the device.
type Frame ¶
type Frame struct {
TID uint16 // トランザクションID
SEOJ ClassCode // 送信元ECHONET Liteオブジェクト
DEOJ ClassCode // 相手先ECHONET Liteオブジェクト
ESV ServiceCode // ECHONET Liteサービス
Properties []*Property // ECHONETプロパティ
}
Frame はECHONET Liteのフレームに対応する構造体。 複数のプロパティの操作を1フレームにまとめて送信することができる。
func NewFrame ¶
func NewFrame(dstClassCode ClassCode, esv ServiceCode, props []*Property) *Frame
NewFrame は Frame構造体のコンストラクタ関数。
func ParseFrame ¶
ParseFrame は ECHONET Liteフレームのバイト列を受け取り、Frame構造体として返す。
func (*Frame) CorrespondTo ¶
CorrespondTo は fとtargetとがリクエスト/レスポンスとして対応しているか確認する。
type Option ¶
type Option func(interface{}) error
Option configures a Device or query.
func DualStackSK ¶
DualStackSK enables or disables the dual stack SK behavior.
func RetryInterval ¶
RetryInterval sets the duration between retries.
type Property ¶
type Property struct {
EPC PropertyCode // ECHONETプロパティ
EDT []byte // 要求電文プロパティ値データ(EDT)
}
Property はECHONET Liteのプロパティに対応する構造体。
func NewProperty ¶
func NewProperty(epc PropertyCode, edt []byte) *Property
NewProperty は Property構造体のコンストラクタ関数。
type PropertyCode ¶
type PropertyCode byte
PropertyCode identifies an ECHONET Lite property code (EPC).
const ( NodeProfileVersionInformation PropertyCode = 0x82 // Version情報 NodeProfileIdentificationNumber PropertyCode = 0x83 // 識別番号 NodeProfileFaultStatus PropertyCode = 0x88 NodeProfileFaultContent PropertyCode = 0x89 NodeProfileManufacturerCode PropertyCode = 0x8a // メーカコード NodeProfileBusinessFacilityCode PropertyCode = 0x8b // 事業場コード NodeProfileProductCode PropertyCode = 0x8c // 商品コード NodeProfileProductionNumber PropertyCode = 0x8d // 製造番号 NodeProfileProductionDate PropertyCode = 0x8e // 製造年月日 NodeProfileUniqueIdentifierData PropertyCode = 0xbf // 個体識別情報 // NodeProfileNumberOfSelfNodeInstances PropertyCode = 0xd3 // 自ノードインスタンス数(作者の環境では1) // 自ノードクラス数(作者の環境では2) NodeProfileNumberOfSelfNodeClasses PropertyCode = 0xd4 NodeProfileInstanceListNotification PropertyCode = 0xd5 NodeProfileSelfNodeInstanceListS PropertyCode = 0xd6 // 自ノードインスタンスリストS NodeProfileSelfNodeClassListS PropertyCode = 0xd7 // 自ノードクラスリストS // 係数(作者の環境では1) LvSmartElectricEnergyMeterCoefficient PropertyCode = 0xd3 // 積算電力量(正方向) LvSmartElectricEnergyMeterNormalDirectionCumulativeElectricEnergy PropertyCode = 0xe0 // 積算電力量単位(作者の環境では0.1kWh) LvSmartElectricEnergyMeterUnitForCumulativeAmountsOfElectricEnergy PropertyCode = 0xe1 // 積算電力量(逆方向) LvSmartElectricEnergyMeterReverseDirectionCumulativeElectricEnergy PropertyCode = 0xe3 // 瞬時電力計測値 LvSmartElectricEnergyMeterInstantaneousElectricPower PropertyCode = 0xe7 // 瞬時電流計測値 LvSmartElectricEnergyMeterInstantaneousCurrent PropertyCode = 0xe8 // 定時積算電力量(正方向) LvSmartElectricEnergyMeterNormalDirectionCumulativeElectricEnergyAtEvery30Min PropertyCode = 0xea // 定時積算電力量(逆方向) LvSmartElectricEnergyMeterReverseDirectionCumulativeElectricEnergyAtEvery30Min PropertyCode = 0xeb )
Property codes for node profile and low-voltage smart electric energy meter.