diff --git a/fsmPev.py b/fsmPev.py index 8f19401..b3285cd 100644 --- a/fsmPev.py +++ b/fsmPev.py @@ -118,6 +118,7 @@ class fsmPev(): # We just use the initial request message from the Ioniq. It contains one entry: DIN. self.addToTrace("Sending the initial SupportedApplicationProtocolReq") self.Tcp.transmit(addV2GTPHeader(exiHexToByteArray(exiHexDemoSupportedApplicationProtocolRequestIoniq))) + self.hardwareInterface.resetSimulation() self.enterState(stateWaitForSupportedApplicationProtocolResponse) def stateFunctionWaitForSupportedApplicationProtocolResponse(self): @@ -313,6 +314,7 @@ class fsmPev(): self.enterState(stateSequenceTimeout) def stateFunctionWaitForPreChargeResponse(self): + self.hardwareInterface.simulatePreCharge() if (self.DelayCycles>0): self.DelayCycles-=1 return @@ -325,6 +327,9 @@ class fsmPev(): if (strConverterResult.find("PreChargeRes")>0): # todo: check the request content, and fill response parameters 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): self.addToTrace("Difference between accu voltage and inlet voltage is small. Sending PowerDeliveryReq.") self.hardwareInterface.setPowerRelayOn() diff --git a/hardwareInterface.py b/hardwareInterface.py index 0c16a7e..714efe1 100644 --- a/hardwareInterface.py +++ b/hardwareInterface.py @@ -52,7 +52,7 @@ class hardwareInterface(): def getInletVoltage(self): #todo: get real measured voltage from the inlet - self.inletVoltage = 230 + self.inletVoltage = self.simulatedInletVoltage return self.inletVoltage def getAccuVoltage(self): @@ -87,6 +87,14 @@ class hardwareInterface(): self.simulatedSoc = 20.0 # percent self.inletVoltage = 0.0 # volts 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): if (self.isInterfaceOk):