/// <summary>
 /// Config the port to the Output
 /// </summary>
 public void DigitalConfigurationOut()
 {
     DigitalIO.clsDigitalIO DioProps = new DigitalIO.clsDigitalIO();
     PortType = clsDigitalIO.PORTOUT;
     NumPort  = DioProps.FindPortsOfType(DaqBoard, PortType, out ProgAbility,
                                         out PortNum, out NumBits, out FirstBit);
     MccDaq.DigitalPortDirection Direction = MccDaq.DigitalPortDirection.DigitalOut;
     ULStat = DaqBoard.DConfigPort(PortNum, Direction);
 }
Exemplo n.º 2
0
        private void frmSetBitOut_Load(object sender, EventArgs e)
        {
            string PortName;

            MccDaq.ErrorInfo ULStat;

            InitUL();

            //determine if digital port exists, its capabilities, etc
            PortType = clsDigitalIO.PORTOUT;
            NumPorts = DioProps.FindPortsOfType(DaqBoard, PortType, out ProgAbility,
                                                out PortNum, out NumBits, out FirstBit);
            if (NumBits > 8)
            {
                NumBits = 8;
            }
            for (int I = NumBits; I < 8; ++I)
            {
                chkSetBit[I].Visible = false;
            }

            if (NumPorts == 0)
            {
                lblInstruct.Text = "Board " + DaqBoard.BoardNum.ToString() +
                                   " has no compatible digital ports.";
                for (int I = 0; I < 8; ++I)
                {
                    chkSetBit[I].Enabled = false;
                }
            }
            else
            {
                // if programmable, set direction of port to output
                // configure the first port for digital output
                //  Parameters:
                //    PortNum        :the output port
                //    Direction      :sets the port for input or output

                if (ProgAbility == clsDigitalIO.PROGPORT)
                {
                    Direction = MccDaq.DigitalPortDirection.DigitalOut;
                    ULStat    = DaqBoard.DConfigPort(PortNum, Direction);
                }
                PortName         = PortNum.ToString();
                lblInstruct.Text = "Set the output value of " + PortName +
                                   " on board " + DaqBoard.BoardNum.ToString() +
                                   " bits using the check boxes.";
            }
        }
Exemplo n.º 3
0
        const MccDaq.DigitalPortDirection Direction = MccDaq.DigitalPortDirection.DigitalIn; //  set direction of port to input


        public frmDigIn()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.PrintAll :all warnings and errors encountered will be printed
            //     MccDaq.ErrorHandling.StopAll   :if an error is encountered, the program will stop

            MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);



            // Create a new MccBoard object for Board 0
            DaqBoard = new MccDaq.MccBoard(0);

            //  configure FirstPortA for digital input
            //   Parameters:
            //     PortNum    :the input port
            //     Direction :sets the port for input or output
            ULStat = DaqBoard.DConfigPort(PortNum, Direction);


            lblBitNum = (new Label[] { _lblBitNum_0, _lblBitNum_1, _lblBitNum_2, _lblBitNum_3,
                                       _lblBitNum_4, _lblBitNum_5, _lblBitNum_6, _lblBitNum_7 });


            lblBitVal = (new Label[] { _lblBitVal_0, _lblBitVal_1, _lblBitVal_2, _lblBitVal_3,
                                       _lblBitVal_4, _lblBitVal_5, _lblBitVal_6, _lblBitVal_7 });
        }
Exemplo n.º 4
0
        public frmDScan()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            lblDataRead = (new Label[] { _lblDataRead_0, _lblDataRead_1, _lblDataRead_2, _lblDataRead_3, _lblDataRead_4,
                                         _lblDataRead_5, _lblDataRead_6, _lblDataRead_7, _lblDataRead_8, _lblDataRead_9 });

            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.PrintAll :all warnings and errors encountered will be printed
            //     MccDaq.ErrorHandling.StopAll   :if an error is encountered, the program will stop

            MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);


            // Create a new MccBoard object for Board 0
            DaqBoard = new MccDaq.MccBoard(0);

            // set aside memory to hold data
            MemHandle = MccDaq.MccService.WinBufAlloc(NumPoints);


            //  configure FirstPortA for digital input
            //   Parameters:
            //     PortNum    :the input port
            //     Direction  :sets the port for input or output
            PortNum = MccDaq.DigitalPortType.FirstPortA;
            ULStat  = DaqBoard.DConfigPort(PortNum, Direction);


            // configure FirstPortA & FirstPortB for digital input
            //   Parameters:
            //      PortNum    :the input port
            //      Direction  :sets the port for input or output
            PortNum = MccDaq.DigitalPortType.FirstPortB;
            ULStat  = DaqBoard.DConfigPort(PortNum, Direction);


            Force = 0;
        }
