Ejemplo n.º 1
0
# pylint: disable=E1101, E0611
#! /usr/bin/python
"""QtDesigner test"""
from __future__ import print_function
import sys
import time
import threading
import socket
import pickle
from PyQt4 import Qt, QtCore
from PyQt4.QtGui import QWidget
from temperature_controller_gui_2 import Ui_temp_control
from PyExpLabSys.common.plotters import DataPlotter
from PyExpLabSys.common.supported_versions import python2_only
import temperature_controller_config as config
python2_only(__file__)


class TemperatureControllerComm(threading.Thread):
    """ Communicates with temperature controller over network """
    def __init__(self):
        threading.Thread.__init__(self)
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.sock.settimeout(0.5)
        self.running = True
        self.status = {}
        self.status['temperature'] = 0
        self.status['setpoint'] = 0
        self.status['dutycycle'] = 0
        self.status['connected'] = False
        self.status['temp_connected'] = False
Ejemplo n.º 2
0
"""

from __future__ import print_function, division, unicode_literals
from struct import pack, unpack
from functools import partial
from operator import itemgetter
from collections import OrderedDict
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
from pymodbus.payload import BinaryPayloadDecoder

# At present this driver is Python 2 only, because minimalmodbus, which we usually use for
# modbus communication, doesn't support function code 23, which is used by this
# device. Pymodbus which we had to use instead, so far (Jan. 16) doesn't have mainline
# support for Python 3.
from PyExpLabSys.common.supported_versions import python2_only
python2_only(__file__)


### Classes ###
###############

class PVCCommon(ModbusClient):
    """Common base for the PVCX, PVCi and PVCiDuo devices

    This common class must be sub-classed and the global_id and firmware_name class
    variables overwritten and the self.fields dict updated if necessary. See the
    :class:`.PVCi` inplementation for details.

    All requests for values (parameters) goes via value field names. To get a list of the
    available fields, have a look at the keys in the :attr:`.fields` dict of the common
    class and the sub-class. These fields names can then be used with :meth:`.get_field` and