-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
89 lines (71 loc) · 2.04 KB
/
main.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import linuxcnc
from opcua import Server
import logging
import time
import os
from os.path import expanduser
from linuxcncopcua import *
import threading
variableMap = {}
server = Server()
c = linuxcnc.command()
path = expanduser("~/opc-tmp/cncprogramm")
def setModeMDI(parent):
c.mode(linuxcnc.MODE_MDI)
c.wait_complete()
print("NOW MACHINE IS MDI!!!")
def setModeManual(parent):
c.mode(linuxcnc.MODE_MANUAL)
c.wait_complete()
print("NOW MACHINE IS MANUAL!!!")
def setModeAuto(parent):
c.mode(linuxcnc.MODE_AUTO)
c.wait_complete()
print("NOW MACHINE IS AUTO!!!")
def setMoveRobotRemovePos(parent):
xInch = 64.770 / 25.4
c.mdi("G0 G21 G90 X63.5 Y0 Z0 A0 B15")# G21 for Units in MM
print("MOVE THAT ROBOT!!")
def startSelectedProgramm(parent):
c.auto(linuxcnc.AUTO_RUN, 0)
c.wait_complete()
print("STAARRTT!!")
def pauseSelectedProgramm(parent):
c.auto(linuxcnc.AUTO_PAUSE)
c.wait_complete()
print("Paused!!")
def resumeSelectedProgramm(parent):
c.auto(linuxcnc.AUTO_RESUME)
c.wait_complete()
print("Resume!!")
def startFileTransfer(hal, funcName):
print("Check Transfer File ")
def checkFinishedTransferFile(hal, funcName):
print("Start Transfer File function")
return True
def checkErrorTransferFile(hal, funcName):
print("Check Error Transfer File")
return False
def update_loop():
while True:
update_function()
time.sleep(0.1)
if __name__ == '__main__':
logging.basicConfig(level=logging.WARN)
print("Selected System path: ", path)
try:
if not os.path.exists(path):
os.makedirs(path)
except OSError:
print ("Creation of the directory %s failed" % path)
else:
print ("Successfully created the directory %s" % path)
print("Configure OPC Server")
init_variables_start_server()
print("Start OPC UA Server")
start_server()
print("Beginn update loop!")
thread = threading.Thread(target=update_loop, args=())
thread.daemon = True
thread.start()
thread.join()