An error occurred while loading the file. Please try again.
-
Grand Francois authoredd0d3582d
import { ComputeNodeType, ParamDefinition, ParamDomainValue } from 'jalhyd';
import { InputField, Dependency, DependencyConditionType, ValueDependencyCondition } from './formulaire';
import { StringMap } from '../../stringmap';
export enum ParamRadioConfig {
/**
* pas de radio, paramètre modifiable à la main uniquement
*/
FIX,
/**
* boutons radio "paramètre fixé" et "paramètre à varier"
*/
VAR,
/**
* boutons radio "paramètre fixé", "paramètre à varier" et "paramètre à calculer"
*/
CAL
};
/**
* class englobante de ParamDefinition (champs supplémentaires pour l'affichage, radio boutons, ...)
*/
export class NgParameter extends InputField {
public unit: string;
public radioConfig: ParamRadioConfig;
public radioState: ParamRadioConfig;
public isDefault: boolean = false; // archi bug du langage ! si on relit cette propriété sans l'avoir modifiée entre-temps, elle vaut undefined !
public minValue: number; // valeur min dans le cas ParamRadioConfig.VAR
public maxValue: number; // valeur max dans le cas ParamRadioConfig.VAR
public stepValue: number; // pas de progression dans le cas ParamRadioConfig.VAR
constructor(private _paramDef: ParamDefinition) {
super(_paramDef.computeNodeType, _paramDef.symbol);
switch (this._paramDef.getDomain().domain) {
case ParamDomainValue.ANY:
this.minValue = -10;
this.maxValue = 10;
this.stepValue = 0.5;
break;
case ParamDomainValue.POS:
case ParamDomainValue.NOT_NULL:
case ParamDomainValue.INTERVAL:
this.minValue = 0.01;
this.maxValue = 10;
this.stepValue = 0.5;
break;
case ParamDomainValue.POS_NULL:
this.minValue = 0;
this.maxValue = 10;
this.stepValue = 0.5;
break;
}
}
get symbol(): string {
return this._paramDef.symbol;
}
// get alias(): string {
// return this._paramDef.symbolAlias;
// }
public getValue() {
return this._paramDef.v;
}
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
public setValue(val: number) {
this._paramDef.v = val;
}
get isDefined(): boolean {
return this._paramDef.isDefined;
}
public checkValue(val: number) {
this._paramDef.checkValue(val);
}
public static getRadioConfig(s: string) {
if (s == "fix")
return ParamRadioConfig.FIX;
if (s == "var")
return ParamRadioConfig.VAR;
if (s == "cal")
return ParamRadioConfig.CAL;
throw "invalid parameter radio configuration " + s;
}
protected verifyDependency(d: Dependency): boolean {
switch (d.masterCondition.type) {
case DependencyConditionType.HasValue:
{
let mc: ValueDependencyCondition = <ValueDependencyCondition>d.masterCondition;
return this.getValue() === mc.value;
}
case DependencyConditionType.IsVariable:
return this.radioState == ParamRadioConfig.VAR;
default:
throw "NgParameter.verifyDependency() : type de condition '" + DependencyConditionType[d.masterCondition.type] + "' non pris en charge";
}
}
public updateLocalisation(loc: StringMap) {
this.label = loc[this.id];
}
}