Example #1
0
        /// <summary>
        /// Prior to this call, you must have created the connector using the
        /// </summary>
        /// <param name="self"></param>
        /// <param name="deserializationContext"></param>
        public void LoadFromXElement(XElement self, DeserializationContext deserializationContext)
        {
            IModel model            = null;
            string connectorName    = self.Attribute("connectorName").Value;
            string connectorDesc    = self.Attribute("connectorDesc").Value;
            Guid   connectorGuidWas = XmlConvert.ToGuid(self.Attribute("connectorGuid").Value);
            Guid   connectorGuidIs  = Guid.NewGuid();

            deserializationContext.SetNewGuidForOldGuid(connectorGuidWas, connectorGuidIs);
            IMOHelper.Initialize(ref m_model, model, ref m_name, connectorName, ref m_description, connectorDesc, ref m_guid, connectorGuidIs);
            IMOHelper.RegisterWithModel(this);

            XElement    source = self.Element("Source");
            Guid        upstreamOwnerGuidWas = XmlConvert.ToGuid(source.Attribute("guid").Value);
            Guid        upstreamOwnerGuidIs  = Guid.NewGuid();
            string      upstreamPortName     = source.Attribute("name").Value;
            IPortOwner  usmb         = (IPortOwner)deserializationContext.GetModelObjectThatHad(upstreamOwnerGuidWas);
            IOutputPort upstreamPort = (IOutputPort)usmb.Ports[upstreamPortName];

            XElement   destination            = self.Element("Destination");
            Guid       downstreamOwnerGuidWas = XmlConvert.ToGuid(destination.Attribute("guid").Value);
            Guid       downstreamOwnerGuidIs  = Guid.NewGuid();
            string     downstreamPortName     = destination.Attribute("name").Value;
            IPortOwner dsmb           = (IPortOwner)deserializationContext.GetModelObjectThatHad(downstreamOwnerGuidWas);
            IInputPort downstreamPort = (IInputPort)dsmb.Ports[downstreamPortName];

            Connect(upstreamPort, downstreamPort);
        }
