Esempio n. 1
0
        private static string cycleStateMachine()
        {
            switch (currentState)
            {
            case (int)CYCLE_STATE.SET_TEST_POINT:
            {
                // Check for end
                if (currentTestPoint >= CyclePoints.cyclePoints.Length)
                {
                    AdtsCom.setGround();
                    uiForm.bADCTestPointNum.Text = "Complete";
                    return("end");
                }
                else
                {
                    // Move to next
                    AdtsCom.setBca(CyclePoints.cyclePoints[currentTestPoint]);
                    AdtsCom.setIas(0.0);
                    return("next");
                }
            }

            case (int)CYCLE_STATE.WAIT_TEST_POINT:
            {
                // Wait for move to complete
                if (AdtsCom.getInMotion())
                {
                    return("wait");
                }
                else
                {
                    // Go to next point
                    currentTestPoint++;

                    // Loop back in state machine
                    currentState = (int)CYCLE_STATE.SET_TEST_POINT;
                    return("wait");
                }
            }

            default:
            {
                return("end");
            }
            }
        }
Esempio n. 2
0
        private static string calPointsStateMachine()
        {
            int loop = 0;

            switch (currentState)
            {
            case (int)CAL_STATE.SET_TEST_POINT:
            {
                // Check for end
                if (BcaCalPoints.currentCalPoint >= BcaCalPoints.bcaCalPoint.Length)
                {
                    // Last point reached - end cal cycle
                    uiForm.setConsoleText("AD", "CAL END\n");
                    AdtsCom.setGround();
                    // Shut this state off
                    calPointsRunning = false;
                    // Button color
                    uiForm.bStartAdcCal.BackColor = System.Drawing.Color.DarkGreen;

                    // Check for chain
                    if (true)
                    {
                        // Start Prog cycle
                        setPrgRunningState(true);
                        return("wait");
                    }

                    return("end");
                }
                else
                {
                    // Move to next position
                    AdtsCom.setIas(0.0);
                    AdtsCom.setBca(BcaCalPoints.bcaCalPoint[BcaCalPoints.currentCalPoint]);
                    BcaCalPoints.currentTargetAlt = BcaCalPoints.bcaCalPoint[BcaCalPoints.currentCalPoint];
                    uiForm.setConsoleText("AD", "CAL POINT SET\n");
                    return("next");
                }
            }

            case (int)CAL_STATE.WAIT_TEST_POINT:
            {
                // Wait for move to complete
                if (AdtsCom.getInMotion())
                {
                    return("wait");
                }
                else
                {
                    return("next");
                }
            }

            case (int)CAL_STATE.GET_DATA:
            {
                // Multiple samples
                if (sampleCount < SAMPLE_COUNT)
                {
                    // Get average readings
                    if (uiForm.cbLru0Use.Checked)
                    {
                        av0PReading[sampleCount] = uiForm.lru0.dataParam[(int)PARAM.SENP];
                        av0SReading[sampleCount] = uiForm.lru0.dataParam[(int)PARAM.SENS];
                    }
                    if (uiForm.cbLru1Use.Checked)
                    {
                        av1PReading[sampleCount] = uiForm.lru1.dataParam[(int)PARAM.SENP];
                        av1SReading[sampleCount] = uiForm.lru1.dataParam[(int)PARAM.SENS];
                    }
                    if (uiForm.cbLru2Use.Checked)
                    {
                        av2PReading[sampleCount] = uiForm.lru2.dataParam[(int)PARAM.SENP];
                        av2SReading[sampleCount] = uiForm.lru2.dataParam[(int)PARAM.SENS];
                    }
                    if (uiForm.cbLru3Use.Checked)
                    {
                        av3PReading[sampleCount] = uiForm.lru3.dataParam[(int)PARAM.SENP];
                        av3SReading[sampleCount] = uiForm.lru3.dataParam[(int)PARAM.SENS];
                    }


                    sampleCount++;
                    return("wait");
                }
                else
                {
                    // Store average readings
                    if (uiForm.cbLru0Use.Checked)
                    {
                        BcaCalPoints.sen0PCalPoint[BcaCalPoints.currentCalPoint] = av0PReading.Average();
                        BcaCalPoints.sen0SCalPoint[BcaCalPoints.currentCalPoint] = av0SReading.Average();
                    }
                    if (uiForm.cbLru1Use.Checked)
                    {
                        BcaCalPoints.sen1PCalPoint[BcaCalPoints.currentCalPoint] = av1PReading.Average();
                        BcaCalPoints.sen1SCalPoint[BcaCalPoints.currentCalPoint] = av1SReading.Average();
                    }
                    if (uiForm.cbLru2Use.Checked)
                    {
                        BcaCalPoints.sen2PCalPoint[BcaCalPoints.currentCalPoint] = av2PReading.Average();
                        BcaCalPoints.sen2SCalPoint[BcaCalPoints.currentCalPoint] = av2SReading.Average();
                    }
                    if (uiForm.cbLru3Use.Checked)
                    {
                        BcaCalPoints.sen3PCalPoint[BcaCalPoints.currentCalPoint] = av3PReading.Average();
                        BcaCalPoints.sen3SCalPoint[BcaCalPoints.currentCalPoint] = av3SReading.Average();
                    }

                    // Add to cal data table
                    uiForm.dgAdcCalPoint.Rows.Add(BcaCalPoints.bcaCalPoint[BcaCalPoints.currentCalPoint].ToString());

                    Control dgv;
                    dgv = uiForm.Controls.Find("dgAdcLru0Data", true).FirstOrDefault();
                    (dgv as DataGridView).Rows.Add(av0PReading.Average().ToString("0000.00"), av0SReading.Average().ToString("0000.00"), "MEASURED");

                    dgv = uiForm.Controls.Find("dgAdcLru1Data", true).FirstOrDefault();
                    (dgv as DataGridView).Rows.Add(av1PReading.Average().ToString("0000.00"), av1SReading.Average().ToString("0000.00"), "MEASURED");

                    dgv = uiForm.Controls.Find("dgAdcLru2Data", true).FirstOrDefault();
                    (dgv as DataGridView).Rows.Add(av2PReading.Average().ToString("0000.00"), av2SReading.Average().ToString("0000.00"), "MEASURED");

                    dgv = uiForm.Controls.Find("dgAdcLru3Data", true).FirstOrDefault();
                    (dgv as DataGridView).Rows.Add(av3PReading.Average().ToString("0000.00"), av3SReading.Average().ToString("0000.00"), "MEASURED");


                    // Go to next point
                    BcaCalPoints.currentCalPoint++;

                    // Loop back in state machine
                    currentState = (int)CAL_STATE.SET_TEST_POINT;
                    sampleCount  = 0;
                    return("wait");
                }
            }

            default:
            {
                return("end");
            }
            }
        }
