skyeye-sdk-js 1.4.0 → 1.4.2

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,8 @@ export declare class RequestFactory {
4
4
  private static _instance;
5
5
  private constructor();
6
6
  static getInstance(): RequestFactory;
7
+ getAddressWidth(cpuName: string): JSONRequest;
8
+ getModuleStatus(): JSONRequest;
7
9
  getRunningStatus(): JSONRequest;
8
10
  runScriptRequest(filename: string): JSONRequest;
9
11
  runCommand(): JSONRequest;
@@ -11,6 +11,23 @@ class RequestFactory {
11
11
  }
12
12
  return this._instance;
13
13
  }
14
+ //判断模块是否完全加载成功
15
+ getAddressWidth(cpuName) {
16
+ const baseRequest = new BaseRequest_1.BaseRequest("SE_get_cpu_address_width");
17
+ const args = {};
18
+ args.cpuname = cpuName;
19
+ baseRequest.setArgs(args);
20
+ const request = new skyeye_rpc_pb_1.JSONRequest();
21
+ request.setRequest(baseRequest.toJSONString());
22
+ return request;
23
+ }
24
+ //判断模块是否完全加载成功
25
+ getModuleStatus() {
26
+ const baseRequest = new BaseRequest_1.BaseRequest("SE_get_modules_loaded_status");
27
+ const request = new skyeye_rpc_pb_1.JSONRequest();
28
+ request.setRequest(baseRequest.toJSONString());
29
+ return request;
30
+ }
14
31
  getRunningStatus() {
15
32
  const baseRequest = new BaseRequest_1.BaseRequest("SE_get_running_status");
16
33
  const request = new skyeye_rpc_pb_1.JSONRequest();
@@ -14,6 +14,8 @@ 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';
18
+ import { GetAddressWidthResponse } from './response/GetAddressWidthResponse';
17
19
  export declare class SkyEyeClient extends JSONTransmissionClient {
18
20
  private host;
19
21
  private port;
@@ -58,6 +60,8 @@ export declare class SkyEyeClient extends JSONTransmissionClient {
58
60
  setCpuRegisterValue(boardName: string, cpuName: string, registerName: string, value: string): Promise<any>;
59
61
  setDeviceRegisterValue(machName: string, deviceName: string, registerName: string, value: string): Promise<any>;
60
62
  getDeviceTree(): Promise<GetDeviceTreeResponse>;
63
+ getAddressWidth(cpuName: string): Promise<GetAddressWidthResponse>;
64
+ getModuleStatus(): Promise<BaseResponse>;
61
65
  getCurrentRunningState(): Promise<GetRunningStateResponse>;
62
66
  getAllDeviceInfo(): Promise<GetAllDeviceInfoResponse>;
63
67
  getRamAddrInfo(machName: string, addr: string): Promise<GetRamAddrInfoResponse>;
@@ -78,6 +82,7 @@ export declare class SkyEyeClient extends JSONTransmissionClient {
78
82
  initSkyEyeAndRun(pathSkyEye: string, fileName: string, port: string, skyeyeDir: string): void;
79
83
  private childProcess;
80
84
  initSkyEyeAndRun2(pathSkyEye: string, fileName: string, port: string, skyeyeDir: string): Promise<boolean>;
85
+ private checkModule;
81
86
  private checkState;
82
87
  private startSkyEye;
83
88
  private setWorkingDirectory;
@@ -55,6 +55,8 @@ 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");
59
+ const GetAddressWidthResponse_1 = require("./response/GetAddressWidthResponse");
58
60
  let client = null;
59
61
  // ----------------------------当前运行程序的设备树----------------------------------------//
60
62
  const boardMap = new Map();
@@ -729,6 +731,38 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
729
731
  return response;
730
732
  });
731
733
  }
734
+ getAddressWidth(cpuName) {
735
+ return __awaiter(this, void 0, void 0, function* () {
736
+ const response = new GetAddressWidthResponse_1.GetAddressWidthResponse();
737
+ try {
738
+ const call = yield this.call(RequestFactory_1.RequestFactory.getInstance().getAddressWidth(cpuName));
739
+ // { result: 2, error: null, name: 'SE_get_running_status' }
740
+ if (call != null) {
741
+ response.isSuccess = true;
742
+ response.result = call.result;
743
+ }
744
+ console.log(call);
745
+ }
746
+ catch (error) {
747
+ }
748
+ return response;
749
+ });
750
+ }
751
+ getModuleStatus() {
752
+ return __awaiter(this, void 0, void 0, function* () {
753
+ const response = new BaseResponse_1.BaseResponse();
754
+ try {
755
+ const call = yield this.call(RequestFactory_1.RequestFactory.getInstance().getModuleStatus());
756
+ // { result: 2, error: null, name: 'SE_get_running_status' }
757
+ if (call != null) {
758
+ response.isSuccess = call.result;
759
+ }
760
+ }
761
+ catch (error) {
762
+ }
763
+ return response;
764
+ });
765
+ }
732
766
  getCurrentRunningState() {
733
767
  return __awaiter(this, void 0, void 0, function* () {
734
768
  const response = new GetRunningStateResponse_1.GetRunningStateResponse();
@@ -1005,6 +1039,7 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
1005
1039
  console.log('runExample');
1006
1040
  this.childProcess = yield this.startSkyEye(port, skyeyeDir);
1007
1041
  yield this.checkState();
1042
+ yield this.checkModule();
1008
1043
  yield this.setWorkingDirectory(pathSkyEye, port);
1009
1044
  yield this.runScript(fileName, port);
1010
1045
  return true;
@@ -1019,16 +1054,49 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
1019
1054
  }
1020
1055
  });
1021
1056
  }