Example #2
0
 /// <summary>
 /// Creates a new instance of the <see cref="T:PfcElement"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="name">The name of this node.</param>
 /// <param name="description">The description for this node.</param>
 /// <param name="guid">The GUID of this node.</param>
 public PfcElement(IProcedureFunctionChart parent, string name, string description, Guid guid)
 {
     m_parent = parent;
     InitializeIdentity(parent.Model, name, description, guid);
     m_userData = null;
     IMOHelper.RegisterWithModel(this);
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BasicNonBufferedConnector"/> class.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="name">The name.</param>
 /// <param name="description">The description.</param>
 /// <param name="guid">The GUID.</param>
 /// <param name="input">The input.</param>
 /// <param name="output">The output.</param>
 public BasicNonBufferedConnector(IModel model, string name, string description, Guid guid, IPort input, IPort output)
 {
     IMOHelper.Initialize(ref m_model, model, ref m_name, name, ref m_description, description, ref m_guid, guid);
     Connect(input, output);
     IMOHelper.RegisterWithModel(this);
     m_inUse = false;
 }
Example #4
0
        /// <summary>
        /// Initializes the fields that feed the properties of this IModelObject identity.
        /// </summary>
        /// <param name="model">The IModelObject's new model value.</param>
        /// <param name="name">The IModelObject's new name value.</param>
        /// <param name="description">The IModelObject's new description value.</param>
        /// <param name="guid"></param>
        public void InitializeIdentity(IModel model, string name, string description, Guid guid)
        {
            Debug.Assert(model == this);
            IModel m_model = null; // To fake out the call below, since Model doesn't have this member field.

            IMOHelper.Initialize(ref m_model, model, ref m_name, name, ref m_description, description, ref m_guid, guid);
        }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SimpleBranchBlock"/> 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 SimpleBranchBlock(IModel model, string name, Guid guid)
 {
     InitializeIdentity(model, name, null, guid);
     m_portSet = new PortSet();
     SetUpInputPort();
     SetUpOutputPorts();
     IMOHelper.RegisterWithModel(this);
 }
Example #6
0
            public ResourceUser(IModel model, string name, Guid guid, SelfManagingResource smr)
            {
                InitializeIdentity(model, name, null, guid);

                m_irr             = new SimpleResourceRequest(1.0, smr);
                m_model.Starting += new ModelEvent(ScheduleMyResourceAction);

                IMOHelper.RegisterWithModel(this);
            }
Example #7
0
        public void Initialize(IModel model, string name, string description, Guid guid,
                               [InitializerArg(0, "max", RefType.Owned, typeof(int), "The largest number of objects the queue can hold.")]
                               int max)
        {
            InitializeIdentity(model, name, description, guid);

            IMOHelper.RegisterWithModel(this);
            model.GetService <InitializationManager>().AddInitializationTask(_Initialize, max);
        }
Example #8
0
        public ItemSink(IModel model, string name, Guid guid)
        {
            InitializeIdentity(model, name, null, guid);

            m_input = new SimpleInputPort(model, "Input", Guid.NewGuid(), this, new DataArrivalHandler(CanAcceptPushedData));
            m_ports.AddPort(m_input);
            Input = m_input;
            m_input.PortDataAccepted += new PortDataEvent(m_input_PortDataAccepted);

            IMOHelper.RegisterWithModel(this);
        }
Example #9
0
        /// <summary>
        /// Creates a new resource manager.
        /// </summary>
        /// <param name="model">The model to which this resource manager belongs. It can be null.</param>
        /// <param name="name">The name of this resource manager.</param>
        /// <param name="guid">The guid by which this resource manager will be known.</param>
        /// <param name="priorityEnabled">If true, this resource manager will handle prioritized resource requests.</param>
        public ResourceManager(IModel model, string name, Guid guid, bool priorityEnabled = false)
        {
            InitializeIdentity(model, name, null, guid);

            SupportsPrioritizedRequests = priorityEnabled;
            m_onResourceRequestAborting = OnResourceRequestAborting;
            m_waiters   = new RscWaiterList(SupportsPrioritizedRequests);
            m_resources = new ArrayList();

            IMOHelper.RegisterWithModel(this);
        }
Example #10
0
        public TaskList(IModel model, string name, Guid guid, Task task)
        {
            Debug.Assert(model.Equals(task.Model), "TaskList being created for a model, but with a root task that is assigned to a different model.");
            InitializeIdentity(model, name, null, guid);

            m_masterTask = task;
            m_list       = new ArrayList();
            m_hashtable  = new Hashtable();

            IMOHelper.RegisterWithModel(this);
        }
Example #11
0
        public Nexus(IModel model, string name, Guid guid, IPortSelector portSelector)
        {
            InitializeIdentity(model, name, null, guid);

            m_ports                   = new PortSet();
            m_portSelector            = portSelector;
            m_cantTakeOrPeekFromNexus = new DataProvisionHandler(CantTakeOrPeekFromNexus);
            m_canAlwaysAcceptData     = new DataArrivalHandler(OnDataArrived);

            IMOHelper.RegisterWithModel(this);
        }
Example #12
0
        public TaskProcessor(IModel model, string name, Guid guid, Task task)
        {
            InitializeIdentity(model, name, null, guid);

            m_masterTask = task;
            m_priority   = 0.0;
            m_when       = DateTime.MinValue;
            m_eet        = ExecEventType.Synchronous;
            Model.GetService <ITaskManagementService>().AddTaskProcessor(this);

            IMOHelper.RegisterWithModel(this);
        }
Example #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WaitingTime"/> 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>
        /// <param name="hostQueue">The host queue.</param>
        /// <param name="nBins">The number of bins into which to divide the waiting time.</param>
        public WaitingTime(IModel model, string name, Guid guid, IQueue hostQueue, int nBins)
        {
            InitializeIdentity(model, name, null, guid);

            m_nBins     = nBins;
            m_hostQueue = hostQueue;
            m_hostQueue.ObjectEnqueued += new QueueOccupancyEvent(m_hostQueue_ObjectEnqueued);
            m_hostQueue.ObjectDequeued += new QueueOccupancyEvent(m_hostQueue_ObjectDequeued);
            m_data      = new ArrayList();
            m_occupants = new Hashtable();

            IMOHelper.RegisterWithModel(this);
        }
Example #14
0
            public void Initialize(IModel model, string name, string description, Guid guid,
                                   [InitializerArg(0, "Random Seed", RefType.Owned, typeof(ulong), "The random seed to be used by this model.")]
                                   ulong randomSeed,
                                   [InitializerArg(1, "Other Model Objects", RefType.Owned, typeof(IModelObject), "We'll get more specific...")]
                                   Guid[] otherModelObjects
                                   )
            {
                InitializeIdentity(model, name, description, guid);

                IMOHelper.RegisterWithModel(this);

                model.GetService <InitializationManager>().AddInitializationTask(new Initializer(_Initialize), randomSeed, otherModelObjects);
            }
Example #15
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);
        }
