예제 #1
0
        public override void Deserialize(IDecoder inStream)
        {
            base.Deserialize(inStream);

            IsMore = inStream.ReadBoolFromInt();
            Value = inStream.ReadString();
        }
예제 #2
0
        public StreamedAudioBuffer(IDecoder decoder)
        {
            if (decoder == null)
                throw new ArgumentNullException("decoder");

            Decoder = decoder;
        }
예제 #3
0
        public override void Deserialize(IDecoder inStream)
        {
            base.Deserialize(inStream);

            ConId = inStream.ReadInt();
            Exchange = inStream.ReadString();
        }
예제 #4
0
 public Codec(ICodecFactory cf, Analyzer a)
 {
     decoder = cf.GetDecoder ();
     encoder = cf.GetEncoder ();
     analyzer = a;
     analyzer.BindListDelegate (this.GetDataFromAnalyzer);
 }
 public void TestSetup()
 {
     const int Seed = 13;
     this.Stream = new MemoryStream();
     this.Encoder = this.CreateEncoder(this.Stream);
     this.Decoder = this.CreateDecoder(this.Stream);
     this.random = new Random(Seed);
 }
예제 #6
0
        public override void Deserialize(IDecoder inStream)
        {
            base.Deserialize(inStream);

            SecType = inStream.ReadString();
            Exchange = inStream.ReadString();
            Symbol = inStream.ReadString();
        }
예제 #7
0
        public ExecutionUnitTests()
        {
            _defaultStack = new Mock<Stack>(10).Object;

            var stopDecoderMock = new Mock<IDecoder>();
            stopDecoderMock.Setup(m => m.Decode(It.IsAny<UInt64>()))
                .Returns(new Instruction { Type = InstructionType.Stop });
            _stopDecoder = stopDecoderMock.Object;
        }
예제 #8
0
		public ClassKey(IDecoder dec) {
			PackageName = dec.ReadStr8() ;
			ClassName = dec.ReadStr8() ;
			Hash[0] = dec.ReadUint32() ;
			Hash[1] = dec.ReadUint32() ;	
			Hash[2] = dec.ReadUint32() ;
			Hash[3] = dec.ReadUint32() ;
			
		}
예제 #9
0
		public SchemaArgument(IDecoder dec, bool methodArg)
		{
			Dictionary<string, Object> map = dec.ReadMap() ;	
			base.PopulateData(map) ;					
				
			if (map.ContainsKey("dir")) {
				Direction = (string) map["dir"] ;			
			}	
		}
예제 #10
0
		public SchemaStatistic(IDecoder dec)
		{
			Dictionary<string, Object> map = dec.ReadMap() ;							
			Name = (string)  map["name"] ;
			Type = (short) short.Parse(""+map["type"]) ;
				
			if (map.ContainsKey("unit")) {
				Unit = (string) map["unit"] ;			
			}
			if (map.ContainsKey("description")) {			
				Description = (string) map["description"] ;			
			}			
		}
예제 #11
0
 /// <summary>
 /// 使用默认配置参数的构造函数
 /// </summary>
 /// <param name="handler"></param>
 public SocketServer(IServerHandler handler,IEncoder encoder, IDecoder decoder)
     : base(DefaultConfigure.SocketBufferSize, DefaultConfigure.MessageBufferSize)
 {
     if (handler == null) throw new ArgumentNullException("handler");
     if (encoder == null) throw new ArgumentNullException("encoder");
     if (decoder == null) throw new ArgumentNullException("decoder");
     this._handler = handler;
     this._protocol = new DefaultBinaryProtocol();
     this._encoder = encoder;
     this._decoder = decoder;
     this._maxMessageSize = DefaultConfigure.MaxMessageSize;
     this._maxConnections = DefaultConfigure.MaxConnections;
 }
예제 #12
0
		public QMFEvent(Session session, IDecoder dec)
		{
			Session = session ;
			ClassKey = new ClassKey(dec) ;
			Timestamp = dec.ReadInt64() ;
			Severity = (EventSeverity) dec.ReadUint8() ;
			SchemaClass sClass = Session.GetSchema(ClassKey) ;
			Arguments = new Dictionary<string, object>() ;
			
			if (sClass != null) {
				foreach (SchemaArgument arg in sClass.Arguments) {
					Arguments[arg.Name] = Session.DecodeValue(dec, arg.Type) ;	
				}
			}	
		}
예제 #13
0
        //static int MAX_FILTER_WIDTH = 20;

        public static Image Compute(string file, IDecoder decoder)
        {
            int numBands = 72;

            Image image = new Image(numBands);
            ImageBuilder image_builder = new ImageBuilder(image);
            Spectrum chroma = new Spectrum(numBands, MIN_FREQ, MAX_FREQ, FRAME_SIZE, SAMPLE_RATE, image_builder);
            FFT fft = new FFT(FRAME_SIZE, OVERLAP, chroma);
            AudioProcessor processor = new AudioProcessor(SAMPLE_RATE, fft);

            processor.Reset(decoder.SampleRate, decoder.Channels);
            decoder.Decode(processor, 120);
            processor.Flush();

            //ExportImage(image, name, 0.5);

            return image;
        }
예제 #14
0
        /// <summary>
        /// Computes the chromagram of an audio file.
        /// </summary>
        /// <param name="decoder">The <see cref="IDecoder"/> instance.</param>
        /// <returns>Chroma image.</returns>
        public static Image ComputeChromagram(IDecoder decoder)
        {
            var image = new Image(12);
            var image_builder = new ImageBuilder(image);

            var chroma_normalizer = new ChromaNormalizer(image_builder);
            var chroma_filter = new ChromaFilter(ChromaFilterCoefficients, chroma_normalizer);
            var chroma = new Chroma(MIN_FREQ, MAX_FREQ, FRAME_SIZE, SAMPLE_RATE, chroma_filter);

            var fft = new FFT(FRAME_SIZE, OVERLAP, chroma, new LomontFFTService());
            var processor = new AudioProcessor(SAMPLE_RATE, fft);

            processor.Reset(decoder.SampleRate, decoder.Channels);
            decoder.Decode(processor, 120);
            processor.Flush();

            return image;
        }
