Exemplo n.º 1
0
	def Do_Shock_Run(self):
		try:
			self.experiment.get("ShockerCalibration")
		except:
			oslogger.error("No calibration step taken: First run a Shocker in calibration mode!")
			return
		
		if (self.var._productName == u"DUMMY"):
			oslogger.info("In (Dummy) Shock: shocking with value: " + str(self.var._value))
		else:
			try:
				lst = self.experiment.get("lastShockTime")
			except:
				lst = 0;
				
			td = time.time() - lst
			# This line is to prevent the possibility to shock if the previous shock was less then the minimum time ago
			if (td > self.var._min_intershock_interval):
				oslogger.info("In (Hardware) Shock: shocking with value: " + str(math.floor((self.var._value/100.0) * self.experiment.get("ShockerCalibration"))))
				self.EE.SetLines(0)
				self.EE.PulseLines(math.floor((self.var._value/100.0) * self.experiment.get("ShockerCalibration")), self.var._duration)
				# TODO:
				mAh = round((self.var._value/100.0) * self.experiment.get("ShockermAhCalibration"),2)
				self.experiment.set("lastShockTime", time.time()) 
				self.experiment.set("BinaryShockValue", math.floor((self.var._value/100.0) * self.experiment.get("ShockerCalibration"))) 
				self.experiment.set("ShockPercValue", self.var._value)
				self.experiment.set("ShockMahValue", mAh)
			else:
				oslogger.warning("In Shock: the shock came too early: please don't give shocks in rapid succession!")
Exemplo n.º 2
0
 def _listen_for_pdb(self):
      
     #  Wait for next request from client
     try:
         message = self._zmq_socket.recv_pyobj(flags=zmq.NOBLOCK)
     except zmq.error.ZMQError:
         QTimer.singleShot(self._poll_interval, self._listen_for_pdb)
         return
     try:
         self._zmq_socket.send(b'ok')
     except zmq.error.ZMQError:
         oslogger.error('failed to send reply')
     if not isinstance(message, dict) or 'type' not in message:
         oslogger.error('invalid debugger message: {}'.format(str(message)))
     elif message['type'] == 'pdb_start':
         oslogger.debug('debugger session started')
         self._poll_interval = POLL_INTERVAL_SHORT
     elif message['type'] == 'pdb_stop':
         oslogger.debug('debugger session stopped')
         self._poll_interval = POLL_INTERVAL_LONG
     elif message['type'] == 'pdb_frame':
         oslogger.debug('debugger frame received')
         self._poll_interval = POLL_INTERVAL_SHORT
         if os.path.exists(message['path']):
             self.extension_manager.fire(
                 'ide_open_file',
                 path=message['path'],
                 line_number=message['line']
             )
             try:
                 # Refocus the console, not the editor
                 self.extension_manager['JupyterConsole']._focus()
             except Exception:
                 pass
         self.extension_manager.fire(
             'workspace_update',
             name=self.extension_manager.provide('jupyter_workspace_name'),
             workspace_func=(lambda: message['workspace'])
         )
     else:
         oslogger.error(
             'invalid debugger message type: {}'.format(message['type'])
         )
     QTimer.singleShot(self._poll_interval, self._listen_for_pdb)
Exemplo n.º 3
0
    def event_jupyter_write(self, msg):

        try:
            self._jupyter_console.current.write(msg)
        except AttributeError:
            oslogger.error(safe_decode(msg))