diff --git a/SiemensS7/Siemens-S7-Test/TestMainForm.cs b/SiemensS7/Siemens-S7-Test/TestMainForm.cs
index 3ce123d..6402e35 100644
--- a/SiemensS7/Siemens-S7-Test/TestMainForm.cs
+++ b/SiemensS7/Siemens-S7-Test/TestMainForm.cs
@@ -14,6 +14,7 @@ using NLog;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
+using System.Threading;
namespace Siemens_S7_Test
{
@@ -64,6 +65,10 @@ namespace Siemens_S7_Test
///
public static Logger lg;
///
+ /// oggetto uiTimer
+ ///
+ protected System.Windows.Forms.Timer uiTimer = new System.Windows.Forms.Timer();
+ ///
/// Gestione statistiche
///
public TimingData PerfStats;
@@ -77,7 +82,21 @@ namespace Siemens_S7_Test
InitializeComponent();
myInit();
+
+ startUiTimer();
}
+
+ private void startUiTimer()
+ {
+ uiTimer.Tick += UiTimer_Tick;
+ uiTimer.Start();
+ }
+
+ private void UiTimer_Tick(object sender, EventArgs e)
+ {
+ advProgBar();
+ }
+
///
/// inizializzo
///
@@ -94,6 +113,8 @@ namespace Siemens_S7_Test
rack = 0
};
setParamPlc();
+ // timer
+ uiTimer.Interval = 20;
}
///
/// Imposto parametri PLC
@@ -165,9 +186,15 @@ namespace Siemens_S7_Test
///
protected void updateStats()
{
- lblTimeMin.Text = $"{PerfStats.currStat.min:0.00} s";
- lblTimeMax.Text = $"{PerfStats.currStat.max:0.00} s";
- lblTimeAvg.Text = $"{PerfStats.currStat.avg:0.00} s";
+ int numByte = 1;
+ int.TryParse(txtMemSize.Text, out numByte);
+ int numTest = 1;
+ int.TryParse(txtNumRep.Text, out numTest);
+ lblTimeMin.Text = $"{PerfStats.currStat.min} ms";
+ lblTimeMax.Text = $"{PerfStats.currStat.max} ms";
+ lblTimeAvg.Text = $"{PerfStats.currStat.avg} ms";
+ lblTotSize.Text = $"{numByte * numTest / 1024} kb";
+ lblThroughtput.Text = $"{numByte / (1024 * PerfStats.currStat.avg) * 1000} bps";
}
///
@@ -184,6 +211,8 @@ namespace Siemens_S7_Test
int.TryParse(txtMemSize.Text, out numByte);
int numTest = 1;
int.TryParse(txtNumRep.Text, out numTest);
+ //tslRTime.Text = "Start reading BYTE";
+ //tslRTime.Invalidate();
// effettuo numero di test secondo indicazioni...
for (int i = 0; i < numTest; i++)
{
@@ -192,7 +221,7 @@ namespace Siemens_S7_Test
memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte);
sw.Stop();
// salvo risultati
- PerfStats.addValue((double)sw.ElapsedMilliseconds / 1000);
+ PerfStats.addValue((double)sw.ElapsedMilliseconds);
}
// mostro update lettura
@@ -234,7 +263,7 @@ namespace Siemens_S7_Test
memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte);
sw.Stop();
// salvo risultati
- PerfStats.addValue((double)sw.ElapsedMilliseconds / 1000);
+ PerfStats.addValue((double)sw.ElapsedMilliseconds);
}
// mostro update lettura
@@ -278,7 +307,7 @@ namespace Siemens_S7_Test
memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte);
sw.Stop();
// salvo risultati
- PerfStats.addValue((double)sw.ElapsedMilliseconds / 1000);
+ PerfStats.addValue((double)sw.ElapsedMilliseconds);
}
// mostro update lettura
@@ -362,8 +391,19 @@ namespace Siemens_S7_Test
showOut(titolo, contenuto);
}
}
+ protected void animateProgBar()
+ {
+ uiTimer.Interval = 20;
+ }
-
+ protected void advProgBar()
+ {
+ toolStripProgressBar1.ProgressBar.Value++;
+ if (toolStripProgressBar1.ProgressBar.Value >= toolStripProgressBar1.ProgressBar.Maximum)
+ {
+ toolStripProgressBar1.ProgressBar.Value = 0;
+ }
+ }
///
/// Esecuzione lettura Real!
diff --git a/SiemensS7/Siemens-S7-Test/TimingData.cs b/SiemensS7/Siemens-S7-Test/TimingData.cs
index 8dabd55..c88a731 100644
--- a/SiemensS7/Siemens-S7-Test/TimingData.cs
+++ b/SiemensS7/Siemens-S7-Test/TimingData.cs
@@ -36,6 +36,7 @@ namespace Siemens_S7_Test
currStat.min = valori.Min();
currStat.max = valori.Max();
currStat.avg = valori.Average();
+ currStat.num = valori.Count;
}
}
///
@@ -46,6 +47,7 @@ namespace Siemens_S7_Test
public double min;
public double max;
public double avg;
+ public int num;
}
}