Ejemplo n.º 1
0
        protected void ReCreateStateVariables(ModelOutput mf)
        {
            mf._stateinterfaceOjbect.Clear();

            foreach (var c in Components)
            {
                Esmf.ComponentStructure.StateStructure s = Esmf.ComponentStructure.StateStructure.LoadFromInterface(c.StateInterfaceType);
                MethodInfo mi  = s.GetType().GetMethod("ConnectToState");
                MethodInfo mi2 = mi.MakeGenericMethod(new Type[] { c.StateInterfaceType });
                object     o   = mi2.Invoke(s, new object[] { mf, c.Name });
                mf._stateinterfaceOjbect.Add(c.Name, o);
            }
        }
Ejemplo n.º 2
0
        protected void RunComponents(ModelOutput mf)
        {
            var stateInterfaces = new Dictionary <string, object>(_components.Count);

            foreach (var c in Components)
            {
                Esmf.ComponentStructure.StateStructure s = Esmf.ComponentStructure.StateStructure.LoadFromInterface(c.StateInterfaceType);
                var o = s.ConnectToState(mf, c.Name);
                stateInterfaces.Add(c.Name, o);
            }

            mf.Clock.Reset();

            var clock = mf.Clock;

            while (!clock.IsDone)
            {
                for (int i = 0; i < _componentsOrder.Count; i++)
                {
                    var c = _components[_componentsOrder[i]];
                    //Console.WriteLine(c.Name);
                    var state = stateInterfaces[c.Name];
                    c.RunComponent(clock, state, mf);
                }

                if (!clock.IsLastTimestep)
                {
                    for (int i = 0; i < _componentsOrder.Count; i++)
                    {
                        var c     = _components[_componentsOrder[i]];
                        var state = stateInterfaces[c.Name];
                        c.RunTransitionFunction(clock, state, mf);
                    }
                }

                clock.Advance();
            }
        }