public void ClearALLDigitalPort()
 {
     for (int i = 0; i != 8; i++)
     {
         DaqBoard.DBitOut(BitPort, i, DigitalLogicState.Low);
     }
 }
 public void TurnOn(int index)
 {
     relaybox.DBitOut(MccDaq.DigitalPortType.FirstPortA, index - 1, MccDaq.DigitalLogicState.High);
     Thread.Sleep(10);
     relaybox.DBitOut(MccDaq.DigitalPortType.FirstPortA, index - 1, MccDaq.DigitalLogicState.High);
     currentPumpState[index] = true;
 }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
0
        private void chkSetBit_CheckStateChanged(object eventSender, System.EventArgs eventArgs)
        {
            MccDaq.DigitalPortType PortType;

            int BitNum = Array.IndexOf(chkSetBit, eventSender);

            // 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;
            }

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

            MccDaq.ErrorInfo ULStat = DaqBoard.DBitOut(PortType, FirstBit + BitNum, BitValue);
        }
Exemplo n.º 5
0
        private void chkSetBit_CheckStateChanged(object eventSender, System.EventArgs eventArgs)
        {
            int BitNum = Array.IndexOf(chkSetBit, eventSender);

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

            MccDaq.DigitalPortType PortType = PortNum;
            MccDaq.ErrorInfo       ULStat   = DaqBoard.DBitOut(PortType, BitNum, BitValue);
            if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.BadBitNumber)
            {
                MessageBox.Show("Boards only supports bit numbers less than " + BitNum.ToString("0"), "Bit value too high", 0);
            }
        }
Exemplo n.º 6
0
 public ErrorInfo.ErrorCode Set(DigitalPortType port, int outputID, DigitalLogicState state)
 {
     lock (this)
     {
         Console.WriteLine(String.Format("port: {0}, outputID: {1}, state: {2}", port, outputID, state));
         if (!BoardFound)
         {
             return(ErrorInfo.ErrorCode.BoardNotExist);
         }
         if (port == DigitalPortType.FirstPortA && outputID >= 0 && outputID <= 7)
         {
             MccDaq.ErrorInfo ULStat;
             ULStat = DaqBoard.DBitOut(port, outputID, state);
             return(PrintError(ULStat));
         }
         else
         {
             SimpleLogger.Logger.Log("Port Not supported");
             Environment.Exit(1);
             return(ErrorInfo.ErrorCode.InvalidNetPort);
         }
     }
 }
Exemplo n.º 7
0
        private void switch_relay(object sender, EventArgs e)
        {
            if (relayBoard == null)
            {
                MessageBox.Show("Initialize a device first", "Error");
                return;
            }
            Button b           = (Button)sender;
            int    relayNumber = Convert.ToInt32(b.Tag);

            if (relayStatus[relayNumber - 1] == false)
            {
                relayStatus[relayNumber - 1] = true;
                relayBoard.DBitOut(DigitalPortType.FirstPortA, relayNumber + 15, DigitalLogicState.High);
            }
            else
            {
                relayStatus[relayNumber - 1] = false;
                relayBoard.DBitOut(DigitalPortType.FirstPortA, relayNumber + 15, DigitalLogicState.Low);
            }
        }
