public override bool Parse(AsfParser parser)
        {
            ErrorCorrectionDataLength = (byte)(_errorCorrectionFlags & 0x0F);
            Attributes.Add(new FormattedAttribute <LAttribute, byte>(LAttribute.ErrorCorrectionDataLength, ErrorCorrectionDataLength));

            bool opaqueDataPresent = ((_errorCorrectionFlags >>= 4) & 1) != 0;

            Attributes.Add(new FormattedAttribute <LAttribute, bool>(LAttribute.OpaqueDataPresent, opaqueDataPresent));
            if (opaqueDataPresent)
            {
                Valid = false;
            }

            LengthType errorCorrectionLengthType = (LengthType)((_errorCorrectionFlags >>= 1) & 3);

            Attributes.Add(new FormattedAttribute <LAttribute, string>(LAttribute.ErrorCorrectionLengthType, errorCorrectionLengthType.PrettyPrint()));
            if (errorCorrectionLengthType != 0)
            {
                Valid = false;
            }

            bool errorCorrectionPresent = ((_errorCorrectionFlags >> 2) & 1) != 0;

            Attributes.Add(new FormattedAttribute <LAttribute, bool>(LAttribute.ErrorCorrectionPresent, errorCorrectionPresent));

            return(Valid);
        }
        public override bool Parse(AsfParser parser)
        {
            TypedValue = _lengthTypeFlags.ToString();

            MultiplePayloadsPresent = (_lengthTypeFlags & 1) != 0;
            Attributes.Add(new FormattedAttribute <LAttribute, bool>(LAttribute.MultiplePayloadsPresent, MultiplePayloadsPresent));

            SequenceType = (LengthType)((_lengthTypeFlags >>= 1) & 3);
            if (SequenceType != LengthType.ValueNotPresent)
            {
                Valid = false;
            }
            Attributes.Add(new FormattedAttribute <LAttribute, string>(LAttribute.SequenceType, SequenceType.PrettyPrint()));

            PaddingLengthType = (LengthType)((_lengthTypeFlags >>= 2) & 3);
            Attributes.Add(new FormattedAttribute <LAttribute, string>(LAttribute.PaddingLengthType, PaddingLengthType.PrettyPrint()));

            PacketLengthType = (LengthType)((_lengthTypeFlags >>= 2) & 3);
            Attributes.Add(new FormattedAttribute <LAttribute, string>(LAttribute.PacketLengthType, PacketLengthType.PrettyPrint()));

            bool errorCorrectionPresent = ((_lengthTypeFlags >>= 2) & 1) != 0;

            Attributes.Add(new FormattedAttribute <LAttribute, bool>(LAttribute.ErrorCorrectionPresent, errorCorrectionPresent));

            return(Valid);
        }
 /// <summary>
 /// Default constructor
 /// </summary>
 public PhysicalUnitTypeAttribute()
 {
     angleUnit  = AngleType.Radian;
     lengthUnit = LengthType.Meter;
     timeUnit   = TimeType.Second;
     massUnit   = MassType.Kilogram;
 }
Пример #4
0
    /// <summary>
    /// 写入一个字符串
    /// </summary>
    /// <param name="content">待写入的字符串</param>
    /// <param name="lenType">写入的字符串长度类型</param>
    public void WriteUTF8String(string content, LengthType lenType)
    {
        byte[] bytes = System.Text.Encoding.UTF8.GetBytes(content);
        int    max;

        if (lenType == LengthType.BYTE)
        {
            WriteByte(bytes.Length);
            max = byte.MaxValue;
        }
        else if (lenType == LengthType.SHORT)
        {
            WriteShort((short)bytes.Length);
            max = short.MaxValue;
        }
        else
        {
            WriteInt(bytes.Length);
            max = int.MaxValue;
        }
        if (bytes.Length > max)
        {
            WriteBytes(bytes, 0, max);
        }
        else
        {
            WriteBytes(bytes, 0, bytes.Length);
        }
    }
