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"); } } }
// Cal Points Start / Stop public static void setCalRunningSate(bool run) { if (run) { connect(); // Start at beginning of table BcaCalPoints.currentCalPoint = 0; currentState = 0; uiForm.setConsoleText("AD", "CYCLE START\n"); // Clear data grid view entries Control dgv = uiForm.Controls.Find("dgAdcLru0Data", true).FirstOrDefault(); (dgv as DataGridView).Rows.Clear(); dgv = uiForm.Controls.Find("dgAdcLru1Data", true).FirstOrDefault(); (dgv as DataGridView).Rows.Clear(); dgv = uiForm.Controls.Find("dgAdcLru2Data", true).FirstOrDefault(); (dgv as DataGridView).Rows.Clear(); dgv = uiForm.Controls.Find("dgAdcLru3Data", true).FirstOrDefault(); (dgv as DataGridView).Rows.Clear(); dgv = uiForm.Controls.Find("dgAdcCalPoint", true).FirstOrDefault(); (dgv as DataGridView).Rows.Clear(); readPointsRunning = false; prgPointsRunning = false; calPointsRunning = true; // Button color uiForm.bStartAdcCal.BackColor = System.Drawing.Color.Green; } else { // Turn outputs off uiForm.lru0.setParameterReq((int)PARAM.NONE, RATE.RATE_0HZ); // Vent test set AdtsCom.setGround(); // Shutdown state calPointsRunning = false; // Button color uiForm.bStartAdcCal.BackColor = System.Drawing.Color.DimGray; } }
public static void setMopsAtpIasRunningSate(bool run) { mopsIasPointsRunning = run; if (run) { // Start at beginning of table currentState = 0; currentTestPoint = 0; // Clear data grid view entries uiForm.dgMopsAdcTestPoints.Rows.Clear(); uiForm.dgMopsAdcTestPoints.Refresh(); // Show IAS Test Points for (int i = 0; i < MopsTestPoints.mopsIasTestPoint.Length; i++) { uiForm.dgMopsAdcTestPoints.Rows.Add(MopsTestPoints.mopsIasTestPoint[i].ToString(), MopsTestPoints.mopsIasTolerance[i].ToString()); } // Button color uiForm.btMopsIasStart.BackColor = System.Drawing.Color.Green; uiForm.btMopsBcaStart.BackColor = System.Drawing.Color.DimGray; } else { // Turn outputs off //uiForm.lru0.setParameterReq((int)PARAM.NONE, RATE.RATE_0HZ); // Vent test set AdtsCom.setGround(); // Button color uiForm.btMopsIasStart.BackColor = System.Drawing.Color.DimGray; uiForm.btMopsBcaStart.BackColor = System.Drawing.Color.DimGray; mopsBcaPointsRunning = false; mopsIasPointsRunning = false; } }
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"); } } }
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"); } } }
// Test Start / Stop public static void setAtpBcaRunningSate(bool run) { bcaPointsRunning = run; if (run) { // Turn outputs on if (uiForm.cbLru0Use.Checked) { uiForm.lru0.setParameterReq((int)PARAM.NONE, RATE.RATE_0HZ); uiForm.lru0.setParameterReq((int)PARAM.BCA, RATE.RATE_10HZ); uiForm.lru0.setParameterReq((int)PARAM.IAS, RATE.RATE_10HZ); uiForm.lru0.setParameterReq((int)PARAM.STATUS, RATE.RATE_1HZ); } if (uiForm.cbLru1Use.Checked) { uiForm.lru1.setParameterReq((int)PARAM.NONE, RATE.RATE_0HZ); uiForm.lru1.setParameterReq((int)PARAM.BCA, RATE.RATE_10HZ); uiForm.lru1.setParameterReq((int)PARAM.IAS, RATE.RATE_10HZ); uiForm.lru1.setParameterReq((int)PARAM.STATUS, RATE.RATE_1HZ); } if (uiForm.cbLru2Use.Checked) { uiForm.lru2.setParameterReq((int)PARAM.NONE, RATE.RATE_0HZ); uiForm.lru2.setParameterReq((int)PARAM.BCA, RATE.RATE_10HZ); uiForm.lru2.setParameterReq((int)PARAM.IAS, RATE.RATE_10HZ); uiForm.lru2.setParameterReq((int)PARAM.STATUS, RATE.RATE_1HZ); } if (uiForm.cbLru3Use.Checked) { uiForm.lru3.setParameterReq((int)PARAM.NONE, RATE.RATE_0HZ); uiForm.lru3.setParameterReq((int)PARAM.BCA, RATE.RATE_10HZ); uiForm.lru3.setParameterReq((int)PARAM.IAS, RATE.RATE_10HZ); uiForm.lru3.setParameterReq((int)PARAM.STATUS, RATE.RATE_1HZ); } // Start at beginning of table currentState = 0; currentTestPoint = 0; // Clear data grid view entries uiForm.dgAdcAtpBcaLru0Data.ClearSelection(); uiForm.dgAdcAtpBcaLru1Data.ClearSelection(); uiForm.dgAdcAtpBcaLru2Data.ClearSelection(); uiForm.dgAdcAtpBcaLru3Data.ClearSelection(); uiForm.dgAdcAtpBcaTestPoints.ClearSelection(); uiForm.dgAdcAtpIasTestPoints.ClearSelection(); // Show BCA Test Points for (int i = 0; i < AtpTestPoints.bcaTestPoint.Length; i++) { uiForm.dgAdcAtpBcaTestPoints.Rows.Add(AtpTestPoints.bcaTestPoint[i].ToString() + " [" + AtpTestPoints.bcaTolerance[i].ToString() + "]"); } // Show IAS Test Points for (int i = 0; i < AtpTestPoints.iasTestPoint.Length; i++) { uiForm.dgAdcAtpIasTestPoints.Rows.Add(AtpTestPoints.iasTestPoint[i].ToString() + " [" + AtpTestPoints.iasTolerance[i].ToString() + "]"); } // Button color uiForm.bStartAdcAtp.BackColor = System.Drawing.Color.Green; } else { // Turn outputs off uiForm.lru0.setParameterReq((int)PARAM.NONE, RATE.RATE_0HZ); uiForm.lru1.setParameterReq((int)PARAM.NONE, RATE.RATE_0HZ); uiForm.lru2.setParameterReq((int)PARAM.NONE, RATE.RATE_0HZ); uiForm.lru3.setParameterReq((int)PARAM.NONE, RATE.RATE_0HZ); // Button color uiForm.bStartAdcAtp.BackColor = System.Drawing.Color.Transparent; // Vent test set AdtsCom.setGround(); } }
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"); } } }