ATLAS Offline Software
IVP1ChannelWidget.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // //
7 // Implementation of class IVP1ChannelWidget //
8 // //
9 // Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> //
10 // //
11 // Initial version: April 2007 //
12 // //
14 
16 #include "VP1Base/IVP1System.h"
17 
18 #include <cassert>
19 #include <QPixmap>
20 
22 
23 public:
24  Imp(const QString & n, const QString & i, const QString & c)
27  canregistercontroller(false),
28  canregistersystem(true),
30 {}
31  const QString name;
32  const QString information;
33  const QString contact_info;
34  unsigned cloneid;
35  std::set<IVP1System *> systems;
36  QWidget * controller;
40  int runnumber;
41  unsigned long long eventnumber;
42  unsigned timestamp;
43 };
44 
45 //_______________________________________________________
46 IVP1ChannelWidget::IVP1ChannelWidget(const QString & n, const QString & i, const QString & c)
47  : QWidget(0), m_d(new Imp(n,i,c))
48 {
50  m_d->cloneid = 0;
51  m_d->controller = 0;
53  m_d->canregistersystem=true;
54  m_d->runnumber = 0;
55  m_d->eventnumber = 0;
56  setObjectName("IVP1ChannelWidget:"+n);
57 }
58 
59 //_______________________________________________________
61 {
62  VP1Msg::messageDebug("IVP1ChannelWidget::~IVP1ChannelWidget()");
63  assert(m_d->state==UNCREATED||m_d->state==CONSTRUCTED);
64  assert(!m_d->controller);
65  //Delete systems:
67  for (it=m_d->systems.begin();it!=itE;++it) {
68  assert((*it)->state()==IVP1System::UNCREATED||(*it)->state()==IVP1System::CONSTRUCTED);
69  VP1Msg::messageDebug("deleting system: "+ (*it)->name());
70  delete *it;
71  }
72  m_d->systems.clear();
73  delete m_d;
74 }
75 
76 //_______________________________________________________
78 {
79  return m_d->controller;
80 }
81 
82 //_______________________________________________________
84 {
85  return false;
86 }
87 
88 //_______________________________________________________
89 void IVP1ChannelWidget::setRunEvtNumber(int runnumber, unsigned long long eventnumber)
90 {
92  m_d->eventnumber = eventnumber;
93 }
94 
95 //_______________________________________________________
96 void IVP1ChannelWidget::setEvtTimestamp(unsigned timestamp)
97 {
98  m_d->timestamp = timestamp;
99 }
100 
101 //________________________________________________________
103 {
104  return m_d->state;
105 }
106 
107 //________________________________________________________
109 {
110 
111 #ifndef NDEBUG
112  assert(s!=CONSTRUCTED);
113  if (s==READY) {
114  assert(m_d->state==CONSTRUCTED);
115  }
116  if (s==UNCREATED) {
117  assert(m_d->state==READY);
118  }
119 #endif
120  m_d->state = s;
121 }
122 
123 //_______________________________________________________
125 {
126  assert(m_d->state==CONSTRUCTED);
127 }
128 
129 //_______________________________________________________
131 {
132  assert(m_d->state==READY);
133  if( ! (s->state()==IVP1System::REFRESHED) ) {
134  VP1Msg::messageVerbose("s->state() != IVP1System::REFRESHED!");
135  }
136  assert(s->state()==IVP1System::REFRESHED);
137 // s = 0;//get rid of compile warning in opt mode
138  VP1Msg::messageDebug("systemRefreshed: "+s->name());
139 }
140 
141 //_______________________________________________________
143 {
144  assert(m_d->state==READY);
145  bool isErased = (s->state()==IVP1System::ERASED) ? true : false;
146  if(!isErased) {
147  VP1Msg::messageVerbose("s->state() != IVP1System::ERASED!");
148  }
149  assert(isErased);
150 // s = 0;//get rid of compile warning in opt mode
151  VP1Msg::messageDebug("systemErased: "+s->name());
152 }
153 
154 //_______________________________________________________
156 {
157  assert(m_d->state==READY);
158 }
159 
160 //_______________________________________________________
162 {
164  for (it=m_d->systems.begin();it!=itE;++it) {
165  // assert((*it)->state()==IVP1System::ERASED);
166  if (*it)
167  (*it)->deleteController();
168  }
169  if (m_d->controller)
170  m_d->controller->deleteLater();
171  m_d->controller = 0;
172 }
173 
174 //_______________________________________________________
175 const QString IVP1ChannelWidget::unique_name() const
176 {
177  return m_d->name+(m_d->cloneid?" ["+QString::number(m_d->cloneid)+"]":QString(""));//Fixme: make sure that it is forbidden to end a name with ' [.*]'!
178 }
179 //________________________________________________________
180 const QString& IVP1ChannelWidget::name() const
181 {
182  return m_d->name;
183 }
184 //________________________________________________________
185 const QString& IVP1ChannelWidget::information() const
186 {
187  return m_d->information;
188 }
189 
190 //________________________________________________________
191 const QString& IVP1ChannelWidget::contact_info() const
192 {
193  return m_d->contact_info;
194 }
195 
196 //_______________________________________________________
198 {
199  return m_d->cloneid;
200 }
201 
202 //_______________________________________________________
204 {
205  m_d->cloneid=id;
207 }
208 
209 //_______________________________________________________
211 {
212  assert(m_d->canregistercontroller&&"Please only register controllers during create()");
213  assert(m_d->state==CONSTRUCTED);
214  assert(w&&"IVP1ChannelWidget::registerController(...) called with null pointer!!");
215  assert(!m_d->controller&&"IVP1ChannelWidget::registerController(...) called twice!!");
216  m_d->controller = w;
217  w->setParent(0);
218 }
219 
220 //_______________________________________________________
222 {
223  assert(m_d->canregistersystem&&"Please only register systems during the channel constructor");
224  assert(m_d->state==CONSTRUCTED);
225  assert(m_d->systems.find(s)==m_d->systems.end()&&"IVP1ChannelWidget::registerSystem(...) called twice on the same system!!");
226  m_d->systems.insert(s);
227  s->setChannel(this);
228 }
229 
230 //_______________________________________________________
231 const std::set<IVP1System *>& IVP1ChannelWidget::systems()
232 {
233  return m_d->systems;
234 }
235 
236 //_______________________________________________________
238 {
239  assert(s->channel()==this);
240  assert(m_d->systems.find(s)!=m_d->systems.end());
241  s->setActiveState(IVP1System::ON);
243 }
244 
245 //_______________________________________________________
246 void IVP1ChannelWidget::turnOff(IVP1System*s,const bool& immediateErase)
247 {
248  assert(s->channel()==this);
249  assert(m_d->systems.find(s)!=m_d->systems.end());
250  s->setActiveState(IVP1System::OFF,!immediateErase);
252 }
253 
254 //_______________________________________________________
255 void IVP1ChannelWidget::getRunEvtNumber(int& runnumber, unsigned long long& eventnumber)
256 {
258  eventnumber = m_d->eventnumber;
259 }
260 
261 //_______________________________________________________
262 void IVP1ChannelWidget::getEvtTimestamp(unsigned& timestamp)
263 {
264  timestamp = m_d->timestamp;
265 }
266 
267 //_______________________________________________________
269 {
270  int nsysOn(0), nsysOnRefreshed(0);
271  QString sysrefreshing;
273  for (it=m_d->systems.begin();it!=itE;++it) {
274  if ((*it)->activeState()==IVP1System::ON) {
275  ++nsysOn;
276  if((*it)->state()==IVP1System::REFRESHED)
277  ++nsysOnRefreshed;
278  if ((*it)->isRefreshing()) {
279  assert(sysrefreshing.isEmpty());
280  sysrefreshing=(*it)->name();
281  }
282  }
283  }
284  //Fixme: Only emit if actually changed.
285  systemRefreshInfoChanged(sysrefreshing, nsysOn, nsysOnRefreshed);
286 }
287 
288 //_______________________________________________________
291  for (it=m_d->systems.begin();it!=itE;++it) {
292  if ((*it)->isRefreshing())
293  return true;
294  }
295  return false;
296 }
297 
298 //_______________________________________________________
299 void IVP1ChannelWidget::setCanRegister(const bool&c,const bool&s)
300 {
303 }
304 
305 //_______________________________________________________
306 QPixmap IVP1ChannelWidget::getSnapshot(bool transp, int width, bool batch)
307 {
308  VP1Msg::messageVerbose("IVP1ChannelWidget::getSnapshot() - using QPixmap::grabWidget()");
309  VP1Msg::messageVerbose("(and so, not using the values - transp: "+QString::number(transp)+" - width: "+QString::number(width)+" - batch: " + batch +")");
310 
311  return this->grab();
312 }
313 
314 //_______________________________________________________
316 {
317 }
318 
319 //_______________________________________________________
321  VP1Msg::messageVerbose("IVP1ChannelWidget base saveState called");
322  return QByteArray();
323 }
324 
325 //_______________________________________________________
327 {
328  VP1Msg::messageVerbose("IVP1ChannelWidget base restoreFromState called");
329  if (!ba.isEmpty())
330  message("Error in IVP1System::restoreFromState: Received non-empty saved state.");
331 }
332 
333 //_______________________________________________________
335 {
336  VP1Msg::messageVerbose("IVP1ChannelWidget base lastOfActiveSystemsRefreshed called");
337 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
IVP1ChannelWidget::registerSystem
void registerSystem(IVP1System *)
Definition: IVP1ChannelWidget.cxx:221
IVP1ChannelWidget::lastOfActiveSystemsRefreshed
virtual void lastOfActiveSystemsRefreshed()
Definition: IVP1ChannelWidget.cxx:334
IVP1ChannelWidget::Imp::canregistersystem
bool canregistersystem
Definition: IVP1ChannelWidget.cxx:39
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
IVP1ChannelWidget::setRunEvtNumber
void setRunEvtNumber(int runnumber, unsigned long long eventnumber)
Definition: IVP1ChannelWidget.cxx:89
IVP1ChannelWidget::Imp::systems
std::set< IVP1System * > systems
Definition: IVP1ChannelWidget.cxx:35
IVP1System::CONSTRUCTED
@ CONSTRUCTED
Definition: IVP1System.h:143
IVP1ChannelWidget::contact_info
const QString & contact_info() const
Definition: IVP1ChannelWidget.cxx:191
IVP1ChannelWidget::State
State
Definition: IVP1ChannelWidget.h:130
IVP1ChannelWidget::Imp::information
const QString information
Definition: IVP1ChannelWidget.cxx:32
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
IVP1ChannelWidget::dockResized
virtual void dockResized()
Definition: IVP1ChannelWidget.cxx:315
skel.it
it
Definition: skel.GENtoEVGEN.py:396
IVP1ChannelWidget::registerController
void registerController(QWidget *)
Definition: IVP1ChannelWidget.cxx:210
IVP1ChannelWidget::deleteControllers
void deleteControllers()
Definition: IVP1ChannelWidget.cxx:161
IVP1ChannelWidget::Imp::contact_info
const QString contact_info
Definition: IVP1ChannelWidget.cxx:33
IVP1ChannelWidget::emitRefreshInfoChanged
void emitRefreshInfoChanged()
Definition: IVP1ChannelWidget.cxx:268
IVP1ChannelWidget::create
virtual void create()
Definition: IVP1ChannelWidget.cxx:124
Preparation.batch
batch
Definition: Preparation.py:49
IVP1ChannelWidget::systemErased
virtual void systemErased(IVP1System *)
Definition: IVP1ChannelWidget.cxx:142
IVP1ChannelWidget::unique_name
const QString unique_name() const
Definition: IVP1ChannelWidget.cxx:175
IVP1ChannelWidget::Imp::state
State state
Definition: IVP1ChannelWidget.cxx:37
IVP1ChannelWidget::turnOff
void turnOff(IVP1System *, const bool &immediateErase=true)
Definition: IVP1ChannelWidget.cxx:246
IVP1ChannelWidget::systemRefreshInfoChanged
void systemRefreshInfoChanged(QString sysrefreshing, int nsysOn, int nsysOnRefreshed)
TruthTest.itE
itE
Definition: TruthTest.py:25
IVP1ChannelWidget::getEvtTimestamp
void getEvtTimestamp(unsigned &timestamp)
Definition: IVP1ChannelWidget.cxx:262
IVP1ChannelWidget::isAccumulator
virtual bool isAccumulator() const
Definition: IVP1ChannelWidget.cxx:83
IVP1ChannelWidget::Imp::controller
QWidget * controller
Definition: IVP1ChannelWidget.cxx:36
IVP1System
Definition: IVP1System.h:36
IVP1ChannelWidget::uncreate
virtual void uncreate()
Definition: IVP1ChannelWidget.cxx:155
lumiFormat.i
int i
Definition: lumiFormat.py:85
IVP1ChannelWidget::~IVP1ChannelWidget
virtual ~IVP1ChannelWidget()
Definition: IVP1ChannelWidget.cxx:60
IVP1ChannelWidget::Imp::canregistercontroller
bool canregistercontroller
Definition: IVP1ChannelWidget.cxx:38
IVP1ChannelWidget::CONSTRUCTED
@ CONSTRUCTED
Definition: IVP1ChannelWidget.h:130
beamspotman.n
n
Definition: beamspotman.py:731
IVP1ChannelWidget::UNCREATED
@ UNCREATED
Definition: IVP1ChannelWidget.h:130
IVP1ChannelWidget::hasRefreshingSystem
bool hasRefreshingSystem()
Definition: IVP1ChannelWidget.cxx:289
IVP1ChannelWidget::Imp::timestamp
unsigned timestamp
Definition: IVP1ChannelWidget.cxx:42
IVP1System::REFRESHED
@ REFRESHED
Definition: IVP1System.h:143
IVP1ChannelWidget::systems
const std::set< IVP1System * > & systems()
Definition: IVP1ChannelWidget.cxx:231
IVP1ChannelWidget::getSnapshot
virtual QPixmap getSnapshot(bool transp=false, int width=0, bool batch=false)
Definition: IVP1ChannelWidget.cxx:306
IVP1ChannelWidget::Imp::name
const QString name
Definition: IVP1ChannelWidget.cxx:31
IVP1ChannelWidget::message
void message(QString)
IVP1ChannelWidget::uniqueNameChanged
void uniqueNameChanged(const QString &)
IVP1System::UNCREATED
@ UNCREATED
Definition: IVP1System.h:143
IVP1ChannelWidget::setState
void setState(const State &)
Definition: IVP1ChannelWidget.cxx:108
DeMoScan.runnumber
runnumber
Definition: DeMoScan.py:266
IVP1System::ON
@ ON
Definition: IVP1System.h:144
IVP1ChannelWidget::state
State state() const
Definition: IVP1ChannelWidget.cxx:102
IVP1ChannelWidget::restoreFromState
virtual void restoreFromState(QByteArray)
Definition: IVP1ChannelWidget.cxx:326
IVP1ChannelWidget::saveState
virtual QByteArray saveState()
Definition: IVP1ChannelWidget.cxx:320
IVP1ChannelWidget::IVP1ChannelWidget
IVP1ChannelWidget(const QString &name, const QString &information, const QString &contact_info)
Definition: IVP1ChannelWidget.cxx:46
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
python.selection.number
number
Definition: selection.py:20
IVP1ChannelWidget::Imp::eventnumber
unsigned long long eventnumber
Definition: IVP1ChannelWidget.cxx:41
VP1Msg::messageVerbose
static void messageVerbose(const QString &)
Definition: VP1Msg.cxx:84
IVP1ChannelWidget::Imp::runnumber
int runnumber
Definition: IVP1ChannelWidget.cxx:40
IVP1ChannelWidget::setCloneID
void setCloneID(unsigned id)
Definition: IVP1ChannelWidget.cxx:203
IVP1ChannelWidget::cloneID
unsigned cloneID() const
Definition: IVP1ChannelWidget.cxx:197
IVP1ChannelWidget::getRunEvtNumber
void getRunEvtNumber(int &runnumber, unsigned long long &eventnumber)
Definition: IVP1ChannelWidget.cxx:255
IVP1ChannelWidget::Imp::Imp
Imp(const QString &n, const QString &i, const QString &c)
Definition: IVP1ChannelWidget.cxx:24
IVP1ChannelWidget::setEvtTimestamp
void setEvtTimestamp(unsigned timestamp)
Definition: IVP1ChannelWidget.cxx:96
VP1Msg::messageDebug
static void messageDebug(const QString &)
Definition: VP1Msg.cxx:39
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
IVP1ChannelWidget::systemRefreshed
virtual void systemRefreshed(IVP1System *)
Definition: IVP1ChannelWidget.cxx:130
IVP1ChannelWidget::setCanRegister
void setCanRegister(const bool &controller, const bool &system)
Definition: IVP1ChannelWidget.cxx:299
IVP1ChannelWidget::READY
@ READY
Definition: IVP1ChannelWidget.h:130
IVP1ChannelWidget::Imp
Definition: IVP1ChannelWidget.cxx:21
IVP1ChannelWidget::Imp::cloneid
unsigned cloneid
Definition: IVP1ChannelWidget.cxx:34
IVP1ChannelWidget::name
const QString & name() const
Definition: IVP1ChannelWidget.cxx:180
IVP1ChannelWidget::controllerWidget
QWidget * controllerWidget()
Definition: IVP1ChannelWidget.cxx:77
IVP1ChannelWidget::m_d
Imp * m_d
Definition: IVP1ChannelWidget.h:119
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
python.compressB64.c
def c
Definition: compressB64.py:93
IVP1ChannelWidget::turnOn
void turnOn(IVP1System *)
Definition: IVP1ChannelWidget.cxx:237
IVP1System.h
IVP1System::OFF
@ OFF
Definition: IVP1System.h:144
IVP1System::ERASED
@ ERASED
Definition: IVP1System.h:143
IVP1ChannelWidget::information
const QString & information() const
Definition: IVP1ChannelWidget.cxx:185
IVP1ChannelWidget.h