fix: the onepoint iterator should work
This commit is contained in:
		
							parent
							
								
									f67e7992ba
								
							
						
					
					
						commit
						80c76bfeb1
					
				| @ -1,6 +1,7 @@ | ||||
| import ast | ||||
| import math | ||||
| import struct | ||||
| import sys | ||||
| import time | ||||
| 
 | ||||
| import numpy as np | ||||
| @ -93,34 +94,28 @@ class Status(object): | ||||
|             for l in lines: | ||||
|                 print(prefix + l) | ||||
| 
 | ||||
| class OnePointIterator( ): | ||||
| 
 | ||||
|     def __init__(self, ref): | ||||
|         self.ref = ref | ||||
| 
 | ||||
|     def __iter__(self): | ||||
|         return self | ||||
| 
 | ||||
|     def __next__(self): | ||||
| 
 | ||||
| def OnePointIterator(pl): | ||||
|     while True: | ||||
| 
 | ||||
|             # pdb.set_trace() | ||||
|             for indexpoint, currentpoint in enumerate(self.ref.pl): | ||||
|         for indexpoint, currentpoint in enumerate(pl): | ||||
|             print("cp", indexpoint, currentpoint) | ||||
|             yield currentpoint[0], currentpoint[1], 255, 255, 255 | ||||
|         continue | ||||
|         for indexpoint, currentpoint in enumerate(pl): | ||||
| 
 | ||||
|             # We modify the point geometry according to warp settings | ||||
|             # print indexpoint, currentpoint | ||||
|             # xyc = [currentpoint[0], currentpoint[1], currentpoint[2]] | ||||
|                 # self.ref.xyrgb = self.ref.get_warped_point(xyc) | ||||
|                 x, y = self.ref.get_warped_point(currentpoint[0], currentpoint[1]) | ||||
|                 r, g, b = self.ref.int_to_rgb(currentpoint[2]) | ||||
|             # ref.xyrgb = ref.get_warped_point(xyc) | ||||
|             x, y = ref.get_warped_point(currentpoint[0], currentpoint[1]) | ||||
|             r, g, b = ref.int_to_rgb(currentpoint[2]) | ||||
| 
 | ||||
|             # We modify the point color based on channel specific r,g,b intensity settings | ||||
|                 rgb = (round(r * self.ref.intred / 100), round(g * self.ref.intgreen / 100), | ||||
|                        round(b * self.ref.intblue / 100)) | ||||
|             rgb = (round(r * ref.intred / 100), round(g * ref.intgreen / 100), | ||||
|                    round(b * ref.intblue / 100)) | ||||
| 
 | ||||
|             # We compute the delta with previous position | ||||
|                 delta_x, delta_y = x - self.ref.prev_x, y -self.ref.prev_y | ||||
|             delta_x, delta_y = x - ref.prev_x, y - ref.prev_y | ||||
| 
 | ||||
|             # We compute the distance from previous postion | ||||
|             if math.hypot(delta_x, delta_y) < 4000: | ||||
| @ -137,13 +132,14 @@ class OnePointIterator( ): | ||||
|                 step = e[0] | ||||
| 
 | ||||
|                 for i in range(0, e[1]): | ||||
|                         self.ref.xyrgb_step = (self.ref.prev_x + step * delta_x, | ||||
|                                            self.ref.prev_y + step * delta_y) + rgb  # + self.ref.xyrgb_prev[2:]# + rgb | ||||
|                         # print(self.ref.xyrgb_step) | ||||
|                         yield self.ref.xyrgb_step | ||||
|                     ref.xyrgb_step = (ref.prev_x + step * delta_x, | ||||
|                                       ref.prev_y + step * delta_y) + rgb  # + ref.xyrgb_prev[2:]# + rgb | ||||
|                     # print(ref.xyrgb_step) | ||||
|                     yield ref.xyrgb_step | ||||
| 
 | ||||
|             ref.prev_x, ref.prev_y = x, y | ||||
|             ref.xyrgb_prev = [x, y] | ||||
| 
 | ||||
|                 self.ref.prev_x, self.ref.prev_y = x, y | ||||
|                 self.ref.xyrgb_prev = [x, y] | ||||
| 
 | ||||