Exemplo n.º 5
0
        private void frmDScan_Load(object sender, EventArgs e)
        {
            string AndString = string.Empty;
            string PortName  = string.Empty;

            MccDaq.ErrorInfo ULStat;

            InitUL();

            //determine if digital port exists, its capabilities, etc
            PortType = clsDigitalIO.PORTINSCAN;
            NumPorts = DioProps.FindPortsOfType(DaqBoard, PortType, out ProgAbility,
                                                out PortNum, out NumBits, out FirstBit);
            if (NumPorts > 2)
            {
                NumPorts = 2;
            }

            if (NumPorts == 0)
            {
                lblInstruct.Text = "Board " + DaqBoard.BoardNum.ToString() +
                                   " has no digital scan ports.";
                cmdReadDIn.Enabled = false;
                cmdTemp.Enabled    = false;
            }
            else
            {
                DataBuffer = new ushort[NumPoints];

                // set aside memory to hold data
                MemHandle = MccDaq.MccService.WinBufAllocEx(NumPoints);
                MccDaq.DigitalPortType DigPort;

                // configure first one or two scan ports
                // for digital input (if programmable)
                //  Parameters:
                //    PortNum        :the input port
                //    Direction      :sets the port for input or output

                for (int NumberOfPort = 0; NumberOfPort < NumPorts; ++NumberOfPort)
                {
                    DigPort  = PortNum + NumberOfPort;
                    PortName = PortName + AndString + DigPort.ToString();
                    if (ProgAbility == clsDigitalIO.PROGPORT)
                    {
                        Direction = DigitalPortDirection.DigitalIn;
                        ULStat    = DaqBoard.DConfigPort(PortNum, Direction);
                    }
                    AndString = " and ";
                }
                lblInstruct.Text = "Scanning digital input port at " + PortName +
                                   " on board " + DaqBoard.BoardNum.ToString() + ".";
            }
            Force = 0;
        }
Exemplo n.º 6
0
        const MccDaq.DigitalPortDirection Direction = MccDaq.DigitalPortDirection.DigitalIn; //  program port for input mode


        public frmDigIn()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            lblShowBitNum = (new Label[] { _lblShowBitNum_0, _lblShowBitNum_1, _lblShowBitNum_2, _lblShowBitNum_3,
                                           _lblShowBitNum_4, _lblShowBitNum_5, _lblShowBitNum_6, _lblShowBitNum_7 });

            lblShowBitVal = (new Label[] { _lblShowBitVal_0, _lblShowBitVal_1, _lblShowBitVal_2, _lblShowBitVal_3,
                                           _lblShowBitVal_4, _lblShowBitVal_5, _lblShowBitVal_6, _lblShowBitVal_7 });

            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.PrintAll :all warnings and errors encountered will be printed
            //     MccDaq.ErrorHandling.StopAll   :if an error is encountered, the program will stop

            MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);

            // Create a new MccBoard object for Board 0
            DaqBoard = new MccDaq.MccBoard(0);


            // Determine if board has AuxPort
            //Parameters:
            //  devNum      : 0-based digital device index
            //  portType    : return value for type of device
            int devNum   = 0;           //AuxPort is the 0th digital device, if present
            int portType = 0;

            DaqBoard.DioConfig.GetDevType(devNum, out portType);
            if (portType != (int)MccDaq.DigitalPortType.AuxPort)
            {
                // this board doesn't have an AuxPort!
                Application.Exit();
            }

            // Check if AuxPort needs configuring
            // Parameters:
            //     devNum      : 0-based digital device index
            //      mask    : bitmask indicating corresponding bit is in respecitve direction
            int inmask = 0, outmask = 0;

            DaqBoard.DioConfig.GetDInMask(devNum, out inmask);
            DaqBoard.DioConfig.GetDOutMask(devNum, out outmask);
            // only non-configurable AuxPorts have overlapping input and output masks
            if (0 == (inmask & outmask))
            {
                DaqBoard.DConfigPort(PortType, MccDaq.DigitalPortDirection.DigitalIn);
            }
        }
