예제 #1
0
        public override void Handling(ushort[] data, MccBoard Board)
        {
            uiDispatcher.Invoke(() =>
            {
                float engUnits;
                reading = true;
                for (int i = 0; i < data.Length; i += 4*qChans)
                {
                    for (int j = 0; j < qChans; j++)
                    {
                        Board.ToEngUnits(Range.Bip10Volts, data[i + j], out engUnits);
                        var lineSeries = models[j].Series[0] as LineSeries;
                        if (lineSeries != null)
                        {
                            lineSeries.Points.Add(new DataPoint(count, engUnits));
                        }
                    }
                    count+=4;
                }
                foreach (PlotModel model in models)
                {
                    var lineSeries = model.Series[0] as LineSeries;
                    if (lineSeries != null && count >= MAX)
                        lineSeries.Points.Clear();
                    model.InvalidatePlot(true);
                }
                if (count >= MAX) count = 0;

            });
        }
        //INITIALIZE
        public PumpControl()
        {
            CancellationTokenSource cts = new CancellationTokenSource();
            int      boardNumber        = 0;
            MccBoard myBoard;

            myBoard = new MccBoard(boardNumber);

            //Pump
            myBoard.DConfigBit(DigitalPortType.AuxPort, PumpControlBit, DigitalPortDirection.DigitalOut);

            //Valves
            myBoard.DConfigBit(DigitalPortType.AuxPort, Valve1Control, DigitalPortDirection.DigitalOut);
            myBoard.DConfigBit(DigitalPortType.AuxPort, Valve2Control, DigitalPortDirection.DigitalOut);
            myBoard.DConfigBit(DigitalPortType.AuxPort, Valve3Control, DigitalPortDirection.DigitalOut);
            myBoard.DConfigBit(DigitalPortType.AuxPort, Valve4Control, DigitalPortDirection.DigitalOut);
            myBoard.DConfigBit(DigitalPortType.AuxPort, Valve5Control, DigitalPortDirection.DigitalOut);
            myBoard.DConfigBit(DigitalPortType.AuxPort, Valve6Control, DigitalPortDirection.DigitalOut);
            myBoard.DConfigBit(DigitalPortType.AuxPort, Valve7Control, DigitalPortDirection.DigitalOut);

            DaqBoard    = myBoard;
            BoardNumber = boardNumber;
            InitializeComponent();
            myBoard.DioConfig.GetDevType(1, out int configVal);
        }
예제 #3
0
 public override void Handling(ushort[] data, MccBoard board)
 {
     lock (FileLock)
     {
         if (reading)
             Monitor.Wait(FileLock);
         string line = "";
         reading = true;
         for (int i = 0; i < data.Length; i++)
         {
             line += String.Format("{0}{1}", data[i], (i + 1) % qChans == 0 ? "" : " ");
             if ((i + 1) % qChans == 0)
             {
                 lines.Add(line);
                 line = "";
             }
         }
         if (parts > 10)
         {
             System.IO.File.AppendAllLines(boardName + ".txt", lines);
             lines.Clear();
             parts = 0;
         }
         parts++;
         reading = false;
         Monitor.Pulse(FileLock);
     }
 }
        public MccDeviceReader(Settings _settings)
        {
            settings = _settings;
            ISet<MccDaq.DigitalPortType> portsUsed = settings.getPortsUsed();
            tempBoard = new MccBoard(settings.TempBoardNumber);

            if (settings.TemperatureFormat == TemperatureFormatEnum.Farenheit)
            {
                tempScale = TempScale.Fahrenheit;
            }
            else
            {
                tempScale = TempScale.Celsius;
            }
            dioBoard = new MccBoard(settings.DIOBoardNumber);
            foreach (MccDaq.DigitalPortType portType in settings.getPortsUsed())
            {
                MccDaq.ErrorInfo ulStat = dioBoard.DConfigPort(portType, MccDaq.DigitalPortDirection.DigitalIn);
                if (ulStat.Value != ErrorInfo.ErrorCode.NoErrors)
                {
                    logger.Error("Error while configuring DIO Board : " + ulStat.Message);
                    throw new DeviceException("Error while configuring DIO Board : " + ulStat.Message);
                }
            }

            //    MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);
        }
