Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
QHyoda.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
23#include <unistd.h>
24#include <signal.h>
25#include <QFileInfo>
26
27#include <QHyoda.h>
28#include <QHyodaJob.h>
29#include <QHyodaIceT.h>
30#include <QHyodaMachine.h>
31#include <QtNetwork/QtNetwork>
32
33// ****************************************************************************
34// * QHyoda class
35// ****************************************************************************
36QHyoda::QHyoda(int argc, char *argv[]):hyodaQuitRequest(false),
37 mainSplitter(NULL),
38 QTabLeft(NULL),
39 QJob(NULL),
40 QTabRight(NULL){
41 const QString localHostName = QHostInfo::localHostName();
42 QHyodaMachine *localhost=new QHyodaMachine(this);
43 hyodaUi();
44 QJob->layout()->addWidget(localhost);
45 QHyodaJob *job = new QHyodaJob(localhost,argc,argv);
46 localhost->layout()->addWidget(job);
47 job->setEnabled(true);
48 setHandlerException();
49}
50
51// ****************************************************************************
52// * ~QHyoda
53// ****************************************************************************
54QHyoda::~QHyoda(void){
55 qDebug() << "QHyoda::~QHyoda DELETE";
56 delete QJob;
57 delete QTabLeft;
58 delete QTabRight;
59 delete mainSplitter;
60}
61
62// ****************************************************************************
63// * setupUi
64// ****************************************************************************
65void QHyoda::hyodaUi(){
66 setupUi(this);
67 resize(2048,1152);
68 //resize(2240,1260);
69 mainSplitter = new QSplitter(Qt::Horizontal, mainWidget);
70 mainSplitter->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
71 verticalLayout->addWidget(mainSplitter);
72 // Le Tab left permet de récupérer l'IHM Mathematica, par exemple
73 QTabLeft = new QTabWidget(mainWidget);
74 QTabLeft->setTabsClosable(true);
75 QTabLeft->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
76 QTabLeft->hide();
77 // Notre central
78 QJob = new QWidget(mainWidget);
79 QVBoxLayout *vbox = new QVBoxLayout;
80 QJob->setLayout(vbox);
81 // Le Tab Right permet de capter les xterms, emacs & co
82 QTabRight = new QTabWidget(mainWidget);
83 QTabRight->setTabsClosable(true);
84 QTabRight->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
85 QTabRight->hide();
86 mainSplitter->addWidget(QTabLeft);
87 mainSplitter->addWidget(QJob);
88 mainSplitter->addWidget(QTabRight);
89 mainSplitter->setSizes(QList<int>()<<128<<512<<128);
90 show();
91}
92
93
94// ****************************************************************************
95// * quit
96// ****************************************************************************
97void QHyoda::quit(void){
98// if (hyodaQuitRequest==false) return;
99/* bool jobed=false;
100 qDebug() << "QHyoda::quit";
101 for(int machineIdx=ui.machines->count();machineIdx>0;--machineIdx){
102 QHyodaMachine *machine=static_cast<QHyodaMachine*>(ui.machines->widget(machineIdx-1));
103 QTabWidget *jobs=(static_cast<QHyodaMachine*>(ui.machines->widget(machineIdx-1)))->jobs;
104 qDebug() << "QHyoda::quit machine"<<machine->name<<":"<<jobs->count()<<"job(s)";
105 for(int jobsIdx=jobs->count();jobsIdx>0;--jobsIdx){
106 QHyodaJob *job= static_cast<QHyodaJob*>(jobs->widget(jobsIdx-1));
107 jobed|=true;
108 }
109 }
110 if (jobed==false){
111 qDebug() << "QHyoda::quit now quit";
112 this->close();
113 }else{
114 qDebug() << "QHyoda::quit not quitting, still people";
115 }*/
116 this->close();
117}
118
119// ****************************************************************************
120// * sigaction & restart
121// ****************************************************************************
122static char *sigAtExitCommand=NULL;
123static void hyodaRestart(void){execlp(sigAtExitCommand,sigAtExitCommand,NULL);}
124void QHyoda::restart(void){
125 atexit(hyodaRestart);
126 QCoreApplication::exit(0);
127}
128
129// ****************************************************************************
130// * sigSegvHandler
131// ****************************************************************************
132static void sigHandler(int sig) {
133 switch (sig){
134 case SIGHUP: qDebug() << "Hangup (POSIX)"; break;
135 case SIGINT:
136 qDebug() << "Interrupt (ANSI)";
137 exit(SIGINT);
138 case SIGQUIT:
139 qDebug() << "Quit (POSIX)";
140 exit(SIGQUIT);
141 case SIGILL: qDebug() << "Illegal instruction (ANSI)"; break;
142 case SIGTRAP: qDebug() << "Trace trap (POSIX)"; break;
143 case SIGABRT: qDebug() << "Abort (ANSI)"; break;
144 case SIGBUS: qDebug() << "BUS error (4.2 BSD)"; break;
145 case SIGFPE: qDebug() << "Floating-point exception (ANSI)"; break;
146 case SIGKILL: qDebug() << "Kill, unblockable (POSIX)"; break;
147 case SIGUSR1: qDebug() << "User-defined signal 1 (POSIX)"; break;
148 case SIGSEGV: qDebug() << "Segmentation violation (ANSI)"; break;
149 case SIGUSR2: qDebug() << "User-defined signal 2 (POSIX)"; break;
150 case SIGPIPE: qDebug() << "Broken pipe (POSIX)"; break;
151 case SIGALRM: qDebug() << " Alarm clock (POSIX)"; break;
152 case SIGTERM: qDebug() << "Termination (ANSI)"; break;
153 case SIGSTKFLT: qDebug() << "Stack fault"; break;
154 case SIGCHLD: qDebug() << "Child status has changed (POSIX)"; break;
155 case SIGCONT: qDebug() << "Continue (POSIX)"; break;
156 case SIGSTOP: qDebug() << "Stop, unblockable (POSIX)"; break;
157 case SIGTSTP: qDebug() << "Keyboard stop (POSIX)"; break;
158 case SIGTTIN: qDebug() << "Background read from tty (POSIX)"; break;
159 case SIGTTOU: qDebug() << "Background write to tty (POSIX)"; break;
160 case SIGURG: qDebug() << "Urgent condition on socket (4.2 BSD)"; break;
161 case SIGXCPU: qDebug() << "CPU limit exceeded (4.2 BSD)"; break;
162 case SIGXFSZ: qDebug() << "File size limit exceeded (4.2 BSD)"; break;
163 case SIGVTALRM: qDebug() << "Virtual alarm clock (4.2 BSD)"; break;
164 case SIGPROF: qDebug() << "Profiling alarm clock (4.2 BSD)"; break;
165 case SIGWINCH: qDebug() << "Window size change (4.3 BSD, Sun)"; break;
166 case SIGPOLL: qDebug() << " Pollable event occurred (System V)"; break;
167 case SIGPWR: qDebug() << "Power failure restart (System V)"; break;
168 case SIGSYS: qDebug() << "Bad system call"; break;
169 default: qDebug() << "Unknown signal";
170 }
171 exit(EXIT_FAILURE);
172}
173
174// ****************************************************************************
175// * Setting our handler exception
176// ****************************************************************************
177void QHyoda::setHandlerException(){
178 struct sigaction sigAction;
179 sigemptyset(&sigAction.sa_mask);
180 sigAction.sa_handler = &sigHandler;
181 sigAction.sa_flags = 0;
182 sigaction(SIGSEGV, &sigAction, 0);
183 sigaction(SIGINT, &sigAction, 0);
184}
QHyoda(int, char **)
Definition QHyoda.cc:36