nem12

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: 10 Imported by: 0

Documentation

Overview

Package nem12 delivers the AEMO NEM12 data processing capability, with support for both the reading and the generating of NEM12 files. This support extends to being both canonical (that is, inclusive of the 100 and 900 rows), non-canonical (that is, exclusive of the 100 and 900 rows), and with relaxed validation.

The NEM12 reader interface allows for the reading of entire meter data streams, daily chunks or individual meter reads at a time.

The NEM12 writer interface delivers the ability to create either a canonical or a non-canonical NEM12 file from the provided data.

Index

Constants

View Source
const (
	// MethodUndefined for undefined methods.
	MethodUndefined = Method(0)
	// Method11Check for check.
	Method11Check = Method(11)
	// Method12Calculated for calculated.
	Method12Calculated = Method(12)
	// Method13SCADA for scada.
	Method13SCADA = Method(13)
	// Method14LikeDay for like day.
	Method14LikeDay = Method(14)
	// Method15AverageLikeDay for average like day.
	Method15AverageLikeDay = Method(15)
	// Method16Agreed for agreed.
	Method16Agreed = Method(16)
	// Method17Linear for linear.
	Method17Linear = Method(17)
	// Method18Alternate for alternate.
	Method18Alternate = Method(18)
	// Method19Zero for zero.
	Method19Zero = Method(19)
	// Method20ChurnCorrection for churn correction (like day).
	Method20ChurnCorrection = Method(20)
	// Method21FiveMinuteNoHistoricalData for five-minute no historical data.
	Method21FiveMinuteNoHistoricalData = Method(21)
	// Method51PreviousYear for previous year.
	Method51PreviousYear = Method(51)
	// Method52PreviousRead for previous read.
	Method52PreviousRead = Method(52)
	// Method53Revision for revision.
	Method53Revision = Method(53)
	// Method54Linear for linear.
	Method54Linear = Method(54)
	// Method55Agreed for agreed.
	Method55Agreed = Method(55)
	// Method56PriortoFirstReadAgreed for prior to first read - agreed.
	Method56PriortoFirstReadAgreed = Method(56)
	// Method57CustomerClass for customer class.
	Method57CustomerClass = Method(57)
	// Method58Zero for zero.
	Method58Zero = Method(58)
	// Method59FiveMinuteNoHistoricalData for five-minute no historical data.
	Method59FiveMinuteNoHistoricalData = Method(59)
	// Method61PreviousYear for previous year.
	Method61PreviousYear = Method(61)
	// Method62PreviousRead for previous read.
	Method62PreviousRead = Method(62)
	// Method63CustomerClass for customer class.
	Method63CustomerClass = Method(63)
	// Method64Agreed for agreed.
	Method64Agreed = Method(64)
	// Method65ADL for adl.
	Method65ADL = Method(65)
	// Method66Revision for revision.
	Method66Revision = Method(66)
	// Method67CustomerRead for customer read.
	Method67CustomerRead = Method(67)
	// Method68Zero for zero.
	Method68Zero = Method(68)
	// Method69LinearExtrapolation for linear extrapolation.
	MetMethod69LinearExtrapolation = Method(69)
	// Method71Recalculation for recalculation.
	Method71Recalculation = Method(71)
	// Method72RevisedTable for revised table.
	Method72RevisedTable = Method(72)
	// Method73RevisedAlgorithm for revised algorithm.
	Method73RevisedAlgorithm = Method(73)
	// Method74Agreed for agreed.
	Method74Agreed = Method(74)
	// Method75ExistingTable for existing table.
	Method75ExistingTable = Method(75)
)
View Source
const (
	// ReasonUndefined where the reason is undefined.
	ReasonUndefined = Reason(-1)
	// ReasonFreeTextDescription where the reason is free text description.
	// For use in the case that other reason code descriptions cannot be reasonably
	// utilised.
	ReasonFreeTextDescription = Reason(0)
	// ReasonMeterEquipmentChanged where the reason is meter/equipment changed.
	// Where metering installation has changed.
	ReasonMeterEquipmentChanged = Reason(1)
	// ReasonExtremeWeatherConditions where the reason is extreme weather conditions.
	// Extreme weather conditions have prevented metering data collection.
	ReasonExtremeWeatherConditions = Reason(2)
	// ReasonQuarantinedPremises where the reason is quarantined premises.
	// Site under quarantine preventing access to metering installation.
	ReasonQuarantinedPremises = Reason(3)
	// ReasonDangerousDog where the reason is dangerous dog.
	// Dog has been identified as posing an immediate hazard to metering installation
	// access.
	ReasonDangerousDog = Reason(4)
	// ReasonBlankScreen where the reason is blank screen.
	// Electronic meter has blank display, could be powered off or faulty display
	// but unable to determine.
	ReasonBlankScreen = Reason(5)
	// ReasonDeEnergisedPremises where the reason is de-energised premises.
	// Blank screen on an electronic meter where the meter reader can determine that
	// the Site is de-energised or an Interval Metered Site where the MDP is providing
	// substituted metering data for a Site that is de-energised but Datastreams are
	// left active.
	ReasonDeEnergisedPremises = Reason(6)
	// ReasonUnableToLocateMeter where the reason is unable to locate meter.
	// The Site was found, but unable to locate the metering installation.
	ReasonUnableToLocateMeter = Reason(7)
	// ReasonVacantPremises where the reason is vacant premises. Meter reader believes
	// the Site is vacant.
	ReasonVacantPremises = Reason(8)
	// ReasonUnderInvestigation where the reason is under investigation. An issue
	// with the metering installation has been identified and is under investigation.
	ReasonUnderInvestigation = Reason(9)
	// ReasonLockDamagedUnableToOpen where the reason is lock damaged unable to open.
	// Unable to open lock due to damage and the lock is preventing access to the
	// metering installation.
	ReasonLockDamagedUnableToOpen = Reason(10)
	// ReasonInWrongRoute where the reason is in wrong route. Unable to obtain reading
	// due to the metering installation being in the wrong route.
	ReasonInWrongRoute = Reason(11)
	// ReasonLockedPremises where the reason is locked premises. Unable to obtain
	// access to metering installation due to Site being locked.
	ReasonLockedPremises = Reason(12)
	// ReasonLockedGate where the reason is locked gate. Locked gate at Site is
	// preventing access to metering installation.
	ReasonLockedGate = Reason(13)
	// ReasonLockedMeterBox where the reason is locked meter box. Locked meter box
	// is preventing access to metering installation.
	ReasonLockedMeterBox = Reason(14)
	// ReasonOvergrownVegetation where the reason is overgrown vegetation. Overgrown
	// vegetation at Site is preventing access to metering installation.
	ReasonOvergrownVegetation = Reason(15)
	// ReasonNoxiousWeeds where the reason is noxious weeds. Noxious weeds at Site
	// are preventing access to metering installation.
	ReasonNoxiousWeeds = Reason(16)
	// ReasonUnsafeEquipmentLocation where the reason is unsafe equipment/location.
	// The equipment or the location of the metering installation has been identified
	// as unsafe (other than meter being high).
	ReasonUnsafeEquipmentLocation = Reason(17)
	// ReasonReadLessThanPrevious where the reason is read less than previous.
	// Current Meter Reading obtained is less than previous Meter Reading, no evidence
	// of tampering and no reverse energy observed.
	ReasonReadLessThanPrevious = Reason(18)
	// ReasonConsumerWanted where the reason is consumer wantedvconsumer
	// wanted.
	ReasonConsumerWanted = Reason(19)
	// ReasonDamagedEquipmentPanel where the reason is damaged equipment/panel.
	// The equipment or the panel of the metering installation has been damaged
	// but has not been identified as unsafe.
	ReasonDamagedEquipmentPanel = Reason(20)
	// ReasonMainSwitchOff where the reason is main switch off. Blank screen on an
	// electronic meter where the meter reader can determine that the main switch
	// has been turned off or Interval Metered Site where the MDP is providing
	// substituted metering data for a Site that the main switch is off but
	// Datastreams are left active.
	ReasonMainSwitchOff = Reason(21)
	// ReasonMeterEquipmentSealsMissing where the reason is meter/equipment seals
	// missing. One or more seals are missing from the metering installation, no
	// tampering has been identified.
	ReasonMeterEquipmentSealsMissing = Reason(22)
	// ReasonReaderError where the reason is reader error. MDP identified that
	// Meter Reading provided by the meter reader was incorrect.
	ReasonReaderError = Reason(23)
	// ReasonSubstitutedReplacedDataDataCorrection where the reason is
	// substituted/replaced data (data correction). Interval Meter Reading – MDP
	// replaced erroneous data for specific Intervals.
	ReasonSubstitutedReplacedDataDataCorrection = Reason(24)
	// ReasonUnableToLocatePremises where the reason is unable to locate premises.
	// Unable to locate Site.
	ReasonUnableToLocatePremises = Reason(25)
	// ReasonNegativeConsumptionGeneration where the reason is negative
	// consumption (generation). Accumulation Meter where the previous Meter
	// Reading is higher than the current Meter Reading, generally Site will have
	// generation.
	ReasonNegativeConsumptionGeneration = Reason(26)
	// ReasonRolr where the reason is rolr. To be used when transferring End User
	// as a result of a RoLR Event.
	ReasonRolr = Reason(27)
	// ReasonCtVtFault where the reason is ct/vt fault. MDP has corrected data due
	// to a known instrument transformer (CT/VT) fault.
	ReasonCtVtFault = Reason(28)
	// ReasonRelayFaultyDamaged where the reason is relay faulty/damaged. Meter
	// reader has identified the relay device within the metering installation is
	// faulty.
	ReasonRelayFaultyDamaged = Reason(29)
	// ReasonMeterStopSwitchOn where the reason is meter stop switch on.
	// (DEPRECATED).
	ReasonMeterStopSwitchOn = Reason(30)
	// ReasonNotAllMetersRead where the reason is not all meters read. Readings
	// for all meters linked to the Site have not been received by the MDP
	// (typically as a result of a non-Scheduled Meter Reading).
	ReasonNotAllMetersRead = Reason(31)
	// ReasonReEnergisedWithoutReadings where the reason is re-energised without
	// readings. Unable to obtain Meter Readings due to exceptional circumstances
	// when the Site is re-energised outside of standard practice.
	ReasonReEnergisedWithoutReadings = Reason(32)
	// ReasonDeEnergisedWithoutReadings where the reason is de-energised without
	// readings. Unable to obtain Meter Readings at the time of de-energisation
	// including disconnection for non-payment.
	ReasonDeEnergisedWithoutReadings = Reason(33)
	// ReasonMeterNotInHandheld where the reason is meter not in handheld.
	// Unexpected meter found on Site (new meter or additional meter).
	ReasonMeterNotInHandheld = Reason(34)
	// ReasonTimeswitchFaultyResetRequired where the reason is timeswitch
	// faulty/reset required. Meter reader has identified the time switching
	// device within the metering installation is faulty and required resetting.
	ReasonTimeswitchFaultyResetRequired = Reason(35)
	// ReasonMeterHighLadderRequired where the reason is meter high/ladder
	// required. Meter in a high position requiring a ladder to obtain Meter
	// Reading.
	ReasonMeterHighLadderRequired = Reason(36)
	// ReasonMeterUnderChurn where the reason is meter under churn. MDP has
	// Substituted data based on metering data not being received from relevant
	// MDP.
	ReasonMeterUnderChurn = Reason(37)
	// ReasonUnmarriedLock where the reason is unmarried lock. Site has two or
	// more locks, one of which is a power industry lock and they have not been
	// interlocked together correctly to allow access to the Site.
	ReasonUnmarriedLock = Reason(38)
	// ReasonReverseEnergyObserved where the reason is reverse energy observed.
	// Reverse energy observed where Site isn’t expected to have reverse energy.
	ReasonReverseEnergyObserved = Reason(39)
	// ReasonUnrestrainedLivestock where the reason is unrestrained livestock.
	// Meter reader observed that livestock is roaming free on Site and could
	// potentially be hazardous, or access wasn’t obtained due to potential for
	// livestock to escape.
	ReasonUnrestrainedLivestock = Reason(40)
	// ReasonFaultyMeterDisplayDials where the reason is faulty meter
	// display/dials. Display or dials on the meter are faulty and Site is not
	// de-energised nor is the display blank on an electronic meter.
	ReasonFaultyMeterDisplayDials = Reason(41)
	// ReasonChannelAddedRemoved where the reason is channel added/removed. MDP
	// obtained metering data for a channel that has been added or substituted
	// metering data where a channel has been removed but the Datastream is still
	// active in MSATS.
	ReasonChannelAddedRemoved = Reason(42)
	// ReasonPowerOutage where the reason is power outage. Interval Meter –
	// Metering data for Intervals have been Substituted due to power not being
	// available at the metering installation.
	ReasonPowerOutage = Reason(43)
	// ReasonMeterTesting where the reason is meter testing. MDP identifies meter
	// has been under testing regime and has provided substituted metering data to
	// reflect energy consumption during testing period.
	ReasonMeterTesting = Reason(44)
	// ReasonReadingsFailedToValidate where the reason is readings failed to
	// validate. Meter Readings have been loaded into MDP’s system, but have
	// failed Validation and have been Substituted.
	ReasonReadingsFailedToValidate = Reason(45)
	// ReasonExtremeWeatherHot where the reason is extreme weather/hot.
	ReasonExtremeWeatherHot = Reason(46)
	// ReasonRefusedAccess where the reason is refused access. The End User
	// refused to provide access when requested.
	ReasonRefusedAccess = Reason(47)
	// ReasonDogOnPremises where the reason is dog on premises. Meter reader has
	// identified that there is a dog on the Site but has been unable to determine
	// if the dog is dangerous.
	ReasonDogOnPremises = Reason(48)
	// ReasonWetPaint where the reason is wet paint (DEPRECATED).
	ReasonWetPaint = Reason(49)
	// ReasonWrongTarif where the reason is wrong tarif (DEPRECATED).
	ReasonWrongTarif = Reason(50)
	// ReasonInstallationDemolished where the reason is installation demolished.
	// Metering installation no longer exists at the Site.
	ReasonInstallationDemolished = Reason(51)
	// ReasonAccessBlocked where the reason is access – blocked. Used when there
	// are items blocking safe access to the meter or Site.
	ReasonAccessBlocked = Reason(52)
	// ReasonPestsInMeterBox where the reason is pests in meter box. Pests have
	// been identified within the meter box that poses a risk to metering data
	// accuracy, safety of the metering installation or a hazard to the meter
	// reader.
	ReasonPestsInMeterBox = Reason(53)
	// ReasonMeterBoxDamagedFaulty where the reason is meter box damaged/faulty.
	// Meter reader identifies that the meter box is damaged or faulty and the
	// mechanical protection or weather proofing of the metering installation is
	// compromised as a result.
	ReasonMeterBoxDamagedFaulty = Reason(54)
	// ReasonDialsObscured where the reason is dials obscured. Meter reader unable
	// to obtain Meter Reading due to meter dials being obscured, meter face
	// painted over, viewing panel in locked meter box with pvc panel misted
	// over/faded/mouldy etc. No evidence of tampering.
	ReasonDialsObscured = Reason(55)
	// ReasonMeterOkSupplyFailure where the reason is meter ok – supply failure.
	// (DEPRECATED).
	ReasonMeterOkSupplyFailure = Reason(58)
	// ReasonIllegalConnection where the reason is illegal connection. Meter
	// reader has identified that the Site has been illegally connected.
	ReasonIllegalConnection = Reason(60)
	// ReasonEquipmentTampered where the reason is equipment tampered. Meter
	// reader identified that the metering installation has been tampered with and
	// the recording of energy consumption may have been affected as a result.
	ReasonEquipmentTampered = Reason(61)
	// ReasonNsrdWindowExpired where the reason is nsrd window expired. Where the
	// NSRD window has expired and the meter reader has been unable to deliver
	// Actual Meter Readings.
	ReasonNsrdWindowExpired = Reason(62)
	// ReasonKeyRequired where the reason is key required. Meter reader typically
	// has access to the key but was unable to obtain/locate the key at the time
	// of Meter Reading.
	ReasonKeyRequired = Reason(64)
	// ReasonWrongKeyProvided where the reason is wrong key provided. Meter reader
	// has been provided with a key but the key no longer opens the lock.
	ReasonWrongKeyProvided = Reason(65)
	// ReasonZeroConsumption where the reason is zero consumption. Where a Site
	// has known zero consumption and the Site is not deenergised in MSATS but no
	// energy is flowing to the meter.
	ReasonZeroConsumption = Reason(68)
	// ReasonReadingExceedsSubstitute where the reason is reading exceeds
	// substitute. Re-Substituted data that has been modified to improve the
	// smoothing of energy to align with the next Actual Meter Reading.
	ReasonReadingExceedsSubstitute = Reason(69)
	// ReasonProbeReportsTampering where the reason is probe reports tampering.
	// (DEPRECATED).
	ReasonProbeReportsTampering = Reason(70)
	// ReasonProbeReadError where the reason is probe read error. Data collector
	// unable to collect the metering data due to the meter probe being unable to
	// extract the metering data.
	ReasonProbeReadError = Reason(71)
	// ReasonReCalculatedBasedOnActualMeteringData where the reason is
	// re-calculated based on actual metering data. MDP received Actual Meter
	// Readings and prior Substitutes have been amended.
	ReasonReCalculatedBasedOnActualMeteringData = Reason(72)
	// ReasonLowConsumption where the reason is low consumption. Meter Reading
	// failed Validation as being too low based on Historical Data and has been
	// either left as an actual or replaced by a Substitute.
	ReasonLowConsumption = Reason(73)
	// ReasonHighConsumption where the reason is high consumption. Meter Reading
	// failed Validation as being too high based on Historical Data and has been
	// either left as an actual or replaced by a Substitute.
	ReasonHighConsumption = Reason(74)
	// ReasonCustomerRead where the reason is customer read. Meter Reading
	// provided to the MDP by the End User. (Only applicable in Jurisdictions
	// where End User Meter Readings are allowed).
	ReasonCustomerRead = Reason(75)
	// ReasonCommunicationsFault where the reason is communications fault. Meter
	// reader attempted to read the meter but was unable due to not being able to
	// remotely communicate with the meter.
	ReasonCommunicationsFault = Reason(76)
	// ReasonEstimationForecast where the reason is estimation forecast. Optional
	// reason code that can be applied to Estimations.
	ReasonEstimationForecast = Reason(77)
	// ReasonNullData where the reason is null data. For Interval Meters where no
	// metering data was received and Substitutes created to cover this period.
	ReasonNullData = Reason(78)
	// ReasonPowerOutageAlarm where the reason is power outage alarm. For Interval
	// Meters where a power outage has been detected by the meter.
	ReasonPowerOutageAlarm = Reason(79)
	// ReasonShortIntervalAlarm where the reason is short interval alarm. For
	// Interval Meters where the time in the meter is slow and has now been
	// corrected, resulting in the interval metering data not being a full 15 or
	// 30 minutes in length.
	ReasonShortIntervalAlarm = Reason(80)
	// ReasonLongIntervalAlarm where the reason is long interval alarm. For
	// Interval Meters where the time in the meter is fast and has now been
	// corrected, resulting in the interval metering data exceeding a full 15 or
	// 30 minutes in length.
	ReasonLongIntervalAlarm = Reason(81)
	// ReasonCrcError where the reason is crc error (DEPRECATED).
	ReasonCrcError = Reason(82)
	// ReasonRAMChecksumError where the reason is ram checksum error (DEPRECATED).
	ReasonRAMChecksumError = Reason(83)
	// ReasonROMChecksumError where the reason is rom checksum error (DEPRECATED).
	ReasonROMChecksumError = Reason(84)
	// ReasonDataMissingAlarm where the reason is data missing alarm (DEPRECATED).
	ReasonDataMissingAlarm = Reason(85)
	// ReasonClockErrorAlarm where the reason is clock error alarm (DEPRECATED).
	ReasonClockErrorAlarm = Reason(86)
	// ReasonResetOccurred where the reason is reset occurred. Resetting of the
	// meter due to re-programming, change of configuration or firmware upgrade
	// etc.
	ReasonResetOccurred = Reason(87)
	// ReasonWatchdogTimeoutAlarm where the reason is watchdog timeout alarm.
	// (DEPRECATED).
	ReasonWatchdogTimeoutAlarm = Reason(88)
	// ReasonTimeResetOccurred where the reason is time reset occurred. Where a
	// time reset has occurred within the metering installation.
	ReasonTimeResetOccurred = Reason(89)
	// ReasonTestMode where the reason is test mode (DEPRECATED).
	ReasonTestMode = Reason(90)
	// ReasonLoadControl where the reason is load control (DEPRECATED).
	ReasonLoadControl = Reason(91)
	// ReasonAddedIntervalDataCorrection where the reason is added interval (data
	// correction) (DEPRECATED).
	ReasonAddedIntervalDataCorrection = Reason(92)
	// ReasonReplacedIntervalDataCorrection where the reason is replaced interval
	// (data correction) (DEPRECATED).
	ReasonReplacedIntervalDataCorrection = Reason(93)
	// ReasonEstimatedIntervalDataCorrection where the reason is estimated
	// interval (data correction) (DEPRECATED).
	ReasonEstimatedIntervalDataCorrection = Reason(94)
	// ReasonPulseOverflowAlarm where the reason is pulse overflow alarm.
	// (DEPRECATED).
	ReasonPulseOverflowAlarm = Reason(95)
	// ReasonDataOutOfLimits where the reason is data out of limits (DEPRECATED).
	ReasonDataOutOfLimits = Reason(96)
	// ReasonExcludedData where the reason is excluded data (DEPRECATED).
	ReasonExcludedData = Reason(97)
	// ReasonParityError where the reason is parity error (DEPRECATED).
	ReasonParityError = Reason(98)
	// ReasonEnergyTypeRegisterChanged where the reason is energy type (register
	// changed) (DEPRECATED).
	ReasonEnergyTypeRegisterChanged = Reason(99)
)
View Source
const (
	// IntervalLengthPT5M is the duration of an interval for 5 minutes.
	IntervalLengthPT5M = time.Duration(5 * secondsInMinute * nanosInSecond)
	// IntervalLengthPT15M is the duration of an interval for 15 minutes.
	IntervalLengthPT15M = time.Duration(15 * secondsInMinute * nanosInSecond)
	// IntervalLengthPT30M is the duration of an interval for 30 minutes.
	IntervalLengthPT30M = time.Duration(30 * secondsInMinute * nanosInSecond)
	// IntervalLengthPT24H is the duration of an interval for 24 hours.
	IntervalLengthPT24H = time.Duration(hoursInDay * minutesInHour * secondsInMinute * nanosInSecond)
)
View Source
const (

	// Date8Format is the golang time format to use with time.Parse fields of
	// NEM12 format Date(8).
	Date8Format = "20060102"

	// DateTime12Format is the golang time format to use with time.Parse fields of
	// NEM12 format DateTime(12).
	DateTime12Format = "200601021504"

	// DateTime14Format is the golang time format to use with time.Parse fields of
	// NEM12 format DateTime(14).
	DateTime14Format = "20060102150405"
)