예제 #5
0
        public IObservable <Mat> Process(IObservable <Mat> source)
        {
            return(Observable.Create <Mat>(observer =>
            {
                var range = Range;
                var lowChannel = Channel;
                var board = new MccBoard(BoardNumber);
                var options = ScanOptions.Default;
                var scanObserver = Observer.Create <Mat>(
                    buffer =>
                {
                    var actualRate = 0;
                    var highChannel = lowChannel + buffer.Rows - 1;
                    var error = board.AOutScan(lowChannel, highChannel, buffer.Rows, ref actualRate, range, buffer.Data, options);
                    try
                    {
                        ThrowExceptionForErrorInfo(error);
                        if (actualRate != 0)
                        {
                            throw new InvalidOperationException($"The specified sampling rate is not available. Suggested rate: {actualRate}");
                        }

                        observer.OnNext(buffer);
                    }
                    catch (Exception ex) { observer.OnError(ex); }
                },
                    observer.OnError,
                    observer.OnCompleted);
                return source.SubscribeSafe(scanObserver);
            }));
        }
예제 #6
0
 public DataHandler(MccBoard board, BoardConfiguration bc, Dispatcher ui)
 {
     dataCont = new ADData(board, bc);
     boardConfig = bc;
     models = new List<ChannelControl>();
     uiDispatcher = ui;
 }
예제 #7
0
        public WiseBoard(MccBoard mccBoard, int boardNum = 0)
        {
            int ndaqs;

            if (mccBoard == null)    // a simulated board
            {
                type          = BoardType.Soft;
                this.mccBoard = new MccBoard(boardNum);
                this.boardNum = boardNum;
                WiseName      = "Board" + boardNum.ToString();
                ndaqs         = (boardNum == 1) ? 16 : 4;
            }
            else                // a real Mcc board
            {
                type          = BoardType.Hard;
                this.mccBoard = mccBoard;
                this.boardNum = this.mccBoard.BoardNum;
                WiseName      = "Board" + this.mccBoard.BoardNum.ToString();
                this.mccBoard.BoardConfig.GetDiNumDevs(out ndaqs);
            }

            daqs = new List <WiseDaq>();
            for (int devno = 0; devno < ndaqs; devno++)
            {
                daqs.Add(new WiseDaq(this, devno));
            }
        }
예제 #8
0
        static void Main(string[] args)
        {
            float    option            = 0;
            ushort   dataValueLum      = 0;
            float    dataValueLumVolt  = 0;
            ushort   dataValueTemp     = 0;
            float    dataValueTempVolt = 0;
            int      channelLum        = 0;
            int      channelTemp       = 0;
            Range    range             = Range.Bip10Volts;
            MccBoard mccBoard          = new MccBoard(0);

            for (int i = 0; i < 200; i++)
            {
                channelLum  = 7;
                channelTemp = 6;

                mccBoard.AIn(channelLum, range, out dataValueLum);
                mccBoard.VIn(channelLum, range, out dataValueLumVolt, 0);


                mccBoard.AIn(channelTemp, range, out dataValueTemp);
                mccBoard.VIn(channelTemp, range, out dataValueTempVolt, 0);

                Console.WriteLine("DataLum: " + dataValueLum.ToString());
                Console.WriteLine(dataValueLumVolt + "Volts");
                Console.WriteLine("DataTemp: " + dataValueTemp.ToString());
                Console.WriteLine(dataValueTempVolt + "Volts");

                Thread.Sleep(1000);
            }

            Console.ReadKey();
        }
예제 #9
0
        public DataAcqBoard(int boardNumber, DigitalPortType channelType, int channelNumber)
        {
            _ulStatErrorInfo = MccService.ErrHandling(ErrorReporting.PrintAll, ErrorHandling.DontStop);

            _board       = new MccBoard(boardNumber);
            _channelType = channelType;
            _channelNum  = channelNumber;

            _pulseIsCleared = true;
            _log.Info("Initialized DataAcqBoard: {0}, channel type {1}, channel number {2}", boardNumber, channelType, channelNumber);
        }
예제 #10
0
 public ADData(MccBoard board, BoardConfiguration bc)
 {
     lowChannel = bc.LowChannel;
     qChans = bc.QChanns;
     NumPoints = 186;//bc.PointsRead;
     MemHandle = MccDaq.MccService.WinBufAllocEx(10*qChans*NumPoints);
     Board = board;
     rate = bc.Rate;
     adData = new ushort[qChans*NumPoints];
     mCb = new CallbackFunction(this.CreateBackground);
 }
