Esempio n. 1
0
        public DataStreamWriter(string filename)
            : this(new FileStream(filename, FileMode.Create))
        {
            Filename = filename;

            var header = new DataStreamRecord()
            {
                RecordType = DataStreamRecordType.Header,
                Length     = 1,
                Data       = new byte[] { 0 },           // version
            };

            Write(header);
        }
Esempio n. 2
0
        public DataStreamRecord ReadRecord() // TODO: what does BinaryReader.Read() do??
        {
            var data = new DataStreamRecord();

            data.Read(this);
            IntervalMax = Math.Max(IntervalMax, data.Interval);

#if PAUSE_READS_PER_TIMESTAMPS
            if (Stopwatch.ElapsedMilliseconds < data.Interval)
            {
                Thread.Sleep((int)(Stopwatch.ElapsedMilliseconds - data.Interval));
            }
#endif

#if THROW_TIMEOUT_EXCEPTIONS // maybe should have Channel do this? Nah, needs to be done herein
            if (data.RecordType == DataStreamRecordType.Timeout)
            {
                throw new TimeoutException();
            }
#endif

            return(data);
        }
Esempio n. 3
0
        public void Write(int interval, DataStreamRecordType type, byte[] data)
        {
            var record = new DataStreamRecord(interval, type, data);

            Write(record);
        }
Esempio n. 4
0
 public void Write(DataStreamRecord record)
 {
     record.Write(this);
 }