evcharger

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DecisionDelay     = 15 * time.Second
	DecisionMagnitude = PluggedInModeMagnitude
)
View Source
const (
	IdleModeID = "idle" // when not charging, including when plugged in or not

	IdleModeMagnitude      = 6
	PluggedInModeMagnitude = 10
)

Variables

View Source
var (
	DefaultRating  float32 = 60  // Amps
	DefaultVoltage float32 = 230 // Volts
)
View Source
var EVChargerApi_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "smartcore.playground.device.evcharger.EVChargerApi",
	HandlerType: (*EVChargerApiServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "PlugIn",
			Handler:    _EVChargerApi_PlugIn_Handler,
		},
		{
			MethodName: "ChargeStart",
			Handler:    _EVChargerApi_ChargeStart_Handler,
		},
		{
			MethodName: "Unplug",
			Handler:    _EVChargerApi_Unplug_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "pkg/device/evcharger/evcharger.proto",
}

EVChargerApi_ServiceDesc is the grpc.ServiceDesc for EVChargerApi service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var File_pkg_device_evcharger_evcharger_proto protoreflect.FileDescriptor

Functions

func Activate

func Activate(n *node.Node)

func RegisterEVChargerApiServer

func RegisterEVChargerApiServer(s grpc.ServiceRegistrar, srv EVChargerApiServer)

func WithEVChargerApiClientFactory

func WithEVChargerApiClientFactory(f func(name string) (EVChargerApiClient, error)) router.Option

WithEVChargerApiClientFactory instructs the router to create a new client the first time Get is called for that name.

Types

type ApiRouter

type ApiRouter struct {
	UnimplementedEVChargerApiServer

	router.Router
}

ApiRouter is a evcharger.EVChargerApiServer that allows routing named requests to specific evcharger.EVChargerApiClient

func NewApiRouter

func NewApiRouter(opts ...router.Option) *ApiRouter

func (*ApiRouter) Add

func (r *ApiRouter) Add(name string, client interface{}) interface{}

Add extends Router.Add to panic if client is not of type evcharger.EVChargerApiClient.

func (*ApiRouter) AddEVChargerApiClient

func (r *ApiRouter) AddEVChargerApiClient(name string, client EVChargerApiClient) EVChargerApiClient

func (*ApiRouter) ChargeStart

func (r *ApiRouter) ChargeStart(ctx context.Context, request *ChargeStartRequest) (*ChargeStartResponse, error)

func (*ApiRouter) GetEVChargerApiClient

func (r *ApiRouter) GetEVChargerApiClient(name string) (EVChargerApiClient, error)

func (*ApiRouter) HoldsType

func (r *ApiRouter) HoldsType(client interface{}) bool

func (*ApiRouter) PlugIn

func (r *ApiRouter) PlugIn(ctx context.Context, request *PlugInRequest) (*PlugInResponse, error)

func (*ApiRouter) Register

func (r *ApiRouter) Register(server *grpc.Server)

func (*ApiRouter) RemoveEVChargerApiClient

func (r *ApiRouter) RemoveEVChargerApiClient(name string) EVChargerApiClient

func (*ApiRouter) Unplug

func (r *ApiRouter) Unplug(ctx context.Context, request *UnplugRequest) (*UnplugResponse, error)

type ApiServer

type ApiServer struct {
	UnimplementedEVChargerApiServer
	// contains filtered or unexported fields
}

func (*ApiServer) ChargeStart

func (api *ApiServer) ChargeStart(ctx context.Context, request *ChargeStartRequest) (*ChargeStartResponse, error)

func (*ApiServer) PlugIn

func (api *ApiServer) PlugIn(ctx context.Context, request *PlugInRequest) (*PlugInResponse, error)

func (*ApiServer) Unplug

func (api *ApiServer) Unplug(ctx context.Context, request *UnplugRequest) (*UnplugResponse, error)

type ChargeStartRequest