Пример #5
0
        private uint GetLengthTypeValue(Stream inStream, long offsetToValue, LengthType valueSize, ref uint bytesRead)
        {
            uint lengthTypeValue = 0;

            switch (valueSize)
            {
            case LengthType.Byte:
                lengthTypeValue = (uint)(ParseFile.ParseSimpleOffset(inStream, offsetToValue, 1)[0]);
                bytesRead       = 1;
                break;

            case LengthType.Word:
                lengthTypeValue = (uint)BitConverter.ToUInt16(ParseFile.ParseSimpleOffset(inStream, offsetToValue, 2), 0);
                bytesRead       = 2;
                break;

            case LengthType.Dword:
                lengthTypeValue = BitConverter.ToUInt32(ParseFile.ParseSimpleOffset(inStream, offsetToValue, 4), 0);
                bytesRead       = 4;
                break;
            }
            ;

            return(lengthTypeValue);
        }
Пример #6
0
        public static string GetMatchTypeDisplayName(MatchType mt, LengthType len = LengthType.Long)
        {
            string dn            = "";
            string specialSuffix = "";

            switch (len)
            {
            case LengthType.Short:
                specialSuffix = "*";
                break;

            case LengthType.Long:
                specialSuffix = " (Special Consideration)";
                break;
            }

            switch (mt.IsSpecialConsideration)
            {
            case true:
                dn = mt.MatchTypeName + specialSuffix;
                break;

            case false:
                dn = mt.MatchTypeName;
                break;
            }

            return(dn);
        }
Пример #7
0
        protected void WriteLengh(int length, LengthType lengthType = LengthType.Int32)
        {
            switch (lengthType)
            {
            case LengthType.Byte:
                if (length > byte.MaxValue)
                {
                    Debug.LogError("长度[" + length + "]大于" + byte.MaxValue);
                }
                Write((byte)length);
                break;

            case LengthType.Int16:
                if (length > Int16.MaxValue)
                {
                    Debug.LogError("长度[" + length + "]大于" + Int16.MaxValue);
                }
                Write((Int16)length);
                break;

            case LengthType.Int32:
                if (length > Int32.MaxValue)
                {
                    Debug.LogError("长度[" + length + "]大于" + Int32.MaxValue);
                }
                Write((Int32)length);
                break;

            default:
                break;
            }
        }
Пример #8
0
 internal LengthValueBox(LayoutMeasure measure, LengthType type, Vector p1, Vector p2) : base(measure)
 {
     Type           = type;
     P1             = p1;
     P2             = p2;
     TargetPosition = (p1 + p2) / 2;
 }
Пример #9
0
        public static bool MaxLengthIsValid(LengthType lengthType, int maxlength)
        {
            bool isValid;

            switch (lengthType)
            {
                case LengthType.FIXED:
                    isValid = maxlength <= _FIXEDMAXLENGTH;
                    break;

                case LengthType.LLVAR:
                    isValid = maxlength <= _LLVARMAXLENGTH;
                    break;

                case LengthType.LLLVAR:
                    isValid = maxlength <= _LLLVARMAXLENGTH;
                    break;

                default:
                    isValid = maxlength <= _FIXEDMAXLENGTH;
                    break;
            }

            return isValid;
        }
Пример #10
0
        public string ReadString(LengthType lengthType = LengthType.Int32)
        {
            var length = ReadLength(lengthType);
            var value  = bytes.GetString(index, length);

            index += length;
            return(value);
        }
Пример #11
0
 //Length
 public NetCommand(LengthType lengthtype, int length, int session)
 {
     Type = CommandType.LENGTH;
     Length = lengthtype;
     Session = session;
     Timestamp = Helper.Now;
     LengthValue = length;
 }
Пример #12
0
        public BinaryWriter Write(byte[] bytes, LengthType lengthType = LengthType.Int32)
        {
            var length = bytes.Length;

            WriteLengh(length, lengthType);
            byteList.AddRange(bytes);
            return(this);
        }
