示例#1
0
        /// <summary>
        /// Builds the frame from JSON text
        /// </summary>
        /// <param name="textFrame">The text of JSON frame.</param>
        /// <returns></returns>
        public IFrame BuildFrame(String textFrame)
        {
            metadata = JObject.Parse(textFrame);
            StmLevel frameLevel = StmLevel.STM1;

            if (metadata["Level"] != null)
            {
                frameLevel = FrameBuilder.getStmLevel(metadata["Level"]);
            }
            Frame returnFrame = new Frame(frameLevel);

            if (metadata["Msoh"].HasValues)
            {
                returnFrame.Msoh = (Header)FrameBuilder.EvaluateContent((JObject)metadata["Msoh"]);
            }
            if (metadata["Rsoh"].HasValues)
            {
                returnFrame.Rsoh = (Header)FrameBuilder.EvaluateContent((JObject)metadata["Rsoh"]);
            }
            if (FrameBuilder.isJArray(metadata["Content"]))
            {
                returnFrame.Content = FrameBuilder.evaluateContents((JArray)metadata["Content"]);
            }
            else
            {
                return(null);
            }
            return(returnFrame);
        }
        /// <summary>
        /// Generates the BIP checksum from content.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <param name="blockCount">The block count.</param>
        /// <param name="level">The level.</param>
        /// <returns></returns>
        public static string GenerateBIP(List <IContent> content, int blockCount, StmLevel level)
        {
            Frame bipFrame = new Frame(level);

            bipFrame.Content = new List <IContent>(content);
            return(BinaryInterleavedParity.GenerateBIP(bipFrame, blockCount));
        }
示例#3
0
 public NodeInput(int tcpPort, int abstractPort, StmLevel level)
     : base(tcpPort)
 {
     InputPort   = abstractPort;
     InputBuffer = new List <List <byte> >();
     Active      = true;
     Level       = level;
 }
示例#4
0
 public NodeInput(int tcpPort, int abstractPort, StmLevel level)
     : base(tcpPort)
 {
     InputPort = abstractPort;
     InputBuffer = new List<List<byte>>();
     Active = true;
     Level = level;
 }
示例#5
0
 public StreamData(int port, StmLevel stm, VirtualContainerLevel vcLevel, int hpo, int? lpo)
 {
     Port = port;
     Stm = stm;
     VcLevel = vcLevel;
     HigherPath = hpo;
     LowerPath = lpo;
 }
示例#6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Frame" /> class.
 /// This create empty Content List
 /// </summary>
 /// <param name="stmLevel">The STM level.</param>
 public Frame(StmLevel stmLevel)
 {
     Content    = new List <IContent>();
     this.Level = stmLevel;
     for (int x = 0; x < ConvertSTMLevel(Level); x++)
     {
         Content.Add(null); //Add empty place for VC4
     }
     this.Msoh = new Header();
     this.Rsoh = new Header();
 }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Frame" /> class.
 /// This create empty Content List
 /// </summary>
 /// <param name="stmLevel">The STM level.</param>
 public Frame(StmLevel stmLevel)
 {
     Content = new List<IContent>();
     this.Level = stmLevel;
     for (int x = 0; x < ConvertSTMLevel(Level); x++)
     {
         Content.Add(null); //Add empty place for VC4
     }
     this.Msoh = new Header();
     this.Rsoh = new Header();
 }
示例#8
0
        private StreamData CreateRecord(List <string> literalRecord)
        {
            int outPort    = int.Parse(literalRecord[0]);
            int?lowerPath  = literalRecord[4].Equals("") ? null : (int?)int.Parse(literalRecord[4]);
            int higherPath = int.Parse(literalRecord[3]);

            VirtualContainerLevel level = VirtualContainerLevelExt.GetContainer(literalRecord[2]);
            StmLevel stm = StmLevelExt.GetContainer(literalRecord[1]);

            StreamData record = new StreamData(outPort, stm, level, higherPath, lowerPath);

            return(record);
        }
示例#9
0
        /// <summary>
        /// Converts the STM level.
        /// </summary>
        /// <param name="stmLevel">The STM level.</param>
        /// <returns></returns>
        public int ConvertSTMLevel(StmLevel stmLevel)
        {
            switch (stmLevel)
            {
            case StmLevel.STM1:
                return(1);

            case StmLevel.STM4:
                return(4);

            case StmLevel.STM16:
                return(16);

            case StmLevel.STM64:
                return(64);

            case StmLevel.STM256:
                return(256);

            default:
                return(1);
            }
        }
示例#10
0
        private void CommuteFrame(int input, IFrame frame, Dictionary <int, IFrame> outputFrames)
        {
            if (!ForwardingTable.ContainsKey(input))
            {
                return;
            }

            List <ForwardingRecord> forwardingRules = ForwardingTable[input];

            foreach (ForwardingRecord record in forwardingRules)
            {
                if (!outputFrames.ContainsKey(record.OutputPort))
                {
                    Dictionary <int, StmLevel> portStmLevels = this.ttf.GetPorts();
                    StmLevel outputFrameLevel = portStmLevels[record.OutputPort];
                    outputFrames.Add(record.OutputPort, new Frame(outputFrameLevel));
                }

                IFrame   outputFrame = outputFrames[record.OutputPort];
                IContent vContainer  = frame.GetVirtualContainer(record.ContainerLevel, record.HigherPathIn, record.VcNumberIn == -1 ? null : (int?)record.VcNumberIn);

                outputFrame.SetVirtualContainer(record.ContainerLevel, record.HigherPathOut, record.VcNumberOut, vContainer);
            }
        }
 /// <summary>
 /// Generates the BIP checksum from content.
 /// </summary>
 /// <param name="content">The content.</param>
 /// <param name="blockCount">The block count.</param>
 /// <param name="level">The level.</param>
 /// <returns></returns>
 public static string GenerateBIP(List<IContent> content, int blockCount, StmLevel level)
 {
     Frame bipFrame = new Frame(level);
     bipFrame.Content = new List<IContent>(content);
     return BinaryInterleavedParity.GenerateBIP(bipFrame, blockCount);
 }
示例#12
0
 /// <summary>
 /// Converts the STM level.
 /// </summary>
 /// <param name="stmLevel">The STM level.</param>
 /// <returns></returns>
 public int ConvertSTMLevel(StmLevel stmLevel)
 {
     switch (stmLevel)
     {
         case StmLevel.STM1:
             return 1;
         case StmLevel.STM4:
             return 4;
         case StmLevel.STM16:
             return 16;
         case StmLevel.STM64:
             return 64;
         case StmLevel.STM256:
             return 256;
         default:
             return 1;
     }
 }