diff --git a/EpdBase/EpdBase.cpp b/EpdBase/EpdBase.cpp
index 30add09..eae5295 100644
--- a/EpdBase/EpdBase.cpp
+++ b/EpdBase/EpdBase.cpp
@@ -55,16 +55,19 @@ DWORD EpdBase::Epd2U::StartCom()
}
void EpdBase::Epd2U::EndCom()
{
- if (port > 0 && CommsInitialized==1) DeinitComms(port);
+ if (port > 0 && CommsInitialized == 1) {
+ DeinitComms(port);
+ Sleep(300);
+ }
CommsInitialized = 0;
}
EpdBase::Epd2U::~Epd2U()
{
EndCom();
}
-int EpdBase::Epd2U::StartDiscover( int EpdTimeout)
+int EpdBase::Epd2U::StartDiscover( int EpdTimeoutms)
{
- maxDiscoverTime = EpdTimeout;
+ maxDiscoverTime = EpdTimeoutms;
if (port == 0) {
DeviceCount = 1;
DeviceIDs[0] = 768;
@@ -82,7 +85,8 @@ int EpdBase::Epd2U::StartDiscover( int EpdTimeout)
LARGE_INTEGER wt; //100 nanoseconds *10000 = millisec
//union { LARGE_INTEGER li; FILETIME ft; LONGLONG ll; } t1, t2;
//wt.QuadPart = -300000000LL;
- wt.QuadPart = Int32x32To64(maxDiscoverTime, -15000); //15 seconden proberen
+ INT64 t = maxDiscoverTime+1000; t *= (INT64)-10000;
+ wt.QuadPart = t; // Int32x32To64(maxDiscoverTime, -10000); //15 seconden proberen
SetWaitableTimer(hWaitTimer, &wt, 0, NULL, NULL, 0);
while (DeviceCount == 0 && wo != 0) //tries-- > 0 &&
{
@@ -597,14 +601,14 @@ int EpdBase::Epd2U::GetAll(bool Closeconnection)
///
///
/// 0=success 1=connect error, 2 = no devices, 3= error reading status
-int EpdBase::Epd2U::ConnectAndStatus(int tokenSourceTimeout)
+int EpdBase::Epd2U::ConnectAndStatus(int tokenSourceTimeoutms)
{
WORD dllStatus;
int rv = 1;
if (CommsInitialized == 0) StartCom();
if (CommsInitialized == 0) rv = 1;
else {
- dllStatus = StartDiscover(tokenSourceTimeout);
+ dllStatus = StartDiscover(tokenSourceTimeoutms);
if (dllStatus != 1) rv = 1; //Connect error
else if (DeviceCount < 1) rv = 2; //TO
else if (ReadStatus() != 0) rv = 1; //Read Error
diff --git a/EpdBase3/Epd3Base.cpp b/EpdBase3/Epd3Base.cpp
index 61e6a5f..b980d95 100644
--- a/EpdBase3/Epd3Base.cpp
+++ b/EpdBase3/Epd3Base.cpp
@@ -146,6 +146,7 @@ void Epd3Base::Epd3U::EndCom()
int Epd3Base::Epd3U::StartDiscover(int tokentimeout)
{
int32_t rv=1;
+ int32_t rv2 = 0;
Error = 0;
if (port == 0) {
DeviceCount = 1;
@@ -153,19 +154,22 @@ int Epd3Base::Epd3U::StartDiscover(int tokentimeout)
DeviceIDs[0] = 768;
return 0;
}
+
Dll3RV = SetDiscoveryCacheTimeout(epdComsHandle, tokentimeout);
//Dll3RV = Commit3(epdComsHandle);
DeviceCount = 0; ConnectTries = 1;
-
+ //rv2 = Cancel(epdComsHandle); Cancel bestaat niet
ResetEvent(hCompletion);
ConnectTimerFired = 0;
current = this;
Dll3RV = StartDiscovery(epdComsHandle, discovery);
if (Dll3RV == 0) {
- Dll3RV = WaitForSingleObject(hCompletion, tokentimeout);
+ Dll3RV = WaitForSingleObject(hCompletion, tokentimeout+1000);
if (Dll3RV == WAIT_OBJECT_0) rv = 1;
else if (Dll3RV == WAIT_TIMEOUT) {
rv = 1; ConnectTimerFired = 1;
+ rv2= StopDiscovery(epdComsHandle);
+ DeviceCount = 0;
} else rv = 2;
}
if ( DeviceCount > 0) {
@@ -445,7 +449,7 @@ error:
/// discover, connect and read status
///
///
-/// 0=success 1=connect error, 2 = no devices, 3= error reading status
+/// 0=success 1=connect error, 2 = time out , no devices, 3= error reading status
int Epd3Base::Epd3U::ConnectAndStatus(int tokenSourceTimeout)
{
WORD dllStatus;
diff --git a/EpdBaseClr/EpdBaseClr.cpp b/EpdBaseClr/EpdBaseClr.cpp
index dbcc5d2..0c55772 100644
--- a/EpdBaseClr/EpdBaseClr.cpp
+++ b/EpdBaseClr/EpdBaseClr.cpp
@@ -810,7 +810,7 @@ int EpdBaseClr::Epd2::ConnectAndStatus()
int rv = 1;
if (!onlyMK2) epd->EndCom(); //indien Mk2
InitData();
- Sleep(100);
+ //Sleep(100);
if (onlyMK2)
rv = epd->ConnectAndStatus(tokenSourceTimeout);
else
@@ -867,7 +867,7 @@ void EpdBaseClr::Epd2::WaitEpd()
_EpdRead(this, gcnew EpdEventArgs(EpdID, EPDIssued, isBG, isMK3));
}
else if (rv == 2 && _EpdTO != nullptr) {
- _EpdTO(this, gcnew EpdTOEventArgs(epd3->ConnectTries, epd3->ConnectTimerFired));
+ _EpdTO(this, gcnew EpdTOEventArgs(0, 0)); // epd3->ConnectTries, epd3->ConnectTimerFired));
}
else if (rv > 0 && _EpdError != nullptr) {
_EpdError(this, gcnew EpdErrorEventArgs(rv));
@@ -892,16 +892,21 @@ void EpdBaseClr::Epd2::WaitEnd()
{
if (waitTask != nullptr)
{
- //if (epd3->hWaitTimer!= nullptr)
- // SetEvent(epd3->hWaitTimer);
- waitTask->Wait(750);
- if (waitTask->Status == System::Threading::Tasks::TaskStatus::Running) {
+ waitTask->Wait(1000);
+ int tries = 5;
+ while (tries-->0 && waitTask->Status == System::Threading::Tasks::TaskStatus::Running) {
tokenSource->Cancel();
waitTask->Wait(1000);
}
- delete waitTask;
- waitTask = nullptr;
- delete tokenSource;
+ if (
+ waitTask->Status == System::Threading::Tasks::TaskStatus::RanToCompletion
+ || waitTask->Status == System::Threading::Tasks::TaskStatus::Canceled
+ || waitTask->Status == System::Threading::Tasks::TaskStatus::Faulted
+ ) {
+ delete waitTask;
+ waitTask = nullptr;
+ }
+ delete tokenSource;
tokenSource = nullptr;
Close();
}
diff --git a/eDosStation/EntryBadge.xaml b/eDosStation/EntryBadge.xaml
index 9fed74a..3189dc0 100644
--- a/eDosStation/EntryBadge.xaml
+++ b/eDosStation/EntryBadge.xaml
@@ -296,7 +296,7 @@
-
+
diff --git a/eDosStation/EntryBadge.xaml.cs b/eDosStation/EntryBadge.xaml.cs
index f6b837c..592c558 100644
--- a/eDosStation/EntryBadge.xaml.cs
+++ b/eDosStation/EntryBadge.xaml.cs
@@ -13,6 +13,7 @@ namespace eDosStation
///
public partial class EntryBadge : Window
{
+
bool taskLoading = false;
const int PageTimeout = 10000;
bool initialising = true;
@@ -29,6 +30,8 @@ namespace eDosStation
eDosStation.DataSet1 dataSet1;
private DateTime ResultTime;
+ private bool EpdReading=false;
+
enum eCOE { quiz = 1 };
#if SimulateEPD
public SimulateData simulData = new SimulateData();
@@ -40,15 +43,18 @@ namespace eDosStation
thisStation = curStation;
_User = null;
taskLoading = false;
+ EpdReading = false;
}
private void Ep_EpdTO(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdTOEventArgs e)
{
+ System.Diagnostics.Debug.WriteLine("TIME OUT");
Dispatcher.InvokeAsync(() => {
endPage();
});
}
private void Ep_EpdError(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdErrorEventArgs e)
{
+
Dispatcher.InvokeAsync(() => {
MessageBox.Show($"EPD Error {e.returnValue}");
endPage();
@@ -56,6 +62,7 @@ namespace eDosStation
}
private void Ep_EpdRead(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdEventArgs e)
{
+ EpdReading = false;
Dispatcher.InvokeAsync(() => GetEPD());
}
private bool LoadDoses()
@@ -233,18 +240,18 @@ namespace eDosStation
simulData.WearerName = ep.WearerName;
#endif
- ep.Hp07RateOn = CurTaskRow.HP07RateON;
- ep.Hp07RateOff = CurTaskRow.HP07RateOFF;
+ ep.Hp07RateOn = CurTaskRow.HP07RateON;
+ ep.Hp07RateOff = CurTaskRow.HP07RateOFF;
- ep.Hp10Rate1On = CurTaskRow.HP10Rate1ON;
- ep.Hp10Rate1Off = CurTaskRow.HP10Rate1OFF;
+ ep.Hp10Rate1On = CurTaskRow.HP10Rate1ON;
+ ep.Hp10Rate1Off = CurTaskRow.HP10Rate1OFF;
- ep.Hp10Rate2On = CurTaskRow.HP10Rate2ON;
- ep.Hp10Rate2Off = CurTaskRow.HP10Rate2OFF;
+ ep.Hp10Rate2On = CurTaskRow.HP10Rate2ON;
+ ep.Hp10Rate2Off = CurTaskRow.HP10Rate2OFF;
- ep.Hp10THDose1 = CurTaskRow.Hp10Dose1;
- ep.Hp10THDose2 = CurTaskRow.Hp10Dose2;
- ep.Hp07THDose = CurTaskRow.Hp07Dose;
+ ep.Hp10THDose1 = CurTaskRow.Hp10Dose1;
+ ep.Hp10THDose2 = CurTaskRow.Hp10Dose2;
+ ep.Hp07THDose = CurTaskRow.Hp07Dose;
////voor Neutron K3, K4
//int? kx = null;
@@ -281,9 +288,9 @@ namespace eDosStation
ep.WriteCalibration();
#endif
-
- float gain = 100.0F;
- if (!CurTaskRow.IsFNGain_ANGainValueNull()) gain= (int)CurTaskRow.FNGain_ANGainValue;
+
+ float gain = 100.0F;
+ if (!CurTaskRow.IsFNGain_ANGainValueNull()) gain = (int)CurTaskRow.FNGain_ANGainValue;
int rv = ep.IssueAndCheck(gain);
if (rv != 0)
{
@@ -296,6 +303,8 @@ namespace eDosStation
panelWait.Visibility = Visibility.Collapsed;
}
}
+ else
+ System.Diagnostics.Debug.WriteLine("Not loaded");
}
private void GetEPD()
{
@@ -304,6 +313,9 @@ namespace eDosStation
statusEPD.Text = string.Empty;
DoEPD();
}
+ else
+ System.Diagnostics.Debug.WriteLine("Not loaded");
+
}
private void SetFilter(bool isAlara)
{
@@ -491,6 +503,11 @@ namespace eDosStation
}
public void endPage()
{
+ if (EpdReading)
+ {
+ //MessageBox.Show("Fout bij initialiseren EPD! ");
+ }
+ EpdReading = false;
dispatcherTimer?.Stop();
dispatcherTimer = null;
this.Close();
@@ -545,12 +562,17 @@ namespace eDosStation
dispatcherTimer.Interval = TimeSpan.FromMilliseconds(thisStation.EPDTimeOut / 10);
dispatcherTimer.Tick += CountDown;
ResultTime = DateTime.Now.AddMilliseconds(thisStation.EPDTimeOut);
+ pWaitEpd.Value = pWaitEpd.Maximum = thisStation.EPDTimeOut / 1000;
dispatcherTimer.Start();
- pWaitEpd.Value = pWaitEpd.Maximum = thisStation.EPDTimeOut/1000;
- Dispatcher.InvokeAsync(new Action(() => { ep.Wait(thisStation.EPDTimeOut, 1); }),DispatcherPriority.Background);
+ startEPDRead();
}
}
}
+ private void startEPDRead()
+ {
+ EpdReading = true;
+ Dispatcher.InvokeAsync(new Action(() => { ep.Wait(thisStation.EPDTimeOut, thisStation.EPDRetries); }), DispatcherPriority.Background);
+ }
private void CountDown(object sender, EventArgs e)
{
double v = (ResultTime - DateTime.Now).TotalSeconds;
@@ -559,7 +581,11 @@ namespace eDosStation
else
{
dispatcherTimer.Stop();
- endPage();
+ pWaitEpd.Value = 0;
+ pWaitEpd.Background = System.Windows.Media.Brushes.Red;
+ statusEPD.Text = "Time out";
+ tWaitFor.Text = "Lezer niet gevonden !";
+ bEpdCancel.IsEnabled = false;
}
}
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -709,6 +735,7 @@ namespace eDosStation
private void Window_Loaded(object sender, RoutedEventArgs e)
{
initialising = true;
+ EpdReading = false;
tbEntry.IsSelected = true;
panelDone.Visibility= Visibility.Collapsed;
panelWait.Visibility = Visibility.Visible;
diff --git a/eDosStation/Settings.xaml.cs b/eDosStation/Settings.xaml.cs
index 78527e5..811c8bc 100644
--- a/eDosStation/Settings.xaml.cs
+++ b/eDosStation/Settings.xaml.cs
@@ -85,7 +85,6 @@ namespace eDosStation
private void Window_Loaded(object sender, RoutedEventArgs e)
{
-
string eDosCom = devcon.FindEdosCom();
try
{
diff --git a/eDosStation/eDosStation.csproj b/eDosStation/eDosStation.csproj
index 328124b..f492e1d 100644
--- a/eDosStation/eDosStation.csproj
+++ b/eDosStation/eDosStation.csproj
@@ -1,6 +1,6 @@
-
+
@@ -336,13 +336,13 @@
-
-
+
+
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\signtool.exe" sign /sha1 857150b64ef7d3e679c8cbde425d2a0b5e58ffaa /fd sha256 /d "Integrity & Authenticity" /tr "http://timestamp.digicert.com" $(TargetPath)
-
+
\ No newline at end of file
diff --git a/eDosStation/packages.config b/eDosStation/packages.config
index f920d52..38f3acf 100644
--- a/eDosStation/packages.config
+++ b/eDosStation/packages.config
@@ -1,7 +1,7 @@
-
+