node-insim
Version:
An InSim library for NodeJS with TypeScript support
180 lines (179 loc) • 7.01 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.OutSimPack = void 0;
var decorators_1 = require("../decorators");
var packets_1 = require("../packets");
/**
* OutSim - MOTION SIMULATOR SUPPORT AND TELEMETRY OUTPUT
*
* The user's car in multiplayer or the viewed car in single player or single player
* replay can output data to an external program while in VIEW_DRIVER or VIEW_CUSTOM.
*
* This can be controlled by 6 lines in the cfg.txt file:
*
* OutSim Mode 0 : 0 = off / 1 = driving / 2 = driving + replay
* OutSim Delay 1 : minimum delay between packets (100ths of a sec)
* OutSim IP 0.0.0.0 : IP address to send the UDP packet
* OutSim Port 0 : IP port
* OutSim ID 0 : if not zero, adds an identifier to the packet
* OutSim Opts 0 : see docs\OutSimPack.txt for the available options
*
* If OutSim Opts is zero, each update sends the following UDP packet.
*
* NOTE 1) X and Y axes are on the ground, Z is up.
*
* NOTE 2) Motion simulators can be dangerous. The Live for Speed developers do
* not support any motion systems in particular and cannot accept responsibility
* for injuries or deaths connected with the use of such machinery.
*/
var OutSimPack = /** @class */ (function (_super) {
__extends(OutSimPack, _super);
function OutSimPack() {
var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
/** Time in milliseconds (to check order) */
_this.Time = 0;
/** Angular velocity vector - X axis */
_this.AngVelX = 0;
/** Angular velocity vector - Y axis */
_this.AngVelY = 0;
/** Angular velocity vector - Z axis */
_this.AngVelZ = 0;
/** Anticlockwise from above (Z) */
_this.Heading = 0;
/** Anticlockwise from above (Z) */
_this.Pitch = 0;
/** Anticlockwise from above (Z) */
_this.Roll = 0;
/** Acceleration - X axis */
_this.AccelX = 0;
/** Acceleration - Y axis */
_this.AccelY = 0;
/** Acceleration - Z axis */
_this.AccelZ = 0;
/** Velocity - X axis */
_this.VelX = 0;
/** Velocity - Y axis */
_this.VelY = 0;
/** Velocity - Z axis */
_this.VelZ = 0;
/** Position - X axis (1 m = 65536) */
_this.PosX = 0;
/** Position - Y axis (1 m = 65536) */
_this.PosY = 0;
/** Position - Z axis (1 m = 65536) */
_this.PosZ = 0;
/** Optional - only if OutSim ID is specified */
_this.ID = 0;
return _this;
}
OutSimPack.prototype.unpack = function (buffer) {
var outSimData = buffer;
if (buffer.length === OutSimPack.MIN_SIZE) {
outSimData = new Uint8Array(OutSimPack.MAX_SIZE);
outSimData.set(buffer);
outSimData.set([0], OutSimPack.MIN_SIZE);
}
return _super.prototype.unpack.call(this, outSimData);
};
OutSimPack.MIN_SIZE = 64;
OutSimPack.MAX_SIZE = 68;
__decorate([
(0, decorators_1.unsigned)()
], OutSimPack.prototype, "Time", void 0);
__decorate([
(0, decorators_1.float)()
], OutSimPack.prototype, "AngVelX", void 0);
__decorate([
(0, decorators_1.float)()
], OutSimPack.prototype, "AngVelY", void 0);
__decorate([
(0, decorators_1.float)()
], OutSimPack.prototype, "AngVelZ", void 0);
__decorate([
(0, decorators_1.float)()
], OutSimPack.prototype, "Heading", void 0);
__decorate([
(0, decorators_1.float)()
], OutSimPack.prototype, "Pitch", void 0);
__decorate([
(0, decorators_1.float)()
], OutSimPack.prototype, "Roll", void 0);
__decorate([
(0, decorators_1.float)()
], OutSimPack.prototype, "AccelX", void 0);
__decorate([
(0, decorators_1.float)()
], OutSimPack.prototype, "AccelY", void 0);
__decorate([
(0, decorators_1.float)()
], OutSimPack.prototype, "AccelZ", void 0);
__decorate([
(0, decorators_1.float)()
], OutSimPack.prototype, "VelX", void 0);
__decorate([
(0, decorators_1.float)()
], OutSimPack.prototype, "VelY", void 0);
__decorate([
(0, decorators_1.float)()
], OutSimPack.prototype, "VelZ", void 0);
__decorate([
(0, decorators_1.int)()
], OutSimPack.prototype, "PosX", void 0);
__decorate([
(0, decorators_1.int)()
], OutSimPack.prototype, "PosY", void 0);
__decorate([
(0, decorators_1.int)()
], OutSimPack.prototype, "PosZ", void 0);
__decorate([
(0, decorators_1.int)()
], OutSimPack.prototype, "ID", void 0);
return OutSimPack;
}(packets_1.Struct));
exports.OutSimPack = OutSimPack;