Variables

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")

	// ErrFieldNil if field is empty.
	ErrFieldNil = fmt.Errorf("field %w", ErrIsNil)
	// ErrFieldInvalid if field is invalid.
	ErrFieldInvalid = fmt.Errorf("field %w", ErrIsInvalid)
	// ErrFieldParticipantLengthInvalid if field participant length is invalid.
	ErrFieldParticipantLengthInvalid = fmt.Errorf("field participan %w", ErrLengthInvalid)
	// ErrFieldIndexReadLengthInvalid if field index read length is invalid.
	ErrFieldIndexReadLengthInvalid = fmt.Errorf("field index read %w", ErrLengthInvalid)
	// ErrFieldIntervalExceedsMaximum if field interval exceeds maximum value.
	ErrFieldIntervalExceedsMaximum = errors.New("field interval exceeds maximum value")
	// ErrFieldIntervalLengthInvalid if field interval length is invalid.
	ErrFieldIntervalLengthInvalid = fmt.Errorf("field interval %w", ErrLengthInvalid)
	// ErrFieldIntervalNegativeInvalid if field interval negative is invalid.
	ErrFieldIntervalNegativeInvalid = fmt.Errorf("field interval negative %w", ErrIsInvalid)
	// ErrFieldIntervalValueNegative if field interval value negative.
	ErrFieldIntervalValueNegative = fmt.Errorf("field interval value negative %w", ErrIsInvalid)
	// ErrFieldMDMDataStreamIdentifierInvalid if field MDM data stream identifier invalid.
	ErrFieldMDMDataStreamIdentifierInvalid = fmt.Errorf("field MDM data stream identifier %w", ErrIsInvalid)
	// ErrFieldMeterSerialNumberInvalid if field meter serial number invalid.
	ErrFieldMeterSerialNumberInvalid = fmt.Errorf("field meter serial number %w", ErrIsInvalid)
	// ErrFieldNMIConfigurationNMISuffixDuplicate if nmi configuration has a nmi suffix that is duplicated.
	ErrFieldNMIConfigurationNMISuffixDuplicate = fmt.Errorf("nmi configuration has a nmi suffix that %w", ErrIsDuplicated)
	// ErrFieldNMIConfigurationMissingNMISuffix if nmi configuration nmi suffix is missing.
	ErrFieldNMIConfigurationMissingNMISuffix = fmt.Errorf("nmi configuration nmi suffix %w", ErrIsMissing)
	// ErrFieldReasonDescriptionLengthInvalid if field reason description length is invalid.
	ErrFieldReasonDescriptionLengthInvalid = fmt.Errorf("field reason description %w", ErrLengthInvalid)
	// ErrFieldRegisterIDInvalid if field register id invalid.
	ErrFieldRegisterIDInvalid = fmt.Errorf("field register id %w", ErrIsInvalid)
	// ErrFieldRetServiceOrderLengthInvalid if field ret service order length is invalid.
	ErrFieldRetServiceOrderLengthInvalid = fmt.Errorf("field ret service order %w", ErrLengthInvalid)
	// ErrFieldVersionHeaderInvalid if field version header invalid.
	ErrFieldVersionHeaderInvalid = fmt.Errorf("field version header %w", ErrIsInvalid)
	// ErrFieldTypeInvalid if field type is invalid.
	ErrFieldTypeInvalid = fmt.Errorf("field type %w", ErrIsInvalid)
	// ErrInstallNil if install is empty.
	ErrInstallNil = fmt.Errorf("install %w", ErrIsNil)
	// ErrInstallInvalid if install is invalid.
	ErrInstallInvalid = fmt.Errorf("install %w", ErrIsInvalid)
	// ErrIntervalMetadataNil if interval metadata is nil.
	ErrIntervalMetadataNil = fmt.Errorf("interval metadata %w", ErrIsNil)
	// ErrIntervalNil if interval is nil.
	ErrIntervalNil = fmt.Errorf("interval %w", ErrIsNil)
	// ErrLengthInvalid if length is invalid.
	ErrLengthInvalid = fmt.Errorf("length %w", ErrIsInvalid)
	// ErrMethodNil if method flag is empty.
	ErrMethodNil = fmt.Errorf("method flag %w", ErrIsNil)
	// ErrMethodInvalid if method flag is invalid.
	ErrMethodInvalid = fmt.Errorf("method flag %w", ErrIsInvalid)
	// ErrMethodTypeNil if method type is empty.
	ErrMethodTypeNil = fmt.Errorf("method type %w", ErrIsNil)
	// ErrMethodTypeInvalid if method type is invalid.
	ErrMethodTypeInvalid = fmt.Errorf("method type %w", ErrIsInvalid)
	// ErrParseFieldCountInvalid if wrong number of fields.
	ErrParseFieldCountInvalid = fmt.Errorf("parse fields count %w", ErrIsInvalid)
	// ErrParseIntervalDataLengthInvalid if parse error: interval data length invalid.
	ErrParseIntervalDataLengthInvalid = fmt.Errorf("interval data length invalid: %w", ErrParseFailed)
	// ErrParseIntervalLengthInvalid if parse error: interval length invalid.
	ErrParseIntervalLengthInvalid = fmt.Errorf("interval length invalid: %w", ErrParseFailed)
	// ErrParseInvalidState if parse error: invalid state.
	ErrParseInvalidState = fmt.Errorf("invalid state: %w", ErrParseFailed)
	// ErrParseRecordHeaderMissing if parse error: record header missing.
	ErrParseRecordHeaderMissing = fmt.Errorf("record header missing: %w", ErrParseFailed)
	// ErrParseRecordNMIDataDetailsMissing if parse error: record NMI data details missing.
	ErrParseRecordNMIDataDetailsMissing = fmt.Errorf("record NMI data details missing: %w", ErrParseFailed)
	// ErrParseRecordIntervalDataMissing if parse error: record interval data missing.
	ErrParseRecordIntervalDataMissing = fmt.Errorf("record interval data missing: %w", ErrParseFailed)
	// ErrParseRecordIntervalEventMissing if parse error: record interval event missing.
	ErrParseRecordIntervalEventMissing = fmt.Errorf("record interval event missing: %w", ErrParseFailed)
	// ErrParseRecordEndMissing if parse error: record end missing.
	ErrParseRecordEndMissing = fmt.Errorf("record end missing: %w", ErrParseFailed)
	// ErrParseUnexpectedEOF if parse error: unexpected EOF.
	ErrParseUnexpectedEOF = fmt.Errorf("unexpected EOF: %w", ErrParseFailed)
	// ErrQualityNil if quality flag is empty.
	ErrQualityNil = fmt.Errorf("quality flag %w", ErrIsNil)
	// ErrQualityInvalid if quality flag is invalid.
	ErrQualityInvalid = fmt.Errorf("quality flag %w", ErrIsInvalid)
	// ErrQualityMethodNil if quality method is empty.
	ErrQualityMethodNil = fmt.Errorf("quality method %w", ErrIsNil)
	// ErrQualityMethodInvalid if quality method is invalid.
	ErrQualityMethodInvalid = fmt.Errorf("quality method %w", ErrIsInvalid)
	// ErrQualityMethodLengthInvalid if quality method length is invalid.
	ErrQualityMethodLengthInvalid = fmt.Errorf("quality method %w", ErrLengthInvalid)
	// ErrQualityMissingMethod if quality method missing required method.
	ErrQualityMissingMethod = fmt.Errorf("quality method required method %w", ErrIsMissing)
	// ErrReaderNil if reader is nil.
	ErrReaderNil = fmt.Errorf("reader %w", ErrIsNil)
	// ErrRecordFieldLengthInvalid if record field length is invalid.
	ErrRecordFieldLengthInvalid = fmt.Errorf("record field %w", ErrLengthInvalid)
	// ErrRecordNil if record is empty.
	ErrRecordNil = fmt.Errorf("record %w", ErrIsNil)
	// ErrReasonCodeNil if reason code is empty.
	ErrReasonCodeNil = fmt.Errorf("reason code %w", ErrIsNil)
	// ErrReasonCodeInvalid if reason code is invalid.
	ErrReasonCodeInvalid = fmt.Errorf("reason code %w", ErrIsInvalid)
	// ErrRecordIndicatorNil if record indicator is empty.
	ErrRecordIndicatorNil = fmt.Errorf("record indicator %w", ErrIsNil)
	// ErrRecordIndicatorInvalid if record indicator is invalid.
	ErrRecordIndicatorInvalid = fmt.Errorf("record indicator %w", ErrIsInvalid)
	// ErrRecordIntervalDataWithoutIntervalCountInvalid if record interval data without interval count is invalid.
	ErrRecordIntervalDataWithoutIntervalCountInvalid = fmt.Errorf("record interval data without interval count %w", ErrIsInvalid)
	// ErrSuffixNil if suffix is empty.
	ErrSuffixNil = fmt.Errorf("suffix %w", ErrIsNil)
	// ErrSuffixLengthInvalid if suffix is invalid.
	ErrSuffixLengthInvalid = fmt.Errorf("suffix %w", ErrIsInvalid)
	// ErrSuffixMeterInvalid if suffix meter is invalid.
	ErrSuffixMeterInvalid = fmt.Errorf("suffix meter %w", ErrIsInvalid)
	// ErrSuffixTypeNil if suffix type is empty.
	ErrSuffixTypeNil = fmt.Errorf("suffix type %w", ErrIsNil)
	// ErrSuffixTypeInvalid if suffix type is invalid.
	ErrSuffixTypeInvalid = fmt.Errorf("suffix type %w", ErrIsInvalid)
	// ErrTransactionCodeNil if transaction code is empty.
	ErrTransactionCodeNil = fmt.Errorf("transaction code %w", ErrIsNil)
	// ErrTransactionCodeInvalid if transaction code is invalid.
	ErrTransactionCodeInvalid = fmt.Errorf("transaction code %w", ErrIsInvalid)
	// ErrUnitOfMeasureNil if unit of measure is empty.
	ErrUnitOfMeasureNil = fmt.Errorf("unit of measure %w", ErrIsNil)
	// ErrUnitOfMeasureInvalid if unit of measure is invalid.
	ErrUnitOfMeasureInvalid = fmt.Errorf("unit of measure %w", ErrIsInvalid)
)
View Source
var (

	// InstallName maps an install to its name.
	InstallName = map[Install]string{
		InstallComms1:    "COMMS1",
		InstallComms2:    "COMMS2",
		InstallComms3:    "COMMS3",
		InstallComms4:    "COMMS4",
		InstallMRIM:      "MRIM",
		InstallBasic:     "BASIC",
		InstallUnmetered: "UMCP",
	}

	// InstallValue maps an install from its name.
	InstallValue = map[string]Install{
		"COMMS1": InstallComms1,
		"COMMS2": InstallComms2,
		"COMMS3": InstallComms3,
		"COMMS4": InstallComms4,
		"MRIM":   InstallMRIM,
		"BASIC":  InstallBasic,
		"UMCP":   InstallUnmetered,
	}
)
View Source
var (

	// MethodName maps a method to its string equivalent.
	MethodName = map[Method]string{
		Method11Check:                      "11",
		Method12Calculated:                 "12",
		Method13SCADA:                      "13",
		Method14LikeDay:                    "14",
		Method15AverageLikeDay:             "15",
		Method16Agreed:                     "16",
		Method17Linear:                     "17",
		Method18Alternate:                  "18",
		Method19Zero:                       "19",
		Method20ChurnCorrection:            "20",
		Method21FiveMinuteNoHistoricalData: "21",
		Method51PreviousYear:               "51",
		Method52PreviousRead:               "52",
		Method53Revision:                   "53",
		Method54Linear:                     "54",
		Method55Agreed:                     "55",
		Method56PriortoFirstReadAgreed:     "56",
		Method57CustomerClass:              "57",
		Method58Zero:                       "58",
		Method59FiveMinuteNoHistoricalData: "59",
		Method61PreviousYear:               "61",
		Method62PreviousRead:               "62",
		Method63CustomerClass:              "63",
		Method64Agreed:                     "64",
		Method65ADL:                        "65",
		Method66Revision:                   "66",
		Method67CustomerRead:               "67",
		Method68Zero:                       "68",
		MetMethod69LinearExtrapolation:     "69",
		Method71Recalculation:              "71",
		Method72RevisedTable:               "72",
		Method73RevisedAlgorithm:           "73",
		Method74Agreed:                     "74",
		Method75ExistingTable:              "75",
	}

	// MethodValue maps a method from its string equivalent.
	MethodValue = map[string]Method{
		"11": Method11Check,
		"12": Method12Calculated,
		"13": Method13SCADA,
		"14": Method14LikeDay,
		"15": Method15AverageLikeDay,
		"16": Method16Agreed,
		"17": Method17Linear,
		"18": Method18Alternate,
		"19": Method19Zero,
		"20": Method20ChurnCorrection,
		"21": Method21FiveMinuteNoHistoricalData,
		"51": Method51PreviousYear,
		"52": Method52PreviousRead,
		"53": Method53Revision,
		"54": Method54Linear,
		"55": Method55Agreed,
		"56": Method56PriortoFirstReadAgreed,
		"57": Method57CustomerClass,
		"58": Method58Zero,
		"59": Method59FiveMinuteNoHistoricalData,
		"61": Method61PreviousYear,
		"62": Method62PreviousRead,
		"63": Method63CustomerClass,
		"64": Method64Agreed,
		"65": Method65ADL,
		"66": Method66Revision,
		"67": Method67CustomerRead,
		"68": Method68Zero,
		"69": MetMethod69LinearExtrapolation,
		"71": Method71Recalculation,
		"72": Method72RevisedTable,
		"73": Method73RevisedAlgorithm,
		"74": Method74Agreed,
		"75": Method75ExistingTable,
	}
)
View Source
var (

	// MethodTypeName maps method types to their string version.
	MethodTypeName = map[MethodType]string{
		MethodTypeEstimated:   "EST",
		MethodTypeSubstituted: "SUB",
	}

	// MethodTypeValue maps method types from their string version.
	MethodTypeValue = map[string]MethodType{
		"EST": MethodTypeEstimated,
		"SUB": MethodTypeSubstituted,
	}
)
View Source
var (

	// QualityName maps a Quality to its name.
	QualityName = map[Quality]string{
		QualityActual:      "A",
		QualityEstimated:   "E",
		QualityFinal:       "F",
		QualityNull:        "N",
		QualitySubstituted: "S",
		QualityVariable:    "V",
	}

	// QualityValue maps a name to its value.
	QualityValue = map[string]Quality{
		"A": QualityActual,
		"E": QualityEstimated,
		"F": QualityFinal,
		"N": QualityNull,
		"S": QualitySubstituted,
		"V": QualityVariable,
	}
)
View Source
var (

	// ReasonName a mapping of the reason to the string of the reason.
	ReasonName = map[Reason]string{
		ReasonFreeTextDescription:                   "0",
		ReasonMeterEquipmentChanged:                 "1",
		ReasonExtremeWeatherConditions:              "2",
		ReasonQuarantinedPremises:                   "3",
		ReasonDangerousDog:                          "4",
		ReasonBlankScreen:                           "5",
		ReasonDeEnergisedPremises:                   "6",
		ReasonUnableToLocateMeter:                   "7",
		ReasonVacantPremises:                        "8",
		ReasonUnderInvestigation:                    "9",
		ReasonLockDamagedUnableToOpen:               "10",
		ReasonInWrongRoute:                          "11",
		ReasonLockedPremises:                        "12",
		ReasonLockedGate:                            "13",
		ReasonLockedMeterBox:                        "14",
		ReasonOvergrownVegetation:                   "15",
		ReasonNoxiousWeeds:                          "16",
		ReasonUnsafeEquipmentLocation:               "17",
		ReasonReadLessThanPrevious:                  "18",
		ReasonConsumerWanted:                        "19",
		ReasonDamagedEquipmentPanel:                 "20",
		ReasonMainSwitchOff:                         "21",
		ReasonMeterEquipmentSealsMissing:            "22",
		ReasonReaderError:                           "23",
		ReasonSubstitutedReplacedDataDataCorrection: "24",
		ReasonUnableToLocatePremises:                "25",
		ReasonNegativeConsumptionGeneration:         "26",
		ReasonRolr:                                  "27",
		ReasonCtVtFault:                             "28",
		ReasonRelayFaultyDamaged:                    "29",
		ReasonMeterStopSwitchOn:                     "30",
		ReasonNotAllMetersRead:                      "31",
		ReasonReEnergisedWithoutReadings:            "32",
		ReasonDeEnergisedWithoutReadings:            "33",
		ReasonMeterNotInHandheld:                    "34",
		ReasonTimeswitchFaultyResetRequired:         "35",
		ReasonMeterHighLadderRequired:               "36",
		ReasonMeterUnderChurn:                       "37",
		ReasonUnmarriedLock:                         "38",
		ReasonReverseEnergyObserved:                 "39",
		ReasonUnrestrainedLivestock:                 "40",
		ReasonFaultyMeterDisplayDials:               "41",
		ReasonChannelAddedRemoved:                   "42",
		ReasonPowerOutage:                           "43",
		ReasonMeterTesting:                          "44",
		ReasonReadingsFailedToValidate:              "45",
		ReasonExtremeWeatherHot:                     "46",
		ReasonRefusedAccess:                         "47",
		ReasonDogOnPremises:                         "48",
		ReasonWetPaint:                              "49",
		ReasonWrongTarif:                            "50",
		ReasonInstallationDemolished:                "51",
		ReasonAccessBlocked:                         "52",
		ReasonPestsInMeterBox:                       "53",
		ReasonMeterBoxDamagedFaulty:                 "54",
		ReasonDialsObscured:                         "55",
		ReasonMeterOkSupplyFailure:                  "58",
		ReasonIllegalConnection:                     "60",
		ReasonEquipmentTampered:                     "61",
		ReasonNsrdWindowExpired:                     "62",
		ReasonKeyRequired:                           "64",
		ReasonWrongKeyProvided:                      "65",
		ReasonZeroConsumption:                       "68",
		ReasonReadingExceedsSubstitute:              "69",
		ReasonProbeReportsTampering:                 "70",
		ReasonProbeReadError:                        "71",
		ReasonReCalculatedBasedOnActualMeteringData: "72",
		ReasonLowConsumption:                        "73",
		ReasonHighConsumption:                       "74",
		ReasonCustomerRead:                          "75",
		ReasonCommunicationsFault:                   "76",
		ReasonEstimationForecast:                    "77",
		ReasonNullData:                              "78",
		ReasonPowerOutageAlarm:                      "79",
		ReasonShortIntervalAlarm:                    "80",
		ReasonLongIntervalAlarm:                     "81",
		ReasonCrcError:                              "82",
		ReasonRAMChecksumError:                      "83",
		ReasonROMChecksumError:                      "84",
		ReasonDataMissingAlarm:                      "85",
		ReasonClockErrorAlarm:                       "86",
		ReasonResetOccurred:                         "87",
		ReasonWatchdogTimeoutAlarm:                  "88",
		ReasonTimeResetOccurred:                     "89",
		ReasonTestMode:                              "90",
		ReasonLoadControl:                           "91",
		ReasonAddedIntervalDataCorrection:           "92",
		ReasonReplacedIntervalDataCorrection:        "93",
		ReasonEstimatedIntervalDataCorrection:       "94",
		ReasonPulseOverflowAlarm:                    "95",
		ReasonDataOutOfLimits:                       "96",
		ReasonExcludedData:                          "97",
		ReasonParityError:                           "98",
		ReasonEnergyTypeRegisterChanged:             "99",
	}

	// ReasonValue a mapping of the string of the reason code to the reason.
	ReasonValue = map[string]Reason{
		"0":  ReasonFreeTextDescription,
		"1":  ReasonMeterEquipmentChanged,
		"2":  ReasonExtremeWeatherConditions,
		"3":  ReasonQuarantinedPremises,
		"4":  ReasonDangerousDog,
		"5":  ReasonBlankScreen,
		"6":  ReasonDeEnergisedPremises,
		"7":  ReasonUnableToLocateMeter,
		"8":  ReasonVacantPremises,
		"9":  ReasonUnderInvestigation,
		"10": ReasonLockDamagedUnableToOpen,
		"11": ReasonInWrongRoute,
		"12": ReasonLockedPremises,
		"13": ReasonLockedGate,
		"14": ReasonLockedMeterBox,
		"15": ReasonOvergrownVegetation,
		"16": ReasonNoxiousWeeds,
		"17": ReasonUnsafeEquipmentLocation,
		"18": ReasonReadLessThanPrevious,
		"19": ReasonConsumerWanted,
		"20": ReasonDamagedEquipmentPanel,
		"21": ReasonMainSwitchOff,
		"22": ReasonMeterEquipmentSealsMissing,
		"23": ReasonReaderError,
		"24": ReasonSubstitutedReplacedDataDataCorrection,
		"25": ReasonUnableToLocatePremises,
		"26": ReasonNegativeConsumptionGeneration,
		"27": ReasonRolr,
		"28": ReasonCtVtFault,
		"29": ReasonRelayFaultyDamaged,
		"30": ReasonMeterStopSwitchOn,
		"31": ReasonNotAllMetersRead,
		"32": ReasonReEnergisedWithoutReadings,
		"33": ReasonDeEnergisedWithoutReadings,
		"34": ReasonMeterNotInHandheld,
		"35": ReasonTimeswitchFaultyResetRequired,
		"36": ReasonMeterHighLadderRequired,
		"37": ReasonMeterUnderChurn,
		"38": ReasonUnmarriedLock,
		"39": ReasonReverseEnergyObserved,
		"40": ReasonUnrestrainedLivestock,
		"41": ReasonFaultyMeterDisplayDials,
		"42": ReasonChannelAddedRemoved,
		"43": ReasonPowerOutage,
		"44": ReasonMeterTesting,
		"45": ReasonReadingsFailedToValidate,
		"46": ReasonExtremeWeatherHot,
		"47": ReasonRefusedAccess,
		"48": ReasonDogOnPremises,
		"49": ReasonWetPaint,
		"50": ReasonWrongTarif,
		"51": ReasonInstallationDemolished,
		"52": ReasonAccessBlocked,
		"53": ReasonPestsInMeterBox,
		"54": ReasonMeterBoxDamagedFaulty,
		"55": ReasonDialsObscured,
		"58": ReasonMeterOkSupplyFailure,
		"60": ReasonIllegalConnection,
		"61": ReasonEquipmentTampered,
		"62": ReasonNsrdWindowExpired,
		"64": ReasonKeyRequired,
		"65": ReasonWrongKeyProvided,
		"68": ReasonZeroConsumption,
		"69": ReasonReadingExceedsSubstitute,
		"70": ReasonProbeReportsTampering,
		"71": ReasonProbeReadError,
		"72": ReasonReCalculatedBasedOnActualMeteringData,
		"73": ReasonLowConsumption,
		"74": ReasonHighConsumption,
		"75": ReasonCustomerRead,
		"76": ReasonCommunicationsFault,
		"77": ReasonEstimationForecast,
		"78": ReasonNullData,
		"79": ReasonPowerOutageAlarm,
		"80": ReasonShortIntervalAlarm,
		"81": ReasonLongIntervalAlarm,
		"82": ReasonCrcError,
		"83": ReasonRAMChecksumError,
		"84": ReasonROMChecksumError,
		"85": ReasonDataMissingAlarm,
		"86": ReasonClockErrorAlarm,
		"87": ReasonResetOccurred,
		"88": ReasonWatchdogTimeoutAlarm,
		"89": ReasonTimeResetOccurred,
		"90": ReasonTestMode,
		"91": ReasonLoadControl,
		"92": ReasonAddedIntervalDataCorrection,
		"93": ReasonReplacedIntervalDataCorrection,
		"94": ReasonEstimatedIntervalDataCorrection,
		"95": ReasonPulseOverflowAlarm,
		"96": ReasonDataOutOfLimits,
		"97": ReasonExcludedData,
		"98": ReasonParityError,
		"99": ReasonEnergyTypeRegisterChanged,
	}
)
View Source
var (
	// IntervalLengths is a slice of all valid interval lengths.
	IntervalLengths = []time.Duration{
		IntervalLengthPT5M,
		IntervalLengthPT15M,
		IntervalLengthPT30M,
	}

	// RecordIndicatorName maps a record indicator to a name.
	RecordIndicatorName = map[RecordIndicator]string{
		RecordHeader:         "100",
		RecordNMIDataDetails: "200",
		RecordIntervalData:   "300",
		RecordIntervalEvent:  "400",
		RecordB2BDetails:     "500",
		RecordEnd:            "900",
	}

	// RecordIndicatorValue maps a record indicator from a name.
	RecordIndicatorValue = map[string]RecordIndicator{
		"100": RecordHeader,
		"200": RecordNMIDataDetails,
		"300": RecordIntervalData,
		"400": RecordIntervalEvent,
		"500": RecordB2BDetails,
		"900": RecordEnd,
	}
)
View Source
var (

	// SuffixValue maps the string value to the suffix.
	SuffixValue = map[string]SuffixType{
		"A": SuffixImportWattHourAverage,
		"B": SuffixImportWattHourMaster,
		"C": SuffixImportWattHourCheck,
		"D": SuffixExportWattHourAverage,
		"E": SuffixExportWattHourMaster,
		"F": SuffixExportWattHourCheck,
		"N": SuffixWattHourNet,
		"J": SuffixImportVoltAmpReactiveHourAverage,
		"K": SuffixImportVoltAmpReactiveHourMaster,
		"L": SuffixImportVoltAmpReactiveHourCheck,
		"P": SuffixExportVoltAmpReactiveHourAverage,
		"Q": SuffixExportVoltAmpReactiveHourMaster,
		"R": SuffixExportVoltAmpReactiveHourCheck,
		"X": SuffixVoltAmpReactiveHourNet,
		"S": SuffixVoltAmpHourAverage,
		"T": SuffixVoltAmpHourMaster,
		"U": SuffixVoltAmpHourCheck,
		"G": SuffixPowerFactorMaster,
		"H": SuffixQMeteringMaster,
		"Y": SuffixQMeteringCheck,
		"M": SuffixParMeteringMaster,
		"W": SuffixParMeteringCheck,
		"V": SuffixVoltsOrAmpsMaster,
		"Z": SuffixVoltsOrAmpsCheck,
	}

	// SuffixName maps the suffix to its string value.
	SuffixName = map[SuffixType]string{
		SuffixImportWattHourAverage:            "A",
		SuffixImportWattHourMaster:             "B",
		SuffixImportWattHourCheck:              "C",
		SuffixExportWattHourAverage:            "D",
		SuffixExportWattHourMaster:             "E",
		SuffixExportWattHourCheck:              "F",
		SuffixWattHourNet:                      "N",
		SuffixImportVoltAmpReactiveHourAverage: "J",
		SuffixImportVoltAmpReactiveHourMaster:  "K",
		SuffixImportVoltAmpReactiveHourCheck:   "L",
		SuffixExportVoltAmpReactiveHourAverage: "P",
		SuffixExportVoltAmpReactiveHourMaster:  "Q",
		SuffixExportVoltAmpReactiveHourCheck:   "R",
		SuffixVoltAmpReactiveHourNet:           "X",
		SuffixVoltAmpHourAverage:               "S",
		SuffixVoltAmpHourMaster:                "T",
		SuffixVoltAmpHourCheck:                 "U",
		SuffixPowerFactorMaster:                "G",
		SuffixQMeteringMaster:                  "H",
		SuffixQMeteringCheck:                   "Y",
		SuffixParMeteringMaster:                "M",
		SuffixParMeteringCheck:                 "W",
		SuffixVoltsOrAmpsMaster:                "V",
		SuffixVoltsOrAmpsCheck:                 "Z",
	}
)

