skyeye-sdk-js 1.1.6 → 1.1.8
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/SkyEyeClient.js +5 -5
- package/package.json +1 -1
- package/src/SkyEyeClient.ts +10 -9
- package/src/GrpcUtil.js +0 -91
package/dist/src/SkyEyeClient.js
CHANGED
|
@@ -83,13 +83,13 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
|
|
|
83
83
|
}
|
|
84
84
|
Monitor(json) {
|
|
85
85
|
const _super = Object.create(null, {
|
|
86
|
-
|
|
86
|
+
monitor: { get: () => super.monitor }
|
|
87
87
|
});
|
|
88
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
89
|
try {
|
|
90
90
|
const request = new skyeye_rpc_pb_1.JSONRequest();
|
|
91
91
|
request.setRequest(json);
|
|
92
|
-
const stream = _super.
|
|
92
|
+
const stream = _super.monitor.call(this, request);
|
|
93
93
|
return stream;
|
|
94
94
|
}
|
|
95
95
|
catch (error) {
|
|
@@ -879,8 +879,6 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
|
|
|
879
879
|
cp.exec(skyeyeDir + " -q " + port + "\n", (err, stdout, stderr) => {
|
|
880
880
|
console.log('stdout: ' + stdout);
|
|
881
881
|
console.log('stderr: ' + stderr);
|
|
882
|
-
});
|
|
883
|
-
setTimeout(() => {
|
|
884
882
|
client = new skyeye_rpc_grpc_pb_1.JSONTransmissionClient('127.0.0.1:' + port, grpc.credentials.createInsecure());
|
|
885
883
|
console.log('client:' + client);
|
|
886
884
|
const Jr = new skyeye_rpc_pb_1.JSONRequest();
|
|
@@ -894,7 +892,9 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
|
|
|
894
892
|
return "1";
|
|
895
893
|
});
|
|
896
894
|
});
|
|
897
|
-
}
|
|
895
|
+
});
|
|
896
|
+
// setTimeout(() => {
|
|
897
|
+
// }, 2000);
|
|
898
898
|
}
|
|
899
899
|
}
|
|
900
900
|
exports.SkyEyeClient = SkyEyeClient;
|
package/package.json
CHANGED
package/src/SkyEyeClient.ts
CHANGED
|
@@ -60,7 +60,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
60
60
|
try {
|
|
61
61
|
const request = new JSONRequest();
|
|
62
62
|
request.setRequest(json);
|
|
63
|
-
const stream = super.
|
|
63
|
+
const stream = super.monitor(request);
|
|
64
64
|
return stream;
|
|
65
65
|
} catch (error) {
|
|
66
66
|
console.error("Error during Monitor:", error);
|
|
@@ -812,12 +812,11 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
812
812
|
public initSkyEyeAndRun(pathSkyEye: string, fileName: string, port: string, skyeyeDir: string) {
|
|
813
813
|
console.log('runExample');
|
|
814
814
|
cp.exec(skyeyeDir + " -q " + port + "\n", (err: any, stdout: any, stderr: any) => {
|
|
815
|
-
console.log('stdout: ' + stdout);
|
|
816
|
-
console.log('stderr: ' + stderr);
|
|
817
|
-
|
|
818
|
-
setTimeout(() => {
|
|
815
|
+
// console.log('stdout: ' + stdout);
|
|
816
|
+
// console.log('stderr: ' + stderr);
|
|
817
|
+
|
|
819
818
|
client = new JSONTransmissionClient('127.0.0.1:' + port, grpc.credentials.createInsecure());
|
|
820
|
-
console.log('client:' + client);
|
|
819
|
+
// console.log('client:' + client);
|
|
821
820
|
const Jr = new JSONRequest();
|
|
822
821
|
Jr.setRequest("{\"request\": {\"name\": \"chdir\", \"args\": {\"path\":\"" + pathSkyEye + "\"}}}");
|
|
823
822
|
client.callSkyEye(Jr, (error: ServiceError | null, response: JSONResponse) => {
|
|
@@ -826,13 +825,15 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
826
825
|
Jr.setRequest("{\"request\": {\"name\": \"run_script\", \"args\": {\"filename\":\"" + fileName + "\"}}}");
|
|
827
826
|
client.callSkyEye(Jr, (error: ServiceError | null, response: JSONResponse) => {
|
|
828
827
|
console.log("run_script res:" + response + error);
|
|
829
|
-
|
|
830
828
|
// this.runCommand()
|
|
831
|
-
|
|
832
829
|
return "1";
|
|
833
830
|
});
|
|
834
831
|
});
|
|
835
|
-
|
|
832
|
+
|
|
833
|
+
});
|
|
834
|
+
// setTimeout(() => {
|
|
835
|
+
|
|
836
|
+
// }, 2000);
|
|
836
837
|
}
|
|
837
838
|
|
|
838
839
|
|
package/src/GrpcUtil.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
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;
|