nmi

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package nmi delivers nmi capabilities to the aemo library.

From: https://aemo.com.au/-/media/files/electricity/nem/retail_and_metering/metering-procedures/2016/0610-0008-pdf.pdf

NMI Structure

The NMI is a ten (10) character identifier assigned by Local Network Service Providers (LNSPs) in accordance with this procedure. The publication of this procedure and assignment of NMIs is authorized by the National Electricity Rules at clause 7.3.1(d), (da), and (db).

The NMI may be used in conjunction with other identifiers or suffixes. These include:

• The NMI checksum, a single numeral used to assist with data validation when the NMI is manually entered into a computer system.

• The NMI data stream suffix used to identify a particular data stream associated with a connection point.

Generally the NMI is an all numeric identifier; the limited circumstances under which alpha characters may be used are listed later in this procedure.

The key attributes of the NMI are:

• The NMI must embody only numeric characters, except as explicitly provided within this document, and must not contain spaces.

• Character letters ‘O’ and ‘I’ are not permitted in order to avoid confusion with numbers 0 and 1.

• ‘W’ is a reserved character to be used as the fifth digit of the Allocated Identifier for wholesale transmission connection metering points only. It may only be used if the NMI is allocated from an alphanumeric block.

• Embedded characters or meanings should not be used in allocating NMIs.

• Where AEMO has allocated a block of NMIs to an LNSP, the LNSP must only use numeric characters in the NMIs allocated to the market unless AEMO has directed the block to be alphanumeric.

• Where AEMO has allocated a block of NMIs to an LNSP, and directed the block to be alphanumeric, the LNSP may use all-numeric or alphanumeric characters in the NMIs allocated to the market.

Network Service Providers must maintain a register of all NMIs released. AEMO maintains a Register of all ‘on-market’ NMIs within AEMO’s market systems.

The base NMI is ten characters. In some circumstances the NMI checksum is appended to the NMI to form an eleven-character NMI, or the two character NMI data stream suffix may be appended to form a twelve-character NMI. NMI checksum is not used with the data stream suffix because the data stream suffix is intended for use only with electronic data transfer.

In the initial allocation of alphanumeric NMIs the first character was a jurisdiction indicator. Jurisdiction indicators were abolished in October.

AEMO may allocate blocks of NMIs to LNSPs from any unused range.

The range 5 XXX XXX XXX has been reserved for use within the gas industry. To avoid the risk of confusion, AEMO has agreed not to issue NMIs commencing with 5.

The range 9 XXX XXX XXX has been reserved as a “break-out” if it becomes necessary to move to an 11 character NMI.

Index

Constants

View Source
const (
	// NMICHECKSUMINVALID is returned when a valid checksum cannot be determined.
	NMICHECKSUMINVALID = -1
	// NmiLength is the standard length of a Nmi.
	NmiLength = 10
	// NmiValidPattern the pattern for valid Nmis.
	NmiValidPattern = `^([A-HJ-NP-Z\d]{10})`
)

Variables

