示例#1
0
        private void PrintExpInfo(MccDaq.MccBoard pBoard)
        {
            //  Get the number of Exps attached to pBoard
            int numEXPs = 0;

            MccDaq.ErrorInfo ULStat = pBoard.BoardConfig.GetNumExps(out numEXPs);

            int BoardType = 0;
            int ADChan1   = 0;
            int ADChan2   = 0;

            for (int expNum = 0; expNum < numEXPs; ++expNum)
            {
                pBoard.ExpansionConfig.GetBoardType(expNum, out BoardType);
                pBoard.ExpansionConfig.GetMuxAdChan1(expNum, out ADChan1);

                if (BoardType == 770)
                {
                    // it's a CIO-EXP32
                    pBoard.ExpansionConfig.GetMuxAdChan2(expNum, out ADChan2);
                    Info += "     A/D channels " + ADChan1.ToString("0") + " and " + ADChan2.ToString("0") + " connected to EXP(devID=" + BoardType.ToString("0") + ")." + LF;
                }
                else
                {
                    Info += "     A/D channel " + ADChan1.ToString("0") + " connected to EXP(devID=" + BoardType.ToString("0") + ")." + LF;
                }
            }

            if (Info.Length != 0)
            {
                Info += LF;
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="boardNum">You can set the board number in Instacal</param>
 public PortControl(int boardNum)
 {
     InitUL();
     AcutalRange     = Range.Bip2Volts;
     DaqBoard        = new MccDaq.MccBoard(boardNum);
     IsCorrectCreate = DaqBoard.BoardNum.ToString();
 }
示例#3
0
文件: ULCT01.cs 项目: otoauler/sdkpub
        MccDaq.CounterRegister RegName = MccDaq.CounterRegister.LoadReg1; //  register name of counter 1

        #endregion Fields

        #region Constructors

        public frmCountTest()
        {
            // 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);

            //  Configure the counter for desired operation
            //   Parameters:
            //     CounterNum :the counter to be setup
            //     Config     :the operation mode of counter to be configured
            MccDaq.C8254Mode Config = MccDaq.C8254Mode.HighOnLastCount;
            ULStat = DaqBoard.C8254Config(CounterNum, Config);

            //  Send a starting value to the counter with MccDaq.MccBoard.CLoad()
            //   Parameters:
            //     RegName    :the register for loading the counter with the starting value
            //     LoadValue  :the starting value to place in the counter
            int LoadValue = 1000;
            ULStat = DaqBoard.CLoad(RegName, LoadValue);

            lblCountLoaded.Text = "Counter starting value loaded:";
            lblShowLoadVal.Text = LoadValue.ToString("0");
        }
示例#4
0
文件: ULCT04.cs 项目: otoauler/sdkpub
        // chip on CIO-CTR10
        public frm9513Freq()
        {
            // 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);

            //  Initialize the board level features
            //   Parameters:
            //     ChipNum    :chip to be initialized (1 for CTR5, 1 or 2 for CTR10)
            //     FOutDivider:the F-Out divider (0-15)
            //     Source     :the signal source for F-Out
            //     Compare1   :status of comparator 1
            //     Compare2   :status of comparator 2
            //     TimeOfDay  :time of day mode control
            short FOutDivider = 1; //  sets up OSC OUT for 10kHz signal which can
            MccDaq.CounterSource Source = MccDaq.CounterSource.Freq3; //  be used as frequency source for this example
            MccDaq.CompareValue Compare1 = MccDaq.CompareValue.Disabled;
            MccDaq.CompareValue Compare2 = MccDaq.CompareValue.Disabled;
            MccDaq.TimeOfDay TimeOfDayCounting = MccDaq.TimeOfDay.Disabled;
            ULStat = DaqBoard.C9513Init(ChipNum, FOutDivider, Source, Compare1, Compare2, TimeOfDayCounting);
        }
示例#5
0
        private void PrintGenInfo(MccDaq.MccBoard pBoard)
        {
            // Get board type of each board
            int BoardType = 0;

            MccDaq.ErrorInfo ULStat = pBoard.BoardConfig.GetBoardType(out BoardType);

            if (BoardType > 0)             // If a board is installed
            {
                // Get the board's name
                BoardName = pBoard.BoardName;

                BoardName = BoardName.TrimEnd();                        // Drop the space characters
                int StringSize = BoardName.Length - 1;                  // Drop the null character at end of string

                BoardName = BoardName.Substring(0, StringSize);
                Info     += "Board #" + pBoard.BoardNum.ToString("0") + " = " + BoardName + " at ";

                // Get the board's base address
                int baseAdr = 0;
                ULStat = pBoard.BoardConfig.GetBaseAdr(0, out baseAdr);

                Info += "Base Address = " + baseAdr.ToString("X") + " hex." + LF + LF;
            }
        }
示例#6
0
 /// <summary>
 /// 自定义Board个数,并初始化
 /// </summary>
 /// <param name="NumOfBoard">初始化的个数</param>
 public MyMccDaq(int NumOfBoard)
 {
     for (int i = 0; i != NumOfBoard; i++)
     {
         DaqBoard[i] = new MccDaq.MccBoard();
     }
 }
示例#7
0
        private int MemHandle = 0; //  define a variable to contain the handle for memory allocated

        #endregion Fields

        #region Constructors

        //  by Windows through MccDaq.MccService.WinBufAlloc()
        public frmDataDisplay()
        {
            MccDaq.ErrorInfo ULStat;

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

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

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

            // Allocate memory buffer to hold data..
            MemHandle = MccDaq.MccService.WinBufAlloc32(NumPoints); //  set aside memory to hold data

            //  This gives us access to labels via an indexed array
            lblCounterData = (new Label[] {this._lblCounterData_0, this._lblCounterData_1, this._lblCounterData_2, this._lblCounterData_3, this._lblCounterData_4});
        }
示例#8
0
文件: ULCT04.cs 项目: r4forth/sdkpub
        const short ChipNum = 1;                // use chip 1 for CIO-CTR05 or for first
        // chip on CIO-CTR10

        public frm9513Freq()
        {
            // 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);


            //  Initialize the board level features
            //   Parameters:
            //     ChipNum    :chip to be initialized (1 for CTR5, 1 or 2 for CTR10)
            //     FOutDivider:the F-Out divider (0-15)
            //     Source     :the signal source for F-Out
            //     Compare1   :status of comparator 1
            //     Compare2   :status of comparator 2
            //     TimeOfDay  :time of day mode control
            short FOutDivider = 1;                                               //  sets up OSC OUT for 10kHz signal which can

            MccDaq.CounterSource Source            = MccDaq.CounterSource.Freq3; //  be used as frequency source for this example
            MccDaq.CompareValue  Compare1          = MccDaq.CompareValue.Disabled;
            MccDaq.CompareValue  Compare2          = MccDaq.CompareValue.Disabled;
            MccDaq.TimeOfDay     TimeOfDayCounting = MccDaq.TimeOfDay.Disabled;
            ULStat = DaqBoard.C9513Init(ChipNum, FOutDivider, Source, Compare1, Compare2, TimeOfDayCounting);
        }
示例#9
0
文件: ULCT07.cs 项目: otoauler/sdkpub
        public frmCountTest()
        {
            // 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);

            //  Send a starting value to the counter with MccDaq.MccBoard.CLoad()
            //   Parameters:
            //     RegName    :the counter register to be loading with the starting value
            //     LoadValue  :the starting value to place in the counter
            int LoadValue = 0;	//Event Counters can only be reset to 0
            MccDaq.CounterRegister RegName = MccDaq.CounterRegister.LoadReg1; //  register name of counter 1
            ULStat = DaqBoard.CLoad32(RegName, LoadValue);

            lblCountLoaded.Text = "Counter starting value loaded:";
            lblShowLoadVal.Text = LoadValue.ToString("0");
        }
示例#10
0
        public frmCountTest()
        {
            // 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);

            //  Send a starting value to the counter with MccDaq.MccBoard.CLoad()
            //   Parameters:
            //     RegName    :the counter register to be loading with the starting value
            //     LoadValue  :the starting value to place in the counter
            int LoadValue = 0;                                                //Event Counters can only be reset to 0

            MccDaq.CounterRegister RegName = MccDaq.CounterRegister.LoadReg1; //  register name of counter 1
            ULStat = DaqBoard.CLoad32(RegName, LoadValue);



            lblCountLoaded.Text = "Counter starting value loaded:";
            lblShowLoadVal.Text = LoadValue.ToString("0");
        }
示例#11
0
        private int MemHandle      = 0;                   //  define a variable to contain the handle for memory allocated
        //  by Windows through MccDaq.MccService.WinBufAlloc()

        public frmDataDisplay()
        {
            MccDaq.ErrorInfo ULStat;

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

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


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

            // Allocate memory buffer to hold data..
            MemHandle = MccDaq.MccService.WinBufAlloc32(NumPoints);             //  set aside memory to hold data


            //  This gives us access to labels via an indexed array
            lblCounterData = (new Label[] { this._lblCounterData_0, this._lblCounterData_1, this._lblCounterData_2, this._lblCounterData_3 });
        }
示例#12
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;
            }
        }
