mirror of
https://github.com/uhi22/pyPLC.git
synced 2024-11-20 01:13:58 +00:00
feature: clear state names for the logging in PevMode. Added time stamp in log.
This commit is contained in:
parent
f0781f5abf
commit
fd56535cb7
3 changed files with 49 additions and 3 deletions
40
fsmPev.py
40
fsmPev.py
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
6
pyPlc.py
6
pyPlc.py
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue