示例#1
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;
            }
        }
示例#2
0
        const MccDaq.DigitalPortDirection Direction = MccDaq.DigitalPortDirection.DigitalIn; //  program port for input mode

        public frmDigIn()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.PrintAll :all warnings and errors encountered will be printed
            //     MccDaq.ErrorHandling.StopAll   :if an error is encountered, the program will stop

            MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);



            // Create a new MccBoard object for Board 0
            DaqBoard = new MccDaq.MccBoard(0);

            // Determine if board has AuxPort
            //Parameters:
            //  devNum      : 0-based digital device index
            //  portType    : return value for type of device
            int devNum   = 0;           //AuxPort is the 0th digital device, if present
            int portType = 0;

            DaqBoard.DioConfig.GetDevType(devNum, out portType);
            if (portType != (int)MccDaq.DigitalPortType.AuxPort)
            {
                // this board doesn't have an AuxPort!
                Application.Exit();
            }

            // Check if AuxPort needs configuring
            // Parameters:
            //     devNum      : 0-based digital device index
            //      mask    : bitmask indicating corresponding bit is in respecitve direction
            int inmask = 0, outmask = 0;

            DaqBoard.DioConfig.GetDInMask(devNum, out inmask);
            DaqBoard.DioConfig.GetDOutMask(devNum, out outmask);
            // only non-configurable AuxPorts have overlapping input and output masks
            if (0 == (inmask & outmask))
            {
                //  configure a single bit for input or output
                //   Parameters:
                //     PortType   :the port for which to configure the bit
                //     BitNum     :the bit to configure
                //     Direction  :sets the bit for input or output
                ULStat = DaqBoard.DConfigBit(PortType, BitNum, Direction);
            }
        }
示例#3
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;
            }
        }
        // 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;
            }
        }
