Documentation ¶
Overview ¶
Open Charge Point Protocol (OCPP) is a standard open protocol for communication between Charge Points and a Central System and is designed to accommodate any type of charging technique. This package contains the base interfaces used for the OCPP 1.6 and OCPP 2.0 implementation.
Index ¶
- type Error
- type ErrorCode
- type Feature
- type Logger
- type Profile
- func (p *Profile) AddFeature(feature Feature)
- func (p *Profile) GetFeature(name string) Feature
- func (p *Profile) ParseRequest(featureName string, rawRequest interface{}, ...) (Request, error)
- func (p *Profile) ParseResponse(featureName string, rawResponse interface{}, ...) (Response, error)
- func (p *Profile) SupportsFeature(name string) bool
- type Request
- type Response
- type VoidLogger
- func (l *VoidLogger) Debug(args ...interface{})
- func (l *VoidLogger) Debugf(format string, args ...interface{})
- func (l *VoidLogger) Error(args ...interface{})
- func (l *VoidLogger) Errorf(format string, args ...interface{})
- func (l *VoidLogger) Info(args ...interface{})
- func (l *VoidLogger) Infof(format string, args ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
Error wraps an OCPP error, containing an ErrorCode, a Description and the ID of the message.
type Feature ¶
type Feature interface { // Returns the unique name of the feature. GetFeatureName() string // Returns the type of the request message. GetRequestType() reflect.Type // Returns the type of the response message. GetResponseType() reflect.Type }
Feature represents a single functionality, associated to a unique name. Every feature describes a Request and a Response message, specified in the OCPP protocol.
type Logger ¶
type Logger interface { Debug(args ...interface{}) Debugf(format string, args ...interface{}) Info(args ...interface{}) Infof(format string, args ...interface{}) Error(args ...interface{}) Errorf(format string, args ...interface{}) }
Logger is the adapter interface that needs to be implemented, if the library should internally print logs.
This allows to hook up your logger of choice.
type Profile ¶
Profile defines a specific set of features, grouped by functionality.
Some vendor may want to keep the protocol as slim as possible, and only support some feature profiles. This can easily be achieved by only registering certain profiles, while remaining compliant with the specifications.
func NewProfile ¶
Creates a new profile, identified by a name and a set of features.
func (*Profile) AddFeature ¶
Adds a feature to the profile.
func (*Profile) GetFeature ¶
Retrieves a feature, identified by a unique name. Returns nil in case the feature is not registered with this profile.
func (*Profile) ParseRequest ¶
func (p *Profile) ParseRequest(featureName string, rawRequest interface{}, requestParser func(raw interface{}, requestType reflect.Type) (Request, error)) (Request, error)
ParseRequest checks whether a feature is supported and passes the rawRequest message to the requestParser function. The type of the request message is passed to the requestParser function, which has to perform type assertion.
func (*Profile) ParseResponse ¶
func (p *Profile) ParseResponse(featureName string, rawResponse interface{}, responseParser func(raw interface{}, responseType reflect.Type) (Response, error)) (Response, error)
ParseRequest checks whether a feature is supported and passes the rawResponse message to the responseParser function. The type of the response message is passed to the responseParser function, which has to perform type assertion.
func (*Profile) SupportsFeature ¶
SupportsFeature returns true if a feature matching the the passed name is registered with this profile, false otherwise.
type Request ¶
type Request interface { // Returns the unique name of the feature, to which this request belongs to. GetFeatureName() string }
Request message
type Response ¶
type Response interface { // Returns the unique name of the feature, to which this request belongs to. GetFeatureName() string }
Response message
type VoidLogger ¶
type VoidLogger struct{}
VoidLogger is an empty implementation of the Logger interface, which doesn't actually process any logs. It may be used as a dummy implementation, if no logs should be visible.
func (*VoidLogger) Debug ¶
func (l *VoidLogger) Debug(args ...interface{})
func (*VoidLogger) Debugf ¶
func (l *VoidLogger) Debugf(format string, args ...interface{})
func (*VoidLogger) Error ¶
func (l *VoidLogger) Error(args ...interface{})
func (*VoidLogger) Errorf ¶
func (l *VoidLogger) Errorf(format string, args ...interface{})
func (*VoidLogger) Info ¶
func (l *VoidLogger) Info(args ...interface{})
func (*VoidLogger) Infof ¶
func (l *VoidLogger) Infof(format string, args ...interface{})