예제 #11
0
 public override IObservable <short> Process(IObservable <short> source)
 {
     return(Observable.Defer(() =>
     {
         var range = Range;
         var channel = Channel;
         var board = new MccBoard(BoardNumber);
         return source.Do(dataValue =>
         {
             var error = board.AOut(channel, range, dataValue);
             ThrowExceptionForErrorInfo(error);
         });
     }));
 }
예제 #12
0
        static void Main(string[] args)
        {
            MccBoard board = new MccBoard(0);
            board.DOut(DigitalPortType.FirstPortA, 100);
            board.DOut(DigitalPortType.FirstPortB, 0);
            int[] hist = new int[201];
            Console.Write("N=");

            int cnt = Convert.ToInt32(Console.ReadLine());
            double max = double.NegativeInfinity;
            double min = double.PositiveInfinity;
            double sum = 0D;
            double sum2 = 0D;
            long StartingTime;
            long EndingTime;
            double ElapsedSeconds;
            int bin;
            for (int c = 0; c < cnt; c++)
            {
                StartingTime = Stopwatch.GetTimestamp();

            //                for (int i = 0; i < 10; i++) ;

                EndingTime = Stopwatch.GetTimestamp();

                ElapsedSeconds = ((double)(EndingTime - StartingTime)) / Stopwatch.Frequency;
                max = Math.Max(max, ElapsedSeconds);
                min = Math.Min(min, ElapsedSeconds);
                sum += ElapsedSeconds;
                sum2 += ElapsedSeconds * ElapsedSeconds;
                bin = Convert.ToInt32(ElapsedSeconds * 1000000);
                if (bin < 200)
                    hist[bin]++;
                else
                    hist[200]++;
            }
            double mean = sum / cnt;
            Console.WriteLine("ETMean=" + (mean * 1000000D).ToString("0.000"));
            double sd = Math.Sqrt(sum2 / cnt - mean * mean);
            Console.WriteLine("ETSD=" + (sd * 1000000D).ToString("0.000000"));
            Console.WriteLine("ETMax=" + (max * 1000000D).ToString("0.000"));
            Console.WriteLine("ETMin=" + (min * 1000000D).ToString("0.000"));
            Console.ReadKey();
            for (int i = 0; i < hist.Length; i++)
                Console.WriteLine(i.ToString("000") + ": " + hist[i].ToString("00000000"));
            Console.ReadKey();
        }
예제 #13
0
 public override IObservable <short> Process <TSource>(IObservable <TSource> source)
 {
     return(Observable.Defer(() =>
     {
         var range = Range;
         var channel = Channel;
         var board = new MccBoard(BoardNumber);
         return source.Select(input =>
         {
             var error = board.AIn(channel, range, out short dataValue);
             if (error.Value != ErrorInfo.ErrorCode.NoErrors)
             {
                 throw new InvalidOperationException(error.Message);
             }
             return dataValue;
         });
     }));
 }
예제 #14
0
        public bool Init(int board)
        {
            _count = 0;
            try
            {
                ULStat = MccService.ErrHandling(ErrorReporting.DontPrint, ErrorHandling.DontStop);
                _daqBoard = new MccBoard(board);
                if (_daqBoard == null)
                {
                    return false;
                }

                _RegName = CounterRegister.LoadReg1; //  register name of counter 1
                Reset();
                Read();
            }
            catch (Exception ex)
            {
                return false;
            }
            return IsOK;
        }
예제 #15
0
파일: MCCDaq.cs 프로젝트: rdherric/Drivers
        /// <summary>
        /// CreateMccBoard does the detection and creation
        /// of the MccBoard object and stores it in the
        /// static variable.
        /// </summary>
        private void CreateMccBoard()
        {
            //If the board has already been created, just return
            //with no further processing
            if (MCCDaq._board != null)
            {
                return;
            }

            //Figure out the number of boards that
            //have been installed
            //Get the max number of boards
            Int32 maxBoards = GlobalConfig.NumBoards;

            //If the number isn't at least one, throw an Exception
            if (maxBoards < 1)
            {
                throw new System.ApplicationException("Could not find MCC DAQ Boards installed.");
            }

            //Iterate through the boards and take the first
            //one that works
            for (Int32 i = 0; i < maxBoards; i++)
            {
                //Attempt to make the MccBoard
                MccBoard board = new MccBoard(i);

                //If the Board doesn't appear to exist, continue
                ErrorInfo ei = board.FlashLED();
                if (ei.Value == ErrorInfo.ErrorCode.BadBoard)
                {
                    continue;
                }

                //Save the board as the member variable and break
                MCCDaq._board = board;
                break;
            }
        }
