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 opcua.ua import Variant, VariantType 

10 

11from hvl_ccb.configuration import configdataclass 

12from . import constants 

13from .base import ( 

14 Supercube2015Base, 

15 SupercubeOpcUaCommunication, 

16 SupercubeOpcUaCommunicationConfig, 

17) 

18 

19 

20@configdataclass 

21class SupercubeAOpcUaConfiguration(SupercubeOpcUaCommunicationConfig): 

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

23 

24 

25class SupercubeAOpcUaCommunication(SupercubeOpcUaCommunication): 

26 @staticmethod 

27 def config_cls(): 

28 return SupercubeAOpcUaConfiguration 

29 

30 

31class Supercube2015WithFU(Supercube2015Base): 

32 """ 

33 Variant A of the Supercube with frequency converter. 

34 """ 

35 

36 @staticmethod 

37 def default_com_cls(): 

38 return SupercubeAOpcUaCommunication 

39 

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

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( 

48 constants.Power.voltage_target, 

49 Variant(volt_v / 1000, varianttype=VariantType.Float), 

50 ) 

51 

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`. 

56 

57 :return: the setpoint voltage in V. 

58 """ 

59 

60 return float(self.read(constants.Power.voltage_target)) * 1000 

61 

62 def get_max_voltage(self) -> float: 

63 """ 

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

65 

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

67 """ 

68 

69 return float(self.read(constants.Power.voltage_max)) * 1000 

70 

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. 

75 

76 :param slope: voltage slope in V/s (0..15'000) 

77 """ 

78 

79 self.write( 

80 constants.Power.voltage_slope, 

81 Variant(slope / 1000, varianttype=VariantType.Float), 

82 ) 

83 

84 def get_primary_voltage(self) -> float: 

85 """ 

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

87 before transformer). 

88 

89 :return: primary voltage in V 

90 """ 

91 

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

93 

94 def get_primary_current(self) -> float: 

95 """ 

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

97 before transformer). 

98 

99 :return: primary current in A 

100 """ 

101 

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

103 

104 def get_frequency(self) -> float: 

105 """ 

106 Read the electrical frequency of the current Supercube setup. 

107 

108 :return: the frequency in Hz 

109 """ 

110 

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

112 

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

114 """ 

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

116 

117 :return: the power setup 

118 """ 

119 

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

121 

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. 

126 

127 :return: state of the FSO functionality 

128 """ 

129 

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

131 

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

137 

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

139 sleep(0.1) 

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