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

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

## 183 statements

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

4 Constants, variable names for the Supercube OPC-connected devices.

5"""

6

7 from aenum import IntEnum

8

9 from hvl_ccb.utils.enum import ValueEnum, unique

10

11

12 class SupercubeOpcEndpoint(ValueEnum):

13 """

14 OPC Server Endpoint strings for the supercube variants.

15 """

16

17 A = "OPC.SimaticNET.S7"

18 B = "OPC.SimaticNET.S7"

19

20

21@unique

22 class GeneralSupport(ValueEnum):

23 """

24 NodeID strings for the support inputs and outputs.

25 """

26

27 in_1_1 = "hvl-ipc.WINAC.Support1InA"

28 in_1_2 = "hvl-ipc.WINAC.Support1InB"

29 in_2_1 = "hvl-ipc.WINAC.Support2InA"

30 in_2_2 = "hvl-ipc.WINAC.Support2InB"

31 in_3_1 = "hvl-ipc.WINAC.Support3InA"

32 in_3_2 = "hvl-ipc.WINAC.Support3InB"

33 in_4_1 = "hvl-ipc.WINAC.Support4InA"

34 in_4_2 = "hvl-ipc.WINAC.Support4InB"

35 in_5_1 = "hvl-ipc.WINAC.Support5InA"

36 in_5_2 = "hvl-ipc.WINAC.Support5InB"

37 in_6_1 = "hvl-ipc.WINAC.Support6InA"

38 in_6_2 = "hvl-ipc.WINAC.Support6InB"

39 out_1_1 = "hvl-ipc.WINAC.Support1OutA"

40 out_1_2 = "hvl-ipc.WINAC.Support1OutB"

41 out_2_1 = "hvl-ipc.WINAC.Support2OutA"

42 out_2_2 = "hvl-ipc.WINAC.Support2OutB"

43 out_3_1 = "hvl-ipc.WINAC.Support3OutA"

44 out_3_2 = "hvl-ipc.WINAC.Support3OutB"

45 out_4_1 = "hvl-ipc.WINAC.Support4OutA"

46 out_4_2 = "hvl-ipc.WINAC.Support4OutB"

47 out_5_1 = "hvl-ipc.WINAC.Support5OutA"

48 out_5_2 = "hvl-ipc.WINAC.Support5OutB"

49 out_6_1 = "hvl-ipc.WINAC.Support6OutA"

50 out_6_2 = "hvl-ipc.WINAC.Support6OutB"

51

52 @classmethod

53 def output(cls, port, contact):

54 """

55 Get the NodeID string for a support output.

56

57 :param port: the desired port (1..6)

58 :param contact: the desired contact at the port (1..2)

59 :return: the node id string

60 """

61

62 return getattr(cls, "out_{}_{}".format(port, contact))

63

64 @classmethod

65 def input(cls, port, contact):

66 """

67 Get the NodeID string for a support input.

68

69 :param port: the desired port (1..6)

70 :param contact: the desired contact at the port (1..2)

71 :return: the node id string

72 """

73

74 return getattr(cls, "in_{}_{}".format(port, contact))

75

76

77@unique

78 class BreakdownDetection(ValueEnum):

79 """

80 Node ID strings for the breakdown detection.

81 """

82

83 #: Boolean read-only variable indicating whether breakdown detection and fast

84 #: switchoff is enabled in the system or not.

85 activated = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.Breakdowndetection.connect"

86

87 #: Boolean read-only variable telling whether the fast switch-off has triggered.

88 #: This can also be seen using the safety circuit state, therefore no method is

89 #: implemented to read this out directly.

90 triggered = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.Breakdowndetection.triggered"

91

92 #: Boolean writable variable to reset the fast switch-off. Toggle to re-enable.

93 reset = "hvl-ipc.WINAC.Support6OutA"

94

95

96@unique

97 class GeneralSockets(ValueEnum):

98 """

99 NodeID strings for the power sockets (3x T13 and 1xCEE16).

100 """

101

102 #: SEV T13 socket No. 1 (writable boolean).

103 t13_1 = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.T13_1"

104

105 #: SEV T13 socket No. 2 (writable boolean).

106 t13_2 = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.T13_2"

107

108 #: SEV T13 socket No. 3 (writable boolean).

109 t13_3 = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.T13_3"

110

111 #: CEE16 socket (writeable boolean).

112 cee16 = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.CEE16"

113

114

115 T13_SOCKET_PORTS = (1, 2, 3)

116"""

