timeout handling search epd

This commit is contained in:
Luc 2021-05-03 09:56:58 +02:00
parent e176beb922
commit 90f7b2ca8e
8 changed files with 115 additions and 93 deletions

View file

@ -1,6 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "EpdBase.h" #include "EpdBase.h"
#define DiscoveryTimeslotPeriod 100 #include "TimeFunctions.cpp"
#define DiscoveryTimeslotPeriod 500
#define DiscoveryExpirationPeriod 6000 #define DiscoveryExpirationPeriod 6000
#define RxRetryCount 5 #define RxRetryCount 5
#define TxRetryCount 5 #define TxRetryCount 5
@ -10,6 +11,10 @@ EpdBase::Epd2U::Epd2U(int comport)
{ {
port = comport; port = comport;
CommsInitialized = 0; CommsInitialized = 0;
Ev1 = INVALID_HANDLE_VALUE;
maxDiscoverTime = 10000;
if (port == 0) return; if (port == 0) return;
SetAutoCommit(0); SetAutoCommit(0);
Error = 123; Error = 123;
@ -59,10 +64,15 @@ int EpdBase::Epd2U::StartDiscover()
{ {
//WORD rv; //WORD rv;
//System::Diagnostics::Trace::WriteLine("StartDiscover"); //System::Diagnostics::Trace::WriteLine("StartDiscover");
Sleep(100);
Error = 0; Error = 0;
Ev1 = CreateWaitableTimer(NULL, TRUE, NULL);
LARGE_INTEGER wt ;
wt.QuadPart = Int32x32To64(maxDiscoverTime,-10000); //10 seconden proberen
//wt.QuadPart = -100000000LL;
if (Ev1!=NULL) SetWaitableTimer(Ev1, &wt, 0, NULL, NULL, FALSE);
//SetDiscoveryTimeslotCount(port, 2); //SetDiscoveryTimeslotCount(port, 2);
//SetDiscoveryTimeslotPeriod(port, DiscoveryTimeslotPeriod); SetDiscoveryTimeslotPeriod(port, DiscoveryTimeslotPeriod);
//SetDiscoveryExpirationPeriod(port, DiscoveryExpirationPeriod); //SetDiscoveryExpirationPeriod(port, DiscoveryExpirationPeriod);
//rv =SetRetryCounts(RxRetryCount, TxRetryCount); //rv =SetRetryCounts(RxRetryCount, TxRetryCount);
@ -72,12 +82,13 @@ int EpdBase::Epd2U::StartDiscover()
DeviceIDs[0] = 768; DeviceIDs[0] = 768;
return 1; return 1;
} }
FlushDiscoveryCache(port); FlushDiscoveryCache(port);
FlushBuffers(port); FlushBuffers(port);
int tries = 25; DeviceCount = 0; DiscRV = 1; int maxtries = 100; DeviceCount = 0; DiscRV = 1; DWORD wo = 1; // ongeveer 43 tries in 10 seconden
while (tries-- > 0 && DeviceCount == 0 ) int tries = 0;
while (DeviceCount == 0 && wo!=0) //tries-- > 0 &&
{ {
tries++;
//memset(DeviceIDs, 0, sizeof(DeviceIDs)); //memset(DeviceIDs, 0, sizeof(DeviceIDs));
DiscRV = Discover(port, DeviceIDs, MaxDevices, &DeviceCount); DiscRV = Discover(port, DeviceIDs, MaxDevices, &DeviceCount);
//System::Diagnostics::Trace::WriteLine(System::String::Format("Discover try: {0} RV={1}", tries, DiscRV)); //System::Diagnostics::Trace::WriteLine(System::String::Format("Discover try: {0} RV={1}", tries, DiscRV));
@ -85,8 +96,10 @@ int EpdBase::Epd2U::StartDiscover()
Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData); Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
//System::Diagnostics::Trace::WriteLine(System::String::Format("StartDiscover Error Connect Reason: {0} ErrorData {1}", ErrorReason, ErrorData)); //System::Diagnostics::Trace::WriteLine(System::String::Format("StartDiscover Error Connect Reason: {0} ErrorData {1}", ErrorReason, ErrorData));
} }
wo = WaitForSingleObject(Ev1, 0);
} }
//System::Diagnostics::Trace::WriteLine(System::String::Format("Discover DeviceCount = {0}", DeviceCount)); //System::Diagnostics::Trace::WriteLine(System::String::Format("Discover DeviceCount = {0}", DeviceCount));
CloseHandle(Ev1); Ev1 = INVALID_HANDLE_VALUE;
return DiscRV; return DiscRV;
} }
void EpdBase::Epd2U::Open(DWORD DeviceID) void EpdBase::Epd2U::Open(DWORD DeviceID)

