Esempio n. 1
0
        public void TestEpochSetup()
        {
            const string protocolID = "Epoch.Fixture";
            var          parameters = new Dictionary <string, object>();

            parameters[param1] = value1;
            parameters[param2] = value2;

            dev1 = new UnitConvertingExternalDevice(dev1Name, "DEVICECO", new Measurement(0, "V"));
            dev2 = new UnitConvertingExternalDevice(dev2Name, "DEVICECO", new Measurement(0, "V"));

            var stream1 = new DAQInputStream("Stream1");
            var stream2 = new DAQInputStream("Stream2");

            var stimParameters = new Dictionary <string, object>();

            stimParameters[param1] = value1;
            stimParameters[param2] = value2;

            var srate = new Measurement(1000, "Hz");

            var samples  = Enumerable.Range(0, 1000).Select(i => new Measurement((decimal)Math.Sin((double)i / 100), "V")).ToList();
            var stimData = new OutputData(samples, srate, false);

            RenderedStimulus stim1 = new RenderedStimulus((string)"RenderedStimulus", (IDictionary <string, object>)stimParameters, (IOutputData)stimData);   //.Data does not need to be persisted
            RenderedStimulus stim2 = new RenderedStimulus((string)"RenderedStimulus", (IDictionary <string, object>)stimParameters, (IOutputData)stimData);   //.Data does not need to be persisted

            Epoch e = new Epoch(protocolID, parameters);

            e.Stimuli[dev1] = stim1;
            e.Stimuli[dev2] = stim2;

            var start = DateTimeOffset.Parse("1/11/2011 6:03:29 PM -08:00");

            // Do this to match the XML stored in the EpochXML.txt resource
            e.StartTime = Maybe <DateTimeOffset> .Yes(start);

            e.Background[dev1] = new Epoch.EpochBackground(new Measurement(0, "V"), new Measurement(1000, "Hz"));
            e.Background[dev2] = new Epoch.EpochBackground(new Measurement(1, "V"), new Measurement(1000, "Hz"));

            e.Responses[dev1] = new Response();
            e.Responses[dev2] = new Response();

            var streamConfig = new Dictionary <string, object>();

            streamConfig[param1] = value1;

            var devConfig = new Dictionary <string, object>();

            devConfig[param2] = value2;

            var responseData1 = new InputData(samples, srate, start)
                                .DataWithStreamConfiguration(stream1, streamConfig)
                                .DataWithExternalDeviceConfiguration(dev1, devConfig);
            var responseData2 = new InputData(samples, srate, start)
                                .DataWithStreamConfiguration(stream2, streamConfig)
                                .DataWithExternalDeviceConfiguration(dev2, devConfig);

            e.Responses[dev1].AppendData(responseData1);
            e.Responses[dev2].AppendData(responseData2);

            e.Keywords.Add(kw1);
            e.Keywords.Add(kw2);

            testEpoch = e;
        }