/// <summary> /// Initializes a new instance of the <see cref="Frame"/> class. /// </summary> /// <param name="frame">The frame.</param> public Frame(Frame frame) { this.Content = new List<IContent>(frame.Content); this.Level = frame.Level; this.Msoh = new Header(frame.Msoh); this.Rsoh = new Header(frame.Rsoh); }
/// <summary> /// Evaluates the header. /// </summary> /// <param name="sdhFrame">The SDH frame.</param> /// <returns></returns> public bool evaluateHeader(IFrame sdhFrame) { Frame tempFrame = new Frame((Frame)sdhFrame); tempFrame.Msoh = null; if (sdhFrame.Msoh != null && (sdhFrame.Msoh.Checksum == BinaryInterleavedParity.GenerateBIP(((Frame)sdhFrame).Content, 21, ((Frame)sdhFrame).Level))) return true; else return false; }
/// <summary> /// Evaluates the header. /// </summary> /// <param name="sdhFrame">The SDH frame.</param> /// <returns></returns> public bool evaluateHeader(IFrame sdhFrame) { //Remove RSOH header from tempFrame Frame tempFrame = new Frame((Frame)sdhFrame); tempFrame.Rsoh = null; //Check BIP if (sdhFrame.Rsoh != null && sdhFrame.Rsoh.Checksum == BinaryInterleavedParity.GenerateBIP(((Frame)tempFrame), 8)) return true; else return false; }
/// <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); }