示例#13
0
        public frmManualConvert()
        {
            // 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);

            // Get the resolution of A/D
            int ADRes;

            DaqBoard.BoardConfig.GetAdResolution(out ADRes);

            // check If the resolution of A/D is higher than 16 bit.
            // If it is, then the A/D is high resolution.
            if (ADRes > 16)
            {
                HighResAD = true;
            }

            lblGainCode.Text    = "BIP5VOLTS";          // initialize gain
            lblGainCodeVal.Text = MccDaq.Range.Bip5Volts.ToString("D");
            lblMinVal.Text      = "-5";
            lblMaxVal.Text      = "5";
        }
示例#14
0
        private void initialize_device_Click(object sender, EventArgs e)
        {
            relayBoard = new MccDaq.MccBoard(0);
            errorInfo = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.DontStop);

            board_name.Text = relayBoard.BoardName;
        }
示例#15
0
文件: ULAO02.cs 项目: otoauler/sdkpub
        private int MemHandle = 0; //  define a variable to contain the handle for

        #endregion Fields

        #region Constructors

        public frmSendAData()
        {
            // 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);

            MemHandle = MccDaq.MccService.WinBufAlloc(NumPoints); //  set aside memory to hold data

            //generate waveform
            ushort FScale =0;
            DaqBoard.FromEngUnits(MccDaq.Range.Bip5Volts, 5.0f, out FScale);
            for (int i=0; i<=NumPoints - 1; ++i)
                DAData[i] = Convert.ToUInt16((i * FScale)/NumPoints);

            //move waveform to buffer
            FirstPoint = 0;
            ULStat = MccDaq.MccService.WinArrayToBuf( ref DAData[0], MemHandle, FirstPoint, NumPoints);

            lblAOutData = (new Label[]{_lblAOutData_0, _lblAOutData_1});
        }
示例#16
0
        private int MemHandle;                                  //  define a variable to contain the handle for
        //  memory allocated by Windows through MccDaq.MccService.WinBufAlloc()


        public frmDataDisplay()
        {
            // 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);

            //  set aside memory to hold data
            MemHandle = MccDaq.MccService.WinBufAlloc(NumPoints);


            lblADData = (new Label[] { _lblADData_0, _lblADData_1, _lblADData_2, _lblADData_3,
                                       _lblADData_4, _lblADData_5, _lblADData_6, _lblADData_7 });
        }
示例#17
0
        private void initialize_device_Click(object sender, EventArgs e)
        {
            relayBoard = new MccDaq.MccBoard(0);
            errorInfo  = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.DontStop);

            board_name.Text = relayBoard.BoardName;
        }
示例#18
0
        const MccDaq.DigitalPortDirection Direction = MccDaq.DigitalPortDirection.DigitalIn; //  set direction of port to input


        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);

            //  configure FirstPortA for digital input
            //   Parameters:
            //     PortNum    :the input port
            //     Direction :sets the port for input or output
            ULStat = DaqBoard.DConfigPort(PortNum, Direction);


            lblBitNum = (new Label[] { _lblBitNum_0, _lblBitNum_1, _lblBitNum_2, _lblBitNum_3,
                                       _lblBitNum_4, _lblBitNum_5, _lblBitNum_6, _lblBitNum_7 });


            lblBitVal = (new Label[] { _lblBitVal_0, _lblBitVal_1, _lblBitVal_2, _lblBitVal_3,
                                       _lblBitVal_4, _lblBitVal_5, _lblBitVal_6, _lblBitVal_7 });
        }
        private void cmdDiscover_Click(object sender, EventArgs e)
        {
            ReleaseDAQDevices();

            lblDevID.Text  = "";
            Cursor.Current = Cursors.WaitCursor;

            // Discover DAQ devices with GetDaqDeviceInventory()
            //  Parameters:
            //    InterfaceType   :interface type of DAQ devices to be discovered

            MccDaq.DaqDeviceDescriptor[] inventory = MccDaq.DaqDeviceManager.GetDaqDeviceInventory(MccDaq.DaqDeviceInterface.Any);

            int numDevDiscovered = inventory.Length;

            cmbBoxDiscoveredDevs.Items.Clear();

            lblStatus.Text = numDevDiscovered + " DAQ Device(s) Discovered";

            if (numDevDiscovered > 0)
            {
                for (int boardNum = 0; boardNum < numDevDiscovered; boardNum++)
                {
                    try
                    {
                        //    Create a new MccBoard object for Board and assign a board number
                        //    to the specified DAQ device with CreateDaqDevice()

                        //    Parameters:
                        //        BoardNum			: board number to be assigned to the specified DAQ device
                        //        DeviceDescriptor	: device descriptor of the DAQ device

                        MccDaq.MccBoard daqBoard = MccDaq.DaqDeviceManager.CreateDaqDevice(boardNum, inventory[boardNum]);

                        // Add the board to combobox
                        cmbBoxDiscoveredDevs.Items.Add(daqBoard);
                    }
                    catch (ULException ule)
                    {
                        lblStatus.Text = "Error occured: " + ule.Message;
                    }
                }
            }


            if (cmbBoxDiscoveredDevs.Items.Count > 0)
            {
                cmbBoxDiscoveredDevs.Enabled       = true;
                cmbBoxDiscoveredDevs.SelectedIndex = 0;
                cmdFlashLED.Enabled = true;
            }
            else
            {
                cmbBoxDiscoveredDevs.Enabled = false;
                cmdFlashLED.Enabled          = false;
            }

            Cursor.Current = Cursors.Default;
        }
示例#20
0
文件: ULAI01.cs 项目: otoauler/sdkpub
        public frmDataDisplay()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            //  Create a new MccBoard object for Board 0
            DaqBoard = new MccDaq.MccBoard(0);
        }
示例#21
0
文件: ULAI01.cs 项目: r4forth/sdkpub
        public frmDataDisplay()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            //  Create a new MccBoard object for Board 0
            DaqBoard = new MccDaq.MccBoard(0);
        }
