def __init__(self, experiment, dev=None): try: import clr clr.AddReference("System.Reflection") from System.Reflection import Assembly directory=os.getcwd() print(directory) pluginfolder = os.dirname(__file__) Assembly.UnsafeLoadFrom(directory+'\share\opensesame_plugins\Pulse_EVT2\HidSharp.dll') Assembly.UnsafeLoadFrom(directory+'\share\opensesame_plugins\Pulse_EVT2\HidSharp.DeviceHelpers.dll') Assembly.UnsafeLoadFrom(directory+'\share\opensesame_plugins\Pulse_EVT2\EventExchanger.dll') except Exception as e: print(e.Message) print(e.Source) try: self._EVT2 = clr.ID.EventExchanger() print(self._EVT2.Attached()) self._nEVT2 = self._EVT2.Attached().count('/')+1 except Exception as e: raise osexception('EVT2 Error') # print(self._EVT2.Attached()) self.experiment = experiment # If a device has not been specified, autodetect if dev in (None, "", "autodetect"): try: if self._nEVT2 == 1: print("Starting the only attached EVT") self._EVT2.Start() else: print(("Starting device %s" % self._EVT2.Attached().partition('/')[0])) self._EVT2.Start(self._EVT2.Attached().partition('/')[0]) except Exception as e: print(e.Message) raise osexception( "libEVT2 does not know how to auto-detect the EVT on your platform. Please specify a device.") else: try: self._EVT2.Start(str(dev)) except Exception as e: raise osexception( "Failed to open device port '%s' in libEVT2: '%s'" \ % (dev, e)) if self._EVT2 is None: raise osexception( "libEVT2 failed to auto-detect a unique instance of the EVT. Please specify a device.") debug.msg("using device %s" % dev)
def __init__(self, experiment, dev=None): try: import clr clr.AddReference("System.Reflection") from System.Reflection import Assembly directory = os.getcwd() print directory pluginfolder = os.dirname(__file__) Assembly.UnsafeLoadFrom( directory + '\share\opensesame_plugins\Pulse_EVT2\HidSharp.dll') Assembly.UnsafeLoadFrom( directory + '\share\opensesame_plugins\Pulse_EVT2\HidSharp.DeviceHelpers.dll' ) Assembly.UnsafeLoadFrom( directory + '\share\opensesame_plugins\Pulse_EVT2\EventExchanger.dll') except Exception, e: print e.Message print e.Source