Beispiel #1
0
 public Vessel(IModel model, string name, string description, Guid guid, double capacity, double pressure, bool autoReset)
 {
     InitializeIdentity(model, name, description, guid);
     m_mixture                  = new Mixture(model, name + ".Mixture", GuidOps.XOR(guid, s_mixture_Guidmask));
     m_mixtureMass              = new DoubleTracker();
     m_mixtureVolume            = new DoubleTracker();
     m_mixture.MaterialChanged += new MaterialChangeListener(m_mixture_MaterialChanged);
     m_pressure                 = m_initialPressure = pressure;
     m_capacity                 = capacity;
     m_autoReset                = autoReset;
     m_model.Starting          += new ModelEvent(m_model_Starting);
 }
Beispiel #2
0
        /// <summary>
        /// Creates a new instance of the <see cref="T:Reaction"/> class.
        /// </summary>
        /// <param name="model">The model in which this object runs.</param>
        /// <param name="name">The user-friendly name of this object. Typically not required to be unique in a pan-model context.</param>
        /// <param name="guid">The GUID of this object. Typically registered as this object's ModelObject key, and thus, required to be unique in a pan-model context.</param>
        public Reaction(IModel model, string name, Guid guid)
        {
            InitializeIdentity(model, name, null, guid);

            if (model != null)
            {
                model.Starting += model_Starting;
            }
            m_model      = model;
            m_nextRiGuid = GuidOps.XOR(m_guid, DEFAULT_RI_GUIDMASK);

            IMOHelper.RegisterWithModel(this);
        }
Beispiel #3
0
        public PfcExecutionContext(IProcedureFunctionChart pfc, string name, string description, Guid guid, PfcExecutionContext parent)
            : base(pfc.Model, name, description, guid, parent)
        {
            if (s_diagnostics)
            {
                string parentName = (parent == null ? "<null>" : parent.Name);
                Console.WriteLine("Creating PFCEC \"" + name + "\" under PFCEC \"" + parentName + "\" For parent " + pfc.Name + " and numbered " + guid);
            }

            m_pfc                = pfc;
            m_step               = null;
            m_timePeriod         = new TimePeriodEnvelope(name, GuidOps.XOR(guid, s_time_Period_Mask));
            m_timePeriod.Subject = this;
            if (parent != null)
            {
                ((TimePeriodEnvelope)parent.TimePeriod).AddTimePeriod(m_timePeriod);
            }
            m_timePeriod.ChangeEvent += new ObservableChangeHandler(m_timePeriod_ChangeEvent);
        }
Beispiel #4
0
        /// <summary>
        /// Creates pfc execution contexts, one per action under the step that is currently running. Each
        /// is given an instance count of zero, as a step can run its action only once, currently.
        /// </summary>
        /// <param name="parentContext">The parent context, that of the step that is currently running.</param>
        /// <param name="kids">The procedure function charts that live in the actions under the step that is currently running.</param>
        /// <param name="kidContexts">The pfc execution contexts that will correspond to the running of each of the child PFCs.</param>
        protected virtual void CreateChildContexts(PfcExecutionContext parentContext, out IProcedureFunctionChart[] kids, out PfcExecutionContext[] kidContexts)
        {
            int kidCount = MyStep.Actions.Count;

            kids        = new ProcedureFunctionChart[kidCount];
            kidContexts = new PfcExecutionContext[kidCount];
            int i = 0;

            foreach (KeyValuePair <string, IProcedureFunctionChart> kvp in MyStep.Actions)
            {
                IProcedureFunctionChart kid = kvp.Value;
                kids[i] = kid;
                Guid kidGuid = GuidOps.XOR(parentContext.Guid, kid.Guid);
                while (parentContext.Contains(kidGuid))
                {
                    kidGuid = GuidOps.Increment(kidGuid);
                }
                kidContexts[i] = new PfcExecutionContext(kid, kvp.Key, null, kidGuid, parentContext);
                kidContexts[i].InstanceCount = 0;
                i++;
            }
        }
Beispiel #5
0
        public PfcExecutionContext(IPfcStepNode stepNode, string name, string description, Guid guid, PfcExecutionContext parent)
            : base(stepNode.Parent.Model, name, description, guid, parent)
        {
            if (s_diagnostics)
            {
                Console.WriteLine("Creating PfcEC \"" + name + "\" under PfcEC \"" + parent.Name + "\" For parent " + stepNode.Name + " and numbered " + guid);
            }

            m_pfc  = stepNode.Parent;
            m_step = stepNode;
            if (stepNode.Actions.Count == 0)
            {
                m_timePeriod         = new TimePeriod(name, GuidOps.XOR(guid, s_time_Period_Mask), TimeAdjustmentMode.InferDuration);
                m_timePeriod.Subject = this;
                ((TimePeriodEnvelope)parent.TimePeriod).AddTimePeriod(m_timePeriod);
            }
            else
            {
                m_timePeriod         = new TimePeriodEnvelope(name, GuidOps.XOR(guid, s_time_Period_Mask));
                m_timePeriod.Subject = this;
                ((TimePeriodEnvelope)parent.TimePeriod).AddTimePeriod(m_timePeriod);
            }
            m_timePeriod.ChangeEvent += new ObservableChangeHandler(m_timePeriod_ChangeEvent);
        }
Beispiel #6
0
 internal void InitializeExecutionInstanceUid(Guid parentExecutionContextUid, Guid myStepUid)
 {
     Debug.Assert(m_nextExecutionInstanceUid.Equals(Guid.Empty));
     m_nextExecutionInstanceUid = GuidOps.XOR(parentExecutionContextUid, myStepUid);
 }
Beispiel #7
0
 private void model_Starting(IModel theModel)
 {
     m_nextRiGuid = GuidOps.XOR(m_guid, DEFAULT_RI_GUIDMASK);
 }