| class Tracer(object): | ||||
|     """A connection to a DAC.""" | ||||
| @ -152,6 +148,8 @@ class Tracer(object): | ||||
|     point_list_number: list | ||||
|     pl: list | ||||
|     client_key: str  # /pl/<laser_id> by default | ||||
|     prev_x = 0 | ||||
|     prev_y = 0 | ||||
| 
 | ||||
|     black_points = [(278.0, 225.0, 0), (562.0, 279.0, 0), (401.0, 375.0, 0), (296.0, 454.0, 0), (298.0, 165.0, 0)] | ||||
|     grid_points = [(300.0, 200.0, 0), (500.0, 200.0, 65280), (500.0, 400.0, 65280), (300.0, 400.0, 65280), | ||||
| @ -191,9 +189,6 @@ class Tracer(object): | ||||
|     # def set_ack_status(self, ack_status: int): | ||||
|     #     raise Exception("Please override the method") | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     def prepare(self): | ||||
|         raise Exception("Please override the method") | ||||
| 
 | ||||
| @ -254,6 +249,8 @@ class Tracer(object): | ||||
|                 # @todo si la clef est vide utiliser les points noirs ?  -> syntax error -> black points. | ||||
|                 try: | ||||
|                     self.pl = ast.literal_eval(self.redis.get(self.clientkey + str(self.laser_id)).decode('ascii')) | ||||
|                     # print(self.clientkey + str(self.laser_id)) | ||||
|                     # print(self.pl) | ||||
| 
 | ||||
|                 except SyntaxError: | ||||
|                     print("BAD POINTLIST on Tracer : laser", self.laser_id, " order 0 : pl : ", self.pl) | ||||
| @ -284,7 +281,8 @@ class Tracer(object): | ||||
| 
 | ||||
|                 if order == 4: | ||||
|                     """ 4: Resampler Change, modify the automatic intermediary points settings """ | ||||
|                     self.resampler = ast.literal_eval(self.redis.get('/resampler/' + str(self.laser_id)).decode('ascii')) | ||||
|                     self.resampler = ast.literal_eval( | ||||
|                         self.redis.get('/resampler/' + str(self.laser_id)).decode('ascii')) | ||||
|                     print("Tracer", self.laser_id, " : resetting lsteps for", self.resampler) | ||||
|                     gstt.stepshortline = self.resampler[0] | ||||
|                     gstt.stepslongline[0] = self.resampler[1] | ||||
| @ -329,8 +327,9 @@ class Tracer(object): | ||||
|             # pdb.set_trace() | ||||
|             # How much room? | ||||
|             capacity = self.get_points_capacity() | ||||
|             iterator = iter(OnePointIterator(self.pl)) | ||||
| 
 | ||||
|             self.redis.set('/cap/' + str(self.laser_id), capacity) | ||||
|             iterator = OnePointIterator(self) | ||||
|             points = [next(iterator) for i in range(capacity)] | ||||
|             self.write(points) | ||||
|             if not started: | ||||
|  | ||||
| @ -50,7 +50,7 @@ class TracerHelios(Tracer): | ||||
|         pass | ||||
| 
 | ||||
|     def get_points_capacity(self): | ||||
|         return 1000 | ||||
|         return 10 | ||||
| 
 | ||||
|     # def GetPoints(self, capacity): | ||||
|     #     a = [2,3] | ||||
| @ -92,16 +92,7 @@ class TracerHelios(Tracer): | ||||
|         # print("hello got {} points".format(len(points))) | ||||
|         points = [point for point in points] | ||||
|         for i, point in enumerate(points): | ||||
|             a = 0 | ||||
|             # @todo why are there 2 tuples in the object ??? | ||||
|             for one_point in point: | ||||
|                 x, y, r, g, b = one_point | ||||
|                 # x = random.randrange(1500,2500) | ||||
|                 # y = random.randrange(1500,2500) | ||||
|                 # r = 255 | ||||
|                 # g = 255 | ||||
|                 # b = 255 | ||||
|                 break | ||||
|             x, y, r, g, b = point | ||||
|             print(x,y,r,g,b) | ||||
|             frame[i] = HeliosPoint(int(x), int(y), int(r), int(g), int(b), 255) | ||||
|         statusAttempts = 0 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user