예제 #15
0
        /// <summary>
        /// Computes the spectogram of an audio file.
        /// </summary>
        /// <param name="decoder">The <see cref="IDecoder"/> instance.</param>
        /// <returns>Chroma image.</returns>
        public static Image ComputeSpectrogram(IDecoder decoder)
        {
            int numBands = 72;

            var image = new Image(numBands);
            var image_builder = new ImageBuilder(image);

            var chroma = new Spectrum(numBands, MIN_FREQ, MAX_FREQ, FRAME_SIZE, SAMPLE_RATE, image_builder);

            var fft = new FFT(FRAME_SIZE, OVERLAP, chroma, new LomontFFTService());
            var processor = new AudioProcessor(SAMPLE_RATE, fft);

            processor.Reset(decoder.SampleRate, decoder.Channels);
            decoder.Decode(processor, 120);
            processor.Flush();

            return image;
        }
예제 #16
0
        public static Image Compute(string file, IDecoder decoder)
        {
            Image image = new Image(12);
            ImageBuilder image_builder = new ImageBuilder(image);
            ChromaNormalizer chroma_normalizer = new ChromaNormalizer(image_builder);
            ChromaFilter chroma_filter = new ChromaFilter(ChromaFilterCoefficients, chroma_normalizer);
            //Chroma chroma = new Chroma(MIN_FREQ, MAX_FREQ, FRAME_SIZE, SAMPLE_RATE, &chroma_normalizer);
            Chroma chroma = new Chroma(MIN_FREQ, MAX_FREQ, FRAME_SIZE, SAMPLE_RATE, chroma_filter);
            FFT fft = new FFT(FRAME_SIZE, OVERLAP, chroma);
            AudioProcessor processor = new AudioProcessor(SAMPLE_RATE, fft);

            processor.Reset(decoder.SampleRate, decoder.Channels);
            decoder.Decode(processor, 120);
            processor.Flush();

            //ExportImage(image, name);

            return image;
        }
예제 #17
0
		public SchemaProperty(IDecoder dec)
		{
			Dictionary<string, Object> map = dec.ReadMap() ;
			base.PopulateData(map) ;
			Name = (string)  map["name"] ;
			
			if (map.ContainsKey("optional")) {
				//System.Console.WriteLine("optional") ;
				Optional = (int)map["optional"] != 0 ;		
			} 
			if (map.ContainsKey("index")) {
				//System.Console.WriteLine("index") ;			
				Index = (int)map["index"] != 0 ;		
			}
			if (map.ContainsKey("access")) {
				//System.Console.WriteLine("access") ;			
				Access = (int) map["access"] ;			
			}
		
		}
예제 #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Computer"/> class.
        /// </summary>
        /// <param name="stack">The stack.</param>
        /// <param name="encoder">The instruction encoder.</param>
        /// <param name="decoder">The instruction decoder.</param>
        public ExecutionUnit(IStack stack, IEncoder encoder, IDecoder decoder, IArithmeticLogicUnit alu)
        {
            _context = new ExecutionContext
            {
                Stack = stack,
                Encoder = encoder,
                Decoder = decoder,
                Alu = alu,
                Executing = true
            };

            _dispatcher = new Dictionary<InstructionType, Action<ExecutionContext, Instruction>>
            {
                { InstructionType.Mult, Multiply.GetAction() },
                { InstructionType.Call, Call.GetAction() },
                { InstructionType.Ret, Return.GetAction() },
                { InstructionType.Stop, Stop.GetAction() },
                { InstructionType.Print, Print.GetAction() },
                { InstructionType.Push, Push.GetAction() }
            };
        }
예제 #19
0
		public SchemaMethod(IDecoder dec)
		{
			Dictionary<string, Object> map = dec.ReadMap() ;
			Name = (string)  map["name"] ;
			ArgCount = (int) map["argCount"] ;
			if (map.ContainsKey("desc")) {
				Description = (string) map["desc"] ;
			}
			for (int x = 0 ; x < ArgCount ; x++) {
				SchemaArgument arg = new SchemaArgument(dec, true) ; 
				Arguments.Add(arg) ;
				if (arg.IsInput()) {
					InputArgCount += 1 ;
				}
				if (arg.IsOutput()) {
					OutputArgCount += 1 ;
				}			
				if (arg.IsBidirectional()) {
					BidirectionalArgCount += 1 ;
				}	
			}
		}
예제 #20
0
		public SchemaClass(int kind, ClassKey key, IDecoder dec, Session session)
		{
			log.Debug(String.Format("New schema class {0}", key)) ;
		    Kind = kind ;
		    Session = session ;
		    this.Key = key ;   
		    bool hasSupertype = false ;
		 
		 	if (kind == CLASS_KIND_TABLE) {
				int propCount = dec.ReadUint16() ;
				int statCount = dec.ReadUint16() ;
				int methodCount = dec.ReadUint16() ;
				
				if (hasSupertype) {		
			 		SuperType = new ClassKey(dec) ;
			 	}
				
				for(int x = 0 ; x < propCount ; x++) {
					Properties.Add(new SchemaProperty(dec)) ;
				}
				for(int x = 0 ; x < statCount ; x++) {
					Statistics.Add(new SchemaStatistic(dec)) ;
				}	
				for(int x = 0 ; x < methodCount ; x++) {
					Methods.Add(new SchemaMethod(dec)) ;
				}	
			}
			
			if (kind == CLASS_KIND_EVENT) {			
				int argCount = dec.ReadUint16() ;		
				if (hasSupertype) {
			 		SuperType = new ClassKey(dec) ;
			 	}				
				for(int x = 0 ; x < argCount ; x++) {
					Arguments.Add(new SchemaArgument(dec, false)) ;
				}	
			}
		}