Exemplo n.º 8
0
        // This function turns on the heater coils according to the string
        // parameter passed to it. Usable string parameters are: "all", "0",
        // "1", "2", and "none"; "all" and "none" turn on/off all the coils,
        // while "0", "1", "2" turns on the coil corresponding to that channel
        // output from the USB-TC device.
        private void TC_channel_out(str channel)
        {
            MccBoard daq = new MccDaq.MccBoard(BoardNum);
            MccDaq.ErrorInfo RetVal;

            for (int i = 0; i < 6; i++)
            {
                RetVal = daq.DConfigBit(DigitalPortType.AuxPort, i,
                    DigitalPortDirection.DigitalOut);
                IsError(this,RetVal,true);
            }

            switch (channel)
            {
                case "all_coils":
                    for (int i = 0; i < 3; i++)
                    {
                        RetVal = daq.DBitOut(DigitalPortType.AuxPort, i,
                            DigitalLogicState.High);
                        IsError(this,RetVal, true);
                    }
                    break;

                case "no_coils":
                    for (int i = 0; i < 3; i++)
                    {
                        RetVal = daq.DBitOut(DigitalPortType.AuxPort, i,
                            DigitalLogicState.Low);
                        IsError(this,RetVal, true);
                    }
                    break;

                case "no_air":
                    for (int i = 3; i < 6; i++)
                    {
                        RetVal = daq.DBitOut(DigitalPortType.AuxPort, i,
                            DigitalLogicState.Low);
                        IsError(this,RetVal, true);
                    }
                    break;

                case "inner":
                    RetVal = daq.DBitOut(DigitalPortType.AuxPort, 0,
                        DigitalLogicState.High);
                    IsError(this,RetVal, true);
                    break;

                case "sample_zone":
                    RetVal = daq.DBitOut(DigitalPortType.AuxPort, 1,
                        DigitalLogicState.High);
                    IsError(this,RetVal, true);
                    break;

                case "outer":
                    RetVal = daq.DBitOut(DigitalPortType.AuxPort, 2,
                        DigitalLogicState.High);
                    IsError(this,RetVal, true);
                    break;

                case "high_n2":
                    RetVal = daq.DBitOut(DigitalPortType.AuxPort, 3,
                        DigitalLogicState.High);
                    IsError(this, RetVal, true);
                    break;

                case "air":
                    RetVal = daq.DBitOut(DigitalPortType.AuxPort, 4,
                        DigitalLogicState.High);
                    IsError(this, RetVal, true);
                    break;

                case "low_n2":
                    RetVal = daq.DBitOut(DigitalPortType.AuxPort, 5,
                        DigitalLogicState.High);
                    IsError(this, RetVal, true);
                    break;

                default:
                    RetVal = new ErrorInfo(1);
                    MessageBox.Show("TC_channel_out() called with invalid parameter!",
                        "   " + "ERROR!");
                    break;
            }

            RetVal = daq.DConfigBit(DigitalPortType.AuxPort, 0,
                DigitalPortDirection.DigitalOut);

            if (IsError(this, RetVal, true) == 0)
            {
                MessageBox.Show("TC_out function error!");
                return;
            }
        }
Exemplo n.º 9
0
        // This function turns on the heater coils according to the string
        // parameter passed to it. Usable string parameters are: "all", "0",
        // "1", "2", and "none"; "all" and "none" turn on/off all the coils,
        // while "0", "1", "2" turns on the coil corresponding to that channel
        // output from the USB-TC device.
        private void coils_on(string state)
        {
            MccBoard daq = new MccDaq.MccBoard(BoardNum);
            MccDaq.ErrorInfo RetVal;

            for (int i = 0; i < 3; i++)
            {
                RetVal = daq.DConfigBit(DigitalPortType.AuxPort, i,
                    DigitalPortDirection.DigitalOut);
                IsError(RetVal);
            }

            switch (state)
            {
                case "all":
                    for (int i = 0; i < 3; i++)
                    {
                        RetVal = daq.DBitOut(DigitalPortType.AuxPort, i,
                            DigitalLogicState.High);
                        IsError(RetVal);
                    }
                    break;

                case "0":
                    RetVal = daq.DBitOut(DigitalPortType.AuxPort, 0,
                        DigitalLogicState.High);
                    IsError(RetVal);
                    break;

                case "1":
                    RetVal = daq.DBitOut(DigitalPortType.AuxPort, 1,
                        DigitalLogicState.High);
                    IsError(RetVal);
                    break;

                case "2":
                    RetVal = daq.DBitOut(DigitalPortType.AuxPort, 2,
                        DigitalLogicState.High);
                    IsError(RetVal);
                    break;

                case "none":
                    for (int i = 0; i < 3; i++)
                    {
                        RetVal = daq.DBitOut(DigitalPortType.AuxPort, i,
                            DigitalLogicState.Low);
                        IsError(RetVal);
                    }
                    break;

                default:
                    MessageBox.Show("coils_on() called with invalid parameter!",
                        "   " + "ERROR!");
                    break;
            }

            RetVal = daq.DConfigBit(DigitalPortType.AuxPort, 0,
                DigitalPortDirection.DigitalOut);
            IsError(RetVal);
        }
 /// <summary>
 /// portNumber from 8-23
 /// </summary>
 /// <param name="portNumber">Port number</param>
 /// <param name="BitValue">DigitalLogicState</param>
 public void DigitOutput(int portNumber, MccDaq.DigitalLogicState BitValue)
 {
     DaqBoard.DBitOut(BitPort, portNumber, BitValue);
 }