Example #16
0
        /// <summary>
        /// Creates a new Resource, wrapped by an implementer of IResource. This constructor is used if the
        /// resource being created is serving as a delegated-to token which represents some other resource.
        /// A resource is created with a capacity, and is granted in portions of that capacity, or if atomic,
        /// all-or-nothing. The IResourceRequest will specify a desired amount. If the IResourceRequest
        /// specifies a desired quantity less than the resource's capacity, and the resource is atomic, the
        /// IResourceRequest will be granted the full capacity of the resource. A self-managing resource
        /// is a resource that is responsible for granting access to itself.
        /// </summary>
        /// <param name="model">The model to which the Resource will belong.</param>
        /// <param name="name">The name of the Resource.</param>
        /// <param name="guid">The guid of the Resource.</param>
        /// <param name="capacity">The capacity of the Resource. How much there is to be granted.</param>
        /// <param name="availability">The initial available quantity of the resource.</param>
        /// <param name="isAtomic">True if the Resource is atomic. Atomicity infers that the resource is granted all-or-nothing.</param>
        /// <param name="isDiscrete">True if the Resource is discrete. Discreteness infers that the resource is granted in unitary amounts.</param>
        /// <param name="isPersistent">True if the Resource is persistent. Persistence infers that the resource, once granted, must be returned to the pool.</param>
        /// <param name="wrappedByWhom">A reference to the outer object which this instance exists to represent.</param>
        public Resource(IModel model, string name, Guid guid, double capacity, double availability, bool isAtomic, bool isDiscrete, bool isPersistent, IResource wrappedByWhom)
        {
            InitializeIdentity(model, name, null, guid);

            InitialCapacity  = capacity;
            Capacity         = capacity;
            InitialAvailable = availability;
            Available        = availability;
            IsAtomic         = isAtomic;
            IsDiscrete       = isDiscrete;
            IsPersistent     = isPersistent;
            m_wrappedByWhom  = wrappedByWhom;

            IMOHelper.RegisterWithModel(this);
        }
Example #17
0
        public SimpleServer(IModel model, string name, Guid guid, IPeriodicity periodicity)
        {
            InitializeIdentity(model, name, null, guid);

            m_input  = new SimpleInputPort(model, "Input", Guid.NewGuid(), this, new DataArrivalHandler(AcceptServiceObject));
            m_output = new SimpleOutputPort(model, "Output", Guid.NewGuid(), this, null, null);
            // AddPort(m_input); <-- Done in port's ctor.
            // AddPort(m_output); <-- Done in port's ctor.
            m_periodicity          = periodicity;
            m_input.DataAvailable += new PortEvent(OnServiceObjectAvailable);
            string sso = m_model.ModelConfig.GetSimpleParameter("SupportsServerObjects");

            m_supportsServerObjects = (sso == null)?false:bool.Parse(sso);

            IMOHelper.RegisterWithModel(this);
        }
Example #18
0
 public Splitter(IModel model, string name, Guid guid, int nOuts)
 {
     IMOHelper.Initialize(ref m_model, model, ref m_name, name, ref m_description, null, ref m_guid, guid);
     m_ports = new PortSet();
     m_input = new SimpleInputPort(model, "Input", Guid.NewGuid(), this, GetDataArrivalHandler());
     //AddPort(m_input); <-- Done in SIP's ctor.
     Input     = m_input;
     Outputs   = new IOutputPort[nOuts];
     m_outputs = new SimpleOutputPort[nOuts];
     for (int i = 0; i < nOuts; i++)
     {
         m_outputs[i] = new SimpleOutputPort(model, "Output" + i, Guid.NewGuid(), this, GetDataProvisionHandler(i), GetPeekHandler(i));
         Outputs[i]   = m_outputs[i];
         //AddPort(m_outputs[i]); <-- Done in SOP's ctor.
     }
     IMOHelper.RegisterWithModel(this);
 }
Example #19
0
        private MultiChannelDelayServer(IModel model, string name, Guid guid)
        {
            InitializeIdentity(model, name, null, guid);

            m_entryPort = new SimpleInputPort(model, "Input", Guid.NewGuid(), this, new DataArrivalHandler(OnDataArrived));
            m_exitPort  = new SimpleOutputPort(model, "Output", Guid.NewGuid(), this, null, null); // No take, no peek.

            // AddPort(m_entryPort); <-- Done in port's ctor.
            // AddPort(m_exitPort); <-- Done in port's ctor.

            m_releaseObject = new ExecEventReceiver(ReleaseObject);

            m_inService = new ArrayList();
            m_pending   = 0;

            IMOHelper.RegisterWithModel(this);
        }
Example #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Queue"/> class.
        /// </summary>
        /// <param name="model">The model in which this queue exists.</param>
        /// <param name="name">The name of this queue.</param>
        /// <param name="guid">The GUID of this queue.</param>
        /// <param name="max">The maximum number of items that can be held in this queue.</param>
        public Queue(IModel model, string name, Guid guid, int max)
        {
            InitializeIdentity(model, name, "", guid);
            m_max = max;

            m_queue = new System.Collections.Queue();

            Guid inGuid  = Utility.GuidOps.Increment(guid);
            Guid outGuid = Utility.GuidOps.Increment(inGuid);

            m_output = new SimpleOutputPort(model, "Output", outGuid, this, new DataProvisionHandler(ProvideData), new DataProvisionHandler(PeekData));
            m_output.PortDataAccepted += new PortDataEvent(OnOutputPortDataAccepted);
            m_input = new SimpleInputPort(model, "Input", inGuid, this, new DataArrivalHandler(OnDataArrived));

            LevelChangedEvent += new QueueLevelChangeEvent(OnQueueLevelChanged);

            IMOHelper.RegisterWithModel(this);
        }
Example #21
0
        public Joiner(IModel model, string name, Guid guid, int nIns)
        {
            InitializeIdentity(model, name, null, guid);

            m_ports = new PortSet();

            m_output = new SimpleOutputPort(model, "Output", Guid.NewGuid(), this, GetTakeHandler(), GetPeekHandler());
            // AddPort(m_output); <-- Done in SOP's ctor.

            m_inputs = new SimpleInputPort[nIns];
            for (int i = 0; i < nIns; i++)
            {
                m_inputs[i] = new SimpleInputPort(model, "Input" + i, Guid.NewGuid(), this, GetDataArrivalHandler(i));
                Inputs[i]   = m_inputs[i];
                // AddPort(m_inputs[i]); <-- Done in SOP's ctor.
            }

            IMOHelper.RegisterWithModel(this);
        }
Example #22
0
        public void Initialize(IModel model, string name, string description, Guid guid,
                               [InitializerArg(0, "inputPortOwner", RefType.Owned, typeof(IPortOwner), "The upstream port owner attached to this connector")]
                               Guid inputPortOwner,
                               [InitializerArg(1, "inputPortName", RefType.Owned, typeof(string), "The name of the port on the upstream port owner")]
                               string inputPortName,
                               [InitializerArg(2, "outputPortOwner", RefType.Owned, typeof(IPort), "The downstream port attached to this connector")]
                               Guid outputPortOwner,
                               [InitializerArg(3, "outputPortName", RefType.Owned, typeof(string), "The downstream port attached to this connector")]
                               string outputPortName)
        {
            InitializeIdentity(model, name, description, guid);

            // Put here: Things that are done in the full constructor, but don't operate
            // on the arguments passed into that ctor or this initialize method.

            IMOHelper.RegisterWithModel(this);

            model.GetService <InitializationManager>().AddInitializationTask(new Initializer(_Initialize), inputPortOwner, inputPortName, outputPortOwner, outputPortName);
        }
Example #23
0
        /// <summary>
        /// Creates a new instance of the <see cref="T:ServerPlus"/> 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>
        /// <param name="periodicity">The periodicity.</param>
        public ServerPlus(IModel model, string name, Guid guid, IPeriodicity periodicity)
        {
            InitializeIdentity(model, name, null, guid);

            m_input  = new SimpleInputPort(model, "Input", Guid.NewGuid(), this, new DataArrivalHandler(AcceptServiceObject));
            m_output = new SimpleOutputPort(model, "Output", Guid.NewGuid(), this, null, null);

            m_periodicity = periodicity;

            string sso = m_model.ModelConfig.GetSimpleParameter("SupportsServerObjects");

            m_supportsServerObjects = (sso == null)?false:bool.Parse(sso);

            OnCanWeProcessServiceObject = new ServiceRequestEvent(CanWeProcessServiceObjectHandler);
            OnPreCommencementSetup      = new ServiceEvent(PreCommencementSetupHandler);
            OnPreCompletionTeardown     = new ServiceEvent(PreCompletionTeardownHandler);

            IMOHelper.RegisterWithModel(this);
        }
Example #24
0
        /// <summary>
        /// Creates a new instance of the <see cref="T:Task"/> class.
        /// </summary>
        /// <param name="model">The model in which the task runs.</param>
        /// <param name="name">The name of the task.</param>
        /// <param name="guid">The GUID of the task.</param>
        public Task(IModel model, string name, Guid guid) : base(name)
        {
            InitializeIdentity(model, name, Description, guid);

            ExecutionDelegate = new EdgeExecutionDelegate(OnEdgeExecution);

            EdgeStartingEvent           += new EdgeEvent(OnEdgeStartingEvent);
            EdgeExecutionStartingEvent  += new EdgeEvent(OnEdgeExecutionStartingEvent);
            EdgeExecutionFinishingEvent += new EdgeEvent(OnEdgeExecutionFinishingEvent);
            EdgeFinishingEvent          += new EdgeEvent(OnEdgeFinishingEvent);

            StructureChangeHandler += new StructureChangeHandler(MyStructureChangedHandler);

            ValidityChangeEvent += new Graphs.Validity.ValidityChangeHandler(Task_ValidityChangeEvent);

            ResetDurationData();

            IMOHelper.RegisterWithModel(this);
        }
Example #25
0
        /// <summary>
        /// Constructor for MaterialType. Provides a way for the user to specify all of the detailed
        /// characteristics of the material.
        /// </summary>
        /// <param name="model">The model to which this MaterialType will belong.</param>
        /// <param name="name">The name of this MaterialType.</param>
        /// <param name="guid">The Guid of this MaterialType.</param>
        /// <param name="specificGravity">The specific gravity associated with material of this type.</param>
        /// <param name="specificHeat">The specific heat associated with material of this type.</param>
        /// <param name="stpState">State of the material at Standard Temperature &amp; Pressure conditions.</param>
        /// <param name="molecularWeight">The molecular weight.</param>
        /// <param name="latentHeatOfVaporization">The latent heat of vaporization associated with material of this type. J/kg.</param>
        public MaterialType(IModel model, string name, Guid guid,
                            double specificGravity,
                            double specificHeat,
                            MaterialState stpState,
                            double molecularWeight,
                            double latentHeatOfVaporization
                            )
        {
            m_name   = name;
            m_guid   = guid;
            m_model  = model;
            STPState = stpState;
            SetSpecificGravity(specificGravity);                   // kilogram per liter.
            SetSpecificHeat(specificHeat);                         // Joules per Kilogram-degree K.
            SetMolecularWeight(molecularWeight);
            SetLatentHeatOfVaporization(latentHeatOfVaporization); // Joules per Kilogram.
            m_emissionClassifications = null;

            IMOHelper.RegisterWithModel(this);
        }
Example #26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ItemSource"/> 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>
        /// <param name="objectSource">The object source.</param>
        /// <param name="pulseSource">The pulse source.</param>
        /// <param name="persistentOutput">If true, then the most recent output value will be returned on any peek or pull.</param>
        public ItemSource(IModel model, string name, Guid guid, ObjectSource objectSource, IPulseSource pulseSource, bool persistentOutput = false)
        {
            InitializeIdentity(model, name, null, guid);

            if (persistentOutput)
            {
                m_output = new SimpleOutputPort(model, "Source", Guid.NewGuid(), this, new DataProvisionHandler(PersistentOutput), new DataProvisionHandler(PersistentOutput));
            }
            else
            {
                m_output = new SimpleOutputPort(model, "Source", Guid.NewGuid(), this, new DataProvisionHandler(VolatileOutput), new DataProvisionHandler(VolatileOutput));
            }
            // m_ports.AddPort(m_output); <-- Done in port's ctor.
            m_objectSource          = objectSource;
            m_pulseSource           = pulseSource;
            pulseSource.PulseEvent += new PulseEvent(OnPulse);

            IMOHelper.RegisterWithModel(this);

            model.Starting += new ModelEvent(delegate(IModel theModel) { m_latestEmission = null; });
        }
Example #27
0
 /// <summary>
 /// Initializes the fields that feed the properties of this IModelObject identity.
 /// </summary>
 /// <param name="model">The IModelObject's new model value.</param>
 /// <param name="name">The IModelObject's new name value.</param>
 /// <param name="description">The IModelObject's new description value.</param>
 /// <param name="guid">The IModelObject's new GUID value.</param>
 public void InitializeIdentity(IModel model, string name, string description, Guid guid)
 {
     IMOHelper.Initialize(ref m_model, model, ref m_name, name, ref m_description, description, ref m_guid, guid);
 }
Example #28
0
        private BufferedServer(IModel model, string name, Guid guid)
        {
            InitializeIdentity(model, name, null, guid);

            IMOHelper.RegisterWithModel(this);
        }
Example #29
0
 public PatientFactory(IModel model, string name, Guid guid)
 {
     InitializeIdentity(model, name, null, guid);
     IMOHelper.RegisterWithModel(this);
 }