feature: clear state names for the logging in PevMode. Added time stamp in log.

This commit is contained in:
uhi22 2023-04-11 22:09:26 +02:00
parent f0781f5abf
commit fd56535cb7
3 changed files with 49 additions and 3 deletions

View file

@ -56,6 +56,44 @@ class fsmPev():
self.exiLogFile.write(strDateTime + "=" + schema + " " + s +"\n") # write the EXI data to the exiLogFile self.exiLogFile.write(strDateTime + "=" + schema + " " + s +"\n") # write the EXI data to the exiLogFile
return exidata return exidata
def prettifyState(self, statenumber):
s="unknownState"
if (statenumber == stateNotYetInitialized):
s = "NotYetInitialized"
if (statenumber == stateConnecting):
s = "Connecting"
if (statenumber == stateConnected):
s = "Connected"
if (statenumber == stateWaitForSupportedApplicationProtocolResponse):
s = "WaitForSupportedApplicationProtocolResponse"
if (statenumber == stateWaitForSessionSetupResponse):
s = "WaitForSessionSetupResponse"
if (statenumber == stateWaitForServiceDiscoveryResponse):
s = "WaitForServiceDiscoveryResponse"
if (statenumber == stateWaitForServicePaymentSelectionResponse):
s = "WaitForServicePaymentSelectionResponse"
if (statenumber == stateWaitForContractAuthenticationResponse):
s = "WaitForContractAuthenticationResponse"
if (statenumber == stateWaitForChargeParameterDiscoveryResponse):
s = "WaitForChargeParameterDiscoveryResponse"
if (statenumber == stateWaitForCableCheckResponse):
s = "WaitForCableCheckResponse"
if (statenumber == stateWaitForPreChargeResponse):
s = "WaitForPreChargeResponse"
if (statenumber == stateWaitForPowerDeliveryResponse):
s = "WaitForPowerDeliveryResponse"
if (statenumber == stateWaitForCurrentDemandResponse):
s = "WaitForCurrentDemandResponse"
if (statenumber == stateWaitForWeldingDetectionResponse):
s = "WaitForWeldingDetectionResponse"
if (statenumber == stateWaitForSessionStopResponse):
s = "WaitForSessionStopResponse"
if (statenumber == stateChargingFinished):
s = "ChargingFinished"
if (statenumber == stateSequenceTimeout):
s = "SequenceTimeout"
return s
def sendChargeParameterDiscoveryReq(self): def sendChargeParameterDiscoveryReq(self):
soc = str(self.hardwareInterface.getSoc()) soc = str(self.hardwareInterface.getSoc())
msg = addV2GTPHeader(self.exiEncode("EDE_"+self.sessionId + "_" + soc)) # EDE for Encode, Din, ChargeParameterDiscovery. msg = addV2GTPHeader(self.exiEncode("EDE_"+self.sessionId + "_" + soc)) # EDE for Encode, Din, ChargeParameterDiscovery.
@ -84,7 +122,7 @@ class fsmPev():
self.Tcp.transmit(msg) self.Tcp.transmit(msg)
def enterState(self, n): def enterState(self, n):
print("from " + str(self.state) + " entering " + str(n)) self.addToTrace("from " + str(self.state) + ":" + self.prettifyState(self.state) + " entering " + str(n) + ":" + self.prettifyState(n))
self.state = n self.state = n
self.cyclesInState = 0 self.cyclesInState = 0

View file

@ -6,8 +6,12 @@ import pyPlcWorker
from pyPlcModes import * from pyPlcModes import *
import sys # for argv import sys # for argv
startTime_ms = round(time.time()*1000)
def cbAddToTrace(s): def cbAddToTrace(s):
print(s) currentTime_ms = round(time.time()*1000)
dT_ms = currentTime_ms - startTime_ms
print("[" + str(dT_ms) + "ms] " + s)
def cbShowStatus(s, selection=""): def cbShowStatus(s, selection=""):
pass pass

View file

@ -12,6 +12,8 @@ import pyPlcWorker
from pyPlcModes import * from pyPlcModes import *
import sys # for argv import sys # for argv
startTime_ms = round(time.time()*1000)
def storekeyname(event): def storekeyname(event):
global nKeystrokes global nKeystrokes
global lastKey global lastKey
@ -26,7 +28,9 @@ def inkey():
lastKey = '' lastKey = ''
def cbAddToTrace(s): def cbAddToTrace(s):
print(s) currentTime_ms = round(time.time()*1000)
dT_ms = currentTime_ms - startTime_ms
print("[" + str(dT_ms) + "ms] " + s)
def cbShowStatus(s, selection=""): def cbShowStatus(s, selection=""):
#print(s) #print(s)