Esempio n. 3
0
        private static string atpIasStateMachine()
        {
            switch (currentState)
            {
            case (int)ATP_STATE.SET_TEST_POINT:
            {
                // Check for end
                if (currentTestPoint >= MopsTestPoints.mopsIasTestPoint.Length)
                {
                    currentState     = 0;
                    currentTestPoint = 0;
                    setMopsAtpIasRunningSate(false);
                    AdtsCom.setGround();
                    return("end");
                }
                else
                {
                    // Move to next
                    AdtsCom.setIas(MopsTestPoints.mopsIasTestPoint[currentTestPoint]);
                    AdtsCom.setBca(IAS_ALT_POINT);
                    return("next");
                }
            }

            case (int)ATP_STATE.WAIT_TEST_POINT:
            {
                // Wait for move to complete
                if (AdtsCom.getInMotion())
                {
                    return("wait");
                }
                else
                {
                    return("next");
                }
            }

            case (int)ATP_STATE.GET_DATA:
            {
                // Multiple samples
                if (sampleCount < SAMPLE_COUNT)
                {
                    // LRU 0
                    // Get average readings
                    avReading[sampleCount] = uiForm.lru0.dataParam[(int)PARAM.IAS];

                    sampleCount++;
                    return("wait");
                }
                else
                {
                    // Add results to test table
                    //uiForm.dgAdcAtpIasLru0Data.Rows.Add(avReading.Average().ToString("000.00"),
                    //	(avReading.Average() - AtpTestPoints.iasTestPoint[currentTestPoint]).ToString("+0;-#;000.00"),
                    //	"PASS");

                    double error = Math.Abs(avReading.Average() - MopsTestPoints.mopsIasTestPoint[currentTestPoint]);
                    if (error < MopsTestPoints.mopsIasTolerance[currentTestPoint])
                    {
                        uiForm.dgMopsAdcTestResults.Rows.Add(avReading.Average().ToString("000.0"), error.ToString("+0.0;-#;0.0"), "PASS");
                    }
                    else
                    {
                        uiForm.dgMopsAdcTestResults.Rows.Add(avReading.Average().ToString("000.0"), error.ToString("+0.0;-#;0.0"), "FAIL");
                    }

                    // Go to next point
                    currentTestPoint++;

                    // Loop back in state machine
                    currentState = (int)ATP_STATE.SET_TEST_POINT;
                    sampleCount  = 0;
                    return("wait");
                }
            }

            default:
            {
                return("end");
            }
            }
        }