Пример #13
0
 public static LengthModel GetModel(LengthType type)
 {
     if (lengths.Count == 0)
     {
         Create();
     }
     return(lengths[(int)type]);
 }
Пример #14
0
 //Length
 public NetCommand(LengthType lengthtype, int length, int session)
 {
     Type        = CommandType.LENGTH;
     Length      = lengthtype;
     Session     = session;
     Timestamp   = Helper.Now;
     LengthValue = length;
 }
Пример #15
0
 public Atrribute(AttributeFormat[] attributeFormat, LengthType lengthType, AttributeMask[] attributeMask, short maxLength, short length)
 {
     AttributeFormat = attributeFormat;
     AttributeMask = attributeMask;
     LengthType = lengthType;
     MaxLength = maxLength;
     Length = lengthType != LengthType.FIXED ? length : maxLength;
 }
Пример #16
0
 public Atrribute(AttributeFormat[] characterFormat, LengthType lengthType, AttributeMask[] attributeMask, short maxLength)
 {
     AttributeFormat = characterFormat;
     LengthType = lengthType;
     AttributeMask = attributeMask;
     MaxLength = maxLength; 
     Length = MaxLength;
 }
Пример #17
0
        public BinaryWriter Write(string value, LengthType lengthType = LengthType.Int32)
        {
            var bytes  = value.GetBytes();
            var length = bytes.Length;

            WriteLengh(length, lengthType);
            byteList.AddRange(bytes);
            return(this);
        }
Пример #18
0
 public Length(LengthType type, int value)
 {
     if (value > 100 || value < -100)
     {
         throw new ArgumentException($"Percentage length must be between -100 and 100%");
     }
     Type  = type;
     Value = value;
 }
Пример #19
0
 public Length(string value, double defaultValue, LengthType defaultType)
 {
     Value = value;
     if (data == 0 && type == LengthType.None)
     {
         data = defaultValue;
         type = defaultType;
     }
 }
Пример #20
0
        public static LengthModel_Ctrl CreateCtrl(LengthType type)
        {
            if (type.GetText() == "")
            {
                return(null);
            }

            return((LengthModel_Ctrl)
                   Assembly.Load(AssemblyName).CreateInstance(type.GetText()));
        }
Пример #21
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="angleType">Type of angle</param>
 /// <param name="lengthType">Type of length</param>
 /// <param name="timeType">Type of time</param>
 /// <param name="massType">Type of mass</param>
 public PhysicalUnitTypeAttribute(AngleType angleType   = AngleType.Radian,
                                  LengthType lengthType = LengthType.Meter,
                                  TimeType timeType     = TimeType.Second,
                                  MassType massType     = MassType.Kilogram)
 {
     this.angleUnit  = angleType;
     this.lengthUnit = lengthType;
     this.timeUnit   = timeType;
     this.massUnit   = massType;
 }
Пример #22
0
        public void TestCreateSingleItem(Enums.ResourceType resourceType, LengthType lengthType, Enums.TextType textType)
        {
            Phase phase = PhaseHelper.CreatePhaseInstance(creatingRequestRecords, resourceType);

            phase.Memo = Util.GetRandomText(textType, stringLength[lengthType]);

            string result = PhaseHelper.WriteResource(phase);

            Assert.That(result, Is.Not.Null.And.Not.Empty, string.Format("Cannot create phase for {0}", resourceType));
        }
Пример #23
0
 /// <summary>
 /// Common Constructor of Iso Field
 /// </summary>
 /// <param name="position">position of Field</param>
 /// <param name="maxLen">max Len of Field value</param>
 /// <param name="lengthType">length Type</param>
 /// <param name="contentType">content type</param>
 /// <param name="dataType">data type</param>
 /// <param name="lenDataType">length data type</param>
 /// <param name="encoding">Encoding type in case that the bytes are not in Common ASCII char set</param>
 public IsoFieldAttribute(IsoFields position, int maxLen, LengthType lengthType, ContentType contentType, DataType dataType = DataType.ASCII,
                          DataType lenDataType = DataType.ASCII, EncodingType encoding = EncodingType.None)
 {
     Position    = position;
     MaxLen      = maxLen;
     LengthType  = lengthType;
     ContentType = contentType;
     DataType    = dataType;
     LenDataType = lenDataType;
     Encoding    = encoding;
 }
Пример #24
0
Файл: Length.cs Проект: wpmyj/c3
 /// <summary>
 ///
 /// </summary>
 /// <param name="lengthType"></param>
 /// <returns></returns>
 public Length ConvertTo(LengthType destType)
 {
     if (this._lengthType == destType)
     {
         return(this);
     }
     else
     {
         double r = _value * GetFactor(this._lengthType) / GetFactor(destType);
         return(new Length(r, destType));
     }
 }
Пример #25
0
        public void TestUpdateSingleItem(Enums.ResourceType resourceType, LengthType lengthType, Enums.TextType textType)
        {
            var phase = new Phase
            {
                Id   = phaseReader.Data[$"{resourceType.ToPrivateEnum()}{0}"].FirstOrDefault().Id,
                Memo = Util.GetRandomText(textType, stringLength[lengthType]),
            };

            string result = PhaseHelper.WriteResource(phase);

            Assert.That(result, Is.Not.Null.And.Not.Empty, string.Format("Cannot update phase memo for {0}", resourceType));
        }
Пример #26
0
        public byte[] ReadBytes(LengthType lengthType = LengthType.Int32)
        {
            var length = ReadLength(lengthType);
            var bytes  = new byte[length];

            for (int i = 0; i < length; i++)
            {
                bytes[i] = ReadByte();
            }

            return(bytes);
        }
Пример #27
0
        public void TestCreateListItem(Enums.ResourceType resourceType, LengthType lengthType, Enums.TextType textType)
        {
            var resourceList = new[] { 0, 1 }.Select(depKey =>
            {
                Phase phase = PhaseHelper.CreatePhaseInstance(creatingRequestRecords, resourceType, depKey);
                phase.Memo  = Util.GetRandomText(textType, stringLength[lengthType]);
                return(phase);
            }).ToList();

            List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList);

            Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot create phase for {0}", resourceType));
        }
    /// <summary>
    /// 读取一个值,值类型根据type决定,int或short或byte
    /// </summary>
    /// <param name="type">值类型</param>
    /// <returns>int数据</returns>
    public int ReadValue(LengthType type)
    {
        switch (type)
        {
        case LengthType.BYTE:
            return(ReadByteToInt());

        case LengthType.SHORT:
            return((int)ReadShort());

        default:
            return(ReadInt());
        }
    }
Пример #29
0
        public Vector()
        {
            d_alpha         = new List <double>();
            d_cosAlpha      = new List <double>();
            d_sinAlpha      = new List <double>();
            d_length        = new List <double>();
            d_lengthNorm    = new List <double>();
            d_equalLength   = 10;
            d_pixelLength   = 0;
            d_lengthType    = LengthType.Axis;
            d_drawArrowHead = true;
            d_arrowHeadSize = -1;

            LineStyle = LineStyle.None;
        }
Пример #30
0
        private static Color GetMeasureTypeColor(LengthType type)
        {
            switch (type)
            {
            default:
            case LengthType.Length:
                return(Color.Black);

            case LengthType.Width:
                return(Color.Blue);

            case LengthType.Height:
                return(Color.Red);
            }
        }
Пример #31
0
        public void TestUpdateListItem(Enums.ResourceType resourceType, LengthType lengthType, Enums.TextType textType)
        {
            var resourceList = new[] { 0, 1 }.Select(depKey =>
            {
                var phase = new Phase
                {
                    Id   = phaseReader.Data[$"{resourceType.ToPrivateEnum()}{depKey}"].FirstOrDefault().Id,
                    Memo = Util.GetRandomText(textType, stringLength[lengthType]),
                };
                return(phase);
            });

            List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList);

            Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot update phase memo for {0}", resourceType));
        }