type ChargeStartRequest struct {
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

func (*ChargeStartRequest) Descriptor deprecated

func (*ChargeStartRequest) Descriptor() ([]byte, []int)

Deprecated: Use ChargeStartRequest.ProtoReflect.Descriptor instead.

func (*ChargeStartRequest) GetName

func (x *ChargeStartRequest) GetName() string

func (*ChargeStartRequest) ProtoMessage

func (*ChargeStartRequest) ProtoMessage()

func (*ChargeStartRequest) ProtoReflect

func (x *ChargeStartRequest) ProtoReflect() protoreflect.Message

func (*ChargeStartRequest) Reset

func (x *ChargeStartRequest) Reset()

func (*ChargeStartRequest) String

func (x *ChargeStartRequest) String() string

type ChargeStartResponse

type ChargeStartResponse struct {
	// contains filtered or unexported fields
}

func (*ChargeStartResponse) Descriptor deprecated

func (*ChargeStartResponse) Descriptor() ([]byte, []int)

Deprecated: Use ChargeStartResponse.ProtoReflect.Descriptor instead.

func (*ChargeStartResponse) ProtoMessage

func (*ChargeStartResponse) ProtoMessage()

func (*ChargeStartResponse) ProtoReflect

func (x *ChargeStartResponse) ProtoReflect() protoreflect.Message

func (*ChargeStartResponse) Reset

func (x *ChargeStartResponse) Reset()

func (*ChargeStartResponse) String

func (x *ChargeStartResponse) String() string

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device is a virtual electric vehicle charger.

func New

func New(name string, tl timeline.TL, opts ...Opt) *Device

New creates a new Device.

func (*Device) Publish

func (d *Device) Publish(announcer node.Announcer)

func (*Device) Scrub

func (d *Device) Scrub(t time.Time) error

type EVChargerApiClient

type EVChargerApiClient interface {
	PlugIn(ctx context.Context, in *PlugInRequest, opts ...grpc.CallOption) (*PlugInResponse, error)
	ChargeStart(ctx context.Context, in *ChargeStartRequest, opts ...grpc.CallOption) (*ChargeStartResponse, error)
	Unplug(ctx context.Context, in *UnplugRequest, opts ...grpc.CallOption) (*UnplugResponse, error)
}

EVChargerApiClient is the client API for EVChargerApi service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func WrapApi

func WrapApi(server EVChargerApiServer) EVChargerApiClient

WrapApi adapts a evcharger.EVChargerApiServer and presents it as a evcharger.EVChargerApiClient

type EVChargerApiServer

type EVChargerApiServer interface {
	PlugIn(context.Context, *PlugInRequest) (*PlugInResponse, error)
	ChargeStart(context.Context, *ChargeStartRequest) (*ChargeStartResponse, error)
	Unplug(context.Context, *UnplugRequest) (*UnplugResponse, error)
	// contains filtered or unexported methods
}

EVChargerApiServer is the server API for EVChargerApi service. All implementations must embed UnimplementedEVChargerApiServer for forward compatibility

type Opt

type Opt func(*opt)

func WithClock

func WithClock(clk clock.Clock) Opt

func WithDedicatedTL

func WithDedicatedTL() Opt

WithDedicatedTL instructs the device that the TL instance is just for that device, no filtering will need to be done.

func WithInputDispatcher

func WithInputDispatcher(dispatcher input.Dispatcher) Opt

func WithRating

func WithRating(r float32) Opt

func WithVoltage

func WithVoltage(v float32) Opt

type PlugInEvent

type PlugInEvent struct {

	// Full describes the values the plugged in device would have when full.
	//
	// Example
	//
	//    Percentage: 100, // when full, the ev is at 100%
	//    DistanceKm: 300, // when full, the ev can travel 300 km
	//    EnergyKwh:  100, // when full, the ev hold 100 kWh of energy
	Full *traits.EnergyLevel_Quantity `protobuf:"bytes,1,opt,name=full,proto3" json:"full,omitempty"`
	// Level encodes the current charge level when the vehicle was plugged in.
	Level *traits.EnergyLevel_Quantity `protobuf:"bytes,2,opt,name=level,proto3" json:"level,omitempty"`
	// Supported charging modes of the device that was just plugged in.
	// Empty implies the charger can make the decision.
	// The first mode is the preferred mode and will be marked as the Normal mode.
	Modes []*PlugInEvent_ChargeMode `protobuf:"bytes,3,rep,name=modes,proto3" json:"modes,omitempty"`
	// contains filtered or unexported fields
}

func (*PlugInEvent) Descriptor deprecated

func (*PlugInEvent) Descriptor() ([]byte, []int)

Deprecated: Use PlugInEvent.ProtoReflect.Descriptor instead.

func (*PlugInEvent) GetFull

func (x *PlugInEvent) GetFull() *traits.EnergyLevel_Quantity

func (*PlugInEvent) GetLevel

func (x *PlugInEvent) GetLevel() *traits.EnergyLevel_Quantity

func (*PlugInEvent) GetModes

func (x *PlugInEvent) GetModes() []*PlugInEvent_ChargeMode

func (*PlugInEvent) ProtoMessage

func (*PlugInEvent) ProtoMessage()

func (*PlugInEvent) ProtoReflect

func (x *PlugInEvent) ProtoReflect() protoreflect.Message

func (*PlugInEvent) Reset

func (x *PlugInEvent) Reset()

func (*PlugInEvent) String

func (x *PlugInEvent) String() string

type PlugInEvent_ChargeMode

type PlugInEvent_ChargeMode struct {
	Id          string                         `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Title       string                         `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`
	Description string                         `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
	Segments    []*traits.ElectricMode_Segment `protobuf:"bytes,4,rep,name=segments,proto3" json:"segments,omitempty"`
	// contains filtered or unexported fields
}

func (*PlugInEvent_ChargeMode) Descriptor deprecated

func (*PlugInEvent_ChargeMode) Descriptor() ([]byte, []int)

Deprecated: Use PlugInEvent_ChargeMode.ProtoReflect.Descriptor instead.

func (*PlugInEvent_ChargeMode) GetDescription

func (x *PlugInEvent_ChargeMode) GetDescription() string

func (*PlugInEvent_ChargeMode) GetId

func (x *PlugInEvent_ChargeMode) GetId() string

func (*PlugInEvent_ChargeMode) GetSegments

func (*PlugInEvent_ChargeMode) GetTitle

func (x *PlugInEvent_ChargeMode) GetTitle() string

func (*PlugInEvent_ChargeMode) ProtoMessage

func (*PlugInEvent_ChargeMode) ProtoMessage()

func (*PlugInEvent_ChargeMode) ProtoReflect

func (x *PlugInEvent_ChargeMode) ProtoReflect() protoreflect.Message

func (*PlugInEvent_ChargeMode) Reset

func (x *PlugInEvent_ChargeMode) Reset()

func (*PlugInEvent_ChargeMode) String

func (x *PlugInEvent_ChargeMode) String() string

type PlugInRequest

type PlugInRequest struct {
	Name  string       `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Event *PlugInEvent `protobuf:"bytes,2,opt,name=event,proto3" json:"event,omitempty"`
	// contains filtered or unexported fields
}

func (*PlugInRequest) Descriptor deprecated

func (*PlugInRequest) Descriptor() ([]byte, []int)

Deprecated: Use PlugInRequest.ProtoReflect.Descriptor instead.

func (*PlugInRequest) GetEvent

func (x *PlugInRequest) GetEvent() *PlugInEvent

func (*PlugInRequest) GetName

func (x *PlugInRequest) GetName() string

func (*PlugInRequest) ProtoMessage

func (*PlugInRequest) ProtoMessage()

func (*PlugInRequest) ProtoReflect

func (x *PlugInRequest) ProtoReflect() protoreflect.Message

func (*PlugInRequest) Reset

func (x *PlugInRequest) Reset()

func (*PlugInRequest) String

func (x *PlugInRequest) String() string

type PlugInResponse

type PlugInResponse struct {
	// contains filtered or unexported fields
}

func (*PlugInResponse) Descriptor deprecated

func (*PlugInResponse) Descriptor() ([]byte, []int)

Deprecated: Use PlugInResponse.ProtoReflect.Descriptor instead.

func (*PlugInResponse) ProtoMessage

func (*PlugInResponse) ProtoMessage()

func (*PlugInResponse) ProtoReflect

func (x *PlugInResponse) ProtoReflect() protoreflect.Message

func (*PlugInResponse) Reset

func (x *PlugInResponse) Reset()

func (*PlugInResponse) String

func (x *PlugInResponse) String() string

type UnimplementedEVChargerApiServer

type UnimplementedEVChargerApiServer struct {
}

UnimplementedEVChargerApiServer must be embedded to have forward compatible implementations.

func (UnimplementedEVChargerApiServer) ChargeStart

func (UnimplementedEVChargerApiServer) PlugIn

func (UnimplementedEVChargerApiServer) Unplug

type UnplugRequest

type UnplugRequest struct {
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

func (*UnplugRequest) Descriptor deprecated

func (*UnplugRequest) Descriptor() ([]byte, []int)

Deprecated: Use UnplugRequest.ProtoReflect.Descriptor instead.

func (*UnplugRequest) GetName

func (x *UnplugRequest) GetName() string

func (*UnplugRequest) ProtoMessage

func (*UnplugRequest) ProtoMessage()

func (*UnplugRequest) ProtoReflect

func (x *UnplugRequest) ProtoReflect() protoreflect.Message

func (*UnplugRequest) Reset

func (x *UnplugRequest) Reset()

func (*UnplugRequest) String

func (x *UnplugRequest) String() string

type UnplugResponse

type UnplugResponse struct {
	// contains filtered or unexported fields
}

func (*UnplugResponse) Descriptor deprecated

func (*UnplugResponse) Descriptor() ([]byte, []int)

Deprecated: Use UnplugResponse.ProtoReflect.Descriptor instead.

func (*UnplugResponse) ProtoMessage

func (*UnplugResponse) ProtoMessage()

func (*UnplugResponse) ProtoReflect

func (x *UnplugResponse) ProtoReflect() protoreflect.Message

func (*UnplugResponse) Reset

func (x *UnplugResponse) Reset()

func (*UnplugResponse) String

func (x *UnplugResponse) String() string

type UnsafeEVChargerApiServer

type UnsafeEVChargerApiServer interface {
	// contains filtered or unexported methods
}

UnsafeEVChargerApiServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to EVChargerApiServer will result in compilation errors.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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