예제 #21
0
        /// <summary>
        /// Sends the download request asynchronously.
        /// </summary>
        /// <typeparam name="TRequest">The type of the request.</typeparam>
        /// <typeparam name="TResponse">The type of the response.</typeparam>
        /// <typeparam name="TError">The type of the error.</typeparam>
        /// <param name="request">The request.</param>
        /// <param name="host">The server host to send the request to.</param>
        /// <param name="route">The route name.</param>
        /// <param name="auth">The auth type of the route.</param>
        /// <param name="requestEncoder">The request encoder.</param>
        /// <param name="resposneDecoder">The response decoder.</param>
        /// <param name="errorDecoder">The error decoder.</param>
        /// <returns>An asynchronous task for the response.</returns>
        /// <exception cref="ApiException{TError}">
        /// This exception is thrown when there is an error reported by the server.
        /// </exception>
        async Task <IDownloadResponse <TResponse> > ITransport.SendDownloadRequestAsync <TRequest, TResponse, TError>(
            TRequest request,
            string host,
            string route,
            string auth,
            IEncoder <TRequest> requestEncoder,
            IDecoder <TResponse> resposneDecoder,
            IDecoder <TError> errorDecoder)
        {
            var serializedArg = JsonWriter.Write(request, requestEncoder, true);
            var res           = await this.RequestJsonStringWithRetry(host, route, auth, RouteStyle.Download, serializedArg)
                                .ConfigureAwait(false);

            if (res.IsError)
            {
                throw StructuredException <TError> .Decode <ApiException <TError> >(
                          res.ObjectResult, errorDecoder, () => new ApiException <TError>(res.RequestId));
            }

            var response = JsonReader.Read(res.ObjectResult, resposneDecoder);

            return(new DownloadResponse <TResponse>(response, res.HttpResponse));
        }
예제 #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StreamReader{T}"/> class for static types.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="leaveOpen">If set to <c>true</c> leaves the input stream open.</param>
        /// <param name="settings">The settings.</param>
        /// <param name="codecFactory">The codec factory.</param>
        public StreamReader(Stream stream, bool leaveOpen, AvroSerializerSettings settings, CodecFactory codecFactory)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            if (codecFactory == null)
            {
                throw new ArgumentNullException("codecFactory");
            }

            this.stream     = stream;
            this.decoder    = new BinaryDecoder(stream, leaveOpen);
            this.header     = ObjectContainerHeader.Read(this.decoder);
            this.codec      = codecFactory.Create(this.header.CodecName);
            this.serializer = AvroSerializer.CreateDeserializerOnly <T>(this.header.Schema, settings);
        }
예제 #23
0
        internal void EncodeOggAudio(AudioFormat data, FormatData destination, IFormat format, Stream stream, ProgressIndicator progress)
        {
            IDecoder decoder = data.Decoder;

            RawkAudio.Encoder encoder = new RawkAudio.Encoder(stream, decoder.Channels, decoder.SampleRate);

            AudioFormat.ProcessOffset(decoder, encoder, data.InitialOffset);

            progress.NewTask(1);

            AudioFormat.Transcode(encoder, decoder, progress);
            progress.Progress();

            encoder.Dispose();
            destination.CloseStream(format, AudioName);

            decoder.Dispose();

            data.Save(destination.AddStream(format, FormatName));
            destination.CloseStream(format, FormatName);

            progress.EndTask();
        }
예제 #24
0
        /// <summary>
        /// Decode as json
        /// </summary>
        /// <param name="decoder"></param>
        private void DecodeJson(IDecoder decoder)
        {
            DataSetWriterId = decoder.ReadString(nameof(JsonDataSetMessageContentMask.DataSetWriterId));
            if (DataSetWriterId != null)
            {
                MessageContentMask |= (uint)JsonDataSetMessageContentMask.DataSetWriterId;
            }
            SequenceNumber = decoder.ReadUInt32(nameof(JsonDataSetMessageContentMask.SequenceNumber));
            if (SequenceNumber != 0)
            {
                MessageContentMask |= (uint)JsonDataSetMessageContentMask.SequenceNumber;
            }
            MetaDataVersion = decoder.ReadEncodeable(
                nameof(JsonDataSetMessageContentMask.MetaDataVersion), typeof(ConfigurationVersionDataType))
                              as ConfigurationVersionDataType;
            if (MetaDataVersion != null)
            {
                MessageContentMask |= (uint)JsonDataSetMessageContentMask.MetaDataVersion;
            }
            Timestamp = decoder.ReadDateTime(nameof(JsonDataSetMessageContentMask.Timestamp));
            if (Timestamp != null)
            {
                MessageContentMask |= (uint)JsonDataSetMessageContentMask.Timestamp;
            }
            Status = decoder.ReadStatusCode(nameof(JsonDataSetMessageContentMask.Status));
            if (Status != null)
            {
                MessageContentMask |= (uint)JsonDataSetMessageContentMask.Status;
            }
            var payload = (KeyDataValuePairCollection)decoder.ReadEncodeableArray(nameof(Payload), typeof(KeyDataValuePair));

            Payload = new DataSet();
            foreach (var tuple in payload)
            {
                Payload[tuple.Key] = new DataValue(tuple.Value);
            }
        }
예제 #25
0
        // *************************************************************************
        // Init Engine
        // *************************************************************************
        public void Init(RAMProgram program, IDecoder decoder, string InstructionSetName = DefaultInstructionSetName)
        {
            //string log_name = "runtime_log.txt";
            //// Clear Old Log
            //if (File.Exists(log_name))
            //{
            //    File.Delete(log_name);
            //}
            //File.Create(log_name).Close();  // must close the file or the handle will stay open and be locked

            //// Init Logger
            //Log.Logger = new LoggerConfiguration()
            //    .WriteTo.File(log_name)
            //   // .WriteTo.Console()
            //    .CreateLogger();

            //Serilog.Debugging.SelfLog.Enable(msg => Debug.WriteLine(msg));
            //Serilog.Debugging.SelfLog.Enable(Console.Error);

            //Log.Information("SAP1Emu: Begin Engine Initialization");

            // Get Instruction Set
            //Log.Information($"SAP1Emu: Using Instruction Set: \"{InstructionSetName}\"");
            InstructionSet = OpCodeLoader.GetSet(InstructionSetName);
            _decoder       = decoder;

            //_decoder = new InstructionDecoder();

            // Init RAM
            if (program == null)
            {
                this.Program = new RAMProgram(new List <string>());
            }
            this.Program = program;

            //Log.Information("SAP1Emu: Finished Engine Initialization");
        }
