-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwindowsremote.py
More file actions
153 lines (126 loc) · 3.61 KB
/
windowsremote.py
File metadata and controls
153 lines (126 loc) · 3.61 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import os
import redis
import time
import socket
'''
COMMON FUNCTION
'''
def clear_screen():
os.system('cls')
def timer():
return time.asctime(time.localtime(time.time()))
'''
CONFIG
'''
menuLogo = '''
_________ _______ _________ __________ __
\_ ___ \ \ \ \_ ___ \ \______ \ ____ _____ _____/ |_ ____
/ \ \/ / | \/ \ \/ | _// __ \ / \ / _ \ __\/ __ \
\ \____/ | \ \____ | | \ ___/| Y Y ( <_> ) | \ ___/
\______ /\____|__ /\______ / |____|_ /\___ >__|_| /\____/|__| \___ >
\/ \/ \/ \/ \/ \/ \/
'''
prompt = "CNCR3M0T3 ~# "
client = redis.Redis(host="127.0.0.1", port=6379)
'''
MENU CLASSES
'''
class WindowsRemote:
def __init__(self):
clear_screen()
print(menuLogo + '''
{3}--3 Axes
{4}--4 Axes
{5}--5 Axes
''')
choice = input(prompt)
clear_screen()
Commander(int(choice))
if choice == "\r" or choice == "\n" or choice == "" or choice == " " or int(choice) > 5:
self.__init__()
else:
try:
print(os.system(choice))
except:
pass
self.action_completed()
def action_completed(self):
input("Task executed, click return to go back")
self.__init__()
class Commander:
def __init__(self, axes):
clear_screen()
self.axes = axes
print(menuLogo + '''
SELECT A COMMAND
{1}--machine state
{2}--home
{3}--unhome
{4}--brake
{r}--return/abort
''')
choice = input(prompt)
if choice == "1":
self.switch_state()
elif choice == "2":
self.home_axis(self.axes)
elif choice == "3":
self.un_home_axis(self.axes)
elif choice == "4":
self.brake()
elif choice == "r":
client.publish("cnc", "abort")
Commander(self.axes)
else:
self.__init__(self.axes)
self.action_completed()
def switch_state(self):
clear_screen()
print(menuLogo + '''
input: estop, estopr, ston, stof,
''')
choice = input(prompt)
client.publish("cnc", choice)
self.action_completed()
def home_axis(self, axes):
self.axes = axes
clear_screen()
print(menuLogo + '''
input axis
''')
choice = int(input(prompt))
if choice < self.axes:
client.publish("cnc", "h" + str(choice))
elif choice == "r":
Commander(self.axes)
else:
self.__init__(self.axes)
self.action_completed()
def un_home_axis(self, axes):
self.axes = axes
clear_screen()
print(menuLogo + '''
input axis
''')
choice = int(input(prompt))
clear_screen()
if choice < self.axes:
client.publish("cnc", "uh" + str(choice))
elif choice == "r":
Commander(self.axes)
else:
self.__init__(self.axes)
self.action_completed()
def brake(self):
client.publish("cnc", "brake")
self.action_completed()
def action_completed(self):
input("Action sent, click return to go back")
Commander(self.axes)
#######
if __name__ == "__main__":
try:
WindowsRemote()
except KeyboardInterrupt:
print("Exiting...\n")
time.sleep(0.25)