117 Port numbers of SEV T13 power socket

118"""

119

120

121@unique

122 class Safety(ValueEnum):

123 """

124 NodeID strings for the basic safety circuit status and green/red switches "ready"

125 and "operate".

126 """

127

128 #: Status is a read-only integer containing the state number of the

129 #: supercube-internal state machine. The values correspond to numbers in

130 #: :class:`SafetyStatus`.

131 status_ready_for_red = "hvl-ipc.WINAC.SYSTEMSTATE.ReadyForRed"

132 status_red = "hvl-ipc.WINAC.SYSTEMSTATE.RED"

133 status_green = "hvl-ipc.WINAC.SYSTEMSTATE.GREEN"

134 status_error = "hvl-ipc.WINAC.SYSTEMSTATE.ERROR"

135

136 #: Writable boolean for switching to Red Ready (locked, HV off) state.

137 switchto_ready = "hvl-ipc.WINAC.SYSTEMSTATE.RED_REQUEST"

138 switchto_green = "hvl-ipc.WINAC.SYSTEMSTATE.GREEN_REQUEST"

139

140 #: Writable boolean for switching to Red Operate (locket, HV on) state.

141 switchto_operate = "hvl-ipc.WINAC.SYSTEMSTATE.switchon"

142

143 #: Writeable boolean to manually turn on or off the horn

144 horn = "hvl-ipc.WINAC.SYSTEM_INTERN.hornen"

145

146

147 class SafetyStatus(IntEnum):

148 """

149 Safety status values that are possible states returned from

150 :meth:`hvl_ccb.dev.supercube.base.Supercube.get_status`. These

151 values correspond to the states of the Supercube's safety circuit statemachine.

152 """

153

154 #: System is initializing or booting.

155 Initializing = 0

156

157 #: System is safe, lamps are green and some safety elements are not in place such

158 #: that it cannot be switched to red currently.

159 GreenNotReady = 1

160

161 #: System is safe and all safety elements are in place to be able to switch to

162 #: *ready*.

163 GreenReady = 2

164

165 #: System is locked in red state and *ready* to go to *operate* mode.

166 RedReady = 3

167

168 #: System is locked in red state and in *operate* mode, i.e. high voltage on.

169 RedOperate = 4

170

171 #: Fast turn off triggered and switched off the system. Reset FSO to go back to a

172 #: normal state.

173 QuickStop = 5

174

175 #: System is in error mode.

176 Error = 6

177

178

179@unique

180 class Power(ValueEnum):

181 """

182 Variable NodeID strings concerning power data.

183 """

184

185 #: Primary voltage in volts, measured by the frequency converter at its output.

186 #: (read-only)

187 voltage_primary = "hvl-ipc.WINAC.SYSTEM_INTERN.FUVoltageprim"

188

189 #: Primary current in ampere, measured by the frequency converter. (read-only)

190 current_primary = "hvl-ipc.WINAC.SYSTEM_INTERN.FUCurrentprim"

191

192 #: Power setup that is configured using the Supercube HMI. The value corresponds to

193 #: the ones in :class:`PowerSetup`. (read-only)

194 setup = "hvl-ipc.WINAC.FU.TrafoSetup"

195

196 #: Voltage slope in V/s.

197 voltage_slope = "hvl-ipc.WINAC.FU.dUdt_-1"

198

199 #: Target voltage setpoint in V.

200 voltage_target = "hvl-ipc.WINAC.FU.SOLL"

201

202 #: Maximum voltage allowed by the current experimental setup. (read-only)

203 voltage_max = "hvl-ipc.WINAC.FU.maxVoltagekV"

204

205 #: Frequency converter output frequency. (read-only)

206 frequency = "hvl-ipc.WINAC.FU.Frequency"

207

208

209 class PowerSetup(IntEnum):

210 """

211 Possible power setups corresponding to the value of variable :attr:`Power.setup`.

