1 /**************************************************************
3 Copyright (C) 1997 Oskar Swida
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 NOTE: This software is using the free software license of
23 the QT library v.1.30 from Troll Tech AS.
24 See the file LICENSE.QT.
27 To contact the author, write:
28 e-mail: swida@aragorn.pb.bialystok.pl
30 ************************************************************/
32 #include <QtGui/QApplication>
33 #include <QtGui/QMainWindow>
34 #include <QtGui/QTextEdit>
35 #include <QtGui/QMenuBar>
36 #include <QtGui/QMessageBox>
37 #include <QtGui/QFileDialog>
38 #include <QtGui/QDialog>
39 #include <QtCore/QString>
40 #include <QtGui/QLabel>
41 #include <QtGui/QLineEdit>
42 #include <QtGui/QPushButton>
43 #include <QtGui/QRadioButton>
44 #include <QtGui/QGroupBox>
45 #include <QtGui/QVBoxLayout>
46 #include <QtCore/QList>
47 #include <QtGui/QListWidget>
50 #include <QtCore/QSocketNotifier>
51 #include <QtGui/QCloseEvent>
52 #include <QtCore/QDir>
53 #include <QtCore/QProcess>
62 #include <netinet/in.h>
64 #include <libconfig.h>
68 #include "ui/kernelwindow.h"
71 #include "kill_interpreter_dialog.h"
72 #include "connect_dialog.h"
74 #include "vlp/config.h"
76 /* File resides in top directory (where are Makefiles)*/
77 #include "../../config.h"
80 char CharLine[25] = "________________________";
83 * Event invoked on program close.
84 * Closes application. Displays additional window to confirm exit.
86 void QKernel::closeEvent(QCloseEvent * e)
91 on_actionQuit_triggered();
95 void QKernel::setLocked(bool locked)
99 actionQuit->setDisabled(locked);
101 actionExecute->setDisabled(locked);
102 actionKill->setDisabled(locked);
103 actionMessage->setDisabled(locked);
104 actionConnect->setDisabled(locked);
105 actionDisconnect->setDisabled(locked);
106 actionInfo->setDisabled(locked);
109 /* Enable only menu entry for unlocking */
110 actionEditor->setDisabled(locked);
111 actionOptions->setDisabled(locked);
112 actionLock_console->setDisabled(locked);
113 actionUnlock_console->setDisabled(!locked);
117 * Kernel program constructor.
118 * Prepares everything to work.
120 QKernel::QKernel(int argc, char **argv)
124 QString arg0(argv[0]);
126 homeDir = QDir(arg0);
131 for(i = 0; (i < 5) && (i < argc-1); i++) {
132 strcpy(myargs[i], "");
134 strcpy(myargs[i], argv[i+1]);
138 QDir q(getRemoteDir());
141 q.mkpath(getRemoteDir());
144 info_messages = actionInfo_messages->isChecked();
145 wait_for_info = FALSE;
147 setWindowTitle(PACKAGE_NAME);
153 ActiveConnections = 0;
154 strcpy(LockPasswd, "");
156 loadConfig(getConfigFilePath());
160 Net_Notify = new QSocketNotifier(net_sock, QSocketNotifier::Read, this);
161 connect(Net_Notify, SIGNAL(activated(int)), this, SLOT(NetMessage()));
163 WriteMessage("\n " PACKAGE_STRING ": READY \n");
166 QString QKernel::getConfigFilePath()
168 return homeDir.absoluteFilePath("vlp.cfg");
171 const char * QKernel::getHomeDir()
173 return homeDir.absolutePath().toStdString().c_str();
176 const char * QKernel::getRemoteDir()
178 return homeDir.absoluteFilePath(REMOTE_PATH).toStdString().c_str();
181 const char * QKernel::getNetModuleSocket()
183 return homeDir.absoluteFilePath(NPATH).toStdString().c_str();
186 const char * QKernel::getGraphModuleSocket()
188 return homeDir.absoluteFilePath(GPATH).toStdString().c_str();
191 void QKernel::loadConfig(const QString & fname)
193 loadConfig(fname.toStdString().c_str());
196 * Loads configuration from the given file.
197 * @param fname Filename of the configuration file.
199 void QKernel::loadConfig(const char * fname)
201 loglan::vlp::Config config;
202 if(config.load(fname)) {
203 NodeNumber = config.getNodeNumber();
204 ConType = config.getConnectionType();
207 std::vector<std::string> hosts = config.getHosts();
208 for (int i = 0; i < hosts.size(); i++) {
209 ConnectList.append(new ConnectEntry(hosts[i].c_str()));
212 strncpy(progdir, config.getProgramDir(), 256);
218 * Additional window id displayed to set which code to execute.
220 void QKernel::on_actionExecute_triggered()
223 QString s = QFileDialog::getOpenFileName(this, "Execute", progdir, "*.log");
226 i = s.indexOf(".log");
231 // @TODO: if no interpreter is running will result in killing app
232 RunIntModule((char*)s.toAscii().data(), 0);
237 * Invokes editor program
239 void QKernel::on_actionEditor_triggered()
241 QString program = getHomeDir();
242 program += "/modules/logedit";
246 if (execl(program.toStdString().c_str(),
255 WriteMessage("Executing logedit failed!");
259 WriteMessage("fork(logedit) failed!");
260 WriteMessage("Exiting...");
262 on_actionQuit_triggered();
268 * Invokes help program
270 void QKernel::on_actionHelp_triggered()
272 QString program = getHomeDir();
273 program += "/modules/loghelp";
275 QString docDir = getHomeDir();
280 if (execl(program.toStdString().c_str(),
281 docDir.toStdString().c_str(),
290 WriteMessage("Executing loghelp failed!");
294 WriteMessage("fork(loghelp) failed!");
295 WriteMessage("Exiting...");
297 on_actionQuit_triggered();
303 * Invokes graphics module
305 void QKernel::RunGraphModule(char *sk)
309 QString program = getHomeDir();
310 program += "/modules/loggraph";
314 if (execl(program.toStdString().c_str(),
315 program.toStdString().c_str(),
325 WriteMessage("Executing loggraph failed!");
326 WriteMessage("Exiting...");
328 on_actionQuit_triggered();
332 WriteMessage("fork(loggraph) failed!");
333 WriteMessage("Exiting...");
335 on_actionQuit_triggered();
343 void QKernel::RunNetModule()
345 struct sockaddr_un svr;
350 QString program = getHomeDir();
351 program += "/modules/lognet";
355 if (execl(program.toStdString().c_str(),
356 program.toStdString().c_str(),
357 getNetModuleSocket(),
358 getConfigFilePath().toStdString().c_str(),
367 WriteMessage("Executing lognet failed!");
368 WriteMessage("Exiting...");
370 on_actionQuit_triggered();
374 WriteMessage("fork(lognet) failed!");
375 WriteMessage("Exiting...");
377 on_actionQuit_triggered();
381 /* -------- socket for NET module -------- */
382 unlink(getNetModuleSocket());
383 sock = socket(AF_UNIX, SOCK_STREAM, 0);
384 bzero(&svr, sizeof(svr));
385 svr.sun_family = AF_UNIX;
386 strcpy(svr.sun_path, getNetModuleSocket());
387 len = strlen(svr.sun_path) + sizeof(svr.sun_family);
388 bind(sock, (struct sockaddr*)&svr, len);
391 net_sock = accept(sock, (struct sockaddr*)0, (unsigned int*)0);
394 WriteMessage("NETWORK successfully connected");
395 fcntl(net_sock, F_SETFL, O_NONBLOCK|fcntl(net_sock, F_GETFL, 0));
397 setsockopt(net_sock, IPPROTO_TCP, TCP_NODELAY, (char*)&on, sizeof(on));
399 WriteMessage("Cannot connect NETWORK resources");
400 WriteMessage("Exiting...");
402 on_actionQuit_triggered();
407 * Connects to the specified address
408 * Additional window is displayed to connect to the specified address
410 void QKernel::on_actionConnect_triggered()
414 ConnectDialog dialog(this);
415 dialog.setWindowTitle("IP Address:");
418 m.msg_type = MSG_NET;
419 m.param.pword[0] = NET_CONNECT_TO;
420 strcpy(m.param.pstr, dialog.getAddress().toStdString().c_str());
421 write(net_sock, &m, sizeof(MESSAGE));
426 * Disconnects from virtual machine
428 void QKernel::on_actionDisconnect_triggered()
433 WriteMessage("Disconnecting from virtual machine");
435 msg.msg_type = MSG_NET;
436 msg.param.pword[0] = NET_DISCONNECT;
437 write(net_sock, &msg, sizeof(MESSAGE));
441 * Quits process. Closes VLP. Shows additional window to confirm exit.
443 void QKernel::on_actionQuit_triggered()
447 QMessageBox::StandardButton response = QMessageBox::question(this,
450 QMessageBox::Ok | QMessageBox::Cancel
454 if (response == QMessageBox::Cancel) {
458 msg.msg_type = MSG_NET;
459 msg.param.pword[0] = NET_DISCONNECT;
460 write(net_sock, &msg, sizeof(MESSAGE));*/
463 msg.msg_type = MSG_NET;
464 msg.param.pword[0] = NET_EXIT;
465 write(net_sock, &msg, sizeof(MESSAGE));
466 /* ::close(net_sock);*/
467 QApplication::instance()->quit();
471 * Sends message to node.
472 * Additional window is displayed to set Node Number of node where send message,
473 * and textfield to enter message.
475 void QKernel::on_actionMessage_triggered()
481 dlg = new QDialog(this, Qt::Dialog);
482 dlg->setWindowTitle("Send message to node");
484 nodenr = new QLineEdit("number", dlg);
485 nodenr->setGeometry(90, 10, 50, 30);
489 tmpQLabel = new QLabel("Node number:", dlg);
490 tmpQLabel->setGeometry(10, 10, 77, 30);
492 tmpQLabel = new QLabel("Message:", dlg);
493 tmpQLabel->setGeometry(10, 50, 70, 30);
496 msg = new QLineEdit("", dlg);
497 msg->setGeometry(80, 60, 330, 30);
500 ob = new QPushButton("Send", dlg);
501 ob->setGeometry(230, 10, 80, 30);
502 ob->setDefault(TRUE);
505 cb = new QPushButton("Cancel", dlg);
506 cb->setGeometry(330, 10, 80, 30);
507 dlg->resize(430, 110);
508 connect(ob, SIGNAL(clicked()), dlg, SLOT(accept()));
509 connect(cb, SIGNAL(clicked()), dlg, SLOT(reject()));
512 m.msg_type = MSG_NET;
513 m.param.pword[0] = NET_PROPAGATE;
514 m.param.pword[1] = MSG_VLP;
515 m.param.pword[2] = NodeNumber;
516 m.param.pword[4] = atoi(nodenr->text().toAscii().data());
517 m.param.pword[6] = VLP_WRITE;
518 strcpy(m.param.pstr, msg->text().toAscii().data());
519 write(net_sock, &m, sizeof(MESSAGE));
525 * Additional window is displayed to get ID of interpreter which should be
528 void QKernel::on_actionKill_triggered()
530 KillInterpreterDialog dialog(this);
531 dialog.setWindowTitle("Kill interpreter");
534 InterpEntry *interpreter;
537 m.msg_type = MSG_INT;
538 m.param.pword[0] = INT_KILL;
539 interpreter = findINTbyID(dialog.getInterpreterId());
540 if (interpreter != NULL) {
541 if (!(interpreter->remote))
542 write(interpreter->sock, &m, sizeof(MESSAGE));
544 WriteMessage("This is a remote instance of a program!");
547 WriteMessage("Interpreter not found");
553 * Sends message to the net module.
555 void QKernel::NetMessage()
558 /* TODO: It has to be rewritten */
564 cnt = read(net_sock, &msg, sizeof(MESSAGE));
565 if ((cnt > 0) && (msg.msg_type == MSG_NET)) {
566 switch(msg.param.pword[0]) {
568 WriteMessage(msg.param.pstr);
571 switch(msg.param.pword[1]) {
573 /* pom = find_link_by_ID(msg.param.pword[5]);
574 msg.msg_type = MSG_NET;
575 msg.param.pword[0] = NET_PROPAGATE;
576 send_int(pom, &msg);*/
579 switch(msg.param.pword[6]) {
581 QApplication::beep();
582 WriteMessage(CharLine);
584 "### Incoming Messsage ###");
585 sprintf(ss, "Mesg from Node %d: %s",
589 WriteMessage(CharLine);
591 case VLP_REMOTE_INSTANCE:
592 sprintf(ss, "%s/%s", getRemoteDir(),
596 WriteMessage("Running program:");
599 pom = RunIntModule(ss, 1);
601 pom->p_ctx.node = msg.param.pword[2];
602 pom->p_ctx.program_id =
604 pom->RInstances[msg.param.pword[2]] = msg.param.pword[7];
607 case VLP_CLOSE_INSTANCE:
608 msg.msg_type = MSG_INT;
609 msg.param.pword[0] = INT_CLOSE_INSTANCE;
610 pom = findINTbyID(msg.param.pword[7]);
612 write(pom->sock, &msg,
615 m1.msg_type = MSG_VLP;
616 m1.param.pword[0] = VLP_INTERPRETER_DOWN;
617 m1.param.pword[1] = pom->ID;
621 WriteMessage("Instance not found");
627 case NET_CONNECTIONS:
628 ActiveConnections = msg.param.pword[1];
629 WriteMessage(msg.param.pstr);
634 /* TODO: It has to be rewritten */
636 QString poms, poms1, poms2;
637 poms.sprintf("%s", msg.param.pstr);
638 while (poms.length() > 0) {
639 cnt = poms.indexOf(';');
641 poms1 = poms.left(cnt);
642 poms = poms.right(poms.length() - cnt - 1);
643 cnt = poms1.indexOf('=');
645 poms2 = poms1.left(cnt);
646 poms1 = poms1.right(poms1.length() - cnt - 1);
647 sprintf(ss, "Node: %s Addr: %s", poms2.toStdString().c_str(), poms1.toStdString().c_str());
655 wait_for_info = FALSE;
656 WriteMessage(CharLine);
663 * Sends message to the interpreter program.
664 * @param sock Interpreter socket to whom the message will be send.
666 void QKernel::IntMessage(int sock)
672 cnt = read(sock, &msg, sizeof(MESSAGE));
673 e = findINTbySocket(sock);
674 if ((cnt > 0) && (e != NULL)) {
675 switch (msg.msg_type) {
677 if (msg.param.pword[0] == GRAPH_ALLOCATE) {
678 RunGraphModule(msg.param.pstr);
682 write(net_sock, &msg, sizeof(MESSAGE));
685 switch(msg.param.pword[0]) {
686 case VLP_REMOTE_INSTANCE_PLEASE:
687 RemoteInstance(e, msg.param.pword[2]);
692 switch(msg.param.pword[0]) {
697 m.msg_type = MSG_VLP;
698 m.param.pword[0] = VLP_INTERPRETER_DOWN;
699 m.param.pword[1] = e->ID;
700 write(net_sock, &m, sizeof(MESSAGE));
705 /* TODO: Check this */
706 Interpreters.removeOne(e);
710 sprintf(ss, "%s : End of program "
711 "execution", msg.param.pstr);
716 msg.msg_type = MSG_INT;
717 msg.param.pword[0] = INT_CTX;
718 msg.param.pword[1] = NodeNumber;
719 msg.param.pword[2] = e->ID;
721 msg.param.pword[3] = e->p_ctx.node;
725 write(sock, &msg, sizeof(MESSAGE));
734 * Writes message to kernel logger.
735 * @parame msg String with message to log
737 void QKernel::WriteMessage(const char *msg)
741 x = desktop->textCursor().blockNumber();
742 y = desktop->textCursor().columnNumber();
748 desktop->setReadOnly(FALSE);
749 desktop->append(msg);
750 desktop->setReadOnly(TRUE);
752 QTextCursor tmpCursor = desktop->textCursor();
753 tmpCursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
754 desktop->setTextCursor(tmpCursor);
758 if (desktop->document()->blockCount() > 100) {
764 * Adds checkbox to menu item. If it is checked additional info messages are
767 void QKernel::on_actionInfo_messages_triggered()
769 if (toolsMenu != NULL) {
770 info_messages = actionInfo_messages->isChecked();
771 actionInfo_messages->setChecked(info_messages);
776 * Allows to set options in GUI window.
777 * Additional window is displayed to set kernel options which are saved in
778 * vlp.cfg file in kernel executable directory.
780 void QKernel::on_actionOptions_triggered()
782 OptionsDialog optionsDialog(getConfigFilePath(), this);
783 if (optionsDialog.exec()) {
784 optionsDialog.saveConfig(getConfigFilePath());
786 loadConfig(getConfigFilePath());
791 * Locks kernel program.
792 * Additional window is displayed to enter password and retype it. If both are
793 * same kernel window is locked.
795 void QKernel::on_actionLock_console_triggered()
797 LockDialog lockDialog(this);
799 if (lockDialog.exec()) {
800 QString password = lockDialog.getPassword();
801 if (lockDialog.getPassword().size() > 0) {
802 strcpy(LockPasswd, password.toStdString().c_str());
805 if (lockDialog.exec()) {
806 password = lockDialog.getPassword();
807 if (password == LockPasswd) {
809 WriteMessage("CONSOLE LOCKED");
811 QMessageBox msg(this);
812 msg.setText("Not matching!");
813 msg.setButtonText(0, "Close");
815 strcpy(LockPasswd, "");
818 strcpy(LockPasswd, "");
825 * Unlocks kernel program.
826 * Additional window is displayed to enter password. If it is correct, kernel
829 void QKernel::on_actionUnlock_console_triggered()
831 LockDialog lockDialog(this);
833 if (lockDialog.exec()) {
834 QString password = lockDialog.getPassword();
835 if (strcmp(password.toStdString().c_str(), LockPasswd) == 0) {
837 WriteMessage("CONSOLE UNLOCKED");
839 QMessageBox msg(this);
840 msg.setText("Wrong password!");
841 msg.setButtonText(0, "Close");
848 * Finds Interpreter by its socket
849 * @param _id ID of the socket
850 * @return returns pointer to the found interpreter slot. NULL otherwise
852 InterpEntry *QKernel::findINTbySocket(int _id)
854 InterpEntry *pom = NULL;
856 for (int i = 0; i < Interpreters.size(); i++) {
857 if (Interpreters.at(i)->sock == _id) {
858 pom = Interpreters.at(i);
867 * Finds Interpreter by its ID.
868 * @param _id ID of the interpreter
869 * @return returns pointer to the found interpreter slot. NULL otherwise
871 InterpEntry *QKernel::findINTbyID(int _id)
873 InterpEntry *pom = NULL;
875 for (int i = 0; i < Interpreters.size(); i++) {
876 if (Interpreters.at(i)->ID == _id) {
877 pom = Interpreters.at(i);
887 * Connects interpreter
888 * @param ss full filepath with filename but without extension of the loglan
890 * @param r Interpreter execution mode. 0 if it will be local instance, 1 if
892 * @return Returns pointer to newly created interpreter slot, or NULL on error.
894 InterpEntry *QKernel::RunIntModule(char *ss, int r)
897 struct sockaddr_un svr;
904 InterpEntry *newINT = NULL;
910 WriteMessage("File not found: no .ccd file");
919 WriteMessage("File not found: no .pcd file");
924 newINT = new InterpEntry;
925 for(i = 0; i < MAXINSTANCES; i++)
926 newINT->RInstances[i] =- 1;
928 strcpy(b, rindex(ss, '/'));
929 for(i = 0; i < strlen(b); i++)
932 sprintf(a, "%s : Start execution", b);
939 strcpy(newINT->shortname, b);
940 strcpy(newINT->fullname, ss);
942 sprintf(a, "%s%d", IPATH, newint);
943 sprintf(cmd, "%s/modules/logint %s %s",
950 sprintf(b, " %s %s %s %s %s",
951 myargs[0], myargs[1], myargs[2], myargs[3], myargs[4]);
955 sock = socket(AF_UNIX, SOCK_STREAM, 0);
957 bzero(&svr, sizeof(svr));
958 svr.sun_family = AF_UNIX;
959 strcpy(svr.sun_path, a);
960 len = strlen(svr.sun_path)+sizeof(svr.sun_family);
961 bind(sock, (struct sockaddr*)&svr, len);
964 newINT->sock = accept(sock, (struct sockaddr*)0, (unsigned int *)0);
967 if (newINT->sock > 0) {
968 fcntl(newINT->sock, F_SETFL,
969 O_NONBLOCK|fcntl(newINT->sock, F_GETFL, 0));
971 setsockopt(newINT->sock, IPPROTO_TCP, TCP_NODELAY, (char*)&on,
978 bzero(&msg, sizeof(MESSAGE));
979 msg.msg_type = MSG_VLP;
980 msg.param.pword[0] = VLP_REGINT;
981 msg.param.pword[1] = newINT->ID;
982 sprintf(msg.param.pstr, "logi%d.net", newint);
983 write(net_sock, &msg, sizeof(MESSAGE));
985 Interpreters.append(newINT);
986 newINT->notify = new QSocketNotifier(newINT->sock,
987 QSocketNotifier::Read);
988 connect(newINT->notify, SIGNAL(activated(int)), this,
989 SLOT(IntMessage(int)));
991 WriteMessage("INTERPRETER successfully connected");
993 WriteMessage("Cannot connect interpreter");
1000 * Allocates remote instance of interpreter
1001 * @param interp Interpreter slot
1002 * @param on Node Number
1004 void QKernel::RemoteInstance(InterpEntry *interp, int on)
1009 m.msg_type = MSG_NET;
1010 m.param.pword[0] = NET_NODE_EXIST;
1011 m.param.pword[1] = on;
1012 m.param.pword[2] = interp->ID;
1013 write(net_sock, &m, sizeof(MESSAGE));
1014 bzero(&m, sizeof(MESSAGE));
1015 while((m.msg_type!=MSG_NET) && (m.param.pword[0]!=NET_NODE_EXIST))
1016 read(net_sock, &m, sizeof(MESSAGE));
1018 /* means node exists */
1019 if (m.param.pword[1] == 1) {
1020 m.msg_type = MSG_NET;
1021 m.param.pword[0] = NET_TRANSMIT_CODE;
1022 m.param.pword[1] = interp->ID;
1023 m.param.pword[2] = on;
1024 strcpy(m.param.pstr, interp->fullname);
1025 write(net_sock, &m, sizeof(MESSAGE));
1027 Net_Notify->setEnabled(FALSE);
1028 while ((m.msg_type != MSG_NET) ||
1029 (m.param.pword[0] != NET_TRANSMITTED))
1030 read(net_sock, &m, sizeof(MESSAGE));
1032 m.msg_type = MSG_NET;
1033 m.param.pword[0] = NET_PROPAGATE;
1034 m.param.pword[1] = MSG_VLP;
1035 m.param.pword[2] = NodeNumber;
1036 m.param.pword[3] = 0;
1037 m.param.pword[4] = on;
1038 m.param.pword[5] = 0;
1039 m.param.pword[6] = VLP_REMOTE_INSTANCE;
1040 m.param.pword[7] = interp->ID;
1041 strcpy(m.param.pstr, interp->shortname);
1042 write(net_sock, &m, sizeof(MESSAGE));
1044 read(net_sock, &m, sizeof(MESSAGE));
1046 if ((m.param.pword[0] == NET_PROPAGATE) &&
1047 (m.param.pword[6] == VLP_REMOTE_INSTANCE_OK)) {
1048 interp->RInstances[on] = m.param.pword[7];
1051 read(net_sock, &m, sizeof(MESSAGE));
1054 Net_Notify->setEnabled(TRUE);
1056 /*bzero(&m, sizeof(MESSAGE));*/
1057 m.msg_type = MSG_VLP;
1058 m.param.pword[0] = VLP_REMOTE_INSTANCE_HERE;
1059 m.param.pword[1] = interp->RInstances[on];
1060 write(interp->sock, &m, sizeof(MESSAGE));
1061 } else { /* There is no such a node! */
1062 sprintf(s, "Warning: Node number %d not found!", on);
1064 WriteMessage("Allocating O-process on the local node");
1065 bzero(&m, sizeof(MESSAGE));
1066 m.msg_type = MSG_VLP;
1067 m.param.pword[0] = VLP_REMOTE_INSTANCE_HERE;
1068 m.param.pword[1] = interp->ID;
1069 write(interp->sock, &m, sizeof(MESSAGE));
1074 * Closes all remote instances
1076 void QKernel::CloseInstances(InterpEntry *e)
1082 WriteMessage("Closing remote instances");
1084 for(i=0; i < MAXINSTANCES; i++)
1085 if (e->RInstances[i]>=0) {
1086 msg.msg_type = MSG_NET;
1087 msg.param.pword[0] = NET_PROPAGATE;
1088 msg.param.pword[1] = MSG_VLP;
1089 msg.param.pword[2] = NodeNumber;
1090 msg.param.pword[4] = i;
1091 msg.param.pword[6] = VLP_CLOSE_INSTANCE;
1092 msg.param.pword[7] = e->RInstances[i];
1093 write(net_sock, &msg, sizeof(MESSAGE));
1098 * Displays information about virtual machine
1100 void QKernel::on_actionInfo_triggered()
1104 WriteMessage(CharLine);
1105 WriteMessage("### Virtual Machine Information ###");
1106 m.msg_type = MSG_NET;
1107 m.param.pword[0] = NET_GET_INFO;
1108 write(net_sock, &m, sizeof(MESSAGE));
1109 wait_for_info = TRUE;
1113 * Program main function
1114 * All program arguments but the first one (argv[0]: program name) are saved and
1115 * passed to all dependent programs on their invocation.
1116 * @param argc Number of program arguments
1117 * @param argv Program arguments
1119 int main(int argc, char **argv)
1123 QApplication * app = new QApplication(argc, argv);
1124 QKernel kernel(argc, argv);