ocmf

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package ocmf detects and validates Open Charge Metering Format (OCMF) records

Index

Constants

View Source
const Header = "OCMF"

Header is the literal string that identifies an OCMF record on the wire.

Variables

This section is empty.

Functions

func LooksLikeOCMF

func LooksLikeOCMF(value string) bool

LooksLikeOCMF reports whether value appears to be an OCMF record, i.e. it starts with the "OCMF|" header used to identify the transfer format.

func Validate

func Validate(value string) (*jsonschema.EvaluationResult, error)

Validate parses value as an OCMF record and validates it against the OCMF JSON Schema.

Types

type Payload

type Payload struct {
	FV string    `json:"FV,omitempty"`
	GI string    `json:"GI,omitempty"`
	GS string    `json:"GS,omitempty"`
	GV string    `json:"GV,omitempty"`
	PG string    `json:"PG,omitempty"`
	MV string    `json:"MV,omitempty"`
	MM string    `json:"MM,omitempty"`
	MS string    `json:"MS,omitempty"`
	MF string    `json:"MF,omitempty"`
	IS *bool     `json:"IS,omitempty"`
	IL string    `json:"IL,omitempty"`
	IF []string  `json:"IF,omitempty"`
	IT string    `json:"IT,omitempty"`
	ID string    `json:"ID,omitempty"`
	CT string    `json:"CT,omitempty"`
	CI string    `json:"CI,omitempty"`
	RD []Reading `json:"RD,omitempty"`
}

Payload is the signed payload data.

type Reading

type Reading struct {
	TM string   `json:"TM,omitempty"`
	TX string   `json:"TX,omitempty"`
	RV *float64 `json:"RV,omitempty"`
	RI string   `json:"RI,omitempty"`
	RU string   `json:"RU,omitempty"`
	RT string   `json:"RT,omitempty"`
	EF string   `json:"EF,omitempty"`
	ST string   `json:"ST,omitempty"`
}

type Record

type Record struct {
	Header    string    `json:"header"`
	Payload   Payload   `json:"payload"`
	Signature Signature `json:"signature"`
}

Record is a fully parsed OCMF record: "OCMF|<Payload>|<Signature>", split on its header and the two JSON sections.

func Parse

func Parse(value string) (*Record, error)

Parse splits a raw OCMF record ("OCMF|<payload>|<signature>") into its header, payload and signature sections and unmarshals the payload and signature JSON objects into their typed Go representations.

type Signature

type Signature struct {
	SA string `json:"SA,omitempty"`
	SE string `json:"SE,omitempty"`
	SM string `json:"SM,omitempty"`
	SD string `json:"SD,omitempty"`
}

Signature is the signature over the payload data.

Jump to

Keyboard shortcuts

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