11 #include "TObjString.h"
14 using namespace Diana;
35 std::string add = GetString(
"GuiHost",
"localhost");
36 int port = GetInt(
"GuiPort",1130);
37 fSocket =
new TSocket(add.c_str(),port);
41 Action act = Menu(ML_Init);
57 if(fRunData.fNumber != hdr.
GetRun())
61 GlobalData().Get(
"DAQ",&rh,
"");
62 if(rh.IsValid()) fRunData = rh.Get();
65 Action act = Menu(ML_Do);
72 Action act = Menu(ML_Done);
82 act = HandleCommand(cmd);
84 Debug(
"Performing action %d",act.
fActionId);
138 if(fSocket && fSocket->IsValid()) {
139 TMessage* mess = NULL;
140 Debug(
"Waiting for command");
143 TObject* obj = mess->ReadObject(mess->GetClass());
149 Warn(
"Object received is not a QGDCommand, Ignored");
153 Panic(
"Connection error, command not received");
161 Debug(
"Sending avalaible commands");
165 if(level == ML_Init) {
174 }
else if(level == ML_Do) {
185 }
else if(level == ML_Done) {
198 if(fSocket && fSocket->IsValid()) {
199 TMessage mess(kMESS_OBJECT);
200 mess.WriteObject( obj );
201 fSocket->Send( mess );
202 Debug(
"Object sent");
204 Panic(
"Connection error, could not send data");
212 const std::vector<QBaseModule*>& modList = GetModulesList();
214 for(
size_t m = 0; m < modList.size(); m++) {
215 QBaseModule *mod = modList[m];
216 std::string fullPath = mod->GetFullPath();
217 eModList.
fModules.push_back(fullPath);
219 SendTObject(&eModList);
224 const std::vector<QBaseModule*>& modList = GetModulesList();
225 if(modIndex <= 0 && modIndex > (
int)modList.size()-1) {
226 Error(
"Module index (%d) out of range",modIndex);
229 const QBaseModule* thisMod = modList[(size_t)modIndex];
230 std::string moduleName = thisMod->GetName();
231 int occurrence = thisMod->GetOccurrence();
232 std::map<std::string, QVdt*> params = GetModuleParameters(moduleName, occurrence);
233 std::map<std::string, QVdt*>::iterator p1 = params.begin();
235 while(p1 != params.end()) {
238 qparam.
fName = p1->first;
247 const std::vector<QBaseModule*>& modList = GetModulesList();
248 if(modIndex <= 0 && modIndex > (
int)modList.size()-1) {
249 Error(
"Module index (%d) out of range",modIndex);
252 const QBaseModule* thisMod = modList[(size_t)modIndex];
253 std::string moduleName = thisMod->GetName();
254 int occurrence = thisMod->GetOccurrence();
255 std::map<std::string,QVdt*> parameters = GetModuleParameters(moduleName,occurrence);
256 std::string parName = newVal.
GetName();
257 std::map<std::string,QVdt*>::iterator thisPar = parameters.find(parName);
258 if(thisPar == parameters.end())
259 Warn(
"Parameter %s not found, setting it anyway",parName.c_str());
260 *(parameters[parName]) = newVal;
265 if( type ==
"QRunData") {
266 SendTObject(&fRunData);
267 }
else if (type ==
"QGlobal") {
268 TMap* data =
new TMap();
269 data->SetName(
"QGlobal");
271 std::vector<QGlobalLabel> labels = fDm->GetWriteLabels();
272 for(
size_t l = 0; l < labels.size(); l++) {
274 const QObject* obj = fDm->GetByLabel(lab);
276 QObject* dobj = obj->Duplicate();
277 obj->FullyFill(dobj);
278 TObjString* strlab =
new TObjString(lab.
GetStringLabel().c_str());
279 data->Add(strlab, dobj);
285 TMap* data =
new TMap();
286 data->SetName(
"QEvent");
288 std::vector<QEventLabel> labels = fEva->GetWriteLabels();
289 for(
size_t l = 0; l < labels.size(); l++) {
291 QObject** obj = fEva->Get(lab.
owner.c_str(),lab.
name.c_str());
293 QObject* dobj = (*obj)->Duplicate();
294 (*obj)->FullyFill(dobj);
295 TObjString* strlab =
new TObjString(lab.
GetStringLabel().c_str());
296 data->Add(strlab, dobj);
#define REGISTER_MODULE(clazz)
driver module for Interactive GUI, interfaced via TSocket with any class inerithing QGDMessageHandler
void ChangeModuleParameter(int modIndex, const QVdt &val)
change module parameter
Action Done()
Done method.
void SendTObject(const TObject *obj)
general purpose function used to send TObjects
Action HandleCommand(QGDCommand cmd)
HandleCommand method. Execute a command.
void ListModuleParameters(int modIndex)
Send List of module parameter.
Action Menu(MenuLevel level)
Menu method. Handle Menu logic.
void SendCommands(MenuLevel level)
Send Avalaible commands to the server.
QGDCommand GetCommand(MenuLevel level)
Get command from standard input.
Action Do(Diana::QEventAssembler &eva)
Do method.
void ListModules()
Send List of avalaible modules.
Action Init(Diana::QEventAssembler &eva)
Init method.
void SendData(const std::string &type)
send data
class to store ActionId and fEventNumber (in case fActionId=ACT_GOTOEV)
Visitor class of QEvent that provides full handling of QEvent.
QEvent & GetEvent()
Get the QEvent.
label for QObject in the QEvent
std::string GetStringLabel() const
get string in the format "owner@name"
std::string owner
owner of the QObject
std::string name
name of the QObject
void Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
std::vector< QGDCommand::Id > fCommands
std::vector< std::string > fModules
std::vector< QGDParameter > fParameters
Label for global QObject's.
std::string GetStringLabel() const
convert label to string
Raw event: bolometer channel, trigger positions and types.
const int & GetChannelId() const
Get ChannelId.
global handle for QRunData
const std::string & GetString() const
std::string GetName() const
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...
QVdt ParameterToQVdt(QGDParameter param)
QGDParameter QVdtToParameter(const QVdt &vdt)