Exemplo n.º 7
0
        private void frmSetDigOut_Load(object sender, EventArgs e)
        {
            MccDaq.ErrorInfo ULStat;

            InitUL();

            //determine if digital port exists, its capabilities, etc
            PortType = clsDigitalIO.PORTOUT;
            NumPorts = DioProps.FindPortsOfType(DaqBoard, PortType, out ProgAbility,
                                                out PortNum, out NumBits, out FirstBit);

            if (NumPorts == 0)
            {
                lblInstruct.Text = "Board " + DaqBoard.BoardNum.ToString() +
                                   " has no compatible digital ports.";
                hsbSetDOutVal.Enabled = false;
                txtValSet.Enabled     = false;
            }
            else
            {
                // if programmable, set direction of port to output
                // configure the first port for digital output
                //  Parameters:
                //    PortNum        :the output port
                //    Direction      :sets the port for input or output

                if (ProgAbility == clsDigitalIO.PROGPORT)
                {
                    Direction = MccDaq.DigitalPortDirection.DigitalOut;
                    ULStat    = DaqBoard.DConfigPort(PortNum, Direction);
                }
                PortName         = PortNum.ToString();
                lblInstruct.Text = "Set the output value of " + PortName +
                                   " on board " + DaqBoard.BoardNum.ToString() +
                                   " using the scroll bar or enter a value in the 'Value set' box.";
                lblValSet.Text     = "Value set at " + PortName + ":";
                lblDataValOut.Text = "Value written to " + PortName + ":";
            }
        }
Exemplo n.º 8
0
        // *----------------------------------------------------------------*
        // *     Initialisation and configuration of the card               *
        // *----------------------------------------------------------------*
        /// <summary>
        /// Constructor that initialise the card
        /// </summary>
        public Card()
        {
            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.
            //              -> PrintAll  : all warnings and errorsencountered will be printed
            //              -> DontPrint : No error printing (in production)
            //     MccDaq.ErrorHandling.
            //              -> StopAll  : If an error is encountered, the program will stop
            //              -> DontStop : No stop (in production)
            ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.DontPrint, MccDaq.ErrorHandling.DontStop);

            // select the first card (the only connected)
            DaqBoard = new MccDaq.MccBoard(0);
            ULStat = DaqBoard.FlashLED();

            //  looking if the card is connected
            if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                // if no errors, configuring the card
                GlobalVariables.mode = "normal";

                // FirstPortA as output for heating control
                ULStat = DaqBoard.DConfigPort(MccDaq.DigitalPortType.FirstPortA, MccDaq.DigitalPortDirection.DigitalOut);
                ULStat = DaqBoard.DOut(MccDaq.DigitalPortType.FirstPortA, 0); // All is off at startup

                // FirstPortB as input for door and windows
                ULStat = DaqBoard.DConfigPort(MccDaq.DigitalPortType.FirstPortB, MccDaq.DigitalPortDirection.DigitalIn);
            }
            else
            {
                // if error, simulation mode and blocking the card
                GlobalVariables.mode = "simulation";
            }
        }
Exemplo n.º 9
0
        private void frmDigIn_Load(object sender, EventArgs e)
        {
            MccDaq.ErrorInfo ULStat;

            InitUL();

            //determine if digital port exists, its capabilities, etc
            PortType = clsDigitalIO.PORTIN;
            NumPorts = DioProps.FindPortsOfType(DaqBoard, PortType, out ProgAbility,
                                                out PortNum, out NumBits, out FirstBit);
            if (NumBits > 8)
            {
                NumBits = 8;
            }

            for (int i = NumBits; i < 8; ++i)
            {
                lblShowBitVal[i].Visible = false;
                lblShowBitNum[i].Visible = false;
            }

            if (NumPorts == 0)
            {
                lblInstruct.Text = "Board " + DaqBoard.BoardNum.ToString() +
                                   " has no compatible digital ports.";
            }
            else
            {
                // if programmable, set direction of port to input
                // configure the first port for digital input
                //  Parameters:
                //    PortNum        :the input port
                //    Direction      :sets the port for input or output

                if (ProgAbility == clsDigitalIO.PROGPORT)
                {
                    Direction = MccDaq.DigitalPortDirection.DigitalIn;
                    ULStat    = DaqBoard.DConfigPort(PortNum, Direction);
                }
                PortName         = PortNum.ToString();
                lblInstruct.Text = "You may change the value read by applying " +
                                   "a TTL high or TTL low to digital inputs on " + PortName +
                                   " on board " + DaqBoard.BoardNum.ToString() + ".";
                lblBitNum.Text        = "The first " + NumBits.ToString() + " bits are:";
                lblBitVal.Text        = PortName + " value read:";
                tmrReadInputs.Enabled = true;
            }
        }
