예제 #1
0
        public void RoundTripChannelConfig()
        {
            HekkaDevice device = HekkaDevice.Zero;

            uint err = ITCMM.ITC_OpenDevice(ITCMM.USB18_ID, 0, ITCMM.SMART_MODE, out device);
            if (err != ITCMM.ACQ_SUCCESS)
            {
                Assert.Fail(ErrorDescription.ErrorString(err));
            }

            try
            {
                //ITCMM.HWFunction hwf = new ITCMM.HWFunction();

                err = ITCMM.ITC_InitDevice(device, IntPtr.Zero); //ref hwf);

                ITCMM.ITCPublicConfig config = new ITCMM.ITCPublicConfig();
                config.OutputEnable = 1;

                err = ITCMM.ITC_ConfigDevice(device, ref config);
                if (err != ITCMM.ACQ_SUCCESS)
                {
                    Assert.Fail(ErrorDescription.ErrorString(err));
                }

                Assert.NotNull(device);

                err = ITCMM.ITC_ResetChannels(device);
                if (err != ITCMM.ACQ_SUCCESS)
                {
                    Assert.Fail(ErrorDescription.ErrorString(err));
                }

                ITCMM.ITCChannelInfo[] info = new ITCMM.ITCChannelInfo[2];

                info[0].ChannelNumber = 0;
                info[0].ChannelType = ITCMM.OUTPUT_GROUP;
                info[1].ChannelNumber = 0;
                info[1].ChannelType = ITCMM.INPUT_GROUP;

                const double srate = 8000;
                info[0].SamplingRate = srate;
                info[1].SamplingRate = srate;

                err = ITCMM.ITC_SetChannels(device, 2, info);
                if (err != ITCMM.ACQ_SUCCESS)
                {
                    Assert.Fail(ErrorDescription.ErrorString(err));
                }

                err = ITCMM.ITC_UpdateChannels(device);
                if (err != ITCMM.ACQ_SUCCESS)
                {
                    Assert.Fail(ErrorDescription.ErrorString(err));
                }

                ITCMM.ITCChannelInfo[] actual = new ITCMM.ITCChannelInfo[2];
                actual[0].ChannelType = info[0].ChannelType;
                actual[0].ChannelNumber = info[0].ChannelNumber;
                actual[1].ChannelType = info[1].ChannelType;
                actual[1].ChannelNumber = info[1].ChannelNumber;

                err = ITCMM.ITC_GetChannels(device, 2, actual);
                if (err != ITCMM.ACQ_SUCCESS)
                {
                    Assert.Fail(ErrorDescription.ErrorString(err));
                }

                Assert.AreEqual(info[0].SamplingRate, actual[0].SamplingRate);
                Assert.AreEqual(info[1].SamplingRate, actual[1].SamplingRate);

            }
            finally
            {
                err = ITCMM.ITC_CloseDevice(device);
                Assert.AreEqual(ITCMM.ACQ_SUCCESS,
                    err,
                    ErrorDescription.ErrorString(err)
                    );
            }
        }
        public ITCMM.ITCChannelInfo ChannelInfo(StreamType channelType, ushort channelNumber)
        {
            ITCMM.ITCChannelInfo[] info = new ITCMM.ITCChannelInfo[1];
            info[0] = new ITCMM.ITCChannelInfo() { ChannelNumber = channelNumber, ChannelType = (uint)channelType };

            uint err = ItcmmCall(() => ITCMM.ITC_GetChannels(DevicePtr, 1, info));
            if (err != ITCMM.ACQ_SUCCESS)
                throw new HekaDAQException("Unable to retrieve channel info struct.", err);

            return info[0];
        }
예제 #3
0
        public void ReadAvailableSamples()
        {
            HekkaDevice device = HekkaDevice.Zero;

            uint err = ITCMM.ITC_OpenDevice(ITCMM.USB18_ID, 0, ITCMM.SMART_MODE, out device);
            if (err != ITCMM.ACQ_SUCCESS)
            {
                Assert.Fail(ErrorDescription.ErrorString(err));
            }

            try
            {
                //ITCMM.HWFunction hwf = new ITCMM.HWFunction();

                err = ITCMM.ITC_InitDevice(device, IntPtr.Zero); // ref hwf);

                ITCMM.ITCPublicConfig config = new ITCMM.ITCPublicConfig();
                config.OutputEnable = 1;

                err = ITCMM.ITC_ConfigDevice(device, ref config);
                if (err != ITCMM.ACQ_SUCCESS)
                {
                    Assert.Fail(ErrorDescription.ErrorString(err));
                }

                Assert.NotNull(device);

                ITCMM.ITCChannelInfo channelInfo = new ITCMM.ITCChannelInfo();
                channelInfo.ChannelType = ITCMM.H2D;
                channelInfo.ChannelNumber = 0;
                channelInfo.SamplingRate = 1000.0;
                Assert.AreEqual(System.IntPtr.Zero, channelInfo.FIFOPointer);

                Assert.AreEqual(ITCMM.ACQ_SUCCESS,
                    ITCMM.ITC_SetChannels(device, 1, new ITCMM.ITCChannelInfo[] { channelInfo })
                    );

                Assert.AreEqual(ITCMM.ACQ_SUCCESS,
                    (int)ITCMM.ITC_UpdateChannels(device)
                    );

                ITCMM.ITCChannelDataEx info = new ITCMM.ITCChannelDataEx();

                info.ChannelType = ITCMM.H2D;
                info.ChannelNumber = 0;

                ITCMM.ITCChannelDataEx[] arr = new ITCMM.ITCChannelDataEx[] { info };
                err = ITCMM.ITC_GetDataAvailable(device, 1, arr);
                if (err != ITCMM.ACQ_SUCCESS)
                {
                    Assert.Fail(ErrorDescription.ErrorString(err));
                }

                info = arr[0];

                Assert.That(info.Value, Is.GreaterThanOrEqualTo(0));
            }
            finally
            {
                err = ITCMM.ITC_CloseDevice(device);
                Assert.AreEqual(ITCMM.ACQ_SUCCESS,
                    err,
                    ErrorDescription.ErrorString(err)
                    );
            }
        }