skyeye-sdk-js 1.4.15 → 1.4.16

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.
@@ -91,7 +91,7 @@ export declare class SkyEyeClient extends JSONTransmissionClient {
91
91
  getPort(): string;
92
92
  initSkyEyeAndRun(pathSkyEye: string, fileName: string, port: string, skyeyeDir: string): void;
93
93
  private childProcess;
94
- initSkyEyeAndRun2(pathSkyEye: string, fileName: string, port: string, skyeyeDir: string): Promise<boolean>;
94
+ initSkyEyeAndRun2(pathSkyEye: string, fileName: string, port: string, skyeyeDir: string, disableRun?: boolean): Promise<boolean>;
95
95
  private checkModule;
96
96
  private checkState;
97
97
  private startSkyEye;
@@ -1171,7 +1171,7 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
1171
1171
  });
1172
1172
  }, 2000);
1173
1173
  }
1174
- initSkyEyeAndRun2(pathSkyEye, fileName, port, skyeyeDir) {
1174
+ initSkyEyeAndRun2(pathSkyEye, fileName, port, skyeyeDir, disableRun) {
1175
1175
  return __awaiter(this, void 0, void 0, function* () {
1176
1176
  try {
1177
1177
  console.log('runExample');
@@ -1186,11 +1186,13 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
1186
1186
  ackObj.result = false;
1187
1187
  throw new Error(ackObj.error);
1188
1188
  }
1189
- response = yield this.runScript(fileName, port);
1190
- ackObj = JSON.parse(response.toString()).ack;
1191
- if (ackObj.result === "false") {
1192
- ackObj.result = false;
1193
- throw new Error(ackObj.error);
1189
+ if (!disableRun) {
1190
+ response = yield this.runScript(fileName, port);
1191
+ ackObj = JSON.parse(response.toString()).ack;
1192
+ if (ackObj.result === "false") {
1193
+ ackObj.result = false;
1194
+ throw new Error(ackObj.error);
1195
+ }
1194
1196
  }
1195
1197
  return true;
1196
1198
  }
package/dist/test.js CHANGED
@@ -1,8 +1,4 @@
1
1
  "use strict";
2
- // import { JSONResponse } from "./src/proto/skyeye_rpc_pb";
3
- // import { GrpcUtil } from "./src/GrpcUtil";
4
- // import { ServiceError } from "@grpc/grpc-js";
5
- // import { Enum } from "protobufjs";
6
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -14,13 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
14
10
  };
15
11
  Object.defineProperty(exports, "__esModule", { value: true });
16
12
  const { SkyEyeClientFactory } = require('./src/SkyEyeClientFactory');
17
- // const { SkyEyeClient } = require('./src/SkyEyeClient')
18
- // const { Cpu } = require('./src/models/Cpu')
19
- // enum RegisterType {
20
- // CPU,
21
- // Device
22
- // }
23
- // let call
13
+ const { SkyEyeClient } = require('./src/SkyEyeClient');
14
+ const { Cpu } = require('./src/models/Cpu');
15
+ var RegisterType;
16
+ (function (RegisterType) {
17
+ RegisterType[RegisterType["CPU"] = 0] = "CPU";
18
+ RegisterType[RegisterType["Device"] = 1] = "Device";
19
+ })(RegisterType || (RegisterType = {}));
24
20
  function test() {
25
21
  return __awaiter(this, void 0, void 0, function* () {
26
22
  // console.log("Connected to SkyEye server");
@@ -49,58 +45,20 @@ function test() {
49
45
  // console.log("response:", response)
50
46
  // console.log("response:", response.boardMap)
51
47
  // console.log("response:", response.boardMap.keys[0])
48
+ // await client.initSkyEyeAndRun(pathSkyEye,fileName,port,skyeyeDir);
52
49
  // const pathSkyEye = "D:/data/case/FMQL45T900_SylixOS";
53
50
  // const fileName = "FMQL45T900_SylixOS.skyeye";
54
51
  // const skyeyeDir = "D:/install/SkyEye/opt/skyeye/bin/skyeye.exe"
55
52
  // const port = "50066"
56
- const pathSkyEye = "C:/Users/lingt/Downloads/SkyTest_Double_rm_28335";
57
- const fileName = "C:/Users/lingt/Downloads/SkyTest_Double_rm_28335/SkyTest_Double.skyeye";
58
- const skyeyeDir = "G:/SkyEye/opt/skyeye/bin/skyeye.exe";
59
- const port = "50051";
60
- // const client = await SkyEyeClientFactory.instance.createConnectedClient('127.0.0.1', port);
53
+ const pathSkyEye = "D:/data/case/c6713_timer_test";
54
+ const fileName = "c6k.skyeye";
55
+ const skyeyeDir = "D:/install/SkyEye/opt/skyeye/bin/skyeye.exe";
56
+ const port = "50053";
61
57
  const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', port);
62
58
  const t = yield client.initSkyEyeAndRun2(pathSkyEye, fileName, port, skyeyeDir);
63
- yield client.runCommand();
64
- setTimeout(() => __awaiter(this, void 0, void 0, function* () {
65
- yield client.stopCommand();
66
- let response = yield client.getGlobalVarValue("c67x_core_0", "li1", 8, "int");
67
- console.log(response);
68
- response = yield client.setGlobalVarValue("c67x_core_0", "li1", 8, "int", "1234567890123456789");
69
- console.log(response);
70
- response = yield client.getGlobalVarValue("c67x_core_0", "li1", 8, "int");
71
- console.log(response);
72
- }), 3000);
73
- // await client.registerTimeMonitor({
74
- // "id": "1",
75
- // "time": 50,
76
- // "cpu_name": "c67x_core_0",
77
- // "direction":"recv",
78
- // "cycle":-1,
79
- // "items": [
80
- // {
81
- // "id": "cc5f450b-6fbb-7bb3-4544-e761a907b46d",
82
- // "cpu_name": "c67x_core_0",
83
- // "var_name": "int1",
84
- // "var_type": "int",
85
- // "var_bytes": 4,
86
- // "type": "global",
87
- // "value": "111"
88
- // }
89
- // ],
90
- // })
91
- // await client.startTimeMonitor("1")
92
- // // await client.getTimeMonitorConfig()
93
- // console.log('bbbbbbbbbbbb')
94
- // call = client.timeDataReceive("1")
95
- // call.on('data',(response)=> {
96
- // const ackObj = response.getResponse();
97
- // console.log(ackObj)
98
- // })
99
- // console.log('gggggggggggggg')
100
- // console.log(call)
101
- // await client.stopTimeMonitor()
102
- // response = client.setBitValue('c67x_core_0', '0x1000','1', 8)
103
- // console.log("response:", response)
59
+ client.runCommand();
60
+ const response = yield client.runToTime("c67x_core_0", "1");
61
+ console.log("response:", response);
104
62
  // const responseCpuList = await client.getCpuList()
105
63
  // console.log("responseCpuList:", responseCpuList)
106
64
  // const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', 50056);
@@ -110,343 +68,3 @@ function test() {
110
68
  });
111
69
  }
112
70
  test();
113
- // const protobuf = require("protobufjs");
114
- // const root = protobuf.loadSync("./src/proto/line_chart.proto");
115
- // const Series = root.lookupType("Series");
116
- // // const { UserData } = require('.src/proto/line_chart_pb'); // 预编译生成
117
- // // const fs = require('fs');
118
- // // JSON对象数据
119
- // const jsonData = {
120
- // series: [
121
- // ],
122
- // time: [
123
- // ]
124
- // };
125
- // for (let i = 0; i < 50; i++) {
126
- // jsonData.series.push({
127
- // name: 'test' + i,
128
- // value: []
129
- // })
130
- // }
131
- // function getRandomDouble(min, max) {
132
- // return Math.random() * (max - min) + min;
133
- // }
134
- // function getRandomInt(max) {
135
- // return Math.floor(Math.random() * max);
136
- // }
137
- // jsonData.series.forEach((item, index) => {
138
- // for (let i = 0; i < 300; i++) {
139
- // item.value.push(getRandomDouble(0,10000))
140
- // }
141
- // })
142
- // for (let i = 0; i < 300; i++) {
143
- // jsonData.time.push({
144
- // "realTime": getRandomDouble(0, 10000),
145
- // "simulationTime": getRandomDouble(0, 10000),
146
- // "customTime": getRandomDouble(0, 10000),
147
- // })
148
- // }
149
- // console.log(jsonData.series.length)
150
- // console.log(jsonData.series[0].value.length)
151
- // // function getSerializedSize(obj) {
152
- // // const jsonString = JSON.stringify(obj);
153
- // // return Buffer.byteLength(jsonString, 'utf8'); // 精确计算 UTF-8 字节数
154
- // // }
155
- // // console.log(getSerializedSize(jsonData))
156
- // // 序列化为Protobuf二进制Buffer
157
- // // const d1 = new Date();
158
- // // const protoBuffer = Series.encode(Series.create(jsonData)).finish();
159
- // // const d2 = new Date();
160
- // // console.log("序列化时间:", (d2.getTime() - d1.getTime()) / 1000);
161
- // // const zlib = require("zlib");
162
- // // // Gzip压缩(同步示例)
163
- // // const compressedData = zlib.gzipSync(protoBuffer);
164
- // // const d3 = new Date();
165
- // // console.log("压缩时间:", (d3.getTime() - d2.getTime()) / 1000);
166
- // // const fs = require("fs");
167
- // // const outputStream = fs.createWriteStream('test.dat');
168
- // // outputStream.write(compressedData);
169
- // // const d4 = new Date();
170
- // // console.log("存储时间:", (d4.getTime() - d3.getTime()) / 1000);
171
- // // console.log("压缩数据已存储");
172
- // // const zlib = require("zlib");
173
- // // const fs = require("fs");
174
- // // const { pipeline } = require('stream');
175
- // // const path = require("path");
176
- // // const d1 = new Date();
177
- // // // 1. 创建转换流:JSON → Protobuf 二进制
178
- // // const buffer = Series.encode(Series.create(jsonData)).finish();
179
- // // console.log('压缩')
180
- // // // 2. 创建压缩流(Brotli 高压缩率)
181
- // // const compress = zlib.createGzip({ level: 9 })
182
- // // const writeStream = fs.createWriteStream( "test.dat"); // 1MB 缓冲区
183
- // // // 5. 管道连接:序列化数据 → 压缩 → 写入文件
184
- // // const dataStream = require("stream").Readable.from(buffer); // 将 Buffer 转为可读流
185
- // // dataStream
186
- // // .pipe(compress) // 压缩数据
187
- // // .pipe(writeStream) // 写入文件
188
- // // .on("finish", () => {
189
- // // const d2 = new Date();
190
- // // console.log("序列化时间:", (d2.getTime() - d1.getTime()) / 1000);
191
- // // console.log("数据已压缩存储成功")
192
- // // })
193
- // // .on("error", (err) => console.error("❌ 写入失败:", err));
194
- // // const compressedInput = fs.readFileSync("user.dat");
195
- // // const decompressedData = zlib.gunzipSync(compressedInput);
196
- // // const decodedProto = Series.decode(decompressedData);
197
- // // const originalJson = Series.toObject(decodedProto, { arrays: true }); // 保留数组类型
198
- // // // console.log("还原的JSON:", originalJson);
199
- // // console.log("还原的JSON:", originalJson.series[0].data[0]);
200
- // const zlib = require("zlib");
201
- // const fs = require("fs");
202
- // class SplitFileWriter {
203
- // constructor() {
204
- // this.currentFile = null;
205
- // this.currentSize = 0;
206
- // this.fileIndex = 0;
207
- // this.filename = `test_111.dat`;
208
- // this.fd = null;
209
- // this.createNewFile();
210
- // }
211
- // createNewFile() {
212
- // if (this.currentFile) this.currentFile.end();
213
- // this.currentFile = fs.createWriteStream(this.filename,{flags: 'a', start: 4 });
214
- // this.currentSize = 0;
215
- // }
216
- // async writeHeader() {
217
- // // 1. 读取并修改前4字节整数
218
- // const readStream = fs.createReadStream(this.filename, { start: 0, end: 3 });
219
- // let headerBuffer = Buffer.alloc(0);
220
- // // 收集前4字节数据
221
- // readStream.on('data', (chunk) => {
222
- // headerBuffer = Buffer.concat([headerBuffer, chunk]);
223
- // });
224
- // // 等待头部读取完成
225
- // await new Promise((resolve, reject) => {
226
- // readStream.on('end', resolve);
227
- // readStream.on('error', reject);
228
- // });
229
- // const newHeaderBuffer = Buffer.alloc(4);
230
- // console.log(headerBuffer)
231
- // if (headerBuffer.length < 4) {
232
- // newHeaderBuffer.writeUInt32BE(0);
233
- // } else {
234
- // // 解析为整数并修改(小端序)
235
- // const originalInt = headerBuffer.readUInt32BE();
236
- // const modifiedInt = originalInt + 1;
237
- // newHeaderBuffer.writeUInt32BE(modifiedInt);
238
- // }
239
- // console.log(newHeaderBuffer.readUint32BE());
240
- // const compressedData = zlib.gzipSync(newHeaderBuffer)
241
- // console.log(compressedData)
242
- // // 2. 修改文件头部(覆盖写入前4字节)
243
- // const writeHeaderStream = fs.createWriteStream(this.filename, { flags: 'r+', start: 0, end:3 });
244
- // writeHeaderStream.write(newHeaderBuffer);
245
- // await new Promise((resolve) => writeHeaderStream.end(resolve));
246
- // }
247
- // async write(chunk) {
248
- // // 100MB限制(含压缩后数据)
249
- // if (this.currentSize + chunk.length > 1000 * 1024 * 1024 ) {
250
- // await this.createNewFile();
251
- // }
252
- // if(this.currentSize === 0) {
253
- // await this.writeHeader()
254
- // }
255
- // this.currentFile.write(chunk, 'binary',async ()=>{
256
- // const fd = this.currentFile.fd;
257
- // fs.fsyncSync(fd);
258
- // await this.writeHeader()
259
- // date2 = new Date()
260
- // console.log('存储时间:', (date2.getTime() - date1.getTime()) / 1000);
261
- // });
262
- // this.currentSize += chunk.length;
263
- // }
264
- // }
265
- // // 3. 每30秒处理数据的管道
266
- // const writer = new SplitFileWriter()
267
- // function handleData(data) {
268
- // let temp = {
269
- // series: [],
270
- // time: []}
271
- // temp.series =data.series.map(series => {
272
- // return {
273
- // name: series.name,
274
- // value: series.value.map(value => {
275
- // return handleDataValue(value)
276
- // })
277
- // }
278
- // })
279
- // temp.time.map(time => {
280
- // time.customTime = handleDataValue(time.customTime)
281
- // time.realTime = handleDataValue(time.realTime)
282
- // time.simulationTime = handleDataValue(time.simulationTime)
283
- // })
284
- // return temp
285
- // }
286
- // function handleDataValue(value) {
287
- // if (typeof value === 'string') {
288
- // return {
289
- // type: 'str',
290
- // stringValue: value
291
- // }
292
- // } else if (typeof value === 'number') {
293
- // if (Number.isInteger(value)) {
294
- // return {
295
- // type: 'int',
296
- // intValue: value
297
- // }
298
- // } else {
299
- // return {
300
- // type: 'dbl',
301
- // doubleValue: value
302
- // }
303
- // }
304
- // } else {
305
- // return {
306
- // type: 'str',
307
- // stringValue: 'undefined'
308
- // }
309
- // }
310
- // }
311
- // // let date1 = new Date();
312
- // // let date2 = new Date();
313
- // // const handled = handleData(jsonData)
314
- // // setInterval(async () => {
315
- // // console.log('下一次循环')
316
- // // date1 = new Date()
317
- // // const chunk = Series.create(handled);
318
- // // const serialized = Series.encode(chunk).finish();
319
- // // // 4. 创建带长度头的消息(解决边界问题)
320
- // // const header = Buffer.alloc(4);
321
- // // header.writeUInt32BE(serialized.length);
322
- // // const dataWithHeader = Buffer.concat([header, serialized]);
323
- // // const compressedData = zlib.gzipSync(dataWithHeader);
324
- // // await writer.write(compressedData)
325
- // // }, 5000);
326
- // function readAndProcessGzip(filePath) {
327
- // try {
328
- // // 1. 同步读取GZIP压缩文件
329
- // let compressedData = fs.readFileSync(filePath);
330
- // const header = Buffer.from(compressedData, 0, 4);
331
- // compressedData = compressedData.subarray(4);
332
- // const chunkSize = header.readUInt32BE();
333
- // // 2. 同步解压GZIP数据
334
- // let decompressedData = zlib.gunzipSync(compressedData);
335
- // // console.log(decompressedData)
336
- // // 3. 分块解析数据(假设格式为:[4字节长度头] + [序列化数据])
337
- // let offset = 0;
338
- // const chunks = [];
339
- // console.log(decompressedData.length)
340
- // console.log('chunkSize',chunkSize)
341
- // while (offset < decompressedData.length) {
342
- // // 3.1 检查长度头完整性(需4字节)
343
- // if (offset + 4 > decompressedData.length) {
344
- // throw new Error("Incomplete header at end of file");
345
- // }
346
- // // 3.2 读取消息长度(大端序)
347
- // const msgLength = decompressedData.readUInt32BE(offset);
348
- // offset += 4;
349
- // // 3.3 检查消息体完整性
350
- // // if (offset + msgLength > decompressedData.length) {
351
- // // throw new Error(`Incomplete data: expected ${msgLength} bytes, got ${decompressedData.length - offset}`);
352
- // // }
353
- // // 3.4 提取单条消息的Buffer
354
- // const msgBuffer = decompressedData.slice(offset, msgLength + offset);
355
- // decompressedData = decompressedData.slice(msgLength + offset);
356
- // offset= 0;
357
- // chunks.push(msgBuffer);
358
- // }
359
- // return chunks; // 返回解析后的Buffer数组
360
- // } catch (err) {
361
- // console.error("Processing failed:", err);
362
- // throw err; // 向上抛出异常
363
- // }
364
- // }
365
- // // // 使用示例
366
- // // const filePath = 'test_111.dat';
367
- // // // const filePath = 'test_1755569497065_0.dat';
368
- // // const date1 = new Date()
369
- // // const parsedChunks = readAndProcessGzip(filePath);
370
- // // const date2 = new Date()
371
- // // console.log("读取时间:", (date2.getTime() - date1.getTime()) / 1000);
372
- // // console.log(`Parsed ${parsedChunks.length} chunks`);
373
- // // parsedChunks.forEach((buf, i) => {
374
- // // // console.log(buf)
375
- // // const decoded = Series.decode(buf);
376
- // // console.log('读取数据长度:', decoded.series[0].value.length);
377
- // // console.log('读取数据第一个数据:', decoded.series[0].value[0]);
378
- // // console.log('读取数据:', decoded.time[0]);
379
- // // });
380
- // // console.log('处理时间:', (new Date().getTime() - date2.getTime()) / 1000);
381
- // const filePath = 'G:\\testchunk\\双板测试通讯_线性图_Z2ooQ_20250827_150827.dat';
382
- // const { pipeline } = require('stream');
383
- // const readHeaderStream = fs.createReadStream(filePath,{start:0, end:3});
384
- // let headerBuffer = Buffer.alloc(0);
385
- // // 收集前4字节数据
386
- // readHeaderStream.on('data', (chunk) => {
387
- // headerBuffer = Buffer.concat([headerBuffer, chunk]);
388
- // console.log('chunkkkkkkSize',headerBuffer.readUInt32BE())
389
- // });
390
- // // 等待头部读取完成
391
- // const readStream = fs.createReadStream(filePath,{start:4});
392
- // // 2. 创建解压流(Gunzip)
393
- // const gunzipStream = zlib.createGunzip();
394
- // // 3. 初始化数组存储解压后的数据块
395
- // const decompressedData = Buffer.alloc(0)
396
- // const chunks = [];
397
- // // 4. 监听解压流的数据事件,收集数据块
398
- // class ChunkProcessor extends Transform {
399
- // constructor(decompressedData) {
400
- // super();
401
- // this.arr = decompressedData
402
- // }
403
- // _transform(chunk, encoding, callback) {
404
- // // 将当前 chunk 加入阻塞队列
405
- // // console.log(chunk.length)
406
- // // console.log(this.arr)
407
- // try {
408
- // this.arr = Buffer.concat([this.arr, chunk]);
409
- // let offset = 0;
410
- // while (offset <= this.arr.length) {
411
- // // 3.1 检查长度头完整性(需4字节)
412
- // if (offset + 4 > this.arr.length) {
413
- // break
414
- // }
415
- // // 3.2 读取消息长度(大端序)
416
- // const msgLength = this.arr.readUInt32BE(offset);
417
- // offset += 4;
418
- // // console.log(msgLength)
419
- // // 3.3 检查消息体完整性
420
- // if (offset + msgLength > this.arr.length) {
421
- // break;
422
- // }
423
- // // 3.4 提取单条消息的Buffer
424
- // const msgBuffer = this.arr.slice(offset, msgLength + offset);
425
- // this.arr = this.arr.slice(msgLength + offset);
426
- // offset= 0;
427
- // // console.log(msgBuffer.length)
428
- // chunks.push(msgBuffer);
429
- // }
430
- // callback();
431
- // } catch (err) {
432
- // console.error("Pipeline error:", err);
433
- // callback(err);
434
- // }
435
- // }
436
- // }
437
- // readStream.pipe(gunzipStream).pipe(new ChunkProcessor(decompressedData)).on('error', err => console.error('Pipeline error:', err)).on('finish', () => {
438
- // console.log('读取chunk个:', chunks.length);
439
- // let sum = 0
440
- // chunks.forEach((buf, i) => {
441
- // // console.log(buf)
442
- // const decoded = Series.decode(buf);
443
- // decoded.series.forEach((item, index) => {
444
- // console.log(item.value[item.value.length - 1].intValue)
445
- // })
446
- // console.log('读取数据长度:', decoded.series[0].value.length);
447
- // sum += decoded.series[0].value.length
448
- // // console.log('读取数据第一个数据:', decoded.series[0].value[0]);
449
- // // console.log('读取数据:', decoded.time[0]);
450
- // });
451
- // console.log('读取数据总长度:', sum);
452
- // });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skyeye-sdk-js",
3
- "version": "1.4.15",
3
+ "version": "1.4.16",
4
4
  "description": "gRPC to SkyEye",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1080,7 +1080,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
1080
1080
 
1081
1081
  private childProcess: cp.ChildProcess | null = null;
1082
1082
 
1083
- public async initSkyEyeAndRun2(pathSkyEye: string, fileName: string, port: string, skyeyeDir: string) {
1083
+ public async initSkyEyeAndRun2(pathSkyEye: string, fileName: string, port: string, skyeyeDir: string, disableRun?: boolean) {
1084
1084
  try {
1085
1085
  console.log('runExample');
1086
1086
 
@@ -1095,11 +1095,13 @@ export class SkyEyeClient extends JSONTransmissionClient {
1095
1095
  ackObj.result = false
1096
1096
  throw new Error(ackObj.error)
1097
1097
  }
1098
- response = await this.runScript(fileName, port);
1099
- ackObj = JSON.parse(response.toString()).ack;
1100
- if (ackObj.result === "false") {
1101
- ackObj.result = false
1102
- throw new Error(ackObj.error)
1098
+ if (!disableRun) {
1099
+ response = await this.runScript(fileName, port);
1100
+ ackObj = JSON.parse(response.toString()).ack;
1101
+ if (ackObj.result === "false") {
1102
+ ackObj.result = false
1103
+ throw new Error(ackObj.error)
1104
+ }
1103
1105
  }
1104
1106
  return true;
1105
1107
  } catch (error) {