3
3
4
4
import os
5
5
import sys
6
- import threading
7
6
import math
8
7
import serial .tools .list_ports
9
8
import glob
10
9
import json
11
10
import time
12
11
import re
13
12
import zipfile
14
- #from zipfile import ZipFile
15
- import datetime
16
13
from gpiozero .pins .mock import MockFactory
17
14
from gpiozero import Device
18
- from github import Github
19
- import wget
20
- import subprocess
21
- from shutil import copyfile
22
15
16
+ '''
17
+ This class does most of the heavy lifting in processing messages from the UI client.
18
+ '''
23
19
class Actions (MakesmithInitFuncs ):
24
20
25
21
Device .pin_factory = MockFactory ()
26
22
27
23
def processAction (self , msg ):
24
+ '''
25
+ When a message comes in via the UI client it gets parsed and processed here.
26
+ :param msg: json of message from UI client
27
+ :return:
28
+ '''
28
29
try :
29
- #Commands allowed during sending gcode
30
+ # Commands allowed during sending gcode. These commands won't screw something up.
30
31
if msg ["data" ]["command" ] == "createDirectory" :
31
32
if not self .createDirectory (msg ["data" ]["arg" ]):
32
33
self .data .ui_queue1 .put ("Alert" , "Alert" , "Error with creating directory." )
@@ -61,10 +62,10 @@ def processAction(self, msg):
61
62
elif msg ["data" ]["command" ] == "shutdown" :
62
63
if not self .shutdown ():
63
64
self .data .ui_queue1 .put ("Alert" , "Alert" , "Error with shutting down." )
64
-
65
- #Commands not allowed during sending gcode
66
65
elif self .data .uploadFlag :
67
66
self .data .ui_queue1 .put ("Alert" , "Alert" , "Cannot issue command while sending gcode." )
67
+ # Commands not allowed during sending gcode.. if you did these commands, something could screw up.
68
+ # If uploadFlag was enabled (see above) then this would never be reached.
68
69
elif msg ["data" ]["command" ] == "update" :
69
70
if not self .data .releaseManager .update (msg ["data" ]["arg" ]):
70
71
self .data .ui_queue1 .put ("Alert" , "Alert" , "Error with updating webcontrol." )
@@ -143,8 +144,8 @@ def processAction(self, msg):
143
144
elif msg ["data" ]["command" ] == "rotateSprocket" :
144
145
if not self .rotateSprocket (msg ["data" ]["arg" ], msg ["data" ]["arg1" ]):
145
146
self .data .ui_queue1 .put ("Alert" , "Alert" , "Error with setting sprocket" )
146
- elif msg ["data" ]["command" ] == "setSprocketsAutomatic " :
147
- if not self .setSprocketsAutomatic ():
147
+ elif msg ["data" ]["command" ] == "setSprocketAutomatic " :
148
+ if not self .setSprocketAutomatic ():
148
149
self .data .ui_queue1 .put ("Alert" , "Alert" , "Error with setting sprockets automatically" )
149
150
elif msg ["data" ]["command" ] == "setSprocketsZero" :
150
151
if not self .setSprocketsZero ():
@@ -763,7 +764,7 @@ def setSprockets(self, sprocket, degrees):
763
764
self .data .console_queue .put (str (e ))
764
765
return False
765
766
766
- def setVerticalAutomatic (self ):
767
+ def setSprocketAutomatic (self ):
767
768
# set the call back for the measurement
768
769
try :
769
770
self .data .measureRequest = self .getLeftChainLength
@@ -786,8 +787,8 @@ def getRightChainLength(self, dist):
786
787
self .moveToVertical ()
787
788
788
789
def moveToVertical (self ):
789
- chainPitch = float (self .data .config .get ("Advanced Settings" , "chainPitch" ))
790
- gearTeeth = float (self .data .config .get ("Advanced Settings" , "gearTeeth" ))
790
+ chainPitch = float (self .data .config .getValue ("Advanced Settings" , "chainPitch" ))
791
+ gearTeeth = float (self .data .config .getValue ("Advanced Settings" , "gearTeeth" ))
791
792
distPerRotation = chainPitch * gearTeeth
792
793
793
794
distL = - 1 * (self .leftChainLength % distPerRotation )
0 commit comments