-
Notifications
You must be signed in to change notification settings - Fork 17
/
runner.py
44 lines (33 loc) · 1.19 KB
/
runner.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
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 9 13:12:35 2016
@author: adiebold
"""
import figura as fg
from gcode import Gcode, RobotCode
import time
from parameters import makeParamObj
import json
import constants as c
class Runner:
def __init__(self, jsonName, outputFileName, gRobot, layerParamLabels, partParamLabels):
self.outputFileName = outputFileName
with open(jsonName, 'r') as fp:
data = json.load(fp)
self.pr = makeParamObj(data[0], data[1], layerParamLabels, partParamLabels)
if gRobot == c.GCODE:
self.gc = Gcode(self.pr)
elif gRobot == c.ROBOTCODE:
self.gc = RobotCode(self.pr)
def run(self):
startTime = time.time()
print('\nGenerating code, please wait...')
fig = fg.Figura(self.pr, self.gc)
with open(self.outputFileName, 'w') as f:
for string in fig.masterGcode_gen():
f.write(string)
endTime = time.time()
print('\nCode generated.')
print('Done calculating: ' + self.outputFileName + '\n')
print('{:.2f} total time'.format(endTime - startTime))
return fig.data_points