Esempio n. 4
0
        private static string atpIasStateMachine()
        {
            int loop = 0;

            switch (currentState)
            {
            case (int)ATP_STATE.SET_TEST_POINT:
            {
                // Check for end
                if (currentTestPoint >= AtpTestPoints.iasTestPoint.Length)
                {
                    AdtsCom.setGround();
                    return("end");
                }
                else
                {
                    // Move to next
                    AdtsCom.setIas(AtpTestPoints.iasTestPoint[currentTestPoint]);
                    AdtsCom.setBca(IAS_ALT_POINT);
                    return("next");
                }
            }

            case (int)ATP_STATE.WAIT_TEST_POINT:
            {
                // Wait for move to complete
                if (AdtsCom.getInMotion())
                {
                    return("wait");
                }
                else
                {
                    return("next");
                }
            }

            case (int)ATP_STATE.GET_DATA:
            {
                // Multiple samples
                if (sampleCount < SAMPLE_COUNT)
                {
                    // LRU 0
                    // Get average readings
                    if (uiForm.cbLru0Use.Checked)
                    {
                        av0Reading[sampleCount] = uiForm.lru0.dataParam[(int)PARAM.IAS];
                    }
                    if (uiForm.cbLru1Use.Checked)
                    {
                        av1Reading[sampleCount] = uiForm.lru1.dataParam[(int)PARAM.IAS];
                    }
                    if (uiForm.cbLru2Use.Checked)
                    {
                        av2Reading[sampleCount] = uiForm.lru2.dataParam[(int)PARAM.IAS];
                    }
                    if (uiForm.cbLru3Use.Checked)
                    {
                        av3Reading[sampleCount] = uiForm.lru3.dataParam[(int)PARAM.IAS];
                    }

                    sampleCount++;
                    return("wait");
                }
                else
                {
                    // Add results to test table
                    //uiForm.dgAdcAtpIasLru0Data.Rows.Add(av0Reading.Average().ToString("000.00"),
                    //    (av0Reading.Average() - AtpTestPoints.iasTestPoint[currentTestPoint]).ToString("+0;-#;000.00"),
                    //    "PASS");

                    if (uiForm.cbLru0Use.Checked)
                    {
                        double error = Math.Abs(av0Reading.Average() - AtpTestPoints.iasTestPoint[currentTestPoint]);
                        if (error < AtpTestPoints.iasTolerance[currentTestPoint])
                        {
                            uiForm.dgAdcAtpIasLru0Data.Rows.Add(av0Reading.Average().ToString("0000.00"), error.ToString("+0;-#;000.00"), "PASS");
                        }
                        else
                        {
                            uiForm.dgAdcAtpIasLru0Data.Rows.Add(av0Reading.Average().ToString("0000.00"), error.ToString("+0;-#;000.00"), "** FAIL **");
                        }
                    }
                    if (uiForm.cbLru1Use.Checked)
                    {
                        double error = Math.Abs(av1Reading.Average() - AtpTestPoints.iasTestPoint[currentTestPoint]);
                        if (error < AtpTestPoints.iasTolerance[currentTestPoint])
                        {
                            uiForm.dgAdcAtpIasLru1Data.Rows.Add(av1Reading.Average().ToString("0000.00"), error.ToString("+0;-#;000.00"), "PASS");
                        }
                        else
                        {
                            uiForm.dgAdcAtpIasLru1Data.Rows.Add(av1Reading.Average().ToString("0000.00"), error.ToString("+0;-#;000.00"), "** FAIL **");
                        }
                    }
                    if (uiForm.cbLru2Use.Checked)
                    {
                        double error = Math.Abs(av2Reading.Average() - AtpTestPoints.iasTestPoint[currentTestPoint]);
                        if (error < AtpTestPoints.iasTolerance[currentTestPoint])
                        {
                            uiForm.dgAdcAtpIasLru2Data.Rows.Add(av2Reading.Average().ToString("0000.00"), error.ToString("+0;-#;000.00"), "PASS");
                        }
                        else
                        {
                            uiForm.dgAdcAtpIasLru2Data.Rows.Add(av2Reading.Average().ToString("0000.00"), error.ToString("+0;-#;000.00"), "** FAIL **");
                        }
                    }
                    if (uiForm.cbLru3Use.Checked)
                    {
                        double error = Math.Abs(av3Reading.Average() - AtpTestPoints.iasTestPoint[currentTestPoint]);
                        if (error < AtpTestPoints.iasTolerance[currentTestPoint])
                        {
                            uiForm.dgAdcAtpIasLru3Data.Rows.Add(av3Reading.Average().ToString("0000.00"), error.ToString("+0;-#;000.00"), "PASS");
                        }
                        else
                        {
                            uiForm.dgAdcAtpIasLru3Data.Rows.Add(av3Reading.Average().ToString("0000.00"), error.ToString("+0;-#;000.00"), "** FAIL **");
                        }
                    }


                    // Go to next point
                    currentTestPoint++;

                    // Loop back in state machine
                    currentState = (int)ATP_STATE.SET_TEST_POINT;
                    sampleCount  = 0;
                    return("wait");
                }
            }

            default:
            {
                return("end");
            }
            }
        }