Skip to content

Commit

Permalink
feat: variable mapping with fix value (placeholders) WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
unocelli committed May 5, 2024
1 parent 651749b commit 3328d2c
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 62 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, EventEmitter, OnInit, Inject, Output, OnDestroy } from '@angular/core';
import { Device, ModbusTagType, Tag, TagType } from '../../../_models/device';
import { Device, ModbusTagType, Tag } from '../../../_models/device';
import { AbstractControl, UntypedFormBuilder, UntypedFormGroup, ValidationErrors, ValidatorFn, Validators } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { TranslateService } from '@ngx-translate/core';
Expand All @@ -13,7 +13,7 @@ import { Subject, takeUntil } from 'rxjs';
export class TagPropertyEditModbusComponent implements OnInit, OnDestroy {
@Output() result = new EventEmitter<any>();
formGroup: UntypedFormGroup;
tagType = TagType;
tagType = ModbusTagType;
memAddress = {
'Coil Status (Read/Write 000001-065536)': '000000',
'Digital Inputs (Read 100001-165536)': '100000',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class FlexEventComponent implements OnInit {
@Input() data: any;
@Input() scripts: Script[];

variablesMapping = 'variablesMapping';
eventRunScript = Utils.getEnumKey(GaugeEventActionType, GaugeEventActionType.onRunScript);

events: GaugeEvent[];
Expand Down Expand Up @@ -74,7 +73,9 @@ export class FlexEventComponent implements OnInit {
// compatibility with <= 1.0.4
this.events.forEach(element => {
if (!element.actoptions || Object.keys(element.actoptions).length == 0) {
element.actoptions = {variablesMapping: []};
element.actoptions = {
variablesMapping: []
};
}
});
}
Expand All @@ -90,7 +91,7 @@ export class FlexEventComponent implements OnInit {
if (element.type) {
// clean unconfig
if (element.action === this.eventRunScript) {
delete element.actoptions[this.variablesMapping];
delete element.actoptions['variablesMapping'];
} else {
delete element.actoptions[SCRIPT_PARAMS_MAP];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[data]="data"
(valueChange)="onValueChange()"
[allowManualEdit]="false"
[withStaticValue]="false"
[withStaticValue]="true"
[devicesOnly]="true">
</flex-variable>
</div>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { View } from '../../../_models/hmi';
import { IPropertyVariable, View } from '../../../_models/hmi';

@Component({
selector: 'flex-variable-map',
Expand Down Expand Up @@ -32,3 +32,8 @@ export class FlexVariableMapComponent implements OnInit {
return v1 && v2 && v1.variableId == v2.variableId;
}
}

export interface VariableMapItemType {
from: IPropertyVariable;
to: IPropertyVariable;
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ export class FlexVariableComponent implements OnInit {
this.value = {
variableId: this.variableId
};
} else if (this.value.variableId) {
} else {
this.variableId = this.value.variableId;
this.variableValue = this.value.variableValue;
}

if (!this.devicesOnly) {
let devPlaceholders = Utils.clone(PlaceholderDevice);
this.placeholders?.forEach(placeholder => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{'gauges.property-map-variable' | translate}}
</button>

<div *ngFor="let variableMap of this.mapping;index as i">
<div *ngFor="let variableMap of mapping;index as i">
<flex-variable-map [data]="data" [view]="view" [value]="mapping[i]" [placeholders]="viewPlaceholders" (valueChange)="onChange()">
<button style="float: right; margin-top: 7px;" mat-icon-button (click)="removeVariableMapping($event, i)" matTooltip="{{'gauges.property-head-remove-mapvariable' | translate}}">
<mat-icon>clear</mat-icon>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';

import { View } from '../../../_models/hmi';
import { VariableMapItemType } from '../flex-variable-map/flex-variable-map.component';

@Component({
selector: 'flex-variables-mapping',
Expand Down Expand Up @@ -71,7 +72,10 @@ export class FlexVariablesMappingComponent implements OnInit, OnChanges {

addVariableMapping($event) {
$event.preventDefault();
this.mapping.push({ from: {}, to: {} });
this.mapping.push(<VariableMapItemType>{
from: {},
to: {},
});
}

removeVariableMapping($event, i) {
Expand Down

0 comments on commit 3328d2c

Please sign in to comment.