def apply_config(self, c): try: active = c.get("active", False) self.Stop() if active: self._runLevel = c.get("runLevel", 0) self.Start() namedRois = [] names = [] for name, d in c.iteritems(): try: if isinstance(d, dict): rType = d.get("type", None) if rType == RoiCounterTask.SQUARE: x = d["x"] y = d["y"] width = d["width"] height = d["height"] namedRois.append( (name, Core.Roi(x, y, width, height))) elif rType == RoiCounterTask.ARC: x = d["x"] y = d["y"] r1 = d["r1"] r2 = d["r2"] a1 = d["a1"] a2 = d["a2"] namedRois.append( (name, Core.ArcRoi(x, y, r1, r2, a1, a2))) elif rType == RoiCounterTask.MASK: x = d["x"] y = d["y"] data = d["data"] self.__roiCounterMgr.setLutMask( name, Core.Point(x, y), data) elif rType == RoiCounterTask.LUT: x = d["x"] y = d["y"] data = d["data"] self.__roiCounterMgr.setLut( name, Core.Point(x, y), data) names.append(name) except KeyError as err: PyTango.Except.throw_exception( 'Config error', 'Missing key %s in roi named %s' % (err, name), 'RoiCounterDeviceServer Class') self.__roiCounterMgr.updateRois(namedRois) self.add(names) except: import traceback traceback.print_exc()
def setArcRois(self,argin) : if self.__roiCounterMgr is None: raise RuntimeError('should start the device first') if not len(argin) % 7: arc_list = [] for roi_id,x,y,r1,r2,start,end in grouper(7,argin): roi_name = self.__roiID2Name.get(roi_id) if roi_name is None: raise RuntimeError('should call add method before setRoi') arc_list.append((roi_name,Core.ArcRoi(x,y,r1,r2,start,end))) self.__roiCounterMgr.updateArcRois(arc_list) else: raise AttributeError('should be a vector as follow [roi_id,centerX,centerY,rayon1,rayon2,angle_start,angle_end,...]')