Exemplo n.º 10
0
        public frmSetDigOut()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.PrintAll :all warnings and errors encountered will be printed
            //     MccDaq.ErrorHandling.StopAll   :if an error is encountered, the program will stop

            MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);

            // Create a new MccBoard object for Board 0
            DaqBoard = new MccDaq.MccBoard(0);

            //  configure FirstPortA for digital output
            //   Parameters:
            //     PortNum    :the output port
            //     Direction  :sets the port for input or output
            ULStat = DaqBoard.DConfigPort(PortNum, Direction);
        }
Exemplo n.º 11
0
        public OutputManagement()
        {
            try
            {
                ErrorInfo.ErrorCode errorCode;
                DaqBoard = new MccDaq.MccBoard(0);
                MccDaq.ErrorInfo ULStat;

                ULStat    = MccDaq.MccService.ErrHandling(ErrorReporting.DontPrint, ErrorHandling.DontStop);
                errorCode = PrintError(ULStat);

                if (ErrorInfo.ErrorCode.NoErrors == PrintError(ULStat))
                {
                    ULStat = DaqBoard.FlashLED();
                }

                if (ErrorInfo.ErrorCode.NoErrors == PrintError(ULStat))
                {
                    ULStat = DaqBoard.DConfigPort(DigitalPortType.FirstPortA, DigitalPortDirection.DigitalOut);
                }

                if (ErrorInfo.ErrorCode.NoErrors == PrintError(ULStat))
                {
                    //It take sometimes for the output to be usable;
                    Console.WriteLine("Board found");
                    Thread.Sleep(500);
                    BoardFound = true;
                    SetAllOff();
                }
            }
            catch (Exception e)
            {
                BoardFound = false;
                SimpleLogger.Logger.Log("Board not found", e);
            }
        }
Exemplo n.º 12
0
        public frmDScan()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            lblDataRead = (new Label[]{_lblDataRead_0, _lblDataRead_1, _lblDataRead_2, _lblDataRead_3, _lblDataRead_4,
                                    _lblDataRead_5, _lblDataRead_6, _lblDataRead_7, _lblDataRead_8, _lblDataRead_9});

            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.PrintAll :all warnings and errors encountered will be printed
            //     MccDaq.ErrorHandling.StopAll   :if an error is encountered, the program will stop

            MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);

            // Create a new MccBoard object for Board 0
            DaqBoard = new MccDaq.MccBoard(0);

            // set aside memory to hold data
            MemHandle = MccDaq.MccService.WinBufAlloc(NumPoints);

            //  configure FirstPortA for digital input
            //   Parameters:
            //     PortNum    :the input port
            //     Direction  :sets the port for input or output
            PortNum = MccDaq.DigitalPortType.FirstPortA;
            ULStat = DaqBoard.DConfigPort(PortNum, Direction);

            // configure FirstPortA & FirstPortB for digital input
            //   Parameters:
            //      PortNum    :the input port
            //      Direction  :sets the port for input or output
            PortNum = MccDaq.DigitalPortType.FirstPortB;
            ULStat = DaqBoard.DConfigPort(PortNum, Direction);

            Force = 0;
        }
