Skip to content

Commit

Permalink
Merge branch 'stop_inc_reqs' into gridx_master_ng
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbeaumont committed Aug 12, 2021
2 parents 7da92ae + f332eda commit bf1d870
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ocpp1.6/charge_point.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ocpp16

import (
"fmt"
"sync"

"github.com/lorenzodonini/ocpp-go/internal/callbackqueue"
"github.com/lorenzodonini/ocpp-go/ocpp"
Expand All @@ -28,6 +29,7 @@ type chargePoint struct {
callbacks callbackqueue.CallbackQueue
stopC chan struct{}
errC chan error // external error channel
incomingWaitGroup sync.WaitGroup
}

func (cp *chargePoint) error(err error) {
Expand Down Expand Up @@ -332,8 +334,9 @@ func (cp *chargePoint) Start(centralSystemUrl string) error {
}

func (cp *chargePoint) Stop() {
cp.client.Stop()
close(cp.stopC)
cp.incomingWaitGroup.Wait()
cp.client.Stop()

if cp.errC != nil {
close(cp.errC)
Expand All @@ -358,6 +361,13 @@ func (cp *chargePoint) notSupportedError(requestId string, action string) {
}

func (cp *chargePoint) handleIncomingRequest(request ocpp.Request, requestId string, action string) {
cp.incomingWaitGroup.Add(1)
defer cp.incomingWaitGroup.Done()
select {
case <-cp.stopC:
return
default:
}
profile, found := cp.client.GetProfileForFeature(action)
// Check whether action is supported and a handler for it exists
if !found {
Expand Down

0 comments on commit bf1d870

Please sign in to comment.