View Source
var (

	// EnergyName maps Energy to strings.
	EnergyName = map[Energy]string{
		EnergyUndefined:   "UNDEFINED",
		EnergyElectricity: "ELECTRICITY",
		EnergyGas:         "GAS",
	}

	// EnergyValue maps strings to Energy.
	EnergyValue = map[string]Energy{
		"UNDEFINED":   EnergyUndefined,
		"ELECTRICITY": EnergyElectricity,
		"GAS":         EnergyGas,
	}
)
View Source
var (
	// ErrIsDuplicated if is duplicated.
	ErrIsDuplicated = errors.New("is duplicated")
	// ErrIsInvalid if is invalid.
	ErrIsInvalid = errors.New("is invalid")
	// ErrIsMissing if is missing.
	ErrIsMissing = errors.New("is missing")
	// ErrIsNil if is nil.
	ErrIsNil = errors.New("is nil")
	// ErrParseFailed if parse has failed.
	ErrParseFailed = errors.New("parse has failed")

	// ErrEnergyInvalid if energy is invalid.
	ErrEnergyInvalid = fmt.Errorf("energy %w", ErrIsInvalid)
	// ErrNmiInvalid if nmi is invalid.
	ErrNmiInvalid = fmt.Errorf("nmi %w", ErrIsInvalid)
	// ErrNmiInvalidChar if nmi has invalid character.
	ErrNmiInvalidChar = fmt.Errorf("nmi has character that %w", ErrIsInvalid)
	// ErrNmiInvalidLength if nmi has invalid length.
	ErrNmiInvalidLength = fmt.Errorf("nmi length %w", ErrIsInvalid)
	// ErrMeterNil if meter is nil.
	ErrMeterNil = fmt.Errorf("meter %w", ErrIsNil)
	// ErrNmiMeterFound if nmi meter is found.
	ErrNmiMeterFound = errors.New("nmi meter is found")
	// ErrNmiMeterNotFound if nmi meter is not found.
	ErrNmiMeterNotFound = fmt.Errorf("nmi meter is not found")
	// ErrNmiMeterIdentifierEmpty if nmi meter identifier is empty.
	ErrNmiMeterIdentifierEmpty = fmt.Errorf("nmi meter identifier %w", ErrIsMissing)
	// ErrNmiNil if nmi is nil.
	ErrNmiNil = fmt.Errorf("nmi %w", ErrIsNil)
	// ErrNmiParticipantNotFound if nmi participant is not found.
	ErrNmiParticipantNotFound = fmt.Errorf("nmi participant is not found")
	// ErrParticipantInvalid if participant is invalid.
	ErrParticipantInvalid = fmt.Errorf("participant %w", ErrIsInvalid)
	// ErrPatternInvalid if pattern is invalid.
	ErrPatternInvalid = fmt.Errorf("pattern %w", ErrIsInvalid)
	// ErrRegionInvalid if region is invalid.
	ErrRegionInvalid = fmt.Errorf("region %w", ErrIsInvalid)
)
View Source
var (

	// ParticipantName maps Participants to strings.
	ParticipantName = map[Participant]string{
		ParticipantUndefined:      "UNDEFINED",
		ParticipantACTEWP:         "ACTEWP",
		ParticipantAEMORESERVED:   "AEMORESERVED",
		ParticipantAURORAP:        "AURORAP",
		ParticipantCITIPP:         "CITIPP",
		ParticipantCNRGYP:         "CNRGYP",
		ParticipantEASTERN:        "EASTERN",
		ParticipantENERGEXP:       "ENERGEXP",
		ParticipantENERGYAP:       "ENERGYAP",
		ParticipantERGONETP:       "ERGONETP",
		ParticipantETSATP:         "ETSATP",
		ParticipantEXEMPTNETWORKS: "EXEMPTNETWORKS",
		ParticipantFEDAIRPORTS:    "FEDAIRPORTS",
		ParticipantGASNSW:         "GASNSW",
		ParticipantGASQLD:         "GASQLD",
		ParticipantGASSA:          "GASSA",
		ParticipantGASTAS:         "GASTAS",
		ParticipantGASVIC:         "GASVIC",
		ParticipantGASWA:          "GASWA",
		ParticipantGPUPP:          "GPUPP",
		ParticipantHORIZONPOWER:   "HORIZONPOWER",
		ParticipantINTEGP:         "INTEGP",
		ParticipantNTRESERVED:     "NTRESERVED",
		ParticipantPLINKP:         "PLINKP",
		ParticipantPOWCP:          "POWCP",
		ParticipantSNOWY:          "SNOWY",
		ParticipantSOLARISP:       "SOLARISP",
		ParticipantTRANSEND:       "TRANSEND",
		ParticipantTRANSGP:        "TRANSGP",
		ParticipantUMPLP:          "UMPLP",
		ParticipantUNITED:         "UNITED",
		ParticipantWESTERNPOWER:   "WESTERNPOWER",
	}

	// ParticipantValue maps strings to Participants.
	ParticipantValue = map[string]Participant{
		"UNDEFINED":      ParticipantUndefined,
		"ACTEWP":         ParticipantACTEWP,
		"AEMORESERVED":   ParticipantAEMORESERVED,
		"AURORAP":        ParticipantAURORAP,
		"CITIPP":         ParticipantCITIPP,
		"CNRGYP":         ParticipantCNRGYP,
		"EASTERN":        ParticipantEASTERN,
		"ENERGEXP":       ParticipantENERGEXP,
		"ENERGYAP":       ParticipantENERGYAP,
		"ERGONETP":       ParticipantERGONETP,
		"ETSATP":         ParticipantETSATP,
		"EXEMPTNETWORKS": ParticipantEXEMPTNETWORKS,
		"FEDAIRPORTS":    ParticipantFEDAIRPORTS,
		"GASNSW":         ParticipantGASNSW,
		"GASQLD":         ParticipantGASQLD,
		"GASSA":          ParticipantGASSA,
		"GASTAS":         ParticipantGASTAS,
		"GASVIC":         ParticipantGASVIC,
		"GASWA":          ParticipantGASWA,
		"GPUPP":          ParticipantGPUPP,
		"HORIZONPOWER":   ParticipantHORIZONPOWER,
		"INTEGP":         ParticipantINTEGP,
		"NTRESERVED":     ParticipantNTRESERVED,
		"PLINKP":         ParticipantPLINKP,
		"POWCP":          ParticipantPOWCP,
		"SNOWY":          ParticipantSNOWY,
		"SOLARISP":       ParticipantSOLARISP,
		"TRANSEND":       ParticipantTRANSEND,
		"TRANSGP":        ParticipantTRANSGP,
		"UMPLP":          ParticipantUMPLP,
		"UNITED":         ParticipantUNITED,
		"WESTERNPOWER":   ParticipantWESTERNPOWER,
	}

	// ParticipantIDs lists all participant ids.
	ParticipantIDs = []string{
		"UNDEFINED",
		"ACTEWP",
		"AEMORESERVED",
		"AURORAP",
		"CITIPP",
		"CNRGYP",
		"EASTERN",
		"ENERGEXP",
		"ENERGYAP",
		"ERGONETP",
		"ETSATP",
		"EXEMPTNETWORKS",
		"FEDAIRPORTS",
		"GASNSW",
		"GASQLD",
		"GASSA",
		"GASTAS",
		"GASVIC",
		"GASWA",
		"GPUPP",
		"HORIZONPOWER",
		"INTEGP",
		"NTRESERVED",
		"PLINKP",
		"POWCP",
		"SNOWY",
		"SOLARISP",
		"TRANSEND",
		"TRANSGP",
		"UMPLP",
		"UNITED",
		"WESTERNPOWER",
	}
)
View Source
var (
	// NmiValidRegexp is the regular expression that Nmi strings may contain.
	NmiValidRegexp = regexp.MustCompile(NmiValidPattern)
)

