Exemple #1
0
        private void btnSweepTest_Click(object sender, EventArgs e)
        {
            if (!testStarted)//Start test.
            {
                //Indicate test has started.
                btnSweepTest.Text = "Abort Test";
                testStarted       = true;

                disableGUI();      //Disable all GUI components.
                resetData();       //Reset all data.
                removeListeners(); //Remove action listeners from the charts.

                //Reset state machine.
                sweepState = swpState.SWP_IDLE;

                //Start test.
                aq.validateDevice(this.btnSweepTest);
                sweepTimer.setTimer(400, timerTypes.TIMER_SWP_TEST, this.btnSweepTest);
            }

            else//Abort the current test.
            {
                //Send abort message to device.
                byte[] bArray = new byte[8];
                bArray[0] = (byte)'X';

                try
                {
                    aq.sp.Write(bArray, 0, 1);
                }
                catch (Exception err)
                {
                    aq.comCloser();
                    aq.comErrorHandler(err.ToString());
                }
            }
        }
Exemple #2
0
        /************************************RX State Machine Functions*************************************/

        public void difTestStateMachine(byte[] bArray, int arraySize)
        {
            UInt16 tempWord;

            //Add incomming data to raw data array.
            for (int i = 0; i < arraySize; i++)
            {
                incommingData.Add(bArray[i]);
            }

            //Update index value.
            totalIndex += arraySize;

            //Populate the word list.
            while (wordBuildingIndex < totalIndex - 1)
            {
                tempWord  = (UInt16)(incommingData[wordBuildingIndex++] << 8);
                tempWord |= (UInt16)(incommingData[wordBuildingIndex++]);
                wordData.Add(tempWord);
            }

            int    gain = aq.aqSettings.tiaGain;
            double gainResistance;

            //compute gain resistance for y-axis current.
            if (gain == 1)
            {
                gainResistance = 100.0;
            }
            else if (gain == 2)
            {
                gainResistance = 1000.0;
            }
            else if (gain == 3)
            {
                gainResistance = 5100.0;
            }
            else if (gain == 4)
            {
                gainResistance = 10000.0;
            }
            else if (gain == 5)
            {
                gainResistance = 51000.0;
            }
            else
            {
                gainResistance = 100000.0;
            }

            while (thisWordIndex < wordData.Count)
            {
                tempWord = wordData[thisWordIndex++];

                switch (sweepState)
                {
                /*****************************************Idle******************************************/

                case swpState.SWP_IDLE:
                    if (tempWord == START_DEP)    //Prepare for deposition.
                    {
                        prepDepChart();
                        sweepState = swpState.SWP_DEP;    //Move to deposition state.
                    }
                    else if (tempWord == START_QUIET)
                    {
                        prepQuietChart();
                        sweepState = swpState.SWP_QUIET;    //Move to quiet time state.
                    }
                    else if (tempWord == START_LIN_SWEEP)
                    {
                        prepRawChart();
                        prepIVChart();
                        sweepState = swpState.SWP_COUNT;    //Move to linear sweep state.
                    }
                    else if (tempWord == ABORT)
                    {
                        doAbort();
                        sweepState = swpState.SWP_ABORT; //Already handled by above function.
                    }
                    else                                 //Error state.
                    {
                        doError();
                        sweepState = swpState.SWP_ERR;    //Already handled above.
                    }
                    break;

                /**************************************Deposition***************************************/

                case swpState.SWP_DEP:
                    if (tempWord == END_BLOCK)    //End of deposition.  Move on.
                    {
                        sweepState = swpState.SWP_DEP_END;
                    }
                    else if (tempWord == ABORT)    //Already handled by above function.
                    {
                        doAbort();
                        sweepState = swpState.SWP_ABORT;
                    }
                    else if (tempWord < ADC_MAX_VALUE)
                    {
                        //Convert data to current and add to list;
                        ds.depAdd(new DataPoint(thisDepTime, (tempWord - 2047) * I_CONSTANT / gainResistance));
                        thisDepTime += depDT;
                    }
                    else    //Error state.
                    {
                        doError();
                        sweepState = swpState.SWP_ERR;    //Already handled above.
                    }
                    break;

                case swpState.SWP_DEP_END:
                    updateTimer.Enabled = false;

                    if (tempWord == START_QUIET)
                    {
                        prepQuietChart();
                        sweepState = swpState.SWP_QUIET;    //Move to quiet time state.
                    }
                    else if (tempWord == START_LIN_SWEEP)
                    {
                        prepRawChart();
                        prepIVChart();
                        sweepState = swpState.SWP_COUNT;    //Move to linear sweep state.
                    }
                    else if (tempWord == ABORT)
                    {
                        doAbort();
                        sweepState = swpState.SWP_ABORT; //Already handled by above function.
                    }
                    else                                 //Error state.
                    {
                        doError();
                        sweepState = swpState.SWP_ERR;    //Already handled above.
                    }
                    break;

                /*****************************************Quiet*****************************************/

                case swpState.SWP_QUIET:
                    if (tempWord == END_BLOCK)    //End of quiet time.  Move on.
                    {
                        sweepState = swpState.SWP_QUIET_END;
                    }
                    else if (tempWord == ABORT)    //Already handled by above function.
                    {
                        doAbort();
                        sweepState = swpState.SWP_ABORT;
                    }
                    else if (tempWord < ADC_MAX_VALUE)
                    {
                        //Convert data to current and add to list;
                        ds.quietAdd(new DataPoint(thisQuietTime, (tempWord - 2047) * I_CONSTANT / gainResistance));
                        thisQuietTime += quietDT;
                    }
                    else    //Error state.
                    {
                        doError();
                        sweepState = swpState.SWP_ERR;    //Already handled above.
                    }
                    break;

                case swpState.SWP_QUIET_END:
                    updateTimer.Enabled = false;

                    if (tempWord == START_LIN_SWEEP)
                    {
                        prepRawChart();
                        prepIVChart();
                        sweepState = swpState.SWP_COUNT;    //Move to linear sweep state.
                    }
                    else if (tempWord == ABORT)
                    {
                        doAbort();
                        sweepState = swpState.SWP_ABORT; //Already handled by above function.
                    }
                    else                                 //Error state.
                    {
                        doError();
                        sweepState = swpState.SWP_ERR;    //Already handled above.
                    }
                    break;

                /*****************************************Sweep*****************************************/

                case swpState.SWP_COUNT:
                    ds.ivAdd();    //Add new array to sweep data list.
                    thisIVCounts.Add(0);
                    sweepCount++;
                    sweepState = swpState.SWP_SWEEP;
                    break;

                case swpState.SWP_SWEEP:
                    if (tempWord == END_BLOCK)
                    {
                        sweepDV   *= -1;    //Change slope of sweep.
                        sweepState = swpState.SWP_END;
                    }
                    else if (tempWord == ABORT)
                    {
                        doAbort();
                        sweepState = swpState.SWP_ABORT;    //Already handled by above function.
                    }
                    else if (tempWord < ADC_MAX_VALUE)
                    {
                        //Add data to raw data chart.
                        ds.rawAdd(new DataPoint(ds.rawCount(), tempWord));

                        //Convert data to current and add to list;
                        ds.ivAddSub(sweepCount, new DataPoint(thisSweepVoltage, (tempWord - 2047) * I_CONSTANT / gainResistance));
                        thisSweepVoltage += sweepDV;
                    }
                    else    //Error state.
                    {
                        doError();
                        sweepState = swpState.SWP_ERR;    //Already handled above.
                    }
                    break;

                case swpState.SWP_END:
                    if (tempWord == START_LIN_SWEEP)
                    {
                        sweepState = swpState.SWP_COUNT;
                    }
                    else if (tempWord == ABORT)
                    {
                        doAbort();
                        sweepState = swpState.SWP_ABORT;    //Already handled by above function.
                    }
                    else if (tempWord == END_TEST)
                    {
                        //Add test type.
                        ds.typeSet("SWP");

                        //Add test name.  Current date and time.  User can change later.
                        ds.nameSet(DateTime.Now.ToString());

                        //Add settings info.
                        ds.settings.arraySet(aq.aqSettings.settingsArray);
                        ds.settings.setByArray(aq.aqSettings.settingsArray);

                        Thread.Sleep(300);    //Give charts time to update.

                        BeginInvoke((MethodInvoker) delegate
                        {
                            //Copy data to top of data tree.
                            aq.dataTree.insertAtIndex(ds, 0);

                            //Set graphing markers in tree view for first data set.
                            aq.dataTree.treeGraphFirstItem();

                            //Causes the graphs to be updated based on the tree view graph markers.
                            aq.dataTree.updateGraphs();

                            enableGUI();    //Give control back to the user.
                            addListeners();
                            resetTestButton();
                            aq.wfHelper.dataLoaded = true;
                        });

                        updateTimer.Enabled = false;
                        sweepState          = swpState.SWP_COMP;
                        aq.rxState          = rxStates.RX_IDLE;
                    }
                    else    //Error state.
                    {
                        doError();
                        sweepState = swpState.SWP_ERR;    //Already handled above.
                    }
                    break;

                /**************************************End States***************************************/

                case swpState.SWP_COMP:
                    sweepState = swpState.SWP_IDLE;    //Shouldn't get here.
                    break;

                case swpState.SWP_ABORT:
                    sweepState = swpState.SWP_IDLE;    //Shouldn't get here.
                    break;

                case swpState.SWP_ERR:    //Nothing to do.  Already handled.
                default:
                    sweepState = swpState.SWP_IDLE;
                    break;
                }
            }
        }