View file

@ -16,9 +16,9 @@ namespace EpdBase
DWORD DeviceIDs[10]; DWORD DeviceIDs[10];
DWORD CurrentDeviceID; DWORD CurrentDeviceID;
//WORD AlarmCtrl = 0b01111110; WORD AlarmCtrl = 0b01111110;
WORD AlarmCtrl = 0b01111010; // NO sound //WORD AlarmCtrl = 0b01111010; // NO sound
WORD EndSessionControl = 0b00010010; WORD EndSessionControl = 0b00010110;
BYTE displayConfig[56] = { 0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; BYTE displayConfig[56] = { 0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
@ -203,6 +203,8 @@ namespace EpdBase
BYTE byStatus3; BYTE byStatus3;
BYTE byStatus4; BYTE byStatus4;
int maxDiscoverTime = 10000;
LARGE_INTEGER WaitDiscovery;
int StartDiscover(); int StartDiscover();
void Open(DWORD DeviceID); void Open(DWORD DeviceID);
void Close(); void Close();
@ -226,10 +228,9 @@ namespace EpdBase
WORD PrepareForIssue(); WORD PrepareForIssue();
WORD DeIssue(); WORD DeIssue();
WORD Issue(); WORD Issue();
~Epd2U(); ~Epd2U();
HANDLE Ev1 = INVALID_HANDLE_VALUE;;
}; };
} }

View file

@ -128,12 +128,6 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\MK3\CommonEpdTypes.h" />
<ClInclude Include="..\MK3\Epd2.h" />
<ClInclude Include="..\MK3\Epd3.h" />
<ClInclude Include="..\MK3\EpdCommon.h" />
<ClInclude Include="..\MK3\Mk3Types.h" />
<ClInclude Include="..\MK3\TimeFunctions.h" />
<ClInclude Include="EpdBase.h" /> <ClInclude Include="EpdBase.h" />
<ClInclude Include="Resource.h" /> <ClInclude Include="Resource.h" />
<ClInclude Include="stdafx.h" /> <ClInclude Include="stdafx.h" />

View file

@ -15,36 +15,18 @@
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="EpdBase.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stdafx.h"> <ClInclude Include="stdafx.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Resource.h"> <ClInclude Include="Resource.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="EpdBase.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TimeFunctions.h"> <ClInclude Include="TimeFunctions.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\MK3\CommonEpdTypes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\MK3\Epd2.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\MK3\Epd3.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\MK3\EpdCommon.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\MK3\Mk3Types.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\MK3\TimeFunctions.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="EpdBase.cpp"> <ClCompile Include="EpdBase.cpp">

View file

@ -12,7 +12,7 @@ void TimeFunctions::UnixTimeToFileTime(time_t t, LPFILETIME pft)
{ {
// Note that LONGLONG is a 64-bit value // Note that LONGLONG is a 64-bit value
LONGLONG ll; LONGLONG ll;
ll = Int32x32To64(t, 10000000) + 116444736000000000; ll = Int32x32To64(t, 10000000) + 116444736000000000;
pft->dwLowDateTime = (DWORD)ll; pft->dwLowDateTime = (DWORD)ll;
pft->dwHighDateTime = ll >> 32; pft->dwHighDateTime = ll >> 32;
@ -23,4 +23,12 @@ void TimeFunctions::UnixTimeToFileTime(time_t t, LPFILETIME pft)
FILETIME ft; FILETIME ft;
UnixTimeToFileTime(t, &ft); UnixTimeToFileTime(t, &ft);
FileTimeToSystemTime(&ft, pst); FileTimeToSystemTime(&ft, pst);
} }
void TimeFunctions::msToFileTime(UINT32 ms, LARGE_INTEGER &pft)
{
// Note that LONGLONG is a 64-bit value
LONGLONG ll;
ll = Int32x32To64(ms, 10000) ;
pft.QuadPart = ll;
}

View file