Functions

func Checksum

func Checksum(s string) int

Checksum calculates a Nmi's checksum.

Types

type Allocations

type Allocations []Pattern

Allocations is an allocation of the NMI.

func (Allocations) Compile

func (a Allocations) Compile() ([]*regexp.Regexp, error)

Compile compiles all patterns.

type DLFC

type DLFC string

DLFC is the Distribution Loss Factor Code.

type Energy

type Energy int32

Energy represents the type of energy for a nmi.

const (
	// EnergyUndefined is undefined.
	EnergyUndefined Energy = iota
	// EnergyElectricity is electricity.
	EnergyElectricity
	// EnergyGas is gas.
	EnergyGas
)

func Energies

func Energies() []Energy

Energies provides a slice of valid energies.

func NewEnergy

func NewEnergy(s string) (Energy, error)

NewEnergy returns an energy based on the string provided.

func (Energy) GoString

func (e Energy) GoString() string

GoString satisfies the GoString interface.

func (Energy) String

func (e Energy) String() string

String satisfies the stringer interface.

type Meter

type Meter struct {
	Nmi                string           `json:"nmi,omitempty"`
	Identifier         string           `json:"identifier,omitempty"`
	Registers          []*MeterRegister `json:"registers,omitempty"`
	SerialNumber       *string          `json:"serialNumber,omitempty"`
	FromDateTime       *time.Time       `json:"fromDateTime,omitempty"`
	ToDateTime         *time.Time       `json:"toDateTime,omitempty"`
	LastTestDate       *time.Time       `json:"lastTestDate,omitempty"`
	AdditionalSiteInfo *string          `json:"additionalSiteInformation,omitempty"`
}

Meter for a NMI.

func (*Meter) GoString

func (m *Meter) GoString() string

GoString meets the gostring interface.

func (*Meter) String

func (m *Meter) String() string

String meets the stringer interface.

type MeterRegister

type MeterRegister struct {
	RegisterID        string `json:"registerID,omitempty"`
	MeasurementStream string `json:"measurementStream,omitempty"`
	NetworkTariffCode string `json:"networkTariffCode,omitempty"`
	UnitOfMeasure     string `json:"unitOfMeasure,omitempty"`
	TimeOfDay         string `json:"timeOfDay,omitempty"`
	Multiplier        int    `json:"multiplier,omitempty"`
	DialFormat        string `json:"dialFormat,omitempty"`
	ControlledLoad    bool   `json:"controlledLoad,omitempty"`
	ConsumptionType   string `json:"consumptionType,omitempty"`
	Status            string `json:"status,omitempty"`
}