Exemplo n.º 13
0
        const MccDaq.DigitalPortDirection Direction = MccDaq.DigitalPortDirection.DigitalOut;         //  program first digital port for output mode


        public frmSetBitOut()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            chkSetBit = (new CheckBox[] { _chkSetBit_0, _chkSetBit_1, _chkSetBit_2, _chkSetBit_3,
                                          _chkSetBit_4, _chkSetBit_5, _chkSetBit_6, _chkSetBit_7 });

            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.PrintAll :all warnings and errors encountered will be printed
            //     MccDaq.ErrorHandling.StopAll   :if an error is encountered, the program will stop

            MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);



            // Create a new MccBoard object for Board 0
            DaqBoard = new MccDaq.MccBoard(0);


            //Get the first port on the device - some devices (such as the
            //USB-ERB08 and USB-SSR08) don't have FirstPortA, but do have
            //FirstPortCL.

            //Parameters:
            //      DevNum      : 0-based digital device index
            //      FirstPort   : return value for type of device

            int DevNum    = 0;
            int FirstPort = 0;

            ULStat = DaqBoard.DioConfig.GetDevType(0, out FirstPort);

            switch (FirstPort)
            {
            case (int)MccDaq.DigitalPortType.FirstPortA:
                FirstBit = 0;
                break;

            case (int)MccDaq.DigitalPortType.FirstPortB:
                FirstBit = 8;
                break;

            case (int)MccDaq.DigitalPortType.FirstPortCL:
                FirstBit = 16;
                break;

            case (int)MccDaq.DigitalPortType.FirstPortCH:
                FirstBit = 20;
                break;

            default:
                FirstBit = 0;
                break;
            }

            //  configure the first port for digital input
            //   Parameters:
            //     PortNum    :the input port
            //     Direction  :sets the port for input or output

            PortNum = (MccDaq.DigitalPortType)FirstPort;
            ULStat  = DaqBoard.DConfigPort(PortNum, Direction);

            // if the first port is FIRSTPORTCL, configure FIRSTPORTCH, too
            if (PortNum == MccDaq.DigitalPortType.FirstPortCL)
            {
                ULStat = DaqBoard.DConfigPort(PortNum + 1, Direction);
            }
        }
Exemplo n.º 14
0
        private void frmStatusDisplay_Load(System.Object eventSender, System.EventArgs eventArgs)
        {
            int NumCntrs, NumPorts, CounterNum;
            int FirstBit;
            int ProgAbility = 0;
            int NumBits     = 0;

            MccDaq.DigitalPortType      PortNum = DigitalPortType.AuxPort;
            MccDaq.DigitalPortDirection Direction;
            MccDaq.ErrorInfo            ULStat;
            MccDaq.TriggerType          DefaultTrig;

            InitUL();

            NumCntrs = 0;
            NumPorts = 0;
            // determine the number of analog, digital, and counter channels and their capabilities
            int ChannelType = clsAnalogIO.ANALOGINPUT;

            NumAIChans = AIOProps.FindAnalogChansOfType(DaqBoard, ChannelType,
                                                        out ADResolution, out Range, out LowChan, out DefaultTrig);
            ChannelType = DigitalIO.clsDigitalIO.PORTIN;
            if (!clsErrorDefs.GeneralError)
            {
                NumPorts = DioProps.FindPortsOfType(DaqBoard, ChannelType, out ProgAbility,
                                                    out PortNum, out NumBits, out FirstBit);
            }
            ChannelType = clsCounters.CTRSCAN;
            if (!clsErrorDefs.GeneralError)
            {
                NumCntrs = CtrProps.FindCountersOfType(DaqBoard, ChannelType, out CounterNum);
            }

            if (NumCntrs == 0)
            {
                lblInstruction.Text = "Board " + DaqBoard.BoardNum.ToString() +
                                      " has no counter devices.";
                cmdStartBgnd.Enabled = false;
            }
            else if (NumAIChans == 0)
            {
                lblInstruction.Text = "Board " + DaqBoard.BoardNum.ToString() +
                                      " does not have analog input channels.";
                cmdStartBgnd.Enabled = false;
            }
            else if (NumPorts == 0)
            {
                lblInstruction.Text = "Board " + DaqBoard.BoardNum.ToString() +
                                      " has no digital devices.";
                cmdStartBgnd.Enabled = false;
            }
            else
            {
                cmdStartBgnd.Enabled = true;
                ADData        = new ushort[NumElements];
                ChanArray     = new short[ChanCount];
                ChanTypeArray = new MccDaq.ChannelType[ChanCount];
                GainArray     = new MccDaq.Range[ChanCount];
                MemHandle     = MccDaq.MccService.WinBufAllocEx(NumElements);
                if (MemHandle == IntPtr.Zero)
                {
                    this.cmdStartBgnd.Enabled = false;
                    NumAIChans = 0;
                }
                //load the arrays with values
                ChanArray[0]     = 0;
                ChanTypeArray[0] = MccDaq.ChannelType.Analog;
                GainArray[0]     = Range;

                ChanArray[1]     = System.Convert.ToInt16(PortNum);
                ChanTypeArray[1] = MccDaq.ChannelType.Digital8;
                if (NumBits == 16)
                {
                    ChanTypeArray[1] = MccDaq.ChannelType.Digital16;
                }
                GainArray[1] = MccDaq.Range.NotUsed;

                ChanArray[2]     = 0;
                ChanTypeArray[2] = MccDaq.ChannelType.Ctr32Low;
                GainArray[2]     = MccDaq.Range.NotUsed;

                ChanArray[3]     = 0;
                ChanTypeArray[3] = MccDaq.ChannelType.Ctr32High;
                GainArray[3]     = MccDaq.Range.NotUsed;

                if (ProgAbility == -1)
                {
                    //configure programmable port for digital input
                    Direction = MccDaq.DigitalPortDirection.DigitalIn;
                    ULStat    = DaqBoard.DConfigPort(PortNum, Direction);
                }

                ULStat = DaqBoard.CConfigScan(0, MccDaq.CounterMode.Bit16,
                                              MccDaq.CounterDebounceTime.DebounceNone,
                                              MccDaq.CounterDebounceMode.TriggerAfterStable,
                                              MccDaq.CounterEdgeDetection.FallingEdge,
                                              MccDaq.CounterTickSize.Tick20833pt3ns, 0);
                lblInstruction.Text = "Board " + DaqBoard.BoardNum.ToString() +
                                      " collecting analog, digital, and counter data " +
                                      " using DaqInScan with Range set to " + Range.ToString() + ".";
            }
        }
