Commit 6197c9ea authored by LIGNEUL CLEMENT's avatar LIGNEUL CLEMENT
Browse files

Merge branch 'compile_tab_options' into 'master'

Compilation tab ok

See merge request !1
parents be993274 9406955e
......@@ -3,18 +3,32 @@ import { Pseudo_term } from './pseudo_term';
import { Win_alert } from './win_alert';
import { run_obj } from './index';
import * as util from './utilities';
import { QWidget } from '@nodegui/nodegui';
import { QCheckBox, QWidget } from '@nodegui/nodegui';
export class Compile {
ez_file_address: string;
dir_path: string;
ready: Number;
options: string;
cuda = false;
gp = false;
cuda_gp = false;
nsgaii = false;
nsgaiii = false;
asrea = false;
ibea = false;
cdas = false;
memetic = false;
cmaes = false;
verbose = false;
true_line = false;
constructor(ez_file: string, dir: string){
this.ez_file_address = ez_file;
this.dir_path = dir;
this.ready = 0;
this.options = '';
}
generate_compile_tab(){
......@@ -23,53 +37,106 @@ export class Compile {
// output terminal
const output_compile = new Pseudo_term('Output :');
// option 1
const param1 = new QComboBox();
var p = '';
param1.setFixedSize(100, 25);
param1.addItem(undefined, 'Option 1');
// test if we can use CUDA
if(output_compile.run_command("nvcc", ["--version"]) !== -1){
param1.addItem(undefined, 'cuda');
} else {
new Win_alert("CUDA option is not available");
}
param1.addItem(undefined, 'gp');
param1.addItem(undefined, 'cuda_gp');
param1.addItem(undefined, 'nsgaii');
param1.addItem(undefined, 'nsgaiii');
param1.addItem(undefined, 'asrea');
param1.addItem(undefined, 'ibea');
param1.addItem(undefined, 'cdas');
param1.addItem(undefined, 'memetic');
param1.addItem(undefined, 'cmaes');
param1.addEventListener('currentTextChanged', (val:string) => {
if(val === "Option 1"){
p = '';
} else {
p = '-'.concat(val);
}
// grid of options
const option_layout = new QGridLayout();
const option_widget = new QWidget();
option_widget.setLayout(option_layout);
const label_mode = new QLabel();
label_mode.setText('Compilation options :');
const misc_label = new QLabel();
misc_label.setText('Miscellaneous options :')
const check_gp = new QCheckBox();
check_gp.setText('gp');
check_gp.addEventListener('stateChanged', ()=>{
this.gp = !this.gp;
});
// option 2
const param2 = new QComboBox();
param2.setFixedSize(100, 25);
var p2 = '';
param2.addItem(undefined, 'Option 2');
param2.addItem(undefined, 'v');
param2.addItem(undefined, 'tl');
param2.addEventListener('currentTextChanged', (val:string) => {
if(val === "Option 2"){
p2 = '';
} else {
p2 = '-'.concat(val);
}
const check_cuda = new QCheckBox();
check_cuda.setText('cuda');
check_cuda.addEventListener('stateChanged', ()=>{
this.cuda = !this.cuda;
});
const check_cuda_gp = new QCheckBox();
check_cuda_gp.setText('cuda_gp');
check_cuda_gp.addEventListener('stateChanged', ()=>{
this.cuda_gp = !this.cuda_gp;
});
const check_nsgaii = new QCheckBox();
check_nsgaii.setText('nsgaii');
check_nsgaii.addEventListener('stateChanged', ()=>{
this.nsgaii = !this.nsgaii;
});
const check_nsgaiii = new QCheckBox();
check_nsgaiii.setText('nsgaiii');
check_nsgaiii.addEventListener('stateChanged', ()=>{
this.nsgaiii = !this.nsgaiii;
});
const check_asrea = new QCheckBox();
check_asrea.setText('asrea');
check_asrea.addEventListener('stateChanged', ()=>{
this.asrea = !this.asrea;
});
const check_ibea = new QCheckBox();
check_ibea.setText('ibea');
check_ibea.addEventListener('stateChanged', ()=>{
this.ibea = !this.ibea;
});
const check_cdas = new QCheckBox();
check_cdas.setText('cdas');
check_cdas.addEventListener('stateChanged', ()=>{
this.cdas = !this.cdas;
});
const check_memetic = new QCheckBox();
check_memetic.setText('memetic');
check_memetic.addEventListener('stateChanged', ()=>{
this.memetic = !this.memetic;
});
const check_cmaes = new QCheckBox();
check_cmaes.setText('cmaes');
check_cmaes.addEventListener('stateChanged', ()=>{
this.cmaes = !this.cmaes;
});
const check_v = new QCheckBox();
check_v.setText('verbose mode');
check_v.addEventListener('stateChanged', ()=>{
this.verbose = !this.verbose;
});
const check_tl = new QCheckBox();
check_tl.setText('true line mode');
check_tl.addEventListener('stateChanged', ()=>{
this.true_line = !this.true_line;
});
option_layout.addWidget(label_mode, 0,0);
option_layout.addWidget(check_gp, 1,0);
option_layout.addWidget(check_cuda, 1,1);
option_layout.addWidget(check_cuda_gp, 1,2);
option_layout.addWidget(check_nsgaii, 1,3);
option_layout.addWidget(check_nsgaiii, 1,4);
option_layout.addWidget(check_asrea, 2,0);
option_layout.addWidget(check_ibea, 2,1);
option_layout.addWidget(check_cdas, 2,2);
option_layout.addWidget(check_memetic, 2,3);
option_layout.addWidget(check_cmaes, 2,4);
option_layout.addWidget(misc_label, 3,0);
option_layout.addWidget(check_v, 4,0);
option_layout.addWidget(check_tl, 4,1);
option_layout.setSpacing(15);
// compile button
const compile_btn = new QPushButton();
compile_btn.setText("Compile");
......@@ -78,17 +145,58 @@ export class Compile {
if(this.ez_file_address === ''){
new Win_alert("Please load a file");
} else {
// avoid problems by disabling all buttons
option_widget.setEnabled(false);
compile_btn.setEnabled(false);
make_clean_btn.setEnabled(false);
file_select.setEnabled(false);
file_select.setEnabled(false);
var dir_path = util.get_path(this.ez_file_address);
// options to compile
var params = [util.get_file_name(this.ez_file_address)];
if(this.cuda)
params.push('-cuda');
if(this.gp)
params.push('-gp');
if(this.cuda_gp)
params.push('-cuda_gp');
if(this.nsgaii)
params.push('-nsgaii');
if(this.nsgaiii)
params.push('-nsgaiii');
if(this.asrea)
params.push('-asrea');
if(this.ibea)
params.push('-ibea');
if(this.cdas)
params.push('-cdas');
if(this.memetic)
params.push('-memetic');
if(this.cmaes)
params.push('-cmaes');
if(this.verbose)
params.push('-v');
if(this.true_line)
params.push('-tl');
// makefile address
var ez_makefile = this.ez_file_address.substring(0, this.ez_file_address.length-2);
ez_makefile = ez_makefile.concat('mak');
var run = output_compile.compile('/usr/local/easena/bin/easena', [this.ez_file_address, p, p2], dir_path);
var run = output_compile.compile('/usr/local/easena/bin/easena', params, dir_path);
run.stdout.on('data', (data) => {
output_compile.text.insertPlainText(data.toString());
......@@ -109,6 +217,7 @@ export class Compile {
make_clean_btn.setEnabled(true);
file_select.setEnabled(true);
compile_btn.setEnabled(true);
option_widget.setEnabled(true);
});
} else {
......@@ -116,9 +225,11 @@ export class Compile {
make_clean_btn.setEnabled(true);
file_select.setEnabled(true);
compile_btn.setEnabled(true);
option_widget.setEnabled(true);
}
});
}
this.options = '';
});
// make clean button
......@@ -150,7 +261,7 @@ export class Compile {
const file_loaded = new QLabel();
// file dialog
// load file dialog
const file_select = new QPushButton();
file_select.setText("Load a file");
file_select.setFixedSize(100, 25);
......@@ -179,15 +290,6 @@ export class Compile {
hbox_load.setStretch(1, 1);
widget_load.setLayout(hbox_load);
// params box
const widget_param = new QWidget();
const hbox_param = new QBoxLayout(0);
hbox_param.addWidget(param1);
hbox_param.addWidget(param2);
hbox_param.setStretch(0, 10);
hbox_param.setStretch(1, 10);
widget_param.setLayout(hbox_param);
// compile box
const widget_comp = new QWidget();
const hbox_comp = new QBoxLayout(0);
......@@ -199,7 +301,7 @@ export class Compile {
global_layout.addWidget(widget_load);
global_layout.addWidget(file_select);
global_layout.addWidget(widget_param);
global_layout.addWidget(option_widget);
global_layout.addWidget(widget_comp);
global_layout.addWidget(output_compile.window);
......
const { QGridLayout } = require("@nodegui/nodegui");
import { QPlainTextEdit, QWidget, QLabel, QPushButton } from '@nodegui/nodegui';
import { ChildProcess, spawn } from 'child_process';
import { spawn } from 'child_process';
import { spawnSync } from 'child_process';
import { inherits } from 'util';
import { running_proc } from '.';
import {Win_alert} from './win_alert';
......@@ -64,15 +63,14 @@ export class Pseudo_term{
console.log('$ ' + command + ' ' + res + '\n');
}
}
process.env.EZ_PATH = "/usr/local/easena/"
var child = spawn(command, array_params,{
cwd: dir,
env: process.env
});
child.stdout.pipe(process.stdout);
// child.stdout.pipe(process.stdout);
// handle error in spawn
child.on('error', function(err) {
......
......@@ -57,7 +57,7 @@ export class Run_tab {
const run_btn = new QPushButton();
run_btn.setText("Run !");
run_btn.setFixedSize(200, 25);
run_btn.addEventListener('clicked', async () => {
run_btn.addEventListener('clicked', () => {
if(this.ready === 0){
new Win_alert('Please compile your file before run', 'Run error');
return;
......@@ -78,7 +78,6 @@ export class Run_tab {
// if first seed not set
if(isNaN(this.option_obj.seed)){
console.log('42');
if(!isNaN(this.option_obj.proc_tab[i].seed_value)){
options = this.options.concat(' --seed ' + this.option_obj.proc_tab[i].seed_value.toString());
} else {
......@@ -86,11 +85,13 @@ export class Run_tab {
seed_cpt += 1;
}
} else {
console.log('43');
options = this.options.concat(' --seed ' + (this.option_obj.seed + seed_cpt).toString());
seed_cpt += 1;
}
if(i !== 0)
options = options.concat(' --plotStats 0');
var run = output_run.run(cmd, options, this.dir_path);
if(i === 0){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment