UNPKG

jalhyd

Version:

JaLHyd, a Javascript Library for Hydraulics

170 lines 6.85 kB
import { IProperties, SectionType } from "./internal_modules"; import { LinkedValue } from "./internal_modules"; import { Nub } from "./internal_modules"; import { ParamDefinition } from "./internal_modules"; import { Props } from "./internal_modules"; import { acSection } from "./internal_modules"; import { PressureLossLaw, PressureLossType } from "./internal_modules"; export declare class Session { static getInstance(): Session; /** instance pour le pattern singleton */ private static _instance; /** free documentation text, in Markdown format, to save into session file (optional) */ documentation: string; /** Nubs de la session */ private _nubs; /** * crée un Nub et l'ajoute à la session * @param props propriétés du Nub (computeType, nodeType...) */ createSessionNub(p: Props, dbg?: boolean): Nub; /** * Adds an existing Nub to the session */ registerNub(n: Nub): void; /** * Adds many existing Nubs to the session */ registerNubs(nubs: Nub[]): void; /** * Removes all Nubs from the Session */ clear(): void; /** * Returns number of Nubs in the session */ getNumberOfNubs(): number; /** Accessor for Nubs list */ getAllNubs(): Nub[]; /** * Removes a Nub from the session; does not consider Structure nubs inside Calculator nubs * @param sn the Nub to remove from the session */ deleteNub(sn: Nub): void; /** * set parameters linked to non exsting modules to fixed mode */ private fixDanglingLinks; /** * Returns a JSON representation of (a part of) the current session * @param options an object having Nub uids as keys, with extra data object as values; * if empty or undefined, all Nubs are serialised * @param settings app preferences to store in the session file (decimals, precision…) */ serialise(options?: { [key: string]: {}; }, settings?: { [key: string]: {}; }): string; /** * Loads (a part of) a session from a JSON representation * @param serialised JSON data * @param uids unserialise only the Nubs havin the given UIDs */ unserialise(serialised: string, uids?: string[]): { nubs: any[]; hasErrors: boolean; settings: any; }; /** * Creates a Nub from a JSON representation and adds it to the current session; returns * a pointer to the Nub and its JSON metadata * @param serialised JSON representation of a single Nub * @param register if false, new Nub will just be returned and won't be registered into the session */ unserialiseSingleNub(serialised: string, register?: boolean): { nub: Nub; meta: any; }; /** * Returns the Nub identified by uid if any */ findNubByUid(uid: string): Nub; private static parameterIndex; /** * Calcule le type de calculette compatible et modifie les propriétés en conséquence. * Permet de charger des fichiers session avec une version antérieure. * Par ex : Lechapt-Calmon -> PressureLoss */ private compatibleCalculator; /** * Crée un Nub à partir d'une description (Props) * @param params propriétés à partir desquelles on détermine la classe du Nub à créer * - calcType: type de Nub * - nodeType: pour un Nub contenant une section * - loiDebit: pour un Nub de type Structure (calcType doit être CalculatorType.Structure) * Si d'autres propriétés sont fournies, elle écraseront les éventuelles propriétés par défaut * définies dans le constructeur du Nub créé * @param dbg activer débogage */ createNub(params: IProperties, parentNub?: Nub, dbg?: boolean): Nub; /** * Returns true if given uid is already used by a Nub in this session, * or a Structure nub inside one of them */ uidAlreadyUsed(uid: string, nubs?: Nub[]): boolean; /** * Returns all Nubs depending on the given one (parameter or result), * without following links (1st level only) * @param uid UID of the Nub that underwent a change * @param symbol symbol of the parameter whose value change triggered this method; if specified, * Nubs targetting this symbol will be considered dependent * @param includeValuesLinks if true, even Nubs targetting non-calculated non-modified parameters * will be considered dependent @see jalhyd#98 * @param includeOtherDependencies if true, will be considered dependent * - Solveur Nubs having given Nub either as X or as Ytarget's parent Nub * - Verificateur Nubs having given Nub either as selected Custom Species or Pass to check */ getDependingNubs(uid: string, symbol?: string, includeValuesLinks?: boolean, includeOtherDependencies?: boolean): Nub[]; /** * Returns all Nubs depending on the result of at least one other Nub. * Used by Solveur to find available "target" nubs to calculate. */ getDownstreamNubs(): Nub[]; /** * Returns all Nubs that do not depend on the result of any other Nub * (includes single Nubs). */ getUpstreamNubs(): Nub[]; /** * Returns all upstream Nubs that have at least one declared extra result. * Used by Solveur to find available "target" nubs to calculate. */ getUpstreamNubsHavingExtraResults(): Nub[]; /** * Returns a list of nub/symbol couples, that can be linked to the given * parameter, among all current nubs * @param p */ getLinkableValues(p: ParamDefinition): LinkedValue[]; /** * @returns true if parameter is a link target in any session nub */ isParameterLinkTarget(p: ParamDefinition): boolean; /** * Crée un Nub de type Section * @param nt SectionType * @param dbg activer débogage */ createSection(nt: SectionType, dbg?: boolean, nullParams?: boolean): acSection; /** * Crée un Nub de type loi de perte de charge */ createPressureLossLaw(plt: PressureLossType, dbg?: boolean, nullParams?: boolean): PressureLossLaw; /** * Creates a Nub from an object representation and adds it to the current session; returns * a pointer to the Nub and its JSON metadata * @param obj object representation of a single Nub * @param register if false, new Nub will just be returned and won't be registered into the session */ private createNubFromObjectRepresentation; /** * Asks all loaded Nubs to relink any parameter that has a wrong target */ private fixLinks; /** * Asks every loaded Solveur to reconnect to its nubToCalculate / searchedParameter */ private fixSolveurs; } //# sourceMappingURL=session.d.ts.map