Exemplo n.º 11
0
        private void air_channel_out(AirChanStatusEnum state)
        {
            MccBoard daq = new MccDaq.MccBoard(BoardNum);
            MccDaq.ErrorInfo RetVal;

            for (int i = 3; i < 6; i++)
            {
                RetVal = daq.DConfigBit(DigitalPortType.AuxPort, i,
                    DigitalPortDirection.DigitalOut);
                IsError(this, RetVal, true);
            }

            switch (state)
            {
                case AirChanStatusEnum.air_off:
                    for (int i = 3; i < 6; i++)
                    {
                        RetVal = daq.DBitOut(DigitalPortType.AuxPort, i,
                            DigitalLogicState.Low);
                        IsError(this, RetVal, true);
                    }
                    break;

                case AirChanStatusEnum.low_n2:
                    RetVal = daq.DBitOut(DigitalPortType.AuxPort, 5,
                        DigitalLogicState.High);
                    IsError(this, RetVal, true);
                    break;

                case AirChanStatusEnum.high_n2:
                    RetVal = daq.DBitOut(DigitalPortType.AuxPort, 3,
                        DigitalLogicState.High);
                    IsError(this, RetVal, true);
                    break;

                case AirChanStatusEnum.air:
                    RetVal = daq.DBitOut(DigitalPortType.AuxPort, 4,
                        DigitalLogicState.High);
                    IsError(this, RetVal, true);
                    break;

                default:
                    RetVal = new ErrorInfo(1);
                    MessageBox.Show("air_channel_out() called with invalid parameter!",
                        "   " + "ERROR!");
                    break;
            }

            RetVal = daq.DConfigBit(DigitalPortType.AuxPort, 0,
                DigitalPortDirection.DigitalOut);

            if (IsError(this, RetVal, true) == 0)
            {
                air_status = state;
            }
        }
Exemplo n.º 12
0
        // This function turns on the heater coils according to the string
        // parameter passed to it. Usable string parameters are: "all", "0",
        // "1", "2", and "none"; "all" and "none" turn on/off all the coils,
        // while "0", "1", "2" turns on the coil corresponding to that channel
        // output from the USB-TC device.
        private void oven_channel_out(OvenChanStatusEnum state)
        {
            MccBoard daq = new MccDaq.MccBoard(BoardNum);
            MccDaq.ErrorInfo RetVal;

            for (int i = 0; i < 3; i++)
            {
                RetVal = daq.DConfigBit(DigitalPortType.AuxPort, i,
                    DigitalPortDirection.DigitalOut);
                IsError(this,RetVal,true);
            }

            switch (state)
            {
                case OvenChanStatusEnum.oven_on:
                    for (int i = 0; i < 3; i++)
                    {
                        RetVal = daq.DBitOut(DigitalPortType.AuxPort, i,
                            DigitalLogicState.High);
                        IsError(this,RetVal, true);
                    }
                    break;

                case OvenChanStatusEnum.oven_off:
                    for (int i = 0; i < 3; i++)
                    {
                        RetVal = daq.DBitOut(DigitalPortType.AuxPort, i,
                            DigitalLogicState.Low);
                        IsError(this,RetVal, true);
                    }
                    break;

                case OvenChanStatusEnum.all_off:
                    for (int i = 0; i < 3; i++)
                    {
                        RetVal = daq.DBitOut(DigitalPortType.AuxPort, i,
                            DigitalLogicState.Low);
                        IsError(this,RetVal, true);
                    }
                    break;

                case OvenChanStatusEnum.inner:
                    RetVal = daq.DBitOut(DigitalPortType.AuxPort, 0,
                        DigitalLogicState.High);
                    IsError(this,RetVal, true);
                    break;

                case OvenChanStatusEnum.SZ:
                    RetVal = daq.DBitOut(DigitalPortType.AuxPort, 1,
                        DigitalLogicState.High);
                    IsError(this,RetVal, true);
                    break;

                case OvenChanStatusEnum.outer:
                    RetVal = daq.DBitOut(DigitalPortType.AuxPort, 2,
                        DigitalLogicState.High);
                    IsError(this,RetVal, true);
                    break;

                default:
                    RetVal = new ErrorInfo(1);
                    MessageBox.Show("oven_channel_out() called with invalid parameter!",
                        "   " + "ERROR!");
                    break;
            }

            RetVal = daq.DConfigBit(DigitalPortType.AuxPort, 0,
                DigitalPortDirection.DigitalOut);

            if (IsError(this, RetVal, true) == 0)
            {
                oven_status = state;
                SetHeatingElementStatus(state);
            }
        }