forked from rahatzamancse/EyeTask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWheelChair.py
68 lines (57 loc) · 2.05 KB
/
WheelChair.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
58
59
60
61
62
63
64
65
66
67
68
from socket import *
class WheelChair:
def __init__(self):
host = "192.168.0.14" # set to IP address of target computer
port = 13000
self.addr = (host, port)
self.socket = socket(AF_INET, SOCK_DGRAM)
self.active = False
self.fan = False
self.light = False
def start(self):
print("WheelChair : start")
self.socket.sendto(bytes('start'.encode()), self.addr)
self.active = True
def stop(self):
print("WheelChair : stop")
self.socket.sendto(bytes('stop'.encode()), self.addr)
self.active = False
def toggleStartStop(self):
if self.active:
print("WheelChair : stop")
self.socket.sendto(bytes('stop'.encode()), self.addr)
self.active = False
else:
print("WheelChair : start")
self.socket.sendto(bytes('start'.encode()), self.addr)
self.active = True
def left(self):
if self.active:
print("WheelChair : left")
self.socket.sendto(bytes('left'.encode()), self.addr)
else:
print("WheelChair is not active")
def right(self):
if self.active:
print("WheelChair : right")
self.socket.sendto(bytes('right'.encode()), self.addr)
else:
print("WheelChair is not active")
def toggleFan(self):
if self.fan:
print("WheelChair : fan Off")
self.socket.sendto(bytes('fanOff'.encode()), self.addr)
else:
print("WheelChair : fan On")
self.socket.sendto(bytes('fanOn'.encode()), self.addr)
def toggleLight(self):
if self.fan:
print("WheelChair : light Off")
self.socket.sendto(bytes('lightOff'.encode()), self.addr)
else:
print("WheelChair : light On")
self.socket.sendto(bytes('lightOn'.encode()), self.addr)
def emergencyStop(self):
self.stop()
def setSpeed(self, val):
self.socket.sendto(bytes(('set ' + str(val)).encode()), self.addr)