Exemplo n.º 15
0
        public int FindPortsOfType(MccDaq.MccBoard DaqBoard, int PortType,
                                   out int ProgAbility, out MccDaq.DigitalPortType DefaultPort,
                                   out int DefaultNumBits, out int FirstBit)

        {
            int   ThisType, NumPorts, NumBits;
            int   DefaultDev, InMask, OutMask;
            int   PortsFound, curCount, curIndex;
            short status;
            bool  PortIsCompatible;
            bool  CheckBitProg = false;

            MccDaq.DigitalPortType CurPort;
            MccDaq.FunctionType    DFunction;
            MccDaq.ErrorInfo       ULStat;
            string ConnectionConflict;

            ULStat = MccDaq.MccService.ErrHandling
                         (MccDaq.ErrorReporting.DontPrint, MccDaq.ErrorHandling.DontStop);

            ConnectionConflict = "This network device is in use by another process or user." +
                                 System.Environment.NewLine + System.Environment.NewLine +
                                 "Check for other users on the network and close any applications " +
                                 System.Environment.NewLine +
                                 "(such as Instacal) that may be accessing the network device.";

            DefaultPort    = (MccDaq.DigitalPortType)(-1);
            CurPort        = DefaultPort;
            PortsFound     = 0;
            FirstBit       = 0;
            ProgAbility    = -1;
            DefaultNumBits = 0;
            ULStat         = DaqBoard.BoardConfig.GetDiNumDevs(out NumPorts);
            if (!(ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors))
            {
                clsErrorDefs.DisplayError(ULStat);
                return(PortsFound);
            }

            if ((PortType == BITOUT) || (PortType == BITIN))
            {
                CheckBitProg = true;
            }
            if ((PortType == PORTOUTSCAN) || (PortType == PORTINSCAN))
            {
                if (NumPorts > 0)
                {
                    DFunction = MccDaq.FunctionType.DiFunction;
                    if (PortType == PORTOUTSCAN)
                    {
                        DFunction = MccDaq.FunctionType.DoFunction;
                    }
                    ULStat = DaqBoard.GetStatus(out status, out curCount, out curIndex, DFunction);
                    if (!(ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors))
                    {
                        NumPorts = 0;
                    }
                }
                PortType = PortType & (PORTOUT | PORTIN);
            }

            for (int DioDev = 0; DioDev < NumPorts; ++DioDev)
            {
                ProgAbility = -1;
                ULStat      = DaqBoard.DioConfig.GetDInMask(DioDev, out InMask);
                ULStat      = DaqBoard.DioConfig.GetDOutMask(DioDev, out OutMask);
                if ((InMask & OutMask) > 0)
                {
                    ProgAbility = FIXEDPORT;
                }
                ULStat = DaqBoard.DioConfig.GetDevType(DioDev, out ThisType);
                if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    CurPort = (DigitalPortType)Enum.Parse(typeof(DigitalPortType),
                                                          ThisType.ToString());
                }
                if ((DioDev == 0) && (CurPort == MccDaq.DigitalPortType.FirstPortCL))
                {
                    //a few devices (USB-SSR08 for example)
                    //start at FIRSTPORTCL and number the bits
                    //as if FIRSTPORTA and FIRSTPORTB exist for
                    //compatibiliry with older digital peripherals
                    FirstBit = 16;
                }

                //check if port is set for requested direction
                //or can be programmed for requested direction
                PortIsCompatible = false;
                switch (PortType)
                {
                case (PORTOUT):
                    if (OutMask > 0)
                    {
                        PortIsCompatible = true;
                    }
                    break;

                case (PORTIN):
                    if (InMask > 0)
                    {
                        PortIsCompatible = true;
                    }
                    break;

                default:
                    PortIsCompatible = false;
                    break;
                }
                PortType = (PortType & (PORTOUT | PORTIN));
                if (!PortIsCompatible)
                {
                    if (ProgAbility != FIXEDPORT)
                    {
                        MccDaq.DigitalPortDirection ConfigDirection;
                        ConfigDirection = DigitalPortDirection.DigitalOut;
                        if (PortType == PORTIN)
                        {
                            ConfigDirection = DigitalPortDirection.DigitalIn;
                        }
                        if ((CurPort == MccDaq.DigitalPortType.AuxPort) && CheckBitProg)
                        {
                            //if it's an AuxPort, check bit programmability
                            ULStat = DaqBoard.DConfigBit(MccDaq.DigitalPortType.AuxPort,
                                                         FirstBit, ConfigDirection);
                            if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                            {
                                //return port to input mode
                                ULStat = DaqBoard.DConfigBit(MccDaq.DigitalPortType.AuxPort,
                                                             FirstBit, DigitalPortDirection.DigitalIn);
                                ProgAbility = PROGBIT;
                            }
                            else
                            {
                                if ((ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NetDevInUseByAnotherProc) ||
                                    (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NetDevInUse))
                                {
                                    System.Windows.Forms.MessageBox.Show(ConnectionConflict, "Device In Use");
                                    break;
                                }
                            }
                        }
                        if (ProgAbility == -1)
                        {
                            //check port programmability
                            ULStat = DaqBoard.DConfigPort(CurPort, ConfigDirection);
                            if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                            {
                                //return port to input mode
                                ULStat = DaqBoard.DConfigBit(MccDaq.DigitalPortType.AuxPort,
                                                             FirstBit, DigitalPortDirection.DigitalIn);
                                ProgAbility = PROGPORT;
                            }
                            else
                            {
                                if ((ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NetDevInUseByAnotherProc) ||
                                    (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NetDevInUse))
                                {
                                    System.Windows.Forms.MessageBox.Show(ConnectionConflict, "Device In Use");
                                    break;
                                }
                            }
                        }
                    }
                    PortIsCompatible = !(ProgAbility == -1);
                }

                if (PortIsCompatible)
                {
                    PortsFound = PortsFound + 1;
                }
                int BitVals, BitWeight;
                int TotalVal, CurBit;
                if (DefaultPort == (MccDaq.DigitalPortType)(-1))
                {
                    ULStat = DaqBoard.DioConfig.GetNumBits(DioDev, out NumBits);
                    if (ProgAbility == FIXEDPORT)
                    {
                        //could have different number of input and output bits
                        CurBit   = 0;
                        TotalVal = 0;
                        BitVals  = OutMask;
                        if (PortType == PORTIN)
                        {
                            BitVals = InMask;
                        }
                        do
                        {
                            BitWeight = (int)Math.Pow(2, CurBit);
                            TotalVal  = BitWeight + TotalVal;
                            CurBit    = CurBit + 1;
                        } while (TotalVal < BitVals);
                        NumBits = CurBit;
                    }
                    DefaultNumBits = NumBits;
                    DefaultDev     = DioDev;
                    DefaultPort    = CurPort;
                }
                if (ProgAbility == PROGBIT)
                {
                    break;
                }
            }
            ULStat = MccDaq.MccService.ErrHandling
                         (clsErrorDefs.ReportError, clsErrorDefs.HandleError);
            return(PortsFound);
        }
