skyeye-sdk-js 1.1.1 → 1.1.3
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 +6 -6
- package/dist/src/RequestFactory.js +5 -5
- package/dist/src/SkyEyeClient.d.ts +16 -16
- package/dist/src/SkyEyeClient.js +15 -4
- package/dist/src/models/FaultInjectItem.d.ts +2 -2
- package/dist/src/models/FaultInjectItemInterface.d.ts +2 -2
- package/dist/src/models/Register.d.ts +4 -4
- package/dist/src/models/RegisterInterface.d.ts +4 -4
- package/dist/test.js +30 -13
- package/package.json +1 -1
- package/src/GrpcUtil.js +91 -0
- package/src/RequestFactory.js +259 -0
- package/src/RequestFactory.ts +11 -13
- package/src/SkyEyeClient.js +1272 -0
- package/src/SkyEyeClient.ts +34 -23
- package/src/models/FaultInjectItem.ts +2 -2
- package/src/models/FaultInjectItemInterface.ts +2 -2
- package/src/models/Register.ts +4 -4
- package/src/models/RegisterInterface.ts +4 -4
- package/src/requests/BaseRequest.js +19 -0
- package/src/response/BaseResponse.js +27 -0
- package/test.ts +24 -6
|
@@ -0,0 +1,1272 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.SkyEyeClient = void 0;
|
|
55
|
+
var grpc = require("@grpc/grpc-js");
|
|
56
|
+
var skyeye_rpc_pb_1 = require("./proto/skyeye_rpc_pb");
|
|
57
|
+
var skyeye_rpc_grpc_pb_1 = require("./proto/skyeye_rpc_grpc_pb");
|
|
58
|
+
var RequestFactory_1 = require("./RequestFactory");
|
|
59
|
+
var GetCpuListResponse_1 = require("./response/GetCpuListResponse");
|
|
60
|
+
var Cpu_1 = require("./models/Cpu");
|
|
61
|
+
var GetDeviceListResponse_1 = require("./response/GetDeviceListResponse");
|
|
62
|
+
var GetRunningStateResponse_1 = require("./response/GetRunningStateResponse");
|
|
63
|
+
var Register_1 = require("./models/Register");
|
|
64
|
+
var GetDeviceTreeResponse_1 = require("./response/GetDeviceTreeResponse");
|
|
65
|
+
var ParseBoardUtils_1 = require("./utils/ParseBoardUtils");
|
|
66
|
+
var GetAllDeviceInfoResponse_1 = require("./response/GetAllDeviceInfoResponse");
|
|
67
|
+
var GetRamAddrInfoResponse_1 = require("./response/GetRamAddrInfoResponse");
|
|
68
|
+
var Device_1 = require("./models/Device");
|
|
69
|
+
var FaultInjectType_1 = require("./models/FaultInjectType");
|
|
70
|
+
var FaultInjectItem_1 = require("./models/FaultInjectItem");
|
|
71
|
+
var GetFaultInjectListResponse_1 = require("./response/GetFaultInjectListResponse");
|
|
72
|
+
var GetDisassembleInfoResponse_1 = require("./response/GetDisassembleInfoResponse");
|
|
73
|
+
var InstructionItem_1 = require("./models/InstructionItem");
|
|
74
|
+
var GetCpuRegisterInfoResponse_1 = require("./response/GetCpuRegisterInfoResponse");
|
|
75
|
+
var SkyEyeSDKException_1 = require("./exception/SkyEyeSDKException");
|
|
76
|
+
var cp = require("child_process");
|
|
77
|
+
var client = null;
|
|
78
|
+
// ----------------------------当前运行程序的设备树----------------------------------------//
|
|
79
|
+
var boardMap = new Map();
|
|
80
|
+
var SkyEyeClient = /** @class */ (function (_super) {
|
|
81
|
+
__extends(SkyEyeClient, _super);
|
|
82
|
+
function SkyEyeClient(host, port) {
|
|
83
|
+
var _this = _super.call(this, host + ":" + port, grpc.credentials.createInsecure(), null) || this;
|
|
84
|
+
_this.host = host;
|
|
85
|
+
_this.port = port;
|
|
86
|
+
return _this;
|
|
87
|
+
}
|
|
88
|
+
SkyEyeClient.prototype.RunTestcase = function (json) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
+
var request, stream;
|
|
91
|
+
return __generator(this, function (_a) {
|
|
92
|
+
try {
|
|
93
|
+
request = new skyeye_rpc_pb_1.JSONRequest();
|
|
94
|
+
request.setRequest(json);
|
|
95
|
+
stream = _super.prototype.runTestcase.call(this, request);
|
|
96
|
+
return [2 /*return*/, stream];
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
console.error("Error during RunTestcase:", error);
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
return [2 /*return*/];
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
SkyEyeClient.prototype.Monitor = function (json) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
+
var request, stream;
|
|
109
|
+
return __generator(this, function (_a) {
|
|
110
|
+
try {
|
|
111
|
+
request = new skyeye_rpc_pb_1.JSONRequest();
|
|
112
|
+
request.setRequest(json);
|
|
113
|
+
stream = _super.prototype.Monitor.call(this, request);
|
|
114
|
+
return [2 /*return*/, stream];
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
console.error("Error during RunTestcase:", error);
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
return [2 /*return*/];
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
SkyEyeClient.prototype.call = function (request) {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
126
|
+
var response, ackObj, error_1;
|
|
127
|
+
var _this = this;
|
|
128
|
+
return __generator(this, function (_a) {
|
|
129
|
+
switch (_a.label) {
|
|
130
|
+
case 0:
|
|
131
|
+
_a.trys.push([0, 2, , 3]);
|
|
132
|
+
this.printRequestLog(request);
|
|
133
|
+
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
134
|
+
_super.prototype.callSkyEye.call(_this, request, function (error, response) {
|
|
135
|
+
if (error) {
|
|
136
|
+
reject(error);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
resolve(response);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
})];
|
|
143
|
+
case 1:
|
|
144
|
+
response = _a.sent();
|
|
145
|
+
ackObj = JSON.parse(response.toString()).ack;
|
|
146
|
+
this.printResponseLog(ackObj);
|
|
147
|
+
return [2 /*return*/, ackObj];
|
|
148
|
+
case 2:
|
|
149
|
+
error_1 = _a.sent();
|
|
150
|
+
console.error("Error during gRPC call:", error_1);
|
|
151
|
+
throw error_1;
|
|
152
|
+
case 3: return [2 /*return*/];
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
SkyEyeClient.prototype.printRequestLog = function (request) {
|
|
158
|
+
if (request.getRequest() != null) {
|
|
159
|
+
var base = JSON.parse(request.getRequest());
|
|
160
|
+
if (base.request.name === "SE_get_running_status" || base.request.name === "SE_get_all_class_info") {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
console.log("客户端请求-- ", JSON.stringify(base));
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
SkyEyeClient.prototype.printResponseLog = function (ackObj) {
|
|
167
|
+
if (ackObj != null) {
|
|
168
|
+
var name_1 = ackObj.name;
|
|
169
|
+
if (name_1 === "SE_get_running_status" || name_1 === "SE_get_all_class_info") {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
console.log("\u5BA2\u6237\u7AEF\u54CD\u5E94-- ", ackObj);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
SkyEyeClient.prototype.runScriptRequest = function (filename) {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
+
var error_2;
|
|
178
|
+
return __generator(this, function (_a) {
|
|
179
|
+
switch (_a.label) {
|
|
180
|
+
case 0:
|
|
181
|
+
_a.trys.push([0, 2, , 3]);
|
|
182
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().runScriptRequest(filename))];
|
|
183
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
184
|
+
case 2:
|
|
185
|
+
error_2 = _a.sent();
|
|
186
|
+
console.error("Error during runScriptRequest:", error_2);
|
|
187
|
+
throw error_2;
|
|
188
|
+
case 3: return [2 /*return*/];
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
SkyEyeClient.prototype.runCommand = function () {
|
|
194
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
195
|
+
var error_3;
|
|
196
|
+
return __generator(this, function (_a) {
|
|
197
|
+
switch (_a.label) {
|
|
198
|
+
case 0:
|
|
199
|
+
_a.trys.push([0, 2, , 3]);
|
|
200
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().runCommand())];
|
|
201
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
202
|
+
case 2:
|
|
203
|
+
error_3 = _a.sent();
|
|
204
|
+
console.error("Error during runCommand:", error_3);
|
|
205
|
+
throw error_3;
|
|
206
|
+
case 3: return [2 /*return*/];
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
SkyEyeClient.prototype.stopCommand = function () {
|
|
212
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
213
|
+
var error_4;
|
|
214
|
+
return __generator(this, function (_a) {
|
|
215
|
+
switch (_a.label) {
|
|
216
|
+
case 0:
|
|
217
|
+
_a.trys.push([0, 2, , 3]);
|
|
218
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().stopCommand())];
|
|
219
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
220
|
+
case 2:
|
|
221
|
+
error_4 = _a.sent();
|
|
222
|
+
console.error("Error during stopCommand:", error_4);
|
|
223
|
+
throw error_4;
|
|
224
|
+
case 3: return [2 /*return*/];
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
SkyEyeClient.prototype.quitCommand = function () {
|
|
230
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
231
|
+
var error_5;
|
|
232
|
+
return __generator(this, function (_a) {
|
|
233
|
+
switch (_a.label) {
|
|
234
|
+
case 0:
|
|
235
|
+
_a.trys.push([0, 2, , 3]);
|
|
236
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().quitCommand())];
|
|
237
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
238
|
+
case 2:
|
|
239
|
+
error_5 = _a.sent();
|
|
240
|
+
console.error("Error during quitCommand:", error_5);
|
|
241
|
+
throw error_5;
|
|
242
|
+
case 3: return [2 /*return*/];
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
SkyEyeClient.prototype.getCpuList = function () {
|
|
248
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
249
|
+
var response, call, cpuItems_1, error_6;
|
|
250
|
+
return __generator(this, function (_a) {
|
|
251
|
+
switch (_a.label) {
|
|
252
|
+
case 0:
|
|
253
|
+
response = new GetCpuListResponse_1.GetCpuListResponse();
|
|
254
|
+
_a.label = 1;
|
|
255
|
+
case 1:
|
|
256
|
+
_a.trys.push([1, 3, , 4]);
|
|
257
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getCpuList())];
|
|
258
|
+
case 2:
|
|
259
|
+
call = _a.sent();
|
|
260
|
+
if (call != null) {
|
|
261
|
+
response.isSuccess = true;
|
|
262
|
+
if (call.result != null) {
|
|
263
|
+
cpuItems_1 = new Array();
|
|
264
|
+
call.result.forEach(function (element) {
|
|
265
|
+
var item = new Cpu_1.Cpu(null);
|
|
266
|
+
if (element.classname) {
|
|
267
|
+
item.setClassName(element.classname);
|
|
268
|
+
}
|
|
269
|
+
if (element.objname) {
|
|
270
|
+
item.setName(element.objname);
|
|
271
|
+
}
|
|
272
|
+
if (element.mach) {
|
|
273
|
+
if (boardMap.has(String(element.mach))) {
|
|
274
|
+
item.setParent(boardMap.get(String(element.mach)));
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
cpuItems_1.push(item);
|
|
278
|
+
});
|
|
279
|
+
response.setCpuList(cpuItems_1);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException(String(call.error));
|
|
284
|
+
}
|
|
285
|
+
return [2 /*return*/, response];
|
|
286
|
+
case 3:
|
|
287
|
+
error_6 = _a.sent();
|
|
288
|
+
console.error("Error during getCpuList:", error_6);
|
|
289
|
+
throw error_6;
|
|
290
|
+
case 4: return [2 /*return*/];
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
SkyEyeClient.prototype.enableDeviceWork = function (deviceName) {
|
|
296
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
297
|
+
var error_7;
|
|
298
|
+
return __generator(this, function (_a) {
|
|
299
|
+
switch (_a.label) {
|
|
300
|
+
case 0:
|
|
301
|
+
_a.trys.push([0, 2, , 3]);
|
|
302
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().enableDeviceWork(deviceName))];
|
|
303
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
304
|
+
case 2:
|
|
305
|
+
error_7 = _a.sent();
|
|
306
|
+
console.error("Error during enableDeviceWork:", error_7);
|
|
307
|
+
throw error_7;
|
|
308
|
+
case 3: return [2 /*return*/];
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
SkyEyeClient.prototype.disableDeviceWork = function (deviceName) {
|
|
314
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
315
|
+
var error_8;
|
|
316
|
+
return __generator(this, function (_a) {
|
|
317
|
+
switch (_a.label) {
|
|
318
|
+
case 0:
|
|
319
|
+
_a.trys.push([0, 2, , 3]);
|
|
320
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().disableDeviceWork(deviceName))];
|
|
321
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
322
|
+
case 2:
|
|
323
|
+
error_8 = _a.sent();
|
|
324
|
+
console.error("Error during disableDeviceWork:", error_8);
|
|
325
|
+
throw error_8;
|
|
326
|
+
case 3: return [2 /*return*/];
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
};
|
|
331
|
+
SkyEyeClient.prototype.changeDir = function (skyeyeProjectRootDir) {
|
|
332
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
333
|
+
var error_9;
|
|
334
|
+
return __generator(this, function (_a) {
|
|
335
|
+
switch (_a.label) {
|
|
336
|
+
case 0:
|
|
337
|
+
_a.trys.push([0, 2, , 3]);
|
|
338
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().changeDir(skyeyeProjectRootDir))];
|
|
339
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
340
|
+
case 2:
|
|
341
|
+
error_9 = _a.sent();
|
|
342
|
+
console.error("Error during changeDir:", error_9);
|
|
343
|
+
throw error_9;
|
|
344
|
+
case 3: return [2 /*return*/];
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
};
|
|
349
|
+
SkyEyeClient.prototype.getRunningDeviceInfo = function () {
|
|
350
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
351
|
+
var error_10;
|
|
352
|
+
return __generator(this, function (_a) {
|
|
353
|
+
switch (_a.label) {
|
|
354
|
+
case 0:
|
|
355
|
+
_a.trys.push([0, 2, , 3]);
|
|
356
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getRunningDeviceInfo())];
|
|
357
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
358
|
+
case 2:
|
|
359
|
+
error_10 = _a.sent();
|
|
360
|
+
console.error("Error during getRunningDeviceInfo:", error_10);
|
|
361
|
+
throw error_10;
|
|
362
|
+
case 3: return [2 /*return*/];
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
};
|
|
367
|
+
SkyEyeClient.prototype.getSimulationTime = function (cpuName) {
|
|
368
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
369
|
+
var error_11;
|
|
370
|
+
return __generator(this, function (_a) {
|
|
371
|
+
switch (_a.label) {
|
|
372
|
+
case 0:
|
|
373
|
+
_a.trys.push([0, 2, , 3]);
|
|
374
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getSimulationTime(cpuName))];
|
|
375
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
376
|
+
case 2:
|
|
377
|
+
error_11 = _a.sent();
|
|
378
|
+
console.error("Error during getCurrentSimulationTime:", error_11);
|
|
379
|
+
throw error_11;
|
|
380
|
+
case 3: return [2 /*return*/];
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
};
|
|
385
|
+
SkyEyeClient.prototype.getCurrentSimulationTime = function () {
|
|
386
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
387
|
+
var cpuList;
|
|
388
|
+
return __generator(this, function (_a) {
|
|
389
|
+
switch (_a.label) {
|
|
390
|
+
case 0: return [4 /*yield*/, this.getCpuList()];
|
|
391
|
+
case 1:
|
|
392
|
+
cpuList = (_a.sent()).getCpuList();
|
|
393
|
+
if (cpuList.length > 0) {
|
|
394
|
+
return [2 /*return*/, this.getSimulationTime(cpuList[0].getName())];
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
console.error("无法获取cpu,请确认cpu是否存在:");
|
|
398
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException("无法获取cpu,请确认cpu是否存在:");
|
|
399
|
+
}
|
|
400
|
+
return [2 /*return*/];
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
};
|
|
405
|
+
SkyEyeClient.prototype.getDeviceList = function () {
|
|
406
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
407
|
+
var response, call, result, objectNode, it, _i, it_1, machine, machName, devices, deviceNames, _a, deviceNames_1, deviceName, device, items, error_12;
|
|
408
|
+
return __generator(this, function (_b) {
|
|
409
|
+
switch (_b.label) {
|
|
410
|
+
case 0:
|
|
411
|
+
response = new GetDeviceListResponse_1.GetDeviceListResponse();
|
|
412
|
+
_b.label = 1;
|
|
413
|
+
case 1:
|
|
414
|
+
_b.trys.push([1, 3, , 4]);
|
|
415
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getDeviceList())];
|
|
416
|
+
case 2:
|
|
417
|
+
call = _b.sent();
|
|
418
|
+
console.log("getDeviceList:", call);
|
|
419
|
+
if (call != null) {
|
|
420
|
+
response.isSuccess = true;
|
|
421
|
+
result = call.result;
|
|
422
|
+
if (typeof result === 'object' && result !== null) {
|
|
423
|
+
objectNode = result;
|
|
424
|
+
it = Object.entries(objectNode);
|
|
425
|
+
for (_i = 0, it_1 = it; _i < it_1.length; _i++) {
|
|
426
|
+
machine = it_1[_i];
|
|
427
|
+
machName = machine[0];
|
|
428
|
+
devices = machine[1];
|
|
429
|
+
if (typeof devices === 'object' && devices !== null) {
|
|
430
|
+
deviceNames = Object.keys(devices);
|
|
431
|
+
for (_a = 0, deviceNames_1 = deviceNames; _a < deviceNames_1.length; _a++) {
|
|
432
|
+
deviceName = deviceNames_1[_a];
|
|
433
|
+
device = new Device_1.Device(null);
|
|
434
|
+
items = devices[deviceName];
|
|
435
|
+
device.name = deviceName;
|
|
436
|
+
if (boardMap.has(machName)) {
|
|
437
|
+
device.parent = boardMap.get(machName);
|
|
438
|
+
}
|
|
439
|
+
if (items && items.hasOwnProperty("classname")) {
|
|
440
|
+
device.className = items["classname"];
|
|
441
|
+
}
|
|
442
|
+
response.deviceList.push(device);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
return [3 /*break*/, 4];
|
|
449
|
+
case 3:
|
|
450
|
+
error_12 = _b.sent();
|
|
451
|
+
console.error("Error during getPC:", error_12);
|
|
452
|
+
throw error_12;
|
|
453
|
+
case 4: return [2 /*return*/, response];
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
};
|
|
458
|
+
SkyEyeClient.prototype.getPC = function (cpuName) {
|
|
459
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
460
|
+
var error_13;
|
|
461
|
+
return __generator(this, function (_a) {
|
|
462
|
+
switch (_a.label) {
|
|
463
|
+
case 0:
|
|
464
|
+
_a.trys.push([0, 2, , 3]);
|
|
465
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getCurrentPC(cpuName))];
|
|
466
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
467
|
+
case 2:
|
|
468
|
+
error_13 = _a.sent();
|
|
469
|
+
console.error("Error during getPC:", error_13);
|
|
470
|
+
throw error_13;
|
|
471
|
+
case 3: return [2 /*return*/];
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
});
|
|
475
|
+
};
|
|
476
|
+
SkyEyeClient.prototype.getCurrentPC = function () {
|
|
477
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
478
|
+
var cpuList, error_14;
|
|
479
|
+
return __generator(this, function (_a) {
|
|
480
|
+
switch (_a.label) {
|
|
481
|
+
case 0: return [4 /*yield*/, this.getCpuList()];
|
|
482
|
+
case 1:
|
|
483
|
+
cpuList = (_a.sent()).getCpuList();
|
|
484
|
+
if (!(cpuList != null && cpuList.length > 0)) return [3 /*break*/, 6];
|
|
485
|
+
_a.label = 2;
|
|
486
|
+
case 2:
|
|
487
|
+
_a.trys.push([2, 4, , 5]);
|
|
488
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getCurrentPC(cpuList[0].getName()))];
|
|
489
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
490
|
+
case 4:
|
|
491
|
+
error_14 = _a.sent();
|
|
492
|
+
console.error("Error during getCurrentPC:", error_14);
|
|
493
|
+
throw error_14;
|
|
494
|
+
case 5: return [3 /*break*/, 7];
|
|
495
|
+
case 6:
|
|
496
|
+
console.error("无法获取cpu,请确认cpu是否存在:");
|
|
497
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException("无法获取cpu,请确认cpu是否存在:");
|
|
498
|
+
case 7: return [2 /*return*/];
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
});
|
|
502
|
+
};
|
|
503
|
+
SkyEyeClient.prototype.getCpuMips = function (cpuName) {
|
|
504
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
505
|
+
var error_15;
|
|
506
|
+
return __generator(this, function (_a) {
|
|
507
|
+
switch (_a.label) {
|
|
508
|
+
case 0:
|
|
509
|
+
_a.trys.push([0, 2, , 3]);
|
|
510
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getCpuMips(cpuName))];
|
|
511
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
512
|
+
case 2:
|
|
513
|
+
error_15 = _a.sent();
|
|
514
|
+
console.error("Error during getCpuMips:", error_15);
|
|
515
|
+
throw error_15;
|
|
516
|
+
case 3: return [2 /*return*/];
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
});
|
|
520
|
+
};
|
|
521
|
+
SkyEyeClient.prototype.getCurrentCpuMips = function () {
|
|
522
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
523
|
+
var cpuList, error_16;
|
|
524
|
+
return __generator(this, function (_a) {
|
|
525
|
+
switch (_a.label) {
|
|
526
|
+
case 0: return [4 /*yield*/, this.getCpuList()];
|
|
527
|
+
case 1:
|
|
528
|
+
cpuList = (_a.sent()).getCpuList();
|
|
529
|
+
console.log("测试", cpuList[0].getName());
|
|
530
|
+
if (!(cpuList != null && cpuList.length > 0)) return [3 /*break*/, 6];
|
|
531
|
+
_a.label = 2;
|
|
532
|
+
case 2:
|
|
533
|
+
_a.trys.push([2, 4, , 5]);
|
|
534
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getCpuMips(cpuList[0].getName()))];
|
|
535
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
536
|
+
case 4:
|
|
537
|
+
error_16 = _a.sent();
|
|
538
|
+
console.error("Error during getCurrentCpuMips:", error_16);
|
|
539
|
+
throw error_16;
|
|
540
|
+
case 5: return [3 /*break*/, 7];
|
|
541
|
+
case 6:
|
|
542
|
+
console.error("无法获取cpu,请确认cpu是否存在:");
|
|
543
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException("无法获取cpu,请确认cpu是否存在:");
|
|
544
|
+
case 7: return [2 /*return*/];
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
});
|
|
548
|
+
};
|
|
549
|
+
SkyEyeClient.prototype.getGlobalVarValue = function (cpuName, varName, bytesNum, valueType) {
|
|
550
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
551
|
+
var error_17;
|
|
552
|
+
return __generator(this, function (_a) {
|
|
553
|
+
switch (_a.label) {
|
|
554
|
+
case 0:
|
|
555
|
+
_a.trys.push([0, 2, , 3]);
|
|
556
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getGlobalVarValue(cpuName, varName, bytesNum, valueType))];
|
|
557
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
558
|
+
case 2:
|
|
559
|
+
error_17 = _a.sent();
|
|
560
|
+
console.error("Error during getGlobalVarValue:", error_17);
|
|
561
|
+
throw error_17;
|
|
562
|
+
case 3: return [2 /*return*/];
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
});
|
|
566
|
+
};
|
|
567
|
+
SkyEyeClient.prototype.getGlobalVarValueDefault = function (varName, valueType) {
|
|
568
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
569
|
+
var cpuList, error_18;
|
|
570
|
+
return __generator(this, function (_a) {
|
|
571
|
+
switch (_a.label) {
|
|
572
|
+
case 0: return [4 /*yield*/, this.getCpuList()];
|
|
573
|
+
case 1:
|
|
574
|
+
cpuList = (_a.sent()).getCpuList();
|
|
575
|
+
if (!(cpuList != null && cpuList.length > 0)) return [3 /*break*/, 6];
|
|
576
|
+
_a.label = 2;
|
|
577
|
+
case 2:
|
|
578
|
+
_a.trys.push([2, 4, , 5]);
|
|
579
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getGlobalVarValue(cpuList[0].getName(), varName, "4", valueType))];
|
|
580
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
581
|
+
case 4:
|
|
582
|
+
error_18 = _a.sent();
|
|
583
|
+
console.error("Error during getGlobalVarValueDefault:", error_18);
|
|
584
|
+
throw error_18;
|
|
585
|
+
case 5: return [3 /*break*/, 7];
|
|
586
|
+
case 6:
|
|
587
|
+
console.error("无法获取cpu,请确认cpu是否存在:");
|
|
588
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException("无法获取cpu,请确认cpu是否存在:");
|
|
589
|
+
case 7: return [2 /*return*/];
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
});
|
|
593
|
+
};
|
|
594
|
+
SkyEyeClient.prototype.setGlobalVarValue = function (cpuName, varName, bytesNum, valueType, value) {
|
|
595
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
596
|
+
var error_19;
|
|
597
|
+
return __generator(this, function (_a) {
|
|
598
|
+
switch (_a.label) {
|
|
599
|
+
case 0:
|
|
600
|
+
_a.trys.push([0, 2, , 3]);
|
|
601
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().setGlobalVarValue(cpuName, varName, bytesNum, valueType, value))];
|
|
602
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
603
|
+
case 2:
|
|
604
|
+
error_19 = _a.sent();
|
|
605
|
+
console.error("Error during setGlobalVarValue:", error_19);
|
|
606
|
+
throw error_19;
|
|
607
|
+
case 3: return [2 /*return*/];
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
});
|
|
611
|
+
};
|
|
612
|
+
SkyEyeClient.prototype.setGlobalVarValueDefault = function (varName, valueType, value) {
|
|
613
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
614
|
+
var cpuList, error_20;
|
|
615
|
+
return __generator(this, function (_a) {
|
|
616
|
+
switch (_a.label) {
|
|
617
|
+
case 0: return [4 /*yield*/, this.getCpuList()];
|
|
618
|
+
case 1:
|
|
619
|
+
cpuList = (_a.sent()).getCpuList();
|
|
620
|
+
if (!(cpuList != null && cpuList.length > 0)) return [3 /*break*/, 6];
|
|
621
|
+
_a.label = 2;
|
|
622
|
+
case 2:
|
|
623
|
+
_a.trys.push([2, 4, , 5]);
|
|
624
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().setGlobalVarValue(cpuList[0].getName(), varName, "4", valueType, value))];
|
|
625
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
626
|
+
case 4:
|
|
627
|
+
error_20 = _a.sent();
|
|
628
|
+
console.error("Error during setGlobalVarValueDefault:", error_20);
|
|
629
|
+
throw error_20;
|
|
630
|
+
case 5: return [3 /*break*/, 7];
|
|
631
|
+
case 6:
|
|
632
|
+
console.error("无法获取cpu,请确认cpu是否存在:");
|
|
633
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException("无法获取cpu,请确认cpu是否存在:");
|
|
634
|
+
case 7: return [2 /*return*/];
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
});
|
|
638
|
+
};
|
|
639
|
+
SkyEyeClient.prototype.getMemoryValue = function (cpuName, baseAddr, length) {
|
|
640
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
641
|
+
return __generator(this, function (_a) {
|
|
642
|
+
try {
|
|
643
|
+
return [2 /*return*/, this.getAddressingSpace(cpuName, baseAddr, length)];
|
|
644
|
+
}
|
|
645
|
+
catch (error) {
|
|
646
|
+
console.error("Error during getMemoryValue:", error);
|
|
647
|
+
throw error;
|
|
648
|
+
}
|
|
649
|
+
return [2 /*return*/];
|
|
650
|
+
});
|
|
651
|
+
});
|
|
652
|
+
};
|
|
653
|
+
SkyEyeClient.prototype.getAddressingSpace = function (cpuName, baseAddr, length) {
|
|
654
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
655
|
+
var error_21;
|
|
656
|
+
return __generator(this, function (_a) {
|
|
657
|
+
switch (_a.label) {
|
|
658
|
+
case 0:
|
|
659
|
+
_a.trys.push([0, 2, , 3]);
|
|
660
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getMemoryValue(cpuName, baseAddr, length))];
|
|
661
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
662
|
+
case 2:
|
|
663
|
+
error_21 = _a.sent();
|
|
664
|
+
console.error("Error during getAddressingSpace:", error_21);
|
|
665
|
+
throw error_21;
|
|
666
|
+
case 3: return [2 /*return*/];
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
});
|
|
670
|
+
};
|
|
671
|
+
SkyEyeClient.prototype.getMemoryValueDefault = function (baseAddr, length) {
|
|
672
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
673
|
+
return __generator(this, function (_a) {
|
|
674
|
+
try {
|
|
675
|
+
return [2 /*return*/, this.getAddressingSpaceDefault(baseAddr, length)];
|
|
676
|
+
}
|
|
677
|
+
catch (error) {
|
|
678
|
+
console.error("Error during getMemoryValue:", error);
|
|
679
|
+
throw error;
|
|
680
|
+
}
|
|
681
|
+
return [2 /*return*/];
|
|
682
|
+
});
|
|
683
|
+
});
|
|
684
|
+
};
|
|
685
|
+
SkyEyeClient.prototype.getAddressingSpaceDefault = function (baseAddr, length) {
|
|
686
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
687
|
+
var cpuList, error_22;
|
|
688
|
+
return __generator(this, function (_a) {
|
|
689
|
+
switch (_a.label) {
|
|
690
|
+
case 0: return [4 /*yield*/, this.getCpuList()];
|
|
691
|
+
case 1:
|
|
692
|
+
cpuList = (_a.sent()).getCpuList();
|
|
693
|
+
if (!(cpuList != null && cpuList.length > 0)) return [3 /*break*/, 6];
|
|
694
|
+
_a.label = 2;
|
|
695
|
+
case 2:
|
|
696
|
+
_a.trys.push([2, 4, , 5]);
|
|
697
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getMemoryValue(cpuList[0].getName(), baseAddr, length))];
|
|
698
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
699
|
+
case 4:
|
|
700
|
+
error_22 = _a.sent();
|
|
701
|
+
console.error("Error during getAddressingSpaceDefault:", error_22);
|
|
702
|
+
throw error_22;
|
|
703
|
+
case 5: return [3 /*break*/, 7];
|
|
704
|
+
case 6:
|
|
705
|
+
console.error("无法获取cpu,请确认cpu是否存在:");
|
|
706
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException("无法获取cpu,请确认cpu是否存在:");
|
|
707
|
+
case 7: return [2 /*return*/];
|
|
708
|
+
}
|
|
709
|
+
});
|
|
710
|
+
});
|
|
711
|
+
};
|
|
712
|
+
SkyEyeClient.prototype.getCpuRegisters = function (cpuName) {
|
|
713
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
714
|
+
var response, call, it, error_23;
|
|
715
|
+
return __generator(this, function (_a) {
|
|
716
|
+
switch (_a.label) {
|
|
717
|
+
case 0:
|
|
718
|
+
response = new GetCpuRegisterInfoResponse_1.GetCpuRegisterInfoResponse();
|
|
719
|
+
_a.label = 1;
|
|
720
|
+
case 1:
|
|
721
|
+
_a.trys.push([1, 3, , 4]);
|
|
722
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getcpuRegisterInfo(cpuName))];
|
|
723
|
+
case 2:
|
|
724
|
+
call = _a.sent();
|
|
725
|
+
if (call != null) {
|
|
726
|
+
response.isSuccess = true;
|
|
727
|
+
it = call.result;
|
|
728
|
+
it.forEach(function (item) {
|
|
729
|
+
var register = new Register_1.Register(null);
|
|
730
|
+
register.name = item.name;
|
|
731
|
+
register.bits = item.size;
|
|
732
|
+
register.description = item.desc;
|
|
733
|
+
register.value = item.value;
|
|
734
|
+
register.offset = item.offset;
|
|
735
|
+
response.registers.push(register);
|
|
736
|
+
response.registers.sort(function (r1, r2) {
|
|
737
|
+
if (r1.offset == null) {
|
|
738
|
+
return 1;
|
|
739
|
+
}
|
|
740
|
+
if (r2.offset == null) {
|
|
741
|
+
return -1;
|
|
742
|
+
}
|
|
743
|
+
if (r1.offset === r2.offset) {
|
|
744
|
+
return 0;
|
|
745
|
+
}
|
|
746
|
+
var numOffset1 = parseInt(r1.offset);
|
|
747
|
+
var numOffset2 = parseInt(r2.offset);
|
|
748
|
+
var result = 0;
|
|
749
|
+
if (!isNaN(numOffset1) && !isNaN(numOffset2)) {
|
|
750
|
+
result = numOffset1 - numOffset2;
|
|
751
|
+
console.log("Result:", result);
|
|
752
|
+
}
|
|
753
|
+
else {
|
|
754
|
+
console.log("Invalid offset values.");
|
|
755
|
+
}
|
|
756
|
+
return result > 0 ? 1 : -1;
|
|
757
|
+
// return r1.offset! - r2.offset! > 0 ? 1 : -1;
|
|
758
|
+
});
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
else {
|
|
762
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException(String(call.error));
|
|
763
|
+
}
|
|
764
|
+
return [3 /*break*/, 4];
|
|
765
|
+
case 3:
|
|
766
|
+
error_23 = _a.sent();
|
|
767
|
+
console.error("Error during getCpuRegistersDefault:", error_23);
|
|
768
|
+
throw error_23;
|
|
769
|
+
case 4: return [2 /*return*/, response];
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
});
|
|
773
|
+
};
|
|
774
|
+
SkyEyeClient.prototype.getCpuRegistersDefault = function () {
|
|
775
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
776
|
+
var cpuList, error_24;
|
|
777
|
+
return __generator(this, function (_a) {
|
|
778
|
+
switch (_a.label) {
|
|
779
|
+
case 0: return [4 /*yield*/, this.getCpuList()];
|
|
780
|
+
case 1:
|
|
781
|
+
cpuList = (_a.sent()).getCpuList();
|
|
782
|
+
if (!(cpuList != null && cpuList.length > 0)) return [3 /*break*/, 6];
|
|
783
|
+
_a.label = 2;
|
|
784
|
+
case 2:
|
|
785
|
+
_a.trys.push([2, 4, , 5]);
|
|
786
|
+
return [4 /*yield*/, this.getCpuRegisters(cpuList[0].getName())];
|
|
787
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
788
|
+
case 4:
|
|
789
|
+
error_24 = _a.sent();
|
|
790
|
+
console.error("Error during getCpuRegistersDefault:", error_24);
|
|
791
|
+
throw error_24;
|
|
792
|
+
case 5: return [3 /*break*/, 7];
|
|
793
|
+
case 6:
|
|
794
|
+
console.error("无法获取cpu,请确认cpu是否存在:");
|
|
795
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException("无法获取cpu,请确认cpu是否存在:");
|
|
796
|
+
case 7: return [2 /*return*/];
|
|
797
|
+
}
|
|
798
|
+
});
|
|
799
|
+
});
|
|
800
|
+
};
|
|
801
|
+
SkyEyeClient.prototype.setCpuRegisterValueDefault = function (register, value) {
|
|
802
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
803
|
+
var error_25;
|
|
804
|
+
return __generator(this, function (_a) {
|
|
805
|
+
switch (_a.label) {
|
|
806
|
+
case 0:
|
|
807
|
+
_a.trys.push([0, 2, , 3]);
|
|
808
|
+
return [4 /*yield*/, this.setCpuRegisterValue(register.getParent().getParent().getName(), register.getParent().getName(), register.getName(), value)];
|
|
809
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
810
|
+
case 2:
|
|
811
|
+
error_25 = _a.sent();
|
|
812
|
+
console.error("Error during getCpuRegistersDefault:", error_25);
|
|
813
|
+
throw error_25;
|
|
814
|
+
case 3: return [2 /*return*/];
|
|
815
|
+
}
|
|
816
|
+
});
|
|
817
|
+
});
|
|
818
|
+
};
|
|
819
|
+
SkyEyeClient.prototype.setCpuRegisterValue = function (boardName, cpuName, registerName, value) {
|
|
820
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
821
|
+
var deviceTree, board, deviceMap, cpu, error_26;
|
|
822
|
+
return __generator(this, function (_a) {
|
|
823
|
+
switch (_a.label) {
|
|
824
|
+
case 0: return [4 /*yield*/, this.getDeviceTree()];
|
|
825
|
+
case 1:
|
|
826
|
+
deviceTree = _a.sent();
|
|
827
|
+
if (!deviceTree.boardMap.has(boardName)) {
|
|
828
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException("未能找到该板卡");
|
|
829
|
+
}
|
|
830
|
+
board = boardMap.get(boardName);
|
|
831
|
+
deviceMap = board.getDeveceMap();
|
|
832
|
+
if (!deviceMap.has(cpuName) || !(deviceMap.get(cpuName) instanceof Cpu_1.Cpu)) {
|
|
833
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException("未能找到该设备");
|
|
834
|
+
}
|
|
835
|
+
cpu = deviceMap.get(cpuName);
|
|
836
|
+
_a.label = 2;
|
|
837
|
+
case 2:
|
|
838
|
+
_a.trys.push([2, 4, , 5]);
|
|
839
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().setRegisterValue(cpu.getParent().getName(), cpuName, registerName, value))];
|
|
840
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
841
|
+
case 4:
|
|
842
|
+
error_26 = _a.sent();
|
|
843
|
+
console.error("Error during getAddressingSpace:", error_26);
|
|
844
|
+
throw error_26;
|
|
845
|
+
case 5: return [2 /*return*/];
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
});
|
|
849
|
+
};
|
|
850
|
+
SkyEyeClient.prototype.getDeviceTree = function () {
|
|
851
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
852
|
+
var state, response, call, boardMap_1, error_27;
|
|
853
|
+
return __generator(this, function (_a) {
|
|
854
|
+
switch (_a.label) {
|
|
855
|
+
case 0: return [4 /*yield*/, this.getCurrentRunningState()];
|
|
856
|
+
case 1:
|
|
857
|
+
state = (_a.sent()).getState();
|
|
858
|
+
if (GetRunningStateResponse_1.StateState.UNLOADED === state || GetRunningStateResponse_1.StateState.QUITED === state) {
|
|
859
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException("当前SkyEye未加载配置,需要加载配置可以获取设备树信息,请检查当前配置");
|
|
860
|
+
}
|
|
861
|
+
response = new GetDeviceTreeResponse_1.GetDeviceTreeResponse();
|
|
862
|
+
_a.label = 2;
|
|
863
|
+
case 2:
|
|
864
|
+
_a.trys.push([2, 4, , 5]);
|
|
865
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getDeviceTree())];
|
|
866
|
+
case 3:
|
|
867
|
+
call = _a.sent();
|
|
868
|
+
console.log("call:", call);
|
|
869
|
+
if (call.result != null) {
|
|
870
|
+
boardMap_1 = ParseBoardUtils_1.ParseBoardUtils.parseBoard(call.result);
|
|
871
|
+
response.boardMap = boardMap_1;
|
|
872
|
+
response.isSuccess = true;
|
|
873
|
+
}
|
|
874
|
+
else {
|
|
875
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException(String(call.error));
|
|
876
|
+
}
|
|
877
|
+
return [3 /*break*/, 5];
|
|
878
|
+
case 4:
|
|
879
|
+
error_27 = _a.sent();
|
|
880
|
+
console.error("Error during getAddressingSpace:", error_27);
|
|
881
|
+
throw error_27;
|
|
882
|
+
case 5: return [2 /*return*/, response];
|
|
883
|
+
}
|
|
884
|
+
});
|
|
885
|
+
});
|
|
886
|
+
};
|
|
887
|
+
SkyEyeClient.prototype.getCurrentRunningState = function () {
|
|
888
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
889
|
+
var response, call, error_28;
|
|
890
|
+
return __generator(this, function (_a) {
|
|
891
|
+
switch (_a.label) {
|
|
892
|
+
case 0:
|
|
893
|
+
response = new GetRunningStateResponse_1.GetRunningStateResponse();
|
|
894
|
+
_a.label = 1;
|
|
895
|
+
case 1:
|
|
896
|
+
_a.trys.push([1, 3, , 4]);
|
|
897
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getRunningStatus())
|
|
898
|
+
// { result: 2, error: null, name: 'SE_get_running_status' }
|
|
899
|
+
];
|
|
900
|
+
case 2:
|
|
901
|
+
call = _a.sent();
|
|
902
|
+
// { result: 2, error: null, name: 'SE_get_running_status' }
|
|
903
|
+
if (call != null) {
|
|
904
|
+
response.isSuccess = true;
|
|
905
|
+
switch (call.result) {
|
|
906
|
+
case 1:
|
|
907
|
+
response.setState(GetRunningStateResponse_1.StateState.UNLOADED);
|
|
908
|
+
break;
|
|
909
|
+
case 2:
|
|
910
|
+
response.setState(GetRunningStateResponse_1.StateState.RUNNING);
|
|
911
|
+
break;
|
|
912
|
+
case 3:
|
|
913
|
+
response.setState(GetRunningStateResponse_1.StateState.STOPPED);
|
|
914
|
+
break;
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
else {
|
|
918
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException(String(call.error));
|
|
919
|
+
}
|
|
920
|
+
return [3 /*break*/, 4];
|
|
921
|
+
case 3:
|
|
922
|
+
error_28 = _a.sent();
|
|
923
|
+
console.error("Error during getCurrentRunningState:", error_28);
|
|
924
|
+
throw error_28;
|
|
925
|
+
case 4: return [2 /*return*/, response];
|
|
926
|
+
}
|
|
927
|
+
});
|
|
928
|
+
});
|
|
929
|
+
};
|
|
930
|
+
SkyEyeClient.prototype.getAllDeviceInfo = function () {
|
|
931
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
932
|
+
var response, call, boardMap_2, error_29;
|
|
933
|
+
return __generator(this, function (_a) {
|
|
934
|
+
switch (_a.label) {
|
|
935
|
+
case 0:
|
|
936
|
+
response = new GetAllDeviceInfoResponse_1.GetAllDeviceInfoResponse();
|
|
937
|
+
_a.label = 1;
|
|
938
|
+
case 1:
|
|
939
|
+
_a.trys.push([1, 3, , 4]);
|
|
940
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getAllDeviceInfo())];
|
|
941
|
+
case 2:
|
|
942
|
+
call = _a.sent();
|
|
943
|
+
if (call != null) {
|
|
944
|
+
response.isSuccess = true;
|
|
945
|
+
boardMap_2 = ParseBoardUtils_1.ParseBoardUtils.parseBoard(call.result);
|
|
946
|
+
response.boardMap = boardMap_2;
|
|
947
|
+
}
|
|
948
|
+
else {
|
|
949
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException(String(call.error));
|
|
950
|
+
}
|
|
951
|
+
return [3 /*break*/, 4];
|
|
952
|
+
case 3:
|
|
953
|
+
error_29 = _a.sent();
|
|
954
|
+
console.error("Error during getAllDeviceInfo:", error_29);
|
|
955
|
+
throw error_29;
|
|
956
|
+
case 4: return [2 /*return*/, response];
|
|
957
|
+
}
|
|
958
|
+
});
|
|
959
|
+
});
|
|
960
|
+
};
|
|
961
|
+
SkyEyeClient.prototype.getRamAddrInfo = function (machName, addr) {
|
|
962
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
963
|
+
var response, call, error_30;
|
|
964
|
+
return __generator(this, function (_a) {
|
|
965
|
+
switch (_a.label) {
|
|
966
|
+
case 0:
|
|
967
|
+
response = new GetRamAddrInfoResponse_1.GetRamAddrInfoResponse();
|
|
968
|
+
_a.label = 1;
|
|
969
|
+
case 1:
|
|
970
|
+
_a.trys.push([1, 3, , 4]);
|
|
971
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getRamAddrInfo(machName, addr))];
|
|
972
|
+
case 2:
|
|
973
|
+
call = _a.sent();
|
|
974
|
+
if (call.result != null) {
|
|
975
|
+
response.isSuccess = true;
|
|
976
|
+
response.bits = call.result.bits;
|
|
977
|
+
response.value = call.result.value;
|
|
978
|
+
}
|
|
979
|
+
else {
|
|
980
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException(String(call.error));
|
|
981
|
+
}
|
|
982
|
+
return [3 /*break*/, 4];
|
|
983
|
+
case 3:
|
|
984
|
+
error_30 = _a.sent();
|
|
985
|
+
console.error("Error during getRamAddrInfo:", error_30);
|
|
986
|
+
throw error_30;
|
|
987
|
+
case 4: return [2 /*return*/, response];
|
|
988
|
+
}
|
|
989
|
+
});
|
|
990
|
+
});
|
|
991
|
+
};
|
|
992
|
+
SkyEyeClient.prototype.setRamFaultInjectDefault = function (device, addr, bit, mode) {
|
|
993
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
994
|
+
var error_31;
|
|
995
|
+
return __generator(this, function (_a) {
|
|
996
|
+
switch (_a.label) {
|
|
997
|
+
case 0:
|
|
998
|
+
_a.trys.push([0, 2, , 3]);
|
|
999
|
+
return [4 /*yield*/, this.setRamFaultInject(device.getParent().getName(), device.getName(), addr, bit, mode)];
|
|
1000
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1001
|
+
case 2:
|
|
1002
|
+
error_31 = _a.sent();
|
|
1003
|
+
throw error_31;
|
|
1004
|
+
case 3: return [2 /*return*/];
|
|
1005
|
+
}
|
|
1006
|
+
});
|
|
1007
|
+
});
|
|
1008
|
+
};
|
|
1009
|
+
SkyEyeClient.prototype.setRamFaultInject = function (boardName, deviceName, addr, bit, mode) {
|
|
1010
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1011
|
+
var error_32;
|
|
1012
|
+
return __generator(this, function (_a) {
|
|
1013
|
+
switch (_a.label) {
|
|
1014
|
+
case 0:
|
|
1015
|
+
_a.trys.push([0, 2, , 3]);
|
|
1016
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().setFaultInject(boardName, deviceName, String(addr), String(bit), mode))];
|
|
1017
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1018
|
+
case 2:
|
|
1019
|
+
error_32 = _a.sent();
|
|
1020
|
+
throw error_32;
|
|
1021
|
+
case 3: return [2 /*return*/];
|
|
1022
|
+
}
|
|
1023
|
+
});
|
|
1024
|
+
});
|
|
1025
|
+
};
|
|
1026
|
+
SkyEyeClient.prototype.setRegisterFaultInjectDefault = function (register, bit, mode) {
|
|
1027
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1028
|
+
var error_33;
|
|
1029
|
+
return __generator(this, function (_a) {
|
|
1030
|
+
switch (_a.label) {
|
|
1031
|
+
case 0:
|
|
1032
|
+
_a.trys.push([0, 2, , 3]);
|
|
1033
|
+
return [4 /*yield*/, this.setRegisterFaultInject(register.getParent().getParent().getName(), register.getParent().getName(), register.baseAddr, bit, mode)];
|
|
1034
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1035
|
+
case 2:
|
|
1036
|
+
error_33 = _a.sent();
|
|
1037
|
+
throw error_33;
|
|
1038
|
+
case 3: return [2 /*return*/];
|
|
1039
|
+
}
|
|
1040
|
+
});
|
|
1041
|
+
});
|
|
1042
|
+
};
|
|
1043
|
+
SkyEyeClient.prototype.setRegisterFaultInject = function (boardName, deviceName, addr, bit, mode) {
|
|
1044
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1045
|
+
var error_34;
|
|
1046
|
+
return __generator(this, function (_a) {
|
|
1047
|
+
switch (_a.label) {
|
|
1048
|
+
case 0:
|
|
1049
|
+
_a.trys.push([0, 2, , 3]);
|
|
1050
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().setFaultInject(boardName, deviceName, "0x" + String(addr), String(bit), mode))];
|
|
1051
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1052
|
+
case 2:
|
|
1053
|
+
error_34 = _a.sent();
|
|
1054
|
+
throw error_34;
|
|
1055
|
+
case 3: return [2 /*return*/];
|
|
1056
|
+
}
|
|
1057
|
+
});
|
|
1058
|
+
});
|
|
1059
|
+
};
|
|
1060
|
+
SkyEyeClient.prototype.deleteFaultInjectDefault = function (faultInjectItem) {
|
|
1061
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1062
|
+
var error_35;
|
|
1063
|
+
return __generator(this, function (_a) {
|
|
1064
|
+
switch (_a.label) {
|
|
1065
|
+
case 0:
|
|
1066
|
+
_a.trys.push([0, 2, , 3]);
|
|
1067
|
+
return [4 /*yield*/, this.deleteFaultInject(faultInjectItem.boardName, faultInjectItem.deviceName, faultInjectItem.addr, String(faultInjectItem.bit), faultInjectItem.type)];
|
|
1068
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1069
|
+
case 2:
|
|
1070
|
+
error_35 = _a.sent();
|
|
1071
|
+
throw error_35;
|
|
1072
|
+
case 3: return [2 /*return*/];
|
|
1073
|
+
}
|
|
1074
|
+
});
|
|
1075
|
+
});
|
|
1076
|
+
};
|
|
1077
|
+
SkyEyeClient.prototype.deleteFaultInject = function (boardName, deviceName, addr, bit, mode) {
|
|
1078
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1079
|
+
var error_36;
|
|
1080
|
+
return __generator(this, function (_a) {
|
|
1081
|
+
switch (_a.label) {
|
|
1082
|
+
case 0:
|
|
1083
|
+
_a.trys.push([0, 2, , 3]);
|
|
1084
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().deleteFaultInject(boardName, deviceName, "0x" + String(addr), String(bit), mode))];
|
|
1085
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1086
|
+
case 2:
|
|
1087
|
+
error_36 = _a.sent();
|
|
1088
|
+
throw error_36;
|
|
1089
|
+
case 3: return [2 /*return*/];
|
|
1090
|
+
}
|
|
1091
|
+
});
|
|
1092
|
+
});
|
|
1093
|
+
};
|
|
1094
|
+
SkyEyeClient.prototype.getFaultInjectList = function () {
|
|
1095
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1096
|
+
var response, call, items_1, error_37;
|
|
1097
|
+
return __generator(this, function (_a) {
|
|
1098
|
+
switch (_a.label) {
|
|
1099
|
+
case 0:
|
|
1100
|
+
response = new GetFaultInjectListResponse_1.GetFaultInjectListResponse();
|
|
1101
|
+
_a.label = 1;
|
|
1102
|
+
case 1:
|
|
1103
|
+
_a.trys.push([1, 3, , 4]);
|
|
1104
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getFaultInjectList())];
|
|
1105
|
+
case 2:
|
|
1106
|
+
call = _a.sent();
|
|
1107
|
+
if (call.result != null) {
|
|
1108
|
+
response.isSuccess = true;
|
|
1109
|
+
items_1 = new Array();
|
|
1110
|
+
call.result.forEach(function (item) {
|
|
1111
|
+
var faultInjectItem = new FaultInjectItem_1.FaultInjectItem(null);
|
|
1112
|
+
if (item != null) {
|
|
1113
|
+
faultInjectItem.deviceName = item.get(1);
|
|
1114
|
+
faultInjectItem.registerName = item.get(2);
|
|
1115
|
+
faultInjectItem.addr = item.get(3);
|
|
1116
|
+
faultInjectItem.bit = item.get(4);
|
|
1117
|
+
switch (String(item.get(5))) {
|
|
1118
|
+
case "0":
|
|
1119
|
+
faultInjectItem.type = FaultInjectType_1.FaultInjectType.SET_ZERO;
|
|
1120
|
+
break;
|
|
1121
|
+
case "1":
|
|
1122
|
+
faultInjectItem.type = FaultInjectType_1.FaultInjectType.SET_ONE;
|
|
1123
|
+
break;
|
|
1124
|
+
case "2":
|
|
1125
|
+
faultInjectItem.type = FaultInjectType_1.FaultInjectType.SET_REVE;
|
|
1126
|
+
break;
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
items_1.push(faultInjectItem);
|
|
1130
|
+
});
|
|
1131
|
+
response.faultInjectItems = items_1;
|
|
1132
|
+
}
|
|
1133
|
+
return [3 /*break*/, 4];
|
|
1134
|
+
case 3:
|
|
1135
|
+
error_37 = _a.sent();
|
|
1136
|
+
throw error_37;
|
|
1137
|
+
case 4: return [2 /*return*/, response];
|
|
1138
|
+
}
|
|
1139
|
+
});
|
|
1140
|
+
});
|
|
1141
|
+
};
|
|
1142
|
+
SkyEyeClient.prototype.getDisassembleInfo = function (cpuName, startAddr, nums) {
|
|
1143
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1144
|
+
var response, call, instructionItems_1, error_38;
|
|
1145
|
+
return __generator(this, function (_a) {
|
|
1146
|
+
switch (_a.label) {
|
|
1147
|
+
case 0:
|
|
1148
|
+
response = new GetDisassembleInfoResponse_1.GetDisassembleInfoResponse();
|
|
1149
|
+
_a.label = 1;
|
|
1150
|
+
case 1:
|
|
1151
|
+
_a.trys.push([1, 3, , 4]);
|
|
1152
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().getDisassembleInfo(cpuName, startAddr, nums))];
|
|
1153
|
+
case 2:
|
|
1154
|
+
call = _a.sent();
|
|
1155
|
+
if (call.result != null) {
|
|
1156
|
+
response.isSuccess = true;
|
|
1157
|
+
instructionItems_1 = new Array();
|
|
1158
|
+
call.result.forEach(function (item) {
|
|
1159
|
+
var instructionItem = new InstructionItem_1.InstructionItem();
|
|
1160
|
+
instructionItem.addr = item.get(0);
|
|
1161
|
+
instructionItem.func = item.get(1);
|
|
1162
|
+
instructionItem.content = item.get(2);
|
|
1163
|
+
instructionItems_1.push(instructionItem);
|
|
1164
|
+
});
|
|
1165
|
+
response.instructions = instructionItems_1;
|
|
1166
|
+
}
|
|
1167
|
+
else {
|
|
1168
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException(String(call.error));
|
|
1169
|
+
}
|
|
1170
|
+
return [3 /*break*/, 4];
|
|
1171
|
+
case 3:
|
|
1172
|
+
error_38 = _a.sent();
|
|
1173
|
+
throw error_38;
|
|
1174
|
+
case 4: return [2 /*return*/, response];
|
|
1175
|
+
}
|
|
1176
|
+
});
|
|
1177
|
+
});
|
|
1178
|
+
};
|
|
1179
|
+
SkyEyeClient.prototype.getDisassembleInfoDefault = function (startAddr, nums) {
|
|
1180
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1181
|
+
var cpuList;
|
|
1182
|
+
return __generator(this, function (_a) {
|
|
1183
|
+
switch (_a.label) {
|
|
1184
|
+
case 0: return [4 /*yield*/, this.getCpuList()];
|
|
1185
|
+
case 1:
|
|
1186
|
+
cpuList = (_a.sent()).getCpuList;
|
|
1187
|
+
if (cpuList != null && cpuList.length > 0) {
|
|
1188
|
+
return [2 /*return*/, this.getDisassembleInfo(cpuList[0].name, startAddr, nums)];
|
|
1189
|
+
}
|
|
1190
|
+
else {
|
|
1191
|
+
console.error("无法获取cpu,请确认cpu是否存在:");
|
|
1192
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException("无法获取cpu,请确认cpu是否存在:");
|
|
1193
|
+
}
|
|
1194
|
+
return [2 /*return*/];
|
|
1195
|
+
}
|
|
1196
|
+
});
|
|
1197
|
+
});
|
|
1198
|
+
};
|
|
1199
|
+
SkyEyeClient.prototype.SingleStep = function (cpuName) {
|
|
1200
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1201
|
+
var error_39;
|
|
1202
|
+
return __generator(this, function (_a) {
|
|
1203
|
+
switch (_a.label) {
|
|
1204
|
+
case 0:
|
|
1205
|
+
_a.trys.push([0, 2, , 3]);
|
|
1206
|
+
return [4 /*yield*/, this.call(RequestFactory_1.RequestFactory.getInstance().singleStep(cpuName))];
|
|
1207
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1208
|
+
case 2:
|
|
1209
|
+
error_39 = _a.sent();
|
|
1210
|
+
throw error_39;
|
|
1211
|
+
case 3: return [2 /*return*/];
|
|
1212
|
+
}
|
|
1213
|
+
});
|
|
1214
|
+
});
|
|
1215
|
+
};
|
|
1216
|
+
SkyEyeClient.prototype.SingleStepDefault = function () {
|
|
1217
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1218
|
+
var cpuList;
|
|
1219
|
+
return __generator(this, function (_a) {
|
|
1220
|
+
switch (_a.label) {
|
|
1221
|
+
case 0: return [4 /*yield*/, this.getCpuList()];
|
|
1222
|
+
case 1:
|
|
1223
|
+
cpuList = (_a.sent()).getCpuList;
|
|
1224
|
+
if (cpuList != null && cpuList.length > 0) {
|
|
1225
|
+
return [2 /*return*/, this.SingleStep(cpuList[0].name)];
|
|
1226
|
+
}
|
|
1227
|
+
else {
|
|
1228
|
+
console.error("无法获取cpu,请确认cpu是否存在:");
|
|
1229
|
+
throw new SkyEyeSDKException_1.SkyEyeSDKException("无法获取cpu,请确认cpu是否存在:");
|
|
1230
|
+
}
|
|
1231
|
+
return [2 /*return*/];
|
|
1232
|
+
}
|
|
1233
|
+
});
|
|
1234
|
+
});
|
|
1235
|
+
};
|
|
1236
|
+
SkyEyeClient.prototype.close = function () {
|
|
1237
|
+
_super.prototype.close.call(this);
|
|
1238
|
+
console.log('gRPC客户端已断开');
|
|
1239
|
+
return true;
|
|
1240
|
+
};
|
|
1241
|
+
SkyEyeClient.prototype.getHost = function () {
|
|
1242
|
+
return this.host;
|
|
1243
|
+
};
|
|
1244
|
+
SkyEyeClient.prototype.getPort = function () {
|
|
1245
|
+
return this.port;
|
|
1246
|
+
};
|
|
1247
|
+
SkyEyeClient.prototype.initSkyEyeAndRun = function (pathSkyEye, fileName, port, skyeyeDir) {
|
|
1248
|
+
var _this = this;
|
|
1249
|
+
console.log('runExample');
|
|
1250
|
+
cp.exec(skyeyeDir + " -q " + port + "\n", function (err, stdout, stderr) {
|
|
1251
|
+
console.log('stdout: ' + stdout);
|
|
1252
|
+
console.log('stderr: ' + stderr);
|
|
1253
|
+
});
|
|
1254
|
+
setTimeout(function () {
|
|
1255
|
+
client = new skyeye_rpc_grpc_pb_1.JSONTransmissionClient('127.0.0.1:' + port, grpc.credentials.createInsecure());
|
|
1256
|
+
console.log('client:' + client);
|
|
1257
|
+
var Jr = new skyeye_rpc_pb_1.JSONRequest();
|
|
1258
|
+
Jr.setRequest("{\"request\": {\"name\": \"chdir\", \"args\": {\"path\":\"" + pathSkyEye + "\"}}}");
|
|
1259
|
+
client.callSkyEye(Jr, function (error, response) {
|
|
1260
|
+
console.log("chdir res:" + response + error);
|
|
1261
|
+
Jr.setRequest("{\"request\": {\"name\": \"run_script\", \"args\": {\"filename\":\"" + fileName + "\"}}}");
|
|
1262
|
+
client.callSkyEye(Jr, function (error, response) {
|
|
1263
|
+
console.log("run_script res:" + response + error);
|
|
1264
|
+
_this.runCommand();
|
|
1265
|
+
return "1";
|
|
1266
|
+
});
|
|
1267
|
+
});
|
|
1268
|
+
}, 2000);
|
|
1269
|
+
};
|
|
1270
|
+
return SkyEyeClient;
|
|
1271
|
+
}(skyeye_rpc_grpc_pb_1.JSONTransmissionClient));
|
|
1272
|
+
exports.SkyEyeClient = SkyEyeClient;
|