Functions

func NEMTime

func NEMTime() *time.Location

NEMTime returns NEM time, the fixed timezone adopted by AEMO in the NEM, set to UTC+10:00.

func ValidateSuffixMeter

func ValidateSuffixMeter(s string) error

ValidateSuffixMeter checks the validity of a NMI suffix's meter character.

Types

type Field

type Field struct {
	Type  FieldType
	Value string
}

Field is the type of Field in a Record of the NEM12 file.

func NewField

func NewField(ft FieldType, v string) (f Field, err error)

NewField returns a new Field, or errors.

func (Field) GoString

func (f Field) GoString() string

GoString provides go string.

func (Field) Validate

func (f Field) Validate() error

Validate returns any errors for the value of the field.

type FieldType

type FieldType int

FieldType is the type of Field in a Record of the NEM12 file.

const (
	// FieldUndefined is for any undefined fields.
	FieldUndefined FieldType = iota
	// FieldRecordIndicator is the field at the start of each row.
	FieldRecordIndicator
	// FieldVersionHeader is the field ... .
	FieldVersionHeader
	// FieldDateTime is the field ... .
	FieldDateTime
	// FieldFromParticipant is the field ... .
	FieldFromParticipant
	// FieldToParticipant is the field ... .
	FieldToParticipant
	// FieldNMI is the field ... .
	FieldNMI
	// FieldNMIConfiguration is the field ... .
	FieldNMIConfiguration
	// FieldRegisterID is the field ... .
	FieldRegisterID
	// FieldNMISuffix is the field ... .
	FieldNMISuffix
	// FieldMDMDataStreamIdentifier is the field ... .
	FieldMDMDataStreamIdentifier
	// FieldMeterSerialNumber is the field ... .
	FieldMeterSerialNumber
	// FieldUnitOfMeasurement is the field ... .
	FieldUnitOfMeasurement
	// FieldIntervalLength is the field ... .
	FieldIntervalLength
	// FieldNextScheduledReadDate is the field ... .
	FieldNextScheduledReadDate
	// FieldIntervalDate is the field ... .
	FieldIntervalDate
	// FieldIntervalValue is the field ... .
	FieldIntervalValue
	// FieldQualityMethod is the field ... .
	FieldQualityMethod
	// FieldReasonCode is the field ... .
	FieldReasonCode
	// FieldReasonDescription is the field ... .
	FieldReasonDescription
	// FieldUpdateDateTime is the field ... .
	FieldUpdateDateTime
	// FieldMSATSLoadDateTime is the field ... .
	FieldMSATSLoadDateTime
	// FieldStartInterval is the field ... .
	FieldStartInterval
	// FieldFinishInterval is the field ... .
	FieldFinishInterval
	// FieldTransactionCode is the field ... .
	FieldTransactionCode
	// FieldRetServiceOrder is the field ... .
	FieldRetServiceOrder
	// FieldReadDateTime is the field ... .
	FieldReadDateTime
	// FieldIndexRead is the field ... .
	FieldIndexRead
)

