skyeye-sdk-js 1.1.2 → 1.1.4

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.
@@ -76,7 +76,7 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
76
76
  return stream;
77
77
  }
78
78
  catch (error) {
79
- console.error("Error during RunTestcase:", error);
79
+ console.error("Error during RunTestcas2e:", error);
80
80
  throw error;
81
81
  }
82
82
  });
@@ -890,7 +890,7 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
890
890
  Jr.setRequest("{\"request\": {\"name\": \"run_script\", \"args\": {\"filename\":\"" + fileName + "\"}}}");
891
891
  client.callSkyEye(Jr, (error, response) => {
892
892
  console.log("run_script res:" + response + error);
893
- this.runCommand();
893
+ // this.runCommand()
894
894
  return "1";
895
895
  });
896
896
  });
package/dist/test.js CHANGED
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ const GrpcUtil_1 = require("./src/GrpcUtil");
12
13
  const { SkyEyeClientFactory } = require('./src/SkyEyeClientFactory');
13
14
  const { SkyEyeClient } = require('./src/SkyEyeClient');
14
15
  function test() {
@@ -18,31 +19,21 @@ function test() {
18
19
  // await client.getDeviceList();
19
20
  // await client.getCurrentCpuMips();
20
21
  // await client.runCommand();
21
- const response = yield client.getCurrentRunningState();
22
+ // const response = await client.getCurrentRunningState();
22
23
  // const response = await client.getGlobalVarValueDefault("a",GlobalVarType.DOUBLE);
23
24
  // const response = await client.getGlobalVarValue("cx53123","a",16,GlobalVarType.DOUBLE);
24
25
  // const response = await client.getCpuRegistersDefault();
25
26
  // const response = await client.getCpuRegisters("c7xx");
26
27
  // const response = await client.getMemoryValueDefault(1, 16);
27
28
  // const response = await client.getMemoryValue("c7s",0,16);
28
- console.log("结果response:", response);
29
- // const pathSkyEye = "D:/data/case/c6713_demo";
30
- // const fileName = "c6713_demo.skyeye";
31
- // const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe"
32
- // const port = "50051"
33
- // await client.initSkyEyeAndRun(pathSkyEye,fileName,port,skyeyeDir);
34
- // GrpcUtil.initAndRunExample();
29
+ // console.log("结果response:", response)
30
+ const pathSkyEye = "D:/data/case/c6713_demo";
31
+ const fileName = "c6713_demo.skyeye";
32
+ const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe";
33
+ const port = "50051";
34
+ yield client.initSkyEyeAndRun(pathSkyEye, fileName, port, skyeyeDir);
35
+ GrpcUtil_1.GrpcUtil.initAndRunExample();
35
36
  // const bean:string = '{"id":"33d209da-2459-4e49-97c3-5b1509bc638c","steps":[{"condition":{"type":10,"value":"123"},"send":{"target":{"type":2,"addr":"1222"},"data":"0101011101"}},{"condition":{"type":0,"value":"0xff"},"send":{"target":{"type":2,"addr":"1222"},"data":"0101011101"}}],"expects":[{"condition":{"type":0,"value":"0xff"},"send":{"target":{"type":3,"addr":"2221"}}}]}';
36
- // const stream = await client.RunTestcase(bean);
37
- // stream.on('data', (response: JSONResponse) => {
38
- // console.log('Received response:', response.toObject());
39
- // });
40
- // stream.on('end', () => {
41
- // console.log('Stream ended');
42
- // });
43
- // stream.on('error', (error: Error) => {
44
- // console.error('Error occurred:', error.message);
45
- // });
46
37
  });
47
38
  }
48
39
  test();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skyeye-sdk-js",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "gRPC to SkyEye",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GrpcUtil = void 0;
