示例#1
0
        private void chkSetBit_CheckStateChanged(object eventSender, System.EventArgs eventArgs)
        {
            string PortName;
            int    BitNum = Array.IndexOf(chkSetBit, eventSender);

            MccDaq.DigitalPortType BitPort;

            MccDaq.DigitalLogicState BitValue = MccDaq.DigitalLogicState.Low;
            if (chkSetBit[BitNum].Checked)
            {
                BitValue = MccDaq.DigitalLogicState.High;
            }

            //the port must be AuxPort or FirstPortA for bit output
            BitPort = MccDaq.DigitalPortType.AuxPort;
            if (PortNum > MccDaq.DigitalPortType.AuxPort)
            {
                BitPort = MccDaq.DigitalPortType.FirstPortA;
            }

            MccDaq.ErrorInfo ULStat = DaqBoard.DBitOut(BitPort, FirstBit + BitNum, BitValue);

            PortName = BitPort.ToString();
            int BitSet = FirstBit + BitNum;

            lblValueSet.Text = PortName + ", bit " + BitSet.ToString()
                               + " value set to " + BitValue.ToString();
        }
示例#2
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();
        }
示例#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();
        }