mirror of
https://github.com/uhi22/pyPLC.git
synced 2024-11-20 01:13:58 +00:00
loops for ChargeParameterDiscovery and CableCheck
This commit is contained in:
parent
0f7c7122b5
commit
a512f8294d
2 changed files with 53 additions and 23 deletions
|
@ -265,15 +265,12 @@ def testTimeConsumption():
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
nFail=0
|
nFail=0
|
||||||
print("Testing exiConnector...")
|
print("Testing exiConnector...")
|
||||||
|
if (False):
|
||||||
testTimeConsumption()
|
testTimeConsumption()
|
||||||
exit()
|
exit()
|
||||||
#testReadExiFromFile()
|
if (False):
|
||||||
#exit()
|
testReadExiFromFile()
|
||||||
#testByteArrayConversion("123456")
|
exit()
|
||||||
#testByteArrayConversion("1234567")
|
|
||||||
#testByteArrayConversion("ABCDEF")
|
|
||||||
#testByteArrayConversion("00112233445566778899AABBCCDDEEFF")
|
|
||||||
#testByteArrayConversion("TRASH!")
|
|
||||||
|
|
||||||
if (False):
|
if (False):
|
||||||
testDecoder("8000ebab9371d34b9b79d189a98989c1d191d191818981d26b9b3a232b30010000040001b75726e3a64696e3a37303132313a323031323a4d73674465660020000100880", pre="DH", comment="supportedAppProtocolReq")
|
testDecoder("8000ebab9371d34b9b79d189a98989c1d191d191818981d26b9b3a232b30010000040001b75726e3a64696e3a37303132313a323031323a4d73674465660020000100880", pre="DH", comment="supportedAppProtocolReq")
|
||||||
|
@ -295,7 +292,7 @@ if __name__ == "__main__":
|
||||||
if (False):
|
if (False):
|
||||||
print("The request from the Ioniq after the EVSE sent ServicePaymentSelectionRes:")
|
print("The request from the Ioniq after the EVSE sent ServicePaymentSelectionRes:")
|
||||||
testDecoder("809A00113020000A00000000", pre="DD", comment="PowerDeliveryReq")
|
testDecoder("809A00113020000A00000000", pre="DD", comment="PowerDeliveryReq")
|
||||||
if (True):
|
if (False):
|
||||||
print("The session setup request of the Ioniq:")
|
print("The session setup request of the Ioniq:")
|
||||||
testDecoder("809A02000000000000000011D01811959401930C00", pre="DD", comment="SessionSetupReq")
|
testDecoder("809A02000000000000000011D01811959401930C00", pre="DD", comment="SessionSetupReq")
|
||||||
testDecoder("80 9A 02 00 40 80 C1 01 41 81 C2 11 E0 00 00 80", pre="DD", comment="SessionSetupRes")
|
testDecoder("80 9A 02 00 40 80 C1 01 41 81 C2 11 E0 00 00 80", pre="DD", comment="SessionSetupRes")
|
||||||
|
@ -308,6 +305,9 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
print("The request of the Ioniq after ServicePaymentSelectionResponse")
|
print("The request of the Ioniq after ServicePaymentSelectionResponse")
|
||||||
testDecoder("80 9A 02 00 40 80 C1 01 41 81 C2 10 B8", pre="DD", comment="ContractAuthenticationReq")
|
testDecoder("80 9A 02 00 40 80 C1 01 41 81 C2 10 B8", pre="DD", comment="ContractAuthenticationReq")
|
||||||
|
if (True):
|
||||||
|
print("The response of the Alpi chargeParameterDiscovery")
|
||||||
|
testDecoder("80 9A 02 00 00 00 00 03 1F DC 8B D0 80 02 00 00 00 00 00 10 00 2A 80 04 00 00 14 0C 00 40 80 E1 8A 3A 0A 0A 00 A0 60 60 00 08 0A 01 E2 30 30 06 10", pre="DD", comment="ChargeParameterDiscoveryRes")
|
||||||
|
|
||||||
|
|
||||||
if (False):
|
if (False):
|
||||||
|
|
36
fsmPev.py
36
fsmPev.py
|
@ -169,6 +169,7 @@ class fsmPev():
|
||||||
msg = addV2GTPHeader(exiEncode("EDE_"+self.sessionId)) # EDE for Encode, Din, ChargeParameterDiscovery.
|
msg = addV2GTPHeader(exiEncode("EDE_"+self.sessionId)) # EDE for Encode, Din, ChargeParameterDiscovery.
|
||||||
self.addToTrace("responding " + prettyHexMessage(msg))
|
self.addToTrace("responding " + prettyHexMessage(msg))
|
||||||
self.Tcp.transmit(msg)
|
self.Tcp.transmit(msg)
|
||||||
|
self.numberOfChargeParameterDiscoveryReq = 1 # first message
|
||||||
self.enterState(stateWaitForChargeParameterDiscoveryResponse)
|
self.enterState(stateWaitForChargeParameterDiscoveryResponse)
|
||||||
else:
|
else:
|
||||||
# Not (yet) finished.
|
# Not (yet) finished.
|
||||||
|
@ -189,6 +190,8 @@ class fsmPev():
|
||||||
self.enterState(stateSequenceTimeout)
|
self.enterState(stateSequenceTimeout)
|
||||||
|
|
||||||
def stateFunctionWaitForChargeParameterDiscoveryResponse(self):
|
def stateFunctionWaitForChargeParameterDiscoveryResponse(self):
|
||||||
|
if (self.cyclesInState<30): # The first second in the state just do nothing.
|
||||||
|
return
|
||||||
if (len(self.rxData)>0):
|
if (len(self.rxData)>0):
|
||||||
self.addToTrace("In state WaitForChargeParameterDiscoveryResponse, received " + prettyHexMessage(self.rxData))
|
self.addToTrace("In state WaitForChargeParameterDiscoveryResponse, received " + prettyHexMessage(self.rxData))
|
||||||
exidata = removeV2GTPHeader(self.rxData)
|
exidata = removeV2GTPHeader(self.rxData)
|
||||||
|
@ -196,18 +199,38 @@ class fsmPev():
|
||||||
strConverterResult = exiDecode(exidata, "DD") # Decode DIN
|
strConverterResult = exiDecode(exidata, "DD") # Decode DIN
|
||||||
self.addToTrace(strConverterResult)
|
self.addToTrace(strConverterResult)
|
||||||
if (strConverterResult.find("ChargeParameterDiscoveryRes")>0):
|
if (strConverterResult.find("ChargeParameterDiscoveryRes")>0):
|
||||||
# todo: check the request content, and fill response parameters
|
# We can have two cases here:
|
||||||
# todo: if the response is "OK", pull the CP line to state C here.
|
# (A) The charger needs more time to show the charge parameters.
|
||||||
|
# (B) The charger finished to tell the charge parameters.
|
||||||
|
if (strConverterResult.find('"EVSEProcessing": "Finished"')>0):
|
||||||
|
self.addToTrace("It is Finished. Will change to state C and send CableCheckReq.")
|
||||||
|
# todo: pull the CP line to state C here.
|
||||||
# self.hardwareInterface.changeToStateC()
|
# self.hardwareInterface.changeToStateC()
|
||||||
self.addToTrace("Will send CableCheckReq")
|
|
||||||
msg = addV2GTPHeader(exiEncode("EDF_"+self.sessionId)) # EDF for Encode, Din, CableCheck
|
msg = addV2GTPHeader(exiEncode("EDF_"+self.sessionId)) # EDF for Encode, Din, CableCheck
|
||||||
self.addToTrace("responding " + prettyHexMessage(msg))
|
self.addToTrace("responding " + prettyHexMessage(msg))
|
||||||
self.Tcp.transmit(msg)
|
self.Tcp.transmit(msg)
|
||||||
|
self.numberOfCableCheckReq = 1 # This is the first request.
|
||||||
self.enterState(stateWaitForCableCheckResponse)
|
self.enterState(stateWaitForCableCheckResponse)
|
||||||
|
else:
|
||||||
|
# Not (yet) finished.
|
||||||
|
if (self.numberOfChargeParameterDiscoveryReq>=20): # approx 20 seconds, should be sufficient for the charger to find its parameters...
|
||||||
|
self.addToTrace("ChargeParameterDiscovery lasted too long. " + str(self.numberOfChargeParameterDiscoveryReq) + " Giving up.")
|
||||||
|
self.enterState(stateSequenceTimeout)
|
||||||
|
else:
|
||||||
|
# Try again.
|
||||||
|
self.numberOfChargeParameterDiscoveryReq += 1 # count the number of tries.
|
||||||
|
self.addToTrace("Not (yet) finished. Will again send ChargeParameterDiscoveryReq #" + str(self.numberOfChargeParameterDiscoveryReq))
|
||||||
|
msg = addV2GTPHeader(exiEncode("EDE_"+self.sessionId)) # EDE for Encode, Din, ChargeParameterDiscovery.
|
||||||
|
self.addToTrace("responding " + prettyHexMessage(msg))
|
||||||
|
self.Tcp.transmit(msg)
|
||||||
|
# we stay in the same state
|
||||||
|
self.enterState(stateWaitForChargeParameterDiscoveryResponse)
|
||||||
if (self.isTooLong()):
|
if (self.isTooLong()):
|
||||||
self.enterState(stateSequenceTimeout)
|
self.enterState(stateSequenceTimeout)
|
||||||
|
|
||||||
def stateFunctionWaitForCableCheckResponse(self):
|
def stateFunctionWaitForCableCheckResponse(self):
|
||||||
|
if (self.cyclesInState<30): # The first second in the state just do nothing.
|
||||||
|
return
|
||||||
if (len(self.rxData)>0):
|
if (len(self.rxData)>0):
|
||||||
self.addToTrace("In state WaitForCableCheckResponse, received " + prettyHexMessage(self.rxData))
|
self.addToTrace("In state WaitForCableCheckResponse, received " + prettyHexMessage(self.rxData))
|
||||||
exidata = removeV2GTPHeader(self.rxData)
|
exidata = removeV2GTPHeader(self.rxData)
|
||||||
|
@ -233,12 +256,19 @@ class fsmPev():
|
||||||
self.addToTrace("responding " + prettyHexMessage(msg))
|
self.addToTrace("responding " + prettyHexMessage(msg))
|
||||||
self.Tcp.transmit(msg)
|
self.Tcp.transmit(msg)
|
||||||
self.enterState(stateWaitForPreChargeResponse)
|
self.enterState(stateWaitForPreChargeResponse)
|
||||||
|
else:
|
||||||
|
if (self.numberOfCableCheckReq>30): # approx 30s should be sufficient for cable check
|
||||||
|
self.addToTrace("CableCheck lasted too long. " + str(self.numberOfCableCheckReq) + " Giving up.")
|
||||||
|
self.enterState(stateSequenceTimeout)
|
||||||
else:
|
else:
|
||||||
# cable check not yet finished or finished with bad result -> try again
|
# cable check not yet finished or finished with bad result -> try again
|
||||||
|
self.numberOfCableCheckReq += 1
|
||||||
self.addToTrace("Will again send CableCheckReq")
|
self.addToTrace("Will again send CableCheckReq")
|
||||||
msg = addV2GTPHeader(exiEncode("EDF_"+self.sessionId)) # EDF for Encode, Din, CableCheck
|
msg = addV2GTPHeader(exiEncode("EDF_"+self.sessionId)) # EDF for Encode, Din, CableCheck
|
||||||
self.addToTrace("responding " + prettyHexMessage(msg))
|
self.addToTrace("responding " + prettyHexMessage(msg))
|
||||||
self.Tcp.transmit(msg)
|
self.Tcp.transmit(msg)
|
||||||
|
# stay in the same state
|
||||||
|
self.enterState(stateWaitForCableCheckResponse)
|
||||||
|
|
||||||
if (self.isTooLong()):
|
if (self.isTooLong()):
|
||||||
self.enterState(stateSequenceTimeout)
|
self.enterState(stateSequenceTimeout)
|
||||||
|
|
Loading…
Reference in a new issue