コード例 #1
0
ファイル: dmc_41x3.py プロジェクト: spauka/Qcodes
    def __init__(self, parent: "DMC4133Controller", name: str,
                 **kwargs: Any) -> None:
        """
        Initializes the vector mode submodule for the controller

        Args:
            parent: an instance of DMC4133Controller
            name: name of the vector mode plane
        """
        super().__init__(parent, name, **kwargs)
        self._plane = name
        self._vector_position_validator = Ints(min_value=-2147483648,
                                               max_value=2147483647)

        self.add_parameter(
            "coordinate_system",
            get_cmd="CA ?",
            get_parser=self._parse_coordinate_system_active,
            set_cmd="CA {}",
            vals=Enum("S", "T"),
            docstring="activates coordinate system for the motion. Two "
            " coordinate systems are possible with values "
            "'S' and 'T'. All vector mode commands will apply to "
            "the active coordinate system.",
        )

        self.add_parameter(
            "vector_acceleration",
            get_cmd="VA ?",
            get_parser=lambda s: int(float(s)),
            set_cmd="VA {}",
            vals=Multiples(min_value=1024, max_value=1073740800, divisor=1024),
            unit="counts/sec2",
            docstring="sets and gets the defined vector's acceleration",
        )

        self.add_parameter(
            "vector_deceleration",
            get_cmd="VD ?",
            get_parser=lambda s: int(float(s)),
            set_cmd="VD {}",
            vals=Multiples(min_value=1024, max_value=1073740800, divisor=1024),
            unit="counts/sec2",
            docstring="sets and gets the defined vector's deceleration",
        )

        self.add_parameter(
            "vector_speed",
            get_cmd="VS ?",
            get_parser=lambda s: int(float(s)),
            set_cmd="VS {}",
            vals=Multiples(min_value=2, max_value=15000000, divisor=2),
            unit="counts/sec",
            docstring="sets and gets defined vector's speed",
        )
コード例 #2
0
ファイル: dmc_41x3.py プロジェクト: spauka/Qcodes
    def __init__(self, name: str, address: str, **kwargs: Any) -> None:
        """
        Initializes the DMC4133Controller class

        Args:
            name: name for the instance
            address: address of the controller burned in
        """
        super().__init__(name=name, address=address, **kwargs)

        self.add_parameter(
            "position_format_decimals",
            get_cmd=None,
            set_cmd="PF 10.{}",
            vals=Ints(0, 4),
            docstring="sets number of decimals in the format "
            "of the position",
        )

        self.add_parameter(
            "absolute_position",
            get_cmd=self._get_absolute_position,
            set_cmd=None,
            unit="quadrature counts",
            docstring="gets absolute position of the motors "
            "from the set origin",
        )

        self.add_parameter(
            "wait",
            get_cmd=None,
            set_cmd="WT {}",
            unit="ms",
            vals=Multiples(min_value=2, max_value=2147483646, divisor=2),
            docstring="controller will wait for the amount of "
            "time specified before executing the next "
            "command",
        )

        self._set_default_update_time()
        self.add_submodule("motor_a", Motor(self, "A"))
        self.add_submodule("motor_b", Motor(self, "B"))
        self.add_submodule("motor_c", Motor(self, "C"))
        self.add_submodule("plane_ab", VectorMode(self, "AB"))
        self.add_submodule("plane_bc", VectorMode(self, "BC"))
        self.add_submodule("plane_ac", VectorMode(self, "AC"))
コード例 #3
0
    def test_divisors(self):
        for d in self.divisors:
            n = Multiples(divisor=d)
            for v in [d * e for e in self.multiples]:
                n.validate(v)

            for v in self.multiples:
                if v == 0:
                    continue
                with self.assertRaises(ValueError):
                    n.validate(v)

            for v in self.not_multiples:
                with self.assertRaises(TypeError):
                    n.validate(v)

        for d in self.not_divisors:
            with self.assertRaises(TypeError):
                n = Multiples(divisor=d)

        n = Multiples(divisor=3, min_value=1, max_value=10)
        self.assertEqual(repr(n), '<Ints 1<=v<=10, Multiples of 3>')
