Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions PIPython/PILogger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
""" Configurations for the PIPython specific logger."""

# Module name "PIlogger" doesn't conform to snake_case naming style pylint: disable=C0103
import logging

__signature__ = 0x66ef14bfe1755410b037a7100e4867bb

PILogger = logging.getLogger('PIlogger')
ch = logging.StreamHandler()
ch.setLevel(logging.NOTSET)
formatter = logging.Formatter('%(name)s:%(levelname)s: %(message)s')
ch.setFormatter(formatter)
PILogger.addHandler(ch)

PIDebug = PILogger.debug
PIInfo = PILogger.info
PIWarning = PILogger.warning
PIError = PILogger.error
PICritical = PILogger.critical

DEBUG = logging.DEBUG
INFO = logging.INFO
WARNING = logging.WARNING
ERROR = logging.ERROR
CRITICAL = logging.CRITICAL
16 changes: 16 additions & 0 deletions PIPython/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Collection of libraries to use PI controllers and process GCS data."""

from .PILogger import PILogger, DEBUG, INFO, WARNING, ERROR, CRITICAL
from .PILogger import PIDebug, PIInfo, PIWarning, PIError, PICritical
from .pidevice import GCS2Device, GCS30Device, GCS2Commands, GCS30Commands
from .pidevice import gcserror
from .pidevice.gcsdevice import GCSDevice
from .pidevice.gcserror import GCSError
from .version import __version__


__all__ = ['GCSDevice', 'GCS2Device', 'GCS30Device', 'GCS2Commands', 'GCS30Commands', '__version__', 'PILogger',
'PIDebug', 'PIInfo', 'PIWarning', 'PIError', 'PICritical', 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']
__signature__ = 0xe2b870f5a6ef3b5fb5a7203a92bd6d31
9 changes: 9 additions & 0 deletions PIPython/datarectools/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Collection of interfaces to PI controllers."""

# Wildcard import datarectools pylint: disable=W0401
from .datarectools import *
from ..pidevice.gcs2.gcs2datarectools import *

__signature__ = 0x43bdf66315477455f0df97bc3bc11492
79 changes: 79 additions & 0 deletions PIPython/datarectools/datarectools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Tools for setting up and using the data recorder of a PI device."""

__signature__ = 0x3e5112fc34b726384b36efebbc6f6b79

from ..pidevice.common.gcsbasedatarectools import GCSBaseDatarecorder
from ..pidevice.gcs2.gcs2datarectools import GCS2Datarecorder
from ..pidevice.gcs30.gcs30datarectools import GCS30Datarecorder
from ..pidevice.gcs30.gcs30commands_helpers import isgcs30
from ..pidevice.gcs30.gcs30error import GCS30Error
from ..pidevice.common.gcscommands_helpers import isdeviceavailable


class Datarecorder():
"""
Retuns an instance to the data recorder tools Datarecorder
"""
def __init__(self, gcs, recorder_id=''):
self._gcs = gcs
self._recorder_id = recorder_id
self._datarecorder = GCSBaseDatarecorder(gcs=gcs)

self._gcs.messages.interface.register_connection_status_changed_callback(self.connection_status_changed)

if self._gcs.messages and self._gcs.messages.connected:
self._downcaste_datarecorder_if_necessary()

def __getattr__(self, name):
return getattr(self._datarecorder, name)

def __setattr__(self, name, value):
private_name = name
if not name.startswith('_'):
private_name = '_' + private_name

if '_datarecorder' in self.__dict__ and private_name not in self.__dict__:
self._datarecorder.__setattr__(name, value)
else:
self.__dict__[name] = value

def __enter__(self):
return self

def __exit__(self, exc_type, exc_val, exc_tb):
self._cleanup()

def __del__(self):
self._cleanup()

def _cleanup(self):
self._gcs.messages.interface.unregister_connection_status_changed_callback(self.connection_status_changed)

@property
def datarecorder(self):
"""
returns the datarecorder object
:return: instance of GCSBaseDatarecorder or GCS2Datarecorder or GCS30Datarecorder
"""
return self._datarecorder

def connection_status_changed(self, gateway):
"""
Callback called by the gateway if the connection state has changed
:param gateway: the gateway
"""
if gateway.connected:
self. _downcaste_datarecorder_if_necessary()

def _downcaste_datarecorder_if_necessary(self):
if isdeviceavailable([GCSBaseDatarecorder, ], self._datarecorder):
if isgcs30(self._gcs.messages):
datarecorder = GCS30Datarecorder(self._gcs, self._recorder_id)
self._gcs.messages.gcs_error_class = GCS30Error
else:
datarecorder = GCS2Datarecorder(self._gcs)

datarecorder.__dict__.update(self._datarecorder.__dict__)
self._datarecorder = datarecorder
9 changes: 9 additions & 0 deletions PIPython/fastaligntools/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Collection of interfaces to PI controllers."""