예제 #16
0
        public override IObservable <short> Process <TSource>(IObservable <TSource> source)
        {
            return(Observable.Defer(() =>
            {
                ErrorInfo configError;
                var portType = PortType;
                var bitNumber = BitNumber;
                var board = new MccBoard(BoardNumber);
                if (bitNumber.HasValue)
                {
                    configError = board.DConfigBit(portType, bitNumber.Value, DigitalPortDirection.DigitalIn);
                }
                else
                {
                    configError = board.DConfigPort(portType, DigitalPortDirection.DigitalIn);
                }
                ThrowExceptionForErrorInfo(configError);

                if (bitNumber.HasValue)
                {
                    return source.Select(input =>
                    {
                        var error = board.DBitIn(portType, bitNumber.Value, out DigitalLogicState bitValue);
                        ThrowExceptionForErrorInfo(error);
                        return (short)bitValue;
                    });
                }
                else
                {
                    return source.Select(input =>
                    {
                        var error = board.DIn(portType, out short dataValue);
                        ThrowExceptionForErrorInfo(error);
                        return dataValue;
                    });
                }
            }));
        }
예제 #17
0
        public override IObservable <short> Process(IObservable <short> source)
        {
            return(Observable.Defer(() =>
            {
                ErrorInfo configError;
                var portType = PortType;
                var bitNumber = BitNumber;
                var board = new MccBoard(BoardNumber);
                if (bitNumber.HasValue)
                {
                    configError = board.DConfigBit(portType, bitNumber.Value, DigitalPortDirection.DigitalOut);
                }
                else
                {
                    configError = board.DConfigPort(portType, DigitalPortDirection.DigitalOut);
                }
                ThrowExceptionForErrorInfo(configError);

                if (bitNumber.HasValue)
                {
                    return source.Do(input =>
                    {
                        var bitValue = input != 0 ? DigitalLogicState.High : DigitalLogicState.Low;
                        var error = board.DBitOut(portType, bitNumber.Value, bitValue);
                        ThrowExceptionForErrorInfo(error);
                    });
                }
                else
                {
                    return source.Do(dataValue =>
                    {
                        var error = board.DOut(portType, dataValue);
                        ThrowExceptionForErrorInfo(error);
                    });
                }
            }));
        }
