skyeye-sdk-js 1.3.9 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/RequestFactory.d.ts +3 -0
- package/dist/src/RequestFactory.js +26 -0
- package/dist/src/SkyEyeClient.d.ts +5 -0
- package/dist/src/SkyEyeClient.js +74 -2
- package/dist/src/response/RunToTimeResponse.d.ts +4 -0
- package/dist/src/response/RunToTimeResponse.js +10 -0
- package/dist/test.js +23 -380
- package/dist/test_backup1.d.ts +1 -0
- package/dist/test_backup1.js +303 -0
- package/package.json +1 -1
- package/src/RequestFactory.ts +30 -0
- package/src/SkyEyeClient.ts +79 -4
- package/src/response/RunToTimeResponse.ts +9 -0
- package/test.ts +30 -448
- package/test_backup1.ts +365 -0
- package/skyeye-sdk-js-1.3.6.tgz +0 -0
- package/skyeye-sdk-js-1.3.7.tgz +0 -0
- package/skyeye-sdk-js-1.3.8.tgz +0 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const { SkyEyeClientFactory } = require('./src/SkyEyeClientFactory');
|
|
13
|
+
const { SkyEyeClient } = require('./src/SkyEyeClient');
|
|
14
|
+
const { Cpu } = require('./src/models/Cpu');
|
|
15
|
+
class RegisterItem {
|
|
16
|
+
}
|
|
17
|
+
var RegisterType;
|
|
18
|
+
(function (RegisterType) {
|
|
19
|
+
RegisterType[RegisterType["CPU"] = 0] = "CPU";
|
|
20
|
+
RegisterType[RegisterType["Device"] = 1] = "Device";
|
|
21
|
+
})(RegisterType || (RegisterType = {}));
|
|
22
|
+
function getAllRegisterList() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const allRegister = [];
|
|
25
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
26
|
+
//通过 getDeviceTree 获取板卡、设备、寄存器层级, 列出所有寄存器列表选择
|
|
27
|
+
const resultTree = yield client.getDeviceTree();
|
|
28
|
+
console.log("结果 resultTree:", JSON.stringify(resultTree));
|
|
29
|
+
console.log("结果 keys:", resultTree.boardMap.keys());
|
|
30
|
+
for (const key of resultTree.boardMap.keys()) {
|
|
31
|
+
const device = resultTree.boardMap.get(key);
|
|
32
|
+
// 在这里对获取到的键值对进行处理
|
|
33
|
+
console.log(`板卡: ${key},设备: ${device.deviceMap}`);
|
|
34
|
+
if (!device.deviceMap || device.deviceMap.keys().length == 0) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
for (const k of device.deviceMap.keys()) {
|
|
38
|
+
const register = device.deviceMap.get(k);
|
|
39
|
+
console.log(`设备: ${k}, 寄存器: ${register}`);
|
|
40
|
+
console.log("寄存器下的寄存器: ", register.registerMap);
|
|
41
|
+
if (!register.registerMap || register.registerMap.keys().length == 0) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
getRegisterMap(register, allRegister);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
console.log("allRegister2:", allRegister.length);
|
|
48
|
+
return allRegister;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// getAllRegisterList()
|
|
52
|
+
function getRegisterMap(bean, allRegister) {
|
|
53
|
+
if (!bean.registerMap || bean.registerMap.keys().length == 0) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
for (const r of bean.registerMap.keys()) {
|
|
57
|
+
const result = bean.registerMap.get(r);
|
|
58
|
+
console.log(`设备: ${r}, 寄存器: ${result}`);
|
|
59
|
+
const item = new RegisterItem();
|
|
60
|
+
item.name = r.name;
|
|
61
|
+
if (bean instanceof Cpu) {
|
|
62
|
+
console.log(`寄存器类型: ${bean.className}`);
|
|
63
|
+
item.type = RegisterType.CPU;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
item.type = RegisterType.Device;
|
|
67
|
+
}
|
|
68
|
+
allRegister.push(item);
|
|
69
|
+
getRegisterMap(result, allRegister);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function setRegister() {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
75
|
+
const r2 = yield client.setDeviceRegisterValue('c6713_0', 'c67x_core_0', 'A7', '34');
|
|
76
|
+
console.log("setRegister:", r2);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function getRegister() {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
82
|
+
const result = yield client.getCpuRegisters("");
|
|
83
|
+
console.log("setRegister:", result);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function getState() {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
89
|
+
const result = yield client.getCurrentRunningState();
|
|
90
|
+
console.log("getState:", result);
|
|
91
|
+
client.getCurrentCpuMips();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
// getState()
|
|
95
|
+
function getCurrentSimulationTime() {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
98
|
+
const result = yield client.getCurrentSimulationTime();
|
|
99
|
+
console.log("getCurrentCpuMips:", result);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
// getCurrentSimulationTime()
|
|
103
|
+
function run() {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
const client = SkyEyeClientFactory.instance.createClient('192.168.0.187', '52589');
|
|
106
|
+
const result = yield client.runCommand();
|
|
107
|
+
console.log("run:", result);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
// run()
|
|
111
|
+
function setMemoryValue() {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
114
|
+
const result = yield client.setMemoryValue('c67x_core_0', '10000', '15', 2);
|
|
115
|
+
console.log("setMemoryValue:", result);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
// setMemoryValue()
|
|
119
|
+
function getMemoryValue() {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
122
|
+
const result = yield client.getMemoryValue('c67x_core_0', "10000", 2);
|
|
123
|
+
console.log("setMemoryValue:", result);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
// getMemoryValue()
|
|
127
|
+
function testSocket() {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
const json = {
|
|
130
|
+
"msgId": "0",
|
|
131
|
+
"msgTime": "2023-12-5 12:00:00",
|
|
132
|
+
"msgType": "2",
|
|
133
|
+
"msgData": {
|
|
134
|
+
"version": "10001",
|
|
135
|
+
"protocol": "0",
|
|
136
|
+
"direction": "0",
|
|
137
|
+
"bigEndian": "0",
|
|
138
|
+
"length": "0",
|
|
139
|
+
"data": "0"
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const net = require('net');
|
|
143
|
+
const client = new net.Socket();
|
|
144
|
+
const host = '127.0.0.1';
|
|
145
|
+
const port = 8099;
|
|
146
|
+
client.connect(port, host, () => {
|
|
147
|
+
console.log('Connected');
|
|
148
|
+
// const str = JSON.stringify(json)
|
|
149
|
+
// // const str = "hhh"
|
|
150
|
+
// const strBuffer = Buffer.from(str, 'utf8'); // 将字符串转换为 Buffer
|
|
151
|
+
// const strLength = strBuffer.length; // 获取 JSON 数据的长度
|
|
152
|
+
// // 创建一个新的 Buffer 用于存储长度信息和数据
|
|
153
|
+
// const totalLength = 4 + strLength; // 4 字节长度 + 数据长度
|
|
154
|
+
// const buffer = Buffer.alloc(totalLength);
|
|
155
|
+
// // 写入前 4 个字节的长度信息
|
|
156
|
+
// buffer.writeUInt32LE(strLength, 0); // 以小端序方式写入 JSON 数据的长度
|
|
157
|
+
// // 将 JSON 数据复制到 Buffer 中
|
|
158
|
+
// strBuffer.copy(buffer, 4); // 从第 5 个字节开始复制 JSON 数据
|
|
159
|
+
// console.log("Buffer sent:", buffer);
|
|
160
|
+
// console.log("String Length:", strLength); // 打印实际的字符串长度
|
|
161
|
+
// console.log("Hex Length:", strLength.toString(16)); // 打印十六进制表示
|
|
162
|
+
// client.write(buffer); // 发送拼接后的 Buffer
|
|
163
|
+
// 发送数据
|
|
164
|
+
//第一阶段0827测试
|
|
165
|
+
// const hexString = "B90000007B0A09226D73674964223A2230222C0A09226D736754696D65223A22323032332D31322D352031323A30303A3030222C0A09226D736754797065223A2232222C0A09226D736744617461223A7B0A09092276657273696F6E223A2231222C0A09092270726F746F636F6C223A2230222C0A090922646972656374696F6E223A2230222C0A090922626967456E6469616E223A2230222C0A0909226C656E677468223A2230222C0A09092264617461223A2230220A097D0A7D0A";
|
|
166
|
+
const s1 = "12 01 AA 11 BB 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 00 33 33 00 00 00 00 00 00 00 00 44 44 00 00 00 00 00 00 88 88 66 44 00 00 00 00 00 00 00 00 00 00 65 76";
|
|
167
|
+
const s1_1 = s1.replace(/\s+/g, '');
|
|
168
|
+
const hexString = "B90000007B0D0A09226D73674964223A2230222C0D0A09226D736754797065223A2232222C0D0A09226D736754696D65223A22323032332D31322D352031323A30303A3030222C0D0A09226D736744617461223A207B0D0A09092276657273696F6E223A223130303031222C0D0A09092270726F746F636F6C223A2230222C0D0A090922646972656374696F6E223A2230222C0D0A090922626967456E6469616E223A2230222C0D0A0909226C656E677468223A36340D0A097D0D0A7D" + s1_1;
|
|
169
|
+
//74
|
|
170
|
+
// const hexString = "B90000007B0D0A09226D73674964223A2230222C0D0A09226D736754797065223A2232222C0D0A09226D736754696D65223A22323032332D31322D352031323A30303A3030222C0D0A09226D736744617461223A207B0D0A09092276657273696F6E223A223130303031222C0D0A09092270726F746F636F6C223A2230222C0D0A090922646972656374696F6E223A2230222C0D0A090922626967456E6469616E223A2230222C0D0A0909226C656E677468223A37340D0A097D0D0A7D1201AA11BB220000000000000000000000000000FFFF000000003333000000000000000044440000000000008888664400000000000000000000006576";
|
|
171
|
+
console.log("hexString:", hexString);
|
|
172
|
+
console.log("hexString:", hexString.length);
|
|
173
|
+
const buffer2 = Buffer.from(hexString, 'hex');
|
|
174
|
+
console.log("buffer2:", buffer2.length);
|
|
175
|
+
client.write(buffer2);
|
|
176
|
+
});
|
|
177
|
+
client.on('data', (data) => {
|
|
178
|
+
console.log('Received: ' + data);
|
|
179
|
+
client.destroy();
|
|
180
|
+
});
|
|
181
|
+
client.on('close', () => {
|
|
182
|
+
console.log('Connection closed');
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
// testSocket()
|
|
187
|
+
function testgetGlobalVarValue() {
|
|
188
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
189
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50052');
|
|
190
|
+
const response = yield client.getGlobalVarValue("cx53123", "a", 16, "double");
|
|
191
|
+
console.log("testgetGlobalVarValue response:", response);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
// testgetGlobalVarValue()
|
|
195
|
+
function testsetGlobalVarValue() {
|
|
196
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
197
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
198
|
+
const response = yield client.setGlobalVarValueDefault("int_test_var_0", "int", 16);
|
|
199
|
+
console.log("testgetGlobalVarValue response:", response);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
// testsetGlobalVarValue()
|
|
203
|
+
function getDeviceList() {
|
|
204
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
205
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
206
|
+
const response = yield client.getDeviceList();
|
|
207
|
+
// console.log("getDeviceList response:", response)
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
// getDeviceList()
|
|
211
|
+
function getDeviceTree() {
|
|
212
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
213
|
+
// const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
214
|
+
const client = SkyEyeClientFactory.instance.createClient('192.168.0.187', '53774');
|
|
215
|
+
const response = yield client.getDeviceTree();
|
|
216
|
+
console.log("getDeviceList response:", response);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
// getDeviceTree()
|
|
220
|
+
function test() {
|
|
221
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
222
|
+
// console.log("Connected to SkyEye server");
|
|
223
|
+
// await client.getDeviceList();
|
|
224
|
+
// await client.getCurrentCpuMips();
|
|
225
|
+
// await client.runCommand();
|
|
226
|
+
// const response = await client.getCurrentRunningState();
|
|
227
|
+
// const response = await client.getGlobalVarValueDefault("a",GlobalVarType.DOUBLE);
|
|
228
|
+
// const response = await client.getGlobalVarValue("cx53123","a",16,GlobalVarType.DOUBLE);
|
|
229
|
+
// const response = await client.getCpuRegistersDefault();
|
|
230
|
+
// const response = await client.getCpuRegisters("c7xx");
|
|
231
|
+
// const response = await client.getMemoryValueDefault(1, 16);
|
|
232
|
+
// const response = await client.getMemoryValue("c7s",0,16);
|
|
233
|
+
// console.log("结果response:", response)
|
|
234
|
+
// const pathSkyEye = "D:/data/case/workspace_c6713/targets/c6713_fc_1553b";
|
|
235
|
+
// const fileName = "c6713_fc_1553b.skyeye";
|
|
236
|
+
// const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe"
|
|
237
|
+
// const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
238
|
+
// const response =await client.getCurrentRunningState()
|
|
239
|
+
// const response = await client.getMemoryValueDefault("128","4")
|
|
240
|
+
// const response = await client.getGlobalVarValueDefault("number_a","int")
|
|
241
|
+
// const response = await client.setGlobalVarValueDefault("number_a", "int", "12")
|
|
242
|
+
// const response = await client.getDeviceTree()
|
|
243
|
+
// const response = await client.getMemoryValueDefault("10001", "1")
|
|
244
|
+
// console.log("response:", response)
|
|
245
|
+
// console.log("response:", response.boardMap)
|
|
246
|
+
// console.log("response:", response.boardMap.keys[0])
|
|
247
|
+
// await client.initSkyEyeAndRun(pathSkyEye,fileName,port,skyeyeDir);
|
|
248
|
+
const pathSkyEye = "D:/data/case/FMQL45T900_SylixOS";
|
|
249
|
+
const fileName = "FMQL45T900_SylixOS.skyeye";
|
|
250
|
+
const skyeyeDir = "D:/install/SkyEye/opt/skyeye/bin/skyeye.exe";
|
|
251
|
+
const port = "50066";
|
|
252
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', port);
|
|
253
|
+
const t = yield client.initSkyEyeAndRun2(pathSkyEye, fileName, port, skyeyeDir);
|
|
254
|
+
client.runCommand();
|
|
255
|
+
console.log("t:", t);
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
test();
|
|
259
|
+
function testMutil() {
|
|
260
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
261
|
+
const pathSkyEye = "D:/data/case/workspace_c6713/targets/c6713_fc_1553b";
|
|
262
|
+
const fileName = "c6713_fc_1553b.skyeye";
|
|
263
|
+
const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe";
|
|
264
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
265
|
+
//启动多个skyeye
|
|
266
|
+
const count = 5;
|
|
267
|
+
const map = new Map;
|
|
268
|
+
for (let i = 1; i < count; i++) {
|
|
269
|
+
const port = 50050 + i;
|
|
270
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', port.toString());
|
|
271
|
+
yield client.initSkyEyeAndRun2(pathSkyEye, fileName, port.toString(), skyeyeDir);
|
|
272
|
+
// await client.RunTestcase(json)
|
|
273
|
+
yield client.runCommand();
|
|
274
|
+
const res = yield client.getCurrentRunningState();
|
|
275
|
+
console.log("state3:", res.state);
|
|
276
|
+
map.set(port, client);
|
|
277
|
+
}
|
|
278
|
+
for (let i = 1; i < count; i++) {
|
|
279
|
+
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
280
|
+
const port = 50050 + i;
|
|
281
|
+
const client = map.get(port);
|
|
282
|
+
yield client.quitCommand();
|
|
283
|
+
}), i * 5000);
|
|
284
|
+
}
|
|
285
|
+
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
286
|
+
// await map.get(50051).stopGrpcService("")
|
|
287
|
+
yield map.get(50051).quitCommand();
|
|
288
|
+
}), 2000);
|
|
289
|
+
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
290
|
+
// await map.get(50052).stopGrpcService("")
|
|
291
|
+
yield map.get(50052).quitCommand();
|
|
292
|
+
}), 5000);
|
|
293
|
+
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
294
|
+
// await map.get(50053).stopGrpcService("")
|
|
295
|
+
yield map.get(50053).quitCommand();
|
|
296
|
+
}), 8000);
|
|
297
|
+
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
298
|
+
// await map.get(50054).stopGrpcService("")
|
|
299
|
+
yield map.get(50054).quitCommand();
|
|
300
|
+
}), 11000);
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
// testMutil()
|
package/package.json
CHANGED
package/src/RequestFactory.ts
CHANGED
|
@@ -16,6 +16,14 @@ export class RequestFactory {
|
|
|
16
16
|
return this._instance;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
//判断模块是否完全加载成功
|
|
20
|
+
public getModuleStatus() {
|
|
21
|
+
const baseRequest = new BaseRequest("SE_get_modules_loaded_status");
|
|
22
|
+
const request = new JSONRequest()
|
|
23
|
+
request.setRequest(baseRequest.toJSONString());
|
|
24
|
+
return request;
|
|
25
|
+
}
|
|
26
|
+
|
|
19
27
|
|
|
20
28
|
public getRunningStatus() {
|
|
21
29
|
const baseRequest = new BaseRequest("SE_get_running_status");
|
|
@@ -145,6 +153,28 @@ export class RequestFactory {
|
|
|
145
153
|
return request;
|
|
146
154
|
}
|
|
147
155
|
|
|
156
|
+
public getCpuFreq(cpuName: string) {
|
|
157
|
+
const baseRequest = new BaseRequest("SE_get_cpu_freq_hz");
|
|
158
|
+
const args: { [key: string]: string } = {};
|
|
159
|
+
args.cpuname = cpuName;
|
|
160
|
+
baseRequest.setArgs(args)
|
|
161
|
+
const request = new JSONRequest()
|
|
162
|
+
request.setRequest(baseRequest.toJSONString());
|
|
163
|
+
return request;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
public runToTimeRequest(cpuName: string,time:string) {
|
|
167
|
+
const baseRequest = new BaseRequest("SE_run_to_time");
|
|
168
|
+
const args: { [key: string]: string } = {};
|
|
169
|
+
args.cpu_name = cpuName;
|
|
170
|
+
args.time_s = time;
|
|
171
|
+
baseRequest.setArgs(args)
|
|
172
|
+
const request = new JSONRequest()
|
|
173
|
+
request.setRequest(baseRequest.toJSONString());
|
|
174
|
+
return request;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
|
|
148
178
|
|
|
149
179
|
public getCurrentPC(cpuName: string) {
|
|
150
180
|
const baseRequest = new BaseRequest("SE_get_current_pc");
|
package/src/SkyEyeClient.ts
CHANGED
|
@@ -24,6 +24,7 @@ import { SkyEyeSDKException } from './exception/SkyEyeSDKException';
|
|
|
24
24
|
import { ServiceError } from '@grpc/grpc-js';
|
|
25
25
|
import * as cp from 'child_process';
|
|
26
26
|
import { Board } from './models/Board';
|
|
27
|
+
import { BaseResponse } from './response/BaseResponse';
|
|
27
28
|
let client: JSONTransmissionClient | any = null;
|
|
28
29
|
|
|
29
30
|
|
|
@@ -64,6 +65,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
|
|
68
|
+
|
|
67
69
|
public async RunTestcase(json: string) {
|
|
68
70
|
try {
|
|
69
71
|
const request = new JSONRequest();
|
|
@@ -272,6 +274,8 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
272
274
|
}
|
|
273
275
|
|
|
274
276
|
|
|
277
|
+
|
|
278
|
+
|
|
275
279
|
public async getDeviceList() {
|
|
276
280
|
const response = new GetDeviceListResponse();
|
|
277
281
|
try {
|
|
@@ -313,6 +317,25 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
313
317
|
}
|
|
314
318
|
|
|
315
319
|
|
|
320
|
+
public async runToTime(cpuName:string,time:string) {
|
|
321
|
+
try {
|
|
322
|
+
return await this.call(RequestFactory.getInstance().runToTimeRequest(cpuName,time));
|
|
323
|
+
} catch (error) {
|
|
324
|
+
console.error("Error during runToTime:", error);
|
|
325
|
+
throw error;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
public async getCpuFreq(cpuName:string){
|
|
331
|
+
try {
|
|
332
|
+
return await this.call(RequestFactory.getInstance().getCpuFreq(cpuName));
|
|
333
|
+
} catch (error) {
|
|
334
|
+
console.error("Error during getCpuFreq:", error);
|
|
335
|
+
throw error;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
316
339
|
public async getPC(cpuName: string) {
|
|
317
340
|
try {
|
|
318
341
|
return await this.call(RequestFactory.getInstance().getCurrentPC(cpuName));
|
|
@@ -639,6 +662,21 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
639
662
|
}
|
|
640
663
|
|
|
641
664
|
|
|
665
|
+
public async getModuleStatus() {
|
|
666
|
+
const response = new BaseResponse();
|
|
667
|
+
|
|
668
|
+
try {
|
|
669
|
+
const call = await this.call(RequestFactory.getInstance().getModuleStatus())
|
|
670
|
+
// { result: 2, error: null, name: 'SE_get_running_status' }
|
|
671
|
+
if (call != null) {
|
|
672
|
+
response.isSuccess = call.result;
|
|
673
|
+
}
|
|
674
|
+
} catch (error) {
|
|
675
|
+
}
|
|
676
|
+
return response;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
|
|
642
680
|
|
|
643
681
|
public async getCurrentRunningState() {
|
|
644
682
|
const response = new GetRunningStateResponse();
|
|
@@ -905,15 +943,14 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
905
943
|
}, 2000);
|
|
906
944
|
}
|
|
907
945
|
|
|
908
|
-
|
|
909
946
|
private childProcess: cp.ChildProcess | null = null;
|
|
910
947
|
|
|
911
|
-
|
|
912
948
|
public async initSkyEyeAndRun2(pathSkyEye: string, fileName: string, port: string, skyeyeDir: string) {
|
|
913
949
|
try {
|
|
914
950
|
console.log('runExample');
|
|
915
951
|
this.childProcess = await this.startSkyEye(port, skyeyeDir);
|
|
916
952
|
await this.checkState();
|
|
953
|
+
await this.checkModule();
|
|
917
954
|
await this.setWorkingDirectory(pathSkyEye, port);
|
|
918
955
|
await this.runScript(fileName, port);
|
|
919
956
|
return true;
|
|
@@ -927,18 +964,56 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
927
964
|
}
|
|
928
965
|
}
|
|
929
966
|
|
|
967
|
+
private checkModule() {
|
|
968
|
+
return new Promise((resolve, reject) => {
|
|
969
|
+
let flag = true;
|
|
970
|
+
const checkInterval = 500;
|
|
971
|
+
const timeout = 30000;
|
|
972
|
+
const startTime = Date.now();
|
|
973
|
+
|
|
974
|
+
|
|
975
|
+
const check = () => {
|
|
976
|
+
const elapsedTime = Date.now() - startTime;
|
|
977
|
+
if (elapsedTime >= timeout) {
|
|
978
|
+
reject(new Error("Timeout: State check exceeded 30 seconds"));
|
|
979
|
+
return;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
if (!flag) {
|
|
983
|
+
resolve("");
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
this.getModuleStatus()
|
|
987
|
+
.then((result) => {
|
|
988
|
+
if (result.isSuccess) {
|
|
989
|
+
flag = false;
|
|
990
|
+
resolve("");
|
|
991
|
+
} else {
|
|
992
|
+
setTimeout(check, checkInterval);
|
|
993
|
+
}
|
|
994
|
+
})
|
|
995
|
+
.catch(() => {
|
|
996
|
+
setTimeout(check, checkInterval);
|
|
997
|
+
});
|
|
998
|
+
};
|
|
999
|
+
check();
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
|
|
930
1003
|
|
|
931
1004
|
|
|
932
1005
|
private checkState() {
|
|
933
1006
|
return new Promise((resolve, reject) => {
|
|
934
1007
|
let flag = true;
|
|
935
1008
|
const checkInterval = 500;
|
|
936
|
-
const timeout =
|
|
1009
|
+
const timeout = 30000;
|
|
937
1010
|
const startTime = Date.now();
|
|
1011
|
+
|
|
1012
|
+
|
|
938
1013
|
const check = () => {
|
|
939
1014
|
const elapsedTime = Date.now() - startTime;
|
|
940
1015
|
if (elapsedTime >= timeout) {
|
|
941
|
-
reject(new Error("Timeout: State check exceeded
|
|
1016
|
+
reject(new Error("Timeout: State check exceeded 30 seconds"));
|
|
942
1017
|
return;
|
|
943
1018
|
}
|
|
944
1019
|
|