func Fields

func Fields() []FieldType

Fields returns all the fields.

func (FieldType) GoString

func (f FieldType) GoString() string

GoString provides the go string.

func (FieldType) Identifier

func (f FieldType) Identifier() string

Identifier returns the code used by AEMO.

type Flag

type Flag interface {
	fmt.GoStringer
	Identifier() string
	Description() (string, error)
}

Flag is an interface for flags.

type Install

type Install int

Install represents an installation type for the metering at a nmi.

const (
	// InstallUndefined if install is undefined.
	InstallUndefined Install = iota
	// InstallComms1 for a type 1 interval meter with communications .
	InstallComms1
	// InstallComms2 for a type 2 interval meter with communications .
	InstallComms2
	// InstallComms3 for a type 3 interval meter with communications .
	InstallComms3
	// InstallComms4 for a type 4 interval meter with communications .
	InstallComms4
	// InstallMRIM for a type 5 manually read interval meter.
	InstallMRIM
	// InstallBasic for a type 6 basic consumption meter.
	InstallBasic
	// InstallUnmetered for type 7 unmetered supply.
	InstallUnmetered
)

func Installs

func Installs() []Install

Installs returns all the installs.

func NewInstall

func NewInstall(s string) (Install, error)

NewInstall returns a new install, and error if not found.