Пример #32
0
        public void WriteString(string value, Encoding encoding, LengthType lengthType = LengthType.UInt32)
        {
            var bytes = encoding.GetBytes(value);

            switch (lengthType)
            {
            case LengthType.UInt16:
                this.WriteUInt16((ushort)bytes.Length);
                break;

            default:
            case LengthType.UInt32:
                this.WriteUInt32((uint)bytes.Length);
                break;
            }
            this.WriteBytes(bytes);
        }
    /// <summary>
    /// 写入一个数据
    /// </summary>
    /// <param name="value">待写入的数据</param>
    /// <param name="type">待写入的数据类型</param>
    public void WriteValue(int value, LengthType type)
    {
        switch (type)
        {
        case LengthType.BYTE:
            this.WriteByte(value);
            break;

        case LengthType.SHORT:
            this.WriteShort((short)value);
            break;

        default:
            this.WriteInt(value);
            break;
        }
    }
Пример #34
0
        protected int ReadLength(LengthType lengthType)
        {
            switch (lengthType)
            {
            case LengthType.Byte:
                return(ReadByte());

            case LengthType.Int16:
                return(ReadInt16());

            case LengthType.Int32:
                return(ReadInt32());

            default:
                return(0);
            }
        }
 /// <summary>
 /// Set LengthType field</summary>
 /// <param name="lengthType_">Nullable field value to be set</param>
 public void SetLengthType(LengthType? lengthType_)
 {
     SetFieldValue(12, 0, lengthType_, Fit.SubfieldIndexMainField);
 }
Пример #36
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="lengthType"></param>
 /// <returns></returns>
 private double GetFactor(LengthType lengthType)
 {
     return _factors[lengthType];
 }
Пример #37
0
		/// <summary>
		/// construct a new Length object. The value is set to 0
		/// </summary>
		/// <param name="u"></param>
		public Length(LengthType u)
		{
			Type = u;
			Value = 0;
		}
Пример #38
0
		/// <summary>
		/// construct a new Length object
		/// </summary>
		/// <param name="u">the type of the Length</param>
		/// <param name="v">the value of the Length</param>
		public Length(LengthType u, float v)
		{
			Type = u;
			Value = v;
		}
Пример #39
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="lengthType"></param>
 /// <returns></returns>
 public Length ConvertTo(LengthType destType)
 {
     if (this._lengthType == destType)
     {
         return this;
     }
     else
     {
         double r = _value * GetFactor(this._lengthType) / GetFactor(destType);
         return new Length(r, destType);
     }
 }
Пример #40
0
        public isoFieldDefinition(int fn, FieldType ft, EncodingType fe, LengthType lt, EncodingType le, int fl)
        {
            fieldType = ft;                         // the data type of the field data

            lengthType = lt;                        // the length type FIXED,LVAR, LLVAR or LLLVAR

            if (lengthType == LengthType.LLVAR)
            {
                lenLength = 1;                      // check the encoding to decide how many bytes needed. if BCD then 1 byte is enough

                lengthEncoding = le;                // the length indicator encoding type

                fixedLength = 0;
            }
            else if (lengthType == LengthType.LLLVAR)
            {
                lenLength = 2;                      // check the encoding to decide how many bytes needed. if BCD then 2 bytes are enough

                lengthEncoding = le;                // the length indicator encoding type

                fixedLength = 0;
            }
            else if (lengthType == LengthType.FIXED)
            {
                lenLength = 0;                      // length indicator is 0 since is FIXED length field

                lengthEncoding = EncodingType.NULL; // encoding method is NULL since we have no length indicator to encode

                fixedLength = fl;
            }

            fieldEncoding = fe;                     // the field data encoding type

            number = fn;                            // field number
        }
Пример #41
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="value"></param>
 /// <param name="lengthType"></param>
 public Length(double value, LengthType lengthType)
 {
     _value = value;
     _lengthType = lengthType;
 }