Exemple #1
0
        public virtual void PrintHtml(string f)
        {
            if (m_files.Count > 0)
            {
                string fileName = null;
                if (f == null)
                {
                    fileName = m_files[0].m_fileName;

                    if (fileName.ToUpper().EndsWith(".ASN1"))
                        fileName = fileName.Substring(0, fileName.Length - 5) + ".html";
                    else if (fileName.ToUpper().EndsWith(".ASN"))
                        fileName = fileName.Substring(0, fileName.Length - 4) + ".html";
                    else
                        fileName += ".html";
                }
                else
                    fileName = f;

                StreamWriterLevel wr = null;
                try
                {
                    wr = new StreamWriterLevel(fileName);
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine(ex.Message);
                    return;
                }
                wr.WriteLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"");
                wr.WriteLine("        \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");

                wr.WriteLine("<html xmlns=\"http://www.w3.org/1999/xhtml\" >");
                wr.WriteLine("<head>");
                wr.WriteLine("    <title>ICD</title>");
                wr.WriteLine("    <style type=\"text/css\"> {0} </style>", ICDFile.css);
                wr.WriteLine("</head>");
                wr.WriteLine("<body>");
                wr.WriteLine("<em>The following tables describe the binary encodings of the data model using the ASN.1 Unaligned Packed Encoding Rules <a href=\"http://www.itu.int/ITU-T/studygroups/com17/languages/X.691-0207.pdf\">(PER)</a> - ITU-T Rec. X.691 (2002) | ISO/IEC 8825-2:2002 ASN.1 encoding rules.");
                wr.WriteLine(" This page was created by the ");
                wr.WriteLine("<a href=\"http://www.semantix.gr/DataModelling/OnlineDemo/icdDemo.htm\">Automatic ICD Generator tool</a></em><br/><br/>");

                foreach (ICDFile file in m_files)
                    file.PrintHtml(wr, 0);

                if (m_HtmlIntegerSizeMustBeExplained || m_HtmlLengthSizeMustBeExplained || m_HtmlRealSizeMustBeExplained || m_WithComponentMustBeExplained)
                {

                    wr.WriteLine("<hr />");
                    if (m_HtmlIntegerSizeMustBeExplained)
                    {
                        wr.WriteLine("<a name=\"INT_SIZE_EXPLAINED123\"></a>");
                        wr.WriteLine("<em>Unconstraint integer's size explained</em><br/>");
                        wr.WriteLine("In unaligned PER, unconstraint integers are encoded into the minimum number of octets (using non negative binary integer or 2's-complement binary integer encoding) and a length determinant, containing the number of value octets, is added at the beginning of the encoding. Therefore uPER can support integers of any size, even of infinity value. However, in almost all processors, integers have limited capacity which is usually four or eight octets. Therefore, the reported maximum size in octets for an unconstraint integer is 1 (for the length determinant) plus the word size for the target processor which is specified in the command line by the wordSize argument. In this invocation, wordSize was specified to be {0} octets and therefore the maximum size of the unconstraint integers is {1} octets or {2} bits", Config.IntegerSize, Config.IntegerSize + 1, (Config.IntegerSize + 1) * 8);
                        wr.WriteLine("<br/>");
                        wr.WriteLine("<br/>");
                    }
                    if (m_HtmlRealSizeMustBeExplained)
                    {
                        wr.WriteLine("<a name=\"REAL_SIZE_EXPLAINED123\"></a>");
                        wr.WriteLine("<em>Real's size explained</em><br/>");
                        wr.WriteLine("In both uPER and aPER, real values are encoded as a pair of integers which represent the mantissa and exponent (real value = mantissa* 2<span style=\"vertical-align: super\">exponent</span>). In particular, a real is encoded into a length determinant field, a header field (always one octet), the exponent field using 2's complement binary integer and the mantissa field. Therefore uPER can support reals with infinity precision since both exponent and mantissa can, theoretically, have infinity length. However, in almost all processors, integers have limited capacity which is usually four or eight octets. Therefore, the reported maximum size in octets for a real is 1 for the length determinant plus 1 for header field plus 3 octets for exponent and finally plus the word size for the target processor which is specified in the command line by the wordSize argument. In this invocation, wordSize was specified to be {0} octets and therefore the maximum size of a real is {1} octets or {2} bits.", Config.IntegerSize, RealType.uPerMaxSize / 8, RealType.uPerMaxSize);
                        wr.WriteLine("<br/>");
                        wr.WriteLine("<br/>");
                    }
                    if (m_HtmlLengthSizeMustBeExplained)
                    {
                        wr.WriteLine("<a name=\"ARRAYS_SIZE_EXPLAINED123\"></a>");
                        wr.WriteLine("<em>Length's size explained</em><br/>");
                        wr.WriteLine("In uPER, the length determinant field, which used in the encoding of sizeable types such as SEQUENCE OFs, SET OFs, BIT STRINGs, OCTET STRINGs and character types, is at most two octets provided that (a) there is a SIZE constraint which limits the length count to a value less than 64K or (b) there is no size constraint, but in the given instance of the sizeable type the number of the elements is less than 16K. In all other cases, the sizeable type is encoded using fragmentation where the length determinant is encoded interstitially with the actual data. In this particular case (i.e. when fragmentation is applicable), the table produced by the autoICD generator does not represent correctly the physical PER encoding.");
                    }

                    if (m_WithComponentMustBeExplained)
                    {
                        wr.WriteLine("<a name=\"WITH_COMPONENT_EXPLAINED123\"></a>");
                        wr.WriteLine("<em>Constraint ignored in encoding</em><br/>");
                        wr.WriteLine("The constraint with the yellow color is not PER visible, as it derives from a WITH COMPONENT or WITH COMPONENTS contraint in the parent type, and therefore is ignored in the encoding/decoding.");
                    }
                    if (m_ZeroBitsMustBeExplained)
                    {
                        wr.WriteLine("<a name=\"ZERO_BITS_EXPLAINED123\"></a>");
                        wr.WriteLine("<em>Field with zero size explained</em><br/>");
                        wr.WriteLine("An integer type that is contraint to a single value (i.e. INTEGER (5) or INTEGER (1..10)(10..20)) requires zero bits when encoded in uPER since the decoder can always determine its value. In other words, a integer field which is contraint to a single value is never transmitted in uPER.");
                    }

                    wr.WriteLine("<hr />");
                }

                foreach (ICDFile file in m_files)
                    file.PrintAsn1InHtml(wr, 0);

                wr.WriteLine("</body>");
                wr.WriteLine("</html>");

                wr.Flush();
                wr.Close();

            }
        }
Exemple #2
0
        public void PrintHtml(StreamWriterLevel wr, int lev)
        {
            Tabularize();

            wr.WriteLine("    <div style=\"width: 100%\">");
            wr.WriteLine(string.Format("    <h1 >Asn1 file : {0}</h1>", System.IO.Path.GetFileName(m_fileName)));

            foreach (ICDModule m in m_modules)
                m.PrintHtml(wr, lev);

            wr.WriteLine("    </div>");

            wr.Flush();
        }