getMediumFromId() public static method

public static getMediumFromId ( int id, LinkedList list ) : Medium,
id int
list LinkedList
return Medium,
示例#1
0
    /*!
     * \brief Adds an IReaction to a medium
     * \param mediumId The medium ID.
     * \param reaction The reaction to add.
     */
    public void addReactionToMedium(int mediumId, IReaction reaction)
    {
        Logger.Log("ReactionEngine::addReactionToMedium(" + mediumId + ", " + reaction + ")", Logger.Level.INFO);
        Medium med = ReactionEngine.getMediumFromId(mediumId, _mediums);

        if (med == null)
        {
            Logger.Log("ReactionEngine::addReactionToMedium medium #" + mediumId + "not found", Logger.Level.WARN);
            return;
        }

        /*TODO FIXME USEFULNESS?/////////////////////////////////////////////////////////////////////
         * ReactionSet reactionsSet = null;
         * string medName = med.getName()+"Reactions";
         * foreach (ReactionSet rs in _reactionsSets) {
         * if (rs.id == medName) reactionsSet = rs;
         * }
         * if (reactionsSet != null) {
         * reactionsSet.reactions.AddLast(IReaction.copyReaction(reaction));
         * } else {
         * Logger.Log("ReactionEngine::addReactionToMedium reactionsSet == null", Logger.Level.WARN);
         * }
         * //////////////////////////////////////////////////////////////////////////////////////////*/

        med.addReaction(IReaction.copyReaction(reaction));
    }
示例#2
0
    void OnTriggerEnter(Collider collider)
    {
        Logger.Log("PhenoFickContact::OnTriggerEnter collider=" + collider, Logger.Level.DEBUG);
        PhysicalMedium PMext = collider.gameObject.GetComponent <PhysicalMedium>();

        if (PMext == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerEnter collider.PMext == null", Logger.Level.TRACE);
            return;
        }
        int    colliderMediumIdExt = PMext.MediumId;
        Medium colliderMediumExt   = ReactionEngine.getMediumFromId(colliderMediumIdExt, _reactionEngine.getMediumList());

        if (colliderMediumExt == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerEnter The collided medium does not exist in the reaction Engine. Load it or change the MediumId number in the PhysicalMedium script.", Logger.Level.WARN);
            return;
        }

        PhysicalMedium PM = GetComponent <PhysicalMedium>();

        if (PMext == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerEnter this.PMext == null", Logger.Level.TRACE);
            return;
        }
        int    mediumId = PM.MediumId;
        Medium medium   = ReactionEngine.getMediumFromId(mediumId, _reactionEngine.getMediumList());

        if (medium == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerEnter The medium does not exist in the reaction Engine. Load it or change the MediumId number in the PhysicalMedium script.", Logger.Level.WARN);
            return;
        }

        float        surface  = Math.Min(PM.Size, PMext.Size);
        Fick         fick     = _reactionEngine.getFick();
        FickReaction reaction = Fick.getFickReactionFromIds(colliderMediumIdExt, mediumId, fick.getFickReactions());

        if (reaction == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerEnter This FickReaction does not exist.", Logger.Level.WARN);
            return;
        }
        reaction.setSurface(surface);

        // set medium as medium of collider
        Logger.Log("colliderMediumIdExt : " + colliderMediumIdExt, Logger.Level.INFO);
        configureExternalDisplays(colliderMediumIdExt);
        _collidedMediumIds.AddLast(colliderMediumIdExt);

        /*
         * Logger.Log("PhenoFickContact::OnTriggerEnter"
         +" reaction.setSurface("+surface+")"
         +" _collidedMediumIds.Count="+_collidedMediumIds.Count
         +" _collidedMediumIds.Last.Value="+_collidedMediumIds.Last.Value
         * ,Logger.Level.);
         */
    }
示例#3
0
 void Start()
 {
     _reactionEngine = ReactionEngine.get();
     _graphWindow    = gameObject.GetComponentInChildren <GraphWindow>();
     if (setMedium(ReactionEngine.getMediumFromId(_mediumId, _reactionEngine.getMediumList())) == false)
     {
         Logger.Log("Failed to load medium curves", Logger.Level.ERROR);
     }
 }
示例#4
0
    /*!
     * \brief remove a reaction from a medium
     * \param mediumId The medium ID.
     * \param name The reaction's name.
     */
    public void removeReactionFromMediumByName(int mediumId, string name)
    {
        Medium med = ReactionEngine.getMediumFromId(mediumId, _mediums);

        if (med == null)
        {
            return;
        }
        med.removeReactionByName(name);
    }
示例#5
0
    private void initializeIfNecessary()
    {
        //???
        //gameObject.SetActive(true);
        _isAlive = true;

        //LinkedList<Medium> mediums = ReactionEngine.get ().getMediumList();
        _medium          = ReactionEngine.getMediumFromId(1, ReactionEngine.get().getMediumList());
        _maxMediumEnergy = _medium.getMaxEnergy();
        _energy          = _medium.getEnergy() / _maxMediumEnergy;
    }
示例#6
0
    /*!
     * \brief This method gets all molecular concentrations
     * \sa Molecule
     * \sa Molecule.getConcentration()
     */
    public void initMolecules()
    {
        LinkedList <Medium> mediums = _reactionEngine.getMediumList();

        _mediumRef = ReactionEngine.getMediumFromId(_mediumId, mediums);

        if (_mediumRef != null && _molecules == null)
        {
            _molecules = _mediumRef.getMolecules();
        }
    }
示例#7
0
    /* !
     * \brief Remove from the specified medium the reaction that has the same characteristics as the one given as parameter
     * \param mediumId The Id of the medium to remove from.
     * \param reaction The model of reaction to remove.
     * \param checkNameAndMedium Whether the name and medium must be taken into account or not.
     */
    public void removeReaction(int mediumId, IReaction reaction, bool checkNameAndMedium = false)
    {
        Medium med = ReactionEngine.getMediumFromId(mediumId, _mediums);

        if (med == null)
        {
            Logger.Log("ReactionEngine::removeReaction could not find medium with id " + mediumId, Logger.Level.WARN);
            return;
        }

        med.removeReaction(reaction, checkNameAndMedium);
    }
示例#8
0
    /*!
     * \brief Load a list of properties in order to convert it into a ActiveTransportReaction
     * \param props The list of ActiveTransportProperties
     * \param mediums The list of mediums
     */
    public void loadActiveTransportReactionsFromProperties(LinkedList <ActiveTransportProperties> props, LinkedList <Medium> mediums)
    {
        ActiveTransportReaction reaction;
        Medium med;

        foreach (ActiveTransportProperties prop in props)
        {
            reaction = new ActiveTransportReaction();
            reaction.setName(prop.name);
            reaction.setSubstrate(prop.substrate);
            reaction.setEnzyme(prop.enzyme);
            reaction.setKcat(prop.Kcat);
            reaction.setEffector(prop.effector);
            reaction.setAlpha(prop.alpha);
            reaction.setBeta(prop.beta);
            reaction.setKm(prop.Km);
            reaction.setKi(prop.Ki);
            reaction.setEnergyCost(prop.energyCost);
            foreach (Product p in prop.products)
            {
                reaction.addProduct(p);
            }
            med = ReactionEngine.getMediumFromId(prop.srcMediumId, mediums);
            if (med == null)
            {
                Debug.Log("Cannot load Active Transport properties because the medium Id : " + prop.srcMediumId + " is unknown.");
                break;
            }
            reaction.setSrcMedium(med);
            med = ReactionEngine.getMediumFromId(prop.dstMediumId, mediums);
            if (med == null)
            {
                Debug.Log("Cannot load Active Transport properties because the medium Id : " + prop.dstMediumId + " is unknown.");
                break;
            }
            reaction.setDstMedium(med);
            med = ReactionEngine.getMediumFromId(prop.mediumId, mediums);
            if (med == null)
            {
                Debug.Log("Cannot load Active Transport properties because the medium Id : " + prop.mediumId + " is unknown.");
                break;
            }
            reaction.setMedium(med);
            med.addReaction(reaction);
        }
    }
示例#9
0
    public static IReaction        buildFickReactionFromProps(FickProperties props, LinkedList <Medium> mediums)
    {
        FickReaction reaction = new FickReaction();
        Medium       med1     = ReactionEngine.getMediumFromId(props.MediumId1, mediums);
        Medium       med2     = ReactionEngine.getMediumFromId(props.MediumId2, mediums);

        if (med1 == null || med2 == null)
        {
            Debug.Log("failed to build FickReaction from FickProperties beacause one or all the medium id don't exist");
            return(null);
        }
        reaction.setSurface(props.surface);
        reaction.setPermCoef(props.P);
        reaction.setMedium1(med1);
        reaction.setMedium2(med2);
        reaction.setEnergyCost(props.energyCost);

        return(reaction);
    }
示例#10
0
    public void setMedium(int mediumId)
    {
        if (!safeLazyInit())
        {
            return;
        }

        _mediumId = mediumId;

        Medium medium = ReactionEngine.getMediumFromId(_mediumId, _mediums);

        if (medium == null)
        {
            Logger.Log("VectrosityPanel Can't find the given medium (" + _mediumId + ")", Logger.Level.ERROR);
            return;
        }

        _molecules = medium.getMolecules();
        if (_molecules == null)
        {
            Logger.Log("VectrosityPanel Can't find molecules in medium (" + _mediumId + ")", Logger.Level.ERROR);
            return;
        }

        VectrosityPanelLine line;

        foreach (Molecule m in _molecules)
        {
            line = _lines.Find(l => m.getName() == l.moleculeName);
            if (null == line)
            {
                _lines.Add(new Line(width, height, infos, _mediumId, m.getName()));
            }
        }

        drawLines(true);

        lineCount = _lines.Count;
    }
示例#11
0
    public void OnTriggerExit(Collider collider)
    {
        Logger.Log("PhenoFickContact::OnTriggerExit collider=" + collider, Logger.Level.DEBUG);
        PhysicalMedium PMext = collider.gameObject.GetComponent <PhysicalMedium>();

        if (PMext == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerExit collider.PMext == null", Logger.Level.TRACE);
            return;
        }
        int    colliderMediumIdExt = PMext.MediumId;
        Medium colliderMediumExt   = ReactionEngine.getMediumFromId(colliderMediumIdExt, _reactionEngine.getMediumList());

        if (colliderMediumExt == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerExit The collided medium does not exist in the reaction Engine. Load it or change the MediumId number in the PhysicalMedium script.", Logger.Level.WARN);
            return;
        }

        PhysicalMedium PM = GetComponent <PhysicalMedium>();

        if (PMext == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerExit this.PMext == null", Logger.Level.TRACE);
            return;
        }
        int    mediumId = PM.MediumId;
        Medium medium   = ReactionEngine.getMediumFromId(mediumId, _reactionEngine.getMediumList());

        if (medium == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerExit The medium does not exist in the reaction Engine. Load it or change the MediumId number in the PhysicalMedium script.", Logger.Level.WARN);
            return;
        }

        // un-set medium as medium of collider
        _collidedMediumIds.Remove(colliderMediumIdExt);

        //string nullLast = (null != _collidedMediumIds.Last)?_collidedMediumIds.Last.Value.ToString():"null";

        /*
         * Logger.Log("PhenoFickContact::OnTriggerExit"
         +" _collidedMediumIds.Count="+_collidedMediumIds.Count
         +" _collidedMediumIds.Last.Value="+nullLast
         * ,Logger.Level.);
         */
        //Logger.Log("PhenoFickContact::OnTriggerExit _collidedMediumIds.Last.Value="+nullLast, Logger.Level.);

        if (null != _collidedMediumIds.Last)
        {
            // TODO consider the current medium as superposition of mediums the ids of which are _collidedMediumIds
            configureExternalDisplays(_collidedMediumIds.Last.Value);
        }
        else
        {
            //not in any Fick contact anymore
            configureExternalDisplays(_vectroPanelInitMediumId);

            Fick         fick     = _reactionEngine.getFick();
            FickReaction reaction = Fick.getFickReactionFromIds(colliderMediumIdExt, mediumId, fick.getFickReactions());
            if (reaction == null)
            {
                Logger.Log("PhenoFickContact::OnTriggerExit This FickReaction does not exist.", Logger.Level.WARN);
            }
            reaction.setSurface(0);
        }
    }