예제 #26
0
        /// <inheritdoc/>
        private void DecodeJson(IDecoder decoder)
        {
            MessageContentMask = 0;
            MessageId          = decoder.ReadString(nameof(MessageId));
            if (MessageId != null)
            {
                MessageContentMask |= (uint)JsonNetworkMessageContentMask.NetworkMessageHeader;
            }
            MessageType = decoder.ReadString(nameof(MessageType));
            if (MessageType != "ua-data")
            {
                // todo throw incorrect message format
            }
            PublisherId = decoder.ReadString(nameof(PublisherId));
            if (PublisherId != null)
            {
                MessageContentMask |= (uint)JsonNetworkMessageContentMask.PublisherId;
            }
            DataSetClassId = decoder.ReadString(nameof(DataSetClassId));
            if (DataSetClassId != null)
            {
                MessageContentMask |= (uint)JsonNetworkMessageContentMask.DataSetClassId;
            }
            DataSetWriterGroup = decoder.ReadString(nameof(DataSetWriterGroup));

            var messagesArray = decoder.ReadEncodeableArray("Messages", typeof(DataSetMessage));

            Messages = new List <DataSetMessage>();
            foreach (var value in messagesArray)
            {
                Messages.Add(value as DataSetMessage);
            }
            if (Messages.Count == 1)
            {
                MessageContentMask |= (uint)JsonNetworkMessageContentMask.SingleDataSetMessage;
            }
        }
예제 #27
0
파일: Audio.cs 프로젝트: zurgeg/riivolution
        public static void Transcode(IEncoder encoder, IDecoder decoder, long samples, ProgressIndicator progress)
        {
            long downmix = decoder.Channels == encoder.Channels ? 0 : encoder.Channels;

            progress.NewTask("Transcoding Audio", samples);
            while (samples > 0)
            {
                int read = decoder.Read((int)Math.Min(samples, RawkAudio.Decoder.BufferSize));
                if (read <= 0)
                {
                    break;
                }

                if (downmix == 1)
                {
                    decoder.AudioBuffer.DownmixTo(decoder.AudioBuffer, new ushort[] { 0xFFFF }, read);
                }

                encoder.Write(decoder.AudioBuffer, read);
                samples -= read;
                progress.Progress(read);
            }
            progress.EndTask();
        }
예제 #28
0
        public virtual void testDecodeChoice()
        {
            IDecoder decoder = newDecoder();

            System.IO.MemoryStream stream = new System.IO.MemoryStream((coderTestUtils.createDataChoicePlainBytes()));
            Data choice = new Data();
            Data val    = decoder.decode <Data>(stream);

            Assert.IsNotNull(val);
            choice.selectPlain(new TestPRN("bbbbbb"));
            checkData(val, choice);

            stream = new System.IO.MemoryStream((coderTestUtils.createDataChoiceSimpleTypeBytes()));
            val    = decoder.decode <Data>(stream);
            Assert.IsNotNull(val);
            choice.selectSimpleType("aaaaaaa");
            checkData(val, choice);

            stream = new System.IO.MemoryStream((coderTestUtils.createDataChoiceTestOCTBytes()));
            val    = decoder.decode <Data>(stream);
            Assert.IsNotNull(val);
            choice.selectBinary(new TestOCT(new byte[] { 0xFF }));
            checkData(val, choice);

            stream = new System.IO.MemoryStream((coderTestUtils.createDataChoiceBooleanBytes()));
            val    = decoder.decode <Data>(stream);
            Assert.IsNotNull(val);
            choice.selectBooleanType(true);
            checkData(val, choice);

            stream = new System.IO.MemoryStream((coderTestUtils.createDataChoiceIntBndBytes()));
            val    = decoder.decode <Data>(stream);
            Assert.IsNotNull(val);
            choice.selectIntBndType(7);
            checkData(val, choice);
        }
 public override void Read(IDecoder dec)
 {
     packing_flags = (int)dec.ReadUint16();
     if ((packing_flags & 256) != 0)
     {
         _Queue = dec.ReadStr8();
     }
     if ((packing_flags & 512) != 0)
     {
         _AlternateExchange = dec.ReadStr8();
     }
     if ((packing_flags & 8192) != 0)
     {
         _Arguments = dec.ReadMap();
     }
     if ((packing_flags & 16384) != 0)
     {
         _MessageCount = dec.ReadUint32();
     }
     if ((packing_flags & 32768) != 0)
     {
         _SubscriberCount = dec.ReadUint32();
     }
 }
예제 #30
0
        public virtual void testDecodeOID()
        {
            IDecoder decoder = newDecoder();

            Assert.NotNull(decoder);

            System.IO.MemoryStream stream =
                new System.IO.MemoryStream(coderTestUtils.createTestOID1Bytes());
            ObjectIdentifier oid1 = decoder.decode <ObjectIdentifier>(stream);

            System.Console.Out.WriteLine("Decoded by " + decoder.ToString() + " (OID " + oid1.Value + ") : " + ByteTools.byteArrayToHexString(stream.ToArray()));
            Assert.Equals(oid1.Value, coderTestUtils.createTestOID1().Value.Value);

            stream = new System.IO.MemoryStream(coderTestUtils.createTestOID1Bytes());
            TestOID oid1_boxed = decoder.decode <TestOID>(stream);

            Assert.Equals(oid1_boxed.Value.Value, coderTestUtils.createTestOID1().Value.Value);

            stream = new System.IO.MemoryStream(coderTestUtils.createTestOID2Bytes());
            ObjectIdentifier oid2 = decoder.decode <ObjectIdentifier>(stream);

            System.Console.Out.WriteLine("Decoded by " + decoder.ToString() + " (OID " + oid2.Value + ") : " + ByteTools.byteArrayToHexString(stream.ToArray()));
            Assert.Equals(oid2.Value, coderTestUtils.createTestOID2().Value.Value);

            stream = new System.IO.MemoryStream(coderTestUtils.createTestOID3Bytes());
            ObjectIdentifier oid3 = decoder.decode <ObjectIdentifier>(stream);

            System.Console.Out.WriteLine("Decoded by " + decoder.ToString() + " (OID " + oid3.Value + ") : " + ByteTools.byteArrayToHexString(stream.ToArray()));
            Assert.Equals(oid3.Value, coderTestUtils.createTestOID3().Value.Value);

            stream = new System.IO.MemoryStream(coderTestUtils.createTestOID4Bytes());
            ObjectIdentifier oid4 = decoder.decode <ObjectIdentifier>(stream);

            System.Console.Out.WriteLine("Decoded by " + decoder.ToString() + " (OID " + oid4.Value + ") : " + ByteTools.byteArrayToHexString(stream.ToArray()));
            Assert.Equals(oid4.Value, coderTestUtils.createTestOID4().Value.Value);
        }