MeterRegister for a Meter for a NMI.

func (*MeterRegister) GoString

func (mr *MeterRegister) GoString() string

GoString meets the gostring interface.

func (*MeterRegister) String

func (mr *MeterRegister) String() string

String meets the stringer interface.

type Meters

type Meters map[string]*Meter

Meters a collection of meters, using a map, with the identifier.

type Nmi

type Nmi struct {
	Identifier                 string `json:"identifier,omitempty"`
	MSATSDetail                string `json:"msatsDetail,omitempty"`
	TransmissionNodeIdentifier TNI    `json:"tni,omitempty"`
	DistributionLossFactorCode DLFC   `json:"dlfc,omitempty"`
	CustomerClassificationCode string `json:"customerClassificationCode,omitempty"`
	CustomerThresholdCode      string `json:"customerThresholdCode,omitempty"`
	JurisdictionCode           string `json:"jurisdictionCode,omitempty"`
	ClassificationCode         string `json:"classificationCode,omitempty"`
	Meters                     Meters `json:"meters,omitempty"`
	DataStreams                string `json:"datastreams,omitempty"`
}

Nmi is a national meter identifier as per AEMO. Ref: - https://aemo.com.au/-/media/files/electricity/nem/retail_and_metering/metering-procedures/2016/0610-0008-pdf.pdf

func NewNmi

func NewNmi(s string) (*Nmi, error)

NewNmi returns a string as a Nmi along with an error if not valid.

func (*Nmi) AddMeter

func (n *Nmi) AddMeter(m *Meter) error

AddMeter adds a new meter, returning an error if already added.

func (*Nmi) AllMeters

func (n *Nmi) AllMeters() ([]*Meter, error)

AllMeters returns all the meters for a Nmi.

func (*Nmi) Checksum

func (n *Nmi) Checksum() int

Checksum returns the checksum of the provided Nmi.

func (*Nmi) ChecksumValid

func (n *Nmi) ChecksumValid(i int) bool

ChecksumValid returns true if the provided checksum is valid.

func (*Nmi) GoString

func (n *Nmi) GoString() string

GoString meets the gostring interface.

func (*Nmi) Participant

func (n *Nmi) Participant() (Participant, error)

Participant returns the pariticipant for the Nmi.

func (*Nmi) Region

func (n *Nmi) Region() (region.Region, error)

Region returns the region based on the allocation.

func (*Nmi) RemoveMeter

func (n *Nmi) RemoveMeter(m *Meter) error

RemoveMeter removes a meter, returning an error if not in the list.

func (*Nmi) String

func (n *Nmi) String() string

String meets the stringer interface.

func (*Nmi) Valid

func (n *Nmi) Valid() bool

Valid returns true if the Nmi is valid.

func (*Nmi) Validate

func (n *Nmi) Validate() error

Validate checks if the Nmi is valid and returns the errors if not.

type Participant

type Participant int32

Participant is an index for the participant.