# Wildcard import fastaligntools pylint: disable=W0401
from .fastaligntools import *
from ..pidevice.gcs2.gcs2fastaligntools import *

__signature__ = 0x15f249f92147d9b09ff22fd2cadd834a
58 changes: 58 additions & 0 deletions PIPython/fastaligntools/fastaligntools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Tools for using the fast alignment routines of a PI device."""

__signature__ = 0x3fa44e8fabc96bb0c40d27198cff23f6

# Class inherits from object, can be safely removed from bases in python3 pylint: disable=R0205
class TargetType(object): # Too few public methods pylint: disable=R0903
"""Enum for TargetType."""
name = {
0: 'Sinusoidal', 1: 'Spiral constant frequency', 2: 'Spiral constant path velocity',
}
sinusoidal = 0
spiral_constant_frequency = 1
spiral_constant_path_velocity = 2


# Class inherits from object, can be safely removed from bases in python3 pylint: disable=R0205
class EstimationMethod(object): # Too few public methods pylint: disable=R0903
"""Enum for EstimationMethod."""
name = {
0: 'Maximum value', 1: 'Gaussian ls fit', 2: 'Center of gravity',
}
maximum_value = 0
gaussian_ls_fit = 1
center_of_gravity = 2


# Class inherits from object, can be safely removed from bases in python3 pylint: disable=R0205
class StopOption(object): # Too few public methods pylint: disable=R0903
"""Enum for StopOption."""
name = {
0: 'Move to maximum intensity', 1: 'Stay at end of scan', 2: 'Move to start of scan', 3: 'Stop at threshold',
4: 'Continuous until threshold',
}
move_to_maximum_intensity = 0
stay_at_end_of_scan = 1
move_to_start_of_scan = 2
stop_at_threshold = 3
continuous_until_threshold = 4


# Class inherits from object, can be safely removed from bases in python3 pylint: disable=R0205
class ResultID(object): # Too few public methods pylint: disable=R0903
"""Enum for ResultID."""
name = {
1: 'Success', 2: 'Maximum value', 3: 'Maximum position', 4: 'Routine definition', 5: 'Scan time',
6: 'Reason of abort', 7: 'Radius', 8: 'Number of direction changes', 9: 'Gradient length',
}
success = 1
max_value = 2
max_position = 3
routine_definition = 4
scan_time = 5
reason_of_abort = 6
radius = 7
number_direction_changes = 8
gradient_length = 9
16 changes: 16 additions & 0 deletions PIPython/gcscommands/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Collection of libraries to use PI controllers and process GCS data."""

import warnings
# Wildcard import pipython.pidevice.common.gcscommands_helpers pylint: disable=W0401
from pipython.pidevice.gcscommands import *
# Redefining built-in 'unicode' pylint: disable=W0622
# Redefining built-in 'basestring' pylint: disable=W0622
from pipython.pidevice.common.gcscommands_helpers import *

warnings.warn("Please use 'pipython.pidevice.gcscommands' instead", DeprecationWarning)

__all__ = ['GCSCommands']

__signature__ = 0x1355c2889da4f7f7e9ec8308ed3a815f
13 changes: 13 additions & 0 deletions PIPython/gcserror/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Collection of libraries to use PI controllers and process GCS data."""

import warnings
# Wildcard import pipython.pidevice.gcserror pylint: disable=W0401
from pipython.pidevice.gcserror import *

warnings.warn("Please use 'pipython.pidevice.gcserror' instead", DeprecationWarning)

__all__ = ['GCSError']

__signature__ = 0xd0ac5fff7ef5b0e006e959b7755d01c3
13 changes: 13 additions & 0 deletions PIPython/gcsmessages/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Collection of libraries to use PI controllers and process GCS data."""

