Exemplo n.º 1
0
        private void LoadTracking(object sender, DoWorkEventArgs e)
        {
            EyetrackerExperiment.App app  = (EyetrackerExperiment.App)App.Current;
            List <LoadFilesArgument> args = (List <LoadFilesArgument>)e.Argument;
            int numFilesLoaded            = 0;

            foreach (LoadFilesArgument arg in args)
            {
                TrackingReader trackingReader = new TrackingReader(arg.test);
                foreach (String fileName in arg.fileNames)
                {
                    app.Log(Severity.Info, String.Format("Trying to load {0}...", fileName));
                    int numSamples = trackingReader.Read(fileName, arg.mergeReplace);
                    if (numSamples > 0)
                    {
                        app.Log(Severity.Info, String.Format("Successfully loaded {0} samples from {1} into database.", numSamples, fileName));
                        numFilesLoaded++;
                    }
                    else if (numSamples == 0)
                    {
                        app.Log(Severity.Warning, String.Format("No samples found in {0}.", fileName));
                    }
                    else
                    {
                        app.Log(Severity.Error, String.Format("Loading of file {0} failed: {1}.", fileName, TrackingReader.getReturnCodeMsg(numSamples)));
                    }
                }
            }
            e.Result = numFilesLoaded;
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldHandleReadAheadEmptyData() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldHandleReadAheadEmptyData()
        {
            // GIVEN
            TrackingReader actual        = new TrackingReader(0);
            int            bufferSize    = 10;
            CharReadable   aheadReadable = ThreadAheadReadable.ThreadAhead(actual, bufferSize);

            // WHEN
            actual.AwaitCompletedReadAttempts(1);

            // THEN
            SectionedCharBuffer buffer = new SectionedCharBuffer(bufferSize);

            buffer = aheadReadable.Read(buffer, buffer.Front());
            assertEquals(buffer.Pivot(), buffer.Back());
            assertEquals(buffer.Pivot(), buffer.Front());
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReadAhead() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldReadAhead()
        {
            // GIVEN
            TrackingReader      actual      = new TrackingReader(23);
            int                 bufferSize  = 5;
            CharReadable        aheadReader = ThreadAheadReadable.ThreadAhead(actual, bufferSize);
            SectionedCharBuffer buffer      = new SectionedCharBuffer(bufferSize);

            // WHEN starting it up it should read and fill the buffer to the brim
            assertEquals(bufferSize, actual.AwaitCompletedReadAttempts(1));

            // WHEN we read one buffer
            int read = 0;

            buffer = aheadReader.Read(buffer, buffer.Front());
            AssertBuffer(Chars(read, bufferSize), buffer, 0, bufferSize);
            read += buffer.Available();

            // and simulate reading all characters, i.e. back section will be empty in the new buffer
            buffer = aheadReader.Read(buffer, buffer.Front());
            AssertBuffer(Chars(read, bufferSize), buffer, 0, bufferSize);
            read += buffer.Available();

            // then simulate reading some characters, i.e. back section will contain some characters
            int keep = 2;

            buffer = aheadReader.Read(buffer, buffer.Front() - keep);
            AssertBuffer(Chars(read - keep, bufferSize + keep), buffer, keep, bufferSize);
            read += buffer.Available();

            keep   = 3;
            buffer = aheadReader.Read(buffer, buffer.Front() - keep);
            AssertBuffer(Chars(read - keep, bufferSize + keep), buffer, keep, bufferSize);
            read += buffer.Available();

            keep   = 1;
            buffer = aheadReader.Read(buffer, buffer.Front() - keep);
            assertEquals(3, buffer.Available());
            AssertBuffer(Chars(read - keep, buffer.Available() + keep), buffer, keep, 3);
            read += buffer.Available();
            assertEquals(23, read);
        }