@ -8,6 +8,7 @@ public:
TimeFunctions(); TimeFunctions();
static void UnixTimeToFileTime(time_t t, LPFILETIME pft); static void UnixTimeToFileTime(time_t t, LPFILETIME pft);
static void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst); static void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst);
static void msToFileTime(UINT32 ms, LARGE_INTEGER &pft);
}; };

View file

@ -17,7 +17,7 @@
</Window.Resources> </Window.Resources>
<DockPanel> <DockPanel>
<TabControl Name="tb" TabStripPlacement="Top" > <TabControl Name="tb" TabStripPlacement="Top" SelectionChanged="tb_SelectionChanged" >
<TabItem Name="tbEntry" > <TabItem Name="tbEntry" >
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<Border Background="AliceBlue" TextBlock.FontSize="24" TextBlock.LineHeight="30px" Padding="20,20,20,20" CornerRadius="10" BorderThickness="2" BorderBrush="Blue" > <Border Background="AliceBlue" TextBlock.FontSize="24" TextBlock.LineHeight="30px" Padding="20,20,20,20" CornerRadius="10" BorderThickness="2" BorderBrush="Blue" >
@ -44,7 +44,6 @@
<StackPanel Orientation="Horizontal" Margin="0,50,0,0" Name="pTestButtons"> <StackPanel Orientation="Horizontal" Margin="0,50,0,0" Name="pTestButtons">
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</TabItem> </TabItem>
<TabItem Name="tbUser" > <TabItem Name="tbUser" >
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Vertical"> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Vertical">
@ -65,7 +64,6 @@
<ProgressBar.Effect> <ProgressBar.Effect>
<DropShadowEffect/> <DropShadowEffect/>
</ProgressBar.Effect> </ProgressBar.Effect>
</ProgressBar> </ProgressBar>
<TextBlock x:Name="tUserSeconds" Text="10" TextAlignment="Center" HorizontalAlignment="Stretch" /> <TextBlock x:Name="tUserSeconds" Text="10" TextAlignment="Center" HorizontalAlignment="Stretch" />
<Button Content="OK" Name="bUserRead" Click="BUserRead_Click"/> <Button Content="OK" Name="bUserRead" Click="BUserRead_Click"/>
@ -218,20 +216,23 @@
</StackPanel> </StackPanel>
</Grid> </Grid>
</TabItem> </TabItem>
<TabItem Name="tbEPD"> <TabItem Name="tbEPD" FontSize="25" FontFamily="Comic Sans MS" >
<Grid> <Grid >
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="100" /> <RowDefinition Height="100" />
<RowDefinition Height="100" /> <RowDefinition Height="100" />
<RowDefinition Height="100" /> <RowDefinition Height="100" />
<RowDefinition Height="100" />
<RowDefinition Height="50" />
<RowDefinition Height="100" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center" FontSize="25" FontFamily="Comic Sans MS"> <TextBlock Grid.Row="0" FontSize="25" FontFamily="Comic Sans MS" Name="epdWait" Text="w" HorizontalAlignment="Center" TextAlignment="Center" />
<Run Text="Issuing EPD:" /> <TextBlock Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center" FontSize="25" FontFamily="Comic Sans MS">
<Run Name="statusEPD" Text="" /> <Run Text="Issuing EPD:" />
<LineBreak/> <Run Name="statusEPD" Text="" /><LineBreak/>
</TextBlock> </TextBlock>
<Image Grid.Row="1" Source="{StaticResource iBG}"/> <Image Grid.Row="2" Source="{StaticResource iBG}"/>
<Button Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="24" Background="LawnGreen" Padding="10,10,10,10" Content="OK" Name="bEpdDone" Visibility="Hidden" Click="bClose_Click" /> <Button Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="24" Background="LawnGreen" Padding="10,10,10,10" Content="OK" Name="bEpdDone" Visibility="Hidden" Click="bClose_Click" />
</Grid> </Grid>
</TabItem> </TabItem>
<TabItem Name="tbNotAllowed"> <TabItem Name="tbNotAllowed">

View file