import warnings
# Wildcard import pipython.pidevice.gcsmessages pylint: disable=W0401
from pipython.pidevice.gcsmessages import *

warnings.warn("Please use 'pipython.pidevice.gcsmessages' instead", DeprecationWarning)

__all__ = ['GCSMessages']

__signature__ = 0xfc844ad2f6e69854add51ed6da5d9e3c
5 changes: 5 additions & 0 deletions PIPython/interfaces/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Collection of libraries to use PI controllers and process GCS data."""

__signature__ = 0xa19734b129c097a658c7f2713534ffd8
13 changes: 13 additions & 0 deletions PIPython/interfaces/gcsdll/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Collection of libraries to use PI controllers and process GCS data."""

import warnings
# Wildcard import pipython.pidevice.interfaces.gcsdll pylint: disable=W0401
from pipython.pidevice.interfaces.gcsdll import *

warnings.warn("Please use 'pipython.pidevice.interfaces.gcsdll' instead", DeprecationWarning)

__all__ = ['GCSDll']

__signature__ = 0xfe7a64230a066b15f72775cd1732d381
13 changes: 13 additions & 0 deletions PIPython/interfaces/pigateway/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Collection of libraries to use PI controllers and process GCS data."""

import warnings
# Wildcard import pipython.pidevice.interfaces.pigateway pylint: disable=W0401
from pipython.pidevice.interfaces.pigateway import *

warnings.warn("Please use 'pipython.pidevice.interfaces.pigateway' instead", DeprecationWarning)

__all__ = ['PIGateway']

__signature__ = 0xcca0e8699c57b617e35b0767f3136290
13 changes: 13 additions & 0 deletions PIPython/interfaces/piserial/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Collection of libraries to use PI controllers and process GCS data."""

import warnings
# Wildcard import pipython.pidevice.interfaces.piserial pylint: disable=W0401
from pipython.pidevice.interfaces.piserial import *

warnings.warn("Please use 'pipython.pidevice.interfaces.piserial' instead", DeprecationWarning)

__all__ = ['PISerial']

__signature__ = 0xfe1208deaa1f62021f2d00f9a45892cc
13 changes: 13 additions & 0 deletions PIPython/interfaces/pisocket/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Collection of libraries to use PI controllers and process GCS data."""

import warnings
# Wildcard import pipython.pidevice.interfaces.pisocket pylint: disable=W0401
from pipython.pidevice.interfaces.pisocket import *

warnings.warn("Please use 'pipython.pidevice.interfaces.pisocket' instead", DeprecationWarning)

__all__ = ['PISocket']

__signature__ = 0x874d9b1e6a272641b5525a18e30cd747
13 changes: 13 additions & 0 deletions PIPython/interfaces/piusb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Collection of libraries to use PI controllers and process GCS data."""

import warnings
# Wildcard import pipython.pidevice.interfaces.piusb pylint: disable=W0401
from pipython.pidevice.interfaces.piusb import *

warnings.warn("Please use 'pipython.pidevice.interfaces.piusb' instead", DeprecationWarning)

__all__ = ['PIUSB']

__signature__ = 0x9af11ca53559f63ad5ac5d5ad8b85fe8
17 changes: 17 additions & 0 deletions PIPython/pidevice/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Collection of libraries to use PI controllers and process GCS data."""

from . import gcserror
from .gcserror import GCSError
from .gcs2.gcs2commands import GCS2Commands
from .gcs2.gcs2device import GCS2Device
from .gcs30.gcs30commands import GCS30Commands
from .gcs30.gcs30device import GCS30Device
from .gcs30.gcs30commands_helpers import isgcs30
from .gcs30.gcs30error import GCS30Error
from .gcsdevice import GCSDevice

__all__ = ['GCSDevice', 'GCS2Device', 'GCS30Device', 'GCS2Commands', 'GCS30Commands', 'isgcs30']

__signature__ = 0xb95fbfed9f30a0eb1dcfb34eca5dd938
5 changes: 5 additions & 0 deletions PIPython/pidevice/common/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Collection of interfaces to PI controllers."""

__signature__ = 0x8802c221f71d24cf31a372eac91fea05
Loading