Exemplo n.º 16
0
        public frmDigAuxOut()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.PrintAll :all warnings and errors encountered will be printed
            //     MccDaq.ErrorHandling.StopAll   :if an error is encountered, the program will stop
            MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);

            // Create a new MccBoard object for Board 0
            DaqBoard = new MccDaq.MccBoard(0);

            // Determine if board has AuxPort
            //Parameters:
            //  devNum      : 0-based digital device index
            //  portType    : return value for type of device
            int devNum =0;  //AuxPort is the 0th digital device, if present
            int portType = 0;
            DaqBoard.DioConfig.GetDevType(devNum, out portType);
            if (portType != (int)MccDaq.DigitalPortType.AuxPort)
            {
                // this board doesn't have an AuxPort!
                Application.Exit();
            }

            // Check if AuxPort needs configuring
            // Parameters:
            //     devNum      : 0-based digital device index
            //      mask    : bitmask indicating corresponding bit is in respecitve direction
            int inmask=0, outmask=0;
            DaqBoard.DioConfig.GetDInMask(devNum, out inmask);
            DaqBoard.DioConfig.GetDOutMask(devNum, out outmask);
            // only non-configurable AuxPorts have overlapping input and output masks
            if (0 == (inmask & outmask))
            {
                DaqBoard.DConfigPort(PortNum, MccDaq.DigitalPortDirection.DigitalOut);
            }
        }
