pipe

package
v0.0.0-...-4086bda Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package pipe provides the core functionality for transferring messages between a charge station and a CSMS using OCPP/J. A Pipe is a bidirectional connection where OCPP Call and CallResult (or CallError) messages are brokered. A Pipe is agnostic to the actual communication channels. It is up to the caller to ensure that the charge station and CSMS Rx and Tx channels are hooked up to an appropriate source or sink.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GatewayMessage

type GatewayMessage struct {
	Context          context.Context  `json:"-"`
	MessageType      ocpp.MessageType `json:"type"`
	Action           string           `json:"action"`
	MessageId        string           `json:"id"`
	RequestPayload   json.RawMessage  `json:"request,omitempty"`
	ResponsePayload  json.RawMessage  `json:"response,omitempty"`
	ErrorCode        ocpp.ErrorCode   `json:"error_code,omitempty"`
	ErrorDescription string           `json:"error_description,omitempty"`
	State            json.RawMessage  `json:"state,omitempty"`
}

type Opt

type Opt func(*Pipe)

func WithCSMSCallQueueLen

func WithCSMSCallQueueLen(queueLen int) Opt

WithCSMSCallQueueLen is a pipe option that sets the maximum number of CSMS Call messages to queue when looking for a CallResult to send to the charge station

func WithCSMSCallResponseBufferLen

func WithCSMSCallResponseBufferLen(queueLen int) Opt

WithCSMSCallResponseBufferLen is a pipe option that sets the maximum number of CSMS Call messages to buffer waiting for CallResult responses from the charge station

func WithCSMSMessageQueueLen

func WithCSMSMessageQueueLen(queueLen int) Opt

WithCSMSMessageQueueLen is a pipe option that sets the maximum number of CSMS messages to queue

func WithMessageIdBufferLen

func WithMessageIdBufferLen(bufferLen int) Opt

WithMessageIdBufferLen is a pipe option that sets the number of previously used message ids to store

func WithResponseTimeout

func WithResponseTimeout(timeout time.Duration) Opt

WithResponseTimeout is a pipe option that sets the response timeout

type Pipe

type Pipe struct {
	// ChargeStationRx is an incoming channel from the Charge Station
	ChargeStationRx chan *GatewayMessage
	// ChargeStationTx is on outgoing channel to the Charge Station
	ChargeStationTx chan *GatewayMessage
	// CSMSRx is an incoming channel from the CSMS
	CSMSRx chan *GatewayMessage
	// CSMSTx is an outgoing channel to the CSMS
	CSMSTx chan *GatewayMessage
	// contains filtered or unexported fields
}

Pipe provides a bidirectional RPC pipe between a ChargeStation and the CSMS

func NewPipe

func NewPipe(opts ...Opt) *Pipe

NewPipe creates a pipe for connecting a charge station to a CSMS

func (Pipe) Close

func (p Pipe) Close()

func (Pipe) Start

func (p Pipe) Start()

Start will begin transferring RPC messages between the ChargeStation and CSMS

type Status

type Status int
const (
	StatusWaiting Status = iota
	StatusChargeStationCall
	StatusCSMSCall
)

Jump to

Keyboard shortcuts

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