func (Install) Description

func (i Install) Description() (string, error)

Description returns the description of the install from AEMO.

func (Install) GoString

func (i Install) GoString() string

GoString returns a text representation of the install to satisfy the GoStringer interface.

func (Install) Identifier

func (i Install) Identifier() string

Identifier returns the code used by AEMO.

func (Install) String

func (i Install) String() string

String returns a text representation of the install.

type Interval

type Interval struct {
	// Data.
	Time           time.Time     `json:"datetime"`
	IntervalLength time.Duration `json:"intervalLength"`
	Value          IntervalValue `json:"intervalValue"`

	// Metadata, shared.
	Metadata *IntervalMetadata `json:"metadata,omitempty"`
}

Interval is duration of time from a start to a finish, with a value.

func (*Interval) Normalize

func (i *Interval) Normalize(uom *UnitOfMeasure) (*Interval, error)

Normalize returns the interval in SI units.

type IntervalLength

type IntervalLength time.Duration

IntervalLength for custom json marshalling of a duration.

type IntervalMetadata

type IntervalMetadata struct {
	Nmi           *nmi.Nmi       `json:"nmi,omitempty"`
	Meter         *nmi.Meter     `json:"meter,omitempty"`
	Suffix        *Suffix        `json:"suffix,omitempty"`
	UnitOfMeasure *UnitOfMeasure `json:"unit,omitempty"`
}

