Commit a7b3bab4 authored by Claudio Scafuri's avatar Claudio Scafuri 💬
Browse files

Merge branch 'python3' into 'master'

Python3

See merge request !4
parents 1424ea97 fda52b92
# module for creating beamline front-end config
# class blfe incapsulates the reading and closing of beamline front-ends shuter/stoppers
# stores also the complet configuration
# $Author: claudio $
#
# $Name: $
#
# $Log: blfe.py,v $
# Revision 1.15 2021-01-11 14:46:35 claudio
# removed 061_BSTOPPERAF
#
# Revision 1.14 2018-04-30 08:36:29 claudio
# #5959 errore closing front end
#
# Revision 1.13 2018-04-12 08:46:16 claudio
# mod syrmep- verificate
#
# Revision 1.12 2018-04-03 08:42:34 claudio
# #5643: modifiche syrmep
#
# Revision 1.11 2017-02-13 09:27:36 claudio
# revision tag
#
# Revision 1.10 2016-03-21 08:54:23 claudio
# tested commands for 112f
#
# Revision 1.9 2016-03-10 09:05:23 claudio
# add 112 stopper
#
# Revision 1.8 2015-12-22 10:34:45 claudio
# ticket 1591
#
# Revision 1.7 2014-09-29 09:08:53 claudio
# correctc CMD and VAR for microfluo shopper
#
# Revision 1.6 2014-09-11 11:15:23 claudio
# corrected label
#
# Revision 1.5 2014-09-10 12:16:13 claudio
# ticket 1406: LEFT_SHUTTER_VACOWAGO_20
#
# Revision 1.4 2013-04-08 14:19:24 claudio
# force case in string comparison
#
# Revision 1.3 2009/11/13 10:01:36 claudio
# "natural" default rpc timeout
#
# Revision 1.2 2008/09/30 07:53:49 claudio
# commented out shutter/stopper under commissioning (11.2)
#
# Revision 1.1 2008/09/23 09:12:10 claudio
# First import
#
#
import lib_pyElettra
class Blfe(object):
def __init__(self):
self.nread = 0
self.nerror = 0
self.nopen = 0
self.nclosed = 0
self.nunknown = 0
self.nentries = 0
self.bltable = []
# here put in the complete table of shopper/shutters/stoppers in beamline jargon
# format of table entry is:
# 'point','host','read-command_name',value,'status',set-command_name,set-parm
# value:0 closed, 1 open, -1 unknown, -2 read error'
# status: UNKNOWN,OPEN,CLOSED,ERROR
# value and status are dynamically changed by read operations
# self.bltable.append(['BACKEND_SHOPPER_VACOBECK_20_STATUS0','bacs011.blcs.elettra.trieste.it','1.0-backend',-1,'UNKNOWN','BACKEND_SHOPPER_VACOBECK_20_RMTCMD0','RMTCMD0'])
self.bltable.append(
[
"FRONTEND_SHOPPER-L_VACO_1_STATUS2",
"011f-bcs.blcs.elettra.trieste.it",
"1.1M TwinMic",
-1,
"UNKNOWN",
"FRONTEND_SHOPPER-L_VACO_1_RMTCMD2",
"VALRMTCMD2",
]
)
self.bltable.append(
[
"FRONTEND_STOPPER_VACO_1_STATUS1",
"012f-bcs.blcs.elettra.trieste.it",
"1.2 Nanospectr.",
-1,
"UNKNOWN",
"FRONTEND_STOPPER_VACO_1_RMTCMD1",
"VALRMTCMD1",
]
)
self.bltable.append(
[
"FRONTEND_SHUTTER_VACO_1_STATUS0",
"012f-bcs.blcs.elettra.trieste.it",
"1.2 Nanospectr.",
-1,
"UNKNOWN",
"FRONTEND_SHUTTER_VACO_1_RMTCMD0",
"VALRMTCMD0",
]
)
self.bltable.append(
[
"022F_USTOPPER1F_VACO_1_STATUS1",
"022f-bcs.blcs.elettra.trieste.it",
"2.2 ESCA",
-1,
"UNKNOWN",
"022F_USTOPPER1F_VACO_1_RMTCMD1",
"VALRMTCMD1",
]
)
self.bltable.append(
[
"022F_USHUTTER1F_VACO_1_STATUS0",
"022f-bcs.blcs.elettra.trieste.it",
"2.2 ESCA",
-1,
"UNKNOWN",
"022F_USHUTTER1F_VACO_1_RMTCMD0",
"VALRMTCMD0",
]
)
self.bltable.append(
[
"032F_USTOPPER1F_VACO_1_STATUS1",
"032f-bcs.blcs.elettra.trieste.it",
"3.2 VUV/Spectrom.",
-1,
"UNKNOWN",
"032F_USTOPPER1F_VACO_1_RMTCMD1",
"VALRMTCMD1",
]
)
self.bltable.append(
[
"032F_USHUTTER1F_VACO_1_STATUS0",
"032f-bcs.blcs.elettra.trieste.it",
"3.2 VUV/Spectrom.",
-1,
"UNKNOWN",
"032F_USHUTTER1F_VACO_1_RMTCMD0",
"VALRMTCMD0",
]
)
self.bltable.append(
[
"FRONTEND_STOPPER_VACO_1_STATUS1",
"042f-bcs.blcs.elettra.trieste.it",
"4.2 Circ. pol.",
-1,
"UNKNOWN",
"FRONTEND_STOPPER_VACO_1_RMTCMD1",
"VALRMTCMD1",
]
)
self.bltable.append(
[
"FRONTEND_SHUTTER_VACO_1_STATUS0",
"042f-bcs.blcs.elettra.trieste.it",
"4.2 Circ. pol.",
-1,
"UNKNOWN",
"FRONTEND_SHUTTER_VACO_1_RMTCMD0",
"VALRMTCMD0",
]
)
self.bltable.append(
[
"XRD_STOPPER1_VACO_11_STATUS0",
"052f-bcs.blcs.elettra.trieste.it",
"5.2 XRD1",
-1,
"UNKNOWN",
"XRD_STOPPER1_VACO_11_RMTCMD0",
"VALRMTCMD0",
]
)
self.bltable.append(
[
"XRD_STOPPER2_VACO_10_STATUS3",
"052f-bcs.blcs.elettra.trieste.it",
"5.2 XRD1",
-1,
"UNKNOWN",
"XRD_STOPPER2_VACO_10_RMTCMD3",
"VALRMTCMD3",
]
)
self.bltable.append(
[
"XRD_STOPPER3_VACO_10_STATUS2",
"052f-bcs.blcs.elettra.trieste.it",
"5.2 XRD1",
-1,
"UNKNOWN",
"XRD_STOPPER3_VACO_10_RMTCMD2",
"VALRMTCMD2",
]
)
self.bltable.append(
[
"052F_WSHUTTER1F_VACO_1_STATUS5",
"052f-bcs.blcs.elettra.trieste.it",
"5.2 SAXS",
-1,
"UNKNOWN",
"052F_WSHUTTER1F_VACO_1_RMTCMD5",
"VALRMTCMD5",
]
)
self.bltable.append(
[
"052F_WSTOPPER1F_VACO_1_STATUS4",
"052f-bcs.blcs.elettra.trieste.it",
"5.2 SAXS",
-1,
"UNKNOWN",
"052F_WSTOPPER1F_VACO_1_RMTCMD4",
"VALRMTCMD4",
]
)
self.bltable.append(
[
"061F_BSTOPPERCF_VACO_1_STATUS2",
"061f-bcs.blcs.elettra.trieste.it",
"6.1 Mat. Science",
-1,
"UNKNOWN",
"061F_BSTOPPERCF_VACO_1_RMTCMD2",
"VALRMTCMD2",
]
)
self.bltable.append(
[
"061F_SHOPPER-R_VACO_2_STATUS2",
"061f-bcs.blcs.elettra.trieste.it",
"6.1 Syrmep",
-1,
"UNKNOWN",
"061F_SHOPPER-R_VACO_2_RMTCMD2",
"VALRMTCMD2",
]
)
self.bltable.append(
[
"061F_BSHUTTERCF_VACO_1_STATUS0",
"061f-bcs.blcs.elettra.trieste.it",
"6.1 Mat. Science",
-1,
"UNKNOWN",
"061F_BSHUTTERCF_VACO_1_RMTCMD0",
"VALRMTCMD0",
]
)
self.bltable.append(
[
"062F_USTOPPER1F_VACO_1_STATUS1",
"062f-bcs.blcs.elettra.trieste.it",
"6.2 GasPhase",
-1,
"UNKNOWN",
"062F_USTOPPER1F_VACO_1_RMTCMD1",
"VALRMTCMD1",
]
)
self.bltable.append(
[
"062F_USHUTTER1F_VACO_1_STATUS0",
"062f-bcs.blcs.elettra.trieste.it",
"6.2 GasPhase",
-1,
"UNKNOWN",
"062F_USHUTTER1F_VACO_1_RMTCMD0",
"VALRMTCMD0",
]
)
self.bltable.append(
[
"FRONTEND_SHOPPER-R_VACO_1_STATUS0",
"071f-bcs.blcs.elettra.trieste.it",
"7.1 MCX",
-1,
"UNKNOWN",
"FRONTEND_SHOPPER-R_VACO_1_RMTCMD0",
"VALRMTCMD0",
]
)
self.bltable.append(
[
"RIGHT_SHUTTER_VACO_30_STATUS4",
"071f-bcs.blcs.elettra.trieste.it",
"7.1 MCX",
-1,
"UNKNOWN",
"RIGHT_SHUTTER_VACO_30_RMTCMD4",
"VALRMTCMD4",
]
)
self.bltable.append(
[
"072F_USTOPPER1F_VACO_1_STATUS1",
"072f-bcs.blcs.elettra.trieste.it",
"7.2 ALOISA",
-1,
"UNKNOWN",
"072F_USTOPPER1F_VACO_1_RMTCMD1",
"VALRMTCMD1",
]
)
self.bltable.append(
[
"072F_USHUTTER1F_VACO_1_STATUS0",
"072f-bcs.blcs.elettra.trieste.it",
"7.2 ALOISA",
-1,
"UNKNOWN",
"072F_USHUTTER1F_VACO_1_RMTCMD0",
"VALRMTCMD0",
]
)
self.bltable.append(
[
"FRONTEND_SHOPPER-R_VACO_2_STATUS0",
"081f-bcs.blcs.elettra.trieste.it",
"8.1 Lilit",
-1,
"UNKNOWN",
"FRONTEND_SHOPPER-R_VACO_2_RMTCMD0",
"VALRMTCMD0",
]
)
self.bltable.append(
[
"FRONTEND_SHOPPER-L_VACO_1_STATUS0",
"081f-bcs.blcs.elettra.trieste.it",
"8.1 BEAR",
-1,
"UNKNOWN",
"FRONTEND_SHOPPER-L_VACO_1_RMTCMD0",
"VALRMTCMD0",
]
)
self.bltable.append(
[
"RIGHT_EXSLIT_VACO_10_STATUS4",
"081f-bcs.blcs.elettra.trieste.it",
"8.1 Lilit",
-1,
"UNKNOWN",
"RIGHT_EXSLIT_VACO_10_RMTCMD4",
"VALRMTCMD4",
]
)
self.bltable.append(
[
"FRONTEND_STOPPER_VACO_1_STATUS1",
"082f-bcs.blcs.elettra.trieste.it",
"8.2 Bach",
-1,
"UNKNOWN",
"FRONTEND_STOPPER_VACO_1_RMTCMD1",
"VALRMTCMD1",
]
)
self.bltable.append(
[
"FRONTEND_SHUTTER_VACO_1_STATUS0",
"082f-bcs.blcs.elettra.trieste.it",
"8.2 Bach",
-1,
"UNKNOWN",
"FRONTEND_SHUTTER_VACO_1_RMTCMD0",
"VALRMTCMD0",
]
)
self.bltable.append(
[
"CENTRAL_STOPPER_VACO_20_STATUS0",
"091f-bcs.blcs.elettra.trieste.it",
"9.1 SISSI",
-1,
"UNKNOWN",
"CENTRAL_STOPPER_VACO_20_RMTCMD0",
"VALRMTCMD0",
]
)
self.bltable.append(
[
"FRONTEND_STOPPER_VACO_1_STATUS1",
"092f-bcs.blcs.elettra.trieste.it",
"9.2 APE",
-1,
"UNKNOWN",
"FRONTEND_STOPPER_VACO_1_RMTCMD1",
"VALRMTCMD1",
]
)
self.bltable.append(
[
"FRONTEND_SHUTTER_VACO_1_STATUS0",
"092f-bcs.blcs.elettra.trieste.it",
"9.2 APE",
-1,
"UNKNOWN",
"FRONTEND_SHUTTER_VACO_1_RMTCMD0",
"VALRMTCMD0",
]
)
self.bltable.append(
[
"FRONTEND_SHOPPER-R_VACO_1_STATUS4",
"101f-bcs.blcs.elettra.trieste.it",
"10.1 DXRL",
-1,
"UNKNOWN",
"FRONTEND_SHOPPER-R_VACO_1_RMTCMD4",
"VALRMTCMD4",
]
)
self.bltable.append(
[
"FRONTEND_SHOPPER-L_VACO_1_STATUS0",
"101f-bcs.blcs.elettra.trieste.it",
"10.1 X-Ray Fluo.",
-1,
"UNKNOWN",
"FRONTEND_SHOPPER-L_VACO_1_RMTCMD0",
"VALRMTCMD0",
]
)
self.bltable.append(
[
"LEFT_SHUTTER_VACOWAGO_20_STATUS1",
"101f-bcs.blcs.elettra.trieste.it",
"10.1L X-Ray Fluo.",
-1,
"UNKNOWN",
"LEFT_SHUTTER_VACOWAGO_20_RMTCMD1",
"RMTCMD1",
]
)
self.bltable.append(
[
"FRONTEND_STOPPER_VACO_1_STATUS1",
"102f-bcs.blcs.elettra.trieste.it",
"10.2 IUVS/BaDElPh",
-1,
"UNKNOWN",
"FRONTEND_STOPPER_VACO_1_RMTCMD1",
"VALRMTCMD1",
]
)
self.bltable.append(
[
"FRONTEND_SHUTTER_VACO_1_STATUS0",
"102f-bcs.blcs.elettra.trieste.it",
"10.2 IUVS/BaDElPh",
-1,
"UNKNOWN",
"FRONTEND_SHUTTER_VACO_1_RMTCMD0",
"VALRMTCMD0",
]
)
self.bltable.append(
[
"FRONTEND_SHOPPER-R_VACO_2_STATUS0",
"111f-bcs.blcs.elettra.trieste.it",
"11.1 XAFS",
-1,
"UNKNOWN",
"FRONTEND_SHOPPER-R_VACO_2_RMTCMD0",
"VALRMTCMD0",
]
)
self.bltable.append(
[
"RIGHT_STOPPER_VACO_30_STATUS6",
"111f-bcs.blcs.elettra.trieste.it",
"11.1 XAFS",
-1,
"UNKNOWN",
"RIGHT_STOPPER_VACO_30_RMTCMD6",
"VALRMTCMD6",
]
)
self.bltable.append(
[
"FRONTEND_SHOPPER-L_VACO_1_STATUS0",
"111f-bcs.blcs.elettra.trieste.it",
"11.1 WhITE",
-1,
"UNKNOWN",
"FRONTEND_SHOPPER-L_VACO_1_RMTCMD0",
"VALRMTCMD0",
]
)
self.bltable.append(
[
"FRONTEND_STOPPER_VACO_1_STATUS1",
"112f-bcs.blcs.elettra.trieste.it",
"11.2 XPRESS & XRD2",
-1,
"UNKNOWN",
"FRONTEND_STOPPER_VACO_1_RMTCMD1",
"VALRMTCMD1",
]
)
self.bltable.append(
[
"RIGHT_SHOPPER2_VACOWAGO_30_STATUS0",
"112f-bcs.blcs.elettra.trieste.it",
"11.2 XPRESS",
-1,
"UNKNOWN",
"RIGHT_SHOPPER2_VACOWAGO_30_RMTCMD0",
"RMTCMD0",
]
)
self.bltable.append(
[
"CENTRAL_STOPPER2_VACOWAGO_20_STATUS1",
"112f-bcs.blcs.elettra.trieste.it",
"11.2 XRD2",
-1,
"UNKNOWN",
"CENTRAL_STOPPER2_VACOWAGO_20_RMTCMD1",
"RMTCMD1",
]
)
# form dictionary of hosts-controlstem objetcs
self.hostdict = {}
for entry in self.bltable:
self.nunknown = self.nunknown + 1
self.nentries = self.nentries + 1
if entry[1] not in self.hostdict:
ControlSystem = lib_pyElettra.XCS()
ControlSystem.open(entry[1])
self.hostdict[entry[1]] = ControlSystem
# print 'add '+entry[1]
def disconnect(self):
for host, contrsys in self.hostdict.items():
contrsys.close()
def read(self):
self.nread = 0
self.nerror = 0
self.nopen = 0
self.nclosed = 0
self.nunknown = 0
for entry in self.bltable:
ControlSystem = self.hostdict[entry[1]]
resp = ControlSystem.fetch(entry[0])
self.nread = self.nread + 1
# print (entry[0]+" "+resp[0]+" "+resp[1])
if resp[1] == "fetchException":
entry[3] = -2
entry[4] = "ERROR"
self.nerror = self.nerror + 1
# print entry[0]+' read error'
else:
if resp[0] == "1" and resp[1].lower() == "open":
entry[3] = 1
entry[4] = "OPEN"
self.nopen = self.nopen + 1
# print entry[0]+' OPENED'
elif resp[0] == "0" and resp[1].lower() == "closed":
entry[3] = 0
entry[4] = "CLOSED"
self.nclosed = self.nclosed + 1
# print entry[0]+' CLOSED'
elif resp[0] == "3" and resp[1].lower() == "closed":
entry[3] = 0
entry[4] = "CLOSED"
self.nclosed = self.nclosed + 1
else:
entry[3] = -1
entry[4] = "UNKNOWN"
# print entry[0]+' UNKNOWN '+ resp[0]+ " "+resp[1]
def allclosed(self):
# return 1 ONLY if we are positvely sure that we have successufully read all the shutters and that they are closed
if self.nclosed == self.nread and self.nread == self.nentries:
return 1
else:
return 0
def closeall(self):
# send close command to all known front-ends shuttters,stoppers, etc.
nclosed = 0
nerror = 0
errtable = []
for entry in self.bltable:
ControlSystem = self.hostdict[entry[1]]
nclosed = nclosed + 1
# print(nclosed, entry[5], entry[6])
if len(entry[5]) > 0 and len(entry[6]) > 0:
resp = ControlSystem.doit(
entry[5], entry[6], "0"
) # 0 per chiudere, 1 per aprire!
else:
resp = "OK"
if resp.find("OK") == -1:
nerror = nerror + 1
errtable.append([entry[1], entry[2], entry[5], entry[6]])
if nerror:
return errtable
#!/usr/bin/env python
#!/usr/bin/python3
# $Author: claudio $
#
......@@ -10,15 +10,13 @@
#
#