Beispiel #1
0
        public override string ToString()
        {
            var build = new StringBuilder();

            build.AppendLine($"Reader Number: {ReaderNumber}");
            build.AppendLine($"  Format Code: {Message.SplitCamelCase(FormatCode.ToString())}");
            build.AppendLine($"    Bit Count: {BitCount}");
            build.AppendLine($"         Data: {FormatData(Data)}");
            return(build.ToString());
        }
Beispiel #2
0
        public static string GetItemFormatString(FormatCode fc)
        {
            string ret = "";

            switch (fc)
            {
            case FormatCode.ASCII:
                ret = "A";
                break;

            case FormatCode.Binary:
                ret = "B";
                break;

            case FormatCode.Boolean:
                ret = "TF";
                break;

            case FormatCode.LIST:
                ret = "L";
                break;

            case FormatCode.MC:
                ret = "C2";
                break;

            case FormatCode.F4:
            case FormatCode.F8:
            case FormatCode.I1:
            case FormatCode.I2:
            case FormatCode.I4:
            case FormatCode.I8:
            case FormatCode.JIS8:
            case FormatCode.U1:
            case FormatCode.U2:
            case FormatCode.U4:
            case FormatCode.U8:
                ret = fc.ToString();
                break;
            }

            return(ret);
        }
        public SVIDAttribute(FormatCode fc, object svId, int size)
        {
            m_Format = fc;
            m_Size   = size;

            string strSvid = svId.ToString();

            switch (fc)
            {
            case FormatCode.U1:
                sbyte u1 = 0;
                if (sbyte.TryParse(strSvid, out u1))
                {
                    m_ID = u1;
                }
                break;

            case FormatCode.U2:
                ushort u2 = 0;
                if (ushort.TryParse(strSvid, out u2))
                {
                    m_ID = u2;
                }
                break;

            case FormatCode.U4:
                UInt32 u4 = 0;
                if (UInt32.TryParse(strSvid, out u4))
                {
                    m_ID = u4;
                }
                break;

            case FormatCode.U8:
                UInt64 u8 = 0;
                if (UInt64.TryParse(strSvid, out u8))
                {
                    m_ID = u8;
                }
                break;

            case FormatCode.I1:
                byte i1 = 0;
                if (byte.TryParse(strSvid, out i1))
                {
                    m_ID = i1;
                }
                break;

            case FormatCode.I2:
                short i2 = 0;
                if (short.TryParse(strSvid, out i2))
                {
                    m_ID = i2;
                }
                break;

            case FormatCode.I4:
                Int32 i4 = 0;
                if (Int32.TryParse(strSvid, out i4))
                {
                    m_ID = i4;
                }
                break;

            case FormatCode.I8:
                Int64 i8 = 0;
                if (Int64.TryParse(strSvid, out i8))
                {
                    m_ID = i8;
                }
                break;

            case FormatCode.ASCII:
                m_ID = strSvid;
                break;

            default:
                //throw error
                throw new Exception("Not supported type " + fc.ToString());
            }
        }
Beispiel #4
0
 public virtual IList<float> ReadTrace(BinaryReader reader, FormatCode sampleFormat, int sampleCount)
 {
     var trace = new float[sampleCount];
     for (int i = 0; i < sampleCount; i++)
     {
         switch (sampleFormat)
         {
             case FormatCode.IbmFloatingPoint4:
                 trace[i] = reader.ReadSingleIbm();
                 break;
             case FormatCode.IeeeFloatingPoint4:
                 trace[i] = reader.ReadSingle();
                 break;
             case FormatCode.TwosComplementInteger2:
                 trace[i] = reader.ReadInt16BigEndian();
                 break;
             default:
                 throw new NotSupportedException("Unsupported sample format: " + sampleFormat.ToString());
         }
     }
     return trace;
 }