IntervalMetadata holds the metadata for an interval.

type IntervalSet

type IntervalSet struct {
	// Data
	Data Intervals `json:"data,omitempty"`

	// Metadata, shared.
	Metadata *IntervalMetadata `json:"metadata,omitempty"`
}

IntervalSet is a set of intervals, with reference to metadata.

func (*IntervalSet) Normalize

func (is *IntervalSet) Normalize() (*IntervalSet, error)

Normalize returns the interval set in SI units.

type IntervalValue

type IntervalValue struct {
	Value             float64         `json:"value"`                       // Value of the interval in the SI unit of measure.
	DecimalValue      decimal.Decimal `json:"decimalValue"`                // Value of the interval in SI unit of measure as a decimal.
	QualityFlag       Quality         `json:"quality"`                     // Quality flag applicable to this value.
	MethodFlag        *Method         `json:"method,omitempty"`            // Method flag applicable to this value.
	ReasonCode        *Reason         `json:"reason,omitempty"`            // ReasonCode applicable to this value.
	ReasonDescription *string         `json:"reasonDescription,omitempty"` // Text describing the reason for when ReasonCode equals FreeTextDescription.
	UpdateDateTime    *time.Time      `json:"updateDateTime,omitempty"`    // Time that the metering data was created or updated as reported by the MDP.
	MSATSLoadDateTime *time.Time      `json:"msatsLoadDateTime,omitempty"` // Time that the metering data was loaded into MSATS.
}

An IntervalValue represents a single meter interval value as presented by an NEM12 file.

type Intervals

type Intervals []*Interval

Intervals is a slice of Interval.

type Method

type Method int

A Method represents the value of the method flag section of a QualityMethod field of a NEM12 interval value.

func Methods

func Methods() []Method

Methods returns all methods.

func NewMethodFlag

func NewMethodFlag(s string) (Method, error)

NewMethodFlag returns a new method flag if valid, and an error if not.

func (Method) Description

func (m Method) Description() (string, error)

Description returns the description of a method flag, along with an error if it is an unknown value.

func (Method) GoString

func (m Method) GoString() string

GoString returns a text representation of the Method to satisfy the GoStringer interface.

func (Method) Identifier

func (m Method) Identifier() string

Identifier to meet the interface specification for a Flag.

func (Method) InstallationTypes

func (m Method) InstallationTypes() []Install

InstallationTypes returns the installation types for a method flag.

func (Method) String

func (m Method) String() string

String returns a text representation of the Method.

func (Method) Types

func (m Method) Types() []MethodType

Types returns the installation types for a method flag.

func (Method) Validate

func (m Method) Validate() error

Validate returns an error if the method flag is invalid.

type MethodType

type MethodType int

A MethodType represents the value of the method flag section of a QualityMethodType field of a NEM12 interval value.

const (
	// MethodTypeUndefined for undefined method types.
	MethodTypeUndefined MethodType = iota
	// MethodTypeEstimated for methods using estimation.
	MethodTypeEstimated
	// MethodTypeSubstituted for methods using substitution.
	MethodTypeSubstituted
)

func MethodTypes

func MethodTypes() []MethodType

MethodTypes returns all method types.

func NewMethodType

func NewMethodType(s string) (MethodType, error)

NewMethodType returns a new method flag if valid, and an error if not.

func (MethodType) Description

func (m MethodType) Description() (string, error)

Description returns the description of a method flag, along with an error if it is an unknown value.

func (MethodType) GoString

func (m MethodType) GoString() string

GoString returns a text representation of the MethodType to satisfy the GoStringer interface.

func (MethodType) Identifier

func (m MethodType) Identifier() string

Identifier to meet the interface specification for a Flag.

func (MethodType) String

func (m MethodType) String() string

String returns a text representation of the MethodType.

func (MethodType) Validate

func (m MethodType) Validate() error

Validate returns an error if the method flag is invalid.

type ParseError

type ParseError struct {
	Line  int   // Line where the error occurred.
	Field int   // Field where the error occurred.
	Err   error // The actual error.
}

A ParseError is returned for parsing errors. Line numbers are 1-indexed and columns are 0-indexed.

