mirror of
https://github.com/uhi22/pyPLC.git
synced 2024-11-20 01:13:58 +00:00
EvseMode: show data of the power supply
This commit is contained in:
parent
d52fe797ad
commit
195c4868b0
3 changed files with 38 additions and 4 deletions
|
@ -262,7 +262,7 @@ class fsmEvse():
|
||||||
self.simulatedPresentVoltage += 20
|
self.simulatedPresentVoltage += 20
|
||||||
if (self.simulatedPresentVoltage<uTarget):
|
if (self.simulatedPresentVoltage<uTarget):
|
||||||
self.simulatedPresentVoltage += 5
|
self.simulatedPresentVoltage += 5
|
||||||
strPresentVoltage = str(self.simulatedPresentVoltage) # "345"
|
strPresentVoltage = str(int(self.simulatedPresentVoltage*10)/10) # "345"
|
||||||
# in case we control a real power supply: give the precharge target to it
|
# in case we control a real power supply: give the precharge target to it
|
||||||
self.hardwareInterface.setPowerSupplyVoltageAndCurrent(uTarget, 1)
|
self.hardwareInterface.setPowerSupplyVoltageAndCurrent(uTarget, 1)
|
||||||
self.callbackShowStatus(strPresentVoltage, "EVSEPresentVoltage")
|
self.callbackShowStatus(strPresentVoltage, "EVSEPresentVoltage")
|
||||||
|
@ -323,7 +323,7 @@ class fsmEvse():
|
||||||
except:
|
except:
|
||||||
self.addToTrace("ERROR: Could not decode the CurrentDemandReq")
|
self.addToTrace("ERROR: Could not decode the CurrentDemandReq")
|
||||||
self.simulatedPresentVoltage = uTarget + 3*random() # The charger provides the voltage which is demanded by the car.
|
self.simulatedPresentVoltage = uTarget + 3*random() # The charger provides the voltage which is demanded by the car.
|
||||||
strPresentVoltage = str(self.simulatedPresentVoltage)
|
strPresentVoltage = str(int(self.simulatedPresentVoltage*10)/10) # "345"
|
||||||
self.callbackShowStatus(strPresentVoltage, "EVSEPresentVoltage")
|
self.callbackShowStatus(strPresentVoltage, "EVSEPresentVoltage")
|
||||||
strEVSEPresentCurrent = "1" # Just as a dummy current
|
strEVSEPresentCurrent = "1" # Just as a dummy current
|
||||||
if (self.blChargeStopTrigger == 1):
|
if (self.blChargeStopTrigger == 1):
|
||||||
|
@ -353,7 +353,7 @@ class fsmEvse():
|
||||||
# todo: check the request content, and fill response parameters
|
# todo: check the request content, and fill response parameters
|
||||||
# simulate the decreasing voltage during the weldingDetection:
|
# simulate the decreasing voltage during the weldingDetection:
|
||||||
self.simulatedPresentVoltage = self.simulatedPresentVoltage*0.8 + 3*random()
|
self.simulatedPresentVoltage = self.simulatedPresentVoltage*0.8 + 3*random()
|
||||||
strPresentVoltage = str(self.simulatedPresentVoltage)
|
strPresentVoltage = str(int(self.simulatedPresentVoltage*10)/10) # "345"
|
||||||
self.callbackShowStatus(strPresentVoltage, "EVSEPresentVoltage")
|
self.callbackShowStatus(strPresentVoltage, "EVSEPresentVoltage")
|
||||||
msg = addV2GTPHeader(exiEncode("E"+self.schemaSelection+"j_"+strPresentVoltage)) # EDj for Encode, Din, WeldingDetectionRes
|
msg = addV2GTPHeader(exiEncode("E"+self.schemaSelection+"j_"+strPresentVoltage)) # EDj for Encode, Din, WeldingDetectionRes
|
||||||
self.showDecodedTransmitMessage(msg)
|
self.showDecodedTransmitMessage(msg)
|
||||||
|
|
20
pyPlc.py
20
pyPlc.py
|
@ -60,6 +60,12 @@ def cbShowStatus(s, selection=""):
|
||||||
if (selection == "UandI"):
|
if (selection == "UandI"):
|
||||||
lblRequestedUandI['text']= "Target " + s + ""
|
lblRequestedUandI['text']= "Target " + s + ""
|
||||||
s=""
|
s=""
|
||||||
|
if (selection == "PowerSupplyUPresent"):
|
||||||
|
lblPowerSupplyUPresent['text']= "UPresent " + s + "V"
|
||||||
|
s=""
|
||||||
|
if (selection == "PowerSupplyUTarget"):
|
||||||
|
lblPowerSupplyUTarget['text']= "UTarget " + s + "V"
|
||||||
|
s=""
|
||||||
if (len(s)>0):
|
if (len(s)>0):
|
||||||
lblStatus['text']=s
|
lblStatus['text']=s
|
||||||
root.update()
|
root.update()
|
||||||
|
@ -101,8 +107,19 @@ if (myMode == C_EVSE_MODE):
|
||||||
print("starting in EvseMode")
|
print("starting in EvseMode")
|
||||||
|
|
||||||
root = tk.Tk()
|
root = tk.Tk()
|
||||||
root.geometry("400x350")
|
#root.geometry("400x350")
|
||||||
|
root.geometry("600x350")
|
||||||
lastKey = ''
|
lastKey = ''
|
||||||
|
if (myMode == C_EVSE_MODE):
|
||||||
|
frmPowerSupply = tk.Frame(root, bg='lightblue', bd=3)
|
||||||
|
frmPowerSupply.pack(side='right', fill='both', expand='True')
|
||||||
|
lblPowerSupplyUTarget = tk.Label(frmPowerSupply, text="(UTarget)", bg='lightblue')
|
||||||
|
lblPowerSupplyUTarget.config(font=('Helvetica bold', 18))
|
||||||
|
lblPowerSupplyUTarget.pack()
|
||||||
|
lblPowerSupplyUPresent = tk.Label(frmPowerSupply, text="(PowerSupplyUPresent)", bg='lightblue')
|
||||||
|
lblPowerSupplyUPresent.config(font=('Helvetica bold', 18))
|
||||||
|
lblPowerSupplyUPresent.pack()
|
||||||
|
|
||||||
lblHelp = tk.Label(root, justify= "left")
|
lblHelp = tk.Label(root, justify= "left")
|
||||||
lblHelp['text']="x=exit \nS=GET_SW \nP=PEV mode \nE=EVSE mode \nL=Listen mode \ns=SET_KEY \nG=GET_KEY (try twice) \nt=SET_KEY modified \n space=stop charging"
|
lblHelp['text']="x=exit \nS=GET_SW \nP=PEV mode \nE=EVSE mode \nL=Listen mode \ns=SET_KEY \nG=GET_KEY (try twice) \nt=SET_KEY modified \n space=stop charging"
|
||||||
lblHelp.pack()
|
lblHelp.pack()
|
||||||
|
@ -124,6 +141,7 @@ lblEVSEPresentVoltage = tk.Label(root, text="(EVSEPresentVoltage)")
|
||||||
lblEVSEPresentVoltage.config(font=('Helvetica bold', 16))
|
lblEVSEPresentVoltage.config(font=('Helvetica bold', 16))
|
||||||
lblEVSEPresentVoltage.pack()
|
lblEVSEPresentVoltage.pack()
|
||||||
|
|
||||||
|
|
||||||
if (myMode == C_EVSE_MODE):
|
if (myMode == C_EVSE_MODE):
|
||||||
lblTestcase = tk.Label(root, text="(test case)")
|
lblTestcase = tk.Label(root, text="(test case)")
|
||||||
lblTestcase.pack()
|
lblTestcase.pack()
|
||||||
|
|
|
@ -730,6 +730,19 @@ class pyPlcHomeplug():
|
||||||
self.addToTrace("[EVSE] transmitting ATTEN_CHAR.IND")
|
self.addToTrace("[EVSE] transmitting ATTEN_CHAR.IND")
|
||||||
self.sniffer.sendpacket(bytes(self.mytransmitbuffer))
|
self.sniffer.sendpacket(bytes(self.mytransmitbuffer))
|
||||||
|
|
||||||
|
def evaluateStartAttenCharInd(self):
|
||||||
|
# self.addToTrace("received START_ATTEN_CHAR.IND")
|
||||||
|
# nothing to do as PEV or EVSE.
|
||||||
|
# interpretation just in case we use it as special message in EVSE mode to get information from the power supply
|
||||||
|
if (self.iAmEvse==1):
|
||||||
|
if ((self.myreceivebuffer[38] == 0xDC) and (self.myreceivebuffer[39] == 0x55) and (self.myreceivebuffer[40] == 0xAA)):
|
||||||
|
uPresent = self.myreceivebuffer[43]
|
||||||
|
uPresent*=256
|
||||||
|
uPresent+=self.myreceivebuffer[44]
|
||||||
|
uPresent/=10 # scaling in the message is 0.1V
|
||||||
|
self.callbackShowStatus(str(uPresent), "PowerSupplyUPresent")
|
||||||
|
# Todo: evaluate other information of the power supply, like cable check result, current, temperature, ...
|
||||||
|
|
||||||
def evaluateAttenCharInd(self):
|
def evaluateAttenCharInd(self):
|
||||||
self.addToTrace("received ATTEN_CHAR.IND")
|
self.addToTrace("received ATTEN_CHAR.IND")
|
||||||
if (self.iAmPev==1):
|
if (self.iAmPev==1):
|
||||||
|
@ -804,6 +817,8 @@ class pyPlcHomeplug():
|
||||||
self.evaluateSlacParamReq()
|
self.evaluateSlacParamReq()
|
||||||
if (mmt == CM_SLAC_PARAM + MMTYPE_CNF):
|
if (mmt == CM_SLAC_PARAM + MMTYPE_CNF):
|
||||||
self.evaluateSlacParamCnf()
|
self.evaluateSlacParamCnf()
|
||||||
|
if (mmt == CM_START_ATTEN_CHAR + MMTYPE_IND):
|
||||||
|
self.evaluateStartAttenCharInd()
|
||||||
if (mmt == CM_MNBC_SOUND + MMTYPE_IND):
|
if (mmt == CM_MNBC_SOUND + MMTYPE_IND):
|
||||||
self.evaluateMnbcSoundInd()
|
self.evaluateMnbcSoundInd()
|
||||||
if (mmt == CM_ATTEN_CHAR + MMTYPE_IND):
|
if (mmt == CM_ATTEN_CHAR + MMTYPE_IND):
|
||||||
|
@ -1130,6 +1145,7 @@ class pyPlcHomeplug():
|
||||||
self.composeSpecialMessage()
|
self.composeSpecialMessage()
|
||||||
self.addToTrace("transmitting SpecialMessage to control the power supply")
|
self.addToTrace("transmitting SpecialMessage to control the power supply")
|
||||||
self.transmit(self.mytransmitbuffer)
|
self.transmit(self.mytransmitbuffer)
|
||||||
|
self.callbackShowStatus(str(targetVoltage), "PowerSupplyUTarget")
|
||||||
|
|
||||||
def enterPevMode(self):
|
def enterPevMode(self):
|
||||||
self.iAmEvse = 0 # not emulating a charging station
|
self.iAmEvse = 0 # not emulating a charging station
|
||||||
|
|
Loading…
Reference in a new issue