Check fkexible

calculation
main
DenisN 2025-04-24 18:54:19 -04:00
parent 7c580e5066
commit 5e3d836b29
11 changed files with 146 additions and 11 deletions

View File

@ -24,6 +24,7 @@
"@nestjs/core": "^11.0.1",
"@nestjs/platform-express": "^11.0.1",
"axios": "1.8.4",
"mathjs": "^14.4.0",
"module": "^1.2.5",
"mqtt": "^5.10.4",
"reflect-metadata": "^0.2.2",

View File

@ -20,6 +20,9 @@ importers:
axios:
specifier: 1.8.4
version: 1.8.4(debug@2.6.9)
mathjs:
specifier: ^14.4.0
version: 14.4.0
module:
specifier: ^1.2.5
version: 1.2.5
@ -1572,6 +1575,9 @@ packages:
commist@3.2.0:
resolution: {integrity: sha512-4PIMoPniho+LqXmpS5d3NuGYncG6XWlkBSVGiWycL22dd42OYdUGil2CWuzklaJoNxyxUSpO4MKIBU94viWNAw==}
complex.js@2.4.2:
resolution: {integrity: sha512-qtx7HRhPGSCBtGiST4/WGHuW+zeaND/6Ld+db6PbrulIB1i2Ev/2UPiqcmpQNPSyfBKraC0EOvOKCB5dGZKt3g==}
component-emitter@1.3.1:
resolution: {integrity: sha512-T0+barUSQRTUQASh8bx02dl+DhF54GtIDY13Y3m9oWTklKbb3Wv974meRpeZ3lp1JpLVECWWNHC4vaG2XHXouQ==}
@ -1687,6 +1693,9 @@ packages:
resolution: {integrity: sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==}
engines: {node: '>=0.10.0'}
decimal.js@10.5.0:
resolution: {integrity: sha512-8vDa8Qxvr/+d94hSh5P3IJwI5t8/c0KsMp+g8bNw9cY2icONa5aPfvKeieW1WlG0WQYwwhJ7mjui2xtiePQSXw==}
decode-uri-component@0.2.2:
resolution: {integrity: sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==}
engines: {node: '>=0.10'}
@ -1823,6 +1832,9 @@ packages:
escape-html@1.0.3:
resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==}
escape-latex@1.2.0:
resolution: {integrity: sha512-nV5aVWW1K0wEiUIEdZ4erkGGH8mDxGyxSeqPzRNtWP7ataw+/olFObw7hujFWlVjNsaDFw5VZ5NzVSIqRgfTiw==}
escape-string-regexp@1.0.5:
resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==}
engines: {node: '>=0.8.0'}
@ -2109,6 +2121,10 @@ packages:
resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==}
engines: {node: '>= 0.6'}
fraction.js@5.2.2:
resolution: {integrity: sha512-uXBDv5knpYmv/2gLzWQ5mBHGBRk9wcKTeWu6GLTUEQfjCxO09uM/mHDrojlL+Q1mVGIIFo149Gba7od1XPgSzQ==}
engines: {node: '>= 12'}
fresh@0.5.2:
resolution: {integrity: sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==}
engines: {node: '>= 0.6'}
@ -2495,6 +2511,9 @@ packages:
engines: {node: '>=10'}
hasBin: true
javascript-natural-sort@0.7.1:
resolution: {integrity: sha512-nO6jcEfZWQXDhOiBtG2KvKyEptz7RVbpGP4vTD2hLBdmNQSsCiicO2Ioinv6UI4y9ukqnBpy+XZ9H6uLNgJTlw==}
jest-changed-files@29.7.0:
resolution: {integrity: sha512-fEArFiwf1BpQ+4bXSprcDc3/x4HSzL4al2tozwVpDFpsxALjLYdyiIK4e5Vz66GQJIbXJ82+35PtysofptNX2w==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
@ -2807,6 +2826,11 @@ packages:
math-random@1.0.4:
resolution: {integrity: sha512-rUxjysqif/BZQH2yhd5Aaq7vXMSx9NdEsQcyA07uEzIvxgI7zIr33gGsh+RU0/XjmQpCW7RsVof1vlkvQVCK5A==}
mathjs@14.4.0:
resolution: {integrity: sha512-CpoYDhNENefjIG9wU9epr+0pBHzlaySfpWcblZdAf5qXik/j/U8eSmx/oNbmXO0F5PyfwPGVD/wK4VWsTho1SA==}
engines: {node: '>= 18'}
hasBin: true
media-typer@0.3.0:
resolution: {integrity: sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==}
engines: {node: '>= 0.6'}
@ -3392,6 +3416,9 @@ packages:
resolution: {integrity: sha512-Gf9qqc58SpCA/xdziiHz35F4GNIWYWZrEshUc/G/r5BnLph6xpKuLeoJoQuj5WfBIx/eQLf+hmVPYHaxJu7V2g==}
engines: {node: '>= 10.13.0'}
seedrandom@3.0.5:
resolution: {integrity: sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg==}
seek-bzip@2.0.0:
resolution: {integrity: sha512-SMguiTnYrhpLdk3PwfzHeotrcwi8bNV4iemL9tx9poR/yeaMYwB9VzR1w7b57DuWpuqR8n6oZboi0hj3AxZxQg==}
hasBin: true
@ -3697,6 +3724,9 @@ packages:
resolution: {integrity: sha512-Y9q1GaV/BO65Z9Yf4NOGMuwt3SGdptkZBnaaKfTQakrDyCLiuO1Kc5wxW4xLdsjzunRtqtOdhekiUFmZbklwYQ==}
engines: {node: '>=0.10.0'}
tiny-emitter@2.1.0:
resolution: {integrity: sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==}
tmp@0.0.33:
resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==}
engines: {node: '>=0.6.0'}
@ -3806,6 +3836,10 @@ packages:
resolution: {integrity: sha512-gd0sGezQYCbWSbkZr75mln4YBidWUN60+devscpLF5mtRDUpiaTvKpBNrdaCvel1NdR2k6vclXybU5fBd2i+nw==}
engines: {node: '>= 0.6'}
typed-function@4.2.1:
resolution: {integrity: sha512-EGjWssW7Tsk4DGfE+5yluuljS1OGYWiI1J6e8puZz9nTMM51Oug8CD5Zo4gWMsOhq5BI+1bF+rWTm4Vbj3ivRA==}
engines: {node: '>= 18'}
typedarray@0.0.6:
resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==}
@ -5736,6 +5770,8 @@ snapshots:
commist@3.2.0: {}
complex.js@2.4.2: {}
component-emitter@1.3.1: {}
concat-map@0.0.1: {}
@ -5850,6 +5886,8 @@ snapshots:
decamelize@1.2.0: {}
decimal.js@10.5.0: {}
decode-uri-component@0.2.2: {}
decompress-response@6.0.0:
@ -5954,6 +5992,8 @@ snapshots:
escape-html@1.0.3: {}
escape-latex@1.2.0: {}
escape-string-regexp@1.0.5: {}
escape-string-regexp@2.0.0: {}
@ -6306,6 +6346,8 @@ snapshots:
forwarded@0.2.0: {}
fraction.js@5.2.2: {}
fresh@0.5.2: {}
fresh@2.0.0: {}
@ -6683,6 +6725,8 @@ snapshots:
filelist: 1.0.4
minimatch: 3.1.2
javascript-natural-sort@0.7.1: {}
jest-changed-files@29.7.0:
dependencies:
execa: 5.1.1
@ -7152,6 +7196,18 @@ snapshots:
math-random@1.0.4: {}
mathjs@14.4.0:
dependencies:
'@babel/runtime': 7.26.10
complex.js: 2.4.2
decimal.js: 10.5.0
escape-latex: 1.2.0
fraction.js: 5.2.2
javascript-natural-sort: 0.7.1
seedrandom: 3.0.5
tiny-emitter: 2.1.0
typed-function: 4.2.1
media-typer@0.3.0: {}
media-typer@1.1.0: {}
@ -7733,6 +7789,8 @@ snapshots:
ajv-formats: 2.1.1(ajv@8.17.1)
ajv-keywords: 5.1.0(ajv@8.17.1)
seedrandom@3.0.5: {}
seek-bzip@2.0.0:
dependencies:
commander: 6.2.1
@ -8071,6 +8129,8 @@ snapshots:
dependencies:
os-homedir: 1.0.2
tiny-emitter@2.1.0: {}
tmp@0.0.33:
dependencies:
os-tmpdir: 1.0.2
@ -8181,6 +8241,8 @@ snapshots:
media-typer: 1.1.0
mime-types: 3.0.0
typed-function@4.2.1: {}
typedarray@0.0.6: {}
typescript-eslint@8.27.0(eslint@9.22.0)(typescript@5.8.2):

