Esempio n. 1
0
def reverse_y(line):
    try:
        d = parseline(line)
        if d.has_key('Y'): d['Y'] = 1224 - d['Y']
        if d.has_key('J'): d['J'] = 1224 - d['J']
        return d
    except:
        return None
Esempio n. 2
0
        def do_face(l,x,y):
            nf = []
            for o in l:
                nl = [odict2str(offseter(parseline(line),x,y)) for line in o.string.splitlines()]
                no = op('\n'.join(nl),o.tool, o.part)
                nf.append(no)

            return nf
Esempio n. 3
0
    def make_part(self, partname, debug=False):
        """create a rat for a part in a temporary file
        and returns
            the file object
            the coordinates of the part in the orignal file
            the bounding box of the part
        """
        
        part_nc = nc()

        flag = 0

        if partname != 'single part' and partname != 'rest':
            part_nc['faces'].append([o for o in self['faces'][0] if o.part == partname]) 
            part_nc['faces'].append([o for o in self['faces'][1] if o.part == partname]) 
        elif partname == 'rest':
            faceA = [o for o in self['faces'][0] if o.part is None]
            faceB = [o for o in self['faces'][1] if o.part is None]
            if faceB == []:
                flag = 1    
            else:
                part_nc['faces'].append(faceA) 
                part_nc['faces'].append(faceB) 
        else:
            part_nc['faces'].append([o for o in self['faces'][0]]) 
            part_nc['faces'].append([o for o in self['faces'][1]]) 

        X = 0
        Y = 0
        x = 2250
        y = 1230
        for o in part_nc['faces'][1]:
            for s in o.string.splitlines():
                d = parseline(s)
                if d.has_key('X'):
                    if d['X'] > X: X = d['X']
                    elif d['X'] < x: x = d['X']
                if d.has_key('Y'):
                    if d['Y'] > Y: Y = d['Y']
                    elif d['Y'] < y: y = d['Y']
                if d.has_key('I'):
                    if d['I'] > X: X = d['I']
                    elif d['I'] < x: x = d['I']
                if d.has_key('J'):
                    if d['J'] > Y: Y = d['J']
                    elif d['J'] < y: y = d['J']
        if debug is True:
            f = part_nc.to_file(sys.path[0] + sep + '..' + sep + 'tmp\\' +partname + '.nc',self['reg'])
        f = part_nc.to_file('',self['reg'])
    
        if flag == 0:
            return f, [x,y], [X-x,Y-y]
        else:
            return flag 
Esempio n. 4
0
 def do_face_a(l,x,y,angle):
     nf = []
     for o in l:
         nl = []
         for line in o.string.splitlines():
             d = parseline(line)
             d = offseter(d,-x,-(1220-y))
             d = rotater(d,-angle)               
             d = offseter(d,x,1220-y)
             nl.append(odict2str(d))
         no = op('\n'.join(nl),o.tool, o.part)
         nf.append(no)
     return nf
Esempio n. 5
0
def total(path, log=False):
    times = time_file(path)
    facelist = []
    file_total = 0
    for face in times:
        s = ""
        total = 0
        current_tool = 0
        for tool in face:
            key = "Tool # "
            s += key + tool[key] + "\n"
            tool_number = parseline(tool[key])["T"]
            if current_tool != tool_number:
                total += TOOL_CHANGE_TIME
                current_tool = tool_number
            key = "Air moves "
            s += key + str(tool[key]) + "\n"
            key = "Air moves time "
            s += key + str(tool[key]) + "\n"
            total += tool[key]
            key = "Cut moves "
            s += key + str(tool[key]) + "\n"
            key = "Cut moves time "
            s += key + str(tool[key]) + "\n"
            total += tool[key]

        file_total += total
        s += "Face total time " + str(total) + "\n"
        facelist.append(s)

        # print len(times)
    if len(times) == 2:
        file_total += FLIP_TIME
    if len(times) == 4:
        file_total += 2 * FLIP_TIME
        file_total += CHANGE_BOARD_TIME

    facelist.append("\nFile total time: " + str(file_total) + "\n")

    if log == True:
        f = open("time_log.txt", "w")
        f.write("\n\n".join(facelist))
        f.close()

    return file_total / 60
Esempio n. 6
0
def measure(face):

    nc_string = face
    nc_list = [line for line in nc_string.splitlines() if line.startswith("G") and not line.startswith("G98")]

    prev_X = 0
    prev_Y = 0
    prev_Z = 0
    current_tool = ""

    # totals
    air_move = []
    cut_move = []

    log = []
    tool_list = []

    for line in nc_list:
        p = {"X": prev_X, "Y": prev_Y, "Z": prev_Z}
        d = consolidate(p, parseline(line))

        # tools logic
        if line.startswith("G00 T"):
            if current_tool != "":
                # dump the tool values
                tool_dict = {current_tool: []}
                tool_dict[current_tool] = [copy(air_move), copy(cut_move)]
                tool_list.append(tool_dict)
                # aknowledge the new tool
                current_tool = line
                air_move = []
                cut_move = []
            else:
                current_tool = line

        elif line.startswith("G97"):
            pass

        else:  # start measuring
            if line.startswith(moves["airmove"]):
                air_move.append((length(p, d), AIR_MOVE_SPEED))

            elif line.startswith(moves["opmove"]):
                cut_move.append((length(p, d), d["F"]))

                # arcs (treated in 2D)
            elif line.startswith("G03") or line.startswith("G02"):
                if [p["X"], p["Y"]] == [d["X"], d["Y"]]:
                    cut_move.append((pi * 2 * radius(d), d["F"]))
                else:
                    if line.startswith("G03"):
                        angle = vecangle(p, d)
                    if line.startswith("G02"):
                        angle = (2 * pi) - vecangle(p, d)

                    cut_move.append((radius(d) * angle, d["F"]))

            prev_X = d["X"]
            prev_Y = d["Y"]
            prev_Z = d["Z"]

    tool_dict = {current_tool: []}
    tool_dict[current_tool] = [copy(air_move), copy(cut_move)]
    tool_list.append(tool_dict)

    return tool_list