Coverage for C:\Users\hjanssen\HOME\pyCharmProjects\ethz_hvl\hvl_ccb\hvl_ccb\dev\supercube2015\typ_a.py : 0%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Copyright (c) 2019-2020 ETH Zurich, SIS ID and HVL D-ITET
2#
3"""
4Supercube Typ A module.
5"""
7from time import sleep
9from opcua.ua import Variant, VariantType
11from hvl_ccb.configuration import configdataclass
12from . import constants
13from .base import (
14 Supercube2015Base,
15 SupercubeOpcUaCommunication,
16 SupercubeOpcUaCommunicationConfig,
17)
20@configdataclass
21class SupercubeAOpcUaConfiguration(SupercubeOpcUaCommunicationConfig):
22 endpoint_name: str = constants.SupercubeOpcEndpoint.A.value # type: ignore
25class SupercubeAOpcUaCommunication(SupercubeOpcUaCommunication):
26 @staticmethod
27 def config_cls():
28 return SupercubeAOpcUaConfiguration
31class Supercube2015WithFU(Supercube2015Base):
32 """
33 Variant A of the Supercube with frequency converter.
34 """
36 @staticmethod
37 def default_com_cls():
38 return SupercubeAOpcUaCommunication
40 def set_target_voltage(self, volt_v: float) -> None:
41 """
42 Set the output voltage to a defined value in V.
44 :param volt_v: the desired voltage in V
45 """
47 self.write(
48 constants.Power.voltage_target,
49 Variant(volt_v / 1000, varianttype=VariantType.Float),
50 )
52 def get_target_voltage(self) -> float:
53 """
54 Gets the current setpoint of the output voltage value in V. This is not a
55 measured value but is the corresponding function to :meth:`set_target_voltage`.
57 :return: the setpoint voltage in V.
58 """
60 return float(self.read(constants.Power.voltage_target)) * 1000
62 def get_max_voltage(self) -> float:
63 """
64 Reads the maximum voltage of the setup and returns in V.
66 :return: the maximum voltage of the setup in V.
67 """
69 return float(self.read(constants.Power.voltage_max)) * 1000
71 def set_slope(self, slope: float) -> None:
72 """
73 Sets the dV/dt slope of the Supercube frequency converter to a new value in
74 V/s.
76 :param slope: voltage slope in V/s (0..15'000)
77 """
79 self.write(
80 constants.Power.voltage_slope,
81 Variant(slope / 1000, varianttype=VariantType.Float),
82 )
84 def get_primary_voltage(self) -> float:
85 """
86 Read the current primary voltage at the output of the frequency converter (
87 before transformer).
89 :return: primary voltage in V
90 """
92 return float(self.read(constants.Power.voltage_primary))
94 def get_primary_current(self) -> float:
95 """
96 Read the current primary current at the output of the frequency converter (
97 before transformer).
99 :return: primary current in A
100 """
102 return float(self.read(constants.Power.current_primary))
104 def get_frequency(self) -> float:
105 """
106 Read the electrical frequency of the current Supercube setup.
108 :return: the frequency in Hz
109 """
111 return float(self.read(constants.Power.frequency))
113 def get_power_setup(self) -> constants.PowerSetup:
114 """
115 Return the power setup selected in the Supercube's settings.
117 :return: the power setup
118 """
120 return constants.PowerSetup(self.read(constants.Power.setup))
122 def get_fso_active(self) -> bool:
123 """
124 Get the state of the fast switch off functionality. Returns True if it is
125 enabled, False otherwise.
127 :return: state of the FSO functionality
128 """
130 return self.read(constants.BreakdownDetection.activated)
132 def fso_reset(self) -> None:
133 """
134 Reset the fast switch off circuitry to go back into normal state and allow to
135 re-enable operate mode.
136 """
138 self.write(constants.BreakdownDetection.reset, True)
139 sleep(0.1)
140 self.write(constants.BreakdownDetection.reset, False)