Exemplo n.º 17
0
        public frmSetBitOut()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            chkSetBit = (new CheckBox[]{_chkSetBit_0, _chkSetBit_1, _chkSetBit_2, _chkSetBit_3,
                                        _chkSetBit_4, _chkSetBit_5, _chkSetBit_6, _chkSetBit_7});

            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.PrintAll :all warnings and errors encountered will be printed
            //     MccDaq.ErrorHandling.StopAll   :if an error is encountered, the program will stop

            MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);

            // Create a new MccBoard object for Board 0
            DaqBoard = new MccDaq.MccBoard(0);

              //Get the first port on the device - some devices (such as the
              //USB-ERB08 and USB-SSR08) don't have FirstPortA, but do have
              //FirstPortCL.

              //Parameters:
              //      DevNum      : 0-based digital device index
              //      FirstPort   : return value for type of device

              int DevNum = 0;
              int FirstPort = 0;
              ULStat = DaqBoard.DioConfig.GetDevType(0, out FirstPort);

              switch(FirstPort)
              {
            case (int) MccDaq.DigitalPortType.FirstPortA:
              FirstBit = 0;
              break;

            case (int) MccDaq.DigitalPortType.FirstPortB:
              FirstBit = 8;
              break;

            case (int) MccDaq.DigitalPortType.FirstPortCL:
              FirstBit = 16;
              break;

            case (int) MccDaq.DigitalPortType.FirstPortCH:
              FirstBit = 20;
              break;

            default:
              FirstBit = 0;
              break;
              }

              //  configure the first port for digital input
              //   Parameters:
              //     PortNum    :the input port
              //     Direction  :sets the port for input or output

              PortNum = (MccDaq.DigitalPortType) FirstPort;
              ULStat = DaqBoard.DConfigPort(PortNum, Direction);

              // if the first port is FIRSTPORTCL, configure FIRSTPORTCH, too
              if(PortNum == MccDaq.DigitalPortType.FirstPortCL)
            ULStat = DaqBoard.DConfigPort(PortNum + 1, Direction);
        }