示例#5
0
        public int FindPortsOfType(MccDaq.MccBoard DaqBoard, int PortType,
                                   out int ProgAbility, out MccDaq.DigitalPortType DefaultPort,
                                   out int DefaultNumBits, out int FirstBit)

        {
            int   ThisType, NumPorts, NumBits;
            int   DefaultDev, InMask, OutMask;
            int   PortsFound, curCount, curIndex;
            short status;
            bool  PortIsCompatible;
            bool  CheckBitProg = false;

            MccDaq.DigitalPortType CurPort;
            MccDaq.FunctionType    DFunction;
            MccDaq.ErrorInfo       ULStat;
            string ConnectionConflict;

            ULStat = MccDaq.MccService.ErrHandling
                         (MccDaq.ErrorReporting.DontPrint, MccDaq.ErrorHandling.DontStop);

            ConnectionConflict = "This network device is in use by another process or user." +
                                 System.Environment.NewLine + System.Environment.NewLine +
                                 "Check for other users on the network and close any applications " +
                                 System.Environment.NewLine +
                                 "(such as Instacal) that may be accessing the network device.";

            DefaultPort    = (MccDaq.DigitalPortType)(-1);
            CurPort        = DefaultPort;
            PortsFound     = 0;
            FirstBit       = 0;
            ProgAbility    = -1;
            DefaultNumBits = 0;
            ULStat         = DaqBoard.BoardConfig.GetDiNumDevs(out NumPorts);
            if (!(ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors))
            {
                clsErrorDefs.DisplayError(ULStat);
                return(PortsFound);
            }

            if ((PortType == BITOUT) || (PortType == BITIN))
            {
                CheckBitProg = true;
            }
            if ((PortType == PORTOUTSCAN) || (PortType == PORTINSCAN))
            {
                if (NumPorts > 0)
                {
                    DFunction = MccDaq.FunctionType.DiFunction;
                    if (PortType == PORTOUTSCAN)
                    {
                        DFunction = MccDaq.FunctionType.DoFunction;
                    }
                    ULStat = DaqBoard.GetStatus(out status, out curCount, out curIndex, DFunction);
                    if (!(ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors))
                    {
                        NumPorts = 0;
                    }
                }
                PortType = PortType & (PORTOUT | PORTIN);
            }

            for (int DioDev = 0; DioDev < NumPorts; ++DioDev)
            {
                ProgAbility = -1;
                ULStat      = DaqBoard.DioConfig.GetDInMask(DioDev, out InMask);
                ULStat      = DaqBoard.DioConfig.GetDOutMask(DioDev, out OutMask);
                if ((InMask & OutMask) > 0)
                {
                    ProgAbility = FIXEDPORT;
                }
                ULStat = DaqBoard.DioConfig.GetDevType(DioDev, out ThisType);
                if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    CurPort = (DigitalPortType)Enum.Parse(typeof(DigitalPortType),
                                                          ThisType.ToString());
                }
                if ((DioDev == 0) && (CurPort == MccDaq.DigitalPortType.FirstPortCL))
                {
                    //a few devices (USB-SSR08 for example)
                    //start at FIRSTPORTCL and number the bits
                    //as if FIRSTPORTA and FIRSTPORTB exist for
                    //compatibiliry with older digital peripherals
                    FirstBit = 16;
                }

                //check if port is set for requested direction
                //or can be programmed for requested direction
                PortIsCompatible = false;
                switch (PortType)
                {
                case (PORTOUT):
                    if (OutMask > 0)
                    {
                        PortIsCompatible = true;
                    }
                    break;

                case (PORTIN):
                    if (InMask > 0)
                    {
                        PortIsCompatible = true;
                    }
                    break;

                default:
                    PortIsCompatible = false;
                    break;
                }
                PortType = (PortType & (PORTOUT | PORTIN));
                if (!PortIsCompatible)
                {
                    if (ProgAbility != FIXEDPORT)
                    {
                        MccDaq.DigitalPortDirection ConfigDirection;
                        ConfigDirection = DigitalPortDirection.DigitalOut;
                        if (PortType == PORTIN)
                        {
                            ConfigDirection = DigitalPortDirection.DigitalIn;
                        }
                        if ((CurPort == MccDaq.DigitalPortType.AuxPort) && CheckBitProg)
                        {
                            //if it's an AuxPort, check bit programmability
                            ULStat = DaqBoard.DConfigBit(MccDaq.DigitalPortType.AuxPort,
                                                         FirstBit, ConfigDirection);
                            if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                            {
                                //return port to input mode
                                ULStat = DaqBoard.DConfigBit(MccDaq.DigitalPortType.AuxPort,
                                                             FirstBit, DigitalPortDirection.DigitalIn);
                                ProgAbility = PROGBIT;
                            }
                            else
                            {
                                if ((ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NetDevInUseByAnotherProc) ||
                                    (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NetDevInUse))
                                {
                                    System.Windows.Forms.MessageBox.Show(ConnectionConflict, "Device In Use");
                                    break;
                                }
                            }
                        }
                        if (ProgAbility == -1)
                        {
                            //check port programmability
                            ULStat = DaqBoard.DConfigPort(CurPort, ConfigDirection);
                            if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                            {
                                //return port to input mode
                                ULStat = DaqBoard.DConfigBit(MccDaq.DigitalPortType.AuxPort,
                                                             FirstBit, DigitalPortDirection.DigitalIn);
                                ProgAbility = PROGPORT;
                            }
                            else
                            {
                                if ((ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NetDevInUseByAnotherProc) ||
                                    (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NetDevInUse))
                                {
                                    System.Windows.Forms.MessageBox.Show(ConnectionConflict, "Device In Use");
                                    break;
                                }
                            }
                        }
                    }
                    PortIsCompatible = !(ProgAbility == -1);
                }

                if (PortIsCompatible)
                {
                    PortsFound = PortsFound + 1;
                }
                int BitVals, BitWeight;
                int TotalVal, CurBit;
                if (DefaultPort == (MccDaq.DigitalPortType)(-1))
                {
                    ULStat = DaqBoard.DioConfig.GetNumBits(DioDev, out NumBits);
                    if (ProgAbility == FIXEDPORT)
                    {
                        //could have different number of input and output bits
                        CurBit   = 0;
                        TotalVal = 0;
                        BitVals  = OutMask;
                        if (PortType == PORTIN)
                        {
                            BitVals = InMask;
                        }
                        do
                        {
                            BitWeight = (int)Math.Pow(2, CurBit);
                            TotalVal  = BitWeight + TotalVal;
                            CurBit    = CurBit + 1;
                        } while (TotalVal < BitVals);
                        NumBits = CurBit;
                    }
                    DefaultNumBits = NumBits;
                    DefaultDev     = DioDev;
                    DefaultPort    = CurPort;
                }
                if (ProgAbility == PROGBIT)
                {
                    break;
                }
            }
            ULStat = MccDaq.MccService.ErrHandling
                         (clsErrorDefs.ReportError, clsErrorDefs.HandleError);
            return(PortsFound);
        }
        // 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);
        }
        // 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;
            }
        }
        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;
            }
        }
        // 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);
            }
        }
示例#10
0
文件: ULDI06.cs 项目: otoauler/sdkpub
        public frmDigIn()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.PrintAll :all warnings and errors encountered will be printed
            //     MccDaq.ErrorHandling.StopAll   :if an error is encountered, the program will stop

            MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);

            // Create a new MccBoard object for Board 0
            DaqBoard = new MccDaq.MccBoard(0);

            // Determine if board has AuxPort
            //Parameters:
            //  devNum      : 0-based digital device index
            //  portType    : return value for type of device
            int devNum =0;  //AuxPort is the 0th digital device, if present
            int portType = 0;
            DaqBoard.DioConfig.GetDevType(devNum, out portType);
            if (portType != (int)MccDaq.DigitalPortType.AuxPort)
            {
                // this board doesn't have an AuxPort!
                Application.Exit();
            }

            // Check if AuxPort needs configuring
            // Parameters:
            //     devNum      : 0-based digital device index
            //      mask    : bitmask indicating corresponding bit is in respecitve direction
            int inmask=0, outmask=0;
            DaqBoard.DioConfig.GetDInMask(devNum, out inmask);
            DaqBoard.DioConfig.GetDOutMask(devNum, out outmask);
            // only non-configurable AuxPorts have overlapping input and output masks
            if (0 == (inmask & outmask))
            {

                //  configure a single bit for input or output
                //   Parameters:
                //     PortType   :the port for which to configure the bit
                //     BitNum     :the bit to configure
                //     Direction  :sets the bit for input or output
                ULStat = DaqBoard.DConfigBit(PortType, BitNum, Direction);
            }
        }