From 3ee88b0ac78caf542e5488c18a496d3687aab6c2 Mon Sep 17 00:00:00 2001
From: "francois.grand" <francois.grand@irstea.fr>
Date: Thu, 28 Jun 2018 15:22:48 +0200
Subject: [PATCH] =?UTF-8?q?=20#45=20ParallelStructure=20:=20impl=C3=A9ment?=
 =?UTF-8?q?ation=20sp=C3=A9cifique=20de=20getReferencedObject()=20et=20uti?=
 =?UTF-8?q?lisation=20dans=20getReferencedParamValues()?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/structure/parallel_structure.ts | 30 +++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/src/structure/parallel_structure.ts b/src/structure/parallel_structure.ts
index 77c57101..f65c03b5 100644
--- a/src/structure/parallel_structure.ts
+++ b/src/structure/parallel_structure.ts
@@ -6,6 +6,8 @@ import { ParallelStructureParams } from "./parallel_structure_params";
 import { Structure } from "./structure";
 import { IParamDefinitionIterator, ParamsEquation, ParamsEquationArrayIterator } from "../param/params-equation";
 import { ParamValues } from "../param/param-values";
+import { NamedIterableValues } from "../param/param-value-iterator";
+import { BaseParam } from "../param/param-base";
 
 /**
  * Interface pour mémoriser le n° d'ouvrage et le paramètre à calculer
@@ -275,14 +277,34 @@ export class ParallelStructure extends Nub {
 
     // interface IReferencedNub
 
+    public getReferencedObject(desc: string): NamedIterableValues {
+        try {
+            // analyse n.X
+            const i: IStructureVarCalc = this.getStructureVarCalc(desc);
+            return this.structures[i.index].getParameter(i.prm);
+        }
+        catch (e) {
+            try {
+                // analyse ouvrage[n].X
+                const i: IStructureVarCalc = this.getStructureVarCalc2(desc);
+                return this.structures[i.index].result.getExtraResult(i.prm);
+            }
+            catch (e) {
+            }
+        }
+        // pas de la forme n.X ou ouvrage[n].X ou erreur sur n ou X
+        return super.getReferencedObject(desc);
+    }
+
     public getReferencedParamValues(desc: string): ParamValues {
         try {
-            // analyse ouvrage[n].X
-            const i: IStructureVarCalc = this.getStructureVarCalc2(desc);
-            return this.structures[i.index].getParameter(i.prm).paramValues;
+            const ro = this.getReferencedObject(desc);
+            if (ro instanceof BaseParam)
+                return ro.paramValues;
+            return undefined;
         }
         catch (e) {
-            // pas de la forme ouvrage[n].X ou erreur sur n ou X
+            // pas de la forme n.X ou ouvrage[n].X ou erreur sur n ou X
             const param = this.getParameter(desc);
             if (param === undefined)
                 return undefined;
-- 
GitLab