func (*ParseError) Error

func (e *ParseError) Error() string

Error to meet the error interface.

func (*ParseError) Unwrap

func (e *ParseError) Unwrap() error

Unwrap for the interface.

type ParseMode

type ParseMode int

ParseMode controls the parsing behaviour.

const (
	// ParseModeStrict defaults to strict mode.
	ParseModeStrict ParseMode = iota
	// ParseModeIgnoreX ignores X when parsing.
	ParseModeIgnoreX
)

type Parser

type Parser interface {
	// ReadDataStream() (*IntervalSet, err error)
	ReadDay() (*IntervalSet, error)
}

Parser provides the ability to parse nem12 files.

func NewParser

func NewParser(r io.Reader) Parser

NewParser returns a new Parser that parses text read from r.

type Quality

type Quality int

Quality represents the value of the quality flag part of the QualityMethod field of an NEM12 interval.

const (
	// QualityUndefined is for undefined quality flags.
	QualityUndefined Quality = iota
	// QualityActual is the quality flag value for actual data.
	QualityActual
	// QualityEstimated is the quality flag value for forward estimated data.
	QualityEstimated
	// QualityFinal is the quality flag value for final substituted data.
	QualityFinal
	// QualityNull is the quality flag value for null data.
	QualityNull
	// QualitySubstituted is the quality flag value for substituted data.
	QualitySubstituted
	// QualityVariable is the quality flag value for variable data.
	QualityVariable
)

func NewQualityFlag

func NewQualityFlag(s string) (Quality, error)

NewQualityFlag returns a new quality flag if valid, and an error if not.

func Qualities

func Qualities() []Quality

Qualities returns a slice of all the qualities.

func (Quality) Description

func (q Quality) Description() (string, error)

Description returns the description of a quality flag. Error is returned if the flag is invalid.

func (Quality) GoString

func (q Quality) GoString() string

GoString returns a text representation of the Quality to satisfy the GoStringer interface.

func (Quality) Identifier

func (q Quality) Identifier() string

Identifier to meet the interface specification for a Flag.

func (*Quality) MarshalJSON

func (q *Quality) MarshalJSON() ([]byte, error)

MarshalJSON marshals for JSON.

func (Quality) MustNotHaveReason

func (q Quality) MustNotHaveReason() bool

MustNotHaveReason indicates if a quality flag must not have a reason.

func (Quality) RequiresMethod

func (q Quality) RequiresMethod() (b bool)

RequiresMethod indicates if a quality flag requires an accompanying method.

func (Quality) RequiresReason

func (q Quality) RequiresReason() (b bool)

RequiresReason indicates if a quality flag requires a reason.

func (Quality) String

func (q Quality) String() string

String returns a text representation of the Quality.

func (*Quality) UnmarshalJSON

func (q *Quality) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals json string.

func (Quality) Validate

func (q Quality) Validate() (err error)

Validate returns an error if the quality flag is invalid.

type QualityMethod

type QualityMethod string

QualityMethod of the NEM12 interval data record (300) or interval event record (400) row.

func NewQualityMethod

func NewQualityMethod(s string) (QualityMethod, error)

NewQualityMethod returns a new quality method, with error if not valid.

func (QualityMethod) Method

func (qm QualityMethod) Method() (Method, error)

Method returns the quality for a given Method.

func (QualityMethod) Quality

func (qm QualityMethod) Quality() (Quality, error)

Quality returns the quality for a given QualityMethod.

func (QualityMethod) Validate

func (qm QualityMethod) Validate() error

Validate returns an error if a quality method is invalid.

type Reason

type Reason int

A Reason represents the value of the reason code field of a NEM12 record.

func ActiveReasons

func ActiveReasons() []Reason

ActiveReasons returns all reasons that are not deprecated.

func DeprecatedReasons

func DeprecatedReasons() []Reason

DeprecatedReasons returns all reasons that are deprecated.

func NewReason

func NewReason(s string) (Reason, error)

NewReason returns a new reason, along with errors if not valid.

func Reasons

func Reasons() []Reason

Reasons returns all reasons.

func (Reason) Deprecated

func (r Reason) Deprecated() bool

Deprecated indicates if this method is a deprecated method.

func (Reason) Description

func (r Reason) Description() (string, error)

Description returns the description of a reason code, along with an error if it is an unknown value.

func (Reason) GoString

func (r Reason) GoString() string

GoString returns a text representation of the reason to satisfy the GoStringer interface.

func (Reason) Identifier

func (r Reason) Identifier() string

Identifier returns the identifier.

func (Reason) RequiresDescription

func (r Reason) RequiresDescription() bool

RequiresDescription flag the need for custom text for description.

func (Reason) String

func (r Reason) String() string

String returns a text representation of the reason.

func (Reason) Validate

func (r Reason) Validate() error

Validate ensures a reason is valid.

type Record

type Record []Field

Record holds a record (row) of NEM12 data, separated by new line.

func NewRecord

func NewRecord(vals []string) (r Record, err error)

NewRecord returns a new record, given the field values.

func NewRecordIntervalData

func NewRecordIntervalData(n int, vals []string) (Record, error)

NewRecordIntervalData returns a new record, given the number of expected intervals and the field values.

func (Record) Field

func (r Record) Field(n int) Field

Field returns the nth field of a Record, or the zero value of a Field string.

func (Record) Indicator

func (r Record) Indicator() RecordIndicator

Indicator returns the indicator for the record.

type RecordIndicator

type RecordIndicator int

RecordIndicator provides the indicator of the type record of record within the NEM12 data structure.

const (
	// RecordUndefined is the record that is undefined.
	RecordUndefined RecordIndicator = iota
	// RecordHeader is the header record.
	RecordHeader
	// RecordNMIDataDetails is the NMI data details record.
	//
	// Multiple 300-500 record blocks are allowed within a single 200 record.
	RecordNMIDataDetails
	// RecordIntervalData is the interval data record.
	//
	// 300 records must be presented in date sequential order. For example, with a
	// series of Meter Readings for a period, the current record is the next
	// incremental IntervalDate after the previous record. Or, where data for
	// individual, non-consecutive days is sent, the IntervalDate for each 300
	// record is later than the previous one.
	//
	// Where the same QualityMethod and ReasonCode apply to all IntervalValues in
	// the 300 record, the QualityMethod, ReasonCode and ReasonDescription in the
	// 300 Record must be used. If either of these fields contains multiple values
	// for the IntervalValues, the QualityMethod in the 300 record must be set to
	// “V” and the 400 record must be provided.
	//
	// The use of ‘V’ as the quality method in this example indicates the
	// QualityMethod, ReasonCode or ReasonDescription vary across the day and will
	// be provided, for each Interval, in the 400 records that would immediately
	// follow this record. Refer 4.5 for details on the use of the 400 records.
	RecordIntervalData
	// RecordIntervalEvent is the interval event record.
	//
	// This record is mandatory where the QualityFlag is ‘V’ in the 300 record or
	// where the quality flag is‘A’ and reason codes 79, 89, and 61 are used.
	//
	// The StartInterval/EndInterval pairs must be presented in ascending record
	// order. The StartInterval/EndInterval period must cover an entire day
	// without gaps or overlaps. For example, (based on a 30-minute Interval):
	//
	//  400,1,26,A,,
	//  400,27,31,S53,9,
	//  400,32,48,E52,,
	//
	// Refer to section 2 (c) of AEMO's MDFF specification for further rules
	// regarding the use of this record.
	RecordIntervalEvent
	// RecordB2BDetails is the business-to-business details record.
	//
	// This record is mandatory where a manual Meter Reading has been performed or
	// attempted. Only valid "500" records associated with the current Meter
	// Reading period must be provided. For example, a 500 record associated with
	// a Substitute will become invalid if Actual Metering Data subsequently
	// replace the Substitutes.
	//
	// This record must be repeated where multiple TransCodes or RetServiceOrders
	// apply to the day.
	RecordB2BDetails
	// RecordEnd is the end record.
	RecordEnd
)

func NewRecordIndicator

func NewRecordIndicator(s string) (RecordIndicator, error)

NewRecordIndicator returns a new record indicator, along with errors if not valid.

func RecordIndicators

func RecordIndicators() []RecordIndicator

RecordIndicators returns all record indicators.

func (RecordIndicator) Description

func (r RecordIndicator) Description() (string, error)

Description returns the description of a record indicator, along with an error if it is an unknown value.

func (RecordIndicator) Fields

func (r RecordIndicator) Fields() []FieldType

Fields returns the expected set of fields, in order, for a record.

func (RecordIndicator) GoString

func (r RecordIndicator) GoString() string

GoString returns a text representation of the reason to satisfy the GoStringer interface.

func (RecordIndicator) Identifier

func (r RecordIndicator) Identifier() string

Identifier returns the identifier for the record indicator.

func (RecordIndicator) IntervalDataFields

func (r RecordIndicator) IntervalDataFields(n int) ([]FieldType, error)

IntervalDataFields returns the expected set of fields, in order, for an interval data record, given the expected number of intervals.

func (RecordIndicator) String

func (r RecordIndicator) String() string

String returns a text representation of the reason.

func (RecordIndicator) Validate

func (r RecordIndicator) Validate() error

Validate ensures a record indicator is valid.

type Suffix

type Suffix struct {
	Type  SuffixType `json:"suffixType,omitempty"`
	Meter rune       `json:"meter,omitempty"`
}

Suffix is a datastream suffix, made up first of a single character flag for the type of datastream, and a second character flag for a meter.

func NewSuffix

func NewSuffix(s string) (Suffix, error)

NewSuffix returns a new suffix, with errors raised if invalid.

type SuffixType

type SuffixType int

SuffixType for suffix types.

