Пример #1
0
    def IsLongWaveMode(self):
        """
        IsLongWaveMode() -> bool

        Return whether the server is using long wave mode.
        """
        return Plexon.PL_IsLongWaveMode()
Пример #2
0
    def IsSortClientRunning(self):
        """
        IsSortClientRunning() -> bool

        Return whether the SortClient is running. 
        """
        return Plexon.PL_IsSortClientRunning()
Пример #3
0
    def GetTimeStampTick(self):
        """
        GetTimeStampTick() -> integer

        Return timestamp resolution in microseconds.
        """
        return Plexon.PL_GetTimeStampTick()
Пример #4
0
    def CloseClient(self):
        """
        CloseClient() 

        Cleans up PlexClient.dll (deletes CClient object) and
        Sends ClientDisconnected command to the server.
        The server decrements the counter for the number of connected clients.
        """
        if not self.library:
            return
        Plexon.PL_CloseClient()
Пример #5
0
    def InitClient(self):
        """
        InitClient() 

        Initializes PlexClient.dll for a client. Opens MMF's and registers the client with the server. Remeber to close the client by yourself. Or try the 'with' statement to initialize the PlexClient class.
        """
        if not self.library:
            logger.warning('Failed to load Plexon client library.')
            return
        if not Plexon.PL_InitClientEx3(0, None, None):
            raise RuntimeError("Failed to initiate Plexon client.")
        TimeStampTick = self.GetTimeStampTick()
        if not TimeStampTick in (25, 40, 50):
            raise RuntimeError("Failed to get timestamp tick.")
        self.MAPSampleRate = 1000 / TimeStampTick * 1000
Пример #6
0
    def GetTimeStampArrays(self, num=MAX_MAP_EVENTS_PER_READ):
        """
        GetTimeStampArrays(num) -> {'type', 'channel', 'unit', 'timestamp'}

        Return dictionary of recent timestamps.
        Parameters
        ----------
        num: number
            Interger of maximun number of timestamp structures

        Returns
        -------
        'type', 'channel', 'unit', 'timestamp': dict keys
            Values are four 1-D arrays of the timestamp structure fields. The array length is the actual transferred TimeStamps.
            'timestamp' is converted to seconds.
        """
        num = ctypes.c_int(num)
        data = {}
        if self.library:
            Plexon.PL_GetTimeStampArrays(
                ctypes.byref(num),
                self.EventTypeArray.ctypes.data_as(
                    ctypes.POINTER(ctypes.c_short)),
                self.EventChannelArray.ctypes.data_as(
                    ctypes.POINTER(ctypes.c_short)),
                self.EventUnitArray.ctypes.data_as(
                    ctypes.POINTER(ctypes.c_short)),
                self.EventTimestampArray.ctypes.data_as(
                    ctypes.POINTER(ctypes.c_int)))
            data['type'] = self.EventTypeArray[:num.value]
            data['channel'] = self.EventChannelArray[:num.value]
            data['unit'] = self.EventUnitArray[:num.value]
            # make man readable timestamp
            data[
                'timestamp'] = self.EventTimestampArray[:num.
                                                        value] / self.MAPSampleRate
        else:
            data['type'] = np.empty(0, dtype=np.uint16)
            data['channel'] = np.empty(0, dtype=np.uint16)
            data['unit'] = np.empty(0, dtype=np.uint16)
            data['timestamp'] = np.empty(0)
        return data
Пример #7
0
    def GetTimeStampStructures(self, num=MAX_MAP_EVENTS_PER_READ):
        """
        GetTimeStampStructures(num) -> (num, array)

        Get recent timestamp number and structures.
        Parameters
        -------
        num: number
            Interger of maximun number of timestamp structures

        Returns
        -------
        num: number 
            Number of actual number of timestamp structures transferred
        array: ctype array
            Array of PL_Event structures filled with new data
        """
        num = ctypes.c_int(num)
        Plexon.PL_GetTimeStampStructures(
            ctypes.byref(num), ctypes.byref(self.ServerEventBuffer[0]))
        return (num.value, self.ServerEventBuffer)
Пример #8
0
 def MarkEvent(self, channel):
     return Plexon.PL_SendUserEvent(channel)