Exemple #1
0
        public override SampleBuffer Allocate(IDecodable channel, long length, bool noConversion)
        {
            var decoder           = channel.DecoderSpec;
            var raw               = decoder.RawDecoderSpec;
            var conv              = decoder.ValueConversionSpec.ConversionType;
            NumericBufferBase ret = null;

            if (raw.IsSameEndianess &&
                conv == ValueConversionType.Linear ||
                conv == ValueConversionType.Identity)
            {
                ret = new LinearBuffer(channel, length);
            }

            else if (raw.IsSameEndianess && conv == ValueConversionType.Rational3)
            {
                ret = new Rat3Buffer(channel, length);
            }

            //TODO: add endianess swapped buffer when we have access to validation data.

            if (noConversion)
            {
                ret.DisableConversion();
            }

            if (ret == null)
            {
                Check.PleaseSendMeYourFile();
            }

            return(ret);
        }
Exemple #2
0
        protected NumericBufferBase(IDecodable decodable) : base(decodable)
        {
            var decoder = decodable.DecoderSpec;

            Raw    = decoder.RawDecoderSpec;
            Val    = decoder.ValueConversionSpec;
            Stride = (int)Raw.Stride;
        }
        private void _checkTrameType()
        {
            byte[] buffer = new byte[3];
            while (this._socket.Available < 3)
            {
                Thread.Sleep(10);
            }

            this._socket.Receive(buffer, 0, 3, SocketFlags.Partial);
            this.TrameHeader = Encoding.ASCII.GetString(buffer, 0, 3);

            switch (this.TrameHeader)
            {
            case "BYE":
                this._decoder = new BYEDecoder();
                break;

            case "END":
                this._decoder = new ENDDecoder();
                break;

            case "HME":
                this._decoder = new HMEDecoder();
                break;

            case "HUM":
                this._decoder = new HUMDecoder();
                break;

            case "MAP":
                this._decoder = new MAPDecoder();
                break;

            case "SET":
                this._decoder = new SETDecoder();
                break;

            case "UPD":
                this._decoder = new UPDDecoder();
                break;

            default:
                break;
            }
        }
        public override SampleBuffer Allocate(IDecodable channel, long length, bool noConversion)
        {
            var spec = channel.DecoderSpec;

            if (spec.IsNumeric)
            {
                return(_numericBufferFactory.Allocate(channel, length, noConversion));
            }

            if (spec.RawDecoderSpec.DataType == DataType.ByteArray)
            {
                return(new ByteBuffer(channel, length));
            }

            if (spec.RawDecoderSpec.DataType == DataType.AnsiString)
            {
                return(new StringBuffer(channel, length));
            }


            return(null);
        }
Exemple #5
0
 protected SampleBuffer(IDecodable decodable)
 {
     Decodable = decodable;
 }
Exemple #6
0
 public static string GetDisplayValue(this IDecodable decodable, double value) =>
 decodable.DecoderSpec.DisplayConversionSpec.GetDisplayValue(value);
Exemple #7
0
 public Rat3Buffer(IDecodable decodable, long length) : base(decodable, length)
 {
     _conv  = (ValueConversionSpec.Rational3)Val;
     _mask  = Raw.Mask;
     _shift = Raw.Shift;
 }
Exemple #8
0
 protected NumericBufferBaseNative(IDecodable decodable, long length) : base(decodable)
 {
     Length    = length;
     HeapArray = Marshal.AllocHGlobal((IntPtr)(length * Unsafe.SizeOf <double>()));
     Storage   = (double *)HeapArray.ToPointer();
 }
Exemple #9
0
 protected NumericBufferBaseManaged(IDecodable decodable, long length) : base(decodable)
 {
     Storage = new double[length];
 }
Exemple #10
0
 public LinearBuffer(IDecodable decodable, long length) : base(decodable, length)
 {
     _conv = Val as ValueConversionSpec.Linear ?? ValueConversionSpec.LinearIdentity;
 }
 public abstract SampleBuffer Allocate(IDecodable channel, long length, bool noConversion);
 public ByteBuffer(IDecodable decodable, long length) : base(decodable)
 {
     _storage = new byte[decodable.DecoderSpec.RawDecoderSpec.TotalByteLength * length];
 }
 public StringBuffer(IDecodable decodable, long length) : base(decodable)
 {
     _raw     = decodable.DecoderSpec.RawDecoderSpec;
     _storage = new string[length];
 }