|
@@ -37,6 +37,26 @@ app.on('window-all-closed', () => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+app.on('ready', () => {
|
|
|
+ // 异步
|
|
|
+ ipcMain.on('run-simulation', (event, {obstacle_flag, default_start_flag, default_end_flag, start_point, end_point}) => {
|
|
|
+ const command = 'bash /home/cicv/work/pji_desktop/simulation/run_simulation.sh ' + obstacle_flag + ' ' + default_start_flag + ' ' + default_end_flag +
|
|
|
+ ' ' + start_point + ' ' + end_point;
|
|
|
+ console.log('command:', command);
|
|
|
+ exec(command, (error, stdout, stderr) => {
|
|
|
+ if (error) {
|
|
|
+ console.error(`exec error: ${error}`);
|
|
|
+ event.reply('run-simulation-response', { success: false, message: error.message });
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ console.log(`stdout: ${stdout}`);
|
|
|
+ console.error(`stderr: ${stderr}`);
|
|
|
+ event.reply('run-simulation-response', { success: true, message: 'Run simulation successfully' });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+})
|
|
|
+
|
|
|
app.on('activate', () => {
|
|
|
if (BrowserWindow.getAllWindows().length === 0) {
|
|
|
createWindow();
|
|
@@ -213,34 +233,22 @@ ipcMain.on('start-container', (event, {zip_file_path, image_name, container_name
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-ipcMain.handle('run-simulation', (event, {obstacle_flag, default_start_flag, default_end_flag, start_point, end_point}) => {
|
|
|
- const command = 'bash /home/cicv/work/pji_desktop/simulation/run_simulation.sh ' + obstacle_flag + ' ' + default_start_flag + ' ' + default_end_flag +
|
|
|
- ' ' + start_point + ' ' + end_point;
|
|
|
- console.log('command:', command);
|
|
|
-
|
|
|
- // 异步
|
|
|
- // exec(command, (error, stdout, stderr) => {
|
|
|
- // if (error) {
|
|
|
- // console.error(`exec error: ${error}`);
|
|
|
- // // event.reply('run-simulation-response', { success: false, message: error.message });
|
|
|
- // return { success: false, message: error.message }
|
|
|
- // } else {
|
|
|
- // console.log(`stdout: ${stdout}`);
|
|
|
- // console.error(`stderr: ${stderr}`);
|
|
|
- // return { success: true, message: 'Run simulation successfully' }
|
|
|
- // }
|
|
|
- // });
|
|
|
-
|
|
|
- // 同步
|
|
|
- try {
|
|
|
- const output = execSync(command)
|
|
|
- console.log("output", output.toString());
|
|
|
- return { success: false, message: error.message }
|
|
|
- } catch (error) {
|
|
|
- console.error(`exec error: ${error}`);
|
|
|
- return { success: true, message: 'Run simulation successfully' }
|
|
|
- }
|
|
|
-});
|
|
|
+// 同步
|
|
|
+// ipcMain.handle('run-simulation', (event, {obstacle_flag, default_start_flag, default_end_flag, start_point, end_point}) => {
|
|
|
+// const command = 'bash /home/cicv/work/pji_desktop/simulation/run_simulation.sh ' + obstacle_flag + ' ' + default_start_flag + ' ' + default_end_flag +
|
|
|
+// ' ' + start_point + ' ' + end_point;
|
|
|
+// console.log('command:', command);
|
|
|
+//
|
|
|
+// // 同步
|
|
|
+// try {
|
|
|
+// const output = execSync(command)
|
|
|
+// console.log("output", output.toString());
|
|
|
+// return { success: false, message: error.message }
|
|
|
+// } catch (error) {
|
|
|
+// console.error(`exec error: ${error}`);
|
|
|
+// return { success: true, message: 'Run simulation successfully' }
|
|
|
+// }
|
|
|
+// });
|
|
|
|
|
|
ipcMain.handle('download-file', async (event, { url, fileName, savePath, overwriteFlag }) => {
|
|
|
try {
|