View File

@ -2,9 +2,10 @@ import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ZvksmetricsModule } from './zvksmetrics/zvksmetrics.module';
import { GruberModule } from './gruber/gruber.module';
@Module({
imports: [ZvksmetricsModule],
imports: [ZvksmetricsModule, GruberModule],
controllers: [AppController],
providers: [AppService],
})

View File

@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { GruberController } from './gruber.controller';
describe('GruberController', () => {
let controller: GruberController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [GruberController],
}).compile();
controller = module.get<GruberController>(GruberController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

View File

@ -0,0 +1,4 @@
import { Controller } from '@nestjs/common';
@Controller('gruber')
export class GruberController {}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { GruberService } from './gruber.service';
import { GruberController } from './gruber.controller';
@Module({
providers: [GruberService],
controllers: [GruberController]
})
export class GruberModule {}

View File

@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { GruberService } from './gruber.service';
describe('GruberService', () => {
let service: GruberService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [GruberService],
}).compile();
service = module.get<GruberService>(GruberService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View File

@ -0,0 +1,4 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class GruberService {}

View File

@ -2,19 +2,19 @@
{
"name": "measure_190", "_comment":"Загрузка процессора за 1 минуту",
"ranges": [
{"min": 0, "max": 0, "status": 3},
{"min": 0, "max": 0.1, "status": 0},
{"min": 0.11, "max": 0.12, "status": 1},
{"min": 0.13, "max": 1, "status": 2},
{"min": 0.5, "max": 0.8, "status": 1}
{"min": 0, "max": 0, "status": 3, "sum": "a+b*a-a"},
{"min": 0, "max": 0.1, "status": 0, "sum": "val: a+b"},
{"min": 0.11, "max": 0.12, "status": 1, "sum": "a+b"} ,
{"min": 0.13, "max": 1, "status": 2, "sum": "a+b"},
{"min": 0.5, "max": 0.8, "status": 1, "sum": "a+b"}
]
},
{
"name": "measure_191", "_comment":"Загрузка процессора за 5 минут",
"ranges": [
{"min": 0, "max": 0.2, "status": 0},
{"min": 0.21, "max": 0.32, "status": 1},
{"min": 0.33, "max": 1, "status": 2}
{"min": 0, "max": 0.2, "status": 0, "sum": "a+b"},
{"min": 0.21, "max": 0.32, "status": 1, "sum": "a+b"},
{"min": 0.33, "max": 1, "status": 2, "sum": "a+b"}
]
}
]

View File

@ -7,9 +7,13 @@ export class ZvksmetricsController {
@Get('ranges')
async getHello(): Promise<any> {
let a: number = 7;
let b: number = 9;
let sum: any = {value: (a+b)/4*b+a};
// let a = await this.metricsService.showStatus();
// console.log(a);
return null;
console.log(sum.value);
return sum.value;
}
//Заглушка для будующей API
@ -24,6 +28,7 @@ export class ZvksmetricsController {
@Post('input')
async getPostMessage (@Body() inputMetrics : any) : Promise<string> {
//console.log(inputMetrics);
let out: any = await this.metricsService.useStatusModel(inputMetrics);
return out;
}

View File

@ -2,6 +2,8 @@ import { Body, Injectable } from '@nestjs/common';
import axios, { Axios, AxiosResponse } from 'axios';
import { readFile } from 'node:fs/promises';
import { response } from 'express';
import { json } from 'node:stream/consumers';
import math, { create, all, evaluate } from 'mathjs'
@Injectable()
@ -26,6 +28,7 @@ export class RangeValues {
min: number;
max: number;
status: number;
sum: any;
};
@Injectable()
@ -45,6 +48,16 @@ export class ZvksmetricsService {
let scope : MetricsRanges [] = [];
scope = await this.setMetricsRanges ();
let rng: any = {val: [{x:3}, {x:4}, {x:5}, {x:9}]};
// console.log(rng.val[0].x);
let testFormula: string = (rng.val[0].x + rng.val[1].x - rng.val[2].x + rng.val[3].x).toString();
// let formula: string = scope[0].ranges[0].sum;
// let value: any = {formula};
console.log(evaluate(testFormula, rng));
let editedMetrics : K2Metrics = await this.getMetrics (inp, scope);
let responseFromExporter : any = await this.sendMetrics (editedMetrics);