Skip to content

Commit 88b9ec9

Browse files
author
stevevista
committed
run qia only in process
1 parent f4fb805 commit 88b9ec9

File tree

13 files changed

+172
-287
lines changed

13 files changed

+172
-287
lines changed

.electron/webpack.renderer.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ const rendererConfig = {
8787
loader: 'babel-loader',
8888
options: {
8989
presets: ['@babel/react', '@babel/env'],
90-
plugins: ['@babel/plugin-proposal-class-properties']
90+
plugins: [
91+
'@babel/plugin-proposal-class-properties',
92+
["import", { "libraryName": "antd", "libraryDirectory": "es", "style": true }]
93+
]
9194
}
9295
}
9396
],

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
11
## Qualcomm interface node demo
2+
3+
* integret electron with react/vue/d3
4+
* scripting Qualocmm QDART QLib/QSPR Interface
5+
6+
## setup
7+
```
8+
cd qshell
9+
npm i
10+
npm run rebuild
11+
npm run dev
12+
```
13+
14+
## build
15+
```
16+
npm run build
17+
```

package-lock.json

Lines changed: 11 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,31 +68,20 @@
6868
"@babel/preset-env": "^7.1.0",
6969
"@babel/preset-react": "^7.0.0",
7070
"@babel/runtime": "^7.1.2",
71-
"babel-minify-webpack-plugin": "^0.3.1",
7271
"babel-eslint": "^10.0.1",
7372
"babel-loader": "^8.0.4",
73+
"babel-minify-webpack-plugin": "^0.3.1",
74+
"babel-plugin-import": "^1.10.0",
7475
"chalk": "^2.4.1",
76+
"clean-webpack-plugin": "^0.1.19",
77+
"copy-webpack-plugin": "^4.5.2",
78+
"css-loader": "^1.0.0",
7579
"del": "^3.0.0",
7680
"electron": "^2.0.11",
7781
"electron-builder": "^20.28.4",
7882
"electron-debug": "^2.0.0",
7983
"electron-rebuild": "^1.8.2",
8084
"eslint": "^5.7.0",
81-
"less": "^3.8.1",
82-
"webpack": "^4.20.2",
83-
"webpack-dev-server": "^3.1.9",
84-
"webpack-hot-middleware": "^2.24.3",
85-
"file-loader": "^2.0.0",
86-
"html-webpack-plugin": "^3.2.0",
87-
"less-loader": "^4.1.0",
88-
"mini-css-extract-plugin": "^0.4.3",
89-
"multispinner": "^0.2.1",
90-
"clean-webpack-plugin": "^0.1.19",
91-
"copy-webpack-plugin": "^4.5.2",
92-
"css-loader": "^1.0.0",
93-
"node-loader": "^0.6.0",
94-
"optimize-css-assets-webpack-plugin": "^5.0.1",
95-
"url-loader": "^1.1.1",
9685
"eslint-config-standard": "^12.0.0",
9786
"eslint-friendly-formatter": "^4.0.1",
9887
"eslint-loader": "^2.1.1",
@@ -102,8 +91,20 @@
10291
"eslint-plugin-promise": "^4.0.1",
10392
"eslint-plugin-react": "^7.11.1",
10493
"eslint-plugin-standard": "^4.0.0",
94+
"file-loader": "^2.0.0",
95+
"html-webpack-plugin": "^3.2.0",
96+
"less": "^3.8.1",
97+
"less-loader": "^4.1.0",
98+
"mini-css-extract-plugin": "^0.4.3",
99+
"multispinner": "^0.2.1",
100+
"node-loader": "^0.6.0",
101+
"optimize-css-assets-webpack-plugin": "^5.0.1",
102+
"url-loader": "^1.1.1",
105103
"vue-loader": "^15.4.2",
106104
"vue-template-compiler": "^2.5.17",
105+
"webpack": "^4.20.2",
106+
"webpack-dev-server": "^3.1.9",
107+
"webpack-hot-middleware": "^2.24.3",
107108
"yml-loader": "^2.1.0"
108109
},
109110
"dependencies": {

src/main/handlers/qspr.js

Lines changed: 26 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,8 @@
1-
import {Scheduler, XTTStructParser} from 'qia'
2-
import {dialog} from 'electron'
1+
import {XTTStructParser} from 'qia'
32
import log from 'electron-log'
4-
// import cluster from 'cluster'
53
import { startProcess } from '../processes'
64

7-
let win
8-
const runners = []
9-
const procs = []
10-
11-
class Runner {
12-
constructor (id) {
13-
const object = new Scheduler(id)
14-
15-
object.on('TEST_START', (msg) => {
16-
if (win) {
17-
win.send('xttRunMsg', 'test_start', msg)
18-
}
19-
})
20-
21-
object.on('TEST_RESULT', (msg) => {
22-
if (win) {
23-
win.send('xttRunMsg', 'test_result', msg)
24-
}
25-
})
26-
27-
object.on('UNIT_START', (msg) => {
28-
if (win) {
29-
msg.xttPath = object.openedXttPath()
30-
win.send('xttRunMsg', 'unit_start', msg)
31-
}
32-
})
33-
34-
object.on('UNIT_END', (msg) => {
35-
if (win) {
36-
win.send('xttRunMsg', 'unit_end', msg)
37-
}
38-
})
39-
40-
object.on('FOLDER_START', (msg) => {
41-
if (win) {
42-
win.send('xttRunMsg', 'folder_start', msg)
43-
}
44-
})
45-
46-
object.on('FOLDER_END', (msg) => {
47-
if (win) {
48-
win.send('xttRunMsg', 'folder_end', msg)
49-
}
50-
})
51-
52-
this.object = object
53-
}
54-
55-
async runXTT (pathname) {
56-
let testTree
57-
try {
58-
if (this.object.openedXttPath() === pathname) {
59-
testTree = this.object.tree
60-
} else {
61-
testTree = await this.object.openXTT(pathname)
62-
}
63-
await testTree.runTree()
64-
} catch (e) {
65-
log.error(e)
66-
}
67-
}
68-
}
5+
const procs = {}
696

707
function loadStrucure (pathname, evt) {
718
return new Promise((resolve, reject) => {
@@ -99,74 +36,41 @@ function loadStrucure (pathname, evt) {
9936
})
10037
}
10138

102-
try {
103-
runners.push(new Runner(0))
104-
} catch (e) {
105-
log.error(e)
106-
}
107-
108-
const executeXTT = (evt, optinos, counts) => {
109-
if (runners.length === 0) {
110-
evt.sender.send('xttRunError', 'not-installed')
111-
return
112-
}
113-
39+
const executeXTT = async (evt, xttPath, counts) => {
11440
if (typeof counts !== 'number') {
11541
counts = 1
11642
}
11743

118-
dialog.showOpenDialog({
119-
properties: ['openFile'],
120-
filters: [{name: 'XTT file', extensions: ['xtt']}]
121-
}, async filePaths => {
122-
if (!filePaths) {
123-
return
124-
}
125-
126-
win = evt.sender
127-
if (optinos.includes('preload')) {
128-
await loadStrucure(filePaths[0], evt)
129-
}
44+
await loadStrucure(xttPath, evt)
13045

131-
if (optinos.includes('process')) {
132-
while (procs.length > 0) {
133-
procs.pop()
46+
for (let i = 0; i < counts; i++) {
47+
const proc = startProcess('qspr', xttPath)
48+
proc.on('message', data => {
49+
if (data.type === 'run-result') {
50+
evt.sender.send('xttRunMsg', i, data.runType, data.msg)
51+
} else if (data.type === 'error') {
52+
log.error(i, data.error)
13453
}
135-
for (let i = 0; i < counts; i++) {
136-
const proc = startProcess('qspr', filePaths[0], i)
137-
proc.on('message', data => {
138-
evt.sender.send('xttRunMsg', data.type, data.msg)
139-
})
140-
procs.push(proc)
141-
}
142-
} else {
143-
runners[0].runXTT(filePaths[0])
144-
if (counts > 1) {
145-
for (let i = 1; i < counts; i++) {
146-
if (runners.length < (i + 1)) {
147-
runners.push(new Runner(i))
148-
}
149-
runners[i].runXTT(filePaths[0])
150-
}
54+
})
55+
proc.on('exit', () => {
56+
console.log('qia exit')
57+
if (procs[i] === proc) {
58+
delete procs[i]
15159
}
152-
}
153-
154-
/*
155-
if (style === 'multiple') {
156-
runner.runXTT(filePaths[0])
157-
runner1.runXTT(filePaths[0])
158-
}
159-
*/
160-
})
60+
})
61+
procs[i] = proc
62+
}
16163
}
16264

16365
const stopXTT = async (evt, optinos) => {
164-
for (const r of runners) {
165-
if (r.object && r.object.tree) {
166-
await r.object.tree.stopTest()
167-
console.log('stopped')
168-
}
66+
for (const k in procs) {
67+
procs[k].send({type: 'stop'})
16968
}
69+
setTimeout(() => {
70+
for (const k in procs) {
71+
procs[k].send({type: 'exit'})
72+
}
73+
}, 3000)
17074
}
17175

17276
export default {

src/main/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ if (process.env.NODE_ENV !== 'development') {
88
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
99
}
1010

11-
let proceesRoutnie = captureProcessRequest()
12-
13-
if (!proceesRoutnie) {
11+
if (!captureProcessRequest()) {
1412
require('./start')
1513
}

src/main/processes/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function captureProcessRequest () {
66
if (i + 1 < process.argv.length) {
77
const name = process.argv[i + 1]
88
const args = process.argv.slice(i + 2)
9-
require(`./${name}`).default(args)
9+
require(`./${name}`).default(...args)
1010
return true
1111
}
1212
}

0 commit comments

Comments
 (0)