diff --git a/script/setup/Layout.py b/script/setup/Layout.py index e1e2fa6..d88f375 100644 --- a/script/setup/Layout.py +++ b/script/setup/Layout.py @@ -154,5 +154,59 @@ def detect_pucks(point_list, block_id=None): puck.detect = DET_EMPTY if (puck.detect==DET_MINISPINE) else DET_UNIPUCK elif match==DET_MINISPINE: puck.detect = DET_EMPTY if (puck.detect==DET_UNIPUCK) else DET_MINISPINE - + +def clear_detection(block_id=None): + for puck in get_pucks(block_id): + puck.detect = DET_ERROR + +################################################################################################### +#Plotting +################################################################################################### + +from plotutils import * + +def plot_base_plate(points = None, show_detect = True, title = None): + colors = (Color.RED, Color.BLUE, Color.MAGENTA, Color(128,0,128), Color(0,128,0), Color(255,128,0)) + p = plot(None, title=title)[0] + plot_circle(p, 0, 0, PLATE_SIZE/2, width = 0, color = Color.GRAY, name = "Plate") + plot_point(p, 0, 0, size = 10, color = Color.GRAY, name = "Center") + #p.setLegendVisible(True) + for block in get_blocks(): + (xmin, xmax) = block.x_range + (ymin, ymax) = block.y_range + (xmin, ymin, xmax, ymax ) = block.roi + r = plot_rectangle(p, xmin, ymin, xmax, ymax, width =1, color=colors[ get_blocks().index(block)], name = block.id) + #In the first time the plot shows, it takes some time for the color to be assigned + #while r.color is None: + # time.sleep(0.001) + + for puck in get_pucks(block.id): + (xu, yu) = puck.led_uni + (xm, ym) = puck.led_mini + plot_point(p, xu, yu, size = 3, color = r.color, name = str(puck.id)+"u") + plot_point(p, xm, ym, size = 7, color = r.color, name = str(puck.id)+"m") + plot_circle(p, xu, yu, LED_TOLERANCE, width = 0, color = r.color, name = str(puck.id)+"uc") + plot_circle(p, xm, ym, LED_TOLERANCE, width = 0, color = r.color, name = str(puck.id)+"mc") + p.addText((xu+xm)/2, (yu+ym)/2, str(puck.id), r.color) + c,w = Color.GRAY,0 + if show_detect: + if puck.detect == DET_UNIPUCK: + c,w = Color.BLACK,1 + elif puck.detect == DET_MINISPINE: + c,w = Color.DARK_GRAY,1 + elif puck.detect == DET_ERROR: + c = Color(128,0,0) + plot_circle(p, xm, ym, PUCK_SIZE/2, width = w, color = c , name = str(puck.id)) + if points is not None: + for point in points: + c, w = Color.GRAY, 1 + for puck in get_pucks(): + match = puck.match(point[0], point[1]) + if match is not None: + w=2 + c = Color.DARK_GRAY if match == "minispine" else Color.BLACK + + + plot_cross(p,point[0], point[1], size = 10, width = w, color = c, name = "P"+ str(points.index(point))) + #plot_point(p,point[0], point[1], size = 5, color = Color.BLACK, name = "Pc"+ str(points.index(point)))