4
+ var grpc = require("@grpc/grpc-js");
5
+ var skyeye_rpc_pb_1 = require("./proto/skyeye_rpc_pb");
6
+ var skyeye_rpc_grpc_pb_1 = require("./proto/skyeye_rpc_grpc_pb");
7
+ var SkyEyeClient_1 = require("./SkyEyeClient");
8
+ var client = null;
9
+ var cp = require("child_process");
10
+ var GrpcUtil = /** @class */ (function () {
11
+ function GrpcUtil(host, port) {
12
+ this.Jr = new skyeye_rpc_pb_1.JSONRequest();
13
+ client = new SkyEyeClient_1.SkyEyeClient(host, port);
14
+ }
15
+ GrpcUtil.initAndRunExample = function () {
16
+ // const pathSkyEye = "D:/install/SkyEye/demo/c6713_demo";
17
+ var pathSkyEye = "D:/data/case/c6713_demo";
18
+ var fileName = "c6713_demo.skyeye";
19
+ console.log('runExample');
20
+ // const output = vscode.window.createOutputChannel("SkyEye Output");
21
+ // output.show(true);
22
+ // 命令行,进实例,跑skyeye.exe
23
+ cp.exec("cd " + pathSkyEye + " / && skyeye.exe -q 50051\n", function (err, stdout, stderr) {
24
+ // output.append(stdout);
25
+ // output.append(stderr);
26
+ console.log('stdout: ' + stdout);
27
+ console.log('stderr: ' + stderr);
28
+ });
29
+ setTimeout(function () {
30
+ //客户端
31
+ client = new skyeye_rpc_grpc_pb_1.JSONTransmissionClient('127.0.0.1:50051', grpc.credentials.createInsecure());
32
+ console.log('client:' + client);
33
+ //chdir
34
+ var Jr = new skyeye_rpc_pb_1.JSONRequest();
35
+ Jr.setRequest("{\"request\": {\"name\": \"chdir\", \"args\": {\"path\":\"" + pathSkyEye + "\"}}}");
36
+ client.callSkyEye(Jr, function (error, response) {
37
+ console.log("chdir res:" + response + error);
38
+ // client.run_script();
39
+ Jr.setRequest("{\"request\": {\"name\": \"run_script\", \"args\": {\"filename\":\"" + fileName + "\"}}}");
40
+ client.callSkyEye(Jr, function (error, response) {
41
+ console.log("run_script res:" + response + error);
42
+ });
43
+ });
44
+ }, 2000);
45
+ return "1";
46
+ };
47
+ //status
48
+ GrpcUtil.prototype.getRunningStatus = function () {
49
+ this.Jr.setRequest("{\"request\": {\"name\": \"SE_get_running_status\", \"args\": {}}}");
50
+ client.callSkyEye(this.Jr, function (error, response) {
51
+ var obj = eval("(" + response.toString() + ")");
52
+ var ackObj = JSON.parse(JSON.stringify(obj.ack));
53
+ console.log("ackObj.result:" + ackObj.result);
54
+ return ackObj;
55
+ });
56
+ };
57
+ //run
58
+ GrpcUtil.prototype.runCommand = function () {
59
+ this.Jr.setRequest("{\"request\": {\"name\": \"run\", \"args\": {}}}");
60
+ client.callSkyEye(this.Jr, function (error, response) {
61
+ console.log("res" + response + error);
62
+ var obj = eval("(" + response.toString() + ")");
63
+ var ackObj = JSON.parse(JSON.stringify(obj.ack));
64
+ console.log("ackObj.result" + ackObj.result);
65
+ });
66
+ };
67
+ //stop
68
+ GrpcUtil.prototype.stopCommand = function () {
69
+ this.Jr.setRequest("{\"request\": {\"name\": \"stop\", \"args\": {}}}");
70
+ client.callSkyEye(this.Jr, function (error, response) {
71
+ console.log("res" + response + error);
72
+ });
73
+ };
74
+ //quit
75
+ GrpcUtil.prototype.quitCommand = function () {
76
+ this.Jr.setRequest("{\"request\": {\"name\": \"quit\", \"args\": {}}}");
77
+ client.callSkyEye(this.Jr, function (error, response) {
78
+ console.log("res" + response + error);
79
+ });
80
+ };
81
+ //SE_get_device_register_info 设备寄存器信息(表格内容)
82
+ GrpcUtil.prototype.getDeviceRegisterInfo = function (machname, devname, _callback) {
83
+ console.log('SE_get_device_register_info:machname:' + machname + ' devname' + devname);
84
+ this.Jr.setRequest("{\"request\": {\"name\": \"SE_get_device_register_info\",\"args\":{\"machname\": \"" + machname + "\",\"devname\": \"" + devname + "\"}}}");
85
+ client.callSkyEye(this.Jr, function (error, response) {
86
+ console.log("res" + response + error);
87
+ });
88
+ };
89
+ return GrpcUtil;
90
+ }());
91
+ exports.GrpcUtil = GrpcUtil;
@@ -50,7 +50,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
50
50
  const stream = super.runTestcase(request);
