예제 #1
0
        private Boolean VerifyValue(Byte[] Value)
        {
            if (Value == null || Value.Length == 0)
            {
                return(true);
            }
            if (FValidDataFormats.Count == 0)
            {
                return(true);
            }

            // If one or more InputDataFormats are defined, we look at the latest received InputFormat from the device
            // for a received value to be accepted, there:
            //   1. Must exists an DataFormat that matches the latest received InputFormat from device.
            //   2. The received valueData length must match this DataFormat.
            wclWeDoDataFormat DataFormat = DataFormatForInputFormat(FInputFormat);

            if (DataFormat == null)
            {
                return(false);
            }

            Boolean ValueCorrect = (Value.Length == (DataFormat.DataSetSize * DataFormat.DataSetCount));

            if (!ValueCorrect)
            {
                FNumbersFromValueData.Clear();
                return(false);
            }

            // If the Data Format has a value fill the NumbersFromValueData array with all received numbers
            if (DataFormat.DataSetCount > 0)
            {
                List <Byte> DataList = Value.ToList();
                FNumbersFromValueData.Clear();
                for (Int32 i = 0; i < DataList.Count; i += DataFormat.DataSetSize)
                {
                    FNumbersFromValueData.Add(DataList.GetRange(i, DataFormat.DataSetSize).ToArray());
                }
            }

            return(ValueCorrect);
        }
예제 #2
0
        /// <summary> Compares two Data Formats </summary>
        /// <param name="obj"> The other object to be compared with current. </param>
        /// <returns> <c>True</c> if this data format is equal to <c>obj</c>.
        ///   <c>False</c> otherwise. </returns>
        public override Boolean Equals(Object obj)
        {
            if (ReferenceEquals(obj, null))
            {
                return(false);
            }
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }

            wclWeDoDataFormat Format = (wclWeDoDataFormat)obj;

            return(FDataSetCount == Format.DataSetCount && FDataSetSize == Format.DataSetSize &&
                   FMode == Format.Mode && FUnit == Format.Unit);
        }
예제 #3
0
 /// <summary> Removes a valid data format. </summary>
 /// <param name="Format"> The data format to remove. </param>
 /// <seealso cref="wclWeDoDataFormat"/>
 protected void RemoveValidDataFormat(wclWeDoDataFormat Format)
 {
     FValidDataFormats.Remove(Format);
 }
예제 #4
0
 /// <summary> Adds a new valid data format. </summary>
 /// <param name="Format"> The data format to add. </param>
 /// <seealso cref="wclWeDoDataFormat"/>
 protected void AddValidDataFormat(wclWeDoDataFormat Format)
 {
     FValidDataFormats.Add(Format);
 }