/// <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);
 }
예제 #2
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;
        }
예제 #3
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.";
            }
        }
예제 #4
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;
            }
        }
예제 #5
0
        private void frmEventDisplay_Load(object sender, EventArgs e)
        {
            MccDaq.ErrorInfo ULStat;
            int PortType, EventMask;

            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);
            EventMask = clsEventSupport.INTEVENT;
            NumEvents = SupportedEvents.FindEventsOfType(DaqBoard, EventMask);
            if (NumPorts == 0)
            {
                lblInstruct.Text = "There are no compatible digital ports on board " +
                                   DaqBoard.BoardNum.ToString() + ".";
            }
            else if (!(EventMask == NumEvents))
            {
                this.lblInstruct.Text = "Board " +
                                        DaqBoard.BoardNum.ToString() +
                                        " doesn't support the specified event types.";
            }
            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 = "Trigger events by supplying a TTL " +
                                   "pulse on the interrupt input of board " +
                                   DaqBoard.BoardNum.ToString() + ". A read of digital inputs on "
                                   + PortName + " is done every " + _updateSize.ToString()
                                   + " interrupts.";
                this.cmdDisableEvent.Enabled = true;
                this.cmdEnableEvent.Enabled  = true;
            }
        }
예제 #6
0
        private void frmDigIn_Load(object sender, EventArgs e)
        {
            string PortName, BitName;

            MccDaq.ErrorInfo ULStat;

            InitUL();

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

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

                Direction        = MccDaq.DigitalPortDirection.DigitalIn;
                ULStat           = DaqBoard.DConfigBit(PortNum, FirstBit, Direction);
                PortName         = PortNum.ToString();
                BitName          = FirstBit.ToString();
                lblInstruct.Text = "You may change the bit state by applying a TTL high " +
                                   "or a TTL low to the corresponding pin on " + PortName + ", bit " +
                                   BitName + " on board " + DaqBoard.BoardNum.ToString() + ".";
                tmrReadInputs.Enabled = true;
            }
        }
예제 #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 + ":";
            }
        }
예제 #8
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() + ".";
            }
        }