예제 #18
0
        public override IObservable <Mat> Generate()
        {
            const int PacketSize = 256;

            return(Observable.Create <Mat>((observer, cancellationToken) =>
            {
                return Task.Factory.StartNew(() =>
                {
                    var range = Range;
                    var sampleRate = SampleRate;
                    var sampleCount = SampleCount;
                    var lowChannel = LowChannel;
                    var highChannel = HighChannel;
                    var board = new MccBoard(BoardNumber);
                    var channels = highChannel - lowChannel + 1;
                    var dataPoints = sampleCount * channels;
                    var bufferSize = PacketSize * (sampleCount * 2 / PacketSize + 1);
                    var bufferPoints = bufferSize * channels;
                    var buffer = new Mat(bufferSize, channels, Depth.S16, 1);
                    var options = ScanOptions.Continuous | ScanOptions.Background;
                    var dataAvailable = default(EventCallback);
                    using (var waitEvent = new AutoResetEvent(false))
                        using (var cancellation = cancellationToken.Register(() => waitEvent.Set()))
                        {
                            try
                            {
                                dataAvailable = delegate { waitEvent.Set(); };
                                var error = board.EnableEvent(EventType.OnDataAvailable, dataPoints, dataAvailable, IntPtr.Zero);
                                ThrowExceptionForErrorInfo(error);

                                var actualRate = sampleRate;
                                error = board.AInScan(lowChannel, highChannel, bufferPoints, ref actualRate, range, buffer.Data, options);
                                ThrowExceptionForErrorInfo(error);
                                if (actualRate != sampleRate)
                                {
                                    throw new InvalidOperationException($"The specified sampling rate is not available. Suggested rate: {actualRate}");
                                }

                                var readIndex = 0;
                                while (!cancellationToken.IsCancellationRequested)
                                {
                                    waitEvent.WaitOne();
                                    error = board.GetStatus(out short status, out int count, out int index, FunctionType.AiFunction);
                                    ThrowExceptionForErrorInfo(error);
                                    if (index < 0)
                                    {
                                        continue;
                                    }

                                    index /= channels;
                                    var overflowCount = 0;
                                    var readCount = index - readIndex;
                                    if (readCount < 0) // overflow
                                    {
                                        overflowCount = bufferSize - readIndex;
                                        readCount = index + overflowCount;
                                    }

                                    while (readCount >= sampleCount)
                                    {
                                        readCount -= sampleCount;
                                        var output = new Mat(channels, sampleCount, buffer.Depth, buffer.Channels);
                                        if (overflowCount > 0)
                                        {
                                            overflowCount -= sampleCount;
                                            if (overflowCount < 0) // wrap-around buffer, copy remainder
                                            {
                                                var overflowSamples = bufferSize - readIndex;
                                                using (var outputOverflow = output.GetSubRect(new Rect(0, 0, overflowSamples, channels)))
                                                    using (var dataOverflow = buffer.GetSubRect(new Rect(0, readIndex, channels, overflowSamples)))
                                                    {
                                                        CV.Transpose(dataOverflow, outputOverflow);
                                                    }

                                                readIndex = 0;
                                                overflowSamples = sampleCount - overflowSamples;
                                                using (var outputOverflow = output.GetSubRect(new Rect(sampleCount - overflowSamples, 0, overflowSamples, channels)))
                                                    using (var dataOverflow = buffer.GetSubRect(new Rect(0, readIndex, channels, overflowSamples)))
                                                    {
                                                        CV.Transpose(dataOverflow, outputOverflow);
                                                    }

                                                observer.OnNext(output);
                                                continue;
                                            }
                                        }

                                        using (var data = buffer.GetSubRect(new Rect(0, readIndex, channels, sampleCount)))
                                        {
                                            CV.Transpose(data, output);
                                        }
                                        readIndex = (readIndex + sampleCount) % bufferSize;
                                        observer.OnNext(output);
                                    }
                                }
                            }
                            finally
                            {
                                board.StopBackground(FunctionType.AiFunction);
                                board.DisableEvent(EventType.OnDataAvailable);
                                GC.KeepAlive(dataAvailable);
                            }
                        }
                },
                                             cancellationToken,
                                             TaskCreationOptions.LongRunning,
                                             TaskScheduler.Default);
            }));
        }
예제 #19
0
        /// <summary>
        /// Constructor. Initializes GridData, Series, DaqDevices, and MccBoards properties.
        /// </summary>
        public LoggerViewModel()
        {
            //Init GridData
            GridData.Columns.Add(new DataColumn("Device", typeof(int)));
            GridData.Columns.Add(new DataColumn("Value", typeof(double)));

            //Init Series
            for (int i = 0; i < 16; i++)
            {
                GridData.Rows.Add(i, 0);
                GLineSeries gSeries = new GLineSeries
                {
                    Title           = "Device " + i.ToString(),
                    Values          = new GearedValues <double>().WithQuality(Quality.Low),
                    Fill            = Brushes.Transparent,
                    StrokeThickness = .5,
                    PointGeometry   = null
                };
                Series.Add(gSeries);
            }

            //Init DataReceived event
            DataReceivedDelegate = DaqBoard_DataReceived;
            DeviceInventory      = DaqDeviceManager.GetDaqDeviceInventory(DaqDeviceInterface.Any);
            ErrorInfo            = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.DontStop);

            DaqDevices = "DAQ Devices: " + DeviceInventory.Length.ToString();

            //Init MccBoards
            MccBoard board;

            for (int i = 0; i < DeviceInventory.Length; i++)
            {
                try
                {
                    board = DaqDeviceManager.CreateDaqDevice(0, DeviceInventory[0]);
                    MccBoards.Add(board);

                    Status      = "Stopped";
                    StatusBrush = Brushes.Red;
                }
                catch (ULException ule)
                {
                    if (ule.ErrorInfo.Value == ErrorCode.BoardNumInUse)
                    {
                        board = new MccBoard(i);
                        MccBoards.Add(board);
                        Status      = "Stopped";
                        StatusBrush = Brushes.Red;
                    }
                    else
                    {
                        Status = ule.Message;
                    }
                }
            }

            //Prepare for user input
            _isReading   = false;
            _updateChart = false;
        }
예제 #20
0
        public void Initialize()
        {
            MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);

            board = new MccDaq.MccBoard(0);
        }
예제 #21
0
 private void SetupThermoCoupleDAQBoard()
 {
     thermocouple_board = new MccBoard(BoardNum);
 }
예제 #22
0
        private void SetupOvenDAQBoard()
        {
            oven_board = new MccBoard(BoardNum);

            ConfigureOvenBoardDioChannelsForOutput();
        }
 private void DetectBoards()
 {
     int maxNumBoards = GlobalConfig.NumBoards;
     int currentBoard = 0;
     boards = new List<MccBoard>();
     ErrorInfo uLStat;
     int boardType;
     for (int i = 0; i < maxNumBoards; i++)
     {
         MccBoard board = new MccBoard(currentBoard);
         uLStat = board.BoardConfig.GetBoardType(out boardType);
         if (boardType == 0) break;
         boards.Add(board);
         currentBoard++;
     }
 }
 private TabItem createTabItem(MccBoard board, int num, BoardConfiguration bc)
 {
     TabItem item = new TabItem();
     item.Header = bc.BoardName;
     Grid grid = new Grid();
     ScrollViewer scrollView = new ScrollViewer();
     scrollView.Content = grid;
     item.Content = scrollView;
     DataHandler dataHand = new DataHandler(board, bc, Dispatcher.CurrentDispatcher);
     dataHand.Finished += ColetaFinished;
     dataHandlers.Add(dataHand);
     for (int i = 0; i < bc.QChanns; i++)
     {
         ChannelControl chCont = new ChannelControl("Channel "+(bc.LowChannel + i + 1).ToString());
         RowDefinition rowDef = new RowDefinition();
         rowDef.Height = new GridLength(250, GridUnitType.Pixel);
         grid.RowDefinitions.Add(rowDef);
         chCont.SetValue(Grid.RowProperty, i);
         grid.Children.Add(chCont);
         dataHand.AddPlotModel(chCont);
     }
     return item;
 }
예제 #25
0
 public void Dispose()
 {
     _board = null;
     GC.SuppressFinalize(this);
 }
예제 #26
0
        public void Initialize(IExecutable executableObject, SetupData setupData, XmlNode setupNode)
        {
            MccBoard board;
            int      num = 0;

            this.m_boards        = new MccBoard[GlobalConfig.NumBoards];
            this.m_boardPortType = new DigitalPortType[GlobalConfig.NumBoards];
            int index = 0;

            while (index < GlobalConfig.NumBoards)
            {
                board = new MccBoard(index);
                board.BoardConfig.GetBoardType(out num);
                if (num == 0)
                {
                    break;
                }
                this.m_boards[index]        = board;
                this.m_boardPortType[index] = (DigitalPortType)1;
                index++;
            }
            Array.Resize <MccBoard>(ref this.m_boards, index);
            Array.Resize <DigitalPortType>(ref this.m_boardPortType, index);
            this.m_hardwareMap = new VixenPlus.HardwareMap[index];
            int num3 = 0;
            int num6 = 0;
            Dictionary <string, int> dictionary = new Dictionary <string, int>();

            this.m_pinBoardIndex  = new int[0];
            this.m_pinBoardOffset = new int[0];
            for (index = 0; index < this.m_boards.Length; index++)
            {
                Dictionary <string, int> dictionary2;
                string str;
                board = this.m_boards[index];
                if (!dictionary.ContainsKey(board.BoardName))
                {
                    dictionary[board.BoardName] = 0;
                }
                this.m_hardwareMap[index] = new VixenPlus.HardwareMap(board.BoardName, dictionary[board.BoardName]);
                (dictionary2 = dictionary)[str = board.BoardName] = dictionary2[str] + 1;
                int pinCount = this.m_pinCount;
                board.BoardConfig.GetDiNumDevs(out num3);
                for (int i = 0; i < num3; i++)
                {
                    int num5;
                    board.DioConfig.GetDevType(i, out num5);
                    if (num5 == 10)
                    {
                        this.m_boardPortType[index] = (DigitalPortType)10;
                    }
                    board.DConfigPort((DigitalPortType)num5, DigitalPortDirection.DigitalOut);
                    board.DioConfig.GetNumBits(i, out num6);
                    Array.Resize <int>(ref this.m_pinBoardIndex, this.m_pinBoardIndex.Length + num6);
                    Array.Resize <int>(ref this.m_pinBoardOffset, this.m_pinBoardOffset.Length + num6);
                    for (int j = 0; j < num6; j++)
                    {
                        this.m_pinBoardIndex[j + this.m_pinCount]  = index;
                        this.m_pinBoardOffset[j + this.m_pinCount] = (this.m_pinCount + j) - pinCount;
                    }
                    this.m_pinCount += num6;
                }
            }
        }
