@mindconnect/mindconnect-nodejs
Version:
NodeJS Library for MindSphere Connectivity - TypeScript SDK for MindSphere - MindSphere Command Line Interface - MindSphere Development Proxy
98 lines • 4.51 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SignalCalculationClient = void 0;
const sdk_client_1 = require("../common/sdk-client");
/**
* Applies operations on one or multiple small input time series -- referred here as signals --
* producing a new signal as output.
*
* Idea¶
* The Signal Calculation Service processes time series data of an entity's sensor.
* The service aggregates, modifies, smoothes and transforms the original sensor data
* for further analysis or storage along with the original data.
*
* The service enables a user to carry out the following tasks:
*
* Detect missing sensor values
* Replace missing sensor values with interpolated ones
* Compute a new physical parameter from available sensor readings
* Aggregate sensor values over a sliding window
*
*
*
* @export
* @class SignalCalculationClient
* @extends {SdkClient}
* @see https://developer.mindsphere.io/apis/analytics-signalcalculation/api-signalcalculation-overview.html
*/
class SignalCalculationClient extends sdk_client_1.SdkClient {
constructor() {
super(...arguments);
this._baseUrl = "/api/signalcalculation/v3";
}
/**
* Applies an operation to the specified properties for the operands defined in the body parameters
*
* @param {SignalCalculationModels.InputParameters} body Operation properties and input data
* @returns {Promise<SignalCalculationModels.Signal>}
*
* @memberOf SignalCalculationClient
*/
PostApplyOperation(body) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.HttpAction({
verb: "POST",
gateway: this.GetGateway(),
authorization: yield this.GetToken(),
body: body,
baseUrl: `${this._baseUrl}/applyOperation`,
}));
});
}
PostApplyOperationDirectRaw(body) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.HttpAction({
verb: "POST",
gateway: this.GetGateway(),
authorization: yield this.GetToken(),
body: body,
baseUrl: `${this._baseUrl}/applyOperationDirect`,
}));
});
}
/**
* Applies an operation to the specified properties for the operands defined in the body parameters
*
* @param {SignalCalculationModels.InputParametersDirect} body Operation properties and input data
* @returns {Promise<SignalCalculationModels.SignalDirect>}
*
* @memberOf SignalCalculationClient
*/
PostApplyOperationDirect(body) {
return __awaiter(this, void 0, void 0, function* () {
const result = yield this.PostApplyOperationDirectRaw(body);
result.timeSeries.forEach((result) => {
var _a, _b, _c, _d;
if (((_a = result._time) === null || _a === void 0 ? void 0 : _a.nano) && ((_b = result._time) === null || _b === void 0 ? void 0 : _b.epochSecond)) {
const unixMillisecondsDate = ((_c = result._time) === null || _c === void 0 ? void 0 : _c.epochSecond) * 1000 + Math.floor(((_d = result._time) === null || _d === void 0 ? void 0 : _d.nano) / 1000000);
// !fix: this thing is buggy, as it returns the nano precision epoch timestamp
// !instead of proper ISOString date, fix on the client, report to mindsphere,
// !hope for the server side fix...
result._time = new Date(unixMillisecondsDate).toISOString();
}
});
return result;
});
}
}
exports.SignalCalculationClient = SignalCalculationClient;
//# sourceMappingURL=signal-calculation.js.map