示例#22
0
文件: ULCT06.cs 项目: r4forth/sdkpub
        const short CounterNum = 1;         //  Counter number

        public frm7266Ctr()
        {
            // 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);


            //  Set the configurable operations of the counter
            //  Parameters:
            //          CounterNum     :the counter to be configured (0-5)
            //          Quadrature     :Select type of counter input
            //          CountingMode   :Slects how counter will operate
            //          IndexMode      :Selects what index signal will control
            //          InvertIndex    :Set to ENABLED id index signal is inverted
            //          FlagPins       :Select which signals will drive Flag pins
            //          GateEnable     :Set to ENABLED to use external gating signal */
            MccDaq.Quadrature   Quadrature   = MccDaq.Quadrature.X1Quad;
            MccDaq.CountingMode CountingMode = MccDaq.CountingMode.ModuloN;
            MccDaq.DataEncoding DataEncoding = MccDaq.DataEncoding.BinaryEncoding;
            MccDaq.IndexMode    IndexMode    = MccDaq.IndexMode.IndexDisabled;
            MccDaq.OptionState  InvertIndex  = MccDaq.OptionState.Disabled;
            MccDaq.FlagPins     FlagPins     = MccDaq.FlagPins.CarryBorrow;
            MccDaq.OptionState  GateEnable   = MccDaq.OptionState.Disabled;
            ULStat = DaqBoard.C7266Config(CounterNum, Quadrature, CountingMode, DataEncoding, IndexMode, InvertIndex, FlagPins, GateEnable);



            //  Send a starting value to the counter with Mccdaq.MccBoard.CLoad32()
            //   Parameters:
            //     RegName    :the counter to be loaded with the starting value
            //     LoadValue  :the starting value to place in the counter
            int LoadValue = 1000;

            //  Convert the value of the counter number to MccDaq.CounterRegister
            MccDaq.CounterRegister RegName = (MccDaq.CounterRegister)(MccDaq.CounterRegister.QuadCount1 + CounterNum - 1);
            ULStat = DaqBoard.CLoad32(RegName, LoadValue);

            lblShowLoadVal.Text = LoadValue.ToString("0");

            LoadValue = 2000;
            RegName   = (MccDaq.CounterRegister)(MccDaq.CounterRegister.QuadPreset1 + CounterNum - 1);

            ULStat             = DaqBoard.CLoad32(RegName, LoadValue);
            lblShowMaxVal.Text = LoadValue.ToString("0");

            tmrReadCounter.Enabled = true;
        }
        public MCC_Relaybox(int mcc_id)
        {
            relaybox = new MccDaq.MccBoard(mcc_id);

            for (int i = 1; i <= 24; i++)
            {
                TurnOff(i);
            }
        }
        private void cmdFlashLED_Click(object sender, EventArgs e)
        {
            MccDaq.MccBoard daqBoard = (MccDaq.MccBoard)cmbBoxDiscoveredDevs.SelectedItem;

            // Flash the LED of the specified DAQ device with FlashLED()

            if (daqBoard != null)
            {
                daqBoard.FlashLED();
            }
        }
示例#25
0
        private void PrintTempInfo(MccDaq.MccBoard pBoard)
        {
            int numTempChans = 0;

            MccDaq.ErrorInfo ULStat = pBoard.BoardConfig.GetNumTempChans(out numTempChans);

            if (numTempChans != 0)
            {
                Info += "     Number of temperature channels: " + numTempChans.ToString("0") + LF + LF;
            }
        }
示例#26
0
文件: ULCT06.cs 项目: otoauler/sdkpub
        public frm7266Ctr()
        {
            // 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);

            //  Set the configurable operations of the counter
            //  Parameters:
            //          CounterNum     :the counter to be configured (0-5)
            //          Quadrature     :Select type of counter input
            //          CountingMode   :Slects how counter will operate
            //          IndexMode      :Selects what index signal will control
            //          InvertIndex    :Set to ENABLED id index signal is inverted
            //          FlagPins       :Select which signals will drive Flag pins
            //          GateEnable     :Set to ENABLED to use external gating signal */
            MccDaq.Quadrature Quadrature = MccDaq.Quadrature.X1Quad;
            MccDaq.CountingMode CountingMode = MccDaq.CountingMode.ModuloN;
            MccDaq.DataEncoding DataEncoding = MccDaq.DataEncoding.BinaryEncoding;
            MccDaq.IndexMode IndexMode = MccDaq.IndexMode.IndexDisabled;
            MccDaq.OptionState InvertIndex = MccDaq.OptionState.Disabled;
            MccDaq.FlagPins FlagPins = MccDaq.FlagPins.CarryBorrow;
            MccDaq.OptionState GateEnable = MccDaq.OptionState.Disabled;
            ULStat = DaqBoard.C7266Config(CounterNum, Quadrature, CountingMode, DataEncoding, IndexMode, InvertIndex, FlagPins, GateEnable);

            //  Send a starting value to the counter with Mccdaq.MccBoard.CLoad32()
            //   Parameters:
            //     RegName    :the counter to be loaded with the starting value
            //     LoadValue  :the starting value to place in the counter
            int LoadValue = 1000;

            //  Convert the value of the counter number to MccDaq.CounterRegister
            MccDaq.CounterRegister RegName = (MccDaq.CounterRegister)(MccDaq.CounterRegister.QuadCount1 + CounterNum -1);
            ULStat = DaqBoard.CLoad32(RegName, LoadValue);

            lblShowLoadVal.Text = LoadValue.ToString("0");

            LoadValue = 2000;
            RegName = (MccDaq.CounterRegister)(MccDaq.CounterRegister.QuadPreset1 + CounterNum - 1);

            ULStat = DaqBoard.CLoad32(RegName, LoadValue);
            lblShowMaxVal.Text = LoadValue.ToString("0");

            tmrReadCounter.Enabled = true;
        }
示例#27
0
文件: ULGT03.cs 项目: caridlin/DAQ
        private void PrintADInfo(MccDaq.MccBoard pBoard)
        {
            int numADChans = 0;

            MccDaq.ErrorInfo ULStat = pBoard.BoardConfig.GetNumAdChans(out numADChans);

            if (numADChans != 0)
            {
                Info += "     Number of A/D channels: " + numADChans.ToString("0") + LF;
            }
        }
示例#28
0
文件: ULGT03.cs 项目: caridlin/DAQ
        private void PrintDAInfo(MccDaq.MccBoard pBoard)
        {
            int numDAChans = 0;

            MccDaq.ErrorInfo ULStat = pBoard.BoardConfig.GetNumDaChans(out numDAChans);

            if (numDAChans > 0)
            {
                Info += "     Number of D/A channels: " + numDAChans.ToString("0") + LF;
            }
        }
示例#29
0
文件: ULGT03.cs 项目: caridlin/DAQ
        private void PrintGenInfo(MccDaq.MccBoard pBoard)
        {
            Info += "Board #" + pBoard.BoardNum.ToString("0")
                    + " = " + pBoard.BoardName + " at ";

            // Get the board's base address
            int baseAdr = 0;

            ULStat = pBoard.BoardConfig.GetBaseAdr(0, out baseAdr);

            Info += "Base Address = " + baseAdr.ToString("X") + " hex." + LF + LF;
        }
示例#30
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);
            }
        }
示例#31
0
        //constuctor for the dyno
        public Dyno()
        {
            isDynCon = false;

            //Initialize Error Handling
            ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);

            //Create an object for board 0
            DaqBoard = new MccDaq.MccBoard(0);

            //Set the range
            Range = MccDaq.Range.Bip10Volts;
            //  return scaled data
            Options = MccDaq.ScanOptions.ScaleData;

            // creating and defining the objects for the moving average
            filterLength = 5;
            averager     = new MovingAverage(filterLength);

            XForce         = 0;
            YForce         = 0;
            ZForceDyno     = 0;
            TForce         = 0;
            VAngle         = 0;
            XYForce        = 0;
            XYForceAverage = 0;

            // Try to initialize the dyno control port and catch any errors
            try
            {
                //Set up port for controlling the dyno
                DynoControlPort          = new SerialPort();
                DynoControlPort.PortName = "COM3";
                DynoControlPort.BaudRate = 4800;
                DynoControlPort.Parity   = Parity.None;
                DynoControlPort.StopBits = StopBits.One;
                DynoControlPort.DataBits = 8;
                DynoControlPort.Open();
            }
            catch (System.IO.IOException e)
            {
                //MessageBox.Show("Open device manager in windows and the 'Setup Serial Ports' section of the C# code and check the serial port names and settings are correct\n\n" + e.ToString(), "Serial Port Error");
                //Process.GetCurrentProcess().Kill();
            }
            catch (System.UnauthorizedAccessException e)
            {
                //MessageBox.Show("Something is wrong? maybe try to restart computer?\n\nHere is some error message stuff...\n\n" + e.ToString(), "Serial Port Error");
                //Process.GetCurrentProcess().Kill();
            }
        }
示例#32
0
        // This function detects the board number. The two parameters of this
        // function are the device name and a TextBox object that holds the
        // value of the board number (which is set when the board is detected by
        // Instacal). It creates a board object with a board number from 0 to 99
        // (since that is the range of MCC board numbers) and checks if that
        // board number corresponds to the USB-TC device. It is important that
        // the variable DEVICE is set to "TC" or "USB-TC", since that is what
        // InstaCal names the USB-TC device when it is detected. If no board is
        // found, a value of -1 is returned.
        public static int GetBoardNum(string dev, TextBox BoardNumBox)
        {
            for (int BoardNum = 0; BoardNum < 99; BoardNum++)
            {
                MccDaq.MccBoard daq = new MccDaq.MccBoard(BoardNum);

                if (daq.BoardName.Contains(dev))
                {
                    BoardNumBox.Text = " " + BoardNum.ToString();
                    return(BoardNum);
                }
            }
            return(-1);
        }