212 """

213

214 #: No safety switches, use only safety components (doors, fence, earthing...)

215 #: without any power.

216 # NoPower = 0

217

218 #: External power supply fed through blue CEE32 input using isolation transformer

219 #: and safety switches of the Supercube, or using an external safety switch

220 #: attached to the Supercube Type B.

221 External = 0

222

223 #: AC voltage with MWB transformer set to 50kV maximum voltage.

224 AC_SingleStage_50kV = 1

225

226 #: AC voltage with MWB transformer set to 100kV maximum voltage.

227 AC_SingleStage_100kV = 2

228

229 #: AC voltage with two MWB transformers, one at 100kV and the other at 50kV,

230 #: resulting in a total maximum voltage of 150kV.

231 AC_DoubleStage_150kV = 3

232

233 #: AC voltage with two MWB transformers both at 100kV, resulting in a total

234 #: maximum voltage of 200kV

235 AC_DoubleStage_200kV = 4

236

237 #: Internal usage of the frequency converter, controlling to the primary voltage

238 #: output of the supercube itself (no measurement transformer used)

239 Internal = 5

240

241 #: DC voltage with one AC transformer set to 100kV AC, resulting in 140kV DC

242 DC_SingleStage_140kV = 6

243

244 #: DC voltage with two AC transformers set to 100kV AC each, resulting in 280kV

245 #: DC in total (or a single stage transformer with Greinacher voltage doubling

246 #: rectifier)

247 DC_DoubleStage_280kV = 7

248

249

250@unique

251 class MeasurementsScaledInput(ValueEnum):

252 """

253 Variable NodeID strings for the four analog BNC inputs for measuring voltage.

254 The voltage returned in these variables is already scaled with the set ratio,

255 which can be read using the variables in :class:`MeasurementsDividerRatio`.

256 """

257

258 input_1 = "hvl-ipc.WINAC.SYSTEM_INTERN.AI1Volt"

259 input_2 = "hvl-ipc.WINAC.SYSTEM_INTERN.AI2Volt"

260 input_3 = "hvl-ipc.WINAC.SYSTEM_INTERN.AI3Volt"

261 input_4 = "hvl-ipc.WINAC.SYSTEM_INTERN.AI4Volt"

262

263 @classmethod

264 def get(cls, channel: int):

265 """

266 Get the attribute for an input number.

267

268 :param channel: the channel number (1..4)

269 :return: the enum for the desired channel.

270 """

271

272 return getattr(cls, "input_{}".format(channel))

273

274

275@unique

276 class MeasurementsDividerRatio(ValueEnum):

277 """

278 Variable NodeID strings for the measurement input scaling ratios. These ratios

279 are defined in the Supercube HMI setup and are provided in the python module here

280 to be able to read them out, allowing further calculations.

281 """

282

283 input_1 = "hvl-ipc.WINAC.SYSTEM_INTERN.DivididerRatio"

284

285 @classmethod

286 def get(cls, channel: int):

287 """

288 Get the attribute for an input number.

289

290 :param channel: the channel number (1..4)

291 :return: the enum for the desired channel.

292 """

293

294 return getattr(cls, "input_{}".format(channel))

295

296

297 class EarthingStickStatus(IntEnum):

298 """

299 Status of an earthing stick. These are the possible values in the status integer

300 e.g. in :attr:`EarthingStick.status_1`.

301 """

302

303 #: Earthing stick is deselected and not enabled in safety circuit. To get out of

304 #: this state, the earthing has to be enabled in the Supercube HMI setup.

305 inactive = 0

306

307 #: Earthing is closed (safe).

308 closed = 1

309

310 #: Earthing is open (not safe).

311 open = 2

312

313 #: Earthing is in error, e.g. when the stick did not close correctly or could not

314 #: open.

315 error = 3

316

317

318@unique

319 class EarthingStick(ValueEnum):

320 """

321 Variable NodeID strings for all earthing stick statuses (read-only integer) and

322 writable booleans for setting the earthing in manual mode.

323 """

324

325 status_1_closed = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_1.CLOSE"

326 status_1_open = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_1.OPEN"

327 status_1_connected = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_1.CONNECT"

328 status_2_closed = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_2.CLOSE"

329 status_2_open = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_2.OPEN"

330 status_2_connected = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_2.CONNECT"

331 status_3_closed = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_3.CLOSE"

332 status_3_open = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_3.OPEN"

333 status_3_connected = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_3.CONNECT"

334 status_4_closed = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_4.CLOSE"

335 status_4_open = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_4.OPEN"

336 status_4_connected = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_4.CONNECT"

337 status_5_closed = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_5.CLOSE"

338 status_5_open = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_5.OPEN"

339 status_5_connected = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_5.CONNECT"

340 status_6_closed = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_6.CLOSE"

341 status_6_open = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_6.OPEN"

342 status_6_connected = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_6.CONNECT"

343

344 manual_1 = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_1.MANUAL"

345 manual_2 = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_2.MANUAL"

346 manual_3 = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_3.MANUAL"

347 manual_4 = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_4.MANUAL"

348 manual_5 = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_5.MANUAL"

349 manual_6 = "hvl-ipc.WINAC.SYSTEM_COMPONENTS.STICK_6.MANUAL"

350

351 @classmethod

352 def status_open(cls, number: int):

353 """