コード例 #4
0
ファイル: dmc_41x3.py プロジェクト: spauka/Qcodes
    def __init__(self, parent: "DMC4133Controller", name: str,
                 **kwargs: Any) -> None:
        """
        Initializes individual motor submodules

        Args:
            parent: an instance of DMC4133Controller
            name: name of the motor to be controlled
        """
        super().__init__(parent, name, **kwargs)
        self._axis = name

        self.add_parameter(
            "relative_position",
            unit="quadrature counts",
            get_cmd=f"MG _PR{self._axis}",
            get_parser=lambda s: int(float(s)),
            set_cmd=self._set_relative_position,
            vals=Ints(-2147483648, 2147483647),
            docstring="sets relative position for the motor's move",
        )

        self.add_parameter(
            "speed",
            unit="counts/sec",
            get_cmd=f"MG _SP{self._axis}",
            get_parser=lambda s: int(float(s)),
            set_cmd=self._set_speed,
            vals=Multiples(min_value=0, max_value=3000000, divisor=2),
            docstring="speed for motor's motion",
        )

        self.add_parameter(
            "acceleration",
            unit="counts/sec2",
            get_cmd=f"MG _AC{self._axis}",
            get_parser=lambda s: int(float(s)),
            set_cmd=self._set_acceleration,
            vals=Multiples(min_value=1024, max_value=1073740800, divisor=1024),
            docstring="acceleration for motor's motion",
        )

        self.add_parameter(
            "deceleration",
            unit="counts/sec2",
            get_cmd=f"MG _DC{self._axis}",
            get_parser=lambda s: int(float(s)),
            set_cmd=self._set_deceleration,
            vals=Multiples(min_value=1024, max_value=1073740800, divisor=1024),
            docstring="deceleration for motor's motion",
        )

        self.add_parameter(
            "off_when_error_occurs",
            get_cmd=self._get_off_when_error_occurs,
            set_cmd=self._set_off_when_error_occurs,
            val_mapping={
                "disable": 0,
                "enable for position, amp error or abort": 1,
                "enable for hw limit switch": 2,
                "enable for all": 3,
            },
            docstring="enables or disables the motor to "
            "automatically turn off when error occurs",
        )

        self.add_parameter(
            "reverse_sw_limit",
            unit="quadrature counts",
            get_cmd=f"MG _BL{self._axis}",
            get_parser=lambda s: int(float(s)),
            set_cmd=self._set_reverse_sw_limit,
            vals=Ints(-2147483648, 2147483647),
            docstring="can be used to set software reverse limit for the motor."
            " motor motion will stop beyond this limit automatically."
            " default value is -2147483648. this value effectively "
            "disables the reverse limit.",
        )

        self.add_parameter(
            "forward_sw_limit",
            unit="quadrature counts",
            get_cmd=f"MG _FL{self._axis}",
            get_parser=lambda s: int(float(s)),
            set_cmd=self._set_forward_sw_limit,
            vals=Ints(-2147483648, 2147483647),
            docstring="can be used to set software forward limit for the motor."
            " motor motion will stop beyond this limit automatically."
            " default value is 2147483647. this value effectively "
            "disables the forward limit.",
        )
コード例 #5
0
    def test_valid_values(self):

        for d in self.divisors:
            n = Multiples(divisor=d)
            for num in n.valid_values:
                n.validate(num)
コード例 #6
0
ファイル: test_multiples.py プロジェクト: yuiponpon/Qcodes
def test_divisors():
    for d in divisors:
        n = Multiples(divisor=d)
        for v in [d * e for e in multiples]:
            n.validate(v)

        for v in multiples:
            if v == 0:
                continue
            with pytest.raises(ValueError):
                n.validate(v)

        for v in not_multiples:
            with pytest.raises(TypeError):
                n.validate(v)

    for d in not_divisors:
        with pytest.raises(TypeError):
            n = Multiples(divisor=d)

    n = Multiples(divisor=3, min_value=1, max_value=10)
    assert repr(n) == '<Ints 1<=v<=10, Multiples of 3>'
コード例 #7
0
    def test_valid_values(self):

        for d in self.divisors:
            n = Multiples(divisor=d)
            n.validate(n._valid_values[0])