示例#33
0
 public static int GetBoardNum(string dev)
 {
     for (int BoardNum = 0; BoardNum < 99; BoardNum++)
     {
         MccDaq.MccBoard daq = new MccDaq.MccBoard(BoardNum);
         if (daq.BoardName.Contains(dev))
         {
             Console.WriteLine("USB-{0} board number = {1}", dev, BoardNum.ToString());
             daq.FlashLED();
             return(BoardNum);
         }
     }
     return(-1);
 }
 /************************************************************************/
 public static int GetBoardNum(string dev)
 {
     for (int BoardNum = 0; BoardNum < 99; BoardNum++)
     {
         MccDaq.MccBoard daq = new MccDaq.MccBoard(BoardNum);
         if (daq.BoardName.Contains(dev))
         {
             Console.WriteLine("USB-{0} board number = {1}", dev, BoardNum.ToString());
             daq.FlashLED();
             return BoardNum;
         }
     }
     return -1;
 }
示例#35
0
文件: VIn01.cs 项目: r4forth/sdkpub
        public frmDataDisplay()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

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

            cmbRange.Items.Insert(0, MccDaq.Range.Bip10Volts);
            cmbRange.Items.Insert(1, MccDaq.Range.Bip5Volts);
            cmbRange.Items.Insert(2, MccDaq.Range.Uni10Volts);
            cmbRange.Items.Insert(3, MccDaq.Range.Uni5Volts);
            cmbRange.SelectedIndex = 1;
        }
示例#36
0
文件: VIn01.cs 项目: otoauler/sdkpub
        public frmDataDisplay()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

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

            cmbRange.Items.Insert(0,MccDaq.Range.Bip10Volts);
            cmbRange.Items.Insert(1,MccDaq.Range.Bip5Volts);
            cmbRange.Items.Insert(2,MccDaq.Range.Uni10Volts);
            cmbRange.Items.Insert(3,MccDaq.Range.Uni5Volts);
            cmbRange.SelectedIndex = 1;
        }
示例#37
0
        private void cmdPrintInfo_Click(object eventSender, System.EventArgs eventArgs)
        {
            MccDaq.MccBoard pCurrentBoard;
            int             BoardType = 0;

            Info = "";

            //Loop through possible board numbers. If installed,
            //(BoardType != 0), get the board information.
            do
            {
                pCurrentBoard = new MccDaq.MccBoard(CurrentBoard);
                ULStat        = pCurrentBoard.BoardConfig.GetBoardType(out BoardType);
                CurrentBoard  = CurrentBoard + 1;
            } while ((BoardType == 0) && (CurrentBoard < MaxNumBoards));

            if (CurrentBoard > MaxNumBoards - 1)
            {
                if (NumBoards == 0)
                {
                    Info = LF + LF +
                           "        There are no boards installed." + LF + LF;
                    Info +=
                        "        You must run InstaCal to install the desired" + LF;
                    Info +=
                        "        boards before running this program." + LF;
                }
                else
                {
                    Info = LF + LF +
                           "        There are no additional boards installed." + LF;
                }
                cmdPrintInfo.Text = "Print Info";
                CurrentBoard      = 0;
                NumBoards         = 0;
            }
            else
            {
                PrintGenInfo(pCurrentBoard);
                PrintADInfo(pCurrentBoard);
                PrintTempInfo(pCurrentBoard);
                PrintDAInfo(pCurrentBoard);
                PrintDigInfo(pCurrentBoard);
                PrintCtrInfo(pCurrentBoard);
                PrintExpInfo(pCurrentBoard);
                cmdPrintInfo.Text = "Print Next";
                NumBoards         = NumBoards + 1;
            }
            txtBoardInfo.Text = Info;
        }
示例#38
0
        private void Form1_Load(object sender, EventArgs e)
        {
            System.Boolean Boardfound = false;
            MccDaq.DaqDeviceManager.IgnoreInstaCal();
            inventory = MccDaq.DaqDeviceManager.GetDaqDeviceInventory(MccDaq.DaqDeviceInterface.Any);
            System.Int32 numDevDiscovered = inventory.Length;

            if (numDevDiscovered > 0)
            {
                for (System.Int16 BoardNum = 0; BoardNum < numDevDiscovered; BoardNum++)
                {
                    try
                    {
                        DaqBoard = MccDaq.DaqDeviceManager.CreateDaqDevice(BoardNum, inventory[BoardNum]);
                        if (DaqBoard.BoardName.Contains("E-1608"))
                        {
                            Boardfound = true;
                            DaqBoard.FlashLED();
                            break;
                        }
                        else
                        {
                            MccDaq.DaqDeviceManager.ReleaseDaqDevice(DaqBoard);
                        }
                    }
                    catch (MccDaq.ULException ule)
                    {
                        System.Windows.Forms.MessageBox.Show(ule.Message, "Плата не обнаружена");
                    }
                }
            }

            if (Boardfound == false)
            {
                System.Windows.Forms.MessageBox.Show("E-1608 не найден. Запустите InstaCal", "Плата не обнаружена");
                this.Close();
            }
            System.String mystring = DaqBoard.BoardName.Substring(0, DaqBoard.BoardName.Trim().Length) + " найдена под номером: " + DaqBoard.BoardNum.ToString();
            this.Text = mystring;
            LoadComboBox(cmboAInRange);
            DaqBoard.BoardConfig.GetNumAdChans(out numchannels);
            nudAInChannel.Maximum = numchannels - 1;

            for (int i = 1; i < 10; i++)
            {
                cbRate.Items.Add(i * 10);
            }
            cbRate.SelectedIndex = 1;
        }
示例#39
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);
            }
        }
示例#40
0
        public void init()
        {
            if (_initialized)
            {
                return;
            }

            int wantedBoards = 3;        // We always have three boards, either real or simulated
            int maxMccBoards;

            if (!Simulated)
            {
                MccService.GetRevision(out mccRevNum, out mccVxdRevNum);
                MccService.ErrHandling(MccDaq.ErrorReporting.DontPrint, MccDaq.ErrorHandling.DontStop);
                maxMccBoards = MccDaq.GlobalConfig.NumBoards;

                // get the real Mcc boards
                for (int i = 0; i < maxMccBoards; i++)
                {
                    int type;

                    MccDaq.MccBoard board = new MccDaq.MccBoard(i);
                    board.BoardConfig.GetBoardType(out type);
                    if (type != 0)
                    {
                        WiseBoards.Add(new WiseBoard(board));
                    }
                }
            }

            // Add simulated boards, as needed
            for (int i = WiseBoards.Count; i < wantedBoards; i++)
            {
                WiseBoards.Add(new WiseBoard(null, i));
            }

            domeboard = WiseBoards.Find(x => x.mccBoard.BoardNum == 0);
            teleboard = WiseBoards.Find(x => x.mccBoard.BoardNum == 1);
            miscboard = WiseBoards.Find(x => x.mccBoard.BoardNum == 2);

            if (computerControlPin == null)
            {
                computerControlPin = new WisePin("CompControl", teleboard, DigitalPortType.SecondPortCH, 0, DigitalPortDirection.DigitalIn);
                computerControlPin.Connect(true);
            }

            _initialized = true;
        }
示例#41
0
        public frmTimerOutput()
        {
            // 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);

            DaqBoard = new MccDaq.MccBoard(0);
        }
示例#42
0
        private IntPtr MemHandle = IntPtr.Zero;            // define a variable to contain the handle for
        // memory allocated by Windows through MccDaq.MccServices.WinBufAlloc()


        public frmDataDisplay()
        {
            // 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);

            // Get the resolution of A/D
            int ADRes;

            DaqBoard.BoardConfig.GetAdResolution(out ADRes);

            // check If the resolution of A/D is higher than 16 bit.
            // If it is, then the A/D is high resolution.
            if (ADRes > 16)
            {
                HighResAD = true;
            }

            //  set aside memory to hold data
            if (HighResAD)
            {
                MemHandle = MccDaq.MccService.WinBufAlloc32Ex(NumPoints);
            }
            else
            {
                MemHandle = MccDaq.MccService.WinBufAllocEx(NumPoints);
            }



            Options = MccDaq.ScanOptions.ConvertData;

            lblADData = (new Label[] { _lblADData_0, _lblADData_1, _lblADData_2, _lblADData_3,
                                       _lblADData_4, _lblADData_5, _lblADData_6, _lblADData_7 });
        }