예제 #31
0
        public void Preload(IEnumerable <int> indices)
        {
            requestedKeys.Clear();
            var toDelete = new List <string>(frames.Keys);

            foreach (var id in indices)
            {
                var    file = files[VVVV.Utils.VMath.VMath.Zmod(id, FrameCount)];
                string key  = file.FullName;
                requestedKeys.Add(key);

                if (frames.ContainsKey(key))
                {
                    toDelete.Remove(key);
                }
                else
                {
                    IDecoder decoder = Decoder.SelectFromFile(file);
                    frames[key]            = new Frame(key, decoder, device, FMemoryPool, FLogger);
                    frames[key].BufferSize = BufferSize;

                    if (description.Width == 0)
                    {
                        frames[key].LoadingCompleted = FrameLoaded;
                    }

                    frames[key].LoadAsync();
                }
            }

            foreach (var d in toDelete)
            {
                frames[d].Dispose();
                frames.Remove(d);
            }
        }
예제 #32
0
        public AudioBuffer(IDecoder decoder)
        {
            if (decoder == null)
                throw new ArgumentNullException("decoder");

            Buffer = AL.GenBuffer();
            Util.CheckOpenAlErrors();

            var data = new float[decoder.TotalSamples];
            var castData = new short[decoder.TotalSamples];

            int read = 0;
            while (read < data.Length)
            {
                read += decoder.ReadSamples(data, read, data.Length - read);
            }

            Util.CastBuffer(data, castData, data.Length);

            AL.BufferData(Buffer, Util.ToOpenAL(decoder.Format), castData, castData.Length * sizeof(short), decoder.Frequency);
            Util.CheckOpenAlErrors();

            decoder.Dispose();
        }
예제 #33
0
 public void Decompress(IDecoder input)
 {
     this.input         = input ?? throw new ArgumentNullException();
     endOfStreamReached = false;
     w = ReadNextSegment(out _);
     if (!endOfStreamReached)
     {
         output.Append(w);
         AddToDictionary(w);
         for (var entry = ReadNextSegment(out var isCharEntry);
              !endOfStreamReached;
              entry = ReadNextSegment(out isCharEntry))
         {
             if (isCharEntry)
             {
                 AddToDictionary(entry);
             }
             output.Append(entry);
             AddToDictionary(w + entry[0]);
             w = entry;
         }
     }
     this.input = null;
 }
예제 #34
0
 public HttpResponse(IDecoder decoder)
 {
     _decoder = decoder;
 }
예제 #35
0
		public void HandleContentIndicator(Broker broker, IDecoder decoder, long sequence, bool hasProperties, bool hasStatistics) {
		
			ClassKey key = new ClassKey(decoder) ;
			SchemaClass sClass = null ;;
			lock (LockObject) {
				sClass = GetSchema(key, false) ;
			}
			if (sClass != null) {
			    QMFObject obj = this.CreateQMFObject(sClass, decoder, hasProperties, hasStatistics, true) ;
				
				if (key.PackageName.Equals("org.apache.qpid.broker") && key.ClassName.Equals("agent") && hasProperties) {
					broker.UpdateAgent(obj) ;
				}
				
				lock (LockObject) {
					if (SyncSequenceList.Contains(sequence)) {
						if (!obj.IsDeleted() && this.SelectMatch(obj)) {
							GetResult.Add(obj) ;
						}	
					}
				}
				
				if (Console != null) {
					if (hasProperties) {
						Console.ObjectProperties(broker, obj) ;
					}
					if (hasStatistics) {
						Console.ObjectStatistics(broker, obj) ;	
					}
				}
			}
		}
예제 #36
0
 public void Decode(IDecoder decoder)
 {
     decoder.PushNamespace(ApplicationUri);
     Foo = decoder.ReadString(FieldName);
     decoder.PopNamespace();
 }
예제 #37
0
 /// <summary cref="IEncodeable.Decode" />
 public virtual void Decode(IDecoder decoder)
 {
 }
예제 #38
0
            public void AddElements(object arrayObj, int elements, int index, ReadItem itemReader, IDecoder decoder,
                                    bool reuse)
            {
                var array = (object[])arrayObj;

                for (int i = index; i < index + elements; i++)
                {
                    array[i] = reuse ? itemReader(array[i], decoder) : itemReader(null, decoder);
                }
            }
예제 #39
0
 public LBBTEntriesFromBTPageExtractor(IDecoder <LBBTEntry> entryDecoder)
 {
     this.entryDecoder = entryDecoder;
 }
