Skip to content

Commit

Permalink
chore: binding-related naming fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nvsukhanov committed Mar 6, 2024
1 parent cf56a8a commit 2260b1b
Show file tree
Hide file tree
Showing 78 changed files with 551 additions and 529 deletions.
16 changes: 8 additions & 8 deletions modules/bindings/src/lib/binding-details-edit-form-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { ControlSchemeBindingType, DeepPartial } from '@app/shared-misc';
import { IBindingDetailsEditFormRenderer } from '@app/shared-control-schemes';

import { IBindingsDetailsEditComponent } from './i-bindings-details-edit-component';
import { BindingSpeedEditComponent, SpeedBindingFormBuilderService, SpeedBindingFormMapperService } from './speed';
import { BindingServoEditComponent, ServoBindingFormBuilderService, ServoBindingFormMapperService } from './servo';
import { BindingSetAngleEditComponent, SetAngleBindingFormBuilderService, SetAngleBindingFormMapperService } from './set-angle';
import { BindingStepperEditComponent, StepperBindingFormBuilderService, StepperBindingFormMapperService } from './stepper';
import { SpeedBindingEditComponent, SpeedBindingFormBuilderService, SpeedBindingFormMapperService } from './speed';
import { ServoBindingEditComponent, ServoBindingFormBuilderService, ServoBindingFormMapperService } from './servo';
import { SetAngleBindingEditComponent, SetAngleBindingFormBuilderService, SetAngleBindingFormMapperService } from './set-angle';
import { StepperBindingEditComponent, StepperBindingFormBuilderService, StepperBindingFormMapperService } from './stepper';
import { TrainBindingEditComponent, TrainBindingFormBuilderService, TrainBindingFormMapperService } from './train';
import { GearboxBindingEditComponent, GearboxBindingFormBuilderService, GearboxBindingFormMapperService } from './gearbox';

Expand All @@ -19,10 +19,10 @@ export class BindingDetailsEditFormRenderer implements IBindingDetailsEditFormRe
public readonly bindingFormDirtyChange: Observable<boolean>;

private readonly renderers: { [k in ControlSchemeBindingType]: Type<IBindingsDetailsEditComponent> | null } = {
[ControlSchemeBindingType.Speed]: BindingSpeedEditComponent,
[ControlSchemeBindingType.Servo]: BindingServoEditComponent,
[ControlSchemeBindingType.SetAngle]: BindingSetAngleEditComponent,
[ControlSchemeBindingType.Stepper]: BindingStepperEditComponent,
[ControlSchemeBindingType.Speed]: SpeedBindingEditComponent,
[ControlSchemeBindingType.Servo]: ServoBindingEditComponent,
[ControlSchemeBindingType.SetAngle]: SetAngleBindingEditComponent,
[ControlSchemeBindingType.Stepper]: StepperBindingEditComponent,
[ControlSchemeBindingType.Train]: TrainBindingEditComponent,
[ControlSchemeBindingType.Gearbox]: GearboxBindingEditComponent
};
Expand Down
32 changes: 16 additions & 16 deletions modules/bindings/src/lib/binding-l10n.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { ControlSchemeBindingType } from '@app/shared-misc';

import { IBindingL10n } from './i-binding-l10n';
import { GearboxBindingL10nService } from './gearbox';
import { ServoL10nService } from './servo';
import { SetAngleL10nService } from './set-angle';
import { SpeedL10nService } from './speed';
import { StepperL10nService } from './stepper';
import { ServoBindingL10nService } from './servo';
import { SetAngleBindingL10nService } from './set-angle';
import { SpeedBindingL10nService } from './speed';
import { StepperBindingL10nService } from './stepper';
import { TrainBindingL10nService } from './train';