示例#43
0
文件: ULTI01.cs 项目: otoauler/sdkpub
        public frmDataDisplay()
        {
            // 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 the board uses EXP boards for temperature measurements
            UsesEXPs = 0;
            ULStat = DaqBoard.BoardConfig.GetUsesExps(out UsesEXPs);
        }
示例#44
0
文件: VOut01.cs 项目: otoauler/sdkpub
        public frmSendAData()
        {
            // 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);

            DaqBoard = new MccDaq.MccBoard(0);

            cmbRange.Items.Insert(0,MccDaq.Range.Bip10Volts);
            cmbRange.Items.Insert(1,MccDaq.Range.Bip5Volts);
            cmbRange.Items.Insert(2,MccDaq.Range.Uni10Volts);
            cmbRange.Items.Insert(3,MccDaq.Range.Uni5Volts);
            cmbRange.SelectedIndex = 1;
        }
示例#45
0
文件: ULDO01.cs 项目: otoauler/sdkpub
        public frmSetDigOut()
        {
            // 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);

            //  configure FirstPortA for digital output
            //   Parameters:
            //     PortNum    :the output port
            //     Direction  :sets the port for input or output
            ULStat = DaqBoard.DConfigPort(PortNum, Direction);
        }
示例#46
0
        // *----------------------------------------------------------------*
        // *     Initialisation and configuration of the card               *
        // *----------------------------------------------------------------*
        /// <summary>
        /// Constructor that initialise the card
        /// </summary>
        public Card()
        {
            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.
            //              -> PrintAll  : all warnings and errorsencountered will be printed
            //              -> DontPrint : No error printing (in production)
            //     MccDaq.ErrorHandling.
            //              -> StopAll  : If an error is encountered, the program will stop
            //              -> DontStop : No stop (in production)
            ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.DontPrint, MccDaq.ErrorHandling.DontStop);

            // select the first card (the only connected)
            DaqBoard = new MccDaq.MccBoard(0);
            ULStat = DaqBoard.FlashLED();

            //  looking if the card is connected
            if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                // if no errors, configuring the card
                GlobalVariables.mode = "normal";

                // FirstPortA as output for heating control
                ULStat = DaqBoard.DConfigPort(MccDaq.DigitalPortType.FirstPortA, MccDaq.DigitalPortDirection.DigitalOut);
                ULStat = DaqBoard.DOut(MccDaq.DigitalPortType.FirstPortA, 0); // All is off at startup

                // FirstPortB as input for door and windows
                ULStat = DaqBoard.DConfigPort(MccDaq.DigitalPortType.FirstPortB, MccDaq.DigitalPortDirection.DigitalIn);
            }
            else
            {
                // if error, simulation mode and blocking the card
                GlobalVariables.mode = "simulation";
            }
        }
