mirror of
https://github.com/uhi22/pyPLC.git
synced 2024-11-20 01:13:58 +00:00
added PreCharge simulation
This commit is contained in:
parent
9b4b825326
commit
cdbd639c94
2 changed files with 14 additions and 1 deletions
|
@ -118,6 +118,7 @@ class fsmPev():
|
||||||
# We just use the initial request message from the Ioniq. It contains one entry: DIN.
|
# We just use the initial request message from the Ioniq. It contains one entry: DIN.
|
||||||
self.addToTrace("Sending the initial SupportedApplicationProtocolReq")
|
self.addToTrace("Sending the initial SupportedApplicationProtocolReq")
|
||||||
self.Tcp.transmit(addV2GTPHeader(exiHexToByteArray(exiHexDemoSupportedApplicationProtocolRequestIoniq)))
|
self.Tcp.transmit(addV2GTPHeader(exiHexToByteArray(exiHexDemoSupportedApplicationProtocolRequestIoniq)))
|
||||||
|
self.hardwareInterface.resetSimulation()
|
||||||
self.enterState(stateWaitForSupportedApplicationProtocolResponse)
|
self.enterState(stateWaitForSupportedApplicationProtocolResponse)
|
||||||
|
|
||||||
def stateFunctionWaitForSupportedApplicationProtocolResponse(self):
|
def stateFunctionWaitForSupportedApplicationProtocolResponse(self):
|
||||||
|
@ -313,6 +314,7 @@ class fsmPev():
|
||||||
self.enterState(stateSequenceTimeout)
|
self.enterState(stateSequenceTimeout)
|
||||||
|
|
||||||
def stateFunctionWaitForPreChargeResponse(self):
|
def stateFunctionWaitForPreChargeResponse(self):
|
||||||
|
self.hardwareInterface.simulatePreCharge()
|
||||||
if (self.DelayCycles>0):
|
if (self.DelayCycles>0):
|
||||||
self.DelayCycles-=1
|
self.DelayCycles-=1
|
||||||
return
|
return
|
||||||
|
@ -325,6 +327,9 @@ class fsmPev():
|
||||||
if (strConverterResult.find("PreChargeRes")>0):
|
if (strConverterResult.find("PreChargeRes")>0):
|
||||||
# todo: check the request content, and fill response parameters
|
# todo: check the request content, and fill response parameters
|
||||||
self.addToTrace("PreCharge aknowledge received.")
|
self.addToTrace("PreCharge aknowledge received.")
|
||||||
|
s = "U_Inlet " + str(self.hardwareInterface.getInletVoltage()) + "V, "
|
||||||
|
s= s + "U_Accu " + str(self.hardwareInterface.getAccuVoltage()) + "V"
|
||||||
|
self.addToTrace(s)
|
||||||
if (abs(self.hardwareInterface.getInletVoltage()-self.hardwareInterface.getAccuVoltage()) < PARAM_U_DELTA_MAX_FOR_END_OF_PRECHARGE):
|
if (abs(self.hardwareInterface.getInletVoltage()-self.hardwareInterface.getAccuVoltage()) < PARAM_U_DELTA_MAX_FOR_END_OF_PRECHARGE):
|
||||||
self.addToTrace("Difference between accu voltage and inlet voltage is small. Sending PowerDeliveryReq.")
|
self.addToTrace("Difference between accu voltage and inlet voltage is small. Sending PowerDeliveryReq.")
|
||||||
self.hardwareInterface.setPowerRelayOn()
|
self.hardwareInterface.setPowerRelayOn()
|
||||||
|
|
|
@ -52,7 +52,7 @@ class hardwareInterface():
|
||||||
|
|
||||||
def getInletVoltage(self):
|
def getInletVoltage(self):
|
||||||
#todo: get real measured voltage from the inlet
|
#todo: get real measured voltage from the inlet
|
||||||
self.inletVoltage = 230
|
self.inletVoltage = self.simulatedInletVoltage
|
||||||
return self.inletVoltage
|
return self.inletVoltage
|
||||||
|
|
||||||
def getAccuVoltage(self):
|
def getAccuVoltage(self):
|
||||||
|
@ -88,6 +88,14 @@ class hardwareInterface():
|
||||||
self.inletVoltage = 0.0 # volts
|
self.inletVoltage = 0.0 # volts
|
||||||
self.findSerialPort()
|
self.findSerialPort()
|
||||||
|
|
||||||
|
def resetSimulation(self):
|
||||||
|
self.simulatedInletVoltage = 0.0 # volts
|
||||||
|
self.simulatedSoc = 20.0 # percent
|
||||||
|
|
||||||
|
def simulatePreCharge(self):
|
||||||
|
if (self.simulatedInletVoltage<230):
|
||||||
|
self.simulatedInletVoltage = self.simulatedInletVoltage + 1.0 # simulate increasing voltage during PreCharge
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
if (self.isInterfaceOk):
|
if (self.isInterfaceOk):
|
||||||
self.ser.close()
|
self.ser.close()
|
||||||
|
|
Loading…
Reference in a new issue