def _connect(self, port_param=1, rs232_baud_param=9600, skip=False, **kwargs): code = 0 if (skip == False): self.disconnect() self.it.disconnect() # disconnect it serial port if rs232_baud_param == 0: baud, success = self.it.connect(port_param, 0) print baud, success if success != 'Connected': return (baud, success) rs232_baud_param = baud self.it.disconnect() # disconnect it serial port code = self._open_rs232_port(port_param, rs232_baud_param) if (code != 0): return (code, Utility.ERROR_CODES[code]) # Sucessfully connected. self._system = System.System() #self._logger = Logger.Logger() #pb may be commented out ### (result_detect_mode, firmware_version) = self._system.detectMode() if (result_detect_mode == 0): code = -501 return (code, 'Laser not detected') ### self._firmware_version = firmware_version #self._logger.bridgeFile(System.bridgePath(firmware_version)) #pb may be commented out dm = Dictionary.DictionaryManager() self._dictionary_manager = dm if not dm.shelf(System.bridgePath(firmware_version)): print "Unable to find bridge files in " + System.bridgePath( firmware_version) code = -500 return (code, 'Firmware version [%s] not supported.' % (firmware_version)) self.it.setupFromTMode(True) self._root_dictionary = dm.rootDictionary() d = Dictionary.Dictionary() # Give it a valid memory object d.memory(dm.dictionary('SYSTEM_DICTIONARY').memory()) d.addEntry('system', dm.dictionary('SYSTEM_DICTIONARY')) # Some firmware version may not have this dictionary try: d.addEntry('ipc_defaults', dm.dictionary('IPC_DICTIONARY')) except: pass if self.it.getLaserType() == 5: # FIXME: why is this None? self.type = 2 else: self.type = 0 self._system.dictionary(d) self._sample_stage = Sample.SampleStage() self._domain_stage = Domain.DomainStage(self.type) self._domain_stage.dictionary(dm.dictionary('DOMAIN_DICTIONARY')) self._control_stage = Control.ControlStage(dm) self._tuner = Tuner.TunerManager(self, dm) self._discrete_stage = Discrete.DiscreteStage() self._discrete_stage.dictionary(dm.dictionary('DISCRETE_DICTIONARY')) self._side_mode_balancer = SideModeBalancer.SideModeBalancer() self._side_mode_balancer.dictionary( dm.dictionary('SIDE_MODE_BALANCER_DICTIONARY')) self._ambient_compensator = AmbientCompensator.AmbientCompensator() self._ambient_compensator.dictionary( dm.dictionary('AMBIENT_COMPENSATOR_DICTIONARY')) self._modem = MODEM.MODEM() self._modem.dictionary(dm.dictionary('MODEM_DICTIONARY')) self._health = Health.Health() self._health.dictionary(dm.dictionary('HEALTH_DICTIONARY')) self.shortcut_definition() #pb self._dictionary_manager.restore() self._need_restore = 1 return (code, '%s %s' % (Utility.ERROR_CODES[code], firmware_version))
def tmode(self, kvdict=None, mode=1, nano=None): if (mode != 1): self._system.send_code_abort_PicassoTalk() return ### (self.laserType, firmware_version ) = self._system.detectMode() # leaves in picasso tmode if (self.laserType == 0): print('Laser not detected') return self._firmware_version = firmware_version if nano is None: if self.it.getLaserType() == 5: # FIXME: why is this None? Nano = True else: Nano = False else: Nano = nano if Nano and (kvdict == None): # NANO print 'Error: Nano detected, kvdict parameter is needed!' return dm = Dictionary.DictionaryManager(kvdict) self._dictionary_manager = dm if Nano == False: # not NANO if not dm.shelf(System.bridgePath(firmware_version)): print "Unable to find bridge files in " + System.bridgePath( firmware_version) print('Firmware version [%s] not supported.' % (firmware_version)) return self.it.setupFromTMode(True) self._root_dictionary = dm.rootDictionary() d = Dictionary.Dictionary() if Nano == False: # not NANO # Give it a valid memory object d.memory(dm.dictionary('SYSTEM_DICTIONARY').memory()) d.addEntry('system', dm.dictionary('SYSTEM_DICTIONARY')) # Some firmware version may not have this dictionary try: d.addEntry('ipc_defaults', dm.dictionary('IPC_DICTIONARY')) except: pass else: self.type = 2 self._system.dictionary(d) self._sample_stage = Sample.SampleStage(nano=nano) self._domain_stage = Domain.DomainStage(self.type) self._domain_stage.dictionary(dm.dictionary('DOMAIN_DICTIONARY')) self._control_stage = Control.ControlStage(dm) self._tuner = Tuner.TunerManager(self, dm, Nano) self._discrete_stage = Discrete.DiscreteStage() self._discrete_stage.dictionary(dm.dictionary('DISCRETE_DICTIONARY')) self._side_mode_balancer = SideModeBalancer.SideModeBalancer() self._side_mode_balancer.dictionary( dm.dictionary('SIDE_MODE_BALANCER_DICTIONARY')) self._ambient_compensator = AmbientCompensator.AmbientCompensator() self._ambient_compensator.dictionary( dm.dictionary('AMBIENT_COMPENSATOR_DICTIONARY')) self._modem = MODEM.MODEM() self._modem.dictionary(dm.dictionary('MODEM_DICTIONARY')) self._health = Health.Health() self._health.dictionary(dm.dictionary('HEALTH_DICTIONARY')) self.shortcut_definition() #pb self._dictionary_manager.restore() self._need_restore = 1 self._system.picassoMode(True) return