const (
	// ParticipantUndefined when participant is undefined.
	ParticipantUndefined Participant = iota
	// ParticipantACTEWP for the participant code ACTEWP.
	ParticipantACTEWP
	// ParticipantAEMORESERVED for the participant code AEMORESERVED.
	ParticipantAEMORESERVED
	// ParticipantAURORAP for the participant code AURORAP.
	ParticipantAURORAP
	// ParticipantCITIPP for the participant code CITIPP.
	ParticipantCITIPP
	// ParticipantCNRGYP for the participant code CNRGYP.
	ParticipantCNRGYP
	// ParticipantEASTERN for the participant code EASTERN.
	ParticipantEASTERN
	// ParticipantENERGEXP for the participant code ENERGEXP.
	ParticipantENERGEXP
	// ParticipantENERGYAP for the participant code ENERGYAP.
	ParticipantENERGYAP
	// ParticipantERGONETP for the participant code ERGONETP.
	ParticipantERGONETP
	// ParticipantETSATP for the participant code ETSATP.
	ParticipantETSATP
	// ParticipantEXEMPTNETWORKS for the participant code EXEMPTNETWORKS.
	ParticipantEXEMPTNETWORKS
	// ParticipantFEDAIRPORTS for the participant code FEDAIRPORTS.
	ParticipantFEDAIRPORTS
	// ParticipantGASNSW for the participant code GASNSW.
	ParticipantGASNSW
	// ParticipantGASQLD for the participant code GASQLD.
	ParticipantGASQLD
	// ParticipantGASSA for the participant code GASSA.
	ParticipantGASSA
	// ParticipantGASTAS for the participant code GASTAS.
	ParticipantGASTAS
	// ParticipantGASVIC for the participant code GASVIC.
	ParticipantGASVIC
	// ParticipantGASWA for the participant code GASWA.
	ParticipantGASWA
	// ParticipantGPUPP for the participant code GPUPP.
	ParticipantGPUPP
	// ParticipantHORIZONPOWER for the participant code HORIZONPOWER.
	ParticipantHORIZONPOWER
	// ParticipantINTEGP for the participant code INTEGP.
	ParticipantINTEGP
	// ParticipantNTRESERVED for the participant code NTRESERVED.
	ParticipantNTRESERVED
	// ParticipantPLINKP for the participant code PLINKP.
	ParticipantPLINKP
	// ParticipantPOWCP for the participant code POWCP.
	ParticipantPOWCP
	// ParticipantSNOWY for the participant code SNOWY.
	ParticipantSNOWY
	// ParticipantSOLARISP for the participant code SOLARISP.
	ParticipantSOLARISP
	// ParticipantTRANSEND for the participant code TRANSEND.
	ParticipantTRANSEND
	// ParticipantTRANSGP for the participant code TRANSGP.
	ParticipantTRANSGP
	// ParticipantUMPLP for the participant code UMPLP.
	ParticipantUMPLP
	// ParticipantUNITED for the participant code UNITED.
	ParticipantUNITED
	// ParticipantWESTERNPOWER for the participant code WESTERNPOWER.
	ParticipantWESTERNPOWER
)

func NewParticipant

func NewParticipant(s string) (Participant, error)

NewParticipant returns a participant for a string (AEMO Participant ID).

func Participants

func Participants() []Participant

Participants returns all valid participants.

func ParticipantsForRegion

func ParticipantsForRegion(r region.Region) []Participant

ParticipantsForRegion returns the pariticipants that operate in a region.

func (Participant) Allocations

func (p Participant) Allocations() Allocations

Allocations returns the participant's allocations.

func (Participant) Energy

func (p Participant) Energy() Energy

Energy returns the energy type of the participant's allocations.

func (Participant) GoString

func (p Participant) GoString() string

GoString meets the gostring interface.

func (Participant) Info

func (p Participant) Info() (*ParticipantInfo, error)

Info struct for a participant.

func (Participant) LongName

func (p Participant) LongName() string

LongName returns the long (full) name of the participant.

func (Participant) ParticipantID

func (p Participant) ParticipantID() string

ParticipantID returns the Participant ID.

func (Participant) Region

func (p Participant) Region() region.Region

Region returns the Participant's Region.

func (Participant) ShortName

func (p Participant) ShortName() string

ShortName returns the short (useful) name of the participant.

func (Participant) String

func (p Participant) String() string

String meets the stringer interface.

func (Participant) Valid

func (p Participant) Valid() bool

Valid returns true if a valid participant.

type ParticipantInfo

type ParticipantInfo struct {
	Participant   Participant   `json:"participant"`
	ParticipantID string        `json:"participantID"`
	Region        region.Region `json:"region"`
	LongName      string        `json:"longName"`
	ShortName     string        `json:"shortName"`
	Energy        Energy        `json:"energy"`
	Allocations   Allocations   `json:"allocations"`
}

ParticipantInfo provides structure for participant information.

type Pattern

type Pattern string

Pattern for making regexes nicer with pattern matching.

func NewPattern

func NewPattern(s string) (Pattern, error)

NewPattern validates a new pattern, return invalid pattern if required.

func (Pattern) Compile

func (p Pattern) Compile() (*regexp.Regexp, error)

Compile compiles the pattern, returning the regexp and an error.

func (Pattern) Match

func (p Pattern) Match(s string) bool

Match returns true if the pattern matches a given string.

func (Pattern) String

func (p Pattern) String() string

String returns the pattern as a string.

type Role

type Role struct {
	FromDateTime time.Time `json:"fromDateTime,omitempty"`
	ToDateTime   time.Time `json:"toDateTime,omitempty"`
	Party        string    `json:"party,omitempty"`
	Type         string    `json:"type,omitempty"`
}

Role related to a Nmi.

type TNI

type TNI string

TNI is the Transmission Node Identifier.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL