示例#1
0
    public bool addAvailableBioBrick(BioBrick brick, bool updateView = true)
    {
        Logger.Log("AvailableBioBricksManager::addAvailableBioBrick(" + brick + ")", Logger.Level.INFO);
        string bbName = brick.getName();

        if ((null != brick) &&
            (null == LinkedListExtensions.Find <BioBrick>(
                 _availableBioBricks
                 , b => b.getName() == bbName
                 , false
                 , " AvailableBioBricksManager::addAvailableBioBrick(" + brick + ", " + updateView + ")"
                 )
            ))
        // TODO deeper safety check
        // && !LinkedListExtensions.Find<BioBrick>(_availableBioBricks, b => b..Equals(brick), true, " AvailableBioBricksManager::addAvailableBioBrick("+brick+", "+updateView+")")
        {
            Logger.Log("AvailableBioBricksManager::addAvailableBioBrick(" + brick + ") will _availableBioBricks.AddLast(" + brick + ")", Logger.Level.INFO);

            _availableBioBricks.AddLast(brick);
            if (updateView)
            {
                updateDisplayedBioBricks();
            }
            return(true);
        }
        else
        {
            Logger.Log("AvailableBioBricksManager::addAvailableBioBrick(" + brick + ") fail", Logger.Level.INFO);
            return(false);
        }
    }
示例#2
0
    public ArrayList getMoleculesFromMedium(int id)
    {
        //"warn" parameter is true to indicate that there is no such Medium
        //as the one needed to get molecules
        Medium medium = LinkedListExtensions.Find <Medium>(
            _mediums
            , m => m.getId() == id
            , true
            , " RE::getMoleculesFromMedium(" + id + ")");

        if (medium != null)
        {
            return(medium.getMolecules());
        }
        else
        {
            return(null);
        }
    }
示例#3
0
    public BioBrick getBioBrickFromAll(string brickName)
    {
        Logger.Log("AvailableBioBricksManager::getBioBrickFromAll", Logger.Level.DEBUG);

        BioBrick brick = LinkedListExtensions.Find <BioBrick>(
            getAllBioBricks()
            , b => (b.getName() == brickName)
            , false
            , "AvailableBioBricksManager::getBioBrickFromAll(" + brickName + ")"
            );

        if (brick != null)
        {
            Logger.Log("AvailableBioBricksManager::getBioBrickFromAll found " + brick, Logger.Level.TRACE);
            return(brick);
        }
        else
        {
            Logger.Log("AvailableBioBricksManager::getBioBrickFromAll failed to find brick with name " + brickName + "!", Logger.Level.WARN);
            return(null);
        }
    }
示例#4
0
    // Searches for a brick from its name in available BioBricks
    //  If it succeeds, adds brick to deviceBricks and returns true
    //  If it fails, searches for it in all the known BioBricks
    //      If it succeeds, adds brick to available BioBricks list and does previous success treatment
    //      If it fails, returns false
    private bool processBrick(string brickName, string filePath = "")
    {
        Logger.Log("DeviceLoader::loadDevicesFromFile brick name " + brickName, Logger.Level.TRACE);
        //"warn" parameter is true to indicate that there is no such BioBrick
        //as the one mentioned in the xml file of the device
        brick = LinkedListExtensions.Find <BioBrick>(_availableBioBricks
                                                     , b => (b.getName() == brickName)
                                                     , true
                                                     , " DeviceLoader::loadDevicesFromFile(" + filePath + ")"
                                                     );

        if (brick == null)
        {
            brick = LinkedListExtensions.Find <BioBrick>(_allBioBricks
                                                         , b => (b.getName() == brickName)
                                                         , true
                                                         , " DeviceLoader::loadDevicesFromFile(" + filePath + ")"
                                                         );
            if (brick != null)
            {
                Logger.Log("DeviceLoader::loadDevicesFromFile successfully added brick " + brick, Logger.Level.TRACE);
                AvailableBioBricksManager.get().addAvailableBioBrick(brick);
            }
        }
        if (brick != null)
        {
            Logger.Log("DeviceLoader::loadDevicesFromFile successfully added brick " + brick, Logger.Level.TRACE);
            deviceBricks.AddLast(brick);
            return(true);
        }
        else
        {
            Logger.Log("DeviceLoader::loadDevicesFromFile failed to add brick with name " + brickName + "!", Logger.Level.WARN);
            return(false);
        }
    }
示例#5
0
    // Update is called once per frame
    void Update()
    {
        int previousListedCount = _displayedListMoleculesCount;
        int previousTotalCount  = _displayedMolecules.Count;

        resetMoleculeList();

        ArrayList molecules = _reactionEngine.getMoleculesFromMedium(mediumId);

        foreach (System.Object molecule in molecules)
        {
            Molecule castMolecule  = (Molecule)molecule;
            string   realName      = castMolecule.getRealName();
            string   codeName      = castMolecule.getName();
            float    concentration = castMolecule.getConcentration();
            if (displayAll || (0 != concentration))
            {
                DisplayedMolecule found = LinkedListExtensions.Find(
                    _displayedMolecules
                    , m => m.getCodeName() == codeName
                    , false
                    , " GraphMoleculeList::Update()"
                    );
                if (null != found)
                {
                    found.update(concentration);
                }
                else
                //molecule is not displayed yet
                {
                    DisplayedMolecule created = new DisplayedMolecule(codeName, realName, concentration, DisplayedMolecule.DisplayType.MOLECULELIST);

                    //search if molecule should be displayed in a Device/molecule component
                    List <EquipedDisplayedDeviceWithMolecules> containers = _equipedDevices.FindAll(eddwm => eddwm.device.getFirstGeneProteinName() == codeName);
                    if (containers.Count != 0)
                    {
                        created.setDisplayType(DisplayedMolecule.DisplayType.DEVICEMOLECULELIST);
                        foreach (EquipedDisplayedDeviceWithMolecules container in containers)
                        {
                            container.addDisplayedMolecule(created);
                        }
                    }
                    else
                    {
                        _displayedListMoleculesCount++;
                    }
                    //anyway add it to molecule list
                    _displayedMolecules.AddLast(created);
                }
            }
        }

        removeUnusedMolecules();

        if (_displayedMolecules.Count != previousTotalCount ||
            previousListedCount != _displayedListMoleculesCount)
        {
            //rearrange devices
            positionDeviceAndMoleculeComponents();
        }

        string namesToDisplay  = "";
        string valuesToDisplay = "";

        foreach (DisplayedMolecule molecule in _displayedMolecules)
        {
            if (molecule.getDisplayType() == DisplayedMolecule.DisplayType.MOLECULELIST)
            {
                namesToDisplay  += molecule.getRealName() + ":\n";
                valuesToDisplay += molecule.getVal() + "\n";
            }
        }
        if (!string.IsNullOrEmpty(namesToDisplay))
        {
            namesToDisplay.Remove(namesToDisplay.Length - 1, 1);
            valuesToDisplay.Remove(valuesToDisplay.Length - 1, 1);
        }
        namesLabel.text  = namesToDisplay;
        valuesLabel.text = valuesToDisplay;

        /*
         * if(null != topLabels)
         * {
         * topLabelsShift = Vector3.up * topLabels.relativeSize.y * topLabels.transform.localScale.y;
         * namesLabel.transform.localPosition = topLabels.transform.localPosition + topLabelsShift;
         * }
         */

        setUnfoldingListBackgroundScale();
    }