1057
+ checkModule() {
1058
+ return new Promise((resolve, reject) => {
1059
+ let flag = true;
1060
+ const checkInterval = 500;
1061
+ const timeout = 30000;
1062
+ const startTime = Date.now();
1063
+ const check = () => {
1064
+ const elapsedTime = Date.now() - startTime;
1065
+ if (elapsedTime >= timeout) {
1066
+ reject(new Error("Timeout: State check exceeded 30 seconds"));
1067
+ return;
1068
+ }
1069
+ if (!flag) {
1070
+ resolve("");
1071
+ return;
1072
+ }
1073
+ this.getModuleStatus()
1074
+ .then((result) => {
1075
+ if (result.isSuccess) {
1076
+ flag = false;
1077
+ resolve("");
1078
+ }
1079
+ else {
1080
+ setTimeout(check, checkInterval);
1081
+ }
1082
+ })
1083
+ .catch(() => {
1084
+ setTimeout(check, checkInterval);
1085
+ });
1086
+ };
1087
+ check();
1088
+ });
1089
+ }
1022
1090
  checkState() {
1023
1091
  return new Promise((resolve, reject) => {
1024
1092
  let flag = true;
1025
1093
  const checkInterval = 500;
1026
- const timeout = 12000;
1094
+ const timeout = 30000;
1027
1095
  const startTime = Date.now();
1028
1096
  const check = () => {
1029
1097
  const elapsedTime = Date.now() - startTime;
1030
1098
  if (elapsedTime >= timeout) {
1031
- reject(new Error("Timeout: State check exceeded 12 seconds"));
1099
+ reject(new Error("Timeout: State check exceeded 30 seconds"));
1032
1100
  return;
1033
1101
  }
1034
1102
  if (!flag) {
@@ -0,0 +1,4 @@
1
+ import { BaseResponse } from "./BaseResponse";
2
+ export declare class GetAddressWidthResponse extends BaseResponse {
3
+ result: object;
4
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetAddressWidthResponse = void 0;
4
+ const BaseResponse_1 = require("./BaseResponse");
5
+ class GetAddressWidthResponse extends BaseResponse_1.BaseResponse {
6
+ }
7
+ exports.GetAddressWidthResponse = GetAddressWidthResponse;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skyeye-sdk-js",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "gRPC to SkyEye",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -16,6 +16,25 @@ export class RequestFactory {
16
16
  return this._instance;
17
17
  }
18
18
 
19
+ //判断模块是否完全加载成功
20
+ public getAddressWidth(cpuName: string) {
21
+ const baseRequest = new BaseRequest("SE_get_cpu_address_width");
22
+ const args: { [key: string]: string } = {};
23
+ args.cpuname = cpuName;
24
+ baseRequest.setArgs(args)
25
+ const request = new JSONRequest()
26
+ request.setRequest(baseRequest.toJSONString());
27
+ return request;
28
+ }
29
+
30
+ //判断模块是否完全加载成功
31
+ public getModuleStatus() {
32
+ const baseRequest = new BaseRequest("SE_get_modules_loaded_status");
33
+ const request = new JSONRequest()
34
+ request.setRequest(baseRequest.toJSONString());
35
+ return request;
36
+ }
37
+
19
38
 
20
39
  public getRunningStatus() {
21
40
  const baseRequest = new BaseRequest("SE_get_running_status");
@@ -24,6 +24,8 @@ 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';
28
+ import { GetAddressWidthResponse } from './response/GetAddressWidthResponse';
27
29
  let client: JSONTransmissionClient | any = null;
28
30
 
29
31
 
@@ -661,6 +663,39 @@ export class SkyEyeClient extends JSONTransmissionClient {
661
663
  }
662
664
 
663
665
 
666
+ public async getAddressWidth(cpuName:string) {
667
+ const response = new GetAddressWidthResponse();
668
+
669
+ try {
670
+ const call = await this.call(RequestFactory.getInstance().getAddressWidth(cpuName))
671
+ // { result: 2, error: null, name: 'SE_get_running_status' }
672
+ if (call != null) {
673
+ response.isSuccess = true;
674
+ response.result = call.result
675
+ }
676
+ console.log(call)
677
+ } catch (error) {
678
+ }
679
+ return response;
680
+ }
681
+
682
+
683
+
684
+ public async getModuleStatus() {
685
+ const response = new BaseResponse();
686
+
687
+ try {
688
+ const call = await this.call(RequestFactory.getInstance().getModuleStatus())
689
+ // { result: 2, error: null, name: 'SE_get_running_status' }
690
+ if (call != null) {
691
+ response.isSuccess = call.result;
692
+ }
693
+ } catch (error) {
694
+ }
695
+ return response;
696
+ }
697
+
698
+
664
699
 
665
700
  public async getCurrentRunningState() {
666
701
  const response = new GetRunningStateResponse();
@@ -934,6 +969,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
934
969
  console.log('runExample');
935
970
  this.childProcess = await this.startSkyEye(port, skyeyeDir);
936
971
  await this.checkState();
972
+ await this.checkModule();
937
973
  await this.setWorkingDirectory(pathSkyEye, port);
938
974
  await this.runScript(fileName, port);
939
975
  return true;
@@ -947,18 +983,56 @@ export class SkyEyeClient extends JSONTransmissionClient {
947
983
  }
948
984
  }
949
985
 
986
+ private checkModule() {
987
+ return new Promise((resolve, reject) => {
988
+ let flag = true;
989
+ const checkInterval = 500;
990
+ const timeout = 30000;
991
+ const startTime = Date.now();
992
+
993
+
994
+ const check = () => {
995
+ const elapsedTime = Date.now() - startTime;
996
+ if (elapsedTime >= timeout) {
997
+ reject(new Error("Timeout: State check exceeded 30 seconds"));
998
+ return;
999
+ }
1000
+
1001
+ if (!flag) {
1002
+ resolve("");
1003
+ return;
1004
+ }
1005
+ this.getModuleStatus()
1006
+ .then((result) => {
1007
+ if (result.isSuccess) {
1008
+ flag = false;
1009
+ resolve("");
1010
+ } else {
1011
+ setTimeout(check, checkInterval);
1012
+ }
1013
+ })
1014
+ .catch(() => {
1015
+ setTimeout(check, checkInterval);
1016
+ });
1017
+ };
1018
+ check();
1019
+ });
1020
+ }
1021
+
950
1022
 
951
1023
 
952
1024
  private checkState() {
953
1025
  return new Promise((resolve, reject) => {
954
1026
  let flag = true;
955
1027
  const checkInterval = 500;
956
- const timeout = 12000;
1028
+ const timeout = 30000;
957
1029
  const startTime = Date.now();
1030
+
1031
+
958
1032
  const check = () => {
959
1033
  const elapsedTime = Date.now() - startTime;
960
1034
  if (elapsedTime >= timeout) {
961
- reject(new Error("Timeout: State check exceeded 12 seconds"));
1035
+ reject(new Error("Timeout: State check exceeded 30 seconds"));
962
1036
  return;
963
1037
  }
964
1038
 
@@ -0,0 +1,6 @@
1
+ import { Board } from "../models/Board";
2
+ import { BaseResponse } from "./BaseResponse";
3
+
4
+ export class GetAddressWidthResponse extends BaseResponse{
5
+ result:object
6
+ }