mirror of
https://github.com/uhi22/pyPLC.git
synced 2024-11-20 01:13:58 +00:00
feature: EvseMode: contract authentication asks the hardwareinterface whether the user is authenticated
This commit is contained in:
parent
56a4c909e0
commit
1171d34d28
2 changed files with 30 additions and 3 deletions
19
fsmEvse.py
19
fsmEvse.py
|
@ -280,8 +280,14 @@ class fsmEvse():
|
|||
self.Tcp.transmit(msg)
|
||||
self.enterState(stateWaitForFlexibleRequest) # todo: not clear, what is specified in DIN
|
||||
if (strConverterResult.find("ContractAuthenticationReq")>0):
|
||||
# todo: check the request content, and fill response parameters
|
||||
msg = addV2GTPHeader(exiEncode("EDl")) # EDl for Encode, Din, ContractAuthenticationResponse
|
||||
# Ask the hardwareInterface, whether the user already presented a valid RFID or similar
|
||||
if (self.hardwareInterface.isUserAuthenticated()):
|
||||
strAuthFinished = "1"
|
||||
self.addToTrace("Contract is fine")
|
||||
else:
|
||||
strAuthFinished = "0"
|
||||
self.addToTrace("Contract is not (yet) fine")
|
||||
msg = addV2GTPHeader(exiEncode("EDl_" + strAuthFinished)) # EDl for Encode, Din, ContractAuthenticationResponse
|
||||
if (testsuite_faultinjection_is_triggered(TC_EVSE_ResponseCode_SequenceError_for_ContractAuthenticationRes)):
|
||||
# send a ContractAuthenticationResponse with Responsecode SequenceError
|
||||
msg = addV2GTPHeader("809a021a3b7c417774813310c0A200")
|
||||
|
@ -291,7 +297,14 @@ class fsmEvse():
|
|||
self.Tcp.transmit(msg)
|
||||
self.enterState(stateWaitForFlexibleRequest) # todo: not clear, what is specified in DIN
|
||||
if (strConverterResult.find("AuthorizationReq")>0):
|
||||
msg = addV2GTPHeader(exiEncode("E"+self.schemaSelection+"l")) # E1l for Encode, Iso1, AuthorizationResponse
|
||||
# Ask the hardwareInterface, whether the user already presented a valid RFID or similar
|
||||
if (self.hardwareInterface.isUserAuthenticated()):
|
||||
strAuthFinished = "1"
|
||||
self.addToTrace("User is Authorized")
|
||||
else:
|
||||
strAuthFinished = "0"
|
||||
self.addToTrace("User is not (yet) authorized")
|
||||
msg = addV2GTPHeader(exiEncode("E"+self.schemaSelection+"l_" + strAuthFinished)) # E1l for Encode, Iso1, AuthorizationResponse
|
||||
self.addToTrace("responding " + prettyHexMessage(msg))
|
||||
self.showDecodedTransmitMessage(msg)
|
||||
self.publishStatus("Authorization")
|
||||
|
|
|
@ -215,6 +215,18 @@ class hardwareInterface():
|
|||
self.callbackShowStatus(format(self.simulatedSoc,".1f"), "soc")
|
||||
return self.simulatedSoc
|
||||
|
||||
def isUserAuthenticated(self):
|
||||
# If the user needs to authorize, fill this function in a way that it returns False as long as
|
||||
# we shall wait for the users authorization, and returns True if the authentication was successfull.
|
||||
# Discussing here: https://github.com/uhi22/pyPLC/issues/28#issuecomment-2230656379
|
||||
# For testing purposes, we just use a counter to decide that we return
|
||||
# once "ongoing" and then "finished".
|
||||
if (self.demoAuthenticationCounter<1):
|
||||
self.demoAuthenticationCounter += 1
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def initPorts(self):
|
||||
if (getConfigValue("charge_parameter_backend") == "chademo"):
|
||||
filters = [
|
||||
|
@ -236,6 +248,7 @@ class hardwareInterface():
|
|||
self.loopcounter = 0
|
||||
self.outvalue = 0
|
||||
self.simulatedSoc = 20.0 # percent
|
||||
self.demoAuthenticationCounter = 0
|
||||
|
||||
self.inletVoltage = 0.0 # volts
|
||||
self.accuVoltage = 0.0
|
||||
|
@ -270,6 +283,7 @@ class hardwareInterface():
|
|||
def resetSimulation(self):
|
||||
self.simulatedInletVoltage = 0.0 # volts
|
||||
self.simulatedSoc = 20.0 # percent
|
||||
self.demoAuthenticationCounter = 0
|
||||
|
||||
def simulatePreCharge(self):
|
||||
if (self.simulatedInletVoltage<230):
|
||||
|
|
Loading…
Reference in a new issue