354 Get the status enum attribute for an earthing stick number.

355

356 :param number: the earthing stick (1..6)

357 :return: the status enum

358 """

359

360 return getattr(cls, "status_{}_open".format(number))

361

362 @classmethod

363 def status_closed(cls, number: int):

364 """

365 Get the status enum attribute for an earthing stick number.

366

367 :param number: the earthing stick (1..6)

368 :return: the status enum

369 """

370

371 return getattr(cls, "status_{}_closed".format(number))

372

373 @classmethod

374 def status_connected(cls, number: int):

375 """

376 Get the status enum attribute for an earthing stick number.

377

378 :param number: the earthing stick (1..6)

379 :return: the status enum

380 """

381

382 return getattr(cls, "status_{}_connected".format(number))

383

384 @classmethod

385 def manual(cls, number: int):

386 """

387 Get the manual enum attribute for an earthing stick number.

388

389 :param number: the earthing stick (1..6)

390 :return: the manual enum

391 """

392

393 return getattr(cls, "manual_{}".format(number))

394

395

396@unique

397 class Errors(ValueEnum):

398 """

399 Variable NodeID strings for information regarding error, warning and message

400 handling.

401 """

402

403 #: Boolean read-only variable telling if a stop is active.

404 stop = "hvl-ipc.WINAC.SYSTEMSTATE.ERROR"

405 stop_number = "hvl-ipc.WINAC.SYSTEMSTATE.Errornumber"

406

407 #: Writable boolean for the error quit button.

408 quit = "hvl-ipc.WINAC.SYSTEMSTATE.Faultconfirmation"

409

410

411 class DoorStatus(IntEnum):

412 """

413 Possible status values for doors.

414 """

415

416 #: not enabled in Supercube HMI setup, this door is not supervised.

417 inactive = 0

418

419 #: Door is open.

420 open = 1

421

422 #: Door is closed, but not locked.

423 closed = 2

424

425 #: Door is closed and locked (safe state).

426 locked = 3

427

428 #: Door has an error or was opened in locked state (either with emergency stop or

429 #: from the inside).

430 error = 4

431

432

433 class AlarmText(ValueEnum):

434 """

435 This enumeration contains textual representations for all error classes (stop,

436 warning and message) of the Supercube system. Use the :meth:`AlarmText.get`

437 method to retrieve the enum of an alarm number.

438 """

439

440 # No alarm

441 Alarm0 = "No Alarm."

442

443 # Safety elements

444 Alarm1 = "STOP Safety switch 1 error"

445 Alarm2 = "STOP Safety switch 2 error"

446 Alarm3 = "STOP Emergency Stop 1"

447 Alarm4 = "STOP Emergency Stop 2"

448 Alarm5 = "STOP Emergency Stop 3"

449 Alarm6 = "STOP Door 1 lock supervision"

450 Alarm7 = "STOP Door 2 lock supervision"

451 Alarm8 = "STOP Door 3 lock supervision"

452 Alarm9 = "STOP Earthing stick 1 error"

453 Alarm10 = "STOP Earthing stick 2 error"

454 Alarm11 = "STOP Earthing stick 3 error"

455 Alarm12 = "STOP Earthing stick 4 error"

456 Alarm13 = "STOP Earthing stick 5 error"

457 Alarm14 = "STOP Earthing stick 6 error"

458 Alarm17 = "STOP Source switch error"

459 Alarm19 = "STOP Fence 1 error"

460 Alarm20 = "STOP Fence 2 error"

461 Alarm21 = "STOP Control error"

462 Alarm22 = "STOP Power outage"

463

464 # generic not defined alarm text

465 not_defined = "NO ALARM TEXT DEFINED"

466

467 @classmethod

468 def get(cls, alarm: int):

469 """

470 Get the attribute of this enum for an alarm number.

471

472 :param alarm: the alarm number

473 :return: the enum for the desired alarm number

474 """

475

476 try:

477 return getattr(cls, "Alarm{}".format(alarm))

478 except AttributeError:

479 return cls.not_defined