예제 #40
0
        /// <summary>
        /// Read and decode a node attribute
        /// </summary>
        /// <param name="decoder"></param>
        /// <param name="attributeId"></param>
        public object Decode(IDecoder decoder, uint attributeId)
        {
            decoder.PushNamespace(Namespaces.OpcUa);
            try {
                var field = GetBrowseName(attributeId);
                switch (attributeId)
                {
                case Attributes.DisplayName:
                case Attributes.InverseName:
                case Attributes.Description:
                    return(decoder.ReadLocalizedText(field));

                case Attributes.WriteMask:
                case Attributes.UserWriteMask:
                case Attributes.AccessLevelEx:
                    var uint32Value = decoder.ReadUInt32(field);
                    if (uint32Value != 0)
                    {
                        return(0);
                    }
                    break;

                case Attributes.NodeId:
                case Attributes.DataType:
                    var nodeIdValue = decoder.ReadNodeId(field);
                    if (nodeIdValue != null)
                    {
                        return(nodeIdValue);
                    }
                    break;

                case Attributes.NodeClass:
                    return(decoder.ReadEnumerated <NodeClass>(field));

                case Attributes.ValueRank:
                    var int32Value = decoder.ReadInt32(field);
                    if (int32Value != 0)
                    {
                        return(int32Value);
                    }
                    break;

                case Attributes.BrowseName:
                    var qualifiedName = decoder.ReadQualifiedName(field);
                    if (qualifiedName != null)
                    {
                        return(qualifiedName);
                    }
                    break;

                case Attributes.Historizing:
                case Attributes.Executable:
                case Attributes.UserExecutable:
                case Attributes.IsAbstract:
                case Attributes.Symmetric:
                case Attributes.ContainsNoLoops:
                    var booleanValue = decoder.ReadBoolean(field);
                    if (booleanValue != false)
                    {
                        return(booleanValue);
                    }
                    break;

                case Attributes.EventNotifier:
                case Attributes.AccessLevel:
                case Attributes.UserAccessLevel:
                    var byteValue = decoder.ReadByte(field);
                    if (byteValue != 0)
                    {
                        return(byteValue);
                    }
                    break;

                case Attributes.MinimumSamplingInterval:
                    var doubleValue = decoder.ReadDouble(field);
                    if ((ulong)doubleValue != 0)
                    {
                        return(doubleValue);
                    }
                    break;

                case Attributes.ArrayDimensions:
                    var uint32array = decoder.ReadUInt32Array(field);
                    if (uint32array != null && uint32array.Count > 0)
                    {
                        return(uint32array);
                    }
                    break;

                case Attributes.AccessRestrictions:
                    var uint16Value = decoder.ReadUInt16(field);
                    if (uint16Value != 0)
                    {
                        return(uint16Value);
                    }
                    break;

                case Attributes.RolePermissions:
                case Attributes.UserRolePermissions:
                    var extensionObjects = decoder.ReadExtensionObjectArray(field);
                    if (extensionObjects != null && extensionObjects.Count > 0)
                    {
                        return(extensionObjects);
                    }
                    break;

                case Attributes.DataTypeDefinition:
                    var extensionObject = decoder.ReadExtensionObject(field);
                    if (extensionObject != null)
                    {
                        return(extensionObject);
                    }
                    break;

                case Attributes.Value:
                default:
                    var variant = decoder.ReadVariant(field);
                    if (variant != Variant.Null)
                    {
                        return(new DataValue(variant));
                    }
                    break;
                }
                return(null);
            }
            finally {
                decoder.PopNamespace();
            }
        }
예제 #41
0
파일: HttpClient.cs 프로젝트: Vittel/Trakkr
        public HttpClient(IEncoderDecoderConfiguration encoderDecoderConfiguration)
        {
            _encoder = encoderDecoderConfiguration.GetEncoder();
            _decoder = encoderDecoderConfiguration.GetDecoder();
            _decoder.ShouldRemoveAtSign = ShouldRemoveAtSign;
            _uriComposer = new UriComposer();

            Request = new HttpRequest(_encoder);
        }
예제 #42
0
 public void PlayMusic(string filename)
 {
     StopMusic ();
     Stream = File.OpenRead (filename);
     MusicDecoder = DecoderFactory.GetDecoderFromStream (Stream);
     MusicStreamer = new StreamingAudio (Device, MusicDecoder.Format, MusicDecoder.SampleRate);
     MusicStreamer.BufferNeeded += (instance, buffer) => MusicDecoder.Read (buffer.Length, buffer);
     MusicStreamer.PlaybackFinished += (sender, e) => {
         if (loopMusic)
             PlayMusic (filename);
         else {
             MusicStreamer.Dispose ();
             MusicDecoder.Dispose ();
             MusicStreamer = null;
         }
     };
     MusicStreamer.Play ();
 }
예제 #43
0
		public ObjectID(IDecoder dec)
		{
			first = (long)dec.ReadUint64() ;
			second = (long)dec.ReadUint64() ;			
		}
예제 #44
0
	    protected QMFObject CreateQMFObject(SchemaClass schema, IDecoder dec, bool hasProperties, bool hasStats , bool isManaged) {
	    	Type realClass = typeof(QMFObject) ;	    	
	    	if (Console != null) {
	    		realClass = Console.TypeMapping(schema.Key) ;    		
	    	}
	    	Type[] types = new Type[] {typeof(Session), typeof(SchemaClass), typeof(IDecoder), typeof(bool), typeof(bool),typeof(bool)} ;
	    	object[] args = new object[] {this, schema, dec, hasProperties, hasStats, isManaged} ;
	    	ConstructorInfo ci = realClass.GetConstructor(types);	    
	    	return (QMFObject) ci.Invoke(args) ;
	    }		    		 																		 																
예제 #45
0
		public object DecodeValue(IDecoder dec, short type) {
		
		 	switch (type) {
		 		case 1: return dec.ReadUint8() ;        // U8
		 		case 2: return dec.ReadUint16() ;       // U16     
		 		case 3: return dec.ReadUint32() ;       // U32
		 		case 4: return dec.ReadUint64() ;       // U64 
		 		case 6: return dec.ReadStr8() ;         // SSTR
		 		case 7: return dec.ReadStr16() ;        // LSTR
		 		case 8: return dec.ReadDatetime() ;	    // ABSTIME
		 		case 9: return dec.ReadUint32() ;       // DELTATIME
		 		case 10: return new ObjectID(dec) ;		// ref
		 		case 11: return dec.ReadUint8() != 0 ;  // bool
		 		case 12: return dec.ReadFloat() ;       // float		
		 		case 13: return dec.ReadDouble() ;      // double		 
		 		case 14: return dec.ReadUuid() ;	    // UUID			
		 		case 15: return dec.ReadMap() ;             // Ftable
		 		case 16: return dec.ReadInt8() ;        // int8
		 		case 17: return dec.ReadInt16() ;       // int16    
		 		case 18: return dec.ReadInt32() ;       // int32
		 		case 19: return dec.ReadInt64() ;       // int64 		 			
		 		case 20:                                // Object
		 			// Peek into the inner type code, make sure 
		 			// it is actually an object
		 			object returnValue = null ;
		 			short innerTypeCode = dec.ReadUint8() ;
		 			if (innerTypeCode != 20) {
		 				returnValue = this.DecodeValue(dec, innerTypeCode) ;
		 			}
		 			else {
		 				ClassKey classKey = new ClassKey(dec) ;
		 				lock(LockObject) {
		 					SchemaClass sClass = GetSchema(classKey) ;
		 					if (sClass != null) {
		 						returnValue = this.CreateQMFObject(sClass, dec, true, true, false) ;
		 					}
		 				}
		 			}
		 			return returnValue;
                case 21:                                 // List
		 	        {
		 	            MSDecoder lDec = new MSDecoder();
		 	            lDec.Init(new MemoryStream(dec.ReadVbin32()));
		 	            long count = lDec.ReadUint32();
		 	            List<object> newList = new List<object>();
		 	            while (count > 0)
		 	            {
		 	                short innerType = lDec.ReadUint8();
		 	                newList.Add(this.DecodeValue(lDec, innerType));
		 	                count -= 1;
		 	            }
		 	            return newList;
		 	        }
                case 22:							    // Array
		 	        {
		 	            MSDecoder aDec = new MSDecoder();
		 	            aDec.Init(new MemoryStream(dec.ReadVbin32()));
		 	            long cnt = aDec.ReadUint32();
		 	            short innerType = aDec.ReadUint8();
		 	            List<object> aList = new List<object>();
		 	            while (cnt > 0)
		 	            {
		 	                aList.Add(this.DecodeValue(aDec, innerType));
		 	                cnt -= 1;
		 	            }
		 	            return aList;
		 	        }
		 	    default: 
		 			throw new Exception(String.Format("Invalid Type Code: {0}", type)) ;		
		 	}	
		 }		
예제 #46
0
        protected override object DeserializeSafe(IDecoder decoder)
        {
            int index = decoder.DecodeInt();

            return(this.Schema.Schemas[index].Serializer.Deserialize(decoder));
        }
예제 #47
0
        protected override void SkipSafe(IDecoder decoder)
        {
            int index = decoder.DecodeInt();

            this.Schema.Schemas[index].Serializer.Skip(decoder);
        }
예제 #48
0
        public override void Deserialize(IDecoder inStream)
        {
            base.Deserialize(inStream);

            TriggerMethod = (TriggerMethod)inStream.ReadInt();
        }
예제 #49
0
 // This is terminal output (like from report escape sequences - should be shunted back into the input buffer)
 private void Vt100_Output(IDecoder _decoder, byte[] _output)
 {
     keyboardStream.Inject(_output);
 }
예제 #50
0
 /// <summary>
 /// Decode from given json using given decoder.
 /// </summary>
 /// <typeparam name="TException">The type of the exception.</typeparam>
 /// <param name="json">The json.</param>
 /// <param name="errorDecoder">The error json.</param>
 /// <param name="exceptionFunc">The function to create exception.</param>
 /// <returns>The structured exception.</returns>
 internal static TException Decode <TException>(string json, IDecoder <TError> errorDecoder, Func <TException> exceptionFunc)
     where TException : StructuredException <TError>
 {
     return(JsonReader.Read(json, new StructuredExceptionDecoder <TException>(errorDecoder, exceptionFunc)));
 }
 public void Setup()
 {
     FakeTransponderReceiver = Substitute.For <ITransponderReceiver>();
     Uut = new I4SWTMandatoryExercise2.Decoder(FakeTransponderReceiver);
 }
예제 #52
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StructuredExceptionDecoder{TException}"/> class.
 /// </summary>
 /// <param name="errorDecoder">The error decoder.</param>
 /// <param name="execptionFunc">The function which creates the exception.</param>
 public StructuredExceptionDecoder(IDecoder <TError> errorDecoder, Func <TException> execptionFunc)
 {
     this.errorDecoder  = errorDecoder;
     this.execptionFunc = execptionFunc;
 }
예제 #53
0
        /// <inheritdoc/>
        public void Decode(IDecoder decoder)
        {
            MessageContentMask = decoder.ReadUInt32("ContentMask");
            if ((MessageContentMask & (uint)MonitoredItemMessageContentMask.NodeId) != 0)
            {
                NodeId = decoder.ReadExpandedNodeId(nameof(MonitoredItemMessageContentMask.NodeId));
            }
            Value = new DataValue();

            // todo check why Value is not encoded as DataValue type
            if ((MessageContentMask & (uint)MonitoredItemMessageContentMask.ServerTimestamp) != 0)
            {
                Value.ServerTimestamp = decoder.ReadDateTime(nameof(MonitoredItemMessageContentMask.ServerTimestamp));
            }
            if ((MessageContentMask & (uint)MonitoredItemMessageContentMask.ServerPicoSeconds) != 0)
            {
                Value.ServerPicoseconds = decoder.ReadUInt16(nameof(MonitoredItemMessageContentMask.ServerPicoSeconds));
            }
            if ((MessageContentMask & (uint)MonitoredItemMessageContentMask.SourceTimestamp) != 0)
            {
                Value.SourceTimestamp = decoder.ReadDateTime(nameof(MonitoredItemMessageContentMask.SourceTimestamp));
            }
            if ((MessageContentMask & (uint)MonitoredItemMessageContentMask.SourcePicoSeconds) != 0)
            {
                Value.SourcePicoseconds = decoder.ReadUInt16(nameof(MonitoredItemMessageContentMask.SourcePicoSeconds));
            }
            if ((MessageContentMask & (uint)MonitoredItemMessageContentMask.StatusCode) != 0)
            {
                Value.StatusCode = decoder.ReadStatusCode(nameof(MonitoredItemMessageContentMask.StatusCode));
            }
            if ((MessageContentMask & (uint)MonitoredItemMessageContentMask.Status) != 0)
            {
                var status = decoder.ReadString(nameof(MonitoredItemMessageContentMask.Status));
            }
            if ((MessageContentMask & (uint)MonitoredItemMessageContentMask.EndpointUrl) != 0)
            {
                EndpointUrl = decoder.ReadString(nameof(MonitoredItemMessageContentMask.EndpointUrl));
            }
            if ((MessageContentMask & (uint)MonitoredItemMessageContentMask.SubscriptionId) != 0)
            {
                SubscriptionId = decoder.ReadString(nameof(MonitoredItemMessageContentMask.SubscriptionId));
            }
            if ((MessageContentMask & (uint)MonitoredItemMessageContentMask.ApplicationUri) != 0)
            {
                ApplicationUri = decoder.ReadString(nameof(MonitoredItemMessageContentMask.ApplicationUri));
            }
            if ((MessageContentMask & (uint)MonitoredItemMessageContentMask.DisplayName) != 0)
            {
                DisplayName = decoder.ReadString(nameof(MonitoredItemMessageContentMask.DisplayName));
            }
            if ((MessageContentMask & (uint)MonitoredItemMessageContentMask.Timestamp) != 0)
            {
                var timestamp = decoder.ReadDateTime(nameof(MonitoredItemMessageContentMask.Timestamp));
            }
            if ((MessageContentMask & (uint)MonitoredItemMessageContentMask.PicoSeconds) != 0)
            {
                var picoseconds = decoder.ReadUInt16(nameof(MonitoredItemMessageContentMask.PicoSeconds));
            }

            Value.WrappedValue = decoder.ReadVariant("Value");

            if ((MessageContentMask & (uint)MonitoredItemMessageContentMask.ExtraFields) != 0)
            {
                var dictionary = (KeyValuePairCollection)decoder.ReadEncodeableArray("ExtensionFields", typeof(Ua.KeyValuePair));
                ExtensionFields = new Dictionary <string, string>(dictionary.Count);
                foreach (var item in dictionary)
                {
                    ExtensionFields[item.Key.Name] = item.Value.ToString();
                }
            }
        }
 public virtual void Deserialize(IDecoder inStream)
 {
     IsConjunctionConnection = inStream.ReadString() == "a";
 }
