Exemplo n.º 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();
        }
Exemplo n.º 2
0
        // This is the tuning function
        public void tuning()
        {
            try
            {
                while (stop_check != 1)
                {
                    MccBoard         daq = new MccDaq.MccBoard(BoardNum);
                    MccDaq.ErrorInfo RetVal;

                    DigitalLogicState[] TuneData = new DigitalLogicState[MAX_CHANCOUNT];

                    Update_Freeze update_freeze_del = new
                                                      Update_Freeze(tuning_helper);

                    for (int i = 0; i < MAX_CHANCOUNT; i++)
                    {
                        RetVal = daq.DConfigBit(DigitalPortType.AuxPort, i, DigitalPortDirection.DigitalIn);
                        RetVal = daq.DBitIn(DigitalPortType.AuxPort, i, out TuneData[i]);
                    }

                    Invoke(update_freeze_del, TuneData);

                    Thread.Sleep(500);
                }

                return;
            }
            catch
            {
                return;
            }
        }
 /// <summary>
 /// portNumber from 0-7
 /// </summary>
 /// <param name="portNumber">port number</param>
 /// <returns>return int type which 1 express High and 0 express Low</returns>
 public int DigitInput(int portNumber)
 {
     MccDaq.DigitalLogicState bitValue;
     MccDaq.ErrorInfo         ULStat = DaqBoard.DBitIn(BitPort, portNumber, out bitValue);
     if (bitValue == DigitalLogicState.High)
     {
         return(1);
     }
     else
     {
         return(0);
     }
 }
Exemplo n.º 4
0
        private void tmrReadInputs_Tick(object eventSender, System.EventArgs eventArgs)         /* Handles tmrReadInputs.Tick */
        {
            tmrReadInputs.Stop();

            //  read a single bit status from the digital port

            //   Parameters:
            //     PortType   :the digital I/O port type
            //     BitNum     :the bit to read
            //     BitValue   :the value read from the port
            MccDaq.DigitalLogicState BitValue;
            MccDaq.ErrorInfo         ULStat = DaqBoard.DBitIn(PortType, BitNum, out BitValue);

            lblBitNum.Text = "Bit number " + BitNum + " state is " + BitValue.ToString();

            tmrReadInputs.Start();
        }
Exemplo n.º 5
0
        private void tmrReadInputs_Tick(object eventSender, System.EventArgs eventArgs)         /* Handles tmrReadInputs.Tick */
        {
            tmrReadInputs.Stop();
            MccDaq.DigitalPortType PortType;

            MccDaq.DigitalLogicState BitValue;
            int BitNum;

            MccDaq.ErrorInfo ULStat;
            for (short i = 0; i < MaxBits; ++i)
            {
                // For boards whose first port is not FIRSTPORTA (such as the USB-ERB08
                // and the USB-SSR08) offset the BitNum by FirstBit

                if (PortNum == MccDaq.DigitalPortType.AuxPort)
                {
                    PortType = MccDaq.DigitalPortType.AuxPort;
                }
                else
                {
                    PortType = MccDaq.DigitalPortType.FirstPortA;
                }

                //  read the bits of FirstPortA digital input and display

                //   Parameters:
                //     PortType    :the type of port
                //     BitNum     :the number of the bit to read from the port
                //     BitValue   :the value read from the port
                BitNum = i;

                ULStat = DaqBoard.DBitIn(PortType, FirstBit + BitNum, out BitValue);

                lblShowBitVal[i].Text = Convert.ToInt32(BitValue).ToString("0");
            }

            tmrReadInputs.Start();
        }
Exemplo n.º 6
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();
        }
Exemplo n.º 7
0
        private void tmrReadInputs_Tick(object eventSender, System.EventArgs eventArgs)         /* Handles tmrReadInputs.Tick */
        {
            tmrReadInputs.Stop();

            // so invalid bit numbers can be handled locally.
            MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.DontPrint, MccDaq.ErrorHandling.StopAll);

            int BitNum;

            MccDaq.DigitalLogicState BitValue;
            for (int i = 0; i <= 7; ++i)
            {
                //  read the bits of AuxPort digital input and display

                //   Parameters:
                //     PortType    :the type of port
                //     BitNum     :the number of the bit to read from the port
                //     BitValue   :the value read from the port
                BitNum = i;
                ULStat = DaqBoard.DBitIn(PortType, BitNum, out BitValue);
                if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    lblShowBitVal[i].Text = Convert.ToInt32(BitValue).ToString("0");
                }
                else if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.BadBitNumber)
                {
                    lblShowBitVal[i].Text = "X";                     // Trap invalid bit numbers
                }
                else
                {
                    throw(new System.Exception());
                }
            }

            tmrReadInputs.Start();
        }
        // This is the tuning function
        public void tuning()
        {
            try
            {
                while (stop_check != 1)
                {
                    MccBoard daq = new MccDaq.MccBoard(BoardNum);
                    MccDaq.ErrorInfo RetVal;

                    DigitalLogicState[] TuneData = new DigitalLogicState[MAX_CHANCOUNT];

                    Update_Freeze update_freeze_del = new
                        Update_Freeze(tuning_helper);

                    for (int i = 0; i < MAX_CHANCOUNT; i++)
                    {
                        RetVal = daq.DConfigBit(DigitalPortType.AuxPort, i, DigitalPortDirection.DigitalIn);
                        RetVal = daq.DBitIn(DigitalPortType.AuxPort, i, out TuneData[i]);
                    }

                    Invoke(update_freeze_del, TuneData);

                    Thread.Sleep(500);
                }

                return;
            }
            catch
            {
                return;
            }
        }