timeout handling
This commit is contained in:
parent
5797105c55
commit
cbf88dce9a
10 changed files with 278 additions and 86 deletions
|
|
@ -85,7 +85,7 @@ int EpdBase::Epd2U::StartDiscover( int EpdTimeoutms)
|
|||
LARGE_INTEGER wt; //100 nanoseconds *10000 = millisec
|
||||
//union { LARGE_INTEGER li; FILETIME ft; LONGLONG ll; } t1, t2;
|
||||
//wt.QuadPart = -300000000LL;
|
||||
INT64 t = maxDiscoverTime+1000; t *= (INT64)-10000;
|
||||
INT64 t = maxDiscoverTime; 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 &&
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ int Epd3Base::Epd3U::StartDiscover(int tokentimeout)
|
|||
current = this;
|
||||
Dll3RV = StartDiscovery(epdComsHandle, discovery);
|
||||
if (Dll3RV == 0) {
|
||||
Dll3RV = WaitForSingleObject(hCompletion, tokentimeout+1000);
|
||||
Dll3RV = WaitForSingleObject(hCompletion, tokentimeout);
|
||||
if (Dll3RV == WAIT_OBJECT_0) rv = 1;
|
||||
else if (Dll3RV == WAIT_TIMEOUT) {
|
||||
rv = 1; ConnectTimerFired = 1;
|
||||
|
|
|
|||
|
|
@ -850,8 +850,10 @@ int EpdBaseClr::Epd2::ConnectAndStatus()
|
|||
isTitleNG = isNG;
|
||||
}
|
||||
}
|
||||
else
|
||||
ConnectError = epd->Error;
|
||||
else {
|
||||
if (epd == nullptr) ConnectError = 99;
|
||||
else ConnectError = epd->Error;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
void EpdBaseClr::Epd2::WaitEpd()
|
||||
|
|
@ -879,12 +881,12 @@ System::Threading::Tasks::Task^ EpdBaseClr::Epd2::Wait(int timeout, int Retries)
|
|||
if (waitTask == nullptr)
|
||||
{
|
||||
tokenSourceTimeout = timeout;
|
||||
tokenSource = gcnew System::Threading::CancellationTokenSource(tokenSourceTimeout + 500);
|
||||
tokenSource = gcnew System::Threading::CancellationTokenSource(tokenSourceTimeout+500);
|
||||
readRetries = Retries;
|
||||
waitTask = System::Threading::Tasks::Task::Run(gcnew Action(this, &Epd2::WaitEpd)); // System::Threading::Tasks::Task::Factory->cre(gcnew Action(this, &CCard::WaitBadge), tokenSource->Token);
|
||||
}
|
||||
else {
|
||||
tokenSource = gcnew System::Threading::CancellationTokenSource(tokenSourceTimeout - 100);
|
||||
tokenSource = gcnew System::Threading::CancellationTokenSource(tokenSourceTimeout +500);
|
||||
}
|
||||
return waitTask;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,15 @@ namespace eDosStation
|
|||
/// <summary>
|
||||
/// Interaction logic for EntryBadge.xaml
|
||||
/// </summary>
|
||||
///
|
||||
|
||||
public partial class EntryBadge : Window
|
||||
{
|
||||
|
||||
private enum eEntryState { none, getuser, gettask, getepd, epdtimeout, epdError, epdOK, final,
|
||||
NotAllowed,
|
||||
Initial
|
||||
}
|
||||
private eEntryState EntryState;
|
||||
bool taskLoading = false;
|
||||
const int PageTimeout = 10000;
|
||||
bool initialising = true;
|
||||
|
|
@ -31,6 +37,7 @@ namespace eDosStation
|
|||
|
||||
private DateTime ResultTime;
|
||||
private bool EpdReading=false;
|
||||
private bool FinalTimeOut=false;
|
||||
|
||||
enum eCOE { quiz = 1 };
|
||||
#if SimulateEPD
|
||||
|
|
@ -44,25 +51,28 @@ namespace eDosStation
|
|||
_User = null;
|
||||
taskLoading = false;
|
||||
EpdReading = false;
|
||||
EntryState = eEntryState.none;
|
||||
}
|
||||
private void Ep_EpdTO(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdTOEventArgs e)
|
||||
{
|
||||
EntryState = eEntryState.epdtimeout;
|
||||
System.Diagnostics.Debug.WriteLine("TIME OUT");
|
||||
Dispatcher.InvokeAsync(() => {
|
||||
endPage();
|
||||
});
|
||||
Dispatcher.InvokeAsync(() => { SetTimedOutAndEnd(); });
|
||||
}
|
||||
private void Ep_EpdError(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdErrorEventArgs e)
|
||||
{
|
||||
|
||||
EntryState = eEntryState.epdError;
|
||||
System.Diagnostics.Debug.WriteLine("ERROR ");
|
||||
Dispatcher.InvokeAsync(() => {
|
||||
MessageBox.Show($"EPD Error {e.returnValue}");
|
||||
endPage();
|
||||
Dispatcher.InvokeAsync(() => { SetTimedOutAndEnd(); });
|
||||
});
|
||||
}
|
||||
private void Ep_EpdRead(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdEventArgs e)
|
||||
{
|
||||
EntryState = eEntryState.epdOK;
|
||||
EpdReading = false;
|
||||
dispatcherTimer?.Stop();
|
||||
Dispatcher.InvokeAsync(() => GetEPD());
|
||||
}
|
||||
private bool LoadDoses()
|
||||
|
|
@ -164,7 +174,7 @@ namespace eDosStation
|
|||
// dispatcherTimer.Stop();
|
||||
// ep.Close();
|
||||
// System.Threading.Thread.Sleep(200);
|
||||
|
||||
|
||||
// int rv = ep.Connect(false,thisStation.EPDTimeOut);
|
||||
// System.Diagnostics.Debug.WriteLine($"Connect {rv} error {ep.ConnectError}");
|
||||
// if (ep.DeviceCount > 0 && ep.EpdID > 0)
|
||||
|
|
@ -296,25 +306,51 @@ namespace eDosStation
|
|||
{
|
||||
MessageBox.Show($"SetIssued error {rv}");
|
||||
}
|
||||
dispatcherTimer.Start(); //restart timer
|
||||
panelDone.Visibility = Visibility.Visible;
|
||||
lbHP07.Text = ep.Hp07Name;
|
||||
lbHP10.Text = ep.Hp10Name;
|
||||
panelWait.Visibility = Visibility.Collapsed;
|
||||
|
||||
|
||||
ShowFinal();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EntryState = eEntryState.epdError;
|
||||
System.Diagnostics.Debug.WriteLine("Not loaded");
|
||||
FinalTimeOut = false;
|
||||
SetTimedOutAndEnd();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowFinal()
|
||||
{
|
||||
FinalTimeOut = false;
|
||||
dispatcherTimer = new DispatcherTimer(DispatcherPriority.Background);
|
||||
dispatcherTimer.Interval = thisStation.InfoProgressbarInterval;
|
||||
dispatcherTimer.Tick += CountDown;
|
||||
ResultTime = DateTime.Now.AddSeconds(thisStation.InfoScreenTimeout);
|
||||
pWaitEpd.Value = pWaitEpd.Maximum = thisStation.InfoScreenTimeout;
|
||||
panelWait.Visibility = Visibility.Collapsed;
|
||||
panelDone.Visibility = Visibility.Visible;
|
||||
bEpdCancel.Content = "OK"; bEpdCancel.IsEnabled = true;
|
||||
EntryState = eEntryState.final;
|
||||
dispatcherTimer.Start(); //restart timer
|
||||
}
|
||||
private void GetEPD()
|
||||
{
|
||||
if (ep.DeviceCount == 1 && ep.EpdID> 0)
|
||||
if (ep.DeviceCount == 1 && ep.EpdID > 0)
|
||||
{
|
||||
statusEPD.Text = string.Empty;
|
||||
DoEPD();
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Not loaded");
|
||||
EntryState = eEntryState.epdtimeout;
|
||||
System.Diagnostics.Debug.WriteLine("TIME OUT");
|
||||
Dispatcher.InvokeAsync(() => { SetTimedOutAndEnd(); });
|
||||
}
|
||||
|
||||
}
|
||||
private void SetFilter(bool isAlara)
|
||||
|
|
@ -404,11 +440,13 @@ namespace eDosStation
|
|||
thisStation.splunkLog?.WriteSplunkLog(taskName, LSWLib.CLog.iseverity.info,"PersID 0 no access");
|
||||
tReasonNoAccess.Text = getCommentUnknown();
|
||||
if (_User.Error > 0) tReasonNoAccess.Text = _User.ErrorMessage;
|
||||
EntryState = eEntryState.NotAllowed;
|
||||
tbNotAllowed.IsSelected = true;
|
||||
Dispatcher.InvokeAsync(() => { endPage(); });
|
||||
}
|
||||
else
|
||||
{
|
||||
EntryState = eEntryState.getuser;
|
||||
tbUser.IsSelected = true;
|
||||
if (_User == null || _User.VisitIDLocked > 0 || _User.AccessAllow == false || _User.hasEPD)
|
||||
{
|
||||
|
|
@ -476,8 +514,9 @@ namespace eDosStation
|
|||
}
|
||||
void AskTask()
|
||||
{
|
||||
thisStation.splunkLog?.WriteSplunkLog("AskTask", LSWLib.CLog.iseverity.info);
|
||||
EntryState = eEntryState.gettask;
|
||||
tbTask.IsSelected = true;
|
||||
thisStation.splunkLog?.WriteSplunkLog("AskTask", LSWLib.CLog.iseverity.info);
|
||||
Naam.Text = _User.FirstName + " " + _User.LastName;
|
||||
dataSet1 = ((eDosStation.DataSet1)(this.FindResource("dataSet1")));
|
||||
dataInterface.FillTaskInfo(_User, dataSet1);
|
||||
|
|
@ -554,15 +593,16 @@ namespace eDosStation
|
|||
}
|
||||
else
|
||||
{
|
||||
EntryState = eEntryState.getepd;
|
||||
tb.SelectedItem = tbEPD;
|
||||
panelDone.Visibility = Visibility.Collapsed;//1
|
||||
panelWait.Visibility = Visibility.Visible;
|
||||
statusEPD.Text = $"Waiting for EPD (max {thisStation.EPDTimeOut/1000} seconds)";
|
||||
statusEPD.Text = $"Waiting for EPD ({thisStation.ScreenEPDTimeout} seconds)";
|
||||
dispatcherTimer = new DispatcherTimer(DispatcherPriority.Background);
|
||||
dispatcherTimer.Interval = TimeSpan.FromMilliseconds(thisStation.EPDTimeOut / 10);
|
||||
dispatcherTimer.Interval = thisStation.ScreenProgressBarInterval;
|
||||
dispatcherTimer.Tick += CountDown;
|
||||
ResultTime = DateTime.Now.AddMilliseconds(thisStation.EPDTimeOut);
|
||||
pWaitEpd.Value = pWaitEpd.Maximum = thisStation.EPDTimeOut / 1000;
|
||||
ResultTime = DateTime.Now.AddSeconds(thisStation.ScreenEPDTimeout);
|
||||
pWaitEpd.Value = pWaitEpd.Maximum = thisStation.ScreenEPDTimeout;
|
||||
dispatcherTimer.Start();
|
||||
startEPDRead();
|
||||
}
|
||||
|
|
@ -570,9 +610,53 @@ namespace eDosStation
|
|||
}
|
||||
private void startEPDRead()
|
||||
{
|
||||
EpdReading = true;
|
||||
EpdReading = true; bEpdCancel.IsEnabled = false;
|
||||
Dispatcher.InvokeAsync(new Action(() => { ep.Wait(thisStation.EPDTimeOut, thisStation.EPDRetries); }), DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
private void SetTimedOutAndEnd()
|
||||
{
|
||||
bool ShowExtraTime= true;
|
||||
if (!FinalTimeOut)
|
||||
{
|
||||
bEpdCancel.IsEnabled = true;
|
||||
FinalTimeOut = true;
|
||||
dispatcherTimer?.Stop();
|
||||
pWaitEpd.Value = 0;
|
||||
switch (EntryState) {
|
||||
case eEntryState.epdtimeout:
|
||||
pWaitEpd.Background = System.Windows.Media.Brushes.Red;
|
||||
statusEPD.Text = "Time out";
|
||||
tWaitFor.Text = "Lezer niet gevonden !";
|
||||
break;
|
||||
case eEntryState.epdError:
|
||||
pWaitEpd.Background = System.Windows.Media.Brushes.Red;
|
||||
statusEPD.Text = "Error";
|
||||
tWaitFor.Text = "Error with EPD!";
|
||||
break;
|
||||
default:
|
||||
bEpdCancel.Content = "OK";
|
||||
ShowExtraTime = false;
|
||||
break;
|
||||
}
|
||||
if (ShowExtraTime)
|
||||
{
|
||||
dispatcherTimer = new DispatcherTimer(DispatcherPriority.Background);
|
||||
dispatcherTimer.Tick += ShowAndEnd;
|
||||
dispatcherTimer.Interval = thisStation.ShowTimeoutTime;
|
||||
dispatcherTimer.Start();
|
||||
}
|
||||
else ShowAndEnd(null,null);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowAndEnd(object sender, EventArgs e)
|
||||
{
|
||||
dispatcherTimer?.Stop();
|
||||
dispatcherTimer = null;
|
||||
endPage();
|
||||
}
|
||||
|
||||
private void CountDown(object sender, EventArgs e)
|
||||
{
|
||||
double v = (ResultTime - DateTime.Now).TotalSeconds;
|
||||
|
|
@ -580,12 +664,8 @@ namespace eDosStation
|
|||
pWaitEpd.Value = v;
|
||||
else
|
||||
{
|
||||
dispatcherTimer.Stop();
|
||||
pWaitEpd.Value = 0;
|
||||
pWaitEpd.Background = System.Windows.Media.Brushes.Red;
|
||||
statusEPD.Text = "Time out";
|
||||
tWaitFor.Text = "Lezer niet gevonden !";
|
||||
bEpdCancel.IsEnabled = false;
|
||||
pWaitEpd.Value = pWaitEpd.Minimum;
|
||||
SetTimedOutAndEnd();
|
||||
}
|
||||
}
|
||||
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
|
|
@ -679,6 +759,7 @@ namespace eDosStation
|
|||
}
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
FinalTimeOut = false;
|
||||
try
|
||||
{
|
||||
if (ep != null)
|
||||
|
|
@ -735,12 +816,12 @@ namespace eDosStation
|
|||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
initialising = true;
|
||||
EpdReading = false;
|
||||
EpdReading = false; FinalTimeOut = false; bEpdCancel.IsEnabled = true;
|
||||
EntryState = eEntryState.Initial;
|
||||
tbEntry.IsSelected = true;
|
||||
panelDone.Visibility= Visibility.Collapsed;
|
||||
panelWait.Visibility = Visibility.Visible;
|
||||
cbAlara.IsChecked = false;
|
||||
|
||||
cbInst1.Content = thisStation.Inst_Name1;
|
||||
Inst1 = true;
|
||||
cbInst1.IsChecked = Inst1;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ namespace eDosStation
|
|||
SolidColorBrush GreenBrush = new SolidColorBrush(Colors.LightGreen);
|
||||
SolidColorBrush AlarmBrush = new SolidColorBrush(Colors.LightCoral);
|
||||
private DateTime ResultTime;
|
||||
private bool EpdReading = false;
|
||||
private bool FinalTimeOut = false;
|
||||
|
||||
|
||||
#if SimulateEPD
|
||||
public SimulateData simulData = new SimulateData();
|
||||
|
|
@ -21,54 +24,75 @@ namespace eDosStation
|
|||
public EpdExit(Station curStation)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
//ep = new EpdBaseClr.Epd2(curStation.ComPort);
|
||||
//ep.SetFeedbackSound(curStation.useBeep,curStation.useBeepMK3());
|
||||
//ep.EpdRead += Ep_EpdRead;
|
||||
//ep.EpdError += Ep_EpdError;
|
||||
//ep.EpdTO += Ep_EpdTO;
|
||||
|
||||
thisStation = curStation;
|
||||
dataInterface = curStation.dataInterface;
|
||||
|
||||
dispatcherTimer = new DispatcherTimer(DispatcherPriority.Normal);
|
||||
dispatcherTimer.Interval = TimeSpan.FromMilliseconds(thisStation.EPDTimeOut / 10);
|
||||
Progress.Maximum = Progress.Value = thisStation.EPDTimeOut / 1000;
|
||||
dispatcherTimer.Tick += DispatcherTimer_Tick;
|
||||
|
||||
}
|
||||
|
||||
private void DispatcherTimer_Tick(object sender, EventArgs e)
|
||||
private void CountDown(object sender, EventArgs e)
|
||||
{
|
||||
double v = (ResultTime - DateTime.Now).TotalSeconds;
|
||||
if (v > Progress.Minimum)
|
||||
Progress.Value = v;
|
||||
else
|
||||
{
|
||||
dispatcherTimer?.Stop();
|
||||
endPage();
|
||||
SetTimedOutAndEnd();
|
||||
}
|
||||
}
|
||||
|
||||
private void Ep_EpdTO(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdTOEventArgs e)
|
||||
{
|
||||
Dispatcher.InvokeAsync(() => {
|
||||
MessageBox.Show($"Timeout after {e.tries} tries, ConnectTimeout={e.connecttimeout}");
|
||||
endPage();
|
||||
});
|
||||
System.Diagnostics.Debug.WriteLine("TIME OUT");
|
||||
Dispatcher.InvokeAsync(() => { SetTimedOutAndEnd(); });
|
||||
}
|
||||
|
||||
private void Ep_EpdError(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdErrorEventArgs e)
|
||||
{
|
||||
Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
MessageBox.Show("EPD error");
|
||||
endPage();
|
||||
System.Diagnostics.Debug.WriteLine("ERROR ");
|
||||
Dispatcher.InvokeAsync(() => {
|
||||
MessageBox.Show($"EPD Error {e.returnValue}");
|
||||
Dispatcher.InvokeAsync(() => { SetTimedOutAndEnd(); });
|
||||
});
|
||||
}
|
||||
|
||||
private void Ep_EpdRead(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdEventArgs e)
|
||||
{
|
||||
EpdReading = false;
|
||||
dispatcherTimer?.Stop();
|
||||
Dispatcher.InvokeAsync(() => LoadDoses());
|
||||
|
||||
}
|
||||
|
||||
private void startEPDRead()
|
||||
{
|
||||
EpdReading = true; bCancel.IsEnabled = false;
|
||||
Dispatcher.InvokeAsync(new Action(() => { ep.Wait(thisStation.EPDTimeOut, thisStation.EPDRetries); }), DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
private void SetTimedOutAndEnd()
|
||||
{
|
||||
if (!FinalTimeOut)
|
||||
{
|
||||
bCancel.IsEnabled = true;
|
||||
FinalTimeOut = true;
|
||||
dispatcherTimer?.Stop();
|
||||
Progress.Value = 0;
|
||||
Progress.Background = System.Windows.Media.Brushes.Red;
|
||||
statusEPD.Content = "Time out";
|
||||
//tWaitFor.Text = "Lezer niet gevonden !";
|
||||
dispatcherTimer = new DispatcherTimer(DispatcherPriority.Background);
|
||||
dispatcherTimer.Tick += ShowAndEnd;
|
||||
dispatcherTimer.Interval = thisStation.ShowTimeoutTime;
|
||||
dispatcherTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowAndEnd(object sender, EventArgs e)
|
||||
{
|
||||
dispatcherTimer?.Stop();
|
||||
dispatcherTimer = null;
|
||||
endPage();
|
||||
}
|
||||
|
||||
private void LoadDoses()
|
||||
|
|
@ -170,8 +194,10 @@ namespace eDosStation
|
|||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Wait.IsSelected = true;
|
||||
dispatcherTimer.Start();
|
||||
ResultTime = DateTime.Now.AddMilliseconds(thisStation.EPDTimeOut);
|
||||
|
||||
dispatcherTimer = new DispatcherTimer(DispatcherPriority.Background);
|
||||
dispatcherTimer.Interval = thisStation.ScreenProgressBarInterval;
|
||||
dispatcherTimer.Tick += CountDown;
|
||||
|
||||
//StartEPD
|
||||
if (ep == null)
|
||||
|
|
@ -189,8 +215,16 @@ namespace eDosStation
|
|||
MessageBox.Show($"{ex.Message}");
|
||||
ep = null;
|
||||
}
|
||||
|
||||
|
||||
if (ep!=null)
|
||||
Dispatcher.InvokeAsync(() => ep.Wait(thisStation.EPDTimeOut, thisStation.EPDRetries ), DispatcherPriority.Background);
|
||||
{
|
||||
ResultTime = DateTime.Now.AddSeconds(thisStation.ScreenEPDTimeout);
|
||||
Progress.Value= Progress.Maximum = thisStation.ScreenEPDTimeout;
|
||||
dispatcherTimer.Start();
|
||||
startEPDRead();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void BCloseExit_Click(object sender, RoutedEventArgs e)
|
||||
|
|
@ -205,6 +239,7 @@ namespace eDosStation
|
|||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
FinalTimeOut = false;
|
||||
if (dispatcherTimer?.IsEnabled == true) dispatcherTimer.IsEnabled = false;
|
||||
try
|
||||
{
|
||||
|
|
@ -216,6 +251,19 @@ namespace eDosStation
|
|||
thisStation.splunkLog.WriteException("EpdExit", "Closing", ex);
|
||||
System.Diagnostics.Debug.WriteLine(ex.Message);
|
||||
}
|
||||
try
|
||||
{
|
||||
if (ep != null)
|
||||
{
|
||||
ep.WaitEnd();
|
||||
ep.Dispose();
|
||||
ep = null;
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void endWithMessage(string message)
|
||||
|
|
@ -226,6 +274,13 @@ namespace eDosStation
|
|||
|
||||
public void endPage()
|
||||
{
|
||||
if (EpdReading)
|
||||
{
|
||||
//MessageBox.Show("Fout bij initialiseren EPD! ");
|
||||
}
|
||||
EpdReading = false;
|
||||
dispatcherTimer?.Stop();
|
||||
dispatcherTimer = null;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,8 @@
|
|||
</Grid>
|
||||
|
||||
<StackPanel Grid.Row="9" Grid.Column="0" Grid.ColumnSpan="6" HorizontalAlignment="Center" VerticalAlignment="Center" >
|
||||
<telerik:RadButton Content="Close" Style="{StaticResource OkCancelButton}" Margin="0,20,0,20" Click="RadButton_Click" />
|
||||
<telerik:RadButton x:Name="bEpdCancel" Content="Close" Style="{StaticResource OkCancelButton}" Margin="0,20,0,20" Click="RadButton_Click" />
|
||||
<TextBlock x:Name="tWaitFor" Text="" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
|
|
|
|||
|
|
@ -10,16 +10,22 @@ namespace eDosStation
|
|||
/// </summary>
|
||||
public partial class ShowEPDDose : Window
|
||||
{
|
||||
private enum eEntryState { none, getepd, epdtimeout, epdError, epdOK, final };
|
||||
private eEntryState EntryState;
|
||||
|
||||
Station thisStation;
|
||||
EpdBaseClr.Epd2 ep;
|
||||
DispatcherTimer dispatcherTimer;
|
||||
private DateTime ResultTime;
|
||||
private User thisUser;
|
||||
private bool EpdReading;
|
||||
private bool FinalTimeOut;
|
||||
|
||||
public ShowEPDDose(Station curStation)
|
||||
{
|
||||
InitializeComponent();
|
||||
thisStation = curStation;
|
||||
EntryState = eEntryState.none;
|
||||
}
|
||||
|
||||
private void CountDown(object sender, EventArgs e)
|
||||
|
|
@ -32,29 +38,29 @@ namespace eDosStation
|
|||
}
|
||||
else
|
||||
{
|
||||
dispatcherTimer.Stop();
|
||||
endPage();
|
||||
|
||||
SetTimedOutAndEnd();
|
||||
}
|
||||
}
|
||||
|
||||
private void Ep_EpdTO(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdTOEventArgs e)
|
||||
{
|
||||
Dispatcher.InvokeAsync(() => {
|
||||
MessageBox.Show($"Timeout after {e.tries} tries, ConnectTimeout={e.connecttimeout}");
|
||||
endPage();
|
||||
});
|
||||
System.Diagnostics.Debug.WriteLine("TIME OUT");
|
||||
Dispatcher.InvokeAsync(() => { SetTimedOutAndEnd(); });
|
||||
}
|
||||
|
||||
private void Ep_EpdError(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdErrorEventArgs e)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("ERROR ");
|
||||
Dispatcher.InvokeAsync(() => {
|
||||
MessageBox.Show($"EPD Error {e.returnValue}");
|
||||
endPage();
|
||||
Dispatcher.InvokeAsync(() => { SetTimedOutAndEnd(); });
|
||||
});
|
||||
}
|
||||
|
||||
private void Ep_EpdRead(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdEventArgs e)
|
||||
{
|
||||
EpdReading = false; dispatcherTimer?.Stop();
|
||||
Dispatcher.InvokeAsync(() => LoadDoses());
|
||||
}
|
||||
|
||||
|
|
@ -112,8 +118,6 @@ namespace eDosStation
|
|||
} else {
|
||||
lNGain.Visibility = NGain.Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(sPersID))
|
||||
{
|
||||
|
|
@ -125,28 +129,69 @@ namespace eDosStation
|
|||
catch
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
epdUserMargin.Text = "--";
|
||||
|
||||
Progress.Visibility = Visibility.Collapsed;
|
||||
bEpdCancel.IsEnabled = true;
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FinalTimeOut = false;
|
||||
EpdReading = false;
|
||||
|
||||
ep = new EpdBaseClr.Epd2(thisStation.ComPort,thisStation.OnlyMK2);
|
||||
ep.SetFeedbackSound(thisStation.useBeep, thisStation.useBeepMK3());
|
||||
ep.EpdRead += Ep_EpdRead;
|
||||
ep.EpdError += Ep_EpdError;
|
||||
ep.EpdTO += Ep_EpdTO;
|
||||
|
||||
dispatcherTimer = new DispatcherTimer(DispatcherPriority.Normal);
|
||||
dispatcherTimer.Interval = TimeSpan.FromMilliseconds(thisStation.EPDTimeOut / 10);
|
||||
Progress.Maximum = Progress.Value = dispatcherTimer.Interval.TotalSeconds * 10;
|
||||
dispatcherTimer = new DispatcherTimer(DispatcherPriority.Background);
|
||||
dispatcherTimer.Interval = thisStation.ScreenProgressBarInterval;
|
||||
dispatcherTimer.Tick += CountDown;
|
||||
|
||||
Dispatcher.InvokeAsync(() => ep.Wait(thisStation.EPDTimeOut, 1),DispatcherPriority.Background);
|
||||
ResultTime = DateTime.Now.AddMilliseconds(thisStation.EPDTimeOut);
|
||||
ResultTime = DateTime.Now.AddSeconds(thisStation.ScreenEPDTimeout);
|
||||
Progress.Value = Progress.Maximum = thisStation.ScreenEPDTimeout;
|
||||
dispatcherTimer.Start();
|
||||
startEPDRead();
|
||||
|
||||
//dispatcherTimer = new DispatcherTimer(DispatcherPriority.Normal);
|
||||
//dispatcherTimer.Interval = TimeSpan.FromMilliseconds(thisStation.EPDTimeOut / 10);
|
||||
//Progress.Maximum = Progress.Value = dispatcherTimer.Interval.TotalSeconds * 10;
|
||||
//dispatcherTimer.Tick += CountDown;
|
||||
//Dispatcher.InvokeAsync(() => ep.Wait(thisStation.EPDTimeOut, 1),DispatcherPriority.Background);
|
||||
//dispatcherTimer.Start();
|
||||
}
|
||||
private void startEPDRead()
|
||||
{
|
||||
EpdReading = true; bEpdCancel.IsEnabled = false;
|
||||
Dispatcher.InvokeAsync(new Action(() => { ep.Wait(thisStation.EPDTimeOut, thisStation.EPDRetries); }), DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
private void SetTimedOutAndEnd()
|
||||
{
|
||||
if (!FinalTimeOut)
|
||||
{
|
||||
bEpdCancel.IsEnabled = true;
|
||||
FinalTimeOut = true;
|
||||
dispatcherTimer?.Stop();
|
||||
Progress.Value = 0;
|
||||
Progress.Background = System.Windows.Media.Brushes.Red;
|
||||
statusEPD.Content = "Time out";
|
||||
tWaitFor.Text = "Lezer niet gevonden !";
|
||||
dispatcherTimer = new DispatcherTimer(DispatcherPriority.Background);
|
||||
dispatcherTimer.Tick += ShowAndEnd;
|
||||
dispatcherTimer.Interval = thisStation.ShowTimeoutTime;
|
||||
dispatcherTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowAndEnd(object sender, EventArgs e)
|
||||
{
|
||||
dispatcherTimer?.Stop();
|
||||
dispatcherTimer = null;
|
||||
endPage();
|
||||
}
|
||||
|
||||
private void endPage()
|
||||
|
|
@ -164,6 +209,7 @@ namespace eDosStation
|
|||
{
|
||||
dispatcherTimer?.Stop();
|
||||
dispatcherTimer = null;
|
||||
EpdReading = true;
|
||||
try
|
||||
{
|
||||
if (ep != null)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using spl1 = LSWLib.CLog;
|
||||
|
|
@ -15,7 +12,7 @@ namespace eDosStation
|
|||
const string moduleName = "Station";
|
||||
public spl1 splunkLog;
|
||||
private bool doLog;
|
||||
public System.IO.StreamWriter stationLog=null;
|
||||
public System.IO.StreamWriter stationLog = null;
|
||||
public int ID_Station { get; set; }
|
||||
public int ComPort { get; set; }
|
||||
public int Inst_CODE1 { get; set; }
|
||||
|
|
@ -25,17 +22,23 @@ namespace eDosStation
|
|||
public string TestCSN { get; set; }
|
||||
public string TestCode { get; set; }
|
||||
public string Reader { get; internal set; }
|
||||
public bool useTestButtons { get; set; }
|
||||
public bool useTestButtons { get; set; }
|
||||
public byte useBeep { get; set; }
|
||||
public bool checkUser { get; internal set; }
|
||||
public bool RestartCom { get; set; }
|
||||
public int EPDTimeOut { get; internal set; }
|
||||
/// <summary>
|
||||
/// EpdTimeout in seconds + 5
|
||||
/// </summary>
|
||||
public int ScreenEPDTimeout { get { return (EPDTimeOut/1000)+1; } }
|
||||
public TimeSpan ScreenProgressBarInterval{ get { return TimeSpan.FromSeconds((double)ScreenEPDTimeout/20.0) ; } }
|
||||
public int EPDRetries { get; internal set; }
|
||||
public bool OnlyMK2 { get; internal set; }
|
||||
public bool RestartComFirst { get; internal set; }
|
||||
|
||||
public bool AllowMultipleEPD { get; internal set; }
|
||||
|
||||
public TimeSpan ShowTimeoutTime { get; internal set; }
|
||||
public TimeSpan InfoProgressbarInterval { get; internal set; }
|
||||
public double InfoScreenTimeout { get; internal set; }
|
||||
public bool Changed = false;
|
||||
public int Error = 0;
|
||||
public string ErrorMessage;
|
||||
|
|
@ -72,6 +75,10 @@ namespace eDosStation
|
|||
EPDTimeOut = 10000; //ms
|
||||
EPDRetries = 2;
|
||||
|
||||
ShowTimeoutTime = TimeSpan.FromSeconds(8);
|
||||
InfoScreenTimeout = 5;
|
||||
InfoProgressbarInterval = TimeSpan.FromSeconds(1);
|
||||
|
||||
beepMk3Map = new Dictionary<byte, ushort>();
|
||||
beepMk3Map.Add(0b00010111, 0b1001110011100001);
|
||||
beepMk3Map.Add(0b00011111, 0b1001110011000001);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="LSWLib" version="3.0.14" targetFramework="net48" />
|
||||
<package id="LSWLib" version="3.1.3" targetFramework="net48" />
|
||||
<package id="Microsoft.VisualStudio.SlowCheetah" version="4.0.8" targetFramework="net48" developmentDependency="true" />
|
||||
</packages>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\LSWLib.3.0.14\build\LSWLib.props" Condition="Exists('..\packages\LSWLib.3.0.14\build\LSWLib.props')" />
|
||||
<Import Project="..\packages\LSWLib.3.1.3\build\LSWLib.props" Condition="Exists('..\packages\LSWLib.3.1.3\build\LSWLib.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
|
|
@ -106,9 +106,9 @@
|
|||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.VisualStudio.SlowCheetah.4.0.8\build\Microsoft.VisualStudio.SlowCheetah.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.VisualStudio.SlowCheetah.4.0.8\build\Microsoft.VisualStudio.SlowCheetah.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\LSWLib.3.0.14\build\LSWLib.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LSWLib.3.0.14\build\LSWLib.props'))" />
|
||||
<Error Condition="!Exists('..\packages\LSWLib.3.0.14\build\LSWLib.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LSWLib.3.0.14\build\LSWLib.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\LSWLib.3.1.3\build\LSWLib.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LSWLib.3.1.3\build\LSWLib.props'))" />
|
||||
<Error Condition="!Exists('..\packages\LSWLib.3.1.3\build\LSWLib.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LSWLib.3.1.3\build\LSWLib.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.VisualStudio.SlowCheetah.4.0.8\build\Microsoft.VisualStudio.SlowCheetah.targets" Condition="Exists('..\packages\Microsoft.VisualStudio.SlowCheetah.4.0.8\build\Microsoft.VisualStudio.SlowCheetah.targets')" />
|
||||
<Import Project="..\packages\LSWLib.3.0.14\build\LSWLib.targets" Condition="Exists('..\packages\LSWLib.3.0.14\build\LSWLib.targets')" />
|
||||
<Import Project="..\packages\LSWLib.3.1.3\build\LSWLib.targets" Condition="Exists('..\packages\LSWLib.3.1.3\build\LSWLib.targets')" />
|
||||
</Project>
|
||||
Loading…
Add table
Reference in a new issue