예제 #55
0
        /// <summary>
        /// Helper for decoding of builtin types.
        /// </summary>
        protected object Decode(IDecoder decoder, BuiltInType builtInType, string fieldName, Type type)
        {
            switch (builtInType)
            {
            case BuiltInType.Null: { var variant = decoder.ReadVariant(fieldName); return(variant.Value); }

            case BuiltInType.Boolean: { return(decoder.ReadBoolean(fieldName)); }

            case BuiltInType.SByte: { return(decoder.ReadSByte(fieldName)); }

            case BuiltInType.Byte: { return(decoder.ReadByte(fieldName)); }

            case BuiltInType.Int16: { return(decoder.ReadInt16(fieldName)); }

            case BuiltInType.UInt16: { return(decoder.ReadUInt16(fieldName)); }

            case BuiltInType.Int32: { return(decoder.ReadInt32(fieldName)); }

            case BuiltInType.UInt32: { return(decoder.ReadUInt32(fieldName)); }

            case BuiltInType.Int64: { return(decoder.ReadInt64(fieldName)); }

            case BuiltInType.UInt64: { return(decoder.ReadUInt64(fieldName)); }

            case BuiltInType.Float: { return(decoder.ReadFloat(fieldName)); }

            case BuiltInType.Double: { return(decoder.ReadDouble(fieldName)); }

            case BuiltInType.String: { return(decoder.ReadString(fieldName)); }

            case BuiltInType.DateTime: { return(decoder.ReadDateTime(fieldName)); }

            case BuiltInType.Guid: { return(decoder.ReadGuid(fieldName)); }

            case BuiltInType.ByteString: { return(decoder.ReadByteString(fieldName)); }

            case BuiltInType.XmlElement: { return(decoder.ReadXmlElement(fieldName)); }

            case BuiltInType.NodeId: { return(decoder.ReadNodeId(fieldName)); }

            case BuiltInType.ExpandedNodeId: { return(decoder.ReadExpandedNodeId(fieldName)); }

            case BuiltInType.StatusCode: { return(decoder.ReadStatusCode(fieldName)); }

            case BuiltInType.QualifiedName: { return(decoder.ReadQualifiedName(fieldName)); }

            case BuiltInType.LocalizedText: { return(decoder.ReadLocalizedText(fieldName)); }

            case BuiltInType.ExtensionObject: { return(decoder.ReadExtensionObject(fieldName)); }

            case BuiltInType.DataValue: { return(decoder.ReadDataValue(fieldName)); }

            case BuiltInType.Enumeration:
            {
                return(type.IsEnum ? decoder.ReadEnumerated(fieldName, type) : (object)decoder.ReadInt32(fieldName));
            }

            case BuiltInType.DiagnosticInfo: { return(decoder.ReadDiagnosticInfo(fieldName)); }

            case BuiltInType.Variant: { return(decoder.ReadVariant(fieldName)); }
            }
            Assert.Fail($"Unknown BuiltInType {builtInType}");
            return(null);
        }
예제 #56
0
#pragma warning disable IDE0060 // Remove unused parameter
        /// <summary>
        /// Decode from binary
        /// </summary>
        /// <param name="decoder"></param>
        private void DecodeBinary(IDecoder decoder)
        {
#pragma warning restore IDE0060 // Remove unused parameter
            // TODO
            throw new NotImplementedException();
        }
예제 #57
0
 internal KafkaMessageStream(string topic, BlockingCollection <FetchedDataChunk> queue, int consumerTimeoutMs, IDecoder <TData> decoder, CancellationToken token)
 {
     this.topic             = topic;
     this.consumerTimeoutMs = consumerTimeoutMs;
     this.queue             = queue;
     this.decoder           = decoder;
     this.iterator          = new ConsumerIterator <TData>(topic, queue, consumerTimeoutMs, decoder, token);
 }
예제 #58
0
		public void HandleSchemaResponse(Broker broker, IDecoder decoder, long sequence) {
			short kind = decoder.ReadUint8() ;	
			ClassKey classKey = new ClassKey(decoder) ;
			SchemaClass sClass = new SchemaClass(kind, classKey, decoder, this) ;				
			lock(LockObject) {
				Dictionary<string, SchemaClass> classMappings = Packages[sClass.PackageName] ;
				classMappings.Remove(sClass.ClassKeyString) ;
				classMappings.Add(sClass.ClassKeyString, sClass) ;
			}
			
			SequenceManager.Release(sequence) ;
			broker.DecrementOutstanding() ;
			if (Console != null) {
				this.Console.NewClass(kind, classKey) ;
			}	
		}	
예제 #59
0
            public void AddElements(object mapObj, int elements, ReadItem itemReader, IDecoder decoder, bool reuse)
            {
                var map = ((IDictionary <string, object>)mapObj);

                for (int i = 0; i < elements; i++)
                {
                    var key = decoder.ReadString();
                    map[key] = itemReader(null, decoder);
                }
            }
예제 #60
0
		public void HandleEventIndicator(Broker broker, IDecoder decoder, long sequence) {
			if (Console != null) {
				QMFEvent newEvent = new QMFEvent(this, decoder) ;
				Console.EventRecieved(broker, newEvent) ;
			}			
		}