Hide keyboard shortcuts

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""" 

6 

7from time import sleep 

8 

9from hvl_ccb.configuration import configdataclass 

10from . import constants 

11from .base import ( 

12 SupercubeBase, 

13 SupercubeOpcUaCommunication, 

14 SupercubeOpcUaCommunicationConfig, 

15) 

16 

17 

18@configdataclass 

19class SupercubeAOpcUaConfiguration(SupercubeOpcUaCommunicationConfig): 

20 endpoint_name: str = constants.SupercubeOpcEndpoint.A.value # type: ignore 

21 

22 

23class SupercubeAOpcUaCommunication(SupercubeOpcUaCommunication): 

24 @staticmethod 

25 def config_cls(): 

26 return SupercubeAOpcUaConfiguration 

27 

28 

29class SupercubeWithFU(SupercubeBase): 

30 """ 

31 Variant A of the Supercube with frequency converter. 

32 """ 

33 

34 @staticmethod 

35 def default_com_cls(): 

36 return SupercubeAOpcUaCommunication 

37 

38 def set_target_voltage(self, volt_v: float) -> None: 

39 """ 

40 **TODO: test set_target_voltage with device** 

41 

42 Set the output voltage to a defined value in V. 

43 

44 :param volt_v: the desired voltage in V 

45 """ 

46 

47 self.write(constants.Power.voltage_target, volt_v) 

48 

49 def get_target_voltage(self) -> float: 

50 """ 

51 **TODO: test get_target_voltage with device** 

52 

53 Gets the current setpoint of the output voltage value in V. This is not a 

54 measured value but is the corresponding function to :meth:`set_target_voltage`. 

55 

56 :return: the setpoint voltage in V. 

57 """ 

58 

59 return float(self.read(constants.Power.voltage_target)) 

60 

61 def get_max_voltage(self) -> float: 

62 """ 

63 **TODO: test get_max_voltage with device** 

64 

65 Reads the maximum voltage of the setup and returns in V. 

66 

67 :return: the maximum voltage of the setup in V. 

68 """ 

69 

70 return float(self.read(constants.Power.voltage_max)) 

71 

72 def set_slope(self, slope: float) -> None: 

73 """ 

74 **TODO: test set_slope with device** 

75 

76 Sets the dV/dt slope of the Supercube frequency converter to a new value in 

77 V/s. 

78 

79 :param slope: voltage slope in V/s (0..15) 

80 """ 

81 

82 self.write(constants.Power.voltage_slope, slope) 

83 

84 def get_primary_voltage(self) -> float: 

85 """ 

86 **TODO: test get_primary_voltage with device** 

87 

88 Read the current primary voltage at the output of the frequency converter ( 

89 before transformer). 

90 

91 :return: primary voltage in V 

92 """ 

93 

94 return float(self.read(constants.Power.voltage_primary)) 

95 

96 def get_primary_current(self) -> float: 

97 """ 

98 **TODO: get_primary_current with device** 

99 

100 Read the current primary current at the output of the frequency converter ( 

101 before transformer). 

102 

103 :return: primary current in A 

104 """ 

105 

106 return float(self.read(constants.Power.current_primary)) 

107 

108 def get_frequency(self) -> float: 

109 """ 

110 **TODO: test get_frequency with device** 

111 

112 Read the electrical frequency of the current Supercube setup. 

113 

114 :return: the frequency in Hz 

115 """ 

116 

117 return float(self.read(constants.Power.frequency)) 

118 

119 def get_power_setup(self) -> constants.PowerSetup: 

120 """ 

121 **TODO: test get_power_setup with device** 

122 

123 Return the power setup selected in the Supercube's settings. 

124 

125 :return: the power setup 

126 """ 

127 

128 return constants.PowerSetup(self.read(constants.Power.setup)) 

129 

130 def get_fso_active(self) -> bool: 

131 """ 

132 **TODO: test get_fso_active with device** 

133 

134 Get the state of the fast switch off functionality. Returns True if it is 

135 enabled, False otherwise. 

136 

137 :return: state of the FSO functionality 

138 """ 

139 

140 return self.read(constants.BreakdownDetection.activated) 

141 

142 def fso_reset(self) -> None: 

143 """ 

144 **TODO: test fso_reset with device** 

145 

146 Reset the fast switch off circuitry to go back into normal state and allow to 

147 re-enable operate mode. 

148 """ 

149 

150 self.write(constants.BreakdownDetection.reset, True) 

151 sleep(0.1) 

152 self.write(constants.BreakdownDetection.reset, False)