51
51
  return stream;
52
52
  } catch (error) {
53
- console.error("Error during RunTestcase:", error);
53
+ console.error("Error during RunTestcas2e:", error);
54
54
  throw error;
55
55
  }
56
56
  }
@@ -827,7 +827,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
827
827
  client.callSkyEye(Jr, (error: ServiceError | null, response: JSONResponse) => {
828
828
  console.log("run_script res:" + response + error);
829
829
 
830
- this.runCommand()
830
+ // this.runCommand()
831
831
 
832
832
  return "1";
833
833
  });
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseRequest = void 0;
4
+ var BaseRequest = /** @class */ (function () {
5
+ function BaseRequest(name) {
6
+ this.request = {
7
+ name: name,
8
+ args: null
9
+ };
10
+ }
11
+ BaseRequest.prototype.toJSONString = function () {
12
+ return JSON.stringify({ request: this.request });
13
+ };
14
+ BaseRequest.prototype.setArgs = function (args) {
15
+ this.request.args = args;
16
+ };
17
+ return BaseRequest;
18
+ }());
19
+ exports.BaseRequest = BaseRequest;
@@ -0,0 +1,27 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.BaseResponse = void 0;
19
+ var skyeye_rpc_pb_1 = require("../proto/skyeye_rpc_pb");
20
+ var BaseResponse = /** @class */ (function (_super) {
21
+ __extends(BaseResponse, _super);
22
+ function BaseResponse() {
23
+ return _super !== null && _super.apply(this, arguments) || this;
24
+ }
25
+ return BaseResponse;
26
+ }(skyeye_rpc_pb_1.JSONResponse));
27
+ exports.BaseResponse = BaseResponse;
package/test.ts CHANGED
@@ -12,7 +12,7 @@ async function test() {
12
12
  // await client.getCurrentCpuMips();
13
13
  // await client.runCommand();
14
14
 
15
- const response = await client.getCurrentRunningState();
15
+ // const response = await client.getCurrentRunningState();
16
16
 
17
17
  // const response = await client.getGlobalVarValueDefault("a",GlobalVarType.DOUBLE);
18
18
  // const response = await client.getGlobalVarValue("cx53123","a",16,GlobalVarType.DOUBLE);
@@ -22,26 +22,17 @@ async function test() {
22
22
 
23
23
  // const response = await client.getMemoryValueDefault(1, 16);
24
24
  // const response = await client.getMemoryValue("c7s",0,16);
25
- console.log("结果response:", response)
25
+ // console.log("结果response:", response)
26
26
 
27
- // const pathSkyEye = "D:/data/case/c6713_demo";
28
- // const fileName = "c6713_demo.skyeye";
29
- // const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe"
30
- // const port = "50051"
31
- // await client.initSkyEyeAndRun(pathSkyEye,fileName,port,skyeyeDir);
27
+ const pathSkyEye = "D:/data/case/c6713_demo";
28
+ const fileName = "c6713_demo.skyeye";
29
+ const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe"
30
+ const port = "50051"
31
+ await client.initSkyEyeAndRun(pathSkyEye,fileName,port,skyeyeDir);
32
32
 
33
- // GrpcUtil.initAndRunExample();
33
+ GrpcUtil.initAndRunExample();
34
34
 
35
35
  // const bean:string = '{"id":"33d209da-2459-4e49-97c3-5b1509bc638c","steps":[{"condition":{"type":10,"value":"123"},"send":{"target":{"type":2,"addr":"1222"},"data":"0101011101"}},{"condition":{"type":0,"value":"0xff"},"send":{"target":{"type":2,"addr":"1222"},"data":"0101011101"}}],"expects":[{"condition":{"type":0,"value":"0xff"},"send":{"target":{"type":3,"addr":"2221"}}}]}';
36
- // const stream = await client.RunTestcase(bean);
37
- // stream.on('data', (response: JSONResponse) => {
38
- // console.log('Received response:', response.toObject());
39
- // });
40
- // stream.on('end', () => {
41
- // console.log('Stream ended');
42
- // });
43
- // stream.on('error', (error: Error) => {
44
- // console.error('Error occurred:', error.message);
45
- // });
36
+
46
37
  }
47
38
  test();