mirror of
https://github.com/uhi22/pyPLC.git
synced 2024-11-10 01:05:42 +00:00
cleanup: use same name jsondict in all files and functions
This commit is contained in:
parent
5f1d281c7a
commit
0a4b91e870
4 changed files with 64 additions and 64 deletions
|
@ -218,9 +218,9 @@ def exiEncode(strMessageName):
|
|||
# "result": "8004440400"
|
||||
# }
|
||||
try:
|
||||
y = json.loads(result.stdout)
|
||||
strConverterResult = y["result"]
|
||||
strConverterError = y["error"]
|
||||
jsondict = json.loads(result.stdout)
|
||||
strConverterResult = jsondict["result"]
|
||||
strConverterError = jsondict["error"]
|
||||
if (len(strConverterError)>0):
|
||||
print("[EXICONNECTOR] exiEncode error " + strConverterError)
|
||||
#print("strConverterResult is " + str(strConverterResult))
|
||||
|
|
50
fsmEvse.py
50
fsmEvse.py
|
@ -54,12 +54,12 @@ class fsmEvse():
|
|||
if (strConverterResult.find("supportedAppProtocolReq")>0):
|
||||
nDinSchemaID = 255 # invalid default value
|
||||
try:
|
||||
y = json.loads(strConverterResult)
|
||||
nAppProtocol_ArrayLen = int(y["AppProtocol_arrayLen"])
|
||||
jsondict = json.loads(strConverterResult)
|
||||
nAppProtocol_ArrayLen = int(jsondict["AppProtocol_arrayLen"])
|
||||
self.addToTrace("The car supports " + str(nAppProtocol_ArrayLen) + " schemas.")
|
||||
for i in range(nAppProtocol_ArrayLen):
|
||||
strNameSpace = y["NameSpace_"+str(i)]
|
||||
nSchemaId = int(y["SchemaID_"+str(i)])
|
||||
strNameSpace = jsondict["NameSpace_"+str(i)]
|
||||
nSchemaId = int(jsondict["SchemaID_"+str(i)])
|
||||
self.addToTrace("The NameSpace " + strNameSpace + " has SchemaID " + str(nSchemaId))
|
||||
if (strNameSpace.find(":din:70121:")>0):
|
||||
nDinSchemaID = nSchemaId
|
||||
|
@ -97,8 +97,8 @@ class fsmEvse():
|
|||
self.Tcp.transmit(msg)
|
||||
self.publishStatus("Session established")
|
||||
self.enterState(stateWaitForServiceDiscoveryRequest)
|
||||
y = json.loads(strConverterResult)
|
||||
self.evccid = y.get("EVCCID", "")
|
||||
jsondict = json.loads(strConverterResult)
|
||||
self.evccid = jsondict.get("EVCCID", "")
|
||||
|
||||
if (self.isTooLong()):
|
||||
self.enterState(0)
|
||||
|
@ -153,8 +153,8 @@ class fsmEvse():
|
|||
if (strConverterResult.find("PowerDeliveryReq")>0):
|
||||
# todo: check the request content, and fill response parameters
|
||||
self.addToTrace("Received PowerDeliveryReq. Extracting SoC parameters")
|
||||
info = json.loads(strConverterResult)
|
||||
current_soc = int(info.get("EVRESSSOC", -1))
|
||||
jsondict = json.loads(strConverterResult)
|
||||
current_soc = int(jsondict.get("EVRESSSOC", -1))
|
||||
self.publishSoCs(current_soc, origin="PowerDeliveryReq")
|
||||
msg = addV2GTPHeader(exiEncode("EDh")) # EDh for Encode, Din, PowerDeliveryResponse
|
||||
if (testsuite_faultinjection_is_triggered(TC_EVSE_ResponseCode_Failed_for_PowerDeliveryRes)):
|
||||
|
@ -166,11 +166,11 @@ class fsmEvse():
|
|||
self.enterState(stateWaitForFlexibleRequest) # todo: not clear, what is specified in DIN
|
||||
if (strConverterResult.find("ChargeParameterDiscoveryReq")>0):
|
||||
self.addToTrace("Received ChargeParameterDiscoveryReq. Extracting SoC parameters via DC")
|
||||
info = json.loads(strConverterResult)
|
||||
current_soc = int(info.get("DC_EVStatus.EVRESSSOC", -1))
|
||||
full_soc = int(info.get("FullSOC", -1))
|
||||
energy_capacity = int(info.get("EVEnergyCapacity.Value", -1))
|
||||
energy_request = int(info.get("EVEnergyRequest.Value", -1))
|
||||
jsondict = json.loads(strConverterResult)
|
||||
current_soc = int(jsondict.get("DC_EVStatus.EVRESSSOC", -1))
|
||||
full_soc = int(jsondict.get("FullSOC", -1))
|
||||
energy_capacity = int(jsondict.get("EVEnergyCapacity.Value", -1))
|
||||
energy_request = int(jsondict.get("EVEnergyRequest.Value", -1))
|
||||
self.publishSoCs(current_soc, full_soc, energy_capacity, energy_request, origin="ChargeParameterDiscoveryReq")
|
||||
|
||||
# todo: check the request content, and fill response parameters
|
||||
|
@ -186,8 +186,8 @@ class fsmEvse():
|
|||
# todo: check the request content, and fill response parameters
|
||||
# todo: make a real cable check, and while it is ongoing, send "Ongoing".
|
||||
self.addToTrace("Received CableCheckReq. Extracting SoC parameters via DC")
|
||||
info = json.loads(strConverterResult)
|
||||
current_soc = int(info.get("DC_EVStatus.EVRESSSOC", -1))
|
||||
jsondict = json.loads(strConverterResult)
|
||||
current_soc = int(jsondict.get("DC_EVStatus.EVRESSSOC", -1))
|
||||
self.publishSoCs(current_soc, -1, -1, origin="CableCheckReq")
|
||||
|
||||
msg = addV2GTPHeader(exiEncode("EDf")) # EDf for Encode, Din, CableCheckResponse
|
||||
|
@ -203,9 +203,9 @@ class fsmEvse():
|
|||
# check the request content, and fill response parameters
|
||||
uTarget = 220 # default in case we cannot decode the requested voltage
|
||||
try:
|
||||
y = json.loads(strConverterResult)
|
||||
strEVTargetVoltageValue = y["EVTargetVoltage.Value"]
|
||||
strEVTargetVoltageMultiplier = y["EVTargetVoltage.Multiplier"]
|
||||
jsondict = json.loads(strConverterResult)
|
||||
strEVTargetVoltageValue = jsondict["EVTargetVoltage.Value"]
|
||||
strEVTargetVoltageMultiplier = jsondict["EVTargetVoltage.Multiplier"]
|
||||
uTarget = combineValueAndMultiplier(strEVTargetVoltageValue, strEVTargetVoltageMultiplier)
|
||||
self.addToTrace("EV wants EVTargetVoltage " + str(uTarget))
|
||||
except:
|
||||
|
@ -246,15 +246,15 @@ class fsmEvse():
|
|||
# check the request content, and fill response parameters
|
||||
uTarget = 220 # default in case we cannot decode the requested voltage
|
||||
try:
|
||||
y = json.loads(strConverterResult)
|
||||
strEVTargetVoltageValue = y["EVTargetVoltage.Value"]
|
||||
strEVTargetVoltageMultiplier = y["EVTargetVoltage.Multiplier"]
|
||||
jsondict = json.loads(strConverterResult)
|
||||
strEVTargetVoltageValue = jsondict["EVTargetVoltage.Value"]
|
||||
strEVTargetVoltageMultiplier = jsondict["EVTargetVoltage.Multiplier"]
|
||||
uTarget = combineValueAndMultiplier(strEVTargetVoltageValue, strEVTargetVoltageMultiplier)
|
||||
self.addToTrace("EV wants EVTargetVoltage " + str(uTarget))
|
||||
current_soc = int(y.get("DC_EVStatus.EVRESSSOC", -1))
|
||||
full_soc = int(y.get("FullSOC", -1))
|
||||
energy_capacity = int(y.get("EVEnergyCapacity.Value", -1))
|
||||
energy_request = int(y.get("EVEnergyRequest.Value", -1))
|
||||
current_soc = int(jsondict.get("DC_EVStatus.EVRESSSOC", -1))
|
||||
full_soc = int(jsondict.get("FullSOC", -1))
|
||||
energy_capacity = int(jsondict.get("EVEnergyCapacity.Value", -1))
|
||||
energy_request = int(jsondict.get("EVEnergyRequest.Value", -1))
|
||||
|
||||
self.publishSoCs(current_soc, full_soc, energy_capacity, energy_request, origin="CurrentDemandReq")
|
||||
|
||||
|
|
60
fsmPev.py
60
fsmPev.py
|
@ -278,9 +278,9 @@ class fsmPev():
|
|||
# todo: check the request content, and fill response parameters
|
||||
strResponseCode = "na"
|
||||
try:
|
||||
y = json.loads(strConverterResult)
|
||||
strSessionId = y["header.SessionID"]
|
||||
strResponseCode = y["ResponseCode"]
|
||||
jsondict = json.loads(strConverterResult)
|
||||
strSessionId = jsondict["header.SessionID"]
|
||||
strResponseCode = jsondict["ResponseCode"]
|
||||
self.addToTrace("Checkpoint506: The Evse decided for SessionId " + strSessionId)
|
||||
self.publishStatus("Session established")
|
||||
self.sessionId = strSessionId
|
||||
|
@ -308,8 +308,8 @@ class fsmPev():
|
|||
if (strConverterResult.find("ServiceDiscoveryRes")>0):
|
||||
strResponseCode = "na"
|
||||
try:
|
||||
y = json.loads(strConverterResult)
|
||||
strResponseCode = y["ResponseCode"]
|
||||
jsondict = json.loads(strConverterResult)
|
||||
strResponseCode = jsondict["ResponseCode"]
|
||||
except:
|
||||
self.addToTrace("ERROR: Could not decode the ServiceDiscoveryResponse")
|
||||
if (strResponseCode!="OK"):
|
||||
|
@ -336,8 +336,8 @@ class fsmPev():
|
|||
# todo: check the request content, and fill response parameters
|
||||
strResponseCode = "na"
|
||||
try:
|
||||
y = json.loads(strConverterResult)
|
||||
strResponseCode = y["ResponseCode"]
|
||||
jsondict = json.loads(strConverterResult)
|
||||
strResponseCode = jsondict["ResponseCode"]
|
||||
except:
|
||||
self.addToTrace("ERROR: Could not decode the ServicePaymentSelectionResponse")
|
||||
if (strResponseCode!="OK"):
|
||||
|
@ -369,8 +369,8 @@ class fsmPev():
|
|||
# Or, the authorization is finished. This is shown by EVSEProcessing=Finished.
|
||||
strResponseCode = "na"
|
||||
try:
|
||||
y = json.loads(strConverterResult)
|
||||
strResponseCode = y["ResponseCode"]
|
||||
jsondict = json.loads(strConverterResult)
|
||||
strResponseCode = jsondict["ResponseCode"]
|
||||
except:
|
||||
self.addToTrace("ERROR: Could not decode the ContractAuthenticationResponse")
|
||||
if (strResponseCode!="OK"):
|
||||
|
@ -414,8 +414,8 @@ class fsmPev():
|
|||
if (strConverterResult.find("ChargeParameterDiscoveryRes")>0):
|
||||
strResponseCode = "na"
|
||||
try:
|
||||
y = json.loads(strConverterResult)
|
||||
strResponseCode = y["ResponseCode"]
|
||||
jsondict = json.loads(strConverterResult)
|
||||
strResponseCode = jsondict["ResponseCode"]
|
||||
except:
|
||||
self.addToTrace("ERROR: Could not decode the ChargeParameterDiscoveryResponse")
|
||||
if (strResponseCode!="OK"):
|
||||
|
@ -429,8 +429,8 @@ class fsmPev():
|
|||
self.publishStatus("ChargeParams discovered")
|
||||
self.addToTrace("Checkpoint550: ChargeParams are discovered. Will change to state C.")
|
||||
#Report charger paramters
|
||||
maxI = combineValueAndMultiplier(y["EVSEMaximumCurrentLimit.Value"], y["EVSEMaximumCurrentLimit.Multiplier"])
|
||||
maxV = combineValueAndMultiplier(y["EVSEMaximumVoltageLimit.Value"], y["EVSEMaximumVoltageLimit.Multiplier"])
|
||||
maxI = combineValueAndMultiplier(jsondict["EVSEMaximumCurrentLimit.Value"], jsondict["EVSEMaximumCurrentLimit.Multiplier"])
|
||||
maxV = combineValueAndMultiplier(jsondict["EVSEMaximumVoltageLimit.Value"], jsondict["EVSEMaximumVoltageLimit.Multiplier"])
|
||||
self.hardwareInterface.setChargerParameters(maxV, maxI)
|
||||
# pull the CP line to state C here:
|
||||
self.hardwareInterface.setStateC()
|
||||
|
@ -474,9 +474,9 @@ class fsmPev():
|
|||
if (strConverterResult.find("CableCheckRes")>0):
|
||||
strResponseCode = "na"
|
||||
try:
|
||||
y = json.loads(strConverterResult)
|
||||
strResponseCode = y["ResponseCode"]
|
||||
strEVSEProcessing = y["EVSEProcessing"]
|
||||
jsondict = json.loads(strConverterResult)
|
||||
strResponseCode = jsondict["ResponseCode"]
|
||||
strEVSEProcessing = jsondict["EVSEProcessing"]
|
||||
self.addToTrace("The CableCheck result is " + strResponseCode + " " + strEVSEProcessing)
|
||||
except:
|
||||
self.addToTrace("ERROR: Could not decode the CableCheckRes")
|
||||
|
@ -530,13 +530,13 @@ class fsmPev():
|
|||
strResponseCode = "na"
|
||||
strEVSEStatusCode = "0" # default in case the decoding does not work
|
||||
try:
|
||||
y = json.loads(strConverterResult)
|
||||
strResponseCode = y["ResponseCode"]
|
||||
strEVSEPresentVoltageValue = y["EVSEPresentVoltage.Value"]
|
||||
strEVSEPresentVoltageMultiplier = y["EVSEPresentVoltage.Multiplier"]
|
||||
jsondict = json.loads(strConverterResult)
|
||||
strResponseCode = jsondict["ResponseCode"]
|
||||
strEVSEPresentVoltageValue = jsondict["EVSEPresentVoltage.Value"]
|
||||
strEVSEPresentVoltageMultiplier = jsondict["EVSEPresentVoltage.Multiplier"]
|
||||
u = combineValueAndMultiplier(strEVSEPresentVoltageValue, strEVSEPresentVoltageMultiplier)
|
||||
self.callbackShowStatus(format(u,".1f"), "EVSEPresentVoltage")
|
||||
strEVSEStatusCode = y["DC_EVSEStatus.EVSEStatusCode"]
|
||||
strEVSEStatusCode = jsondict["DC_EVSEStatus.EVSEStatusCode"]
|
||||
except:
|
||||
self.addToTrace("ERROR: Could not decode the PreChargeResponse")
|
||||
self.addToTrace("PreChargeResponse received.")
|
||||
|
@ -612,8 +612,8 @@ class fsmPev():
|
|||
if (strConverterResult.find("PowerDeliveryRes")>0):
|
||||
strResponseCode = "na"
|
||||
try:
|
||||
y = json.loads(strConverterResult)
|
||||
strResponseCode = y["ResponseCode"]
|
||||
jsondict = json.loads(strConverterResult)
|
||||
strResponseCode = jsondict["ResponseCode"]
|
||||
except:
|
||||
self.addToTrace("ERROR: Could not decode the PowerDeliveryResponse")
|
||||
if (strResponseCode!="OK"):
|
||||
|
@ -653,16 +653,16 @@ class fsmPev():
|
|||
u = 0 # a default voltage of 0V in case we cannot convert the actual value
|
||||
strEVSEStatusCode = "0" # default in case the decoding does not work
|
||||
try:
|
||||
y = json.loads(strConverterResult)
|
||||
strResponseCode = y["ResponseCode"]
|
||||
strEVSEPresentVoltageValue = y["EVSEPresentVoltage.Value"]
|
||||
strEVSEPresentVoltageMultiplier = y["EVSEPresentVoltage.Multiplier"]
|
||||
strEVSEPresentCurrentValue = y["EVSEPresentCurrent.Value"]
|
||||
strEVSEPresentCurrentMultiplier = y["EVSEPresentCurrent.Multiplier"]
|
||||
jsondict = json.loads(strConverterResult)
|
||||
strResponseCode = jsondict["ResponseCode"]
|
||||
strEVSEPresentVoltageValue = jsondict["EVSEPresentVoltage.Value"]
|
||||
strEVSEPresentVoltageMultiplier = jsondict["EVSEPresentVoltage.Multiplier"]
|
||||
strEVSEPresentCurrentValue = jsondict["EVSEPresentCurrent.Value"]
|
||||
strEVSEPresentCurrentMultiplier = jsondict["EVSEPresentCurrent.Multiplier"]
|
||||
u = combineValueAndMultiplier(strEVSEPresentVoltageValue, strEVSEPresentVoltageMultiplier)
|
||||
i = combineValueAndMultiplier(strEVSEPresentCurrentValue, strEVSEPresentCurrentMultiplier)
|
||||
self.callbackShowStatus(format(u,".1f"), "EVSEPresentVoltage")
|
||||
strEVSEStatusCode = y["DC_EVSEStatus.EVSEStatusCode"]
|
||||
strEVSEStatusCode = jsondict["DC_EVSEStatus.EVSEStatusCode"]
|
||||
self.hardwareInterface.setChargerVoltageAndCurrent(u, i)
|
||||
except:
|
||||
self.addToTrace("ERROR: Could not decode the PreChargeResponse")
|
||||
|
|
|
@ -126,23 +126,23 @@ def convertPcapToTxt(inputFileName):
|
|||
if (decoded.find("CurrentDemandReq")>0) and (t3CurrentDemandBegin==0):
|
||||
t3CurrentDemandBegin = float(packet.sniff_timestamp)
|
||||
try:
|
||||
y = json.loads(decoded)
|
||||
jsondict = json.loads(decoded)
|
||||
try:
|
||||
u = combineValueAndMultiplier(y["EVSEPresentVoltage.Value"], y["EVSEPresentVoltage.Multiplier"])
|
||||
u = combineValueAndMultiplier(jsondict["EVSEPresentVoltage.Value"], jsondict["EVSEPresentVoltage.Multiplier"])
|
||||
print("[" + str(packet.sniff_time) + "] EVSEPresentVoltage=" + str(u), file=fileOutValues)
|
||||
i = combineValueAndMultiplier(y["EVSEPresentCurrent.Value"], y["EVSEPresentCurrent.Multiplier"])
|
||||
i = combineValueAndMultiplier(jsondict["EVSEPresentCurrent.Value"], jsondict["EVSEPresentCurrent.Multiplier"])
|
||||
print("[" + str(packet.sniff_time) + "] EVSEPresentCurrent=" + str(i), file=fileOutValues)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
u = combineValueAndMultiplier(y["EVTargetVoltage.Value"], y["EVTargetVoltage.Multiplier"])
|
||||
u = combineValueAndMultiplier(jsondict["EVTargetVoltage.Value"], jsondict["EVTargetVoltage.Multiplier"])
|
||||
print("[" + str(packet.sniff_time) + "] EVTargetVoltage=" + str(u), file=fileOutValues)
|
||||
i = combineValueAndMultiplier(y["EVTargetCurrent.Value"], y["EVTargetCurrent.Multiplier"])
|
||||
i = combineValueAndMultiplier(jsondict["EVTargetCurrent.Value"], jsondict["EVTargetCurrent.Multiplier"])
|
||||
print("[" + str(packet.sniff_time) + "] EVTargetCurrent=" + str(i), file=fileOutValues)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
soc = y["DC_EVStatus.EVRESSSOC"]
|
||||
soc = jsondict["DC_EVStatus.EVRESSSOC"]
|
||||
print("[" + str(packet.sniff_time) + "] EVRESSSOC=" + str(soc), file=fileOutValues)
|
||||
except:
|
||||
pass
|
||||
|
|
Loading…
Reference in a new issue