feature: add relay control to hardwareInterface

This commit is contained in:
uhi22 2022-12-16 13:03:36 +01:00
parent 4c80baf752
commit 8b9f840232
3 changed files with 28 additions and 6 deletions

View file

@ -0,0 +1,8 @@
# Installation on Windows10
## Driver for the USB-to-Serial brigde
For the USB-to-Serial bridge, which is sold as CP2102, the Windows 10 tries to install the driver when plugged-in. But
the device did not work together with the driver which windows found automatically. A root cause may be, that the
device is not an original CP2102, but a clone. Finally found a driver on https://www.pololu.com/docs/0J7/all, which works.

View file

@ -1,6 +1,6 @@
# Todos # Todos
- [ ] Decode CableCheckRes."DC_EVSEStatus.EVSEStatusCode": dinDC_EVSEStatusCodeType as readable text - [x] Decode CableCheckRes."DC_EVSEStatus.EVSEStatusCode": dinDC_EVSEStatusCodeType as readable text
- [ ] Decode CableCheckRes."DC_EVSEStatus.EVSEIsolationStatus": dinisolationLevelType as readable text - [ ] Decode CableCheckRes."DC_EVSEStatus.EVSEIsolationStatus": dinisolationLevelType as readable text
- [ ] Encoder: PreChargeReq: is it possible to enable the units for EVTargetVoltage and EVTargetCurrent? - [ ] Encoder: PreChargeReq: is it possible to enable the units for EVTargetVoltage and EVTargetCurrent?
- [ ] Find out, why Alpi reports CableCheckRes = Finished FAILED in v0.4 - [ ] Find out, why Alpi reports CableCheckRes = Finished FAILED in v0.4

View file

@ -50,6 +50,14 @@ class hardwareInterface():
self.addToTrace("Switching PowerRelay OFF.") self.addToTrace("Switching PowerRelay OFF.")
self.outvalue &= ~2 self.outvalue &= ~2
def setRelay2On(self):
self.addToTrace("Switching PowerRelay ON.")
self.outvalue |= 4
def setRelay2Off(self):
self.addToTrace("Switching PowerRelay OFF.")
self.outvalue &= ~4
def getInletVoltage(self): def getInletVoltage(self):
#todo: get real measured voltage from the inlet #todo: get real measured voltage from the inlet
self.inletVoltage = self.simulatedInletVoltage self.inletVoltage = self.simulatedInletVoltage
@ -122,16 +130,22 @@ def myPrintfunction(s):
if __name__ == "__main__": if __name__ == "__main__":
print("Testing hardwareInterface...") print("Testing hardwareInterface...")
hw = hardwareInterface(myPrintfunction) hw = hardwareInterface(myPrintfunction)
for i in range(0, 300): for i in range(0, 350):
hw.mainfunction() hw.mainfunction()
if (i==100): if (i==50):
hw.setStateC() hw.setStateC()
if (i==100):
hw.setStateB()
if (i==150):
hw.setStateC()
hw.setPowerRelayOn()
if (i==200): if (i==200):
hw.setStateB() hw.setStateB()
hw.setPowerRelayOff()
if (i==250): if (i==250):
hw.setStateC() hw.setRelay2On()
if (i==280): if (i==300):
hw.setStateB() hw.setRelay2Off()
sleep(0.03) sleep(0.03)
hw.close() hw.close()
print("finished.") print("finished.")