예제 #27
0
 protected override void Init()
 {
     m_buffer = new float[1];
     m_channels = new MccDAQChannel[m_channelsNum];
     m_status = MccService.ErrHandling(ErrorReporting.DontPrint, ErrorHandling.DontStop);
     DaqBoard = new MccDaq.MccBoard(m_board);
     m_status = DaqBoard.BoardConfig.GetUsesExps(out UsesEXPs);
     if (m_status.Value == ErrorInfo.ErrorCode.BadBoard)
     {
         throw new ArgumentException(String.Format("MccDAQBoard number {0} failed to init! Check Instacal for valid board numbers.", m_board));
     }
     m_units = MccDaq.TempScale.Celsius;
     m_options = 0;
 }
예제 #28
0
 public void Initialize(IExecutable executableObject, SetupData setupData, XmlNode setupNode)
 {
     MccBoard board;
     int num = 0;
     this.m_boards = new MccBoard[GlobalConfig.NumBoards];
     this.m_boardPortType = new DigitalPortType[GlobalConfig.NumBoards];
     int index = 0;
     while (index < GlobalConfig.NumBoards)
     {
         board = new MccBoard(index);
         board.BoardConfig.GetBoardType(out num);
         if (num == 0)
         {
             break;
         }
         this.m_boards[index] = board;
         this.m_boardPortType[index] = (DigitalPortType)1;
         index++;
     }
     Array.Resize<MccBoard>(ref this.m_boards, index);
     Array.Resize<DigitalPortType>(ref this.m_boardPortType, index);
     this.m_hardwareMap = new VixenPlus.HardwareMap[index];
     int num3 = 0;
     int num6 = 0;
     Dictionary<string, int> dictionary = new Dictionary<string, int>();
     this.m_pinBoardIndex = new int[0];
     this.m_pinBoardOffset = new int[0];
     for (index = 0; index < this.m_boards.Length; index++)
     {
         Dictionary<string, int> dictionary2;
         string str;
         board = this.m_boards[index];
         if (!dictionary.ContainsKey(board.BoardName))
         {
             dictionary[board.BoardName] = 0;
         }
         this.m_hardwareMap[index] = new VixenPlus.HardwareMap(board.BoardName, dictionary[board.BoardName]);
         (dictionary2 = dictionary)[str = board.BoardName] = dictionary2[str] + 1;
         int pinCount = this.m_pinCount;
         board.BoardConfig.GetDiNumDevs(out num3);
         for (int i = 0; i < num3; i++)
         {
             int num5;
             board.DioConfig.GetDevType(i, out num5);
             if (num5 == 10)
             {
                 this.m_boardPortType[index] = (DigitalPortType)10;
             }
             board.DConfigPort((DigitalPortType) num5, DigitalPortDirection.DigitalOut);
             board.DioConfig.GetNumBits(i, out num6);
             Array.Resize<int>(ref this.m_pinBoardIndex, this.m_pinBoardIndex.Length + num6);
             Array.Resize<int>(ref this.m_pinBoardOffset, this.m_pinBoardOffset.Length + num6);
             for (int j = 0; j < num6; j++)
             {
                 this.m_pinBoardIndex[j + this.m_pinCount] = index;
                 this.m_pinBoardOffset[j + this.m_pinCount] = (this.m_pinCount + j) - pinCount;
             }
             this.m_pinCount += num6;
         }
     }
 }
예제 #29
0
파일: MccDIO.cs 프로젝트: avishayp/MccDAQAO
        public bool Init(Object condata)
        {
            if (IsInit)
                return true;

            try
            {
                int boardnum = (int)condata;
                m_daqBoard = new MccBoard(boardnum);
                InitUL();
                IsInit = InternalDAConfig();
            }
            catch (System.Exception ex)
            {
            }
            return IsInit;
        }
 public abstract void Handling(ushort[] data, MccBoard board);
예제 #31
0
 public TestAnalogInput()
 {
     this.acqBoard = new MccBoard(0);
     this.LightIn  = new AnalogInput(this.acqBoard, 7);
 }