const (
	// SuffixUndefined if suffix is undefined.
	SuffixUndefined SuffixType = iota
	// SuffixImportWattHourAverage is for SuffixImportWattHourAverage.
	SuffixImportWattHourAverage
	// SuffixImportWattHourMaster is for SuffixImportWattHourMaster.
	SuffixImportWattHourMaster
	// SuffixImportWattHourCheck is for SuffixImportWattHourCheck.
	SuffixImportWattHourCheck
	// SuffixExportWattHourAverage is for SuffixExportWattHourAverage.
	SuffixExportWattHourAverage
	// SuffixExportWattHourMaster is for SuffixExportWattHourMaster.
	SuffixExportWattHourMaster
	// SuffixExportWattHourCheck is for SuffixExportWattHourCheck.
	SuffixExportWattHourCheck
	// SuffixWattHourNet is for SuffixWattHourNet.
	SuffixWattHourNet
	// SuffixImportVoltAmpReactiveHourAverage is for SuffixImportVoltAmpReactiveHourAverage.
	SuffixImportVoltAmpReactiveHourAverage
	// SuffixImportVoltAmpReactiveHourMaster is for SuffixImportVoltAmpReactiveHourMaster.
	SuffixImportVoltAmpReactiveHourMaster
	// SuffixImportVoltAmpReactiveHourCheck is for SuffixImportVoltAmpReactiveHourCheck.
	SuffixImportVoltAmpReactiveHourCheck
	// SuffixExportVoltAmpReactiveHourAverage is for SuffixExportVoltAmpReactiveHourAverage.
	SuffixExportVoltAmpReactiveHourAverage
	// SuffixExportVoltAmpReactiveHourMaster is for SuffixExportVoltAmpReactiveHourMaster.
	SuffixExportVoltAmpReactiveHourMaster
	// SuffixExportVoltAmpReactiveHourCheck is for SuffixExportVoltAmpReactiveHourCheck.
	SuffixExportVoltAmpReactiveHourCheck
	// SuffixVoltAmpReactiveHourNet is for SuffixVoltAmpReactiveHourNet.
	SuffixVoltAmpReactiveHourNet
	// SuffixVoltAmpHourAverage is for SuffixVoltAmpHourAverage.
	SuffixVoltAmpHourAverage
	// SuffixVoltAmpHourMaster is for SuffixVoltAmpHourMaster.
	SuffixVoltAmpHourMaster
	// SuffixVoltAmpHourCheck is for SuffixVoltAmpHourCheck.
	SuffixVoltAmpHourCheck
	// SuffixPowerFactorMaster is for SuffixPowerFactorMaster.
	SuffixPowerFactorMaster
	// SuffixQMeteringMaster is for SuffixQMeteringMaster.
	SuffixQMeteringMaster
	// SuffixQMeteringCheck is for SuffixQMeteringCheck.
	SuffixQMeteringCheck
	// SuffixParMeteringMaster is for SuffixParMeteringMaster.
	SuffixParMeteringMaster
	// SuffixParMeteringCheck is for SuffixParMeteringCheck.
	SuffixParMeteringCheck
	// SuffixVoltsOrAmpsMaster is for SuffixVoltsOrAmpsMaster.
	SuffixVoltsOrAmpsMaster
	// SuffixVoltsOrAmpsCheck is for SuffixVoltsOrAmpsCheck.
	SuffixVoltsOrAmpsCheck
)

func NewSuffixType

func NewSuffixType(s string) (SuffixType, error)

NewSuffixType to create a new suffix from the string value.

func SuffixTypes

func SuffixTypes() []SuffixType

SuffixTypes returns all suffixes.

func (SuffixType) Description

func (s SuffixType) Description() string

Description returns the description for a suffix type.

func (SuffixType) GoString

func (s SuffixType) GoString() string

GoString returns a text representation of the reason to satisfy the GoStringer interface.

func (SuffixType) Identifier

func (s SuffixType) Identifier() string

Identifier returns the identifier.

func (*SuffixType) MarshalJSON

func (s *SuffixType) MarshalJSON() ([]byte, error)

MarshalJSON marshals for JSON.

func (SuffixType) Stream

func (s SuffixType) Stream() string

Stream returns the stream for a suffix type.

func (SuffixType) String

func (s SuffixType) String() string

String returns a text representation of the reason.

func (SuffixType) Unit

func (s SuffixType) Unit() UnitOfMeasure

Unit returns the base unit for a suffix type.

func (*SuffixType) UnmarshalJSON

func (s *SuffixType) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the JSON data to a suffix type.

type TransactionCode

type TransactionCode int

TransactionCode represents the value of the transaction code flag.

const (
	// TransactionUndefined is for undefined transaction flags.
	TransactionUndefined TransactionCode = iota
	// TransactionAlteration is the transaction code value for 'A', when alteration.
	TransactionAlteration
	// TransactionMeterReconfiguration is the transaction code value for 'C', when meter reconfiguration.
	TransactionMeterReconfiguration
	// TransactionReEnergisation is the transaction code value for 'G', when re-energisation.
	TransactionReEnergisation
	// TransactionDeEnergisation is the transaction code value for 'D', when de-energisation.
	TransactionDeEnergisation
	// TransactionEstimate is the transaction code value for 'E', when estimated read.
	TransactionEstimate
	// TransactionNormalRead is the transaction code value for 'N', when normal read.
	TransactionNormalRead
	// TransactionOther is the transaction code value for 'O', when other.
	TransactionOther
	// TransactionSpecialRead is the transaction code value for 'S', when special read.
	TransactionSpecialRead
	// TransactionRemovalOfMeter is the transaction code value for 'R', when removal of meter.
	TransactionRemovalOfMeter
)

func NewTransactionCode

func NewTransactionCode(s string) (TransactionCode, error)

NewTransactionCode returns a new transaction flag if valid, and an error if not.

func Transactions

func Transactions() []TransactionCode

Transactions returns a slice of all the transactions.

func (TransactionCode) Description

func (t TransactionCode) Description() (string, error)

Description returns the description of a transaction flag. Error is returned if the flag is invalid.

func (TransactionCode) GoString

func (t TransactionCode) GoString() string

GoString returns a text representation of the Transaction to satisfy the GoStringer interface.

func (TransactionCode) Identifier

func (t TransactionCode) Identifier() string

Identifier to meet the interface specification for a Flag.

func (TransactionCode) String

func (t TransactionCode) String() string

String returns a text representation of the Transaction.

type UnitOfMeasure

type UnitOfMeasure int

A UnitOfMeasure represents a unit of measure as specified by the UOM field of a NMIDataDetails record.

const (
	// UnitUndefined for undefined units.
	UnitUndefined UnitOfMeasure = iota
	// UnitMegawattHour for the unit of megawatt hours.
	UnitMegawattHour
	// UnitKilowattHour for the unit of kilowatt hours.
	UnitKilowattHour
	// UnitWattHour for the unit of watt hours.
	UnitWattHour
	// UnitMegawatt for the unit of megawatts.
	UnitMegawatt
	// UnitKilowatt for the unit of kilowatts.
	UnitKilowatt
	// UnitWatt for the unit of watts.
	UnitWatt
	// UnitMegavoltAmpereReactiveHour for the unit of megavolt ampere reactive hours.
	UnitMegavoltAmpereReactiveHour
	// UnitKilovoltAmpereReactiveHour for the unit of kilovolt ampere reactive hours.
	UnitKilovoltAmpereReactiveHour
	// UnitVoltAmpereReactiveHour for the unit of volt ampere reactive hours.
	UnitVoltAmpereReactiveHour
	// UnitMegavoltAmpereReactive for the unit of megavolt ampere reactives.
	UnitMegavoltAmpereReactive
	// UnitKilovoltAmpereReactive for the unit of kilovolt ampere reactives.
	UnitKilovoltAmpereReactive
	// UnitVoltAmpereReactive for the unit of volt ampere reactives.
	UnitVoltAmpereReactive
	// UnitMegavoltAmpereHour for the unit of megavolt ampere hours.
	UnitMegavoltAmpereHour
	// UnitKilovoltAmpereHour for the unit of kilovolt ampere hours.
	UnitKilovoltAmpereHour
	// UnitVoltAmpereHour for the unit of volt ampere hours.
	UnitVoltAmpereHour
	// UnitMegavoltAmpere for the unit of megavolt amperes.
	UnitMegavoltAmpere
	// UnitKilovoltAmpere for the unit of kilovolt amperes.
	UnitKilovoltAmpere
	// UnitVoltAmpere for the unit of volt amperes.
	UnitVoltAmpere
	// UnitKilovolt for the unit of kilovolts.
	UnitKilovolt
	// UnitVolt for the unit of volts.
	UnitVolt
	// UnitKiloampere for the unit of kiloamperes.
	UnitKiloampere
	// UnitAmpere for the unit of amperes.
	UnitAmpere
	// UnitPowerFactor for the unit of power factors.
	UnitPowerFactor
)

func NewUnit

func NewUnit(s string) (UnitOfMeasure, error)

NewUnit returns a new reason, along with errors if not valid.

func Units

func Units() []UnitOfMeasure

Units returns all units.

func (UnitOfMeasure) Base

func (u UnitOfMeasure) Base() UnitOfMeasure

Base returns the base unit in SI for a unit of measure.

func (UnitOfMeasure) DecimalMultiplier

func (u UnitOfMeasure) DecimalMultiplier() decimal.Decimal

DecimalMultiplier for the unit of measure to SI unit, but using the decimal package.

func (UnitOfMeasure) Description

func (u UnitOfMeasure) Description() (string, error)

Description returns the description of a reason code, along with an error if it is an unknown value.

func (UnitOfMeasure) GoString

func (u UnitOfMeasure) GoString() string

GoString returns a text representation of the reason to satisfy the GoStringer interface.

func (UnitOfMeasure) Identifier

func (u UnitOfMeasure) Identifier() string

Identifier returns the identifier.

func (*UnitOfMeasure) MarshalJSON

func (u *UnitOfMeasure) MarshalJSON() ([]byte, error)

MarshalJSON marshals for JSON.

func (UnitOfMeasure) Multiplier

func (u UnitOfMeasure) Multiplier() float64

Multiplier for the unit of measure to SI unit.

func (UnitOfMeasure) Name

func (u UnitOfMeasure) Name() (string, error)

Name returns the name of the unit.

func (UnitOfMeasure) String

func (u UnitOfMeasure) String() string

String returns a text representation of the reason.

func (*UnitOfMeasure) UnmarshalJSON

func (u *UnitOfMeasure) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals json string.

func (UnitOfMeasure) Validate

func (u UnitOfMeasure) Validate() error

Validate ensures a reason is valid.

Jump to

Keyboard shortcuts

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