skyeye-sdk-js 1.4.0 → 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.
|
@@ -4,6 +4,7 @@ export declare class RequestFactory {
|
|
|
4
4
|
private static _instance;
|
|
5
5
|
private constructor();
|
|
6
6
|
static getInstance(): RequestFactory;
|
|
7
|
+
getModuleStatus(): JSONRequest;
|
|
7
8
|
getRunningStatus(): JSONRequest;
|
|
8
9
|
runScriptRequest(filename: string): JSONRequest;
|
|
9
10
|
runCommand(): JSONRequest;
|
|
@@ -11,6 +11,13 @@ class RequestFactory {
|
|
|
11
11
|
}
|
|
12
12
|
return this._instance;
|
|
13
13
|
}
|
|
14
|
+
//判断模块是否完全加载成功
|
|
15
|
+
getModuleStatus() {
|
|
16
|
+
const baseRequest = new BaseRequest_1.BaseRequest("SE_get_modules_loaded_status");
|
|
17
|
+
const request = new skyeye_rpc_pb_1.JSONRequest();
|
|
18
|
+
request.setRequest(baseRequest.toJSONString());
|
|
19
|
+
return request;
|
|
20
|
+
}
|
|
14
21
|
getRunningStatus() {
|
|
15
22
|
const baseRequest = new BaseRequest_1.BaseRequest("SE_get_running_status");
|
|
16
23
|
const request = new skyeye_rpc_pb_1.JSONRequest();
|
|
@@ -14,6 +14,7 @@ import { FaultInjectItem } from './models/FaultInjectItem';
|
|
|
14
14
|
import { GetFaultInjectListResponse } from './response/GetFaultInjectListResponse';
|
|
15
15
|
import { GetDisassembleInfoResponse } from './response/GetDisassembleInfoResponse';
|
|
16
16
|
import { GetCpuRegisterInfoResponse } from './response/GetCpuRegisterInfoResponse';
|
|
17
|
+
import { BaseResponse } from './response/BaseResponse';
|
|
17
18
|
export declare class SkyEyeClient extends JSONTransmissionClient {
|
|
18
19
|
private host;
|
|
19
20
|
private port;
|
|
@@ -58,6 +59,7 @@ export declare class SkyEyeClient extends JSONTransmissionClient {
|
|
|
58
59
|
setCpuRegisterValue(boardName: string, cpuName: string, registerName: string, value: string): Promise<any>;
|
|
59
60
|
setDeviceRegisterValue(machName: string, deviceName: string, registerName: string, value: string): Promise<any>;
|
|
60
61
|
getDeviceTree(): Promise<GetDeviceTreeResponse>;
|
|
62
|
+
getModuleStatus(): Promise<BaseResponse>;
|
|
61
63
|
getCurrentRunningState(): Promise<GetRunningStateResponse>;
|
|
62
64
|
getAllDeviceInfo(): Promise<GetAllDeviceInfoResponse>;
|
|
63
65
|
getRamAddrInfo(machName: string, addr: string): Promise<GetRamAddrInfoResponse>;
|
|
@@ -78,6 +80,7 @@ export declare class SkyEyeClient extends JSONTransmissionClient {
|
|
|
78
80
|
initSkyEyeAndRun(pathSkyEye: string, fileName: string, port: string, skyeyeDir: string): void;
|
|
79
81
|
private childProcess;
|
|
80
82
|
initSkyEyeAndRun2(pathSkyEye: string, fileName: string, port: string, skyeyeDir: string): Promise<boolean>;
|
|
83
|
+
private checkModule;
|
|
81
84
|
private checkState;
|
|
82
85
|
private startSkyEye;
|
|
83
86
|
private setWorkingDirectory;
|
package/dist/src/SkyEyeClient.js
CHANGED
|
@@ -55,6 +55,7 @@ const InstructionItem_1 = require("./models/InstructionItem");
|
|
|
55
55
|
const GetCpuRegisterInfoResponse_1 = require("./response/GetCpuRegisterInfoResponse");
|
|
56
56
|
const SkyEyeSDKException_1 = require("./exception/SkyEyeSDKException");
|
|
57
57
|
const cp = __importStar(require("child_process"));
|
|
58
|
+
const BaseResponse_1 = require("./response/BaseResponse");
|
|
58
59
|
let client = null;
|
|
59
60
|
// ----------------------------当前运行程序的设备树----------------------------------------//
|
|
60
61
|
const boardMap = new Map();
|
|
@@ -729,6 +730,21 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
|
|
|
729
730
|
return response;
|
|
730
731
|
});
|
|
731
732
|
}
|
|
733
|
+
getModuleStatus() {
|
|
734
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
735
|
+
const response = new BaseResponse_1.BaseResponse();
|
|
736
|
+
try {
|
|
737
|
+
const call = yield this.call(RequestFactory_1.RequestFactory.getInstance().getModuleStatus());
|
|
738
|
+
// { result: 2, error: null, name: 'SE_get_running_status' }
|
|
739
|
+
if (call != null) {
|
|
740
|
+
response.isSuccess = call.result;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
catch (error) {
|
|
744
|
+
}
|
|
745
|
+
return response;
|
|
746
|
+
});
|
|
747
|
+
}
|
|
732
748
|
getCurrentRunningState() {
|
|
733
749
|
return __awaiter(this, void 0, void 0, function* () {
|
|
734
750
|
const response = new GetRunningStateResponse_1.GetRunningStateResponse();
|
|
@@ -1005,6 +1021,7 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
|
|
|
1005
1021
|
console.log('runExample');
|
|
1006
1022
|
this.childProcess = yield this.startSkyEye(port, skyeyeDir);
|
|
1007
1023
|
yield this.checkState();
|
|
1024
|
+
yield this.checkModule();
|
|
1008
1025
|
yield this.setWorkingDirectory(pathSkyEye, port);
|
|
1009
1026
|
yield this.runScript(fileName, port);
|
|
1010
1027
|
return true;
|
|
@@ -1019,16 +1036,49 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
|
|
|
1019
1036
|
}
|
|
1020
1037
|
});
|
|
1021
1038
|
}
|
|
1039
|
+
checkModule() {
|
|
1040
|
+
return new Promise((resolve, reject) => {
|
|
1041
|
+
let flag = true;
|
|
1042
|
+
const checkInterval = 500;
|
|
1043
|
+
const timeout = 30000;
|
|
1044
|
+
const startTime = Date.now();
|
|
1045
|
+
const check = () => {
|
|
1046
|
+
const elapsedTime = Date.now() - startTime;
|
|
1047
|
+
if (elapsedTime >= timeout) {
|
|
1048
|
+
reject(new Error("Timeout: State check exceeded 30 seconds"));
|
|
1049
|
+
return;
|
|
1050
|
+
}
|
|
1051
|
+
if (!flag) {
|
|
1052
|
+
resolve("");
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
this.getModuleStatus()
|
|
1056
|
+
.then((result) => {
|
|
1057
|
+
if (result.isSuccess) {
|
|
1058
|
+
flag = false;
|
|
1059
|
+
resolve("");
|
|
1060
|
+
}
|
|
1061
|
+
else {
|
|
1062
|
+
setTimeout(check, checkInterval);
|
|
1063
|
+
}
|
|
1064
|
+
})
|
|
1065
|
+
.catch(() => {
|
|
1066
|
+
setTimeout(check, checkInterval);
|
|
1067
|
+
});
|
|
1068
|
+
};
|
|
1069
|
+
check();
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1022
1072
|
checkState() {
|
|
1023
1073
|
return new Promise((resolve, reject) => {
|
|
1024
1074
|
let flag = true;
|
|
1025
1075
|
const checkInterval = 500;
|
|
1026
|
-
const timeout =
|
|
1076
|
+
const timeout = 30000;
|
|
1027
1077
|
const startTime = Date.now();
|
|
1028
1078
|
const check = () => {
|
|
1029
1079
|
const elapsedTime = Date.now() - startTime;
|
|
1030
1080
|
if (elapsedTime >= timeout) {
|
|
1031
|
-
reject(new Error("Timeout: State check exceeded
|
|
1081
|
+
reject(new Error("Timeout: State check exceeded 30 seconds"));
|
|
1032
1082
|
return;
|
|
1033
1083
|
}
|
|
1034
1084
|
if (!flag) {
|
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");
|
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
|
|
|
@@ -661,6 +662,21 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
661
662
|
}
|
|
662
663
|
|
|
663
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
|
+
|
|
664
680
|
|
|
665
681
|
public async getCurrentRunningState() {
|
|
666
682
|
const response = new GetRunningStateResponse();
|
|
@@ -934,6 +950,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
934
950
|
console.log('runExample');
|
|
935
951
|
this.childProcess = await this.startSkyEye(port, skyeyeDir);
|
|
936
952
|
await this.checkState();
|
|
953
|
+
await this.checkModule();
|
|
937
954
|
await this.setWorkingDirectory(pathSkyEye, port);
|
|
938
955
|
await this.runScript(fileName, port);
|
|
939
956
|
return true;
|
|
@@ -947,18 +964,56 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
947
964
|
}
|
|
948
965
|
}
|
|
949
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
|
+
|
|
950
1003
|
|
|
951
1004
|
|
|
952
1005
|
private checkState() {
|
|
953
1006
|
return new Promise((resolve, reject) => {
|
|
954
1007
|
let flag = true;
|
|
955
1008
|
const checkInterval = 500;
|
|
956
|
-
const timeout =
|
|
1009
|
+
const timeout = 30000;
|
|
957
1010
|
const startTime = Date.now();
|
|
1011
|
+
|
|
1012
|
+
|
|
958
1013
|
const check = () => {
|
|
959
1014
|
const elapsedTime = Date.now() - startTime;
|
|
960
1015
|
if (elapsedTime >= timeout) {
|
|
961
|
-
reject(new Error("Timeout: State check exceeded
|
|
1016
|
+
reject(new Error("Timeout: State check exceeded 30 seconds"));
|
|
962
1017
|
return;
|
|
963
1018
|
}
|
|
964
1019
|
|