示例#1
0
        private void tmrReadInputs_Tick(object eventSender, System.EventArgs eventArgs) /* Handles tmrReadInputs.Tick */
        {
            MccDaq.DigitalPortType BitPort;
            string PortName, BitName;

            tmrReadInputs.Stop();

            //  read a single bit status from the digital port

            //   Parameters:
            //     PortNum    :the digital I/O port type (must be
            //                 AUXPORT or FIRSTPORTA for bit read)
            //     BitNum     :the bit to read
            //     BitValue   :the value read from the port

            BitPort = DigitalPortType.AuxPort;
            if (PortNum > BitPort)
            {
                BitPort = DigitalPortType.FifthPortA;
            }
            MccDaq.DigitalLogicState BitValue;
            MccDaq.ErrorInfo         ULStat = DaqBoard.DBitIn(BitPort, FirstBit, out BitValue);

            PortName       = BitPort.ToString();
            BitName        = FirstBit.ToString();
            lblBitNum.Text = "The state of " + PortName + " bit " + BitName
                             + " is " + BitValue.ToString();

            tmrReadInputs.Start();
        }
示例#2
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;
            }
        }
示例#3
0
        private void tmrReadInputs_Tick(object eventSender, System.EventArgs eventArgs)
        {
            tmrReadInputs.Stop();
            string PortName;
            int    LastBit;

            int BitNum;

            MccDaq.DigitalLogicState BitValue;
            MccDaq.DigitalPortType   BitPort;

            BitPort = DigitalPortType.AuxPort;
            BitNum  = FirstBit;
            if (PortNum > BitPort)
            {
                BitPort = DigitalPortType.FirstPortA;
            }
            for (int i = 0; i < NumBits; ++i)
            {
                //  read the bits of digital input and display

                //   Parameters:
                //     PortNum    :the type of port (must be AUXPORT
                //                 or FIRSTPORTA for bit input)
                //     BitNum     :the number of the bit to read from the port
                //     BitValue   :the value read from the port

                BitNum = FirstBit + i;
                MccDaq.ErrorInfo ULStat = DaqBoard.DBitIn(BitPort, BitNum, out BitValue);
                lblShowBitVal[i].Text = Convert.ToInt32(BitValue).ToString("0");
            }
            PortName       = BitPort.ToString();
            LastBit        = (FirstBit + NumBits) - 1;
            lblBitVal.Text = PortName + ", bit " + FirstBit.ToString() +
                             " - " + LastBit.ToString() + " values:";
            tmrReadInputs.Start();
        }