Ejemplo n.º 1
0
 def ama_care(self):
     #Get the new pixel addressed positions
     tmp = Websock.get_pixels()
     if tmp != None and tmp != {}:
         Mesh.pixels = json.loads(tmp)
     tmp = json.loads(Websock.get_pos_unk())
     if tmp != None:
         Listen.unk = tmp
     #Get the model format to check
     tmp = Websock.get_ama_model()
     if tmp != None:
         self.ama_check = eval(tmp)['ama']
     if self.ama_model():
         # send a COLOR frame only if the model match the expected model
         Mesh.sequence = (Mesh.sequence + 1) % 65536
         array = self.msg.color(self.model._model, Mesh.sequence,
                                Mesh.pixels, Listen.unk, self.ama_check)
         self.mesh_conn.send(array)
Ejemplo n.º 2
0
 def run(self, params, expires_at=None):
     self.start_socket()
     # get necessary informations
     self.rows = SchedulerState.get_rows()
     self.cols = SchedulerState.get_cols()
     # get the pixels to address
     self.pos_unknown = loads(
         Websock.get_pos_unk())  #format {'@mac1' : ((x,j), index), ...}}
     self.params = params
     print_flush("Launched AMA app with {0} parameter".format(
         self.params['mode']))
     if (self.params['mode'] == 'ama'
         ):  # assisted manual addressing : reset the position of all pixels
         Websock.send_pixels({})
     elif (self.params['mode'] == 'rac'):
         # hot assisted readdressing : reattribute the unusued pixel indexes (get from deconnected pixels) without changing already addressed pixels
         self.deco = loads(Websock.get_deco())
         array = []
         for key in self.deco.keys(
         ):  #Generate the list of all free cells for the frontend
             value = self.deco[key]
             array += [value[0]]
         self.send_pixel_down(array)  #sends this list to the frontend
         self.reattributing_indexes()  #update the dictionnaries
     #Put esp root in ADDR or CONF state, depending on the current state of the server : indicate start of procedure
     Websock.send_esp_state(0)
     if self.params['mode'] == 'skip':
         self.skip_procedure()
         sleep(1)
     else:
         self.addressing_procedure()
     #publish on REDIS and save in DB the new pixels dictionary
     self.update_DB()
     #Put ESPs in COLOR state
     Websock.send_esp_state(1)
     self.visual_verification()
     self.wait_to_be_kill()