# *****************************************************************************
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# Module authors:
#   Markus Zolliker <markus.zolliker@psi.ch>
# *****************************************************************************
"""LakeShore Model 350"""

from frappy.core import Parameter, IntRange, FloatRange
import frappy_psi.lakeshore as ls


class IO(ls.IO):
    model = 350


class Device(ls.Device2):
    model = 350


class Sensor(ls.Sensor):
    model = 350

    def get_curve_type(self, calcurve):
        logformat, range_limit = super().get_curve_type(calcurve)
        excit = 0
        if self.intype[0] == 3 and calcurve.calibrange[0] > 0.2:
            excit = 1  # TODO: add extra parameter for excitation
        self.intype += (excit,)
        return logformat, range_limit


class Loop(ls.Loop, Sensor):
    pass


class MainOutput(ls.Output):
    model = 350
    output_no = Parameter(datatype=IntRange(1, 1))
    imax = 1.732
    max_power = Parameter(datatype=FloatRange(0, 75, unit='W'))


class AnalogOutput(ls.AnalogOutput):
    model = 350
    output_no = Parameter(datatype=IntRange(3,4))
