forked from snaptec/openWB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trigopen.py
executable file
·57 lines (49 loc) · 1.7 KB
/
trigopen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
# coding: utf8
import time
import RPi.GPIO as GPIO
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--chargepoint", type=int, choices=[0, 1, 2], default=0,
help="chargepoint to trigger (int), defaults to 0 (1 and 2)")
parser.add_argument("-d", "--duration", type=float, default=2.0, help="duration in seconds (float), defaults to 2.0")
parser.add_argument("-v", "--verbose", action="store_true", help="verbose debug output")
args = parser.parse_args()
switchChargepoint1 = (bool)(args.chargepoint == 0 or args.chargepoint == 1)
switchChargepoint2 = (bool)(args.chargepoint == 0 or args.chargepoint == 2)
if(args.verbose):
print("Wartezeit vor und nach 1p/3p Umschaltung: %fs" % (args.duration))
print("Zu schaltende Ladepunkte: %d" % (args.chargepoint))
print("Schalte Ladepunkt 1: %s" % (str(switchChargepoint1)))
print("Schalte Ladepunkt 2: %s" % (str(switchChargepoint2)))
# setup GPIOs
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
if(switchChargepoint1):
GPIO.setup(22, GPIO.OUT)
GPIO.setup(29, GPIO.OUT)
if(switchChargepoint2):
GPIO.setup(15, GPIO.OUT)
GPIO.setup(11, GPIO.OUT)
# block CP
if(switchChargepoint1):
GPIO.output(22, GPIO.HIGH)
if(switchChargepoint2):
GPIO.output(15, GPIO.HIGH)
time.sleep(args.duration)
# switch phases
if(switchChargepoint1):
GPIO.output(29, GPIO.HIGH)
if(switchChargepoint2):
GPIO.output(11, GPIO.HIGH)
time.sleep(2)
if(switchChargepoint1):
GPIO.output(29, GPIO.LOW)
if(switchChargepoint2):
GPIO.output(11, GPIO.LOW)
time.sleep(args.duration)
# enable CP
if(switchChargepoint1):
GPIO.output(22, GPIO.LOW)
if(switchChargepoint2):
GPIO.output(15, GPIO.LOW)