@ -18,10 +18,10 @@ namespace eDosStation
Station thisStation; Station thisStation;
EpdBaseClr.Epd2 ep; EpdBaseClr.Epd2 ep;
bool EpdFound = false; bool EpdFound = false;
DispatcherTimer dispatcherTimer; DispatcherTimer dispatcherTimer, epdTimer;
int Search, UserSeconds; int Search, UserSeconds;
Boolean Inst1 = false, Inst2 = false; Boolean Inst1 = false, Inst2 = false;
private System.Threading.Tasks.Task ReaderTask =null; private System.Threading.Tasks.Task ReaderTask = null;
private DataInterface dataInterface; private DataInterface dataInterface;
public LSWDesfirePublic.CCard dfReader = null; public LSWDesfirePublic.CCard dfReader = null;
//System.Threading.Thread t; //System.Threading.Thread t;
@ -33,9 +33,9 @@ namespace eDosStation
static User _User; static User _User;
DataSet1.GetTaskInfoRow CurTaskRow; DataSet1.GetTaskInfoRow CurTaskRow;
enum eCOE { quiz=1} ; enum eCOE { quiz = 1 };
#if SimulateEPD #if SimulateEPD
public SimulateData simulData = new SimulateData(); public SimulateData simulData = new SimulateData();
@ -54,7 +54,7 @@ namespace eDosStation
{ {
bool rv = true; bool rv = true;
System.Diagnostics.Debug.WriteLine("LoadDoses: EPD GEt Status"); System.Diagnostics.Debug.WriteLine("LoadDoses: EPD GEt Status");
int rva= ep.GetStatus(); int rva = ep.GetStatus();
#if SimulateEPD #if SimulateEPD
ep.CountsClock = 12345; ep.CountsClock = 12345;
ep.alarmStatus = 0; ep.alarmStatus = 0;
@ -72,10 +72,10 @@ namespace eDosStation
this.Close(); this.Close();
return false; return false;
} }
if (ep.alarmStatus != 0 || (ep.otherAlarms & 0x7f)!=0) if (ep.alarmStatus != 0 || (ep.otherAlarms & 0x7f) != 0)
{ {
StringBuilder sb = new StringBuilder("EPD is in alarm status\n\n"); StringBuilder sb = new StringBuilder("EPD is in alarm status\n\n");
if (ep.alarmStatus>0) sb.AppendLine("- Alarm dose"); if (ep.alarmStatus > 0) sb.AppendLine("- Alarm dose");
if (ep.OtherAlarmBatLow > 0) sb.AppendLine("- Battery Low"); if (ep.OtherAlarmBatLow > 0) sb.AppendLine("- Battery Low");
sb.AppendLine(); sb.AppendLine();
sb.AppendLine("Please take another"); sb.AppendLine("Please take another");
@ -90,7 +90,7 @@ namespace eDosStation
this.Close(); this.Close();
return false; return false;
} }
rva = ep.ReadTresholds(); rva = ep.ReadTresholds();
if (rva != 1) if (rva != 1)
{ {
@ -101,13 +101,15 @@ namespace eDosStation
} }
private void DispatcherTimer_Tick(object sender, EventArgs e) private void DispatcherTimer_Tick(object sender, EventArgs e)
{ {
//Was timeout
//voorlopig niet meer gebruikt
EpdFound = false; EpdFound = false;
dispatcherTimer.Stop(); dispatcherTimer.Stop();
ep.Close(); ep.Close();
System.Threading.Thread.Sleep(200); System.Threading.Thread.Sleep(200);
int rv= ep.Connect(false); int rv = ep.Connect(false);
System.Diagnostics.Debug.WriteLine($"Connect {rv} error {ep.ConnectError}"); System.Diagnostics.Debug.WriteLine($"Connect {rv} error {ep.ConnectError}");
if (ep.DeviceCount >0 && ep.b.CurrentDeviceID>0) if (ep.DeviceCount > 0 && ep.b.CurrentDeviceID > 0)
{ {
System.Diagnostics.Debug.WriteLine($"Devices:{ep.DeviceCount} id:{ep.b.CurrentDeviceID} {ep.ConnectError} "); System.Diagnostics.Debug.WriteLine($"Devices:{ep.DeviceCount} id:{ep.b.CurrentDeviceID} {ep.ConnectError} ");
EpdFound = true; EpdFound = true;
@ -151,7 +153,7 @@ namespace eDosStation
dataInterface.VisitInitCommand.Parameters["EPD_InternalID"].Value = (int)ep.EpdID; dataInterface.VisitInitCommand.Parameters["EPD_InternalID"].Value = (int)ep.EpdID;
dataInterface.VisitInitCommand.Parameters["isBG"].Value = isBG; dataInterface.VisitInitCommand.Parameters["isBG"].Value = isBG;
dataInterface.VisitInitCommand.Parameters["ENTRY_EPD_CLOCK"].Value = ep.CountsClock; dataInterface.VisitInitCommand.Parameters["ENTRY_EPD_CLOCK"].Value = ep.CountsClock;
using (var l = new SqlLog()) using (var l = new SqlLog())
try try
@ -224,31 +226,34 @@ namespace eDosStation
private void GetEPD() private void GetEPD()
{ {
if (_User == null || CurTaskRow == null) return; if (_User == null || CurTaskRow == null) return;
int ok = ep.Connect(false); int ok = ep.Connect(false);
if (ok != 1) System.Diagnostics.Debug.WriteLine($"GetEpd {ok} ConnectError: {ep.ConnectError}"); if (ok != 1) System.Diagnostics.Debug.WriteLine($"GetEpd {ok} ConnectError: {ep.ConnectError}");
if (ep.DeviceCount == 1 && ep.b.CurrentDeviceID>0) if (ep.DeviceCount == 1 && ep.b.CurrentDeviceID > 0)
{ {
epdWait.Text = string.Empty;
EpdFound = true; EpdFound = true;
DoEPD(); DoEPD();
} }
if (!EpdFound) if (!EpdFound)
{ {
statusEPD.Text = $"EPD: Wait "; MessageBox.Show("EPD niet gevonden");
Search = 100; this.Close();
dispatcherTimer = new DispatcherTimer(); endPage();
dispatcherTimer.Tick += DispatcherTimer_Tick; //statusEPD.Text = $"EPD: Wait ";
dispatcherTimer.Interval = new TimeSpan(0, 0, 2); //Search = 100;
dispatcherTimer.Start(); //dispatcherTimer = new DispatcherTimer();
return; //dispatcherTimer.Tick += DispatcherTimer_Tick;
//dispatcherTimer.Interval = new TimeSpan(0, 0, 2);
//dispatcherTimer.Start();
//return;
} }
} }
private void SetFilter(bool isAlara) private void SetFilter(bool isAlara)
{ {
Inst1 = (cbInst1.IsChecked ==true); Inst1 = (cbInst1.IsChecked == true);
Inst2 = (cbInst2.IsChecked ==true); Inst2 = (cbInst2.IsChecked == true);
StringBuilder fi = new StringBuilder(); StringBuilder fi = new StringBuilder();
if (!Inst1 && !Inst2) if (!Inst1 && !Inst2)
{ {
@ -277,7 +282,7 @@ namespace eDosStation
public string getCommentUnknown() public string getCommentUnknown()
{ {
StringBuilder res = new StringBuilder(); StringBuilder res = new StringBuilder();
var r = dataInterface.GetCommentOnEventRow(3); var r = dataInterface.GetCommentOnEventRow(3);
res.AppendLine(r.Comment_NL).Replace("\\n", "\n"); res.AppendLine(r.Comment_NL).Replace("\\n", "\n");
res.AppendLine("---"); res.AppendLine("---");
res.AppendLine(r.Comment_FR).Replace("\\n", "\n"); res.AppendLine(r.Comment_FR).Replace("\\n", "\n");
@ -289,18 +294,18 @@ namespace eDosStation
public string getCommentOnEvent(string prefix, int id) public string getCommentOnEvent(string prefix, int id)
{ {
string res=string.Empty; string res = string.Empty;
if (!string.IsNullOrWhiteSpace(prefix)) res = prefix + "\n"; if (!string.IsNullOrWhiteSpace(prefix)) res = prefix + "\n";
var r = dataInterface.GetCommentOnEventRow(id); var r = dataInterface.GetCommentOnEventRow(id);
string l = _User?.Language ?? "E"; string l = _User?.Language ?? "E";
if (r!=null) if (r != null)
switch (l) switch (l)
{ {
case "N": res += r.Comment_NL; break; case "N": res += r.Comment_NL; break;
case "F": res += r.Comment_FR; break; case "F": res += r.Comment_FR; break;
default: res += r.Comment_EN; break; default: res += r.Comment_EN; break;
} }
return res.Replace("\\n","\n"); return res.Replace("\\n", "\n");
} }
/// <summary> /// <summary>
@ -324,9 +329,9 @@ namespace eDosStation
else else
{ {
tbUser.IsSelected = true; tbUser.IsSelected = true;
if (_User == null || _User.VisitIDLocked >0 || _User.AccessAllow == false) if (_User == null || _User.VisitIDLocked > 0 || _User.AccessAllow == false)
{ {
if (_User.VisitIDLocked > 0|| _User.AccessAllow == false) if (_User.VisitIDLocked > 0 || _User.AccessAllow == false)
ReasonNoAccess = _User.ReasonNoAccess; ReasonNoAccess = _User.ReasonNoAccess;
else ReasonNoAccess = getCommentOnEvent(string.Empty, 3); else ReasonNoAccess = getCommentOnEvent(string.Empty, 3);
} }
@ -354,7 +359,7 @@ namespace eDosStation
private void SwitchToTask(object sender, EventArgs e) private void SwitchToTask(object sender, EventArgs e)
{ {
if (--UserSeconds > 0 && (_User.AccessAllow!=true || !string.IsNullOrEmpty(_User.UserComment) || !string.IsNullOrEmpty(_User.ReasonNoAccess))) if (--UserSeconds > 0 && (_User.AccessAllow != true || !string.IsNullOrEmpty(_User.UserComment) || !string.IsNullOrEmpty(_User.ReasonNoAccess)))
{ {
tUserSeconds.Text = UserSeconds.ToString(); tUserSeconds.Text = UserSeconds.ToString();
pUserSeconds.Value = UserSeconds; pUserSeconds.Value = UserSeconds;
@ -384,19 +389,18 @@ namespace eDosStation
} }
public void showBadge(int persID, string csn) public void showBadge(int persID, string csn)
{ {
CSN.Text = csn; CSN.Text = csn;
Site.Text = string.Empty; Site.Text = string.Empty;
Code.Text = persID.ToString(); Code.Text = persID.ToString();
Dispatcher.Invoke(CheckBadge); Dispatcher.Invoke(CheckBadge);
} }
public void endPage() public void endPage()
{ {
dfReader.WaitEnd(); dfReader.WaitEnd();
dfReader.Dispose(); dfReader.Dispose();
this.Close(); this.Close();
} }
private void bClose_Click(object sender, RoutedEventArgs e) private void bClose_Click(object sender, RoutedEventArgs e)
{ {
dfReader?.Dispose(); dfReader = null; dfReader?.Dispose(); dfReader = null;
@ -409,6 +413,8 @@ namespace eDosStation
Code.Text = string.Empty; Code.Text = string.Empty;
} }
private void TaskOK_Click(object sender, RoutedEventArgs e) private void TaskOK_Click(object sender, RoutedEventArgs e)
{ {
bool isOk = false; bool isOk = false;
@ -429,21 +435,26 @@ namespace eDosStation
if (isOk) if (isOk)
{ {
tbEPD.IsSelected = true;
System.Windows.Data.CollectionViewSource getTaskListViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("getTaskListViewSource"))); System.Windows.Data.CollectionViewSource getTaskListViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("getTaskListViewSource")));
var rv = getTaskListViewSource.View.CurrentItem as DataRowView; var rv = getTaskListViewSource.View.CurrentItem as DataRowView;
CurTaskRow = rv.Row as DataSet1.GetTaskInfoRow; CurTaskRow = rv.Row as DataSet1.GetTaskInfoRow;
if (CurTaskRow.MinWorkerDosisMargin > _User.Margin) if (CurTaskRow.MinWorkerDosisMargin > _User.Margin)
{ {
MessageBox.Show("Margin exceeded"); MessageBox.Show("Margin exceeded");
endPage();
} }
else else
{ {
GetEPD(); tb.SelectedItem = tbEPD;
bEpdDone.Visibility = Visibility.Hidden;//1
epdWait.Text = "Waiting max 10 seconds";
Dispatcher.Invoke(new Action(() => { GetEPD(); }),DispatcherPriority.ApplicationIdle);
} }
} }
} }
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
var lb = sender as ListBox; var lb = sender as ListBox;
@ -618,6 +629,17 @@ namespace eDosStation
endPage(); endPage();
} }
private void tb_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count>0 && e.AddedItems[0] is TabControl)
{
}
}
private void DfReader_BadgeTO(LSWDesfirePublic.CCard Sender, EventArgs e) private void DfReader_BadgeTO(LSWDesfirePublic.CCard Sender, EventArgs e)
{ {
this.Dispatcher.Invoke(new Action(() => endPage())); this.Dispatcher.Invoke(new Action(() => endPage()));