From a0182a01e05465c7d041ec4feac53c096a3d4f33 Mon Sep 17 00:00:00 2001
From: Lucio Zambon <lucio.zambon@elettra.eu>
Date: Tue, 29 Sep 2020 14:19:48 +0200
Subject: [PATCH] Upload New File

---
 src/acs.cpp | 2787 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 2787 insertions(+)
 create mode 100644 src/acs.cpp

diff --git a/src/acs.cpp b/src/acs.cpp
new file mode 100644
index 0000000..02f2c50
--- /dev/null
+++ b/src/acs.cpp
@@ -0,0 +1,2787 @@
+/***************************************************************************
+ *   Copyright (C) 2007 by                                       *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+
+#include "acs.h"
+#include <unistd.h>
+// #include <qtango.h>
+#include <QMessageBox>
+#include <qtimer.h>
+#include <QDesktopWidget>
+#include <curl/curl.h>
+
+
+char tmBuffer[80];
+int noSrvRetry;
+double resizeFactorX, resizeFactorY, resizeFactorM;
+string strstat, linac_strstat, uh_strstat;
+
+/*
+  timestamp() 
+  send a timestamp to standard output
+*/
+void timestamp() 
+{
+	struct tm *mytime;
+	time_t myTime_t;
+	myTime_t = time(NULL);
+	mytime = localtime(&myTime_t);
+	strftime(tmBuffer, 79, "%Y-%m-%d %H:%M:%S ", mytime);
+	return;
+}
+
+char url[200];
+string web_data;
+size_t write_data(char *ptr, size_t size, size_t nmemb, void *userdata) {
+	for (unsigned c=0; c<size*nmemb; c++) {
+		web_data.push_back(ptr[c]);
+	}
+	return size * nmemb;
+}
+void acs::web_read(char *url, const char *data) {
+	CURL *curl;
+	CURLcode res;
+	curl = curl_easy_init();
+	if(curl) {
+		char *output = curl_easy_escape(curl, (strlen(data)>0)? data: "", 0);
+		strcat(url, output);
+		// cout << "curl_easy_escape(): " << url << endl;
+		curl_easy_setopt(curl, CURLOPT_URL, url);
+		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &write_data);
+		// Perform the request, res will get the return code
+		res = curl_easy_perform(curl);
+		if (res == CURLE_OK && !web_data.compare("NOK")) {
+			QMessageBox::information(this, "REGISTRAZIONE MANCANTE", "ATTENZIONE, badge non presente nel registro elettronico degli accessi\nEffettuare al piu' presto la registrazione", QMessageBox::Ok);
+		}
+		web_data.clear();
+		// clean escaped url string
+		curl_free(output);
+		// always cleanup
+		curl_easy_cleanup(curl);
+	}
+}
+
+acs::acs(QWidget *parent) : QWidget(parent)
+{
+	noSrvRetry = 0;
+	linac_strstat = " ";
+	uh_strstat = " ";
+	QSettings settings("fermi", "acs");
+	// load (or set) path for images
+	if (settings.contains("imgpath")) {
+		imgpath = settings.value("imgpath").toString();
+		// cout << imgpath.toStdString() << endl;
+	}
+	else {
+		settings.setValue("imgpath", "/runtime/fermi/share/images/acs");
+		// settings.setValue("imgpath", "/home/zambonl/devel/qt/fermi/acs/img");
+	}
+	if (!imgpath.endsWith("/")) {
+		imgpath = imgpath + "/";
+	}
+	// get host name
+	char hostname[256];
+	strcpy(hostname, getenv("DISPLAY"));
+	if (!strncmp(hostname, ":0", 2)) {
+		if (gethostname(hostname, 255) < 0) {
+			cout << "invalid hostname" << endl;
+			strcpy(hostname, "nohost:0");
+		}
+	}
+	cout << "hostname: " << hostname << endl;
+	// load (or set) control location
+	if (settings.contains("controlLocation")) {
+		controlLocation = settings.value("controlLocation").toString();
+	}
+	else {
+		settings.setValue("controlLocation", "Sala Controllo Anello");
+		controlLocation = "controlLocation";
+	}
+	// settings.setValue("master", "ca-booster:0.0");
+	// settings.setValue("masterA0", "kaioh:0.0,kaioh-clone:0.0");
+
+	// load (or set) master
+	if (settings.contains("master")) {
+		master = settings.value("master").toString().contains(hostname);
+	}
+	else {
+		settings.setValue("master", "ca-booster:0.0");
+		master = false;
+	}
+	std::string a = settings.value("master").toString().toStdString();
+	cout << a << ", master: " << (master? "true": "false") << endl;
+	// load (or set) master for A0
+	if (settings.contains("masterA0")) {
+		masterA0 = settings.value("masterA0").toString().contains(hostname);
+	}
+	else {
+		settings.setValue("masterA0", "kaioh:0.0,kaioh-clone:0.0");
+		masterA0 = false;
+	}
+	// std::string b = settings.value("masterA0").toString().toStdString();
+	// cout << b << ", masterA0: " << (masterA0? "true": "false") << endl;
+	// masterA0 = true;
+	// setup User Interface
+	try {
+		ui.setupUi(this);
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "cannot setup UI" << endl;
+	}
+	catch (...) {
+		timestamp();
+		cout << tmBuffer << "default exception, cannot setup UI" << endl;
+	}
+
+	// <==== TODO check master
+	master = masterA0 = true;
+	// ui.controlFrame->setHidden(true);
+
+	cout << "connecting" << endl;
+	// connect to control access server
+	try {
+		plc_server = new Tango::DeviceProxy("f/access_control/safety");
+		// plc_server = new Tango::DeviceProxy("ken/plc/pss");
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "Fatal Error: Access Control Device Server not responding, the application will be terminated immediately" << endl;
+		exit(1);
+	}
+	catch (...) {
+		timestamp();
+		cout << tmBuffer << "Fatal Error: Access Control Device Server not responding, the application will be terminated immediately" << endl;
+		exit(1);
+	}
+	cout << "connected" << endl; // exit(0);
+	refreshCount = 0;
+	refresh();
+	// init timer
+	try {
+		timer = new QTimer(this);
+		timer->setInterval(500);
+		timer->setSingleShot(false);
+		connect(timer, SIGNAL(timeout()), this, SLOT(refresh()));
+		timer->start();
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "cannot connect UI" << endl;
+	}
+	catch (...) {int
+		timestamp();
+		cout << tmBuffer << "default exception, cannot setup UI" << endl;
+	}
+	// init button action
+	try {
+		// open list of staff inside
+		connect(ui.A0PresenceButton, SIGNAL(clicked()), this, SLOT(open_inA0_list()));
+		inA0_list_process = new QProcess(this);
+		connect(ui.AsoPresenceButton, SIGNAL(clicked()), this, SLOT(open_inAso_list()));
+		inAso_list_process = new QProcess(this);
+		connect(ui.staffListButton, SIGNAL(clicked()), this, SLOT(open_staff_list()));
+		staff_list_process = new QProcess(this);
+		// switch control
+		connect(ui.controlSwitchButton, SIGNAL(clicked()), this, SLOT(switch_control_location()));
+		permission_process = new QProcess(this);
+		// open permission panel
+		// open status panels
+		connect(ui.linacShutdownInfoButton, SIGNAL(clicked()), this, SLOT(open_stat_linac_shutdown()));
+		stat_shutdown_process = new QProcess(this);
+		connect(ui.linacOffInfoButton, SIGNAL(clicked()), this, SLOT(open_stat_linac_off()));
+		stat_off_process = new QProcess(this);
+		connect(ui.linacOnInfoButton, SIGNAL(clicked()), this, SLOT(open_stat_linac_on()));
+		stat_on_process = new QProcess(this);
+		connect(ui.undulatorShutdownInfoButton, SIGNAL(clicked()), this, SLOT(open_stat_undulator_shutdown()));
+		undulator_stat_shutdown_process = new QProcess(this);
+		connect(ui.undulatorOffInfoButton, SIGNAL(clicked()), this, SLOT(open_stat_undulator_off()));
+		undulator_stat_off_process = new QProcess(this);
+		connect(ui.undulatorOnInfoButton, SIGNAL(clicked()), this, SLOT(open_stat_undulator_on()));
+		undulator_stat_on_process = new QProcess(this);
+		// open linac RF signals
+		// connect(ui.enableInfoButton_9, SIGNAL(clicked()), this, SLOT(open_rfinhibit_panel()));
+		connect(ui.enableInfoButton_9, SIGNAL(clicked()), this, SLOT(open_klystat()));
+		rfinhibit_process = new QProcess(this);
+		connect(ui.enableInfoButton_7, SIGNAL(clicked()), this, SLOT(open_rfpcgun_panel()));
+		rfpcgun_process = new QProcess(this);
+		connect(ui.enableInfoButton_6, SIGNAL(clicked()), this, SLOT(open_klystat()));
+		klystat_process = new QProcess(this);
+		connect(ui.SwitchPickupButton, SIGNAL(clicked()), this, SLOT(open_klyswitch()));
+		connect(ui.enableInfoButton_8, SIGNAL(clicked()), this, SLOT(open_klyswitch()));
+		klyswitch_process = new QProcess(this);
+		// open doors detailed panels
+		connect(ui.linacDoorButton, SIGNAL(clicked()), this, SLOT(open_linac_doors()));
+		linac_doors_process = new QProcess(this);
+		connect(ui.e0DoorButton, SIGNAL(clicked()), this, SLOT(open_e0_doors()));
+		e0_doors_process = new QProcess(this);
+		connect(ui.e1DoorButton, SIGNAL(clicked()), this, SLOT(open_e1_doors()));
+		e1_doors_process = new QProcess(this);
+		connect(ui.e2DoorButton, SIGNAL(clicked()), this, SLOT(open_e2_doors()));
+		e2_doors_process = new QProcess(this);
+		connect(ui.e3DoorButton, SIGNAL(clicked()), this, SLOT(open_e3_doors()));
+		e3_doors_process = new QProcess(this);
+		connect(ui.e4DoorButton, SIGNAL(clicked()), this, SLOT(open_e4_doors()));
+		e4_doors_process = new QProcess(this);
+		connect(ui.e5DoorButton, SIGNAL(clicked()), this, SLOT(open_e5_doors()));
+		e5_doors_process = new QProcess(this);
+		connect(ui.e6DoorButton, SIGNAL(clicked()), this, SLOT(open_e6_doors()));
+		e6_doors_process = new QProcess(this);
+		connect(ui.e7DoorButton, SIGNAL(clicked()), this, SLOT(open_e7_doors()));
+		e7_doors_process = new QProcess(this);
+		connect(ui.tlDoorButton, SIGNAL(clicked()), this, SLOT(open_tl_doors()));
+		tl_doors_process = new QProcess(this);
+		connect(ui.soDoorButton, SIGNAL(clicked()), this, SLOT(open_so_doors()));
+		so_doors_process = new QProcess(this);
+		// open emergency buttons detailed panel
+		connect(ui.emergencyButton, SIGNAL(clicked()), this, SLOT(open_emergency_buttons()));
+		emergency_buttons_process = new QProcess(this);
+		connect(ui.emergencyButton_so, SIGNAL(clicked()), this, SLOT(open_emergency_buttons_so()));
+		emergency_buttons_so_process = new QProcess(this);
+		// open BST detailed panels
+		connect(ui.bst_linacButton, SIGNAL(clicked()), this, SLOT(open_bst_linac_panel()));
+		bst_linac_process = new QProcess(this);
+		connect(ui.bst1_fel1Button, SIGNAL(clicked()), this, SLOT(open_bst1_fel1_panel()));
+		bst1_fel1_process = new QProcess(this);
+		connect(ui.bst1_fel2Button, SIGNAL(clicked()), this, SLOT(open_bst1_fel2_panel()));
+		bst1_fel2_process = new QProcess(this);
+		connect(ui.bst2_fel1Button, SIGNAL(clicked()), this, SLOT(open_bst2_fel1_panel()));
+		bst2_fel1_process = new QProcess(this);
+		connect(ui.bst2_fel2Button, SIGNAL(clicked()), this, SLOT(open_bst2_fel2_panel()));
+		bst2_fel2_process = new QProcess(this);
+		connect(ui.bst_diagButton, SIGNAL(clicked()), this, SLOT(open_bst_diag_panel()));
+		bst_diag_process = new QProcess(this);
+		// open BST info panel
+		connect(ui.bstInfoButton, SIGNAL(clicked()), this, SLOT(open_bst_linac_info_panel()));
+		bst_linac_info_process = new QProcess(this);
+		connect(ui.bst1_fel1InfoButton, SIGNAL(clicked()), this, SLOT(open_bst_bl_info_panel()));
+		connect(ui.bst2_fel1InfoButton, SIGNAL(clicked()), this, SLOT(open_bst_bl_info_panel()));
+		connect(ui.bst1_fel2InfoButton, SIGNAL(clicked()), this, SLOT(open_bst_bl_info_panel()));
+		connect(ui.bst2_fel2InfoButton, SIGNAL(clicked()), this, SLOT(open_bst_bl_info_panel()));
+		connect(ui.bst_diagInfoButton, SIGNAL(clicked()), this, SLOT(open_bst_bl_info_panel()));
+		bst_bl_info_process = new QProcess(this);
+		// open search detailed panel
+		connect(ui.watchInfoButton_0, SIGNAL(clicked()), this, SLOT(open_search_panel()));
+		connect(ui.watchInfoButton_1, SIGNAL(clicked()), this, SLOT(open_search_panel()));
+		connect(ui.watchInfoButton_2, SIGNAL(clicked()), this, SLOT(open_search_panel()));
+		connect(ui.watchInfoButton_3, SIGNAL(clicked()), this, SLOT(open_search_panel()));
+		connect(ui.watchInfoButton_l, SIGNAL(clicked()), this, SLOT(open_search_panel()));
+		connect(ui.watchInfoButton_tl, SIGNAL(clicked()), this, SLOT(open_search_panel()));
+		connect(ui.watchInfoButton_4, SIGNAL(clicked()), this, SLOT(open_search_panel()));
+		connect(ui.watchInfoButton_5, SIGNAL(clicked()), this, SLOT(open_search_panel()));
+		connect(ui.watchInfoButton_6, SIGNAL(clicked()), this, SLOT(open_search_panel()));
+		connect(ui.watchInfoButton_7, SIGNAL(clicked()), this, SLOT(open_search_panel()));
+		connect(ui.watchInfoButton_so, SIGNAL(clicked()), this, SLOT(open_search_panel()));
+		search_process = new QProcess(this);
+		connect(ui.psInfoButton, SIGNAL(clicked()), this, SLOT(open_ps_panel()));
+		ps_process = new QProcess(this);
+		connect(ui.toroidInfoButton, SIGNAL(clicked()), this, SLOT(open_toroid_panel()));
+		toroid_process = new QProcess(this);
+		// open esa detailed panels
+		/* 
+		connect(ui.emergencyInfoButton_esa1, SIGNAL(clicked()), this, SLOT(open_emergency_esa1_panel()));
+		emergency_esa1_process = new QProcess(this);
+		connect(ui.emergencyInfoButton_esa2, SIGNAL(clicked()), this, SLOT(open_emergency_esa2_panel()));
+		emergency_esa2_process = new QProcess(this);
+		*/
+		connect(ui.watchInfoButton_esa1, SIGNAL(clicked()), this, SLOT(open_watch_esa1_panel()));
+		watch_esa1_process = new QProcess(this);
+		connect(ui.watchInfoButton_esa2, SIGNAL(clicked()), this, SLOT(open_watch_esa2_panel()));
+		watch_esa2_process = new QProcess(this);
+		connect(ui.watchInfoButton_esa, SIGNAL(clicked()), this, SLOT(open_esahutch_panel()));
+		esahutch_process = new QProcess(this);
+		// connect(ui.scrapersInfoButton_1, SIGNAL(clicked()), this, SLOT(open_scrapersinfo_panel()));
+		// scrapersinfo_process = new QProcess(this);
+		// switch booster map
+		// connect(ui.mapButton, SIGNAL(clicked()), this, SLOT(open_map()));
+		// open TOP-UP Error panel
+		// connect(ui.topupError_Button, SIGNAL(clicked()), this, SLOT(open_topup_error()));
+		// topup_error_process = new QProcess(this);
+		// connect(ui.tunnelWatch_label, SIGNAL(clicked()), this, SLOT(open_bst()));
+		bst_process = new QProcess(this);
+		// open log page on Firefox browser
+		connect(ui.alarmListButton, SIGNAL(clicked()), this, SLOT(open_alarmlist_panel()));
+		alarmlist_process = new QProcess(this);
+		// open hardware failure monitoring panel
+		connect(ui.hardwareButton, SIGNAL(clicked()), this, SLOT(open_hardware_panel()));
+		hardware_process = new QProcess(this);
+		// open version monitoring panel
+		connect(ui.versionButton, SIGNAL(clicked()), this, SLOT(open_version_panel()));
+		// open register browser
+		connect(ui.registerButton, SIGNAL(clicked()), this, SLOT(open_register()));
+		register_process = new QProcess(this);
+		// operations reserved to master only
+		// if (master) {
+		// open access doors
+		connect(ui.A0OpenButton, SIGNAL(clicked()), this, SLOT(open_A0door()));
+		connect(ui.AsoOpenButton, SIGNAL(clicked()), this, SLOT(open_Asodoor()));
+		connect(ui.A0OpenButton, SIGNAL(pressed()), this, SLOT(open2_A0door()));
+		connect(ui.A0OpenButton, SIGNAL(released()), this, SLOT(close_A0door()));
+		// open/close beam stoppers
+		connect(ui.bst_linac_OpenCmd_Button, SIGNAL(clicked()), this, SLOT(open_bst_linac()));
+		connect(ui.bst_linac_CloseCmd_Button, SIGNAL(clicked()), this, SLOT(close_bst_linac()));
+		connect(ui.bst1_fel1_OpenCmd_Button, SIGNAL(clicked()), this, SLOT(open_bst1_fel1()));
+		connect(ui.bst1_fel1_CloseCmd_Button, SIGNAL(clicked()), this, SLOT(close_bst1_fel1()));
+		connect(ui.bst2_fel1_OpenCmd_Button, SIGNAL(clicked()), this, SLOT(open_bst2_fel1()));
+		connect(ui.bst2_fel1_CloseCmd_Button, SIGNAL(clicked()), this, SLOT(close_bst2_fel1()));
+		connect(ui.bst1_fel2_OpenCmd_Button, SIGNAL(clicked()), this, SLOT(open_bst1_fel2()));
+		connect(ui.bst1_fel2_CloseCmd_Button, SIGNAL(clicked()), this, SLOT(close_bst1_fel2()));
+		connect(ui.bst2_fel2_OpenCmd_Button, SIGNAL(clicked()), this, SLOT(open_bst2_fel2()));
+		connect(ui.bst2_fel2_CloseCmd_Button, SIGNAL(clicked()), this, SLOT(close_bst2_fel2()));
+		connect(ui.bst_diag_OpenCmd_Button, SIGNAL(clicked()), this, SLOT(open_bst_diag()));
+		connect(ui.bst_diag_CloseCmd_Button, SIGNAL(clicked()), this, SLOT(close_bst_diag()));
+		// acknowledge emergency
+		connect(ui.emergencyRestoreButton, SIGNAL(clicked()), this, SLOT(emergencyRestore()));
+		connect(ui.emergencyRestoreButton_tl, SIGNAL(clicked()), this, SLOT(emergencyRestore_tl()));
+		connect(ui.emergencyRestoreButton_so, SIGNAL(clicked()), this, SLOT(emergencyRestore_so()));
+		// restore
+		connect(ui.A0RestoreButton, SIGNAL(clicked()), this, SLOT(a0Restore()));
+		connect(ui.AsoRestoreButton, SIGNAL(clicked()), this, SLOT(asoRestore()));
+		// request watch
+		connect(ui.A0WatchButton, SIGNAL(clicked()), this, SLOT(watchRequest()));
+		connect(ui.AsoWatchButton, SIGNAL(clicked()), this, SLOT(watchRequest_undulator()));
+		// }
+		// controlSwitchButton
+		// connect(ui.controlSwitchButton, SIGNAL(clicked()), this, SLOT(switch_master()));
+		// open map panel
+		map = 0;
+		connect(ui.openMapButton, SIGNAL(clicked()), this, SLOT(open_map_panel()));
+		map_process = new QProcess(this);
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "cannot connect UI buttons" << endl;
+	}
+	catch (...) {
+		timestamp();
+		cout << tmBuffer << "default exception, cannot setup UI" << endl;
+	}
+	// init map
+	// ui.mapButton->setIcon(QPixmap(imgpath+"/floor_small.png"));
+	// init info buttons
+	ui.watchInfoButton_0->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.watchInfoButton_1->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.watchInfoButton_2->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.watchInfoButton_3->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.watchInfoButton_4->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.watchInfoButton_5->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.watchInfoButton_6->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.watchInfoButton_7->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.watchInfoButton_l->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.watchInfoButton_tl->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.watchInfoButton_so->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.linacShutdownInfoButton->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.linacOffInfoButton->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.linacOnInfoButton->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.undulatorShutdownInfoButton->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.undulatorOffInfoButton->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.undulatorOnInfoButton->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.enableInfoButton_6->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.enableInfoButton_7->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.enableInfoButton_8->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.enableInfoButton_9->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.bstInfoButton->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.bst1_fel1InfoButton->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.bst2_fel1InfoButton->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.bst1_fel2InfoButton->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.bst2_fel2InfoButton->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.bst_diagInfoButton->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.watchInfoButton_esa1->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.watchInfoButton_esa2->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.watchInfoButton_esa->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.psInfoButton->setIcon(QPixmap(imgpath+"/info.png"));
+	ui.toroidInfoButton->setIcon(QPixmap(imgpath+"/info.png"));
+	// ui.emergencyInfoButton_esa1->setIcon(QPixmap(imgpath+"/info.png"));
+	// ui.emergencyInfoButton_esa2->setIcon(QPixmap(imgpath+"/info.png"));
+	
+	// init bst close buttons 
+	ui.bst_linac_CloseCmd_Button->setIcon(QPixmap(imgpath+"/close_cmd.png"));
+	ui.bst1_fel1_CloseCmd_Button->setIcon(QPixmap(imgpath+"/close_cmd.png"));
+	ui.bst2_fel1_CloseCmd_Button->setIcon(QPixmap(imgpath+"/close_cmd.png"));
+	ui.bst1_fel2_CloseCmd_Button->setIcon(QPixmap(imgpath+"/close_cmd.png"));
+	ui.bst2_fel2_CloseCmd_Button->setIcon(QPixmap(imgpath+"/close_cmd.png"));
+	ui.bst_diag_CloseCmd_Button->setIcon(QPixmap(imgpath+"/close_cmd.png"));
+
+	ui.A0PresenceButton->setIcon(QPixmap(imgpath+"/list.png"));
+	ui.A0OpenButton->setIcon(QPixmap(imgpath+"/open.png"));
+	// init restore buttons 
+	ui.AsoRestoreButton->setIcon(QPixmap(imgpath+"/restore.png"));
+	ui.A0RestoreButton->setIcon(QPixmap(imgpath+"/restore.png"));
+	ui.A0WatchButton->setIcon(QPixmap(imgpath+"/watch_request.png"));
+	ui.emergencyRestoreButton->setIcon(QPixmap(imgpath+"/restore_small.png"));
+	ui.emergencyRestoreButton_tl->setIcon(QPixmap(imgpath+"/restore_small.png"));
+	ui.emergencyRestoreButton_so->setIcon(QPixmap(imgpath+"/restore_small.png"));
+	// init open panel buttons
+	ui.alarmListButton->setIcon(QPixmap(imgpath+"/alarm_list.png"));
+	ui.controlSwitchButton->setIcon(QPixmap(imgpath+"/control_switch.png"));
+	ui.openMapButton->setIcon(QPixmap(imgpath+"/map.png"));
+	ui.staffListButton->setIcon(QPixmap(imgpath+"/staff_list.png"));
+	ui.versionButton->setIcon(QPixmap(imgpath+"/version.png"));
+	ui.hardwareButton->setIcon(QPixmap(imgpath+"/hardware.png"));
+	ui.SwitchPickupButton->setIcon(QPixmap(imgpath+"/switchpickup.png"));
+	// init siren
+	ui.A0_siren_label->setPixmap(QPixmap(imgpath+"/siren.png"));
+	ui.A0_permission_label->setPixmap(QPixmap(imgpath+"/permissions.png"));
+	ui.emergencyButton->setIcon(QPixmap(imgpath+"/alarm_on.png"));
+	ui.emergencyButton_tl->setIcon(QPixmap(imgpath+"/alarm_on.png"));
+	ui.emergencyButton_so->setIcon(QPixmap(imgpath+"/alarm_on.png"));
+	// ui.linac_label->setPixmap(QPixmap(imgpath+"Linac_1250.png"));
+	ui.consentA0_0->setPixmap(QPixmap(imgpath+"/permission_off.png"));
+	ui.consentA0_1->setPixmap(QPixmap(imgpath+"/permission_off.png"));
+	ui.consentA0_2->setPixmap(QPixmap(imgpath+"/permission_off.png"));
+
+
+	ui.AsoPresenceButton->setIcon(QPixmap(imgpath+"/list.png"));
+	ui.AsoOpenButton->setIcon(QPixmap(imgpath+"/open.png"));
+	// init restore buttons 
+	ui.AsoRestoreButton->setIcon(QPixmap(imgpath+"/restore.png"));
+	ui.AsoWatchButton->setIcon(QPixmap(imgpath+"/watch_request.png"));
+	// init open panel buttons
+	ui.alarmListButton->setIcon(QPixmap(imgpath+"/alarm_list.png"));
+	ui.controlSwitchButton->setIcon(QPixmap(imgpath+"/control_switch.png"));
+	ui.openMapButton->setIcon(QPixmap(imgpath+"/map.png"));
+	ui.staffListButton->setIcon(QPixmap(imgpath+"/staff_list.png"));
+	ui.versionButton->setIcon(QPixmap(imgpath+"/version.png"));
+	ui.hardwareButton->setIcon(QPixmap(imgpath+"/hardware.png"));
+	ui.SwitchPickupButton->setIcon(QPixmap(imgpath+"/switchpickup.png"));
+	ui.registerButton->setIcon(QPixmap(imgpath+"/registro_accessi.png"));
+	// init siren
+	ui.Aso_siren_label->setPixmap(QPixmap(imgpath+"/siren.png"));
+	ui.Aso_permission_label->setPixmap(QPixmap(imgpath+"/permissions.png"));
+	ui.emergencyButton->setIcon(QPixmap(imgpath+"/alarm_on.png"));
+	ui.emergencyButton_tl->setIcon(QPixmap(imgpath+"/alarm_on.png"));
+	ui.emergencyButton_so->setIcon(QPixmap(imgpath+"/alarm_on.png"));
+	// ui.linac_label->setPixmap(QPixmap(imgpath+"Linac_1250.png"));
+	ui.consentAso_0->setPixmap(QPixmap(imgpath+"/permission_off.png"));
+	ui.consentAso_1->setPixmap(QPixmap(imgpath+"/permission_off.png"));
+	ui.consentAso_2->setPixmap(QPixmap(imgpath+"/permission_off.png"));
+	// init bst pressure icons
+	ui.bst1_fel1press->setPixmap(QPixmap(imgpath+"/pressure_white.png"));
+	ui.bst2_fel1press->setPixmap(QPixmap(imgpath+"/pressure_white.png"));
+	ui.bst1_fel2press->setPixmap(QPixmap(imgpath+"/pressure_white.png"));
+	ui.bst2_fel2press->setPixmap(QPixmap(imgpath+"/pressure_white.png"));
+	ui.bst1_blpress->setPixmap(QPixmap(imgpath+"/pressure_white.png"));
+
+	// init doors
+	// ui.e0_2->setIcon(QPixmap(imgpath+"/e0_2_open.png"));
+	// ui.i1_e0->setIcon(QPixmap(imgpath+"/i1_e0_open.png"));
+	// cout << imgpath.toStdString() << "/Linac_plant_1250.png" << endl;
+	// ui.linac_label_door_0->setPixmap(QPixmap(imgpath+"/linac_door1_red.png"));
+	// set style
+	style = " -style=windows";
+	plcstat = false;
+	ui.noPlc->hide();
+	ui.frame_3->show();
+
+	// init resize data structure
+	w_buffer tmp_buffer;
+	// init global container
+	tmp_buffer.w = NULL;
+	tmp_buffer.x = 0.0;
+	tmp_buffer.y = 0.0;
+	tmp_buffer.width = (double) this->width();
+	tmp_buffer.height = (double) this->height();
+	ws_buffer.push_back(tmp_buffer);
+	// init all widgets
+	foreach(QWidget *w, this->findChildren<QWidget *>()) {
+		tmp_buffer.w = w;
+		tmp_buffer.font = w->font();
+		tmp_buffer.x = (double) w->x();
+		tmp_buffer.y = (double) w->y();
+		tmp_buffer.width = (double) w->width();
+		tmp_buffer.height = (double) w->height();
+		ws_buffer.push_back(tmp_buffer);
+	}
+	resizeFactorX = resizeFactorY = resizeFactorM = 1;
+	QDesktopWidget mydesk;
+	if ((mydesk.width()>100) && (this->width()-2 > mydesk.width())) this->resize(mydesk.width(), this->height()*mydesk.width()/this->width());
+	cout << (((mydesk.width()>100) && (this->width()-2 > mydesk.width()))? "true ": "false") << endl;
+	cout << "mydesk.width(): " << mydesk.width() << ", this->height(): " << this->height() << endl;
+	cout << "resizeFactorX: " << resizeFactorX << ", resizeFactorY: " << resizeFactorY << ", resizeFactorM: " << resizeFactorM  << endl;
+	// strcpy(url, "http://fcsproxy.elettra.eu/docs/pss/register_alarm.php?user_inside=");
+	// web_read(url, "n.surname");
+}
+
+acs::~acs()
+{
+}
+
+void acs::resizeEvent( QResizeEvent * event ) {
+	foreach(w_buffer tmp_buffer, ws_buffer) {
+		if (tmp_buffer.w==NULL) {
+			resizeFactorX = this->width()/tmp_buffer.width;
+			resizeFactorY = this->height()/tmp_buffer.height;
+			resizeFactorM = resizeFactorX<resizeFactorY? resizeFactorX: resizeFactorY;
+		}
+		else {
+			tmp_buffer.w->resize(tmp_buffer.width*resizeFactorX,tmp_buffer.height*resizeFactorY);
+			tmp_buffer.w->move(tmp_buffer.x*resizeFactorX,tmp_buffer.y*resizeFactorY);
+			// fonts require special treatment
+			QFont font = tmp_buffer.font;
+			font.setPointSizeF(font.pointSizeF()*resizeFactorM);
+			tmp_buffer.w->setFont(font);
+		}
+	}
+}
+
+int acs::myWriteCommand(const char *cmdName)
+{
+	try {
+		plc_server->command_inout(cmdName);
+		return 1;
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "error writing command: " << cmdName << endl;
+	}
+	catch (...) {
+		timestamp();
+		cout << tmBuffer << "default exception writing command: " << cmdName << endl;
+	}
+	return 0;
+}
+
+int acs::myWriteCommand(const char *cmdName, const int param)
+{
+	Tango::DeviceData paramData;
+	Tango::DevShort paramDevShort = param; 
+	paramData << paramDevShort;
+	try {
+		plc_server->command_inout(cmdName, paramData);
+		return 1;
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "error writing command: " << cmdName << endl;
+	}
+	catch (...) {
+		timestamp();
+		cout << tmBuffer << "default exception writing command: " << cmdName << endl;
+	}
+	return 0;
+}
+
+int acs::myReadShortint(const char *attrName, short int *attrVal)
+{
+	try {
+		plc_server->read_attribute(attrName) >> *attrVal;
+		return 1;
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "error reading attribute: " << attrName << endl;
+	}
+	catch (...) {
+		timestamp();
+		cout << tmBuffer << "default exception reading attribute: " << attrName << endl;
+	}
+	return 0;
+}
+
+int acs::myReadString(const char *attrName, string &strstat)
+{
+	try {
+		plc_server->read_attribute(attrName) >> strstat;
+		return 1;
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "error reading attribute: " << attrName << endl;
+	}
+	catch (...) {
+		timestamp();
+		cout << tmBuffer << "default exception reading attribute: " << attrName << endl;
+	}
+	return 0;
+}
+
+int acs::myReadShortArray(const char *attrName, vector<short> & attrVal)
+{
+	try {
+		plc_server->read_attribute(attrName) >> attrVal;
+		return 1;
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "error reading attribute: " << attrName << endl;
+	}
+	catch (...) {
+		timestamp();
+		cout << tmBuffer << "default exception reading attribute: " << attrName << endl;
+	}
+	return 0;
+}
+
+int acs::myReadBool(const char *attrName, bool *attrVal)
+{
+	try {
+		plc_server->read_attribute(attrName) >> *attrVal;
+		return 1;
+	}
+	catch (const Tango::DevFailed &e) {
+		// timestamp(); cout << tmBuffer << "error reading attribute: " << attrName << endl;
+	}
+	catch (...) {
+		timestamp();
+		cout << tmBuffer << "default exception reading attribute: " << attrName << endl;
+	}
+	return 0;
+}
+
+int acs::myReadBoolArray(const char *attrName, vector<bool> & attrVal)
+{
+	try {
+		plc_server->read_attribute(attrName) >> attrVal;
+		return 1;
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "error reading attribute: " << attrName << endl;
+	}
+	catch (...) {
+		timestamp();
+		cout << tmBuffer << "default exception reading attribute: " << attrName << endl;
+	}
+	return 0;
+}
+
+int acs::myReadAttribute(const char *attrName)
+{
+	try {
+		myAttribute = plc_server->read_attribute(attrName);
+		return 1;
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "error reading attribute: " << attrName << endl;
+	}
+	catch (...) {
+		timestamp();
+		cout << tmBuffer << "default exception reading attribute: " << attrName << endl;
+	}
+	return 0;
+}
+
+int acs::mySetColor(QFrame *widget, const char *color, QPalette::ColorRole role=QPalette::Dark)
+{
+	QPalette button;
+	button.setColor(QPalette::Light, QColor(color));
+	button.setColor(role, QColor(color));
+	widget->setPalette(button);
+	return 0;
+}
+
+int acs::mySetTextColor(QLabel *widget, const char *text, const char *color)
+{
+	QPalette button;
+	widget->setText(text);
+	button.setColor(QPalette::WindowText, QColor(color));
+	widget->setPalette(button);
+	return 0;
+}
+
+int acs::mySetTextColor(QLabel *widget, const char *text, const char *color, const char *bgcolor)
+{
+	QPalette button;
+	widget->setText(text);
+	button.setColor(QPalette::Window, QColor(bgcolor));
+	button.setColor(QPalette::WindowText, QColor(color));
+	widget->setPalette(button);
+	return 0;
+}
+
+
+
+
+void acs::open_A0door()
+{
+	cout << "open_A0door " << endl;
+	// operations reserved to master only
+	if (!master and !masterA0) {
+		QMessageBox::information(this, "Apertura Negata", "Apertura porta consentita solo da workstation controllo accessi\nin sala controllo anello accanto alle telecamere", QMessageBox::Ok);
+	}
+	else if (controlLocation == "Sala Controllo Anello") {
+		if (master) {
+			myWriteCommand("LinacDoorOpen");
+		}
+		else {
+			QMessageBox::information(this, "Apertura Negata", "Controlla bottone: CAMBIA CONTROLLO PSA / SALA CONTROLLO", QMessageBox::Ok);
+		}
+	}
+	else {
+		if (masterA0) {
+			myWriteCommand("LinacDoorOpen");
+		}
+		else {
+			QMessageBox::information(this, "Apertura Negata", "Controlla bottone: CAMBIA CONTROLLO PSA / SALA CONTROLLO", QMessageBox::Ok);
+		}
+	}
+}
+
+void acs::open2_A0door()
+{
+	cout << "open_A0door(), pressed " << endl;
+
+}
+
+void acs::close_A0door()
+{
+	cout << "open_A0door(), released " << endl;
+
+}
+
+void acs::open_Asodoor()
+{
+	// operations reserved to master only
+	if (!master and !masterA0) {
+		QMessageBox::information(this, "Apertura Negata", "Apertura porta consentita solo da workstation controllo accessi\nin sala controllo anello accanto alle telecamere", QMessageBox::Ok);
+	}
+	else if (controlLocation == "Sala Controllo Anello") {
+		if (master) {
+			myWriteCommand("UndulatorDoorOpen");
+		}
+		else {
+			QMessageBox::information(this, "Apertura Negata", "Controlla bottone: CAMBIA CONTROLLO PSA / SALA CONTROLLO", QMessageBox::Ok);
+		}
+	}
+	else {
+		if (masterA0) {
+			myWriteCommand("UndulatorDoorOpen");
+		}
+		else {
+			QMessageBox::information(this, "Apertura Negata", "Controlla bottone: CAMBIA CONTROLLO PSA / SALA CONTROLLO", QMessageBox::Ok);
+		}
+	}
+}
+
+void acs::a0Restore()
+{
+	// operations reserved to master only
+	if (!master and !masterA0) {
+		QMessageBox::information(this, "Ripristino Negato", "Ripristino consentito solo da workstation controllo accessi\nin sala controllo anello accanto alle telecamere", QMessageBox::Ok);
+	}
+	else if (controlLocation == "Sala Controllo Anello") {
+		if (master) {
+			myWriteCommand("LinacDoorReset");
+		}
+		else {
+			QMessageBox::information(this, "Ripristino Negato", "Controlla bottone: CAMBIA CONTROLLO PSA / SALA CONTROLLO", QMessageBox::Ok);
+		}
+	}
+	else {
+		if (masterA0) {
+			myWriteCommand("LinacDoorReset");
+		}
+		else {
+			QMessageBox::information(this, "Ripristino Negato", "Controlla bottone: CAMBIA CONTROLLO PSA / SALA CONTROLLO", QMessageBox::Ok);
+		}
+	}
+	// myWriteCommand("Ripr_in_inj");
+	cout << "a0Restore" << endl;
+}
+
+void acs::asoRestore()
+{
+	// operations reserved to master only
+	if (!master and !masterA0) {
+		QMessageBox::information(this, "Ripristino Negato", "Ripristino consentito solo da workstation controllo accessi\nin sala controllo anello accanto alle telecamere", QMessageBox::Ok);
+	}
+	else if (controlLocation == "Sala Controllo Anello") {
+		if (master) {
+			myWriteCommand("UndulatorDoorReset");
+		}
+		else {
+			QMessageBox::information(this, "Ripristino Negato", "Controlla bottone: CAMBIA CONTROLLO PSA / SALA CONTROLLO", QMessageBox::Ok);
+		}
+	}
+	else {
+		if (masterA0) {
+			myWriteCommand("UndulatorDoorReset");
+		}
+		else {
+			QMessageBox::information(this, "Ripristino Negato", "Controlla bottone: CAMBIA CONTROLLO PSA / SALA CONTROLLO", QMessageBox::Ok);
+		}
+	}
+	// myWriteCommand("Ripr_in_inj");
+	cout << "a0Restore" << endl;
+}
+
+void acs::watchRequest()
+{
+	// operations reserved to master only
+	if (!master and !masterA0) {
+		QMessageBox::information(this, "Richiesta ronda negata", "Richiesta ronda consentita solo da workstation controllo accessi\nin sala controllo anello accanto alle telecamere", QMessageBox::Ok);
+	}
+	else if (controlLocation == "Sala Controllo Anello") {
+		if (master) {
+			// watch request procedure
+			try {
+				int r = QMessageBox::question(this, "Conferma richiesta ronda", "Conferma richiesta ronda", "Richiesta ronda", "Annulla");
+				if (r == 0) {
+					myWriteCommand("LinacSearchRequest");
+				}
+			}
+			catch (const Tango::DevFailed &e) {
+				timestamp();
+				cout << tmBuffer << "Non posso richiedere la ronda" << endl;
+			}
+		}
+		else {
+			QMessageBox::information(this, "Richiesta ronda negata", "Controlla bottone: CAMBIA CONTROLLO PSA / SALA CONTROLLO", QMessageBox::Ok);
+		}
+	}
+	else {
+		if (masterA0) {
+			// watch request procedure
+			try {
+				int r = QMessageBox::question(this, "Conferma richiesta ronda", "Conferma richiesta ronda", "Richiesta ronda", "Annulla");
+				if (r == 0) {
+					myWriteCommand("LinacSearchRequest");
+				}
+			}
+			catch (const Tango::DevFailed &e) {
+				timestamp();
+				cout << tmBuffer << "Non posso richiedere la ronda" << endl;
+			}
+		}
+		else {
+			QMessageBox::information(this, "Richiesta ronda negata", "Controlla bottone: CAMBIA CONTROLLO PSA / SALA CONTROLLO", QMessageBox::Ok);
+		}
+	}
+	cout << "watchRequest" << endl;
+}
+
+void acs::watchRequest_undulator()
+{
+	// operations reserved to master only
+	if (!master and !masterA0) {
+		QMessageBox::information(this, "Richiesta ronda negata", "Richiesta ronda consentita solo da workstation controllo accessi\nin sala controllo anello accanto alle telecamere", QMessageBox::Ok);
+	}
+	else if (controlLocation == "Sala Controllo Anello") {
+		if (master) {
+			// watch request procedure
+			try {
+				int r = QMessageBox::question(this, "Conferma richiesta ronda", "Conferma richiesta ronda", "Richiesta ronda", "Annulla");
+				if (r == 0) {
+					myWriteCommand("UndulatorSearchRequest");
+				}
+			}
+			catch (const Tango::DevFailed &e) {
+				timestamp();
+				cout << tmBuffer << "Non posso richiedere la ronda" << endl;
+			}
+		}
+		else {
+			QMessageBox::information(this, "Richiesta ronda negata", "Controlla bottone: CAMBIA CONTROLLO PSA / SALA CONTROLLO", QMessageBox::Ok);
+		}
+	}
+	else {
+		if (masterA0) {
+			// watch request procedure
+			try {
+				int r = QMessageBox::question(this, "Conferma richiesta ronda", "Conferma richiesta ronda", "Richiesta ronda", "Annulla");
+				if (r == 0) {
+					myWriteCommand("UndulatorSearchRequest");
+				}
+			}
+			catch (const Tango::DevFailed &e) {
+				timestamp();
+				cout << tmBuffer << "Non posso richiedere la ronda" << endl;
+			}
+		}
+		else {
+			QMessageBox::information(this, "Richiesta ronda negata", "Controlla bottone: CAMBIA CONTROLLO PSA / SALA CONTROLLO", QMessageBox::Ok);
+		}
+	}
+	cout << "watchRequest" << endl;
+}
+
+void acs::emergencyRestore()
+{
+	// operations reserved to master only
+	if (!master and !masterA0) {
+		QMessageBox::information(this, "Ripristino Negato", "Ripristino consentito solo da workstation controllo accessi\nin sala controllo anello accanto alle telecamere", QMessageBox::Ok);
+	}
+	else if (controlLocation == "Sala Controllo Anello") {
+		if (master) {
+			myWriteCommand("LinacEmeAck");
+		}
+		else {
+			QMessageBox::information(this, "Ripristino Negato", "Controlla bottone: CAMBIA CONTROLLO PSA / SALA CONTROLLO", QMessageBox::Ok);
+		}
+	}
+	else {
+		if (masterA0) {
+			myWriteCommand("LinacEmeAck");
+		}
+		else {
+			QMessageBox::information(this, "Ripristino Negato", "Controlla bottone: CAMBIA CONTROLLO PSA / SALA CONTROLLO", QMessageBox::Ok);
+		}
+	}
+	// myWriteCommand("Ack_eme");
+	cout << "Ack_eme" << endl;
+}
+
+void acs::emergencyRestore_tl()
+{
+	// operations reserved to master only
+	if (!master and !masterA0) {
+		QMessageBox::information(this, "Ripristino Negato", "Ripristino consentito solo da workstation controllo accessi\nin sala controllo anello accanto alle telecamere", QMessageBox::Ok);
+	}
+	else if (controlLocation == "Sala Controllo Anello") {
+		if (master) {
+			myWriteCommand("LinacEmeTLAck");
+		}
+		else {
+			QMessageBox::information(this, "Ripristino Negato", "Controlla bottone: CAMBIA CONTROLLO PSA / SALA CONTROLLO", QMessageBox::Ok);
+		}
+	}
+	else {
+		if (masterA0) {
+			myWriteCommand("LinacEmeTLAck");
+		}
+		else {
+			QMessageBox::information(this, "Ripristino Negato", "Controlla bottone: CAMBIA CONTROLLO PSA / SALA CONTROLLO", QMessageBox::Ok);
+		}
+	}
+	// myWriteCommand("Ack_eme");
+	cout << "Ack_tl_eme" << endl;
+}
+
+void acs::emergencyRestore_so()
+{
+	// operations reserved to master only
+	if (!master and !masterA0) {
+		QMessageBox::information(this, "Ripristino Negato", "Ripristino consentito solo da workstation controllo accessi\nin sala controllo anello accanto alle telecamere", QMessageBox::Ok);
+	}
+	else if (controlLocation == "Sala Controllo Anello") {
+		if (master) {
+			myWriteCommand("UndulatorEmeAck");
+		}
+		else {
+			QMessageBox::information(this, "Ripristino Negato", "Controlla bottone: CAMBIA CONTROLLO PSA / SALA CONTROLLO", QMessageBox::Ok);
+		}
+	}
+	else {
+		if (masterA0) {
+			myWriteCommand("UndulatorEmeAck");
+		}
+		else {
+			QMessageBox::information(this, "Ripristino Negato", "Controlla bottone: CAMBIA CONTROLLO PSA / SALA CONTROLLO", QMessageBox::Ok);
+		}
+	}
+	// myWriteCommand("Ack_eme");
+	cout << "Ack_eme undulator" << endl;
+}
+
+void acs::open_inA0_list()
+{
+	if (inA0_list_process->state() == QProcess::Running) {
+		inA0_list_process->kill();
+		inA0_list_process->waitForFinished(3000);
+	}
+	inA0_list_process->start("acslistinalinac"+style);
+
+}
+
+void acs::open_inAso_list()
+{
+	if (inAso_list_process->state() == QProcess::Running) {
+		inAso_list_process->kill();
+		inAso_list_process->waitForFinished(3000);
+	}
+	inAso_list_process->start("acslistinaso"+style);
+
+}
+
+void acs::open_staff_list()
+{
+	if (staff_list_process->state() == QProcess::Running) {
+		staff_list_process->kill();
+		staff_list_process->waitForFinished(3000);
+	}
+	staff_list_process->start("acsliststaff"+style);
+
+}
+
+void acs::open_linac_doors()
+{
+	if (linac_doors_process->state() == QProcess::Running) {
+		linac_doors_process->kill();
+		linac_doors_process->waitForFinished(3000);
+	}
+	linac_doors_process->start("acsdoorl"+style);
+}
+
+void acs::open_e0_doors()
+{
+	if (e0_doors_process->state() == QProcess::Running) {
+		e0_doors_process->kill();
+		e0_doors_process->waitForFinished(3000);
+	}
+	e0_doors_process->start("acsdoore0"+style);
+}
+
+void acs::open_e1_doors()
+{
+	if (e1_doors_process->state() == QProcess::Running) {
+		e1_doors_process->kill();
+		e1_doors_process->waitForFinished(3000);
+	}
+	e1_doors_process->start("acsdoore1"+style);
+}
+
+void acs::open_e2_doors()
+{
+	if (e2_doors_process->state() == QProcess::Running) {
+		e2_doors_process->kill();
+		e2_doors_process->waitForFinished(3000);
+	}
+	e2_doors_process->start("acsdoore2"+style);
+}
+
+void acs::open_e3_doors()
+{
+	if (e3_doors_process->state() == QProcess::Running) {
+		e3_doors_process->kill();
+		e3_doors_process->waitForFinished(3000);
+	}
+	e3_doors_process->start("acsdoore3"+style);
+}
+
+void acs::open_e4_doors()
+{
+	if (e4_doors_process->state() == QProcess::Running) {
+		e4_doors_process->kill();
+		e4_doors_process->waitForFinished(3000);
+	}
+	e4_doors_process->start("acsdoore4"+style);
+}
+
+void acs::open_e5_doors()
+{
+	if (e5_doors_process->state() == QProcess::Running) {
+		e5_doors_process->kill();
+		e5_doors_process->waitForFinished(3000);
+	}
+	e5_doors_process->start("acsdoore5"+style);
+}
+
+void acs::open_e6_doors()
+{
+	if (e6_doors_process->state() == QProcess::Running) {
+		e6_doors_process->kill();
+		e6_doors_process->waitForFinished(3000);
+	}
+	e6_doors_process->start("acsdoore6"+style);
+}
+
+void acs::open_e7_doors()
+{
+	if (e7_doors_process->state() == QProcess::Running) {
+		e7_doors_process->kill();
+		e7_doors_process->waitForFinished(3000);
+	}
+	e7_doors_process->start("acsdoore7"+style);
+}
+
+void acs::open_tl_doors()
+{
+	if (tl_doors_process->state() == QProcess::Running) {
+		tl_doors_process->kill();
+		tl_doors_process->waitForFinished(3000);
+	}
+	tl_doors_process->start("acsdoortl"+style);
+}
+
+void acs::open_so_doors()
+{
+	if (so_doors_process->state() == QProcess::Running) {
+		so_doors_process->kill();
+		so_doors_process->waitForFinished(3000);
+	}
+	so_doors_process->start("acsdoorso"+style);
+}
+
+void acs::open_emergency_buttons()
+{
+	if (emergency_buttons_process->state() == QProcess::Running) {
+		emergency_buttons_process->kill();
+		emergency_buttons_process->waitForFinished(3000);
+	}
+	emergency_buttons_process->start("acsemergency"+style);
+}
+
+void acs::open_emergency_buttons_so()
+{
+	if (emergency_buttons_so_process->state() == QProcess::Running) {
+		emergency_buttons_so_process->kill();
+		emergency_buttons_so_process->waitForFinished(3000);
+	}
+	emergency_buttons_so_process->start("acsemergencyundulator"+style);
+}
+
+
+void acs::open_bst_linac_panel()
+{
+	if (bst_linac_process->state() != QProcess::Running) {
+		bst_linac_process->start("acsbst Linac_bst_1 Linac_bst_1 BST_LINAC "+style);
+	}
+}
+
+void acs::open_bst_linac_info_panel()
+{
+	if (bst_linac_info_process->state() != QProcess::Running) {
+		bst_linac_info_process->kill();
+		bst_linac_info_process->waitForFinished(3000);
+	}
+	bst_linac_info_process->start("acsinhibitbstlinac"+style);
+}
+
+void acs::open_bst_bl_info_panel()
+{
+	if (bst_bl_info_process->state() != QProcess::Running) {
+		bst_bl_info_process->kill();
+		bst_bl_info_process->waitForFinished(3000);
+	}
+	bst_bl_info_process->start("acsinhibitbstbl"+style);
+}
+
+void acs::open_bst1_fel1_panel()
+{
+	if (bst1_fel1_process->state() != QProcess::Running) {
+		bst1_fel1_process->kill();
+		bst1_fel1_process->waitForFinished(3000);
+	}
+	bst1_fel1_process->start("acsbst Undulator_bst1_fel1 BST1_FEL1 BST1_FEL1"+style);
+}
+
+void acs::open_bst2_fel1_panel()
+{
+	if (bst2_fel1_process->state() != QProcess::Running) {
+		bst2_fel1_process->kill();
+		bst2_fel1_process->waitForFinished(3000);
+	}
+	bst2_fel1_process->start("acsbst Undulator_bst2_fel1 BST2_FEL1 BST2_FEL1"+style);
+}
+
+void acs::open_bst1_fel2_panel()
+{
+	if (bst1_fel2_process->state() != QProcess::Running) {
+		bst1_fel2_process->kill();
+		bst1_fel2_process->waitForFinished(3000);
+	}
+	bst1_fel2_process->start("acsbst Undulator_bst1_fel2 BST1_FEL2 BST1_FEL2"+style);
+}
+
+void acs::open_bst2_fel2_panel()
+{
+	if (bst2_fel2_process->state() != QProcess::Running) {
+		bst2_fel2_process->kill();
+		bst2_fel2_process->waitForFinished(3000);
+	}
+	bst2_fel2_process->start("acsbst Undulator_bst2_fel2 BST2_FEL2 BST2_FEL2"+style);
+}
+
+void acs::open_bst_diag_panel()
+{
+	if (bst_diag_process->state() != QProcess::Running) {
+		bst_diag_process->kill();
+		bst_diag_process->waitForFinished(3000);
+	}
+	bst_diag_process->start("acsbst Undulator_bst_diag BST_DIAGN BST_DIAGN"+style);
+}
+
+void acs::open_emergency_esa1_panel()
+{
+	if (emergency_esa1_process->state() == QProcess::Running) {
+		emergency_esa1_process->kill();
+		emergency_esa1_process->waitForFinished(3000);
+	}
+	emergency_esa1_process->start("acsalarmesa1"+style);
+}
+
+void acs::open_emergency_esa2_panel()
+{
+	if (emergency_esa2_process->state() == QProcess::Running) {
+		emergency_esa2_process->kill();
+		emergency_esa2_process->waitForFinished(3000);
+	}
+	emergency_esa2_process->start("acsalarmesa2"+style);
+}
+
+void acs::open_watch_esa1_panel()
+{
+	if (watch_esa1_process->state() == QProcess::Running) {
+		watch_esa1_process->kill();
+		watch_esa1_process->waitForFinished(3000);
+	}
+	watch_esa1_process->start("acssearchesa1"+style);
+}
+
+void acs::open_watch_esa2_panel()
+{
+	if (watch_esa2_process->state() == QProcess::Running) {
+		watch_esa2_process->kill();
+		watch_esa2_process->waitForFinished(3000);
+	}
+	watch_esa2_process->start("acssearchesa2"+style);
+}
+
+void acs::open_esahutch_panel()
+{
+	if (esahutch_process->state() == QProcess::Running) {
+		esahutch_process->kill();
+		esahutch_process->waitForFinished(3000);
+	}
+	esahutch_process->start("acsesahutch"+style);
+}
+
+
+void acs::open_stat_linac_shutdown()
+{
+	// cout << "open_stat_linac_shutdown()" << endl; return;
+	if (stat_shutdown_process->state() == QProcess::Running) {
+		stat_shutdown_process->kill();
+		stat_shutdown_process->waitForFinished(3000);
+	}
+	stat_shutdown_process->start("acslinacshutdown"+style);
+}
+
+void acs::open_stat_linac_off()
+{
+	if (stat_off_process->state() == QProcess::Running) {
+		stat_off_process->kill();
+		stat_off_process->waitForFinished(3000);
+	}
+	stat_off_process->start("acslinacoff"+style);
+}
+
+void acs::open_stat_linac_on()
+{
+	if (stat_on_process->state() == QProcess::Running) {
+		stat_on_process->kill();
+		stat_on_process->waitForFinished(3000);
+	}
+	stat_on_process->start("acslinacon"+style);
+}
+
+void acs::open_stat_undulator_shutdown()
+{
+	// cout << "open_stat_linac_shutdown()" << endl; return;
+	if (undulator_stat_shutdown_process->state() == QProcess::Running) {
+		undulator_stat_shutdown_process->kill();
+		undulator_stat_shutdown_process->waitForFinished(3000);
+	}
+	undulator_stat_shutdown_process->start("acsundulatorshutdown"+style);
+}
+
+void acs::open_stat_undulator_off()
+{
+	if (undulator_stat_off_process->state() == QProcess::Running) {
+		undulator_stat_off_process->kill();
+		undulator_stat_off_process->waitForFinished(3000);
+	}
+	undulator_stat_off_process->start("acsundulatoroff"+style);
+}
+
+void acs::open_stat_undulator_on()
+{
+	if (undulator_stat_on_process->state() == QProcess::Running) {
+		undulator_stat_on_process->kill();
+		undulator_stat_on_process->waitForFinished(3000);
+	}
+	undulator_stat_on_process->start("acsundulatoron"+style);
+}
+
+void acs::open_klyswitch()
+{
+	if (klyswitch_process->state() == QProcess::Running) {
+		klyswitch_process->kill();
+		klyswitch_process->waitForFinished(3000);
+	}
+	klyswitch_process->start("acsklyswitch"+style);
+}
+
+void acs::open_klystat()
+{
+	if (klystat_process->state() == QProcess::Running) {
+		klystat_process->kill();
+		klystat_process->waitForFinished(3000);
+	}
+	klystat_process->start("acsklystat"+style);
+}
+
+void acs::open_rfinhibit_panel()
+{
+	if (rfinhibit_process->state() == QProcess::Running) {
+		rfinhibit_process->kill();
+		rfinhibit_process->waitForFinished(3000);
+	}
+	rfinhibit_process->start("acsinhibitrf"+style);
+}
+
+void acs::open_rfpcgun_panel()
+{
+	if (rfpcgun_process->state() == QProcess::Running) {
+		rfpcgun_process->kill();
+		rfpcgun_process->waitForFinished(3000);
+	}
+	short int mod;
+	myReadShortint("Linac_mod_on_pcgun", &mod);
+	cout << (mod==0? "acsinhibitrfks": "acsinhibitrfk1") << endl;
+	rfpcgun_process->start((mod==0? "acsinhibitrfks": "acsinhibitrfk1")+style);
+}
+
+void acs::open_permission_panel()
+{
+	if (permission_process->state() == QProcess::Running) {
+		permission_process->kill();
+		permission_process->waitForFinished(3000);
+	}
+	permission_process->start("acspermission"+style);
+}
+
+void acs::open_plants_panel()
+{
+	if (plants_process->state() == QProcess::Running) {
+		plants_process->kill();
+		plants_process->waitForFinished(3000);
+	}
+	plants_process->start("acsplants"+style);
+}
+
+void acs::open_topup_error()
+{
+	if (topup_error_process->state() == QProcess::Running) {
+		topup_error_process->kill();
+		topup_error_process->waitForFinished(3000);
+	}
+	topup_error_process->start("acstopuperror"+style);
+}
+
+void acs::open_search_panel()
+{
+	if (search_process->state() == QProcess::Running) {
+		search_process->kill();
+		search_process->waitForFinished(3000);
+	}
+	search_process->start("acssearch"+style);
+}
+
+void acs::open_map()
+{
+	// ui.mapButton->setIcon(QPixmap(imgpath+(map? "/floor_small.png": "/roof_small.png")));
+	map = 1 - map;
+}
+
+void acs::open_map_panel()
+{
+	if (map_process->state() == QProcess::Running) {
+		map_process->kill();
+		map_process->waitForFinished(3000);
+	}
+	map_process->start("acsmap"+style);
+}
+
+void acs::open_hardware_panel()
+{
+	if (hardware_process->state() == QProcess::Running) {
+		hardware_process->kill();
+		hardware_process->waitForFinished(3000);
+	}
+	hardware_process->start("acshardware"+style);
+}
+
+void acs::open_ps_panel()
+{
+	if (ps_process->state() == QProcess::Running) {
+		ps_process->kill();
+		ps_process->waitForFinished(3000);
+	}
+	ps_process->start("acsps"+style);
+}
+
+void acs::open_toroid_panel()
+{
+	if (toroid_process->state() == QProcess::Running) {
+		toroid_process->kill();
+		toroid_process->waitForFinished(3000);
+	}
+	toroid_process->start("acstoroid"+style);
+}
+
+void acs::refresh()
+{
+	vector<bool> stat, stat2, stat3, stat4;
+	bool boolstat, undulatorPlcStat, linacPlcStat;
+	char firstAbi[1000] = 
+	"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\np, li { white-space: pre-wrap; }\n</style></head><body style=\" font-family:'Sans Serif'; font-size:11pt; font-weight:600; font-style:normal;\">\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">1<span style=\" vertical-align:super;\">a</span> ABI</p></body></html>";
+	// stat.size(16);
+	refreshCount = 1 - refreshCount;
+	Tango::DeviceAttribute StateFlags;
+	if (plc_server == NULL) {
+		cout << "Cannot connect server" << endl;
+		return;
+	}
+	linacPlcStat = false;
+	// set PLC status
+	if (myReadBool("Plc_status", &boolstat)) {
+		if (noSrvRetry > 0) cout << tmBuffer << "PLC connected" << endl;
+		noSrvRetry = 0;
+		if (boolstat) {
+			linacPlcStat =true;
+			ui.noPlc->hide();
+			mySetTextColor(ui.A0_plc_label, "PLC ON", "white", "black");
+			mySetColor(ui.A0_plc_label, "#ffffff", QPalette::Window);
+			mySetColor(ui.A0_header_label, "#ffffff", QPalette::Window);
+		}
+		else {
+			mySetTextColor(ui.A0_plc_label, refreshCount? "NO PLC": "", "black", refreshCount? "#ffd800": "white");
+			mySetColor(ui.A0_plc_label, "#ffd800", QPalette::Window);
+			mySetColor(ui.A0_header_label, "#ffd800", QPalette::Window);
+			ui.noPlc->show();
+		}
+		/*
+		// cout << "boolstat" << endl;
+		if (!plcstat && boolstat) {
+			QMessageBox::information(this, "PLC NOK", "\n\n\n\n        ATTENZIONE!                        \n\n\n        PLC non raggiungibile                                 \n\n\n\n\n\n\n\n\n\n", QMessageBox::Ok);
+		}
+		// cout << "mySetTextColor" << endl;
+		mySetTextColor(ui.A0_plc_label, boolstat? "PLC OK": "PLC NOK", boolstat? "black": "#e00000", "white");
+		// mySetTextColor(ui.A1_plc_label, boolstat? "PLC OK": "PLC NOK", boolstat? "black": "#e00000", "white");
+		plcstat = boolstat;
+		// ui.A0_plc_label->setText(boolstat? "PLC ON": "PLC OFF");
+		*/
+	}
+	else {
+		noSrvRetry++;
+		mySetColor(ui.A0_plc_label, "#ffd800", QPalette::Window);
+		mySetTextColor(ui.A0_plc_label, refreshCount? "NO SRV": "", "black", refreshCount? "#ffd800": "white");
+		mySetColor(ui.A0_header_label, "#ffd800", QPalette::Window);
+		// mySetTextColor(ui.A1_plc_label, refreshCount? "NO SRV": "", "black", refreshCount? "#ffff00": "white");
+		// ui.A0_plc_label->setText(refreshCount? "PLC ???": "");
+		timestamp();
+		if (noSrvRetry == 1) cout << tmBuffer << "error: cannot connect to PLC" << endl;
+		// if (noSrvRetry > 3 && noSrvRetry%40) return;
+	}
+	undulatorPlcStat = false;
+	if (myReadBool("Undulator_plc_status", &boolstat)) {
+		if (noSrvRetry > 0) cout << tmBuffer << "PLC connected" << endl;
+		noSrvRetry = 0;
+		if (boolstat) {
+			undulatorPlcStat = true;
+			ui.noPlc->hide();
+			mySetTextColor(ui.Aso_plc_label, "PLC ON", "white", "black");
+			mySetColor(ui.Aso_plc_label, "#ffffff", QPalette::Window);
+			mySetColor(ui.Aso_header_label, "#ffffff", QPalette::Window);
+		}
+		else {
+			mySetTextColor(ui.Aso_plc_label, refreshCount? "NO PLC": "", "black", refreshCount? "#ffd800": "white");
+			mySetColor(ui.Aso_plc_label, "#ffd800", QPalette::Window);
+			mySetColor(ui.Aso_header_label, "#ffd800", QPalette::Window);
+			ui.noPlc->show();
+		}
+	}
+	else {
+		noSrvRetry++;
+		mySetColor(ui.Aso_plc_label, "#ffd800", QPalette::Window);
+		mySetTextColor(ui.Aso_plc_label, refreshCount? "NO SRV": "", "black", refreshCount? "#ffd800": "white");
+		mySetColor(ui.Aso_header_label, "#ffd800", QPalette::Window);
+		timestamp();
+		if (noSrvRetry > 3 && noSrvRetry%40) return;
+		if (noSrvRetry == 1) cout << tmBuffer << "error: cannot connect to PLC" << endl;
+	}
+	// set keys
+	if (linacPlcStat && myReadBoolArray("Linac_access_state", stat)) {
+		mySetTextColor(ui.linacKeyStat, stat[3]? firstAbi: "SHUTDOWN", stat[3]? "#000000": "#00aa00");
+	}
+	else {
+		mySetTextColor(ui.linacKeyStat, "???", "#000000");
+	}
+	if (undulatorPlcStat && myReadBoolArray("Undulator_access_state", stat)) {
+		mySetTextColor(ui.undulatorKeyStat, stat[3]? firstAbi: "SHUTDOWN", stat[3]? "#000000": "#00aa00");
+		mySetTextColor(ui.mdbKeyStat, !stat[4]? "ENABLE": "DISABLE", !stat[4]? "#00aa00": "#e00000");
+		ui.lineInOperation->setText(stat[5]? "FEL1": (stat[6]? "FEL2": "???"));
+	}
+	else {
+		mySetTextColor(ui.undulatorKeyStat, "???", "#000000");
+		mySetTextColor(ui.mdbKeyStat, "???", "#000000");
+		ui.lineInOperation->setText("???");
+	}
+	short int en;
+	if ((stat[5] || stat[6]) && undulatorPlcStat && myReadShortint(stat[5]? "Undulator_sprd_fel_1": "Undulator_sprd_fel_2", &en)) {
+		ui.OperationEnergy->setText(QString::number(en)+" [MeV]");
+	}
+	else {
+		ui.OperationEnergy->setText("??? [MeV]");
+	}
+	// set linac external badge board
+	if (linacPlcStat && myReadBoolArray("Linac_key_ext", stat) and myReadBoolArray("Linac_key_release", stat2)) {
+		ui.keyA0ext_00->setPixmap(QPixmap(imgpath+(stat[0]? (stat2[0]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyA0ext_01->setPixmap(QPixmap(imgpath+(stat[1]? (stat2[1]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyA0ext_02->setPixmap(QPixmap(imgpath+(stat[2]? (stat2[2]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyA0ext_03->setPixmap(QPixmap(imgpath+(stat[3]? (stat2[3]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyA0ext_04->setPixmap(QPixmap(imgpath+(stat[4]? (stat2[4]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyA0ext_05->setPixmap(QPixmap(imgpath+(stat[5]? (stat2[5]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyA0ext_06->setPixmap(QPixmap(imgpath+(stat[6]? (stat2[6]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyA0ext_07->setPixmap(QPixmap(imgpath+(stat[7]? (stat2[7]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyA0ext_08->setPixmap(QPixmap(imgpath+(stat[8]? (stat2[8]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyA0ext_09->setPixmap(QPixmap(imgpath+(stat[9]? (stat2[9]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyA0ext_10->setPixmap(QPixmap(imgpath+(stat[10]? (stat2[10]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyA0ext_11->setPixmap(QPixmap(imgpath+(stat[11]? (stat2[11]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyA0ext_12->setPixmap(QPixmap(imgpath+(stat[12]? (stat2[12]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyA0ext_13->setPixmap(QPixmap(imgpath+(stat[13]? (stat2[13]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyA0ext_14->setPixmap(QPixmap(imgpath+(stat[14]? (stat2[14]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyA0ext_15->setPixmap(QPixmap(imgpath+(stat[15]? (stat2[15]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+	}
+	else {
+		ui.keyA0ext_00->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyA0ext_01->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyA0ext_02->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyA0ext_03->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyA0ext_04->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyA0ext_05->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyA0ext_06->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyA0ext_07->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyA0ext_08->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyA0ext_09->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyA0ext_10->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyA0ext_11->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyA0ext_12->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyA0ext_13->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyA0ext_14->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyA0ext_15->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+	}
+	// set linac internal badge board
+	if (linacPlcStat && myReadBoolArray("Linac_key_int", stat)) {
+		ui.keyA0int_00->setPixmap(QPixmap(imgpath+(stat[0]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyA0int_01->setPixmap(QPixmap(imgpath+(stat[1]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyA0int_02->setPixmap(QPixmap(imgpath+(stat[2]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyA0int_03->setPixmap(QPixmap(imgpath+(stat[3]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyA0int_04->setPixmap(QPixmap(imgpath+(stat[4]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyA0int_05->setPixmap(QPixmap(imgpath+(stat[5]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyA0int_06->setPixmap(QPixmap(imgpath+(stat[6]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyA0int_07->setPixmap(QPixmap(imgpath+(stat[7]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyA0int_08->setPixmap(QPixmap(imgpath+(stat[8]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyA0int_09->setPixmap(QPixmap(imgpath+(stat[9]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyA0int_10->setPixmap(QPixmap(imgpath+(stat[10]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyA0int_11->setPixmap(QPixmap(imgpath+(stat[11]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyA0int_12->setPixmap(QPixmap(imgpath+(stat[12]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyA0int_13->setPixmap(QPixmap(imgpath+(stat[13]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyA0int_14->setPixmap(QPixmap(imgpath+(stat[14]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyA0int_15->setPixmap(QPixmap(imgpath+(stat[15]? "internal_key_on.png": "internal_key_off.png")));
+	}
+	else {
+		ui.keyA0int_00->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyA0int_01->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyA0int_02->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyA0int_03->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyA0int_04->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyA0int_05->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyA0int_06->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyA0int_07->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyA0int_08->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyA0int_09->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyA0int_10->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyA0int_11->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyA0int_12->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyA0int_13->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyA0int_14->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyA0int_15->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+	}
+	// set Undulator external badge board
+	if (undulatorPlcStat && myReadBoolArray("Undulator_key_ext", stat) and myReadBoolArray("Undulator_key_release", stat2)) {
+		ui.keyAsoext_00->setPixmap(QPixmap(imgpath+(stat[0]? (stat2[0]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyAsoext_01->setPixmap(QPixmap(imgpath+(stat[1]? (stat2[1]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyAsoext_02->setPixmap(QPixmap(imgpath+(stat[2]? (stat2[2]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyAsoext_03->setPixmap(QPixmap(imgpath+(stat[3]? (stat2[3]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyAsoext_04->setPixmap(QPixmap(imgpath+(stat[4]? (stat2[4]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyAsoext_05->setPixmap(QPixmap(imgpath+(stat[5]? (stat2[5]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyAsoext_06->setPixmap(QPixmap(imgpath+(stat[6]? (stat2[6]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyAsoext_07->setPixmap(QPixmap(imgpath+(stat[7]? (stat2[7]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyAsoext_08->setPixmap(QPixmap(imgpath+(stat[8]? (stat2[8]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyAsoext_09->setPixmap(QPixmap(imgpath+(stat[9]? (stat2[9]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyAsoext_10->setPixmap(QPixmap(imgpath+(stat[10]? (stat2[10]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyAsoext_11->setPixmap(QPixmap(imgpath+(stat[11]? (stat2[11]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyAsoext_12->setPixmap(QPixmap(imgpath+(stat[12]? (stat2[12]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyAsoext_13->setPixmap(QPixmap(imgpath+(stat[13]? (stat2[13]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyAsoext_14->setPixmap(QPixmap(imgpath+(stat[14]? (stat2[14]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+		ui.keyAsoext_15->setPixmap(QPixmap(imgpath+(stat[15]? (stat2[15]? "internal_key_on.png": "external_key_on.png"): "external_key_off.png")));
+	}
+	else {
+		ui.keyAsoext_00->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyAsoext_01->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyAsoext_02->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyAsoext_03->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyAsoext_04->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyAsoext_05->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyAsoext_06->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyAsoext_07->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyAsoext_08->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyAsoext_09->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyAsoext_10->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyAsoext_11->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyAsoext_12->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyAsoext_13->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyAsoext_14->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+		ui.keyAsoext_15->setPixmap(QPixmap(imgpath+("external_key_off.png")));
+	}
+	// set Undulator internal badge board
+	if (undulatorPlcStat && myReadBoolArray("Undulator_key_int", stat)) {
+		ui.keyAsoint_00->setPixmap(QPixmap(imgpath+(stat[0]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyAsoint_01->setPixmap(QPixmap(imgpath+(stat[1]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyAsoint_02->setPixmap(QPixmap(imgpath+(stat[2]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyAsoint_03->setPixmap(QPixmap(imgpath+(stat[3]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyAsoint_04->setPixmap(QPixmap(imgpath+(stat[4]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyAsoint_05->setPixmap(QPixmap(imgpath+(stat[5]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyAsoint_06->setPixmap(QPixmap(imgpath+(stat[6]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyAsoint_07->setPixmap(QPixmap(imgpath+(stat[7]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyAsoint_08->setPixmap(QPixmap(imgpath+(stat[8]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyAsoint_09->setPixmap(QPixmap(imgpath+(stat[9]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyAsoint_10->setPixmap(QPixmap(imgpath+(stat[10]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyAsoint_11->setPixmap(QPixmap(imgpath+(stat[11]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyAsoint_12->setPixmap(QPixmap(imgpath+(stat[12]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyAsoint_13->setPixmap(QPixmap(imgpath+(stat[13]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyAsoint_14->setPixmap(QPixmap(imgpath+(stat[14]? "internal_key_on.png": "internal_key_off.png")));
+		ui.keyAsoint_15->setPixmap(QPixmap(imgpath+(stat[15]? "internal_key_on.png": "internal_key_off.png")));
+	}
+	else {
+		ui.keyAsoint_00->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyAsoint_01->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyAsoint_02->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyAsoint_03->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyAsoint_04->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyAsoint_05->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyAsoint_06->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyAsoint_07->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyAsoint_08->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyAsoint_09->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyAsoint_10->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyAsoint_11->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyAsoint_12->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyAsoint_13->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyAsoint_14->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+		ui.keyAsoint_15->setPixmap(QPixmap(imgpath+("internal_key_off.png")));
+	}
+	bool free_access = false;
+	bool free_access_undulator = false;
+	// set access permission
+	if (linacPlcStat && myReadBoolArray("Linac_access_state", stat)) {
+		QPalette button;
+		const QColor color;
+		free_access = stat[10];
+		if (stat[10]) mySetTextColor(ui.A0_stat_label, "LIBERO", "#00aa00", "white");
+		if (stat[12]) mySetTextColor(ui.A0_stat_label, "CONTROLLATO", "#e0e000", "black");
+		if (stat[11]) mySetTextColor(ui.A0_stat_label, "VIETATO", "#e00000", "white");
+		ui.A0WatchButton->setIcon(QPixmap(imgpath+(stat[12]? "/watch_request.png": "/watch_request_inhibit.png")));
+	}
+	else {
+		mySetTextColor(ui.A0_stat_label, "???", "#e0e000", "black");
+	}
+	if (undulatorPlcStat && myReadBoolArray("Undulator_access_state", stat)) {
+		QPalette button;
+		const QColor color;
+		free_access_undulator = stat[10];
+		if (stat[10]) mySetTextColor(ui.Aso_stat_label, "LIBERO", "#00aa00", "white");
+		if (stat[12]) mySetTextColor(ui.Aso_stat_label, "CONTROLLATO", "#e0e000", "black");
+		if (stat[11]) mySetTextColor(ui.Aso_stat_label, "VIETATO", "#e00000", "white");
+		ui.AsoWatchButton->setIcon(QPixmap(imgpath+(stat[12]? "/watch_request.png": "/watch_request_inhibit.png")));
+	}
+	else {
+		mySetTextColor(ui.Aso_stat_label, "???", "#e0e000", "black");
+	}
+	if (undulatorPlcStat && myReadBoolArray("Undulator_access_hutch", stat)) {
+		mySetTextColor(ui.esaWatch_label, stat[12]? "ACCESSO LIBERO": "ACCESSO VIETATO", stat[12]? "#00aa00": "#e00000");
+	}
+	else {
+		mySetTextColor(ui.esaWatch_label, "???", "#e0e000", "black");
+	}
+	// set hourglass siren and radiation warning
+	if (linacPlcStat && myReadBoolArray("Linac_sir_buz", stat)) {
+		ui.A0_hourglass_label->setPixmap(QPixmap(imgpath+(stat[1]? "hourglass.png": "")));
+		ui.A0_radiation_label->setPixmap(QPixmap(imgpath+(stat[2] || stat[3]? "radiation.png": "")));
+		ui.A0_siren_label->setPixmap(QPixmap(imgpath+(!stat[10]? "siren.png": "siren_on.png")));
+	}
+	else {
+		ui.A0_hourglass_label->setPixmap(QPixmap(imgpath+""));
+		ui.A0_radiation_label->setPixmap(QPixmap(imgpath+""));
+		ui.A0_siren_label->setPixmap(QPixmap(imgpath+"siren.png"));
+	}
+	// set hourglass siren and radiation warning
+	if (linacPlcStat && myReadBoolArray("Undulator_sir_buz", stat)) {
+		ui.Aso_hourglass_label->setPixmap(QPixmap(imgpath+(stat[2]? "hourglass.png": "")));
+		ui.Aso_radiation_label->setPixmap(QPixmap(imgpath+(stat[3]? "radiation.png": "")));
+		ui.Aso_siren_label->setPixmap(QPixmap(imgpath+(!stat[10]? "siren.png": "siren_on.png")));
+	}
+	else {
+		ui.Aso_hourglass_label->setPixmap(QPixmap(imgpath+""));
+		ui.Aso_radiation_label->setPixmap(QPixmap(imgpath+""));
+		ui.Aso_siren_label->setPixmap(QPixmap(imgpath+"siren.png"));
+	}
+// ui.Aso_radiation_label->setPixmap(QPixmap(imgpath+"radiation.png"));
+	if (undulatorPlcStat && myReadBoolArray("Undulator_sir_buz", stat)) {
+		// ui.Aso_radiation_label->setPixmap(QPixmap(imgpath+(stat[2] || stat[3]? "radiation.png": "")));
+		ui.ESA1_siren_label->setPixmap(QPixmap(imgpath+(!stat[11]? "siren.png": "siren_on.png")));
+		ui.ESA2_siren_label->setPixmap(QPixmap(imgpath+(!stat[12]? "siren.png": "siren_on.png")));
+		// mySetTextColor(ui.siren_esa1, stat[11]? (refreshCount? "ALLARME ON": " "): "ALLARME OFF", stat[11]? "#e00000": "#00aa00");
+		// mySetTextColor(ui.siren_esa2, stat[12]? (refreshCount? "ALLARME ON": " "): "ALLARME OFF", stat[12]? "#e00000": "#00aa00");
+	}
+	else {
+		// ui.Aso_radiation_label->setPixmap(QPixmap(imgpath+""));
+		// mySetTextColor(ui.siren_esa1, "???", "black");
+		// mySetTextColor(ui.siren_esa2, "???", "black");
+	}
+	// set input process and presence
+	if (linacPlcStat && myReadBoolArray("Linac_glob_signals", stat)) {
+		ui.A0PresenceButton->setIcon(QPixmap(imgpath+((refreshCount && (!stat[1]))? "listred.png": "list.png")));
+		ui.consentA0_2->setPixmap(QPixmap(imgpath+(!stat[7]? "permission_on.png": "permission_off.png")));
+	}
+	else {
+		ui.A0PresenceButton->setIcon(QPixmap(imgpath+"list.png"));
+		ui.consentA0_2->setPixmap(QPixmap(imgpath+"permission_off.png"));
+	}
+	if (undulatorPlcStat && myReadBoolArray("Undulator_glob_signals", stat)) {
+		ui.AsoPresenceButton->setIcon(QPixmap(imgpath+((refreshCount && (!stat[1]))? "listred.png": "list.png")));
+		ui.consentAso_2->setPixmap(QPixmap(imgpath+(!stat[7]? "permission_on.png": "permission_off.png")));
+	}
+	else {
+		ui.AsoPresenceButton->setIcon(QPixmap(imgpath+"list.png"));
+		ui.consentAso_2->setPixmap(QPixmap(imgpath+"permission_off.png"));
+	}
+	strcpy(url, "http://xyzfcsproxy.elettra.eu/docs/pss/register_alarm.php?user_inside=");
+	web_read(url, linac_strstat.c_str());
+	// set badge acknowledge
+	if (linacPlcStat && myReadString("Linac_badge_ack", strstat)) {
+		ui.userNameA0Label->setText(strstat.c_str());
+		if (linac_strstat != strstat) {
+			// cout << strstat.c_str() << ", old: " << linac_strstat.c_str() << ", len: "<< strlen(strstat.c_str()) << endl;
+			linac_strstat = strstat;
+			for (unsigned i=0; i<strstat.length(); i++) {
+				if (strstat[i] != ' ') {
+					strcpy(url, "http://fcsproxy.elettra.eu/docs/pss/register_alarm.php?user_inside=");
+					web_read(url, strstat.c_str());
+					break;
+				}
+			}
+		}
+	}
+	else {
+		ui.userNameA0Label->setText("???");
+	}
+	if (undulatorPlcStat && myReadString("Undulator_badge_ack", strstat)) {
+		ui.userNameAsoLabel->setText(strstat.c_str());
+		if (uh_strstat != strstat) {
+			uh_strstat = strstat;
+			for (unsigned i=0; i<strstat.length(); i++) {
+				if (strstat[i] != ' ') {
+					cout << strstat.c_str() << ", len: "<< strlen(strstat.c_str()) << endl;
+					strcpy(url, "http://fcsproxy.elettra.eu/docs/pss/register_alarm.php?user_inside=");
+					web_read(url, strstat.c_str());
+					break;
+				}
+			}
+		}
+	}
+	else {
+		ui.userNameAsoLabel->setText("???");
+	}
+	/*
+	// is restore necessary
+	if (myReadAttribute("Linac_access_signals")) {
+		myAttribute >> stat;
+	}
+	*/
+	bool e0, e1, e2, e3, e4, e5, e6, e7, etl, eso, el;
+	bool eh0, eh1, eh2, eh3, eh4, eh5, eh6, eh7, ehtl, ehso, ehl;
+	bool en0, en1, en2, en3, en4, en5, en6, en7, entl, enso, enl;
+	en0=en1=en2=en3=en4=en5=en6=en7=entl=enso=enl=true;
+	e0=e1=e2=e3=e4=e5=e6=e7=etl=eso=el=true;
+	eh0=eh1=eh2=eh3=eh4=eh5=eh6=eh7=ehtl=ehso=ehl=true;
+	// set escape doors e0
+	if (linacPlcStat && myReadBoolArray("Linac_doors_e0", stat) && myReadBoolArray("Linac_doors_memoopen_e0", stat2)) {
+		/*
+		ui.e0_1_label->setIcon(QPixmap(imgpath+(!stat[0]? "/e0_1_label_red.png": (stat2[0]? "/e0_1_label_yellow.png": "/e0_1_label_white.png"))));
+		ui.e0_1_door->setIcon(QPixmap(imgpath+(!stat[0]? "/e0_1_door_open.png": "/e0_1_door_close.png")));
+		ui.e0_2->setIcon(QPixmap(imgpath+(!stat[1]? "/e0_2_red.png": (stat2[1]? "/e0_2_yellow.png": "/e0_2_white.png"))));
+		ui.i1_e0->setIcon(QPixmap(imgpath+(!stat[2]? "/i1_e0_red.png": (stat2[2]? "/i1_e0_yellow.png": "/i1_e0_white.png"))));
+		ui.i2_e0->setIcon(QPixmap(imgpath+(!stat[3]? "/i2_e0_red.png": (stat2[3]? "/i2_e0_yellow.png": "/i2_e0_white.png"))));
+		*/
+		e0 = !stat[0] || !stat[1] || !stat[2] || !stat[3];
+		eh0 = stat2[0] || stat2[1] || stat2[2] || stat2[3];
+		ui.e0DoorButton->setIcon(QPixmap(imgpath+(e0? "door_small_open.png": (eh0? "door_small_hold.png": "door_small_close.png"))));
+		el = !stat[0];
+		ehl = stat2[0];
+	}
+	else {
+		ui.e0DoorButton->setIcon(QPixmap(imgpath+"door_small_unknown.png"));
+		en0 = false;
+	}
+	// set escape doors e1
+	if (linacPlcStat && myReadBoolArray("Linac_doors_e1", stat) && myReadBoolArray("Linac_doors_memoopen_e1", stat2)) {
+		e1 = !stat[0] || !stat[1] || !stat[2] || !stat[3];
+		eh1 = stat2[0] || stat2[1] || stat2[2] || stat2[3];
+		ui.e1DoorButton->setIcon(QPixmap(imgpath+(e1? "door_small_open.png": (eh1? "door_small_hold.png": "door_small_close.png"))));
+		el = el || !stat[0];
+		ehl = ehl || stat2[0];
+	}
+	else {
+		ui.e1DoorButton->setIcon(QPixmap(imgpath+"door_small_unknown.png"));
+		en1 = false;
+	}
+	// set escape doors e2
+	if (linacPlcStat && myReadBoolArray("Linac_doors_e2", stat) && myReadBoolArray("Linac_doors_memoopen_e2", stat2)) {
+		e2 = !stat[0] || !stat[1] || !stat[2] || !stat[3];
+		eh2 = stat2[0] || stat2[1] || stat2[2] || stat2[3];
+		ui.e2DoorButton->setIcon(QPixmap(imgpath+(e2? "door_small_open.png": (eh2? "door_small_hold.png": "door_small_close.png"))));
+		el = el || !stat[0];
+		ehl = ehl || stat2[0];
+	}
+	else {
+		ui.e2DoorButton->setIcon(QPixmap(imgpath+"door_small_unknown.png"));
+		en2 = false;
+	}
+	// set escape doors e3
+	if (linacPlcStat && myReadBoolArray("Linac_doors_e3", stat) && myReadBoolArray("Linac_doors_memoopen_e3", stat2)) {
+		e3 = !stat[0] || !stat[1] || !stat[4];
+		eh3 = stat2[0] || stat2[1] || stat2[4];
+		ui.e3DoorButton->setIcon(QPixmap(imgpath+(e3? "door_small_open.png": (eh3? "door_small_hold.png": "door_small_close.png"))));
+		el = el || !stat[0] || !stat[2] || !stat[3];
+		ehl = ehl || stat2[0] || stat2[2] || stat2[3];
+	}
+	else {
+		ui.e3DoorButton->setIcon(QPixmap(imgpath+"door_small_unknown.png"));
+		en3 = false;
+	}
+	// set escape doors transfer line
+	if (linacPlcStat && myReadBoolArray("Linac_doors_tl", stat) && myReadBoolArray("Linac_doors_memoopen_tl", stat2)) {
+		etl = !stat[0] || !stat[1];
+		ehtl = stat2[0] || stat2[1];
+		ui.tlDoorButton->setIcon(QPixmap(imgpath+(etl? "door_small_open.png": (ehtl? "door_small_hold.png": "door_small_close.png"))));
+		el = el || !stat[0];
+		ehl = ehl || stat2[0];
+	}
+	else {
+		ui.tlDoorButton->setIcon(QPixmap(imgpath+"door_small_unknown.png"));
+		entl = false;
+	}
+	// set escape doors l
+	if (linacPlcStat && myReadBoolArray("Linac_doors_l", stat) && myReadBoolArray("Linac_doors_memoopen_l", stat2)) {
+		ui.doorLinac_qLabel->setPixmap(QPixmap(imgpath+(!stat[0]? "door_big_open.png": "door_big_close.png")));
+		// ui.alinac->setIcon(QPixmap(imgpath+(!stat[0]? "alinac_red.png": (stat2[0]? "alinac_yellow.png": "alinac_white.png"))));
+		// ui.pr->setIcon(QPixmap(imgpath+(!stat[1]? "pr_red.png": (stat2[1]? "pr_yellow.png": "pr_white.png"))));
+		el = el || !stat[0] || !stat[1] || !stat[2];
+		ehl = ehl || stat2[0] || stat2[1] || stat2[2];
+		ui.linacDoorButton->setIcon(QPixmap(imgpath+(el? "door_small_open.png": (ehl? "door_small_hold.png": "door_small_close.png"))));
+	}
+	else {
+		ui.doorLinac_qLabel->setPixmap(QPixmap(imgpath+"door_big_unknown.png"));
+		ui.linacDoorButton->setIcon(QPixmap(imgpath+"door_small_unknown.png"));
+		enl = false;
+	}
+	// set escape doors global for Linac
+	if (linacPlcStat && myReadBoolArray("Linac_doors_ext", stat) && myReadBoolArray("Linac_doors_memoopen_ext", stat2) && en0 && en1 && en2 && en3 && entl && enl) {
+		bool eg = !stat[0] || !stat[1] || !stat[2] || el;
+		bool ehg = stat2[0] || stat2[1] || stat2[2] || ehl;
+		ui.linacDoorButton->setIcon(QPixmap(imgpath+(eg? "door_small_open.png": (ehg? "door_small_hold.png": "door_small_close.png"))));
+		// ui.i3_e0->setIcon(QPixmap(imgpath+(!stat[2]? "i3_e0_red.png": (stat2[2]? "i3_e0_yellow.png": "i3_e0_white.png"))));
+	}
+	else {
+		ui.linacDoorButton->setIcon(QPixmap(imgpath+"door_small_unknown.png"));
+	}
+
+	el = ehl = false;
+	// set escape doors e4
+	if (undulatorPlcStat && myReadBoolArray("Undulator_doors_e4", stat) && myReadBoolArray("Undulator_doors_memoopen_e4", stat2)) {
+		e4 = !stat[0] || !stat[1];
+		eh4 = stat2[0] || stat2[1];
+		ui.e4DoorButton->setIcon(QPixmap(imgpath+(e4? "door_small_open.png": (eh4? "door_small_hold.png": "door_small_close.png"))));
+		el = el || !stat[0] || !stat[2] || !stat[3];
+		ehl = ehl || stat2[0] || stat2[2] || stat2[3];
+	}
+	else {
+		ui.e4DoorButton->setIcon(QPixmap(imgpath+"door_small_unknown.png"));
+		en4 = false;
+	}
+	// set escape doors e5
+	if (undulatorPlcStat && myReadBoolArray("Undulator_doors_e5", stat) && myReadBoolArray("Undulator_doors_memoopen_e5", stat2)) {
+		e5 = !stat[0] || !stat[1];
+		eh5 = stat2[0] || stat2[1];
+		ui.e5DoorButton->setIcon(QPixmap(imgpath+(e5? "door_small_open.png": (eh5? "door_small_hold.png": "door_small_close.png"))));
+		el = el || !stat[0] || !stat[2] || !stat[3];
+		ehl = ehl || stat2[0] || stat2[2] || stat2[3];
+	}
+	else {
+		ui.e5DoorButton->setIcon(QPixmap(imgpath+"door_small_unknown.png"));
+		en5 = false;
+	}
+	// set escape doors e6
+	if (undulatorPlcStat && myReadBoolArray("Undulator_doors_e6", stat) && myReadBoolArray("Undulator_doors_memoopen_e6", stat2)) {
+		e6 = !stat[0] || !stat[1];
+		eh6 = stat2[0] || stat2[1];
+		ui.e6DoorButton->setIcon(QPixmap(imgpath+(e6? "door_small_open.png": (eh6? "door_small_hold.png": "door_small_close.png"))));
+		el = el || !stat[0] || !stat[2] || !stat[3];
+		ehl = ehl || stat2[0] || stat2[2] || stat2[3];
+	}
+	else {
+		ui.e6DoorButton->setIcon(QPixmap(imgpath+"door_small_unknown.png"));
+		en6 = false;
+	}
+	// set escape doors e7
+	if (undulatorPlcStat && myReadBoolArray("Undulator_doors_e7", stat) && myReadBoolArray("Undulator_doors_memoopen_e7", stat2)) {
+		e7 = !stat[0] || !stat[1];
+		eh7 = stat2[0] || stat2[1];
+		ui.e7DoorButton->setIcon(QPixmap(imgpath+(e7? "door_small_open.png": (eh7? "door_small_hold.png": "door_small_close.png"))));
+		el = el || !stat[0] || !stat[2];
+		ehl = ehl || stat2[0] || stat2[2];
+	}
+	else {
+		ui.e7DoorButton->setIcon(QPixmap(imgpath+"door_small_unknown.png"));
+		en7 = false;
+	}
+	// set escape doors undulator hall
+	if (undulatorPlcStat && myReadBoolArray("Undulator_doors_so", stat) && myReadBoolArray("Undulator_doors_memoopen_so", stat2)) {
+		ui.doorSo_qLabel->setPixmap(QPixmap(imgpath+(!stat[0]? "door_big_open.png": "door_big_close.png")));
+		eso = el || !stat[0] || !stat[1] || !stat[2];
+		ehso = ehl || stat2[0] || stat2[1] || stat2[2];
+		ui.soDoorButton->setIcon(QPixmap(imgpath+(eso? "door_small_open.png": (ehso? "door_small_hold.png": "door_small_close.png"))));
+	}
+	else {
+		ui.doorSo_qLabel->setPixmap(QPixmap(imgpath+"door_big_unknown.png"));
+		ui.soDoorButton->setIcon(QPixmap(imgpath+"door_small_unknown.png"));
+		enso = false;
+	}
+	// set escape doors esa1
+	if (undulatorPlcStat && myReadBoolArray("Undulator_doors_esa", stat) && myReadBoolArray("Undulator_doors_memoopen_esa", stat2)) {
+		ui.esa1DoorButton->setIcon(QPixmap(imgpath+(!stat[0]? "door_small_open.png": (stat2[0]? "door_small_hold.png": "door_small_close.png"))));
+		ui.esa2DoorButton->setIcon(QPixmap(imgpath+(!stat[1]? "door_small_open.png": (stat2[1]? "door_small_hold.png": "door_small_close.png"))));
+	}
+	else {
+		ui.esa1DoorButton->setIcon(QPixmap(imgpath+"door_small_unknown.png"));
+		ui.esa2DoorButton->setIcon(QPixmap(imgpath+"door_small_unknown.png"));
+	}
+
+	// set beam stoppers
+	if (linacPlcStat && myReadBoolArray("Linac_bst_1", stat)) {
+		ui.bst_linacButton->setIcon(QPixmap(imgpath+((stat[0] && !stat[1])? "bst_open.png": ((stat[1] && !stat[0])? "bst_close.png": (stat[2] || stat[3] || !stat[11]? "bst_alarm.png": "bst_unknown.png")))));
+		mySetTextColor(ui.bst_linac_Stat_label, (stat[4]? "   abilitato": "disabilitato"), (stat[4]? "#00aa00": "#e00000"));
+		ui.bst_linac_OpenCmd_Button->setIcon(QPixmap(imgpath+((!stat[0] && stat[4])? "open_cmd.png": "open_cmd_hinibit.png")));
+		// ui.bst_linac_CloseCmd_Button->setIcon(QPixmap(imgpath+(!stat[1]? "close_cmd.png": "close_cmd_red.png")));
+		ui.bst_linac_OpenStat_qLabel->setPixmap(QPixmap(imgpath+(stat[0]? "open_on.png": "open_off.png")));
+		ui.bst_linac_CloseStat_qLabel->setPixmap(QPixmap(imgpath+(stat[1]? "close_on.png": "close_off.png")));
+		ui.bst_linacpress->setPixmap(QPixmap(imgpath+((stat[11] || !refreshCount)? "/pressure_white.png": "/pressure_red.png")));
+		ui.bst_linacpress->setToolTip(stat[11]? " aria compressa OK": " aria compressa FAULT");
+	}
+	else {
+		ui.bst_linacButton->setIcon(QPixmap(imgpath+("bst_unknown.png")));
+		mySetTextColor(ui.bst_linac_Stat_label, "???", "#aaaaaa");
+		ui.bst_linac_OpenCmd_Button->setIcon(QPixmap(imgpath+"open_cmd_hinibit.png"));
+		ui.bst_linacpress->setPixmap(QPixmap(imgpath+"/pressure_unknown.png"));
+		ui.bst_linacpress->setToolTip(" aria compressa ???");
+	}
+	if (undulatorPlcStat && myReadBoolArray("Undulator_bst1_fel1", stat)) {
+		ui.bst1_fel1Button->setIcon(QPixmap(imgpath+((stat[0] && !stat[1])? "bst_open.png": ((stat[1] && !stat[0])? "bst_close.png": (stat[2] || stat[3]? "bst_alarm.png": "bst_unknown.png")))));
+		mySetTextColor(ui.bst1_fel1_Stat_label, (stat[4]? "   abilitato": "disabilitato"), (stat[4]? "#00aa00": "#e00000"));
+		ui.bst1_fel1_OpenCmd_Button->setIcon(QPixmap(imgpath+((stat[7] && stat[4])? "open_cmd.png": "open_cmd_hinibit.png")));
+		ui.bst1_fel1_OpenStat_qLabel->setPixmap(QPixmap(imgpath+(stat[0]? "open_on.png": "open_off.png")));
+		ui.bst1_fel1_CloseStat_qLabel->setPixmap(QPixmap(imgpath+(stat[1]? "close_on.png": "close_off.png")));
+		ui.bst1_fel1press->setPixmap(QPixmap(imgpath+((stat[11] || !refreshCount)? "/pressure_white.png": "/pressure_red.png")));
+		ui.bst2_fel1press->setPixmap(QPixmap(imgpath+((stat[11] || !refreshCount)? "/pressure_white.png": "/pressure_red.png")));
+		ui.bst1_fel1press->setToolTip(stat[11]? " aria compressa OK": " aria compressa FAULT");
+		ui.bst2_fel1press->setToolTip(stat[11]? " aria compressa OK": " aria compressa FAULT");
+	}
+	else {
+		ui.bst1_fel1Button->setIcon(QPixmap(imgpath+("bst_unknown.png")));
+		mySetTextColor(ui.bst1_fel1_Stat_label, "???", "#aaaaaa");
+		ui.bst1_fel1_OpenCmd_Button->setIcon(QPixmap(imgpath+"open_cmd_hinibit.png"));
+		ui.bst1_fel1press->setPixmap(QPixmap(imgpath+"/pressure_unknown.png"));
+		ui.bst2_fel1press->setPixmap(QPixmap(imgpath+"/pressure_unknown.png"));
+		ui.bst1_fel1press->setToolTip(" aria compressa ???");
+		ui.bst2_fel1press->setToolTip(" aria compressa ???");
+	}
+	if (undulatorPlcStat && myReadBoolArray("Undulator_bst2_fel1", stat)) {
+		ui.bst2_fel1Button->setIcon(QPixmap(imgpath+((stat[0] && !stat[1])? "bst_open.png": ((stat[1] && !stat[0])? "bst_close.png": (stat[2] || stat[3]? "bst_alarm.png": "bst_unknown.png")))));
+		mySetTextColor(ui.bst2_fel1_Stat_label, (stat[4]? "   abilitato": "disabilitato"), (stat[4]? "#00aa00": "#e00000"));
+		ui.bst2_fel1_OpenCmd_Button->setIcon(QPixmap(imgpath+((stat[7] && stat[4])? "open_cmd.png": "open_cmd_hinibit.png")));
+		ui.bst2_fel1_OpenStat_qLabel->setPixmap(QPixmap(imgpath+(stat[0]? "open_on.png": "open_off.png")));
+		ui.bst2_fel1_CloseStat_qLabel->setPixmap(QPixmap(imgpath+(stat[1]? "close_on.png": "close_off.png")));
+	}
+	else {
+		ui.bst2_fel1Button->setIcon(QPixmap(imgpath+("bst_unknown.png")));
+		mySetTextColor(ui.bst2_fel1_Stat_label, "???", "#aaaaaa");
+		ui.bst2_fel1_OpenCmd_Button->setIcon(QPixmap(imgpath+"open_cmd_hinibit.png"));
+	}
+	if (undulatorPlcStat && myReadBoolArray("Undulator_bst1_fel2", stat)) {
+		ui.bst1_fel2Button->setIcon(QPixmap(imgpath+((stat[0] && !stat[1])? "bst_open.png": ((stat[1] && !stat[0])? "bst_close.png": (stat[2] || stat[3]? "bst_alarm.png": "bst_unknown.png")))));
+		mySetTextColor(ui.bst1_fel2_Stat_label, (stat[4]? "   abilitato": "disabilitato"), (stat[4]? "#00aa00": "#e00000"));
+		ui.bst1_fel2_OpenCmd_Button->setIcon(QPixmap(imgpath+((stat[7] && stat[4])? "open_cmd.png": "open_cmd_hinibit.png")));
+		ui.bst1_fel2_OpenStat_qLabel->setPixmap(QPixmap(imgpath+(stat[0]? "open_on.png": "open_off.png")));
+		ui.bst1_fel2_CloseStat_qLabel->setPixmap(QPixmap(imgpath+(stat[1]? "close_on.png": "close_off.png")));
+		ui.bst1_fel2press->setPixmap(QPixmap(imgpath+((stat[11] || !refreshCount)? "/pressure_white.png": "/pressure_red.png")));
+		ui.bst2_fel2press->setPixmap(QPixmap(imgpath+((stat[11] || !refreshCount)? "/pressure_white.png": "/pressure_red.png")));
+		ui.bst1_fel2press->setToolTip(stat[11]? " aria compressa OK": " aria compressa FAULT");
+		ui.bst2_fel2press->setToolTip(stat[11]? " aria compressa OK": " aria compressa FAULT");
+	}
+	else {
+		ui.bst1_fel2Button->setIcon(QPixmap(imgpath+("bst_unknown.png")));
+		mySetTextColor(ui.bst1_fel2_Stat_label, "???", "#aaaaaa");
+		ui.bst1_fel2_OpenCmd_Button->setIcon(QPixmap(imgpath+"open_cmd_hinibit.png"));
+		ui.bst1_fel2press->setPixmap(QPixmap(imgpath+"/pressure_unknown.png"));
+		ui.bst2_fel2press->setPixmap(QPixmap(imgpath+"/pressure_unknown.png"));
+		ui.bst1_fel2press->setToolTip(" aria compressa ???");
+		ui.bst2_fel2press->setToolTip(" aria compressa ???");
+	}
+	if (undulatorPlcStat && myReadBoolArray("Undulator_bst2_fel2", stat)) {
+		ui.bst2_fel2Button->setIcon(QPixmap(imgpath+((stat[0] && !stat[1])? "bst_open.png": ((stat[1] && !stat[0])? "bst_close.png": (stat[2] || stat[3]? "bst_alarm.png": "bst_unknown.png")))));
+		mySetTextColor(ui.bst2_fel2_Stat_label, (stat[4]? "   abilitato": "disabilitato"), (stat[4]? "#00aa00": "#e00000"));
+		ui.bst2_fel2_OpenCmd_Button->setIcon(QPixmap(imgpath+((stat[7] && stat[4])? "open_cmd.png": "open_cmd_hinibit.png")));
+		ui.bst2_fel2_OpenStat_qLabel->setPixmap(QPixmap(imgpath+(stat[0]? "open_on.png": "open_off.png")));
+		ui.bst2_fel2_CloseStat_qLabel->setPixmap(QPixmap(imgpath+(stat[1]? "close_on.png": "close_off.png")));
+	}
+	else {
+		ui.bst2_fel2Button->setIcon(QPixmap(imgpath+("bst_unknown.png")));
+		mySetTextColor(ui.bst2_fel2_Stat_label, "???", "#aaaaaa");
+		ui.bst2_fel2_OpenCmd_Button->setIcon(QPixmap(imgpath+"open_cmd_hinibit.png"));
+	}
+	if (undulatorPlcStat && myReadBoolArray("Undulator_bst_diag", stat)) {
+		ui.bst_diagButton->setIcon(QPixmap(imgpath+((stat[0] && !stat[1])? "bst_open.png": ((stat[1] && !stat[0])? "bst_close.png": (stat[2] || stat[3]? "bst_alarm.png": "bst_unknown.png")))));
+		mySetTextColor(ui.bst_diag_Stat_label, (stat[4]? "   abilitato": "disabilitato"), (stat[4]? "#00aa00": "#e00000"));
+		ui.bst_diag_OpenCmd_Button->setIcon(QPixmap(imgpath+((stat[7] && stat[4])? "open_cmd.png": "open_cmd_hinibit.png")));
+		ui.bst_diag_OpenStat_qLabel->setPixmap(QPixmap(imgpath+(stat[0]? "open_on.png": "open_off.png")));
+		ui.bst_diag_CloseStat_qLabel->setPixmap(QPixmap(imgpath+(stat[1]? "close_on.png": "close_off.png")));
+		// ui.bst1_blpress->setPixmap(QPixmap(imgpath+((stat[11] || !refreshCount)? "/pressure_white.png": "/pressure_red.png")));
+	}
+	else {
+		ui.bst_diagButton->setIcon(QPixmap(imgpath+("bst_unknown.png")));
+		mySetTextColor(ui.bst_diag_Stat_label, "???", "#aaaaaa");
+		ui.bst_diag_OpenCmd_Button->setIcon(QPixmap(imgpath+"open_cmd_hinibit.png"));
+		ui.bst1_blpress->setPixmap(QPixmap(imgpath+"pressure_white.png"));
+	}
+
+	// search status
+	if (linacPlcStat && myReadBoolArray("Linac_search_signals_l", stat)) {
+		// todo check watch_ini stat[2]?
+		mySetTextColor(ui.tunnelWatch_label, (stat[0]? "RONDA OK": (refreshCount? (stat[6]? "RONDA IN CORSO": "RONDA PENDENTE"): "")), (stat[0]? "#00a000": (stat[6]? "#e08000": "#e00000")));
+	}
+	else {
+		mySetTextColor(ui.tunnelWatch_label, "???", "#000000");
+	}
+	if (linacPlcStat && myReadBoolArray("Linac_search_signals_e0", stat)) {
+		mySetTextColor(ui.e0Watch_label, (stat[0]? "RONDA OK": (refreshCount? (stat[4]? "RONDA IN CORSO": "RONDA PENDENTE"): "")), (stat[0]? "#00a000": (stat[4]? "#e08000": "#e00000")));
+	}
+	else {
+		mySetTextColor(ui.e0Watch_label, "???", "#000000");
+	}
+	if (linacPlcStat && myReadBoolArray("Linac_search_signals_e1", stat)) {
+		mySetTextColor(ui.e1Watch_label, (stat[0]? "RONDA OK": (refreshCount? (stat[5]? "RONDA IN CORSO": "RONDA PENDENTE"): "")), (stat[0]? "#00a000": (stat[5]? "#e08000": "#e00000")));
+	}
+	else {
+		mySetTextColor(ui.e1Watch_label, "???", "#000000");
+	}
+	if (linacPlcStat && myReadBoolArray("Linac_search_signals_e2", stat)) {
+		mySetTextColor(ui.e2Watch_label, (stat[0]? "RONDA OK": (refreshCount? (stat[5]? "RONDA IN CORSO": "RONDA PENDENTE"): "")), (stat[0]? "#00a000": (stat[5]? "#e08000": "#e00000")));
+	}
+	else {
+		mySetTextColor(ui.e2Watch_label, "???", "#000000");
+	}
+	if (linacPlcStat && myReadBoolArray("Linac_search_signals_e3", stat)) {
+		mySetTextColor(ui.e3Watch_label, (stat[0]? "RONDA OK": (refreshCount? (stat[5]? "RONDA IN CORSO": "RONDA PENDENTE"): "")), (stat[0]? "#00a000": (stat[5]? "#e08000": "#e00000")));
+	}
+	else {
+		mySetTextColor(ui.e3Watch_label, "???", "#000000");
+	}
+	if (linacPlcStat && myReadBoolArray("Linac_search_signals_tl", stat)) {
+		mySetTextColor(ui.tlWatch_label, (stat[0]? "RONDA OK": (refreshCount? (stat[2]? "RONDA IN CORSO": "RONDA PENDENTE"): "")), (stat[0]? "#00a000": (stat[2]? "#e08000": "#e00000")));
+	}
+	else {
+		mySetTextColor(ui.tlWatch_label, "???", "#000000");
+	}
+	if (undulatorPlcStat && myReadBoolArray("Undulator_search_signals_e4", stat)) {
+		mySetTextColor(ui.e4Watch_label, (stat[0]? "RONDA OK": (refreshCount? (stat[4]? "RONDA IN CORSO": "RONDA PENDENTE"): "")), (stat[0]? "#00a000": (stat[4]? "#e08000": "#e00000")));
+	}
+	else {
+		mySetTextColor(ui.e4Watch_label, "???", "#000000");
+	}
+	if (undulatorPlcStat && myReadBoolArray("Undulator_search_signals_e5", stat)) {
+		mySetTextColor(ui.e5Watch_label, (stat[0]? "RONDA OK": (refreshCount? (stat[5]? "RONDA IN CORSO": "RONDA PENDENTE"): "")), (stat[0]? "#00a000": (stat[5]? "#e08000": "#e00000")));
+	}
+	else {
+		mySetTextColor(ui.e5Watch_label, "???", "#000000");
+	}
+	if (undulatorPlcStat && myReadBoolArray("Undulator_search_signals_e6", stat)) {
+		mySetTextColor(ui.e6Watch_label, (stat[0]? "RONDA OK": (refreshCount? (stat[5]? "RONDA IN CORSO": "RONDA PENDENTE"): "")), (stat[0]? "#00a000": (stat[5]? "#e08000": "#e00000")));
+	}
+	else {
+		mySetTextColor(ui.e6Watch_label, "???", "#000000");
+	}
+	if (undulatorPlcStat && myReadBoolArray("Undulator_search_signals_e7", stat)) {
+		mySetTextColor(ui.e7Watch_label, (stat[0]? "RONDA OK": (refreshCount? (stat[5]? "RONDA IN CORSO": "RONDA PENDENTE"): "")), (stat[0]? "#00a000": (stat[5]? "#e08000": "#e00000")));
+	}
+	else {
+		mySetTextColor(ui.e7Watch_label, "???", "#000000");
+	}
+	if (undulatorPlcStat && myReadBoolArray("Undulator_search_signals_so", stat)) {
+		mySetTextColor(ui.soWatch_label, (stat[0]? "RONDA OK": (refreshCount? (stat[6]? "RONDA IN CORSO": "RONDA PENDENTE"): "")), (stat[0]? "#00a000": (stat[6]? "#e08000": "#e00000")));
+	}
+	else {
+		mySetTextColor(ui.soWatch_label, "???", "#000000");
+	}
+	if (undulatorPlcStat && myReadBoolArray("Undulator_search_signals_esa1", stat)) {
+		mySetTextColor(ui.esa1Watch_label, (stat[10]? "RONDA OK": (refreshCount? (stat[11]? "RONDA IN CORSO": "RONDA PENDENTE"): "")), (stat[10]? "#00a000": (stat[11]? "#e08000": "#e00000")));
+	}
+	else {
+		mySetTextColor(ui.esa1Watch_label, "???", "#000000");
+	}
+	if (undulatorPlcStat && myReadBoolArray("Undulator_search_signals_esa2", stat)) {
+		mySetTextColor(ui.esa2Watch_label, (stat[10]? "RONDA OK": (refreshCount? (stat[11]? "RONDA IN CORSO": "RONDA PENDENTE"): "")), (stat[10]? "#00a000": (stat[11]? "#e08000": "#e00000")));
+	}
+	else {
+		mySetTextColor(ui.esa2Watch_label, "???", "#000000");
+	}
+	ui.frame_3->stackUnder(ui.title_bst);
+	// hardware button summary
+	if (linacPlcStat && myReadBoolArray("Linac_boards_disabled", stat) && undulatorPlcStat && myReadBoolArray("Undulator_boards_disabled", stat2)) {
+		bool enab = false;
+		for (unsigned int i=0; i<stat.size(); i++) {
+			enab = enab || stat[i];
+		}
+		for (unsigned int i=0; i<stat2.size(); i++) {
+			enab = enab || stat2[i];
+		}
+		ui.hardwareButton->setIcon(QPixmap(imgpath+(enab && refreshCount? "hardware_alarm.png": "hardware.png")));
+	}
+	else {
+		ui.hardwareButton->setIcon(QPixmap(imgpath+(refreshCount? "hardware_alarm.png": "hardware.png")));
+	}
+	// set linac input process
+	if (linacPlcStat && myReadBoolArray("Linac_access_signals", stat)) {
+		ui.consentA0_0->setPixmap(QPixmap(imgpath+(stat[8] || free_access? "permission_on.png": "permission_off.png")));
+		ui.consentA0_1->setPixmap(QPixmap(imgpath+(stat[9] || stat[10] || stat[11] || free_access? "permission_on.png": "permission_off.png")));
+		ui.A0OpenButton->setIcon(QPixmap(imgpath+(stat[9]? "open.png": "open_hinibit.png")));
+		ui.A0RestoreButton->setIcon(QPixmap(imgpath+(stat[35]? "restore.png": "restore_hinibit.png")));
+		// check if A_Linac in operation is running
+		if (stat[8]) {
+			mySetTextColor(ui.A0_access_label, refreshCount? "INGRESSO IN CORSO": "", "#e0e000", "#0000e0");
+			if (stat[28]) ui.messageA0Label->setText("Premi ripristino (timeout estrazione testimone in ingresso)");
+			if (stat[29]) ui.messageA0Label->setText("Premi ripristino (timeout sblocco porta in ingresso)");
+			if (stat[30]) ui.messageA0Label->setText("Premi ripristino (timeout apertura porta in ingresso)");
+			if (stat[31]) ui.messageA0Label->setText("Premi ripristino (timeout chiusura porta in ingresso)");
+			if (stat[32]) ui.messageA0Label->setText("Premi ripristino (timeout deposito testimone in ingresso)");
+		}
+		// check if A_Linac out operation is running
+		else if (stat[16]) {
+			mySetTextColor(ui.A0_access_label, refreshCount? "USCITA IN CORSO": "", "#e0e000", "#0000e0");
+			if (stat[28]) ui.messageA0Label->setText("Premi ripristino (timeout deposito testimone in uscita)");
+			if (stat[29]) ui.messageA0Label->setText("Premi ripristino (timeout sblocco porta in uscita)");
+			if (stat[30]) ui.messageA0Label->setText("Premi ripristino (timeout apertura porta in uscita)");
+			if (stat[31]) ui.messageA0Label->setText("Premi ripristino (timeout chiusura porta in uscita)");
+			if (stat[32]) ui.messageA0Label->setText("Premi ripristino (timeout lettura badge in uscita)");
+		}
+		else {
+			mySetTextColor(ui.A0_access_label, "", "#e0e000", "white");
+			ui.messageA0Label->setText("");
+		}
+	}
+	else {
+		mySetTextColor(ui.A0_access_label, "???", "#0000e0");
+		ui.consentA0_0->setPixmap(QPixmap(imgpath+"permission_off.png"));
+		ui.consentA0_1->setPixmap(QPixmap(imgpath+"permission_off.png"));
+		ui.A0OpenButton->setIcon(QPixmap(imgpath+"open.png"));
+		mySetTextColor(ui.A0_access_label, "", "#e0e000", "white");
+		ui.messageA0Label->setText("???");
+	}
+	// set undulator input process
+	if (undulatorPlcStat && myReadBoolArray("Undulator_access_signals", stat)) {
+		ui.consentAso_0->setPixmap(QPixmap(imgpath+(stat[8] || free_access_undulator? "permission_on.png": "permission_off.png")));
+		ui.consentAso_1->setPixmap(QPixmap(imgpath+(stat[9] || stat[10] || stat[11] || free_access_undulator? "permission_on.png": "permission_off.png")));
+		ui.AsoOpenButton->setIcon(QPixmap(imgpath+(stat[9]? "open.png": "open_hinibit.png")));
+		ui.AsoRestoreButton->setIcon(QPixmap(imgpath+(stat[35]? "restore.png": "restore_hinibit.png")));
+		// check if A_Linac in operation is running
+		if (stat[8]) {
+			mySetTextColor(ui.Aso_access_label, refreshCount? "INGRESSO IN CORSO": "", "#e0e000", "#0000e0");
+			if (stat[28]) ui.messageAsoLabel->setText("Premi ripristino (timeout estrazione testimone in ingresso)");
+			if (stat[29]) ui.messageAsoLabel->setText("Premi ripristino (timeout sblocco porta in ingresso)");
+			if (stat[30]) ui.messageAsoLabel->setText("Premi ripristino (timeout apertura porta in ingresso)");
+			if (stat[31]) ui.messageAsoLabel->setText("Premi ripristino (timeout chiusura porta in ingresso)");
+			if (stat[32]) ui.messageAsoLabel->setText("Premi ripristino (timeout deposito testimone in ingresso)");
+		}
+		// check if A_Linac out operation is running
+		else if (stat[16]) {
+			mySetTextColor(ui.Aso_access_label, refreshCount? "USCITA IN CORSO": "", "#e0e000", "#0000e0");
+			if (stat[28]) ui.messageAsoLabel->setText("Premi ripristino (timeout deposito testimone in uscita)");
+			if (stat[29]) ui.messageAsoLabel->setText("Premi ripristino (timeout sblocco porta in uscita)");
+			if (stat[30]) ui.messageAsoLabel->setText("Premi ripristino (timeout apertura porta in uscita)");
+			if (stat[31]) ui.messageAsoLabel->setText("Premi ripristino (timeout chiusura porta in uscita)");
+			if (stat[32]) ui.messageAsoLabel->setText("Premi ripristino (timeout lettura badge in uscita)");
+		}
+		else {
+			mySetTextColor(ui.Aso_access_label, "", "#e0e000", "white");
+			ui.messageAsoLabel->setText("");
+		}
+	}
+	else {
+		mySetTextColor(ui.Aso_access_label, "???", "#0000e0");
+		ui.consentAso_0->setPixmap(QPixmap(imgpath+"permission_off.png"));
+		ui.consentAso_1->setPixmap(QPixmap(imgpath+"permission_off.png"));
+		ui.AsoOpenButton->setIcon(QPixmap(imgpath+"open.png"));
+		mySetTextColor(ui.Aso_access_label, "", "#e0e000", "white");
+		ui.messageAsoLabel->setText("???");
+	}
+	// linac status
+	if (linacPlcStat && myReadBoolArray("Linac_state", stat)) {
+		mySetColor(ui.linacShutdownLabel, stat[0]? "black": "#dddddd", QPalette::WindowText);
+		mySetColor(ui.linacOffLabel, stat[1]? "black": "#dddddd", QPalette::WindowText);
+		mySetColor(ui.linacOnLabel, stat[2]? "black": "#dddddd", QPalette::WindowText);
+	}
+	else {
+		mySetColor(ui.linacShutdownLabel, "#dddddd", QPalette::WindowText);
+		mySetColor(ui.linacOffLabel, "#dddddd", QPalette::WindowText);
+		mySetColor(ui.linacOnLabel, "#dddddd", QPalette::WindowText);
+	}
+	// undulator status
+	if (undulatorPlcStat && myReadBoolArray("Undulator_state", stat)) {
+		mySetColor(ui.undulatorShutdownLabel, stat[0]? "black": "#dddddd", QPalette::WindowText);
+		mySetColor(ui.undulatorOffLabel, stat[1]? "black": "#dddddd", QPalette::WindowText);
+		mySetColor(ui.undulatorOnLabel, stat[2]? "black": "#dddddd", QPalette::WindowText);
+	}
+	else {
+		mySetColor(ui.undulatorShutdownLabel, "#dddddd", QPalette::WindowText);
+		mySetColor(ui.undulatorOffLabel, "#dddddd", QPalette::WindowText);
+		mySetColor(ui.undulatorOnLabel, "#dddddd", QPalette::WindowText);
+	}
+	bool MODKS_ON_CTF = false;
+	// linac modulator status
+	if (linacPlcStat && myReadBoolArray("Linac_mod_positions", stat)) {
+		mySetTextColor(ui.linacRfPcgunEnabLabel, stat[9]? "Abilitata": "Disabilitata", stat[9]? "black": (refreshCount? "black": "white"));
+		MODKS_ON_CTF = stat[10];
+	}
+	else {
+		mySetTextColor(ui.linacRfPcgunEnabLabel, "???", "black");
+	}
+	// Linac_mod_abi_rf[0]Linac_mod_positions[10]
+	if (linacPlcStat && myReadBoolArray("Linac_mod_abi_rf", stat)) {
+		bool linacRfTunnelEnab;
+		// K3_RF_Abi OR (KS_RF_Abi AND MODKS_ON_CTF)
+		linacRfTunnelEnab = stat[3] || (stat[0] && MODKS_ON_CTF);
+		// short int pcgun, s0;
+		// mySetTextColor(ui.linacRfTunnelEnabLabel, stat[3]? "Abilitata": "Disabilitata", stat[3]? "black": (refreshCount? "black": "white"));
+		mySetTextColor(ui.linacRfTunnelEnabLabel, linacRfTunnelEnab? "Abilitata": "Disabilitata", linacRfTunnelEnab? "black": (refreshCount? "black": "white"));
+	}
+	else {
+		mySetTextColor(ui.linacRfTunnelEnabLabel, "???", "black");
+	}
+	// linac switches status
+	vector<short> switchArray;
+	if (linacPlcStat && myReadShortArray("Linac_switches_config", switchArray) && myReadBoolArray("Linac_pickup", stat2)) {
+		// cout << switchArray[3] << endl;
+		bool rfCtfOn = switchArray[0]==3 || switchArray[0]==4 || switchArray[0]==6 || switchArray[0]==8 || 
+					 switchArray[1]==3 || switchArray[1]==4 || switchArray[1]==6 || switchArray[1]==8 || !stat2[4] || !stat2[5];
+		bool rfCtfOff = switchArray[0]==1 || switchArray[0]==2 || switchArray[0]==5 || switchArray[0]==7 ||
+					  switchArray[1]==1 || switchArray[1]==2 || switchArray[1]==5 || switchArray[1]==7;
+		bool rfPcGunOn = switchArray[3]==3 || switchArray[3]==4 || switchArray[3]==6 || switchArray[3]==8 || !stat2[0];
+		bool rfPcGunOff = switchArray[3]==1 || switchArray[3]==2 || switchArray[3]==5 || switchArray[3]==7;
+		mySetTextColor(ui.linacRfPcgunStatLabel, (rfPcGunOn? "ON": (rfPcGunOff? "OFF": "???")), (rfPcGunOn? "#e00000": (rfPcGunOff? "#00b000": "black")));
+		bool rfS0aOn = switchArray[5]==2 || switchArray[5]==4 || switchArray[5]==7 || switchArray[5]==8;
+		bool rfS0aOff = switchArray[5]==1 || switchArray[5]==3 || switchArray[5]==5 || switchArray[5]==6;
+		bool rfS0bOn = switchArray[4]==2 || switchArray[4]==4 || switchArray[4]==7 || switchArray[4]==8;
+		bool rfS0bOff = switchArray[4]==1 || switchArray[4]==3 || switchArray[4]==5 || switchArray[4]==6;
+		if (myReadBoolArray("Linac_mod_rf", stat)) {
+			bool rfOn = false;
+			bool rfOff = false;
+			for (unsigned i=3; i<stat.size(); i++) {
+				rfOn = rfOn || !stat[i];
+			}
+			for (unsigned i=0; i<4; i++) {
+				rfOn = rfOn || !stat2[i];
+			}
+			rfOn = rfOn || rfPcGunOn || rfS0aOn || rfS0bOn || rfCtfOn;
+			rfOff = rfPcGunOff || rfS0aOff || rfS0bOff || rfCtfOff;
+			mySetTextColor(ui.linacRfTunnelStatLabel, (rfOn? "ON": (rfOff? "OFF": "???")), (rfOn? "#e00000": (rfOff? "#00b000": "black")));
+		}
+		else {
+			mySetTextColor(ui.linacRfTunnelStatLabel, "???", "black");
+		}
+	}
+	else {
+		mySetTextColor(ui.linacRfPcgunStatLabel, "???", "black");
+		mySetTextColor(ui.linacRfTunnelStatLabel, "???", "black");
+	}
+	bool eme, holdeme, holdtleme;
+	eme = holdeme = holdtleme = false;
+	if (linacPlcStat && myReadBoolArray("Linac_search_ini_l", stat)) {
+		// holdeme = !stat[10];
+		holdeme = stat[10];
+	}
+	if (linacPlcStat && myReadBoolArray("Linac_search_ini_tl", stat)) {
+		holdtleme = !stat[3];
+	}
+	// set search buttons
+	if (linacPlcStat && myReadBoolArray("Linac_emergency_buttons", stat) && myReadBoolArray("Linac_emergency_memo_buttons", stat2)) {
+		ui.emergencyButton_tl->setIcon(QPixmap(imgpath+((!stat[12] && refreshCount)? "/alarm_on.png": ((holdtleme || stat2[12])? "/alarm_hold.png": "/alarm_off.png"))));
+		ui.emergencyRestoreButton_tl->setIcon(QPixmap(imgpath+((holdtleme || stat2[12])? "/restore_small.png": "/restore_small_hinibit.png")));
+		for (int i=0; i<12; i++) {
+			eme = eme || !stat[i];
+			holdeme = holdeme || stat2[i];
+		}
+		// cout << "Linac hold emergency: " << (holdeme? "true": "false") << endl;
+		ui.emergencyButton->setIcon(QPixmap(imgpath+((eme && refreshCount)? "/alarm_on.png": (holdeme? "/alarm_hold.png": "/alarm_off.png"))));
+		// ui.emergencyRestoreButton->setIcon(QPixmap(imgpath+(holdeme? "/restore_small.png": "/restore_small_hinibit.png")));
+		ui.emergencyRestoreButton->setIcon(QPixmap(imgpath+((holdeme && !eme)? "/restore_small.png": "/restore_small_hinibit.png")));
+	}
+	else {
+		ui.emergencyButton->setIcon(QPixmap(imgpath+"/alarm_on.png"));
+		ui.emergencyButton_tl->setIcon(QPixmap(imgpath+"/alarm_on.png"));
+		ui.emergencyRestoreButton->setIcon(QPixmap(imgpath+"/restore_small.png"));
+		ui.emergencyRestoreButton_tl->setIcon(QPixmap(imgpath+"/restore_small.png"));
+	}
+	if (linacPlcStat && myReadBoolArray("Linac_search_ini_tl", stat)) {
+		holdeme = !stat[10];
+	}
+	eme = holdeme = false;
+	if (undulatorPlcStat && myReadBoolArray("Undulator_search_ini_so", stat)) {
+		holdeme = !stat[7];
+	}
+	// cout << "Undulator hold emergency: " << (holdeme? "true": "false") << endl;
+	if (undulatorPlcStat && myReadBoolArray("Undulator_emergency_buttons", stat) && myReadBoolArray("Undulator_emergency_memo_buttons", stat2)) {
+		for (int i=0; i<13; i++) {
+			eme = eme || !stat[i];
+			holdeme = holdeme || stat2[i];
+		}
+		// cout << "Undulator hold emergency: " << (holdeme? "true": "false") << endl;
+		ui.emergencyButton_so->setIcon(QPixmap(imgpath+((eme && refreshCount)? "/alarm_on.png": (holdeme? "/alarm_hold.png": "/alarm_off.png"))));
+		ui.emergencyRestoreButton_so->setIcon(QPixmap(imgpath+((holdeme && !eme)? "/restore_small.png": "/restore_small_hinibit.png")));
+		ui.emergencyButton_esa1->setIcon(QPixmap(imgpath+((!stat[13] && refreshCount)? "/alarm_on.png": "/alarm_off.png")));
+		ui.emergencyButton_esa2->setIcon(QPixmap(imgpath+((!stat[14] && refreshCount)? "/alarm_on.png": "/alarm_off.png")));
+	}
+	else {
+		ui.emergencyButton_so->setIcon(QPixmap(imgpath+"/alarm_on.png"));
+		ui.emergencyRestoreButton_so->setIcon(QPixmap(imgpath+"/restore_small.png"));
+	}
+	if (undulatorPlcStat && myReadBoolArray("Undulator_bst_inhibit_bl", stat)) {
+		mySetTextColor(ui.BendingCheck, stat[10]? "OK": (refreshCount? "Errore": ""), stat[10]? "#00a000": "#e00000");
+		mySetTextColor(ui.ToroidCheck, stat[9]? (stat[11]? "OK": (refreshCount? "Errore": "")): "Disabilitato", stat[9]? (stat[11]?"#00a000": "#e00000"): "#000000");
+	}
+	else {
+		mySetTextColor(ui.BendingCheck, "???", "#000000");
+		mySetTextColor(ui.ToroidCheck, "???", "#000000");
+	}
+
+	foreach(w_buffer tmp_buffer, ws_buffer) {
+		if (qobject_cast <QPushButton *> (tmp_buffer.w) != NULL) {
+			if (!(qobject_cast <QPushButton *> (tmp_buffer.w)->icon().isNull())) {
+				// cout << "y: " << ((int) tmp_buffer.height*resizeFactorY )<<  ", objName: " << tmp_buffer.w->objectName().toStdString() << endl;
+				QSize s((int) tmp_buffer.width*resizeFactorX, (int) tmp_buffer.height*resizeFactorY);
+				QIcon q; q = qobject_cast <QPushButton *> (tmp_buffer.w)->icon();
+				QPixmap p = q.pixmap((int) tmp_buffer.width*resizeFactorX, (int) tmp_buffer.height*resizeFactorY); p = p.scaled(s);
+				qobject_cast <QPushButton *> (tmp_buffer.w)->setIcon(QIcon(p));
+				qobject_cast <QPushButton *> (tmp_buffer.w)->setIconSize(s);
+			}
+		}
+	}
+}
+
+
+void acs::open_bst_linac()
+{
+	vector<bool> stat;
+	// check if button is enabled
+	if (myReadAttribute("Linac_bst_1")) {
+		myAttribute >> stat; 
+		if (!stat[7]) {
+			return;
+		}
+	}
+	else {
+		return;
+	}
+	// open procedure
+	try {
+		int r = QMessageBox::question(this, "Conferma apertura", "Conferma apertura Beam Stopper BST_Linac", "Apri", "Annulla");
+		if (r == 0) {
+			try {
+				myWriteCommand("LinacBstOpen");
+			}
+			catch (...) {
+			}
+		}
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "Non posso aprire BST_LINAC" << endl;
+	}
+	cout << "open_bst_Linac" << endl;
+}
+
+void acs::close_bst_linac()
+{
+	// open procedure
+	try {
+		int r = QMessageBox::question(this, "Conferma chiusura", "Conferma chiusura Beam Stopper BST_Linac", "Chiudi", "Annulla");
+		if (r == 0) {
+			try {
+				myWriteCommand("LinacBstClose");
+			}
+			catch (...) {
+			}
+		}
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "Non posso chiudere BST_Linac" << endl;
+	}
+	cout << "close_bst_Linac" << endl;
+}
+
+void acs::open_bst1_fel1()
+{
+	vector<bool> stat;
+	// check if button is enabled
+	if (myReadAttribute("Undulator_bst1_fel1")) {
+		myAttribute >> stat; 
+		if (!stat[7]) {
+			return;
+		}
+	}
+	else {
+		return;
+	}
+	// open procedure
+	try {
+		int r = QMessageBox::question(this, "Conferma apertura", "Conferma apertura Beam Stopper BST1_FEL1", "Apri", "Annulla");
+		if (r == 0) {
+			try {
+				myWriteCommand("UndulatorBstOpen", 1);
+			}
+			catch (...) {
+			}
+		}
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "Non posso aprire BST1_FEL1" << endl;
+	}
+	cout << "open_BST1_FEL1" << endl;
+}
+
+void acs::close_bst1_fel1()
+{
+	// open procedure
+	try {
+		int r = QMessageBox::question(this, "Conferma chiusura", "Conferma chiusura Beam Stopper BST1_FEL1", "Chiudi", "Annulla");
+		if (r == 0) {
+			try {
+				myWriteCommand("UndulatorBstClose", 1);
+			}
+			catch (...) {
+			}
+		}
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "Non posso chiudere BST1_FEL1" << endl;
+	}
+	cout << "close_BST1_FEL1" << endl;
+}
+
+void acs::open_bst2_fel1()
+{
+	vector<bool> stat;
+	// check if button is enabled
+	if (myReadAttribute("Undulator_bst2_fel1")) {
+		myAttribute >> stat; 
+		if (!stat[7]) {
+			return;
+		}
+	}
+	else {
+		return;
+	}
+	// open procedure
+	try {
+		int r = QMessageBox::question(this, "Conferma apertura", "Conferma apertura Beam Stopper BST2_FEL1", "Apri", "Annulla");
+		if (r == 0) {
+			try {
+				myWriteCommand("UndulatorBstOpen", 2);
+			}
+			catch (...) {
+			}
+		}
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "Non posso aprire BST2_FEL1" << endl;
+	}
+	cout << "open_BST2_FEL1" << endl;
+}
+
+void acs::close_bst2_fel1()
+{
+	// open procedure
+	try {
+		int r = QMessageBox::question(this, "Conferma chiusura", "Conferma chiusura Beam Stopper BST2_FEL1", "Chiudi", "Annulla");
+		if (r == 0) {
+			try {
+				myWriteCommand("UndulatorBstClose", 2);
+			}
+			catch (...) {
+			}
+		}
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "Non posso chiudere BST2_FEL1" << endl;
+	}
+	cout << "close_BST2_FEL1" << endl;
+}
+
+void acs::open_bst1_fel2()
+{
+	vector<bool> stat;
+	// check if button is enabled
+	if (myReadAttribute("Undulator_bst1_fel2")) {
+		myAttribute >> stat; 
+		if (!stat[7]) {
+			return;
+		}
+	}
+	else {
+		return;
+	}
+	// open procedure
+	try {
+		int r = QMessageBox::question(this, "Conferma apertura", "Conferma apertura Beam Stopper BST1_FEL2", "Apri", "Annulla");
+		if (r == 0) {
+			try {
+				myWriteCommand("UndulatorBstOpen", 3);
+			}
+			catch (...) {
+			}
+		}
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "Non posso aprire BST1_FEL2" << endl;
+	}
+	cout << "open_BST1_FEL2" << endl;
+}
+
+void acs::close_bst1_fel2()
+{
+	// open procedure
+	try {
+		int r = QMessageBox::question(this, "Conferma chiusura", "Conferma chiusura Beam Stopper BST1_FEL2", "Chiudi", "Annulla");
+		if (r == 0) {
+			try {
+				myWriteCommand("UndulatorBstClose", 3);
+			}
+			catch (...) {
+			}
+		}
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "Non posso chiudere BST1_FEL2" << endl;
+	}
+	cout << "close_BST1_FEL2" << endl;
+}
+
+void acs::open_bst2_fel2()
+{
+	vector<bool> stat;
+	// check if button is enabled
+	if (myReadAttribute("Undulator_bst2_fel2")) {
+		myAttribute >> stat; 
+		if (!stat[7]) {
+			return;
+		}
+	}
+	else {
+		return;
+	}
+	// open procedure
+	try {
+		int r = QMessageBox::question(this, "Conferma apertura", "Conferma apertura Beam Stopper BST2_FEL2", "Apri", "Annulla");
+		if (r == 0) {
+			try {
+				myWriteCommand("UndulatorBstOpen", 4);
+			}
+			catch (...) {
+			}
+		}
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "Non posso aprire BST2_FEL2" << endl;
+	}
+	cout << "open_BST2_FEL2" << endl;
+}
+
+void acs::close_bst2_fel2()
+{
+	// open procedure
+	try {
+		int r = QMessageBox::question(this, "Conferma chiusura", "Conferma chiusura Beam Stopper BST2_FEL2", "Chiudi", "Annulla");
+		if (r == 0) {
+			try {
+				myWriteCommand("UndulatorBstClose", 4);
+			}
+			catch (...) {
+			}
+		}
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "Non posso chiudere BST2_FEL2" << endl;
+	}
+	cout << "close_BST2_FEL2" << endl;
+}
+
+void acs::open_bst_diag()
+{
+	vector<bool> stat;
+	// check if button is enabled
+	if (myReadAttribute("Undulator_bst_diag")) {
+		myAttribute >> stat; 
+		if (!stat[7]) {
+			return;
+		}
+	}
+	else {
+		return;
+	}
+	// open procedure
+	try {
+		int r = QMessageBox::question(this, "Conferma apertura", "Conferma apertura Beam Stopper BST_DIAGN", "Apri", "Annulla");
+		if (r == 0) {
+			try {
+				myWriteCommand("UndulatorBstOpen", 5);
+			}
+			catch (...) {
+			}
+		}
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "Non posso aprire BST_DIAGN" << endl;
+	}
+	cout << "open_BST_DIAGN" << endl;
+}
+
+void acs::close_bst_diag()
+{
+	// open procedure
+	try {
+		int r = QMessageBox::question(this, "Conferma chiusura", "Conferma chiusura Beam Stopper BST_DIAGN", "Chiudi", "Annulla");
+		if (r == 0) {
+			try {
+				myWriteCommand("UndulatorBstClose", 5);
+			}
+			catch (...) {
+			}
+		}
+	}
+	catch (const Tango::DevFailed &e) {
+		timestamp();
+		cout << tmBuffer << "Non posso chiudere BST_DIAGN" << endl;
+	}
+	cout << "close_BST_DIAGN" << endl;
+}
+
+
+
+void acs::switch_master()
+{
+	// load (or set) master
+	QSettings settings("fermi", "acs");
+	if (settings.contains("masterlist")) {
+		if (getenv("DISPLAY")==settings.value("masterlist").toString() && settings.contains("master")) {
+			if (settings.value("master").toString().contains(getenv("DISPLAY"))) {
+				master = false;
+				settings.setValue("master", "none");
+			}
+			else {
+				master = true;
+				settings.setValue("master", getenv("DISPLAY"));
+			}
+
+		}
+		// cout << master.toStdString() << endl;
+	}
+	else {
+		settings.setValue("masterlist", "qua:0");
+	}
+}
+
+
+void acs::open_scrapersinfo_panel()
+{
+	if (scrapersinfo_process->state() != QProcess::Running) {
+		scrapersinfo_process->kill();
+		scrapersinfo_process->waitForFinished(3000);
+	}
+	scrapersinfo_process->start("acsscrapersinfo"+style);
+}
+
+void acs::open_alarmlist_panel()
+{
+	alarmlist_process->start("firefox 192.168.205.101/docs/fermi/pss.php?startdate=lastday");
+}
+
+void acs::switch_control_location()
+{
+	QSettings settings("fermi", "acs");
+	// load control location
+	controlLocation = settings.value("controlLocation").toString();
+	if (controlLocation == "Sala Controllo Anello") {
+		settings.setValue("controlLocation", "PSA");
+	}
+	else {
+		settings.setValue("controlLocation", "Sala Controllo Anello");
+	}
+}
+
+void acs::open_register()
+{
+	register_process->start("/usr/local/firefox/firefox http://fcsproxy.elettra.eu/docs/pss/register.php");
+}
+
+void acs::open_version_panel()
+{
+	vector<bool> stat;
+	string strstat;
+	// set PLC status
+	if (myReadAttribute("Version")) {
+		myAttribute >> strstat;
+		// strstat += "pan_ver: 1.30";
+		strstat += "pan_ver: ";
+		strstat += myversion.length()>17? myversion.substr(15,2): myversion;
+		// open procedure
+		try {
+			QMessageBox::question(this, "Versione", strstat.c_str(), "Esci");
+		}
+		catch (const Tango::DevFailed &e) {
+			timestamp();
+			cout << tmBuffer << "Non posso leggere la versione" << endl;
+		}
+	}
+	else {
+		timestamp();
+		cout << tmBuffer << "Non posso leggere la versione" << endl;
+	}
+}
-- 
GitLab