@Injectable()
Expand All @@ -20,21 +20,21 @@ export class BindingL10nService implements IBindingControllerInputNameResolver,
IBindingTypeToL10nKeyMapper
{
private readonly bindingL10nServices: { [k in ControlSchemeBindingType]: IBindingL10n<k> } = {
[ControlSchemeBindingType.Gearbox]: this.gearboxL10nService,
[ControlSchemeBindingType.Servo]: this.servoL10nService,
[ControlSchemeBindingType.SetAngle]: this.setAngleL10nService,
[ControlSchemeBindingType.Speed]: this.speedL10nService,
[ControlSchemeBindingType.Stepper]: this.stepperL10nService,
[ControlSchemeBindingType.Train]: this.trainL10nService
[ControlSchemeBindingType.Gearbox]: this.gearboxBindingL10nService,
[ControlSchemeBindingType.Servo]: this.servoBindingL10nService,
[ControlSchemeBindingType.SetAngle]: this.setAngleBindingL10nService,
[ControlSchemeBindingType.Speed]: this.speedBindingL10nService,
[ControlSchemeBindingType.Stepper]: this.stepperBindingL10nService,
[ControlSchemeBindingType.Train]: this.trainBindingL10nService
};

constructor(
private readonly gearboxL10nService: GearboxBindingL10nService,
private readonly servoL10nService: ServoL10nService,
private readonly setAngleL10nService: SetAngleL10nService,
private readonly speedL10nService: SpeedL10nService,
private readonly stepperL10nService: StepperL10nService,
private readonly trainL10nService: TrainBindingL10nService
private readonly gearboxBindingL10nService: GearboxBindingL10nService,
private readonly servoBindingL10nService: ServoBindingL10nService,
private readonly setAngleBindingL10nService: SetAngleBindingL10nService,
private readonly speedBindingL10nService: SpeedBindingL10nService,
private readonly stepperBindingL10nService: StepperBindingL10nService,
private readonly trainBindingL10nService: TrainBindingL10nService
) {
}

Expand Down
16 changes: 8 additions & 8 deletions modules/bindings/src/lib/binding-task-factory.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Injectable } from '@angular/core';
import { ControlSchemeBindingType } from '@app/shared-misc';
import { AttachedIoPropsModel, ControlSchemeBinding, ITaskFactory, PortCommandTask, PortCommandTaskPayload } from '@app/store';

import { ServoTaskPayloadBuilderService } from './servo';
import { SetAngleTaskPayloadBuilderService } from './set-angle';
import { SpeedTaskPayloadBuilderService } from './speed';
import { ServoBindingTaskPayloadBuilderService } from './servo';
import { SetAngleBindingTaskPayloadBuilderService } from './set-angle';
import { SpeedBindingTaskPayloadBuilderService } from './speed';
import { TrainBindingTaskPayloadBuilderService } from './train';
import { StepperTaskPayloadBuilderService } from './stepper';
import { StepperBindingTaskPayloadBuilderService } from './stepper';
import { GearboxBindingTaskPayloadBuilderService } from './gearbox';
import { BindingTaskPayloadHashBuilderService } from './binding-task-payload-hash-builder.service';
import { ITaskPayloadBuilder } from './i-task-payload-factory';
Expand All @@ -25,11 +25,11 @@ export class BindingTaskFactoryService implements ITaskFactory {
};

