wpilib-riolog
Version:
58 lines • 2.04 kB
JavaScript
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
var MessageType;
(function (MessageType) {
MessageType[MessageType["Error"] = 0] = "Error";
MessageType[MessageType["Warning"] = 1] = "Warning";
MessageType[MessageType["Print"] = 2] = "Print";
})(MessageType = exports.MessageType || (exports.MessageType = {}));
class PrintMessage {
constructor(data) {
this.messageType = MessageType.Print;
let count = 0;
this.timestamp = data.readFloatBE(count);
count += 4;
this.seqNumber = data.readInt16BE(count);
count += 2;
const slice = data.slice(count);
this.line = slice.toString('utf8');
}
}
exports.PrintMessage = PrintMessage;
class ErrorMessage {
constructor(data) {
let count = 0;
this.timestamp = data.readFloatBE(count);
count += 4;
this.seqNumber = data.readInt16BE(count);
count += 2;
this.numOccur = data.readInt16BE(count);
count += 2;
this.errorCode = data.readInt32BE(count);
count += 4;
this.flags = data.readUInt8(count);
count += 1;
let tmp = this.getSizedString(data, count);
this.details = tmp.data;
count += tmp.byteLength;
tmp = this.getSizedString(data, count);
this.location = tmp.data;
count += tmp.byteLength;
tmp = this.getSizedString(data, count);
this.callStack = tmp.data;
count += tmp.byteLength;
// tslint:disable-next-line:no-bitwise
this.messageType = (this.flags & 1) !== 0 ? MessageType.Error : MessageType.Warning;
}
getSizedString(data, start) {
const size = data.readUInt16BE(start);
start += 2;
const count = size + 2;
return {
byteLength: count,
data: data.toString('utf8', start, start + count - 2),
};
}
}
exports.ErrorMessage = ErrorMessage;
//# sourceMappingURL=message.js.map