示例#47
0
文件: ULCT05.cs 项目: otoauler/sdkpub
        public frm8536Count()
        {
            // 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);

            // Init the counter for desired operation
            //   Parameters:
            //      ChipNum     :the chip to be setup
            //      Ctr1Output  :how the counter output is used
            short ChipNum = 1;
            MccDaq.CtrlOutput Ctr1Output = MccDaq.CtrlOutput.NotLinked;
            ULStat = DaqBoard.C8536Init(ChipNum, Ctr1Output);

            // Configure the counter for desired operation
            //   Parameters:
            //      CounterNum    :which counter
            //      OutputControl :which counter output signal is used
            //      RecycleMode   :reload at 0 ?
            //      TrigType      :trigger type
            CounterNum = 1;
            MccDaq.C8536OutputControl OutputControl = MccDaq.C8536OutputControl.ToggleOnTc;
            MccDaq.RecycleMode RecycleMode = MccDaq.RecycleMode.Recycle;
            MccDaq.C8536TriggerType TrigType = MccDaq.C8536TriggerType.HWStartTrig;
            ULStat = DaqBoard.C8536Config(CounterNum, OutputControl, RecycleMode, TrigType);
        }
        // This function updates the temperature log text file. It returns if
        // the number of channels is invalid. Otherwise, it uses a while loop to
        // output temperature readings to a .txt file in the same directory as
        // the program folder. It shows an error if there is an open channel.
        public void update_log()
        {
            MccBoard daq = new MccDaq.MccBoard(BoardNum);
            MccDaq.ErrorInfo RetVal;
            string subject = "";
            string body = "";

            string separator = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +
                            "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +
                            "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +
                            "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

             while (log_check == 0)
            {
                if (log_state == 0)
                {
                    log_state = 1;

                    string[] text1 = {"Temperature and events log file.", " ",
                                    "Created on " +
                                    date_time.ToString(format),
                                    " ","Temperature read approx. every 5 "+
                                    "seconds in degrees Celsius.", " "," "};

                    System.IO.File.WriteAllLines(directory, text1);

                    string text2 = "Time\t\t\t";

                    for (int i = 0; i < MAX_CHANCOUNT; i++)
                    {
                        text2 += String.Format("Ch{0}", i) + "\t\t";
                    }

                    using (StreamWriter sw = File.AppendText(directory))
                    {
                        sw.WriteLine(text2);
                        sw.WriteLine(" ");
                    }
                }

                if (HeatingStarted && !HeatingStarted_logged)
                {
                    string temp = DateTime.Now.ToString("T") + "\t\t" +
                            "HEATING STARTED!";

                    using (StreamWriter sw = File.AppendText(directory))
                    {
                        sw.WriteLine(" ");
                        sw.WriteLine(separator);
                        sw.WriteLine(" ");
                        sw.WriteLine(temp);
                        sw.WriteLine("\t\t\tUser: "******"\t\t\tBatch code: " + BatchCode_copy);
                        sw.WriteLine("\t\t\tMax. Temperature: " + MaxTemp_copy);
                        sw.WriteLine("\t\t\tHold Time: " + HoldTime_copy);
                        sw.WriteLine("\t\t\tCooling method: " + CoolMethod_copy);
                        sw.WriteLine(" ");
                        sw.WriteLine(separator);
                        sw.WriteLine(" ");
                    }

                    subject = "Heating has started on " + OvenName_copy +
                        " oven!";

                    body = User_copy + ",\n\n" + subject +
                        "\n\nParameters are: \nBatch Code: " + BatchCode_copy +
                        "\nMax.Temp: " + MaxTemp_copy +
                        "\nHold Time: " + HoldTime_copy +
                        "\nCooling Method: " + CoolMethod_copy +
                        "\nTime: " + OvenStartTime_copy;
                    SendEmail(subject, body);
                    HeatingStarted_logged = true;
                }

                else if (HeatingStopped && !HeatingStopped_logged)
                {
                    string temp = DateTime.Now.ToString("T") + "\t\t" +
                            "HEATING STOPPED!";

                    using (StreamWriter sw = File.AppendText(directory))
                    {
                        sw.WriteLine(" ");
                        sw.WriteLine(separator);
                        sw.WriteLine(" ");
                        sw.WriteLine(temp);
                        sw.WriteLine(" ");
                        sw.WriteLine(separator);
                        sw.WriteLine(" ");
                    }

                    subject = "Heating has stopped on " + OvenName_copy +
                        " oven!";
                    body = User_copy + ",\n\n" + subject;
                    SendEmail(subject, body);
                    HeatingStopped_logged = true;
                }

                else if (MaxTempReached && !MaxTempReached_logged)
                {
                    string temp = DateTime.Now.ToString("T") + "\t\t" +
                            "MAX. TEMP REACHED!";

                    using (StreamWriter sw = File.AppendText(directory))
                    {
                        sw.WriteLine(" ");
                        sw.WriteLine(separator);
                        sw.WriteLine(" ");
                        sw.WriteLine(temp);
                        sw.WriteLine(" ");
                        sw.WriteLine(separator);
                        sw.WriteLine(" ");
                    }

                    subject = "Max. temp reached on " + OvenName_copy +
                        " oven!";
                    body = User_copy + ",\n\n" + subject;
                    SendEmail(subject, body);
                    MaxTempReached_logged = true;
                }

                else if (CoolingStarted && !CoolingStarted_logged)
                {
                    string temp = DateTime.Now.ToString("T") + "\t\t" +
                            "COOLING STARTED!";

                    using (StreamWriter sw = File.AppendText(directory))
                    {
                        sw.WriteLine(" ");
                        sw.WriteLine(separator);
                        sw.WriteLine(" ");
                        sw.WriteLine(temp);
                        sw.WriteLine(" ");
                        sw.WriteLine(separator);
                        sw.WriteLine(" ");
                    }

                    subject = "Cooling has started on " + OvenName_copy +
                        " oven!";
                    body = User_copy + ",\n\n" + subject;
                    SendEmail(subject, body);
                    CoolingStarted_logged = true;
                }

                else if (IsCriticalError && !IsCriticalError_logged)
                {
                    string temp = DateTime.Now.ToString("T") + "\t\t" +
                            "CRITICAL ERROR!";

                    using (StreamWriter sw = File.AppendText(directory))
                    {
                        sw.WriteLine(" ");
                        sw.WriteLine(separator);
                        sw.WriteLine(" ");
                        sw.WriteLine(temp);
                        sw.WriteLine(" ");
                        sw.WriteLine(separator);
                        sw.WriteLine(" ");
                    }

                    subject = "Critical error on " + OvenName_copy + " oven!";
                    body = User_copy + ",\n\n" + subject + "\n" +
                        CriticalErrorMessage;
                    SendEmail(subject, body);
                    IsCriticalError_logged = true;
                }

                else if (OvenRunDone && !OvenRunDone_logged)
                {
                    string temp = DateTime.Now.ToString("T") + "\t\t" +
                            "OVEN RUN COMPLETE!";

                    using (StreamWriter sw = File.AppendText(directory))
                    {
                        sw.WriteLine(" ");
                        sw.WriteLine(separator);
                        sw.WriteLine(" ");
                        sw.WriteLine(temp);
                        sw.WriteLine("\t\t\tUser: "******"\t\t\tBatch code: " + BatchCode_copy);
                        sw.WriteLine("\t\t\tMax. Temperature: " + MaxTemp_copy);
                        sw.WriteLine("\t\t\tHold Time: " + HoldTime_copy);
                        sw.WriteLine("\t\t\tCooling method: " + CoolMethod_copy);
                        sw.WriteLine(" ");
                        sw.WriteLine(separator);
                        sw.WriteLine(" ");
                    }

                    subject = "Oven run completed on " + OvenName_copy + " oven!";
                    body = User_copy + ",\n\n" + subject + "\n";
                    SendEmail(subject, body);
                    OvenRunDone_logged = true;
                }

                string text3 = DateTime.Now.ToString("T") + "\t\t";

                for (int i = 0; i < MAX_CHANCOUNT; i++)
                {
                    RetVal = daq.TIn(i, TempScale.Celsius,
                        out LogData[i], ThermocoupleOptions.Filter);
                    IsError(this, RetVal, true);

                    if (RetVal.Value != 0)
                        text3 += "***\t\t";
                    else
                        text3 += LogData[i].ToString() + "\t\t";
                }

                using (StreamWriter sw = File.AppendText(directory))
                {
                    sw.WriteLine(text3);
                }

                Thread.Sleep(4800);
            }
        }
        // This function detects the board number. The two parameters of this
        // function are the device name and a TextBox object that holds the
        // value of the board number (which is set when the board is detected by
        // Instacal). It creates a board object with a board number from 0 to 99
        // (since that is the range of MCC board numbers) and checks if that
        // board number corresponds to the USB-TC device. It is important that
        // the variable DEVICE is set to "TC" or "USB-TC", since that is what
        // InstaCal names the USB-TC device when it is detected. If no board is
        // found, a value of -1 is returned.
        public static int GetBoardNum(string dev, TextBox BNum)
        {
            for (int BoardNum = 0; BoardNum < 99; BoardNum++)
            {
                MccDaq.MccBoard daq = new MccDaq.MccBoard(BoardNum);

                if (daq.BoardName.Contains(dev))
                {
                    BNum.Text = " " + BoardNum.ToString();

                    return BoardNum;
                }
            }
            return -1;
        }
        // This function reads and displays the temperature inputs by detecting
        // the buttons clicked, by detecting the value of the variable "check".
        // It runs a while loop to keep checking for button presses, and using
        // Thread.Sleep(), it checks buttons, reads and displays temperatures in
        // the selected scale at a set frequency (2 Hz). The loop ends when the
        // value of check is set to -1 by clicking the Exit button. Temperatures
        // are read using the TInScan function, and an array is passed to the
        // update_temp() function to display them using a delegate.
        private void temp_reader()
        {
            while (read_check != -1)
               {
                int count = 0;
                float[] TempData = new float[MAX_CHANCOUNT];
                float[] TempData_C = new float[MAX_CHANCOUNT];

                MccBoard daq = new MccDaq.MccBoard(BoardNum);
                MccDaq.ErrorInfo RetVal;

                Update_Temperature update_temp_del = new
                    Update_Temperature(update_temp);

                Update_Warning update_warning_del = new
                    Update_Warning(update_warning);

                Reset_Checkboxes resetcheckboxes_del = new
                    Reset_Checkboxes(resetcheckboxes);

                for (int i = 0; i < MAX_CHANCOUNT; i++)
                {
                    if (((CheckBox)this.Controls["Ch" +
                        i.ToString("#0") + "Box"]).Enabled == true &&
                        ((CheckBox)this.Controls["Ch" +
                        i.ToString("#0") + "Box"]).Checked == true)
                    {
                        count++;
                    }
                }

                if (count == 0)
                {
                    TempData = new float[MAX_CHANCOUNT] {-9999, -9999,
                        -9999, -9999, -9999, -9999, -9999, -9999};

                    Array.Copy(TempData, TempData_C, 8);

                    not_showing_temp = true;
                    Invoke(update_temp_del, TempData, TempData_C);
                }
                else
                    not_showing_temp = false;

                if (read_check == 1 && not_showing_temp == false)
                {
                    for (int i = 0; i < MAX_CHANCOUNT; i++)
                    {
                        if (((CheckBox)this.Controls["Ch" +
                            i.ToString("#0") + "Box"]).Checked == true)
                        {
                            RetVal = daq.TIn(i, TempScale.Celsius,
                                out TempData_C[i],
                                ThermocoupleOptions.Filter);
                            IsError(this,RetVal, true);
                        }
                        else
                            TempData_C[i] = -9999;
                    }

                    switch(my_TempScale)
                    {
                        case TempScale.Fahrenheit:
                            for (int i = 0; i < MAX_CHANCOUNT; i++)
                            {
                                if (((CheckBox)this.Controls["Ch" +
                                    i.ToString("#0") + "Box"]).Checked == true)
                                {
                                    RetVal = daq.TIn(i, TempScale.Fahrenheit,
                                        out TempData[i],
                                        ThermocoupleOptions.Filter);
                                    IsError(this,RetVal, true);
                                }
                                else
                                    TempData[i] = -9999;
                            }
                            break;

                        case TempScale.Kelvin:
                            for (int i = 0; i < MAX_CHANCOUNT; i++)
                            {
                                if (((CheckBox)this.Controls["Ch" +
                                    i.ToString("#0") + "Box"]).Checked == true)
                                {
                                    RetVal = daq.TIn(i, TempScale.Kelvin,
                                        out TempData[i],
                                        ThermocoupleOptions.Filter);
                                    IsError(this,RetVal, true);
                                }
                                else
                                    TempData[i] = -9999;
                            }
                            break;

                        default:
                            for (int i = 0; i < MAX_CHANCOUNT; i++)
                            {
                                if (((CheckBox)this.Controls["Ch" +
                                    i.ToString("#0") + "Box"]).Checked == true)
                                {
                                    RetVal = daq.TIn(i, TempScale.Celsius,
                                        out TempData[i],
                                        ThermocoupleOptions.Filter);
                                    IsError(this,RetVal, true);
                                }
                                else
                                    TempData[i] = -9999;
                            }
                            break;
                    }

                    Invoke(update_temp_del, TempData, TempData_C);

                    Thread.Sleep(500);
                }

                if ((read_check == 0 && oven_check == 1) ||
                    (not_showing_temp == true && oven_check == 1))
                {
                    string temp = String.Format("WARNING! Temperature" +
                        " readings are no longer live during an oven run!\n" +
                        "Automatically fixing this in {0} seconds...",
                        (int)(warning_time/2));

                    Invoke(update_warning_del, temp, 1);

                    Thread.Sleep(500);

                    warning_time--;

                    if (warning_time <= 0)
                    {
                        read_check = 1;
                        Invoke(resetcheckboxes_del);
                        not_showing_temp = false;
                        Invoke(update_warning_del, " ", 0);
                        warning_time = 20;
                    }
                }

                // Make sure that the text is grayed out when the Stop TC button
                // is in its clicked state.
                if (read_check == 0 && oven_check != 1)
                {
                    TempData[0] = 1234;
                    TempData_C[0] = 1234;
                    Invoke(update_temp_del, TempData, TempData_C);
                    Thread.Sleep(500);
                }
            }
        }
        // This function changes CHANCOUNT, by detecting the actual number of
        // working thermocouple inputs connected to the USB-TC board.
        private void TC_finder()
        {
            MccBoard daq = new MccDaq.MccBoard(BoardNum);
            MccDaq.ErrorInfo RetVal;

            CHANCOUNT = MAX_CHANCOUNT;

            float[] temp = new float[MAX_CHANCOUNT];

            try
            {
                for (int i = 0; i < MAX_CHANCOUNT; i++)
                {
                    RetVal = daq.TIn(i, TempScale.Celsius,
                        out temp[i], ThermocoupleOptions.Filter);

                    if (RetVal.Value != 0)
                    {
                        CHANCOUNT--;

                        ((CheckBox)this.Controls["Ch" +
                            i.ToString("#0") + "Box"]).Checked = false;

                        ((CheckBox)this.Controls["Ch" +
                            i.ToString("#0") + "Box"]).Enabled = false;
                    }

                    else
                    {
                        ((CheckBox)this.Controls["Ch" +
                            i.ToString("#0") + "Box"]).Checked = true;

                        ((CheckBox)this.Controls["Ch" +
                            i.ToString("#0") + "Box"]).Enabled = true;
                    }
                }

                NumThermocouples.Text = " " + CHANCOUNT.ToString();

                return;
            }

            catch
            {
                MessageBox.Show("TC_finder has an error!", "   " + "ERROR!");
                return;
            }
        }
        // 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;
            }
        }
        // This function implements PID control in the oven, by using three
        // USB-TC output channels. It calls the functions channel_out() to
        // control the heater coils according to the known setup.
        private void PID_control()
        {
            MccBoard daq = new MccDaq.MccBoard(BoardNum);
            MccDaq.ErrorInfo RetVal;int count = 0;

            float[] PID_LogData = new float[MAX_CHANCOUNT] {0, 0, 0, 0, 0, 0, 0 ,0};;

            int PID_max_temp = Convert.ToInt32(MaxTemp.Text);

            float current_error = 0; // difference between current and target
                                     // temperatures

            float prev_error = PID_max_temp;    // the last recorded error;
                                                // initialized to the max temp.

            float time_slice = 1;   // any non-zero value, so that we don't have
                                    // a divide-by-zero error

            float derivative_component = 0; // error change rate w.r.t time
            float integral_component = 0; // total accumulated error

            bool fill_n2_check = false;

            TC_channel_out(OvenChanStatusEnum.all_off);   // start with all oven channels off
            air_channel_out(AirChanStatusEnum.air_off);     //Start with air switched off

            while (oven_check == 1)
            {
                if (CoolMethod_copy == "1")
                {
                    // Flow high pressure nitrogen for like 10 seconds to fill
                    // the oven cavity with nitrogen
                    if (fill_n2_check == false)
                    {
                        air_channel_out(AirChanStatusEnum.high_n2);
                        Thread.Sleep(1000);
                        count++;
                        if (count >= 10)
                        {
                            fill_n2_check = true;
                            count = 0;
                        }
                        else
                            continue;
                    }

                    // Low pressure N2 trickle begins
                    air_channel_out(AirChanStatusEnum.low_n2);
                }

                // CONTROL HERE !!! ///////////// HEATING BEGINS !!! //////////

                Heat_Time = DateTime.Now;

                if (PID_LogData.Max() <= (0.80 * Convert.ToInt32(MaxTemp.Text)))
                {
                    TC_channel_out(OvenChanStatusEnum.oven_on);

                    if (HeatingStarted == false)        // Reach 80% temp. with
                    {                                   // just direct heating
                        HeatingStarted = true;
                        HeatingStopped = false;
                        HeatingStopped_logged = false;
                    }
                }
                else if (MaxTempReached == false)
                {
                    // The deivative component is degrees / second error change
                    // rate. Let's attempt to keep it at error * 0.01 for now

                    if (derivative_component < current_error * 0.01)
                        TC_channel_out(OvenChanStatusEnum.oven_on);
                    else
                        TC_channel_out(OvenChanStatusEnum.oven_off);

                    if (current_error <= 0)
                    {
                        MaxTempReached = true;
                    }

                }
                else
                    TC_channel_out(OvenChanStatusEnum.oven_off);

                ///////////////////////////////////////////////////////////////

                for (int i = 0; i < MAX_CHANCOUNT; i++)
                {
                    RetVal = daq.TIn(i, TempScale.Celsius,
                        out PID_LogData[i], ThermocoupleOptions.Filter);

                    if (RetVal.Value != 0)
                        PID_LogData[i] = 0;
                }

                current_error = PID_max_temp - PID_LogData.Max();
                time_slice = (float)DateTime.Now.Subtract(Heat_Time).TotalSeconds;

                integral_component += current_error;

                derivative_component = (prev_error - current_error) /
                    (time_slice);

                prev_error = current_error;

                count++;
            }

            TC_channel_out(OvenChanStatusEnum.oven_off);
        }