constructor(
private readonly servoTaskPayloadBuilder: ServoTaskPayloadBuilderService,
private readonly setAngleTaskPayloadBuilder: SetAngleTaskPayloadBuilderService,
private readonly speedTaskPayloadBuilder: SpeedTaskPayloadBuilderService,
private readonly servoTaskPayloadBuilder: ServoBindingTaskPayloadBuilderService,
private readonly setAngleTaskPayloadBuilder: SetAngleBindingTaskPayloadBuilderService,
private readonly speedTaskPayloadBuilder: SpeedBindingTaskPayloadBuilderService,
private readonly trainTaskPayloadBuilder: TrainBindingTaskPayloadBuilderService,
private readonly stepperTaskPayloadBuilder: StepperTaskPayloadBuilderService,
private readonly stepperTaskPayloadBuilder: StepperBindingTaskPayloadBuilderService,
private readonly gearboxTaskPayloadBuilder: GearboxBindingTaskPayloadBuilderService,
private readonly hashBuilder: BindingTaskPayloadHashBuilderService
) {
Expand Down
6 changes: 3 additions & 3 deletions modules/bindings/src/lib/binding-task-filter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { ITaskFilter, PortCommandTask } from '@app/store';

import { IBindingTaskFilter } from './i-binding-task-filter';
import { HashCompareFilterService, MostRecentTaskFilterService } from './common';
import { SpeedFilterService } from './speed';
import { SpeedBindingTaskFilterService } from './speed';

@Injectable()
export class BindingTaskFilterService implements ITaskFilter {
private readonly filters: { [k in ControlSchemeBindingType]: IBindingTaskFilter<k> } = {
[ControlSchemeBindingType.Speed]: this.speedFilter,
[ControlSchemeBindingType.Speed]: this.speedBindingTaskFilter,
[ControlSchemeBindingType.Servo]: this.hashCompareFilter,
[ControlSchemeBindingType.SetAngle]: this.mostRecentTaskFilter,
[ControlSchemeBindingType.Stepper]: this.mostRecentTaskFilter,
Expand All @@ -19,7 +19,7 @@ export class BindingTaskFilterService implements ITaskFilter {

constructor(
private readonly mostRecentTaskFilter: MostRecentTaskFilterService,
private readonly speedFilter: SpeedFilterService,
private readonly speedBindingTaskFilter: SpeedBindingTaskFilterService,
private readonly hashCompareFilter: HashCompareFilterService
) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { Injectable } from '@angular/core';
import { PortCommandTaskPayload } from '@app/store';
import { ControlSchemeBindingType } from '@app/shared-misc';

import { servoPayloadHash } from './servo';
import { setAnglePayloadHash } from './set-angle';
import { speedPayloadHash } from './speed';
import { stepperPayloadHash } from './stepper';
import { servoBindingPayloadHash } from './servo';
import { setAngleBindingPayloadHash } from './set-angle';
import { speedBindingPayloadHash } from './speed';
import { stepperBindingPayloadHash } from './stepper';
import { trainBindingPayloadHash } from './train';
import { gearboxBindingPayloadHash } from './gearbox';

Expand All @@ -16,13 +16,13 @@ export class BindingTaskPayloadHashBuilderService {
): string {
switch (payload.bindingType) {
case ControlSchemeBindingType.Servo:
return servoPayloadHash(payload);
return servoBindingPayloadHash(payload);
case ControlSchemeBindingType.SetAngle:
return setAnglePayloadHash(payload);
return setAngleBindingPayloadHash(payload);
case ControlSchemeBindingType.Speed:
return speedPayloadHash(payload);
return speedBindingPayloadHash(payload);
case ControlSchemeBindingType.Stepper:
return stepperPayloadHash(payload);
return stepperBindingPayloadHash(payload);
case ControlSchemeBindingType.Train:
return trainBindingPayloadHash(payload);
case ControlSchemeBindingType.Gearbox:
Expand Down
32 changes: 16 additions & 16 deletions modules/bindings/src/lib/binding-task-runner.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ import { Observable } from 'rxjs';
import { ControlSchemeBindingType } from '@app/shared-misc';
import { ITaskRunner, PortCommandTask } from '@app/store';

import { ServoTaskRunnerService } from './servo';
import { SetAngleTaskRunnerService } from './set-angle';
import { SpeedTaskRunnerService } from './speed';
import { ServoBindingTaskRunnerService } from './servo';
import { SetAngleBindingTaskRunnerService } from './set-angle';
import { SpeedBindingTaskRunnerService } from './speed';
import { TrainBindingTaskRunnerService } from './train';
import { StepperTaskRunnerService } from './stepper';
import { StepperBindingTaskRunnerService } from './stepper';
import { GearboxBindingTaskRunnerService } from './gearbox';
import { IBindingTaskRunner } from './i-binding-task-runner';

@Injectable()
export class BindingTaskRunnerService implements ITaskRunner {
private readonly runnersMap: { [k in ControlSchemeBindingType]: IBindingTaskRunner<k> } = {
[ControlSchemeBindingType.Servo]: this.servoTaskRunnerService,
[ControlSchemeBindingType.SetAngle]: this.setAngleTaskRunnerService,
[ControlSchemeBindingType.Speed]: this.speedTaskRunnerService,
[ControlSchemeBindingType.Stepper]: this.stepperTaskRunnerService,
[ControlSchemeBindingType.Train]: this.trainTaskRunnerService,
[ControlSchemeBindingType.Gearbox]: this.gearboxTaskRunnerService,
[ControlSchemeBindingType.Servo]: this.servoBindingTaskRunnerService,
[ControlSchemeBindingType.SetAngle]: this.setAngleBindingTaskRunnerService,
[ControlSchemeBindingType.Speed]: this.speedBindingTaskRunnerService,
[ControlSchemeBindingType.Stepper]: this.stepperBindingTaskRunnerService,
[ControlSchemeBindingType.Train]: this.trainBindingTaskRunnerService,
[ControlSchemeBindingType.Gearbox]: this.gearboxBindingTaskRunnerService,
};

constructor(
private readonly servoTaskRunnerService: ServoTaskRunnerService,
private readonly setAngleTaskRunnerService: SetAngleTaskRunnerService,
private readonly speedTaskRunnerService: SpeedTaskRunnerService,
private readonly trainTaskRunnerService: TrainBindingTaskRunnerService,
private readonly stepperTaskRunnerService: StepperTaskRunnerService,
private readonly gearboxTaskRunnerService: GearboxBindingTaskRunnerService
private readonly servoBindingTaskRunnerService: ServoBindingTaskRunnerService,
private readonly setAngleBindingTaskRunnerService: SetAngleBindingTaskRunnerService,
private readonly speedBindingTaskRunnerService: SpeedBindingTaskRunnerService,
private readonly trainBindingTaskRunnerService: TrainBindingTaskRunnerService,
private readonly stepperBindingTaskRunnerService: StepperBindingTaskRunnerService,
private readonly gearboxBindingTaskRunnerService: GearboxBindingTaskRunnerService
) {
}

Expand Down
20 changes: 10 additions & 10 deletions modules/bindings/src/lib/gearbox/gearbox-binding-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ReactiveFormsModule } from '@angular/forms';
import { AsyncPipe } from '@angular/common';
import { ControlSchemeBindingType, ValidationMessagesDirective } from '@app/shared-misc';
import { HideOnSmallScreenDirective, ToggleControlComponent } from '@app/shared-ui';
import { GearboxInputAction, HubMotorPositionFacadeService } from '@app/store';
import { GearboxBindingInputAction, HubMotorPositionFacadeService } from '@app/store';
import { BindingControlSelectHubComponent, BindingControlSelectIoComponent, MotorPositionAdjustmentComponent } from '@app/shared-control-schemes';

import {
Expand Down Expand Up @@ -117,23 +117,23 @@ export class GearboxBindingEditComponent implements IBindingsDetailsEditComponen
this._form = form;
this._nextLevelControlBindingComponentData = {
bindingType: ControlSchemeBindingType.Gearbox,
inputFormGroup: form.controls.inputs.controls[GearboxInputAction.NextGear],
inputAction: GearboxInputAction.NextGear,
inputName$: this.l10nService.getBindingInputName(GearboxInputAction.NextGear)
inputFormGroup: form.controls.inputs.controls[GearboxBindingInputAction.NextGear],
inputAction: GearboxBindingInputAction.NextGear,
inputName$: this.l10nService.getBindingInputName(GearboxBindingInputAction.NextGear)
};

this._prevLevelControlBindingComponentData = {
bindingType: ControlSchemeBindingType.Gearbox,
inputFormGroup: form.controls.inputs.controls[GearboxInputAction.PrevGear],
inputAction: GearboxInputAction.PrevGear,
inputName$: this.l10nService.getBindingInputName(GearboxInputAction.PrevGear)
inputFormGroup: form.controls.inputs.controls[GearboxBindingInputAction.PrevGear],
inputAction: GearboxBindingInputAction.PrevGear,
inputName$: this.l10nService.getBindingInputName(GearboxBindingInputAction.PrevGear)
};

this._resetControlBindingComponentData = {
bindingType: ControlSchemeBindingType.Gearbox,
inputFormGroup: form.controls.inputs.controls[GearboxInputAction.Reset],
inputAction: GearboxInputAction.Reset,
inputName$: this.l10nService.getBindingInputName(GearboxInputAction.Reset)
inputFormGroup: form.controls.inputs.controls[GearboxBindingInputAction.Reset],
inputAction: GearboxBindingInputAction.Reset,
inputName$: this.l10nService.getBindingInputName(GearboxBindingInputAction.Reset)
};

this.portRequestSubscription?.unsubscribe();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { FormBuilder, FormControl, Validators } from '@angular/forms';
import { MotorServoEndState } from 'rxpoweredup';
import { DeepPartial } from '@app/shared-misc';
import { ControlSchemeGearboxBinding, GearboxInputAction } from '@app/store';
import { ControlSchemeGearboxBinding, GearboxBindingInputAction } from '@app/store';
import { ControlSchemeFormBuilderService } from '@app/shared-control-schemes';

import { CommonBindingsFormControlsBuilderService } from '../common';
Expand All @@ -21,9 +21,9 @@ export class GearboxBindingFormBuilderService implements IBindingFormBuilder<Gea
public build(): GearboxBindingForm {
return this.formBuilder.group({
inputs: this.formBuilder.group({
[GearboxInputAction.NextGear]: this.commonFormControlsBuilder.inputFormGroup(),
[GearboxInputAction.PrevGear]: this.commonFormControlsBuilder.optionalInputFormGroup(),
[GearboxInputAction.Reset]: this.commonFormControlsBuilder.optionalInputFormGroup()
[GearboxBindingInputAction.NextGear]: this.commonFormControlsBuilder.inputFormGroup(),
[GearboxBindingInputAction.PrevGear]: this.commonFormControlsBuilder.optionalInputFormGroup(),
[GearboxBindingInputAction.Reset]: this.commonFormControlsBuilder.optionalInputFormGroup()
}),
hubId: this.controlSchemeFormBuilder.hubIdControl(),
portId: this.controlSchemeFormBuilder.portIdControl(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { ControlSchemeBindingType } from '@app/shared-misc';
import { ControlSchemeBinding, ControlSchemeGearboxBinding, GearboxInputAction } from '@app/store';
import { ControlSchemeBinding, ControlSchemeGearboxBinding, GearboxBindingInputAction } from '@app/store';

import { CommonFormMapperService, InputFormGroup } from '../common';
import { GearboxBindingForm } from './gearbox-binding-form';
Expand All @@ -25,8 +25,8 @@ export class GearboxBindingFormMapperService {
id,
bindingType: ControlSchemeBindingType.Gearbox,
inputs: {
[GearboxInputAction.NextGear]: this.commonFormMapperService.mapInputFormToSchemeInput(
form.controls.inputs.controls[GearboxInputAction.NextGear]
[GearboxBindingInputAction.NextGear]: this.commonFormMapperService.mapInputFormToSchemeInput(
form.controls.inputs.controls[GearboxBindingInputAction.NextGear]
)
},
hubId,
Expand All @@ -40,13 +40,13 @@ export class GearboxBindingFormMapperService {
useDecelerationProfile: form.controls.useDecelerationProfile.getRawValue(),
initialLevelIndex: form.controls.initialLevelIndex.getRawValue()
};
if (form.controls.inputs.controls[GearboxInputAction.PrevGear].controls.controllerId.value !== null) {
result.inputs[GearboxInputAction.PrevGear] =
this.commonFormMapperService.mapInputFormToSchemeInput(form.controls.inputs.controls[GearboxInputAction.PrevGear] as InputFormGroup);
if (form.controls.inputs.controls[GearboxBindingInputAction.PrevGear].controls.controllerId.value !== null) {
result.inputs[GearboxBindingInputAction.PrevGear] =
this.commonFormMapperService.mapInputFormToSchemeInput(form.controls.inputs.controls[GearboxBindingInputAction.PrevGear] as InputFormGroup);
}
if (form.controls.inputs.controls[GearboxInputAction.Reset].controls.controllerId.value !== null) {
result.inputs[GearboxInputAction.Reset] =
this.commonFormMapperService.mapInputFormToSchemeInput(form.controls.inputs.controls[GearboxInputAction.Reset] as InputFormGroup);
if (form.controls.inputs.controls[GearboxBindingInputAction.Reset].controls.controllerId.value !== null) {
result.inputs[GearboxBindingInputAction.Reset] =
this.commonFormMapperService.mapInputFormToSchemeInput(form.controls.inputs.controls[GearboxBindingInputAction.Reset] as InputFormGroup);
}
return result;
}
Expand Down
Loading

0 comments on commit 2260b1b

Please sign in to comment.