EvseMode: simulated voltage during PreCharge and Charging

This commit is contained in:
uhi22 2023-03-29 08:44:09 +02:00
parent 223c70dc86
commit a2cbd78660

View file

@ -57,6 +57,7 @@ class fsmEvse():
def stateFunctionWaitForSessionSetupRequest(self): def stateFunctionWaitForSessionSetupRequest(self):
if (len(self.rxData)>0): if (len(self.rxData)>0):
self.simulatedPresentVoltage = 0
self.addToTrace("In state WaitForSessionSetupRequest, received " + prettyHexMessage(self.rxData)) self.addToTrace("In state WaitForSessionSetupRequest, received " + prettyHexMessage(self.rxData))
exidata = removeV2GTPHeader(self.rxData) exidata = removeV2GTPHeader(self.rxData)
self.rxData = [] self.rxData = []
@ -136,10 +137,13 @@ class fsmEvse():
self.enterState(stateWaitForFlexibleRequest) # todo: not clear, what is specified in DIN self.enterState(stateWaitForFlexibleRequest) # todo: not clear, what is specified in DIN
if (strConverterResult.find("PreChargeReq")>0): if (strConverterResult.find("PreChargeReq")>0):
# todo: check the request content, and fill response parameters # todo: check the request content, and fill response parameters
strPresentVoltage = "345" # simulating preCharge
if (self.simulatedPresentVoltage<300):
self.simulatedPresentVoltage += 10
strPresentVoltage = str(self.simulatedPresentVoltage) # "345"
msg = addV2GTPHeader(exiEncode("EDg_"+strPresentVoltage)) # EDg for Encode, Din, PreChargeResponse msg = addV2GTPHeader(exiEncode("EDg_"+strPresentVoltage)) # EDg for Encode, Din, PreChargeResponse
self.addToTrace("responding " + prettyHexMessage(msg)) self.addToTrace("responding " + prettyHexMessage(msg))
self.publishStatus("PreCharging") self.publishStatus("PreCharging " + strPresentVoltage)
self.Tcp.transmit(msg) self.Tcp.transmit(msg)
self.enterState(stateWaitForFlexibleRequest) # todo: not clear, what is specified in DIN self.enterState(stateWaitForFlexibleRequest) # todo: not clear, what is specified in DIN
if (strConverterResult.find("ContractAuthenticationReq")>0): if (strConverterResult.find("ContractAuthenticationReq")>0):
@ -151,7 +155,11 @@ class fsmEvse():
self.enterState(stateWaitForFlexibleRequest) # todo: not clear, what is specified in DIN self.enterState(stateWaitForFlexibleRequest) # todo: not clear, what is specified in DIN
if (strConverterResult.find("CurrentDemandReq")>0): if (strConverterResult.find("CurrentDemandReq")>0):
# todo: check the request content, and fill response parameters # todo: check the request content, and fill response parameters
msg = addV2GTPHeader(exiEncode("EDi")) # EDi for Encode, Din, CurrentDemandRes if (self.simulatedPresentVoltage<300):
self.simulatedPresentVoltage += 1;
strPresentVoltage = str(self.simulatedPresentVoltage)
strEVSEPresentCurrent = "10" # Just as a dummy current
msg = addV2GTPHeader(exiEncode("EDi_"+strPresentVoltage + "_" + strEVSEPresentCurrent)) # EDi for Encode, Din, CurrentDemandRes
self.addToTrace("responding " + prettyHexMessage(msg)) self.addToTrace("responding " + prettyHexMessage(msg))
self.publishStatus("CurrentDemand") self.publishStatus("CurrentDemand")
self.Tcp.transmit(msg) self.Tcp.transmit(msg)
@ -215,6 +223,7 @@ class fsmEvse():
self.state = 0 self.state = 0
self.cyclesInState = 0 self.cyclesInState = 0
self.rxData = [] self.rxData = []
self.simulatedPresentVoltage = 0
self.Tcp.resetTheConnection() self.Tcp.resetTheConnection()
def socketStateNotification(self, notification): def socketStateNotification(self, notification):