Ejemplo n.º 1
0
        /// <summary>
        /// Create a list of Channels, using the mesh hierarchy to get the visible frames representing the channels,
        /// and the gene or the physiology to get the species-specific parameters such as chemical selectivity
        /// </summary>
        /// <param name="gene"></param>
        /// <returns></returns>
        private Channel[] LoadChannels(Gene gene)
        {
            // Read any channels defined by the gene
            Channel[] channel = gene.GetChannels();

            // If none are defined, create some and load with the default chemical#s from the cell type
            if (channel.Length == 0)
            {
                ChannelData[] chanData = physiology.GetChannelData();					// read the default src, dst, chem
                if (chanData != null)
                {
                    channel = new Channel[chanData.GetLength(0)];						// create enough channels
                    for (int c = 0; c < channel.Length; c++)							// copy in the default chemical selectivity
                    {
                        channel[c] = new Channel();
                        channel[c].chemical = chanData[c].Chemical;
                        channel[c].constant = chanData[c].Constant;                     // and default for user-definable constant
                    }
                }
            }

            //// Get a list of the "chan#" frames (visible organelles), in order, then copy to the channels
            //JointFrame[] channelFrame = null;
            //try
            //{
            //    channelFrame = JointFrame.IndexFrameType(rootFrame, JointFrame.FrameType.Channel);
            //    for (int c = 0; c < channel.Length; c++)
            //    {
            //        channel[c].organelle = channelFrame[c];
            //    }
            //}
            //catch
            //{
            //    throw new SDKException(this.name + " has different numbers of channels in the cell type ("
            //                            + channel.Length + ") and the mesh (" + channelFrame.Length + ")");
            //}

            return channel;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Read a channel node (note: not all members of Channel are filled (e.g. mesh frames))
        /// </summary>
        /// <param name="xml"></param>
        /// <returns></returns>
        public static Channel ReadChannel(XmlTextReader xml)
        {
            string tag = "";
            Channel channel = new Channel();

            while (xml.Read())												// for each node...
            {
                // <tag>
                if (xml.NodeType == XmlNodeType.Element)
                {
                    tag = xml.Name;
                }
                // text within tags
                else if (xml.NodeType == XmlNodeType.Text)
                {
                    channel.ReadXml(xml, tag);
                }
                // closing tag
                else if (xml.NodeType == XmlNodeType.EndElement)
                {
                    if (xml.Name == "channel")
                    {
                        return channel;										// return the channel I just created
                    }
                }
            }

            throw new XmlException("missing </channel> tag");				// should always return before end of file
        }