示例#54
0
文件: ULAI03.cs 项目: otoauler/sdkpub
        private short UserTerm; //  flag to stop acquisition manually

        #endregion Fields

        #region Constructors

        public frmStatusDisplay()
        {
            MccDaq.ErrorInfo ULStat;

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

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

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

            //  set aside memory to hold data
            MemHandle = MccDaq.MccService.WinBufAlloc(NumPoints);

            //  Note: Any change to label names requires a change to the corresponding array element
            lblADData = (new Label[] {this._lblADData_0, this._lblADData_1, this._lblADData_2, this._lblADData_3, this._lblADData_4, this._lblADData_5, this._lblADData_6, this._lblADData_7});
        }
示例#55
0
        // This function reads and displays the temperature inputs by detecting
        // the buttons clicked, by detecting the value of the variable "check".
        // It runs a while loop to keep checking for button presses, and using
        // Thread.Sleep(), it checks buttons, reads and displays temperatures in
        // the selected scale at a set frequency (2 Hz). The loop ends when the
        // value of check is set to -1 by clicking the Exit button. Temperatures
        // are read using the TInScan function, and an array is passed to the
        // update_gui() function to display them using a delegate.
        private void TC_reader()
        {
            while (true)
               {
                if (check == 1 || check == 3)
                {
                    MccBoard daq = new MccDaq.MccBoard(BoardNum);

                    float[] TempData = new float[CHANCOUNT];

                    MccDaq.ErrorInfo RetVal;

                    switch(T_Scale)
                    {
                        case "F":
                            RetVal = daq.TInScan(FIRSTCHANNEL, LASTCHANNEL,
                                TempScale.Fahrenheit, out TempData[0], ThermocoupleOptions.Filter);
                            IsError(RetVal);
                            break;
                        case "K":
                            RetVal = daq.TInScan(FIRSTCHANNEL, LASTCHANNEL,
                                TempScale.Kelvin, out TempData[0], ThermocoupleOptions.Filter);
                            IsError(RetVal);
                            break;
                        default:
                            RetVal = daq.TInScan(FIRSTCHANNEL, LASTCHANNEL,
                                TempScale.Celsius, out TempData[0], ThermocoupleOptions.Filter);
                            IsError(RetVal);
                            break;
                    }

                    Update_Display update_del = new Update_Display(update_gui);

                    Invoke(update_del, TempData);

                    Thread.Sleep(500);
                }

                if (check == -1)
                {
                    break;
                }
             }
        }
