From 21aa28241b4f089cdf791b22e19e8f398b6913c5 Mon Sep 17 00:00:00 2001 From: Nikolai Sukhanov Date: Thu, 31 Aug 2023 18:23:55 +0400 Subject: [PATCH] fix(control schemes): fix profile add/dec default timing --- .../port-config-edit-page.component.ts | 13 ++++++------- src/app/shared/i-app-config.ts | 4 ---- src/app/store/reducers/control-scheme.reducer.ts | 10 ++++------ 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/app/control-schemes/port-config-edit-page/port-config-edit-page.component.ts b/src/app/control-schemes/port-config-edit-page/port-config-edit-page.component.ts index cdd435fe..04afae91 100644 --- a/src/app/control-schemes/port-config-edit-page/port-config-edit-page.component.ts +++ b/src/app/control-schemes/port-config-edit-page/port-config-edit-page.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, Inject, OnDestroy, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core'; import { Store } from '@ngrx/store'; import { JsonPipe, NgIf } from '@angular/common'; import { PushPipe } from '@ngrx/component'; @@ -9,8 +9,8 @@ import { MatInputModule } from '@angular/material/input'; import { TranslocoModule } from '@ngneat/transloco'; import { MatButtonModule } from '@angular/material/button'; import { Router } from '@angular/router'; -import { APP_CONFIG, HintComponent, IAppConfig } from '@app/shared'; -import { CONTROL_SCHEME_ACTIONS } from '@app/store'; +import { HintComponent } from '@app/shared'; +import { CONTROL_SCHEME_ACTIONS, DEFAULT_ACC_DEC_PROFILE_TIME_MS } from '@app/store'; import { PORT_CONFIG_EDIT_PAGE_SELECTORS } from './port-config-edit-page.selectors'; import { RoutesBuilderService } from '../../routing'; @@ -38,11 +38,11 @@ export class PortConfigEditPageComponent implements OnInit, OnDestroy { public readonly minAccDecProfileTimeMs = 0; - public readonly maxAccDecProfileTimeMs = this.config.maxAccDecProfileTimeMs; + public readonly maxAccDecProfileTimeMs = 10000; public readonly formGroup = this.formBuilder.group({ accelerationTimeMs: this.formBuilder.control( - this.config.defaultAccDecProfileTimeMs, + DEFAULT_ACC_DEC_PROFILE_TIME_MS, { nonNullable: true, validators: [ @@ -53,7 +53,7 @@ export class PortConfigEditPageComponent implements OnInit, OnDestroy { } ), decelerationTimeMs: this.formBuilder.control( - this.config.defaultAccDecProfileTimeMs, + DEFAULT_ACC_DEC_PROFILE_TIME_MS, { nonNullable: true, validators: [ @@ -70,7 +70,6 @@ export class PortConfigEditPageComponent implements OnInit, OnDestroy { constructor( private readonly store: Store, private readonly formBuilder: FormBuilder, - @Inject(APP_CONFIG) private readonly config: IAppConfig, private readonly routesBuilder: RoutesBuilderService, private readonly router: Router ) { diff --git a/src/app/shared/i-app-config.ts b/src/app/shared/i-app-config.ts index d0a9bba2..1842a092 100644 --- a/src/app/shared/i-app-config.ts +++ b/src/app/shared/i-app-config.ts @@ -7,8 +7,6 @@ export interface IAppConfig { readonly hubBatteryPollInterval: number; readonly hubRssiPollInterval: number; readonly logLevel: LogLevel; - readonly defaultAccDecProfileTimeMs: number; - readonly maxAccDecProfileTimeMs: number; } export const APP_CONFIG = new InjectionToken('APP_CONFIG', { @@ -18,8 +16,6 @@ export const APP_CONFIG = new InjectionToken('APP_CONFIG', { hubBatteryPollInterval: 20000, hubRssiPollInterval: 10000, logLevel: isDevMode() ? LogLevel.Debug : LogLevel.Warning, - defaultAccDecProfileTimeMs: 100, - maxAccDecProfileTimeMs: 10000, }), providedIn: 'root' }); diff --git a/src/app/store/reducers/control-scheme.reducer.ts b/src/app/store/reducers/control-scheme.reducer.ts index 98e7e9af..92bcd731 100644 --- a/src/app/store/reducers/control-scheme.reducer.ts +++ b/src/app/store/reducers/control-scheme.reducer.ts @@ -5,18 +5,14 @@ import { ControlSchemeBinding, ControlSchemeModel, ControlSchemePortConfig } fro import { CONTROL_SCHEME_ACTIONS } from '../actions'; import { attachedIosIdFn } from './attached-ios.reducer'; -const DEFAULT_ACCELERATION_PROFILE_TIME_MS = 1000; - -const DEFAULT_DECELERATION_PROFILE_TIME_MS = 1000; - function createDefaultPortConfig( { hubId, portId }: { hubId: string; portId: number }, ): ControlSchemePortConfig { return { hubId, portId, - accelerationTimeMs: DEFAULT_ACCELERATION_PROFILE_TIME_MS, - decelerationTimeMs: DEFAULT_DECELERATION_PROFILE_TIME_MS, + accelerationTimeMs: DEFAULT_ACC_DEC_PROFILE_TIME_MS, + decelerationTimeMs: DEFAULT_ACC_DEC_PROFILE_TIME_MS, }; } @@ -46,6 +42,8 @@ function ensurePortConfigsAreUpToDate( return portConfigs; } +export const DEFAULT_ACC_DEC_PROFILE_TIME_MS = 100; + export enum ControlSchemeRunState { Idle, Starting,