1212import serial .tools .list_ports
1313from config import conf , write_config_fields
1414
15+ try :
16+ from PIL import Image
17+ except ImportError :
18+ print "Pillow module missing, raster mode will fail."
19+
1520
1621__author__ = 'Stefan Hechenberger <stefan@nortd.com>'
1722
4449
4550CMD_AIR_ENABLE = "L"
4651CMD_AIR_DISABLE = "M"
47- # CMD_AUX1_ENABLE = "N"
48- # CMD_AUX1_DISABLE = "O"
52+ CMD_AUX_ENABLE = "N"
53+ CMD_AUX_DISABLE = "O"
4954# CMD_AUX2_ENABLE = "P"
5055# CMD_AUX2_DISABLE = "Q"
5156
144149
145150 "L" : "CMD_AIR_ENABLE" ,
146151 "M" : "CMD_AIR_DISABLE" ,
147- # "N": "CMD_AUX1_ENABLE ",
148- # "O": "CMD_AUX1_DISABLE ",
152+ "N" : "CMD_AUX_ENABLE " ,
153+ "O" : "CMD_AUX_DISABLE " ,
149154 # "P": "CMD_AUX2_ENABLE",
150155 # "Q": "CMD_AUX2_DISABLE",
151156
@@ -931,7 +936,7 @@ def job(jobdict):
931936
932937 # reset vavles
933938 air_off ()
934- # aux1_off ()
939+ # aux_off ()
935940
936941 # loop passes
937942 for pass_ in jobdict ['passes' ]:
@@ -949,8 +954,8 @@ def job(jobdict):
949954 air_on ()
950955 else :
951956 air_on () # also default this behavior
952- # if 'aux1_assist ' in pass_ and pass_['aux1_assist '] == 'pass':
953- # aux1_on ()
957+ # if 'aux_assist ' in pass_ and pass_['aux_assist '] == 'pass':
958+ # aux_on ()
954959 # seekrate
955960 if 'seekrate' in pass_ :
956961 seekrate = pass_ ['seekrate' ]
@@ -984,7 +989,6 @@ def job(jobdict):
984989 px_h = int (size [1 ]/ pxsize )
985990 # create image obj, convert to grayscale, scale, loop through lines
986991 print "--- start of image processing ---"
987- import Image
988992 imgobj = Image .open (io .BytesIO (base64 .b64decode (data [22 :].encode ('utf-8' ))))
989993 imgobj = imgobj .resize ((px_w ,px_h ), resample = Image .BICUBIC )
990994 if imgobj .mode == 'RGBA' :
@@ -1009,8 +1013,8 @@ def job(jobdict):
10091013 # assists on, beginning of feed if set to 'feed'
10101014 if 'air_assist' in pass_ and pass_ ['air_assist' ] == 'feed' :
10111015 air_on ()
1012- # if 'aux1_assist ' in pass_ and pass_['aux1_assist '] == 'feed':
1013- # aux1_on ()
1016+ # if 'aux_assist ' in pass_ and pass_['aux_assist '] == 'feed':
1017+ # aux_on ()
10141018 ### go through image lines ####
10151019 pxarray = imgobj .getdata ()
10161020 # if len(pxarray) % size[0] != 0:
@@ -1028,6 +1032,7 @@ def job(jobdict):
10281032 end += px_w
10291033 # move to start of line
10301034 feedrate (seekrate )
1035+ # intensity(0.0)
10311036 move (leadinpos , line_y )
10321037 # lead-in
10331038 feedrate (feedrate_ )
@@ -1048,8 +1053,8 @@ def job(jobdict):
10481053 # assists off, end of feed if set to 'feed'
10491054 if 'air_assist' in pass_ and pass_ ['air_assist' ] == 'feed' :
10501055 air_off ()
1051- # if 'aux1_assist ' in pass_ and pass_['aux1_assist '] == 'feed':
1052- # aux1_off ()
1056+ # if 'aux_assist ' in pass_ and pass_['aux_assist '] == 'feed':
1057+ # aux_off ()
10531058
10541059 elif kind == "fill" or kind == "path" :
10551060 path = def_ ['data' ]
@@ -1071,8 +1076,8 @@ def job(jobdict):
10711076 # also air_assist defaults to 'feed'
10721077 if 'air_assist' in pass_ and pass_ ['air_assist' ] == 'feed' :
10731078 air_on ()
1074- # if 'aux1_assist ' in pass_ and pass_['aux1_assist '] == 'feed':
1075- # aux1_on ()
1079+ # if 'aux_assist ' in pass_ and pass_['aux_assist '] == 'feed':
1080+ # aux_on ()
10761081 # TODO dwell according to pierce time
10771082 if is_2d :
10781083 for i in xrange (1 , len (polyline )):
@@ -1083,17 +1088,17 @@ def job(jobdict):
10831088 # turn off assists if set to 'feed'
10841089 if 'air_assist' in pass_ and pass_ ['air_assist' ] == 'feed' :
10851090 air_off ()
1086- # if 'aux1_assist ' in pass_ and pass_['aux1_assist '] == 'feed':
1087- # aux1_off ()
1091+ # if 'aux_assist ' in pass_ and pass_['aux_assist '] == 'feed':
1092+ # aux_off ()
10881093
10891094 # assists off, end of pass if set to 'pass'
10901095 if 'air_assist' in pass_ :
10911096 if pass_ ['air_assist' ] == 'pass' :
10921097 air_off ()
10931098 else :
10941099 air_off () # also default this behavior
1095- # if 'aux1_assist ' in pass_ and pass_['aux1_assist '] == 'pass':
1096- # aux1_off ()
1100+ # if 'aux_assist ' in pass_ and pass_['aux_assist '] == 'pass':
1101+ # aux_off ()
10971102
10981103 # return to origin
10991104 feedrate (conf ['seekrate' ])
@@ -1150,28 +1155,15 @@ def air_off():
11501155 with SerialLoop .lock :
11511156 SerialLoop .send_command (CMD_AIR_DISABLE )
11521157
1158+ def aux_on ():
1159+ global SerialLoop
1160+ with SerialLoop .lock :
1161+ SerialLoop .send_command (CMD_AUX_ENABLE )
11531162
1154- # def aux1_on():
1155- # global SerialLoop
1156- # with SerialLoop.lock:
1157- # SerialLoop.send_command(CMD_AUX1_ENABLE)
1158- #
1159- # def aux1_off():
1160- # global SerialLoop
1161- # with SerialLoop.lock:
1162- # SerialLoop.send_command(CMD_AUX1_DISABLE)
1163- #
1164- #
1165- # def aux2_on():
1166- # global SerialLoop
1167- # with SerialLoop.lock:
1168- # SerialLoop.send_command(CMD_AUX2_ENABLE)
1169- #
1170- # def aux2_off():
1171- # global SerialLoop
1172- # with SerialLoop.lock:
1173- # SerialLoop.send_command(CMD_AUX2_DISABLE)
1174-
1163+ def aux_off ():
1164+ global SerialLoop
1165+ with SerialLoop .lock :
1166+ SerialLoop .send_command (CMD_AUX_DISABLE )
11751167
11761168def set_offset_table ():
11771169 global SerialLoop
0 commit comments