private void timerExecGPS_Tick(object sender, EventArgs e) { this.timerExecGPS.Enabled = false; if (this.stateGPSPosition == TaskTestState.EXEC) { this.doLog("GPS no fix (" + this.gps_location + ")"); this.stateGPSPosition = TaskTestState.DONE; } }
void gps_OnGPSDateEventHandler(object sender, GPSData e) { this.gps_location = e.GotPosition.ToString() + " (" + e.NumberOfSatellites.ToString() + ") " + e.LongitudeD + "/" + e.LatitudeD; if (e.GotPosition && this.stateGPSPosition==TaskTestState.EXEC) { this.timerExecGPS.Enabled = false; this.stateGPSPosition = TaskTestState.DONE; this.Invoke(new invoked_log(this.doLog), "GPS: " + this.gps_location); } }
// we close the GPS in separate thread because otherwise it may lockup due to thread implementation in .NET private void threadedCloseGPS() { try { if (this.gps != null) { this.gps.CloseComPort(); // this.gps = null; // V1.3.0 } } catch { } this.stateGPSPosition = TaskTestState.IDLE; }
// Initiate the "Belade" Test private void doStartBelade() { Form1.SystemIdleTimerReset(); Form1.SetSystemPowerState(IntPtr.Zero, Form1.POWER_STATE_ON, 0); // V 1.5.3 this.complained = false; // V1.5.2 // devide should not go into suspend, but just in case bool result = (PowerPolicyNotify(PowerMode.UnattendedMode, UNATTENDED_ON) != 0); this.startTime = DateTime.Now; this.timeSpan = DateTime.Now.Subtract(this.startTime); //V1.5.1 this.logFile = @"\My Documents\trans-o-flex-" + this.startTime.ToString("yyyy-MM-dd_HH-mm-ss") + "-Belade.log"; this.textBoxLog.Text = string.Empty; // V1.5.4 swapped, used wrong WirelessManager.SetWWANState(this.radioButtonBeladeGPRS.Checked); WirelessManager.SetWLANState(this.radioButtonBeladeWIFI.Checked); if (this.radioButtonBeladeGPRS.Checked) { this.textBoxLog.Text = "Attaching to GPRS ..."; Application.DoEvents(); if (!this.cmr.Connected) { this.cmr.Connect(this.textBoxGPRSEntry.Text, ConnMgr.ConnectionMode.Asynchronous, this.textBoxGPRSBenutzer.Text, this.textBoxGPRSKennwort.Text, this.textBoxGPRSAPN.Text); int maxWait = 30; while (!cmr.Connected && maxWait-- > 0) { Thread.Sleep(1000); } } } this.startLevel = SystemNotification.GetBatteryLife(); this.lastLevel = this.startLevel; this.numTotalDataBytes = 0; this.testHours = (int)(this.numericUpDownBeladeLaufzeitStunden.Value); // V1.3.0 use global var // V1.5.2 this.testSpan = new TimeSpan(this.testHours, 0, 0); this.doLog("Testdauer Beladephase: " + this.testHours.ToString() + " Stunde(n)"); this.doLog("Akku " + this.startLevel.ToString() + "%"); if (this.testHours > 0) { if ((int)(this.numericUpDownBeladeScanBarcodes.Value) > 0) { int secondsNextScan = this.testHours * 3600 / (int)(this.numericUpDownBeladeScanBarcodes.Value); this.timerPlanScan.Interval = secondsNextScan * 1000; this.doLog("Scan jede " + secondsNextScan.ToString() + " Sekunde(n)"); this.timeoutScanBarcode = (int)(this.numericUpDownBeladeScanBarcodeDurationSekunden.Value) * 1000; } if ((int)(this.numericUpDownBeladeSnapPhotos.Value) > 0) { int secondsNextPhoto = this.testHours * 3600 / (int)(this.numericUpDownBeladeSnapPhotos.Value); this.timerPlanPhoto.Interval = secondsNextPhoto * 1000; this.timeoutSnapPhoto = (int)(this.numericUpDownBeladeSnapPhotoDurationSekunden.Value) * 1000; this.timerExecPhoto.Interval = this.timeoutSnapPhoto; this.doLog("Photo jede " + secondsNextPhoto.ToString() + " Sekunde(n)"); } if ((int)(this.numericUpDownBeladeFTPSessions.Value) > 0) { int secondsNextData = this.testHours * 3600 / (int)(this.numericUpDownBeladeFTPSessions.Value); this.numSendDataBytes = (int)(this.numericUpDownBeladeFTPSessionSize.Value); // V1.2.0 this.timerPlanData.Interval = secondsNextData * 1000; this.doLog("Data jede " + secondsNextData.ToString() + " Sekunde(n)"); } } this.doLog("Test Belade gestart"); this.testPlanType = TestPlanType.BELADE_EXEC; // V1.5.0 this.numScanBarcodes = 0; this.numSnapPhotos = 0; this.numFTPSessions = 0; this.numFTPSuccess = 0; this.numTourCycles = 0; this.stateScanBarcode = TaskTestState.IDLE; this.stateSnapPhoto = TaskTestState.IDLE; this.stateFTPSession = TaskTestState.IDLE; this.stateTourCycle = TaskTestState.IDLE; this.stateGPSPosition = TaskTestState.IDLE; // V1.3.0 // this.timerLoopSecond.Enabled = true; // V1.5.0 if (this.testHours > 0) { this.timerPlanScan.Enabled = ((int)(this.numericUpDownBeladeScanBarcodes.Value) > 0); this.timerPlanPhoto.Enabled = ((int)(this.numericUpDownBeladeSnapPhotos.Value) > 0); this.timerPlanData.Enabled = ((int)(this.numericUpDownBeladeFTPSessions.Value) > 0); this.timerPlanGPS.Enabled = false; // V1.3.0 this.timerPlanTourCycle.Enabled = false; // V1.3.0 } // V1.5.0 done at global test start // this.buttonStop.Enabled = true; }
// Initiate the "Tour" Test private void doStartTour() { Form1.SystemIdleTimerReset(); Form1.SetSystemPowerState(IntPtr.Zero, Form1.POWER_STATE_ON, 0); // V 1.5.3 this.complained = false; // V1.5.2 bool result = (PowerPolicyNotify(PowerMode.UnattendedMode, UNATTENDED_ON) != 0); this.startTime = DateTime.Now; this.timeSpan = DateTime.Now.Subtract(this.startTime); //V1.5.1 this.logFile = @"\My Documents\trans-o-flex-" + this.startTime.ToString("yyyy-MM-dd_HH-mm-ss") + "-Tour.log"; this.textBoxLog.Text = string.Empty; WirelessManager.SetWLANState(false); WirelessManager.SetWWANState(true); this.textBoxLog.Text = "Attaching to GPRS ..."; Application.DoEvents(); if (!this.cmr.Connected) { this.cmr.Connect(this.textBoxGPRSEntry.Text, ConnMgr.ConnectionMode.Asynchronous, this.textBoxGPRSBenutzer.Text, this.textBoxGPRSKennwort.Text, this.textBoxGPRSAPN.Text); int maxWait = 30; while (!cmr.Connected && maxWait-- > 0) { Thread.Sleep(1000); } } this.startLevel = SystemNotification.GetBatteryLife(); this.lastLevel = this.startLevel; this.numTotalDataBytes = 0; this.testHours = (int)(this.numericUpDownTourLaufzeitStunden.Value); // V1.3.0 use global var // V1.5.2 this.testSpan = new TimeSpan(this.testHours, 0, 0); this.doLog("Testdauer Tourphase: " + this.testHours.ToString() + " Stunde(n)"); this.doLog("Akku " + this.startLevel.ToString() + "%"); this.gps_location = "-/-"; this.gps = new GPS("SWI6:", 4800); // this.gps.OpenComPort(); this.gps.OnGPSDateEventHandler += new GPS.GPSDateEventHandler(gps_OnGPSDateEventHandler); if (this.testHours > 0) { if ((int)(this.numericUpDownTourCycleIntervalMinuten.Value) > 0) { int secondsNextScan = (int)(this.numericUpDownTourCycleIntervalMinuten.Value) * 60; this.timerPlanTourCycle.Interval = secondsNextScan * 1000; this.doLog("Interval jede " + secondsNextScan.ToString() + " Sekunde(n)"); this.timeoutScanBarcode = (int)(this.numericUpDownTourCycleScanBarcodeDurationSekunden.Value) * 1000; int secondsDisplayOn = (int)(this.numericUpDownTourCycleDisplayAn.Value) * 60; // V1.5.2 this.doSetTimeouts(0, 0, 0, 0, 0, 0); // V1.5.2 this.timerManageUnattended.Interval = secondsDisplayOn * 1000; this.timerManageUnattended.Enabled = true; this.doLog("Display an " + secondsDisplayOn.ToString() + " Sekunde(n)"); } if ((int)(this.numericUpDownTourSnapPhotos.Value) > 0) { int secondsNextPhoto = this.testHours * 3600 / (int)(this.numericUpDownTourSnapPhotos.Value); this.timerPlanPhoto.Interval = secondsNextPhoto * 1000; this.timeoutSnapPhoto = (int)(this.numericUpDownTourSnapPhotoDurationSekunden.Value) * 1000; this.timerExecPhoto.Interval = this.timeoutSnapPhoto; this.doLog("Photo jede " + secondsNextPhoto.ToString() + " Sekunde(n)"); } if ((int)(this.numericUpDownTourFTPSessionIntervalSekunden.Value) > 0) { int secondsNextData = (int)(this.numericUpDownTourFTPSessionIntervalSekunden.Value); this.numSendDataBytes = (int)(this.numericUpDownTourFTPSessionSize.Value); // V1.2.0 this.timerPlanData.Interval = secondsNextData * 1000; this.doLog("Data jede " + secondsNextData.ToString() + " Sekunde(n)"); } // V1.3.0 if ((int)(this.numericUpDownTourGPSIntervalSekunden.Value) > 0) { int secondsNextGPS = (int)(this.numericUpDownTourGPSIntervalSekunden.Value); this.timerPlanGPS.Interval = secondsNextGPS * 1000; this.doLog("GPS jede " + secondsNextGPS.ToString() + " Sekunde(n)"); } } this.doLog("Test Tour gestart"); this.testPlanType = TestPlanType.TOUR_EXEC; // V1.5.0 this.numScanBarcodes = 0; this.numSnapPhotos = 0; this.numFTPSessions = 0; this.numFTPSuccess = 0; this.numTourCycles = 0; this.stateScanBarcode = TaskTestState.IDLE; this.stateSnapPhoto = TaskTestState.IDLE; this.stateFTPSession = TaskTestState.IDLE; this.stateTourCycle = TaskTestState.IDLE; this.stateGPSPosition = TaskTestState.IDLE; // V1.3.0 if (this.testHours > 0) { this.timerPlanScan.Enabled = false; // V1.3.0 this.timerPlanTourCycle.Enabled = ((int)(this.numericUpDownTourCycleIntervalMinuten.Value) > 0); this.timerPlanPhoto.Enabled = ((int)(this.numericUpDownTourSnapPhotos.Value) > 0); this.timerPlanData.Enabled = ((int)(this.numericUpDownTourFTPSessionIntervalSekunden.Value) > 0); this.timerPlanGPS.Enabled = ((int)(this.numericUpDownTourGPSIntervalSekunden.Value) > 0); // V1.3.0 } }
void ca_CameraEvent(object sender, CameraAssembly.CameraEventArgs e) { this.doLog("Photo snapped " + e.TaskCode.ToString()); if (e.TaskCode == CameraAssembly.CameraTaskCodes.ImageCaptureComplete) { this.stateSnapPhoto = TaskTestState.DONE; } else { this.stateSnapPhoto = TaskTestState.DONE; } }
void da_DecodeEvent(object sender, DecodeAssembly.DecodeEventArgs e) { this.stateScanBarcode = TaskTestState.DONE; }
private void timerPlanTourCycle_Tick(object sender, EventArgs e) { // V1.5.2 this.timerManageUnattended.Enabled = false; Form1.SystemIdleTimerReset(); Form1.SetSystemPowerState(IntPtr.Zero, Form1.POWER_STATE_ON, 0); // V1.5.2 int secondsDisplayOn = (int)(this.numericUpDownTourCycleDisplayAn.Value) * 60; this.timerManageUnattended.Interval = secondsDisplayOn * 1000; this.deviceInUnattended = false; this.timerManageUnattended.Enabled = true; if (this.stateTourCycle == TaskTestState.IDLE) { this.stateTourCycle = TaskTestState.PLAN; } else { this.doLog("Cycle skipped (" + this.stateTourCycle.ToString() + ")"); } }
// This is the main State Machine Loop // It will activate, based up certain sequence and mutual exclusion rules, any Task which was set to from IDLE to PLAN by the timers // It will also initiate certain cleanup when a Task is DONE and revert it back to IDLE private void timerSecond_Tick(object sender, EventArgs e) { this.timeSpan = DateTime.Now.Subtract(this.startTime); this.doRefreshOutputStatusDisplay(); if (this.stopTest) // V1.3.0 interrupt any plans is we are supposed to stop { if (this.stateFTPSession == TaskTestState.PLAN) { this.stateFTPSession = TaskTestState.IDLE; } if (this.stateScanBarcode == TaskTestState.PLAN) { this.stateScanBarcode = TaskTestState.IDLE; } if (this.stateSnapPhoto == TaskTestState.PLAN) { this.stateSnapPhoto = TaskTestState.IDLE; } if (this.stateTourCycle == TaskTestState.PLAN) { this.stateTourCycle = TaskTestState.IDLE; } if (this.stateGPSPosition != TaskTestState.IDLE) { this.stateGPSPosition = TaskTestState.DONE; } // V1.5.2 bool result = (PowerPolicyNotify(PowerMode.UnattendedMode, UNATTENDED_OFF) != 0); } switch (this.testPlanType) { case TestPlanType.BELADE_PLAN: if (this.checkBoxIncludeBeladePhase.Checked) { this.timerStateMachine.Enabled = false; this.timerStateMachine.Interval = 5000; // V1.5.2 go in relax mode this.doStartBelade(); this.timerStateMachine.Enabled = true; } else { this.doLog("Test: skip Belade ..."); this.testPlanType = TestPlanType.TOUR_PLAN; } break; case TestPlanType.TOUR_PLAN: if (this.checkBoxIncludeTourPhase.Checked) { this.timerStateMachine.Enabled = false; this.timerStateMachine.Interval = 5000; // V1.5.2 go in relax mode this.doStartTour(); this.timerStateMachine.Enabled = true; } else { this.doLog("Test: skip Tour ..."); this.testPlanType = TestPlanType.RUHE_PLAN; } break; case TestPlanType.RUHE_PLAN: if (this.checkBoxIncludeRuhePhase.Checked) { this.timerStateMachine.Enabled = false; this.timerStateMachine.Interval = 20000; // V1.5.2 go in relax mode this.doStartRuhe(); this.timerStateMachine.Enabled = true; } else { this.doLog("Test: skip Ruhe ..."); this.testPlanType = TestPlanType.DONE; } break; case TestPlanType.RUHE_EXEC: if (!stopTest && !skipPhase) { // this.doLog("Ruhephase ping"); if (this.radioButtonRuheSuspend.Checked) { this.timerStateMachine.Enabled = false; // temp disable the looper because we get dual entry after resume // V1.5.2 // long fileStartTime = DateTime.Now.AddHours((double)this.numericUpDownRuheLaufzeitStunden.Value).AddMinutes((double)this.numericUpDownRuheLaufzeitMinuten.Value).ToFileTime(); long fileStartTime = this.startTime.AddHours((double)this.numericUpDownRuheLaufzeitStunden.Value).AddMinutes((double)this.numericUpDownRuheLaufzeitMinuten.Value).ToFileTime(); // V1.5.2 wakeup every hour to log battery , so let's see which interval is shorter long fileStartTime2 = DateTime.Now.AddHours((double)1.0).ToFileTime(); // long fileStartTime2 = DateTime.Now.AddMinutes((double)2.0).ToFileTime(); if (fileStartTime2 < fileStartTime) { fileStartTime = fileStartTime2; } long localFileStartTime = 0; FileTimeToLocalFileTime(ref fileStartTime, ref localFileStartTime); SystemTime systemStartTime = new SystemTime(); FileTimeToSystemTime(ref localFileStartTime, systemStartTime); // we plan to be woken up after a few hours string myappname = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase; CeRunAppAtTime(myappname, systemStartTime); this.doLog("Suspend für " + this.numericUpDownRuheLaufzeitStunden.Value.ToString() + "h" + this.numericUpDownRuheLaufzeitMinuten.Value.ToString() + "m"); // V1.5.2 UtilMethods.SuspendDevice(); // PowerPolicyNotify(PowerMode.SuspendKeyOrPwrButtonPressed, 0); this.timeSpan = DateTime.Now.Subtract(this.startTime); // V1.5.0 this.doLog("Wakeup nach: " + this.timeSpan.ToString().Split('.')[0]); // V2.5.2 this.lastLevel = SystemNotification.GetBatteryLife(); this.doLog("Akku " + this.lastLevel.ToString() + "%"); this.timerStateMachine.Enabled = true; } else if (!this.deviceInUnattended) { // V1.5.2 this.timerManageUnattended.Interval = 1000; this.timerManageUnattended.Enabled = true; } this.timeSpan = DateTime.Now.Subtract(this.startTime); // V1.5.0 // if (timeSpan.Hours >= this.testHours) // V1.3.0 use global var if (timeSpan.CompareTo(this.testSpan)>0) // V1.5.2 { this.doLog("Ruhephase ending"); Form1.SystemIdleTimerReset(); Form1.SetSystemPowerState(IntPtr.Zero, Form1.POWER_STATE_ON, 0); this.timerManageUnattended.Enabled = false; this.deviceInUnattended = false; this.testPlanType = TestPlanType.DONE; this.doLog("Test beendet nach: " + this.timeSpan.ToString().Split('.')[0]); this.testPlanType = TestPlanType.DONE; } // if we were woken up earlier, then we look back into this } else { this.testPlanType = TestPlanType.DONE; } break; case TestPlanType.BELADE_EXEC: case TestPlanType.TOUR_EXEC: case TestPlanType.DONE: if (this.stateGPSPosition == TaskTestState.DONE) { this.timerExecGPS.Enabled = false; this.stateGPSPosition = TaskTestState.IDLE; Thread t = new Thread(new ThreadStart(this.threadedCloseGPS)); t.Start(); } // GPS .. this may need to be reviewed // Currently the GPS is opened every time on test demand and closed after Fix or Timeout // The event handler waits for a Fix-position or else the Close timer will end // Not sure there is time enough for fix, although Windows should also have the GPS open // Alternatively, the GPS needs to be opened at the start of the Test and closed at the End and at test interval we simply take the current status immediately if (this.stateGPSPosition == TaskTestState.PLAN) { try { this.doLog("GPS: obtain location ..."); if (this.gps.OpenComPort() == 0) { // V1.3.0 this.stateGPSPosition = TaskTestState.EXEC; this.timerExecGPS.Enabled = true; } else { this.stateGPSPosition = TaskTestState.IDLE; this.doLog("GPS: fail to open GPS"); } } catch { this.stateGPSPosition = TaskTestState.IDLE; } } if (this.stateTourCycle == TaskTestState.PLAN && (this.stateSnapPhoto == TaskTestState.IDLE || this.stateSnapPhoto == TaskTestState.PLAN)) { this.numTourCycles++; this.stateTourCycle = TaskTestState.EXEC; this.numTourCycleScanBarcodes = (int)(this.numericUpDownTourCycleScanBarcodes.Value); } if (this.stateTourCycle == TaskTestState.EXEC && this.numTourCycleScanBarcodes > 0 && this.stateScanBarcode == TaskTestState.IDLE) { this.numTourCycleScanBarcodes--; this.stateScanBarcode = TaskTestState.PLAN; } if (this.stateTourCycle == TaskTestState.EXEC && this.numTourCycleScanBarcodes == 0) { if (this.textBoxDataServer.Text != string.Empty && (int)(this.numericUpDownTourCycleFTPSessionSize.Value) > 0) { this.numFTPSessions++; this.doLog("Interval Data #" + this.numTourCycles.ToString() + ": (" + this.numericUpDownTourCycleFTPSessionSize.Value.ToString() + ")"); try { OpenNETCF.Net.Ftp.FTP client = new OpenNETCF.Net.Ftp.FTP(this.textBoxDataServer.Text); if (client != null) { client.BeginConnect(this.textBoxDataBenutzer.Text, this.textBoxDataKennwort.Text); int numWait = 50; while (!client.IsConnected && numWait-- > 0) { Thread.Sleep(100); } if (client.IsConnected) { client.TransferType = OpenNETCF.Net.Ftp.FTPTransferType.Binary; this.numTotalDataBytes += (int)(this.numericUpDownTourCycleFTPSessionSize.Value); client.SendBytes((int)this.numericUpDownTourCycleFTPSessionSize.Value); client.Disconnect(); client = null; this.numFTPSuccess++; } else { this.doLog("FTP nicht geöffnet"); } } else { this.doLog("FTP nicht geöffnet"); } } catch (Exception ee) { this.doLog(this.textBoxDataBenutzer.Text + ":" + this.textBoxDataKennwort.Text + "@" + this.textBoxDataServer.Text + " -> " + ee.Message); } } this.stateTourCycle = TaskTestState.DONE; } if (this.stateTourCycle == TaskTestState.DONE) { this.stateTourCycle = TaskTestState.IDLE; } if (this.stateScanBarcode == TaskTestState.PLAN && (this.stateSnapPhoto == TaskTestState.IDLE || this.stateSnapPhoto == TaskTestState.PLAN)) { this.numScanBarcodes++; this.doLog("Scan #" + this.numScanBarcodes.ToString()); this.stateScanBarcode = TaskTestState.EXEC; this.da.Connect(); this.da.ScanTimeout = this.timeoutScanBarcode; this.da.ScanBarcode(); } if (this.stateScanBarcode == TaskTestState.DONE) { this.da.Disconnect(); this.stateScanBarcode = TaskTestState.IDLE; } if (this.stateSnapPhoto == TaskTestState.PLAN && this.stateScanBarcode == TaskTestState.IDLE && this.stateTourCycle == TaskTestState.IDLE) { this.numSnapPhotos++; this.doLog("Photo #" + this.numSnapPhotos.ToString()); this.stateSnapPhoto = TaskTestState.EXEC; try { #if HSM this.ca.Connect(this.pictureBox1.Handle, null, null); #else this.ca.Connect(ref this.pictureBox1, null, null); #endif long resolutionSetting; this.ca.GetResolutionCount(out resolutionSetting); this.ca.SetResolution((uint)(resolutionSetting - 1)); this.ca.SetProperty(CameraProperty.Illumination, 1, PropertyMode.Manual); this.ca.SetProperty(CameraProperty.ColorEnable, 1, PropertyMode.Manual); this.ca.StartPreview(); this.timerExecPhoto.Enabled = true; } catch (Exception ee) { this.doLog("Exception in exec photo"+ee.Message); } } if (this.stateSnapPhoto == TaskTestState.DONE) { try { this.ca.StopPreview(); this.ca.Disconnect(); } catch { } this.stateSnapPhoto = TaskTestState.IDLE; } if (this.stateFTPSession == TaskTestState.PLAN) { this.numFTPSessions++; this.doLog("Data #" + this.numFTPSessions.ToString() + ": (" + this.numSendDataBytes.ToString() + ") "); this.stateFTPSession = TaskTestState.EXEC; if (this.textBoxDataServer.Text != string.Empty) { try { OpenNETCF.Net.Ftp.FTP client = new OpenNETCF.Net.Ftp.FTP(this.textBoxDataServer.Text); if (client != null) { client.BeginConnect(this.textBoxDataBenutzer.Text, this.textBoxDataKennwort.Text); int numWait = 50; while (!client.IsConnected && numWait-- > 0) { Thread.Sleep(100); } if (client.IsConnected) { client.TransferType = OpenNETCF.Net.Ftp.FTPTransferType.Binary; this.numTotalDataBytes += this.numSendDataBytes; client.SendBytes(this.numSendDataBytes); client.Disconnect(); client = null; this.numFTPSuccess++; } else { this.doLog("FTP nicht geöffnet"); } } else { this.doLog("FTP nicht geöffnet"); } } catch (Exception ee) { this.doLog(this.textBoxDataBenutzer.Text + ":" + this.textBoxDataKennwort.Text + "@" + this.textBoxDataServer.Text + " -> " + ee.Message); } } this.stateFTPSession = TaskTestState.DONE; } if (this.stateFTPSession == TaskTestState.DONE) { this.stateFTPSession = TaskTestState.IDLE; } if ((this.stopTest || this.skipPhase || timeSpan.CompareTo(this.testSpan) > 0) && (this.stateFTPSession != TaskTestState.IDLE || this.stateSnapPhoto != TaskTestState.IDLE || this.stateScanBarcode != TaskTestState.IDLE || this.stateGPSPosition != TaskTestState.IDLE)) { // do nothing yet, wait until substates are finised if (!complained) { // V1.5.3 this.timerPlanScan.Enabled = false; this.timerPlanPhoto.Enabled = false; this.timerPlanData.Enabled = false; this.timerPlanTourCycle.Enabled = false; this.timerPlanGPS.Enabled = false; complained = true; this.doLog("waiting for sub test to complete"); } } else // V1.5.2 // if (!this.stopTest && (this.skipPhase || timeSpan.Hours >= this.testHours || this.testPlanType == TestPlanType.DONE)) // V1.3.0 use global var if (!this.stopTest && (this.skipPhase || timeSpan.CompareTo(this.testSpan)>0 || this.testPlanType == TestPlanType.DONE)) // V1.3.0 use global var { // V1.3.0 this.timerPlanScan.Enabled = false; this.timerPlanPhoto.Enabled = false; this.timerPlanData.Enabled = false; this.timerPlanTourCycle.Enabled = false; this.timerPlanGPS.Enabled = false; // V1.5.3 // this.timerExecGPS.Enabled = false; this.doLog("Test beenden ..."); // V1.3.2 test for TestType if (!this.skipPhase && this.testPlanType == TestPlanType.BELADE_EXEC && (int)(this.numericUpDownBeladeFTPBulkSize.Value) > 0) { this.numFTPSessions++; this.doLog("Bulk #" + this.numFTPSessions.ToString() + ": (" + this.numericUpDownBeladeFTPBulkSize.Value.ToString() + ") "); if (this.textBoxDataServer.Text != string.Empty) { try { OpenNETCF.Net.Ftp.FTP client = new OpenNETCF.Net.Ftp.FTP(this.textBoxDataServer.Text); if (client != null) { client.BeginConnect(this.textBoxDataBenutzer.Text, this.textBoxDataKennwort.Text); int numWait = 50; while (!client.IsConnected && numWait-- > 0) { Thread.Sleep(100); } if (client.IsConnected) { client.TransferType = OpenNETCF.Net.Ftp.FTPTransferType.Binary; this.numTotalDataBytes += (int)(this.numericUpDownBeladeFTPBulkSize.Value) * 1024 * 1024; client.SendBytes((int)this.numericUpDownBeladeFTPBulkSize.Value * 1024 * 1024); client.Disconnect(); client = null; this.numFTPSuccess++; } else { this.doLog("FTP nicht geöffnet"); } } else { this.doLog("FTP nicht geöffnet"); } } catch (Exception ee) { this.doLog(this.textBoxDataBenutzer.Text + ":" + this.textBoxDataKennwort.Text + "@" + this.textBoxDataServer.Text + " -> " + ee.Message); } } // V1.5.2 bool result = (PowerPolicyNotify(PowerMode.UnattendedMode, UNATTENDED_OFF) != 0); } this.doLog("Akku " + SystemNotification.GetBatteryLife().ToString() + "%"); // this.timerSecond.Enabled = false; // V1.3.0 // V1.5.0 jump to next major test switch (this.testPlanType) { case TestPlanType.BELADE_EXEC: this.timeSpan = DateTime.Now.Subtract(this.startTime); //V1.5.0 this.doLog("Test beendet nach: " + this.timeSpan.ToString().Split('.')[0]); this.testPlanType = TestPlanType.TOUR_PLAN; break; case TestPlanType.TOUR_EXEC: this.timeSpan = DateTime.Now.Subtract(this.startTime); //V1.5.0 this.doLog("Test beendet nach: " + this.timeSpan.ToString().Split('.')[0]); this.testPlanType = TestPlanType.RUHE_PLAN; //Thread t = new Thread(new ThreadStart(this.threadedCloseGPS)); //t.Start(); break; case TestPlanType.DONE: this.stopTest = true; // V1.3.0 this.buttonSkipPhase.Enabled = false; this.buttonStop.Enabled = false; // V1.3.2 // this.testPlanType = TestPlanType.NONE; break; default: // can't be here ... break; } this.skipPhase = false; } if (this.stopTest && this.stateFTPSession == TaskTestState.IDLE && this.stateSnapPhoto == TaskTestState.IDLE && this.stateScanBarcode == TaskTestState.IDLE && this.stateGPSPosition == TaskTestState.IDLE) { Form1.SystemIdleTimerReset(); Form1.SetSystemPowerState(IntPtr.Zero, Form1.POWER_STATE_ON, 0); // V1.5.3 this.timerPlanScan.Enabled = false; // V1.3.0 this.timerPlanPhoto.Enabled = false; // V1.3.0 this.timerPlanData.Enabled = false; // V1.3.0 this.timerPlanTourCycle.Enabled = false; // V1.3.0 this.timerPlanGPS.Enabled = false; // V1.3.0 this.timerManageUnattended.Enabled = false; this.timerStateMachine.Enabled = false; this.timerStateMachine.Interval = 1000; // V1.5.2 go back in speed mode next time this.menuItemExit.Enabled = true; this.menuItemStart.Enabled = true; this.testPlanType = TestPlanType.NONE; this.gps = null; // V1.5.2 this.doSetTimeouts(3 * 60, 0, 0, 0, 5 * 60, 0); } this.doRefreshOutputStatusDisplay(); break; default: // IDLE, DONE this.doLog("Default? : " + this.testPlanType.ToString()); this.timerStateMachine.Enabled = false; break; } }
private void timerPlanScan_Tick(object sender, EventArgs e) { if (this.stateScanBarcode == TaskTestState.IDLE) { this.stateScanBarcode = TaskTestState.PLAN; } else { this.doLog("Scan skipped (" + this.stateScanBarcode.ToString() + ")"); } }
private void timerPlanPhoto_Tick(object sender, EventArgs e) { if (this.stateSnapPhoto == TaskTestState.IDLE) { this.stateSnapPhoto = TaskTestState.PLAN; } else { this.doLog("Photo skipped (" + this.stateSnapPhoto.ToString() + ")"); } }
private void timerPlanGPS_Tick(object sender, EventArgs e) { if (this.stateGPSPosition == TaskTestState.IDLE) { this.stateGPSPosition = TaskTestState.PLAN; } else { this.doLog("GPS skipped (" + this.stateGPSPosition.ToString() + ")"); } }
private void timerPlanData_Tick(object sender, EventArgs e) { if (this.stateFTPSession == TaskTestState.IDLE) { this.stateFTPSession = TaskTestState.PLAN; } else { this.doLog("Data skipped (" + this.stateFTPSession.ToString() + ")"); } }
private void timerExecPhoto_Tick(object sender, EventArgs e) { this.timerExecPhoto.Enabled = false; string filename = @"\My Documents\trans-o-flex-" + this.startTime.ToString("yyyy-MM-dd_HH-mm-ss") + "_" + this.numSnapPhotos.ToString() + ".jpg"; try { if (File.Exists(filename)) { File.Delete(filename); } } catch { } try { this.ca.SnapPicture(filename, JPGQuality.High); } catch (Exception ee) { //ee = ee; this.doLog("Exception in timerExecPhoto_Tick: "+ ee.Message); this.stateSnapPhoto = TaskTestState.DONE; // V1.3.0 in case of exception, clear the state } }