Skip to content

Commit 60c7aaa

Browse files
committed
handling bad meas, speed up program
1 parent 9932740 commit 60c7aaa

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

GwinstekLCRTester/MainWindow.xaml.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,12 @@ public MainWindow()
107107
{
108108
System.Windows.MessageBox.Show("Nie znaleziono aktywnych portów COM");
109109
Close();
110-
};
110+
}
111+
catch (FileNotFoundException)
112+
{
113+
System.Windows.MessageBox.Show("Nie można połączyć się z portem, czy kabel RS jest podłączony?");
114+
return;
115+
}
111116
}
112117

113118
private void ChangeSendButtonText(bool finished)
@@ -316,15 +321,14 @@ private void ExecuteTests()
316321
}
317322
}
318323
deviceCounter += 1;
319-
fileHandler.closeWriter();
320324
}
321325
catch (FormatException)
322326
{
323327
returnToIdle(rsConnector, false, "Podano nienumeryczną lub niepoprawną wartość dla częstotliwości bądź cyklów!");
324328
return;
325329
}
326330
}
327-
331+
fileHandler.closeWriter();
328332
System.Windows.MessageBox.Show("Zakończono wszystkie testy");
329333
}
330334

GwinstekLCRTester/RSCommunication.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,12 @@ public RSCommunication(string portName, uint baudRate, Parity parityNumber, uint
4848

4949
}
5050

51-
public decimal[] getMeasurementParams(string msType, string multiplier, bool addD = false, int waitFetchMs = 700)
51+
public decimal[] getMeasurementParams(string msType, string multiplier, bool addD = false, int waitFetchMs = 400)
5252
{
5353

5454
string d_Parameter = null;
5555
decimal[] responseDecimalArray = new decimal[3];
5656

57-
5857
// dodatkowe opcjonalne mierzenie parametru D
5958
if (addD)
6059
{
@@ -70,10 +69,9 @@ public decimal[] getMeasurementParams(string msType, string multiplier, bool add
7069
if (msType == "DCR")
7170
waitFetchMs += 3000;
7271

73-
System.Threading.Thread.Sleep(waitFetchMs);
72+
System.Threading.Thread.Sleep(waitFetchMs);
7473
_serialPort.WriteLine("FETCH?");
7574

76-
string cos = _serialPort.ReadLine();
7775

7876
try
7977
{
@@ -94,7 +92,7 @@ public decimal[] getMeasurementParams(string msType, string multiplier, bool add
9492
MessageBoxResult result = System.Windows.MessageBox.Show("Błąd pomiaru, czy chcesz ponowić pomiar na tych samych parametrach?", "Błąd", MessageBoxButton.OKCancel);
9593
if (result == MessageBoxResult.OK)
9694
{
97-
getMeasurementParams(msType, multiplier, addD, waitFetchMs += 700);
95+
responseDecimalArray = getMeasurementParams(msType, multiplier, addD, waitFetchMs += 700);
9896
}
9997
else
10098
{
@@ -177,7 +175,7 @@ public void setMeasurementInDevice(string command)
177175
_serialPort.Dispose();
178176
_serialPort.Close();
179177
_serialPort.Open();
180-
System.Threading.Thread.Sleep(3000);
178+
System.Threading.Thread.Sleep(1000);
181179
}
182180

183181

0 commit comments

Comments
 (0)