示例#56
0
文件: ULDI03.cs 项目: otoauler/sdkpub
        public frmDScan()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            lblDataRead = (new Label[]{_lblDataRead_0, _lblDataRead_1, _lblDataRead_2, _lblDataRead_3, _lblDataRead_4,
                                    _lblDataRead_5, _lblDataRead_6, _lblDataRead_7, _lblDataRead_8, _lblDataRead_9});

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

            // set aside memory to hold data
            MemHandle = MccDaq.MccService.WinBufAlloc(NumPoints);

            //  configure FirstPortA for digital input
            //   Parameters:
            //     PortNum    :the input port
            //     Direction  :sets the port for input or output
            PortNum = MccDaq.DigitalPortType.FirstPortA;
            ULStat = DaqBoard.DConfigPort(PortNum, Direction);

            // configure FirstPortA & FirstPortB for digital input
            //   Parameters:
            //      PortNum    :the input port
            //      Direction  :sets the port for input or output
            PortNum = MccDaq.DigitalPortType.FirstPortB;
            ULStat = DaqBoard.DConfigPort(PortNum, Direction);

            Force = 0;
        }
示例#57
0
文件: ULCT02.cs 项目: otoauler/sdkpub
        //  chip on CTR10
        public frm9513Ctr()
        {
            // 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);

            //  Initialize the board level features
            //   Parameters:
            //     ChipNum       :Chip to be initialized (1 for CTR05, 1 or 2 for CTR10)
            //     FOutDivider   :the F-Out divider (0-15)
            //     FOutSource    :the signal source for F-Out
            //     Compare1      :status of comparator 1
            //     Compare2      :status of comparator 2
            //     TimeOfDay     :time of day mode control
            short FOutDivider = 0;
            MccDaq.CounterSource FOutSource = MccDaq.CounterSource.Freq4;
            MccDaq.CompareValue Compare1 = MccDaq.CompareValue.Disabled;
            MccDaq.CompareValue Compare2 = MccDaq.CompareValue.Disabled;
            MccDaq.TimeOfDay TimeOfDayCounting = MccDaq.TimeOfDay.Disabled;
            ULStat = DaqBoard.C9513Init(ChipNum, FOutDivider, FOutSource, Compare1, Compare2, TimeOfDayCounting);

            //  Set the configurable operations of the counter
            //   Parameters:
            //     CounterNum     :the counter to be configured (1 to 5 for CTR05)
            //     GateControl    :gate control value
            //     CounterEdge    :which edge to count
            //     CountSource    :signal source
            //     SpecialGate    :status of special gate
            //     Reload         :method of reloading
            //     RecyleMode     :recyle mode
            //     BCDMode        :counting mode, Binary or BCD
            //     CountDirection :direction for the counting operation (COUNTUP or COUNTDOWN)
            //     OutputControl  :output signal type and level
            MccDaq.GateControl GateControl = MccDaq.GateControl.NoGate;
            MccDaq.CountEdge CounterEdge = MccDaq.CountEdge.PositiveEdge;
            MccDaq.CounterSource CountSource = MccDaq.CounterSource.Freq4;
            MccDaq.OptionState SpecialGate = MccDaq.OptionState.Disabled;
            MccDaq.Reload Reload = MccDaq.Reload.LoadReg;
            MccDaq.RecycleMode RecycleMode = MccDaq.RecycleMode.Recycle;
            MccDaq.BCDMode BCDMode = MccDaq.BCDMode.Disabled;
            MccDaq.CountDirection CountDirection = MccDaq.CountDirection.CountUp;
            MccDaq.C9513OutputControl OutputControl = MccDaq.C9513OutputControl.AlwaysLow;
            ULStat = DaqBoard.C9513Config(CounterNum, GateControl, CounterEdge, CountSource, SpecialGate, Reload, RecycleMode, BCDMode, CountDirection, OutputControl);

            //  Send a starting value to the counter with MccDaq.MccBoard.CLoad()
            //   Parameters:
            //     RegName    :the register for loading the counter with the starting value
            //     LoadValue  :the starting value to place in the counter
            MccDaq.CounterRegister RegName = MccDaq.CounterRegister.LoadReg1; //  name of register in counter 1
            int LoadValue = 1000;
            ULStat = DaqBoard.CLoad(RegName, LoadValue);

            lblLoadValue.Text = "Value loaded to counter:";
            lblShowLoadVal.Text = LoadValue.ToString("0");
        }
示例#58
0
文件: ULMM01.cs 项目: otoauler/sdkpub
        public frmShowFileData()
        {
            // 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);
            MemBoard = new MccDaq.MccBoard(MemBoardNum);

            lblShowData = (new Label[]{_lblShowData_0, _lblShowData_1, _lblShowData_2, _lblShowData_3, _lblShowData_4,
                                          _lblShowData_5, _lblShowData_6, _lblShowData_7, _lblShowData_8, _lblShowData_9,
                                          _lblShowData_10, _lblShowData_11, _lblShowData_12, _lblShowData_13, _lblShowData_14,
                                          _lblShowData_15, _lblShowData_16, _lblShowData_17, _lblShowData_18, _lblShowData_19});
        }
示例#59
0
文件: ULGT04.cs 项目: otoauler/sdkpub
        /* Handles cmdListInstalled.Click */
        private void cmdListInstalled_Click(object eventSender, System.EventArgs eventArgs)
        {
            // Get board type of each board currently installed
            txtListBoards.Text = "Currently installed boards:" + LF + LF;

            int typeVal;
            string BoardName;
            MccDaq.ErrorInfo ULStat;
            for (int BoardNum=0; BoardNum < MaxNumBoards; ++BoardNum)
            {
                MccDaq.MccBoard board = new MccDaq.MccBoard(BoardNum);
                ULStat = board.BoardConfig.GetBoardType(out typeVal);
                if (typeVal != 0)
                {
                    //  Get the BoardName property from the MccBoard object
                    BoardName = board.BoardName;
                    BoardName = BoardName.TrimEnd(); // Drop the space characters
                    BoardName = BoardName.Substring(0, BoardName.Length - 1);

                    txtListBoards.Text += "Board #" + BoardNum.ToString("0") + " = " + BoardName + LF;
                }
            }
        }
示例#60
0
        // This function changes CHANCOUNT, by detecting the actual number of
        // working thermocouple inputs connected to the USB-TC board.
        private void DetectThermoCoupleInputs()
        {
            MccBoard daq = new MccDaq.MccBoard(BoardNum);
            MccDaq.ErrorInfo RetVal;

            CHANCOUNT = MAX_CHANCOUNT;
            NUM_WALLCOUNT = 2;

            float[] temp = new float[MAX_CHANCOUNT];

            try
            {
                for (int i = 0; i < MAX_CHANCOUNT; i++)
                {
                    RetVal = daq.TIn(i, TempScale.Celsius,
                        out temp[i], ThermocoupleOptions.Filter);

                    if (RetVal.Value != 0)
                    {
                        CHANCOUNT--;

                        ((CheckBox)this.Controls["Channel" +
                            i.ToString("#0") + "CheckBox"]).Checked = false;

                        ((CheckBox)this.Controls["Channel" +
                            i.ToString("#0") + "CheckBox"]).Enabled = false;

                        if (i == (int)TemperatureVsTimeDataSeriesEnum.Inner ||
                            i == (int)TemperatureVsTimeDataSeriesEnum.Outer)
                        {
                            NUM_WALLCOUNT--;
                        }
                    }
                    else
                    {
                        ((CheckBox)this.Controls["Channel" +
                            i.ToString("#0") + "CheckBox"]).Checked = true;

                        ((CheckBox)this.Controls["Channel" +
                            i.ToString("#0") + "CheckBox"]).Enabled = true;
                    }

                }

                NumThermocouplesDetectedTextBox.Text = " " + CHANCOUNT.ToString();

                return;
            }

            catch(Exception e)
            {
                MessageBox.Show(
                    String.Format(
                        "ThermoCouple_Finder has encountered an unexpected error!{0}" +
                        "Error Message: {1}{0}" +
                        "Error Source: {2}{0}" +
                        "Stack Trace: {3}{0}",
                        Environment.NewLine,
                        e.Message,
                        e.Source,
                        e.StackTrace)
                    , "   " + "ERROR!");
                return;
            }
        }