epd simul

This commit is contained in:
Luc Vandenbroucke 2021-03-26 17:20:57 +01:00
parent 6adcf2798f
commit f76a13619e
10 changed files with 162 additions and 79 deletions

View file

@ -11,6 +11,7 @@ EpdBase::Epd2U::Epd2U(int comport)
{ {
port = comport; port = comport;
CommsInitialized = 0; CommsInitialized = 0;
if (port == 0) return;
SetAutoCommit(0); SetAutoCommit(0);
Error = 123; Error = 123;
//SetTimeouts(port, 20, 1000, 1000); //SetTimeouts(port, 20, 1000, 1000);
@ -18,6 +19,7 @@ EpdBase::Epd2U::Epd2U(int comport)
DWORD EpdBase::Epd2U::WriteConfig() DWORD EpdBase::Epd2U::WriteConfig()
{ {
if (port == 0) return 1;
return WriteDisplayConfig(00,2,40,10, 2,displayConfig, 56); return WriteDisplayConfig(00,2,40,10, 2,displayConfig, 56);
} }
@ -25,8 +27,11 @@ DWORD EpdBase::Epd2U::StartCom()
{ {
DWORD rv; DWORD rv;
ErrorReason = 0; ErrorReason = 0;
int mx = 10; int mx = 10;
if (port == 0) {
CommsInitialized = 1;
return 1;
}
if (CommsInitialized==0) if (CommsInitialized==0)
do { do {
InitRv = InitComms(port, 9600, 8, 0, 0); InitRv = InitComms(port, 9600, 8, 0, 0);
@ -51,7 +56,7 @@ DWORD EpdBase::Epd2U::StartCom()
EpdBase::Epd2U::~Epd2U() EpdBase::Epd2U::~Epd2U()
{ {
DeinitComms(port); if (port>0) DeinitComms(port);
CommsInitialized = 0; CommsInitialized = 0;
} }
@ -67,9 +72,14 @@ int EpdBase::Epd2U::StartDiscover()
//rv =SetRetryCounts(RxRetryCount, TxRetryCount); //rv =SetRetryCounts(RxRetryCount, TxRetryCount);
if (port == 0) {
DeviceCount = 1;
DeviceIDs[0] = 768;
return 1;
}
FlushDiscoveryCache(port); FlushDiscoveryCache(port);
FlushBuffers(port); FlushBuffers(port);
int tries = 25; DeviceCount = 0; DiscRV = 1; int tries = 25; DeviceCount = 0; DiscRV = 1;
while (tries-- > 0 && DeviceCount == 0 ) while (tries-- > 0 && DeviceCount == 0 )
{ {
@ -88,17 +98,20 @@ int EpdBase::Epd2U::StartDiscover()
void EpdBase::Epd2U::Open(DWORD DeviceID) void EpdBase::Epd2U::Open(DWORD DeviceID)
{ {
CurrentDeviceID = DeviceID; CurrentDeviceID = DeviceID;
ConRV = Connect(DeviceID); if (port > 0) {
if (ConRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData); ConRV = Connect(DeviceID);
else { if (ConRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
OpenRV = OpenDevice(port, CurrentDeviceID); else {
if (OpenRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData); OpenRV = OpenDevice(port, CurrentDeviceID);
if (OpenRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
}
} }
else { OpenRV = ConRV = 1; }
} }
void EpdBase::Epd2U::Close() void EpdBase::Epd2U::Close()
{ {
CloseDevice(); if (port>0) CloseDevice();
//DeinitComms(port); CommsInitialized = 0; //DeinitComms(port); CommsInitialized = 0;
} }
@ -152,6 +165,13 @@ WORD EpdBase::Epd2U::ReadStatus()
ErrorSource = ErrorReason = ErrorData = 0; ErrorSource = ErrorReason = ErrorData = 0;
EpdID = HardVersion = SoftVersion = FunctionFlags = 0; EpdID = HardVersion = SoftVersion = FunctionFlags = 0;
if (port == 0) {
EpdID = 4567;
EpdType = 0;
FunctionFlags = 0x000;
return 1;
}
CommitRV = ReadEpdStatus(&EpdClock, &RealTime, &IssueCount, &OffTime, &OperatingStatus, &ErrorStatus, &AlarmStatus, &OtherAlarms, &EEPROMBadSectors); CommitRV = ReadEpdStatus(&EpdClock, &RealTime, &IssueCount, &OffTime, &OperatingStatus, &ErrorStatus, &AlarmStatus, &OtherAlarms, &EEPROMBadSectors);
if (CommitRV == 1) CommitRV = Commit(); if (CommitRV == 1) CommitRV = Commit();
if (CommitRV == 1) CommitRV = ReadEpdID( if (CommitRV == 1) CommitRV = ReadEpdID(
@ -196,6 +216,8 @@ WORD EpdBase::Epd2U::ReadStatus()
WORD EpdBase::Epd2U::EPDReadExtraStatus() WORD EpdBase::Epd2U::EPDReadExtraStatus()
{ {
if (port == 0) return 1;
byBatADC = bySupplyADC = 0; byBatADC = bySupplyADC = 0;
/*CommitRV = ReadA2ConfigStatus( /*CommitRV = ReadA2ConfigStatus(
&byBatADC, &byBatADC,
@ -215,6 +237,8 @@ WORD EpdBase::Epd2U::EPDReadExtraStatus()
WORD EpdBase::Epd2U::EPDReadConfig() WORD EpdBase::Epd2U::EPDReadConfig()
{ {
if (port == 0) return 1;
ReadConfigRV = ReadConfig( ReadConfigRV = ReadConfig(
&CountDownTime, &CountDownTime,
&ReturnTime, &ReturnTime,
@ -237,6 +261,8 @@ WORD EpdBase::Epd2U::EPDReadConfig()
WORD EpdBase::Epd2U::TurnOff() WORD EpdBase::Epd2U::TurnOff()
{ {
if (port == 0) return 1;
OffRV = EpdOff(); OffRV = EpdOff();
if (OffRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData); if (OffRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
EndSessionRV = EndSession(AlarmCtrl,10); EndSessionRV = EndSession(AlarmCtrl,10);
@ -251,7 +277,7 @@ WORD EpdBase::Epd2U::TurnOff()
WORD EpdBase::Epd2U::TurnOn() WORD EpdBase::Epd2U::TurnOn()
{ {
if (port == 0) return 1;
//OnRV = EpdOn(); //OnRV = EpdOn();
//if (OnRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData); //if (OnRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
@ -270,6 +296,7 @@ WORD EpdBase::Epd2U::TurnOn()
WORD EpdBase::Epd2U::WriteCal() WORD EpdBase::Epd2U::WriteCal()
{ {
if (port == 0) return 1;
if (K6 > 2000) if (K6 > 2000)
{ CommitRV = 0; { CommitRV = 0;
@ -289,8 +316,13 @@ WORD EpdBase::Epd2U::WriteCal()
WORD EpdBase::Epd2U::ReadTresHolds() WORD EpdBase::Epd2U::ReadTresHolds()
{ {
if (port == 0) {
Hp10THDose1 = Hp10THDose2 = Hp10THDose2 = 123;
Hp10Rate1On = Hp10Rate2On = Hp07RateOn = Hp10Rate1Off = Hp10Rate2Off = Hp07RateOff = 124;
return 1;
}
Hp10THDose1 = Hp10THDose2 = Hp07THDose = 0; Hp10THDose1 = Hp10THDose2 = Hp07THDose = 0;
ReadDoseTresholdRV = ReadAlarmDoseThresholds(&Hp10THDose1, &Hp10THDose2, &Hp07THDose); ReadDoseTresholdRV = ReadAlarmDoseThresholds(&Hp10THDose1, &Hp10THDose2, &Hp10THDose2);
CommitRV = Commit(); CommitRV = Commit();
if (CommitRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData); if (CommitRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
ReadAlarmRateThresholdsRV = ReadAlarmRateThresholds( ReadAlarmRateThresholdsRV = ReadAlarmRateThresholds(
@ -318,6 +350,12 @@ WORD EpdBase::Epd2U::ReadTresHolds()
WORD EpdBase::Epd2U::ReadDoses() WORD EpdBase::Epd2U::ReadDoses()
{ {
if (port == 0) {
Hp10Dose = Hp07Dose = Hp10Total = Hp07Total = Knocks = Resets = QualityData = 21;
Hp10Peak = Hp07Peak = Hp10Time = Hp07Time = 1000;
ErrorSource = ErrorReason = ErrorData = 0;
return 1;
}
ReadDosesQualityRV = ReadPeaksRV = CommitRV = 0; ReadDosesQualityRV = ReadPeaksRV = CommitRV = 0;
ReadDosesQualityRV = ReadDosesQuality( ReadDosesQualityRV = ReadDosesQuality(
&Hp10Dose, &Hp10Dose,
@ -333,7 +371,6 @@ WORD EpdBase::Epd2U::ReadDoses()
return 0; return 0;
} }
ReadPeaksRV = ReadPeaks( ReadPeaksRV = ReadPeaks(
&Hp10Peak, &Hp10Peak,
&Hp07Peak, &Hp07Peak,
@ -360,14 +397,13 @@ WORD EpdBase::Epd2U::ReadDoses()
&HG); &HG);
CommitRV = Commit(); CommitRV = Commit();
if (CommitRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData); if (CommitRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
return CommitRV; return CommitRV;
} }
WORD EpdBase::Epd2U::PrepareForIssue() WORD EpdBase::Epd2U::PrepareForIssue()
{ {
if (port == 0) return 1;
CommitRV = WriteConfig(); CommitRV = WriteConfig();
if (CommitRV) CommitRV = Commit(); if (CommitRV) CommitRV = Commit();
if (CommitRV) CommitRV = ClearDose(); if (CommitRV) CommitRV = ClearDose();
@ -379,6 +415,7 @@ WORD EpdBase::Epd2U::PrepareForIssue()
WORD EpdBase::Epd2U::DeIssue() WORD EpdBase::Epd2U::DeIssue()
{ {
ClearDoseRV = ClearTotalDoseRV = ClearPeakRatesRV = DeIssueEpdRV = 0; ClearDoseRV = ClearTotalDoseRV = ClearPeakRatesRV = DeIssueEpdRV = 0;
if (port == 0) return 1;
if (CommitRV) CommitRV = ClearDose(); if (CommitRV) CommitRV = ClearDose();
if (CommitRV) CommitRV = ClearTotalDose(); if (CommitRV) CommitRV = ClearTotalDose();
if (CommitRV) CommitRV = ClearPeakRates(); if (CommitRV) CommitRV = ClearPeakRates();
@ -409,7 +446,7 @@ WORD EpdBase::Epd2U::DeIssue()
WORD EpdBase::Epd2U::Issue() WORD EpdBase::Epd2U::Issue()
{ {
IssueEpdRV = WriteAlarmDoseThresholdsRV = WriteAlarmRateThresholdsRV = WriteWearerNameRV = OnRV = CommitRV = 0; IssueEpdRV = WriteAlarmDoseThresholdsRV = WriteAlarmRateThresholdsRV = WriteWearerNameRV = OnRV = CommitRV = 0;
if (port == 0) return 1;
DWORD OKRV = SetFailFlag(); // all actions have been completed DWORD OKRV = SetFailFlag(); // all actions have been completed
if (OKRV) OKRV = Commit(); if (OKRV) OKRV = Commit();

View file

@ -1,12 +1,11 @@
#include "stdafx.h" #include "stdafx.h"
#include "EpdBaseClr.h" #include "EpdBaseClr.h"
EpdBaseClr::Epd2::Epd2(int port) EpdBaseClr::Epd2::Epd2(int port)
{ {
//HANDLE hMod = LoadLibrary(L"Reader2.dll"); //HANDLE hMod = LoadLibrary(L"Reader2.dll");
epd = new EpdBase::Epd2U(port);
b = gcnew sEpdBase(); b = gcnew sEpdBase();
epd = new EpdBase::Epd2U(port);
this->InitRV = epd->InitRv; this->InitRV = epd->InitRv;
epd->StartCom(); epd->StartCom();
} }
@ -25,17 +24,20 @@ EpdBaseClr::Epd2::!Epd2()
int EpdBaseClr::Epd2::Connect(bool reinit) int EpdBaseClr::Epd2::Connect(bool reinit)
{ {
ConnectError = 0; ConnectError = 0;
if (epd->CommsInitialized==0) epd->StartCom();
b->CurrentDeviceID = 0; b->CurrentDeviceID = 0;
DeviceCount = 0; DeviceCount = 0;
DiscRV = epd->StartDiscover(); DiscRV = 0;
if (DiscRV == 1) if (epd != nullptr) {
{ if (epd->CommsInitialized == 0) epd->StartCom();
DeviceCount = epd->DeviceCount; DiscRV = epd->StartDiscover();
if (epd->DeviceCount >= 0) b->CurrentDeviceID = epd->DeviceIDs[0]; if (DiscRV == 1)
} {
else { DeviceCount = epd->DeviceCount;
ConnectError = epd->Error; if (epd->DeviceCount >= 0) b->CurrentDeviceID = epd->DeviceIDs[0];
}
else {
ConnectError = epd->Error;
}
} }
return DiscRV; return DiscRV;
} }
@ -43,8 +45,7 @@ int EpdBaseClr::Epd2::Connect(bool reinit)
int EpdBaseClr::Epd2::Close() int EpdBaseClr::Epd2::Close()
{ {
b->CurrentDeviceID = 0; b->CurrentDeviceID = 0;
epd->Close(); if (epd!=nullptr) epd->Close();
//delete epd;
return 0; return 0;
} }
@ -85,7 +86,6 @@ int EpdBaseClr::Epd2::DecodeStatus()
return 1; return 1;
} }
int EpdBaseClr::Epd2::GetStatus() int EpdBaseClr::Epd2::GetStatus()
{ {
GetStatusError = 0; StatusRV = 0; Issued = false; GetStatusError = 0; StatusRV = 0; Issued = false;
@ -204,7 +204,6 @@ int EpdBaseClr::Epd2::SetIssued()
int EpdBaseClr::Epd2::WriteCalibration() int EpdBaseClr::Epd2::WriteCalibration()
{ {
epd->K1 = K1; epd->K1 = K1;
epd->K2 = K2; epd->K2 = K2;

View file

@ -68,7 +68,7 @@ namespace RegisterBAdge
UpdPers.Parameters["LastName"].Value = (string)r["LastName"]; UpdPers.Parameters["LastName"].Value = (string)r["LastName"];
UpdPers.Parameters["NickName"].Value = (string)r["NickName"]; UpdPers.Parameters["NickName"].Value = (string)r["NickName"];
UpdPers.Parameters["birthDate"].Value = (DateTime)r["birthDate"]; UpdPers.Parameters["birthDate"].Value = (DateTime)r["birthDate"];
UpdPers.Parameters["conCode"].Value = (string)r["conCode"]; //UpdPers.Parameters["conCode"].Value = (string)r["conCode"];
UpdPers.Parameters["AccessAllow"].Value = (Boolean)r["AccessAllow"]; UpdPers.Parameters["AccessAllow"].Value = (Boolean)r["AccessAllow"];
UpdPers.Parameters["Language"].Value = (string)r["Language"]; UpdPers.Parameters["Language"].Value = (string)r["Language"];
UpdPers.Parameters["VisitIdLocked"].Value = DBNull.Value; UpdPers.Parameters["VisitIdLocked"].Value = DBNull.Value;
@ -168,7 +168,7 @@ namespace RegisterBAdge
UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("LastName", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("LastName", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value));
UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("NickName", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("NickName", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value));
UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("birthDate", System.Data.SqlDbType.Date, 0, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("birthDate", System.Data.SqlDbType.Date, 0, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value));
UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("conCode", System.Data.SqlDbType.VarChar, 4, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); //UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("conCode", System.Data.SqlDbType.VarChar, 4, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value));
UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("AccessAllow", System.Data.SqlDbType.Bit, 0, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("AccessAllow", System.Data.SqlDbType.Bit, 0, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value));
UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("Language", System.Data.SqlDbType.Char, 1, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("Language", System.Data.SqlDbType.Char, 1, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value));
UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("VisitIdLocked", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("VisitIdLocked", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value));

View file

@ -192,20 +192,20 @@
<TextBlock Grid.Row="2" Grid.Column="2" Text="{Binding MinWorkerDosisMargin,StringFormat={}Margin: {0:0.00} }" /> <TextBlock Grid.Row="2" Grid.Column="2" Text="{Binding MinWorkerDosisMargin,StringFormat={}Margin: {0:0.00} }" />
</Grid> </Grid>
<StackPanel Grid.Row="3" Grid.Column="0" Grid.RowSpan="1" VerticalAlignment="Center" > <StackPanel Grid.Row="3" Grid.Column="0" Grid.RowSpan="1" VerticalAlignment="Center" >
<Image Height="120" VerticalAlignment="Center" > <Image Height="120" VerticalAlignment="Center" >
<Image.Style> <Image.Style>
<Style TargetType="{x:Type Image}"> <Style TargetType="{x:Type Image}">
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{Binding EPDRad}" Value="BG"> <DataTrigger Binding="{Binding EPDRad}" Value="BG">
<Setter Property="Source" Value="{StaticResource iBG}"></Setter> <Setter Property="Source" Value="{StaticResource iBG}"></Setter>
</DataTrigger> </DataTrigger>
<DataTrigger Binding="{Binding EPDRad}" Value="NG"> <DataTrigger Binding="{Binding EPDRad}" Value="NG">
<Setter Property="Source" Value="{StaticResource iNG}"></Setter> <Setter Property="Source" Value="{StaticResource iNG}"></Setter>
</DataTrigger> </DataTrigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>
</Image.Style> </Image.Style>
</Image> </Image>
</StackPanel> </StackPanel>
<StackPanel Grid.Row="4" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" > <StackPanel Grid.Row="4" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" >
<telerik:RadButton Name="TaskCancel" Content="Cancel" Click="TaskCancel_Click" Width="300" Height="50" CornerRadius="10" TextBlock.FontSize="25" Margin="20,0,0,0" /> <telerik:RadButton Name="TaskCancel" Content="Cancel" Click="TaskCancel_Click" Width="300" Height="50" CornerRadius="10" TextBlock.FontSize="25" Margin="20,0,0,0" />
@ -220,17 +220,15 @@
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="100" /> <RowDefinition Height="100" />
<RowDefinition Height="100" /> <RowDefinition Height="100" />
<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" VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center" FontSize="25" FontFamily="Comic Sans MS">
<Run Text="Issuing EPD:" /> <Run Text="Issuing EPD:" />
<Run Name="statusEPD" Text="" /> <Run Name="statusEPD" Text="" />
<LineBreak/> <LineBreak/>
</TextBlock> </TextBlock>
<Image Grid.Row="1" Source="{StaticResource iBG}"/> <Image Grid.Row="1" 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="2" 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

@ -1,24 +1,13 @@
using System; using System;
using System.Collections.Generic;
using System.Data; using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading; using System.Windows.Threading;
namespace eDosStation namespace eDosStation
{ {
/// <summary> /// <summary>
/// Interaction logic for EntryBadge.xaml /// Interaction logic for EntryBadge.xaml
/// </summary> /// </summary>
@ -94,7 +83,6 @@ namespace eDosStation
} }
return rv; return rv;
//ep.Hp07THDose =
} }
private void DispatcherTimer_Tick(object sender, EventArgs e) private void DispatcherTimer_Tick(object sender, EventArgs e)
{ {
@ -132,6 +120,7 @@ namespace eDosStation
{ {
bool isBG = (ep.epdType != 3); //3 = zwarte 0=grijs bool isBG = (ep.epdType != 3); //3 = zwarte 0=grijs
var co = LocalRemote.getCon(true); var co = LocalRemote.getCon(true);
LocalRemote.VisitInitCommand.Connection = co;
LocalRemote.VisitInitCommand.Parameters["ID_Station"].Value = thisStation.ID_Station; LocalRemote.VisitInitCommand.Parameters["ID_Station"].Value = thisStation.ID_Station;
LocalRemote.VisitInitCommand.Parameters["ID_Visit"].Value = ID_Visit; LocalRemote.VisitInitCommand.Parameters["ID_Visit"].Value = ID_Visit;
LocalRemote.VisitInitCommand.Parameters["PersID"].Value = _User.PersID; LocalRemote.VisitInitCommand.Parameters["PersID"].Value = _User.PersID;
@ -142,6 +131,8 @@ namespace eDosStation
LocalRemote.VisitInitCommand.ExecuteNonQuery(); LocalRemote.VisitInitCommand.ExecuteNonQuery();
StationVisitID = (int?)LocalRemote.VisitInitCommand.Parameters["EPDVisitID"].Value; StationVisitID = (int?)LocalRemote.VisitInitCommand.Parameters["EPDVisitID"].Value;
co.Close(); co.Close();
int rv = ep.PrepareForIssue(); int rv = ep.PrepareForIssue();
if (rv != 1) if (rv != 1)
{ {
@ -188,6 +179,7 @@ namespace eDosStation
} }
else else
ep.Close(); ep.Close();
} }
private void GetEPD() private void GetEPD()
{ {
@ -210,6 +202,7 @@ namespace eDosStation
dispatcherTimer.Start(); dispatcherTimer.Start();
return; return;
} }
} }
private void SetFilter(bool isAlara) private void SetFilter(bool isAlara)
{ {
@ -418,7 +411,7 @@ namespace eDosStation
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 exeeded"); MessageBox.Show("Margin exceeded");
} }
else else
{ {

View file

@ -118,7 +118,6 @@ namespace eDosStation
{ {
MessageBox.Show($"DeIssueerror {rv}"); MessageBox.Show($"DeIssueerror {rv}");
} }
var l = new SqlLog(); var l = new SqlLog();
try try
{ {
@ -132,6 +131,21 @@ namespace eDosStation
l.Dispose(); l.Dispose();
} }
if (!NoTimeout) dispatcherTimer.Start(); //Knop hide if (!NoTimeout) dispatcherTimer.Start(); //Knop hide
//int? EpdVisitID = LocalRemote.LastID();
//if (EpdVisitID.HasValue)
//{
// ep.WearerName = "Hallo";
// ep.WearerID = EpdVisitID.Value.ToString(); ;
// ep.Hp07 = 123;
// ep.Hp10 = 124;
// Wearer.Text = $"Wearer: {ep.WearerName}";
// EpdVisit.Text = $"Visit: {ep.WearerID}";
// HpDose07.Text = $"Hp07: {ep.Hp07:0.00} µSv ";
// HpDose10.Text = $"Hp10: {ep.Hp10:0.00} µSv";
// LocalRemote.VisitExit(EpdVisitID.Value, ep);
//}
return; return;
} }

View file

@ -11,6 +11,7 @@ namespace eDosStation
{ {
public static class LocalRemote public static class LocalRemote
{ {
static public int ID_Station;
static public bool isLocal = false; static public bool isLocal = false;
static public string serverConstr; static public string serverConstr;
static public string serverTestConstr; static public string serverTestConstr;
@ -21,10 +22,9 @@ namespace eDosStation
static public System.Data.SqlClient.SqlCommand VisitInitCommand; static public System.Data.SqlClient.SqlCommand VisitInitCommand;
public static SqlCommand VisitExitCommand; public static SqlCommand VisitExitCommand;
public static SqlCommand NextIDCommand; public static SqlCommand NextIDCommand;
public static SqlCommand LastLocalIDCommand;
static public DataSet1.CommentOnEventDataTable dtCOE; static public DataSet1.CommentOnEventDataTable dtCOE;
public static int? NextID() public static int? NextID()
{ {
int? nxtValue = null; int? nxtValue = null;
@ -32,6 +32,14 @@ namespace eDosStation
nxtValue = NextIDCommand.ExecuteScalar() as int?; nxtValue = NextIDCommand.ExecuteScalar() as int?;
return nxtValue; return nxtValue;
} }
public static int? LastID()
{
int? lastValue = null;
if (NextIDCommand.Connection.State == ConnectionState.Closed) LastLocalIDCommand.Connection.Open();
lastValue = LastLocalIDCommand.ExecuteScalar() as int?;
return lastValue;
}
static public bool checkCon(bool leaveOpen = false) static public bool checkCon(bool leaveOpen = false)
{ {
if (Connection != null && Connection.State == System.Data.ConnectionState.Open) return true; if (Connection != null && Connection.State == System.Data.ConnectionState.Open) return true;
@ -73,6 +81,13 @@ namespace eDosStation
return rv; return rv;
} }
internal static void SetStation(int curIDStation)
{
ID_Station = curIDStation;
LastLocalIDCommand.Parameters["ID_Station"].Value = curIDStation;
VisitInitCommand.Parameters["ID_Station"].Value = curIDStation;
}
static public void first() static public void first()
{ {
var cb = new System.Data.SqlClient.SqlConnectionStringBuilder(Properties.Settings.Default.eDosConnectionString); var cb = new System.Data.SqlClient.SqlConnectionStringBuilder(Properties.Settings.Default.eDosConnectionString);
@ -94,6 +109,8 @@ namespace eDosStation
localConstr = System.Configuration.ConfigurationManager.ConnectionStrings["eDosStation.Properties.Settings.localConnectionString"].ConnectionString; localConstr = System.Configuration.ConfigurationManager.ConnectionStrings["eDosStation.Properties.Settings.localConnectionString"].ConnectionString;
SequenceConnection = new SqlConnection(localConstr); SequenceConnection = new SqlConnection(localConstr);
NextIDCommand = new SqlCommand("SELECT NEXT VALUE FOR VisitSequence as VisitID", SequenceConnection); NextIDCommand = new SqlCommand("SELECT NEXT VALUE FOR VisitSequence as VisitID", SequenceConnection);
serverConstr = System.Configuration.ConfigurationManager.ConnectionStrings["eDosStation.Properties.Settings.eDosConnectionString"].ConnectionString; serverConstr = System.Configuration.ConfigurationManager.ConnectionStrings["eDosStation.Properties.Settings.eDosConnectionString"].ConnectionString;
var cb = new System.Data.SqlClient.SqlConnectionStringBuilder(serverConstr); var cb = new System.Data.SqlClient.SqlConnectionStringBuilder(serverConstr);
cb.ConnectTimeout = 5; cb.ConnectTimeout = 5;
@ -150,9 +167,13 @@ namespace eDosStation
static void MakeCommands() static void MakeCommands()
{ {
LastLocalIDCommand = new SqlCommand("VisitIDLast", SequenceConnection);
LastLocalIDCommand.CommandType = CommandType.StoredProcedure;
var pa = new System.Data.SqlClient.SqlParameter("ID_Station", SqlDbType.Int, 4); LastLocalIDCommand.Parameters.Add(pa);
VisitInitCommand = new System.Data.SqlClient.SqlCommand("VisitInit", Connection); VisitInitCommand = new System.Data.SqlClient.SqlCommand("VisitInit", Connection);
VisitInitCommand.CommandType = System.Data.CommandType.StoredProcedure; VisitInitCommand.CommandType = System.Data.CommandType.StoredProcedure;
var pa = new System.Data.SqlClient.SqlParameter("ID_Station", SqlDbType.Int, 4); VisitInitCommand.Parameters.Add(pa); pa = new System.Data.SqlClient.SqlParameter("ID_Station", SqlDbType.Int, 4); VisitInitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("ID_Visit", SqlDbType.Int, 4); pa.Direction = ParameterDirection.Input; VisitInitCommand.Parameters.Add(pa); pa = new System.Data.SqlClient.SqlParameter("ID_Visit", SqlDbType.Int, 4); pa.Direction = ParameterDirection.Input; VisitInitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("PersID", SqlDbType.Int, 4); VisitInitCommand.Parameters.Add(pa); pa = new System.Data.SqlClient.SqlParameter("PersID", SqlDbType.Int, 4); VisitInitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("ID_Task", SqlDbType.Int, 4); VisitInitCommand.Parameters.Add(pa); pa = new System.Data.SqlClient.SqlParameter("ID_Task", SqlDbType.Int, 4); VisitInitCommand.Parameters.Add(pa);
@ -292,7 +313,7 @@ namespace eDosStation
u.PersID = (int)Values[rs.GetOrdinal("PersID")]; u.PersID = (int)Values[rs.GetOrdinal("PersID")];
u.LastName = Values[rs.GetOrdinal("LastName")].ToString(); u.LastName = Values[rs.GetOrdinal("LastName")].ToString();
u.FirstName = Values[rs.GetOrdinal("FirstName")].ToString(); u.FirstName = Values[rs.GetOrdinal("FirstName")].ToString();
u.conCode = Values[rs.GetOrdinal("conCode")].ToString(); //u.conCode = Values[rs.GetOrdinal("conCode")].ToString();
u.Language = Values[rs.GetOrdinal("Language")].ToString(); u.Language = Values[rs.GetOrdinal("Language")].ToString();
u.AccessAllow = Values[rs.GetOrdinal("AccessAllow")] as bool?; u.AccessAllow = Values[rs.GetOrdinal("AccessAllow")] as bool?;
u.Margin = Values[rs.GetOrdinal("AccessAllow")] as double?; u.Margin = Values[rs.GetOrdinal("AccessAllow")] as double?;
@ -300,7 +321,7 @@ namespace eDosStation
u.ReasonNoAccess = Values[rs.GetOrdinal("ReasonNoAccess")].ToString().Replace("\\n", "\n"); u.ReasonNoAccess = Values[rs.GetOrdinal("ReasonNoAccess")].ToString().Replace("\\n", "\n");
u.UserComment = Values[rs.GetOrdinal("Comment")].ToString(); u.UserComment = Values[rs.GetOrdinal("Comment")].ToString();
u.AllOk = (u.AccessAllow == true && u.VisitIDLocked == 0); u.AllOk = (u.AccessAllow == true && u.VisitIDLocked == 0);
rs.Close();
} }
else else
{ {
@ -308,7 +329,7 @@ namespace eDosStation
u.PersID = 0; u.PersID = 0;
u.LastName = "Not Found"; u.LastName = "Not Found";
u.FirstName = "Not Found"; u.FirstName = "Not Found";
u.conCode = "A1"; //u.conCode = "A1";
u.Language = "N"; u.Language = "N";
u.AccessAllow = false; u.AccessAllow = false;
u.Margin = 0; u.Margin = 0;
@ -317,6 +338,7 @@ namespace eDosStation
u.UserComment = ""; u.UserComment = "";
u.AllOk = (u.AccessAllow == true & u.VisitIDLocked == 0); u.AllOk = (u.AccessAllow == true & u.VisitIDLocked == 0);
} }
rs.Close();
} }
return u; return u;

View file

@ -15,7 +15,7 @@
</MenuItem> </MenuItem>
</Menu> </Menu>
<StatusBar DockPanel.Dock="Bottom" > <StatusBar DockPanel.Dock="Bottom" >
<StatusBarItem Name="Status" Content="Offline"/> <StatusBarItem Name="Status" Content="Offline" HorizontalContentAlignment="Center" HorizontalAlignment="Stretch"/>
</StatusBar> </StatusBar>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>

View file

@ -54,6 +54,23 @@ namespace eDosStation
s.ShowDialog(); s.ShowDialog();
} }
private void setLocalStatus()
{
if (LocalRemote.isLocal)
{
Status.Content = "*** Offline ***";
Status.Foreground = Brushes.Yellow;
Status.Background = Brushes.Red;
}
else
{
Status.Content = ">>> Online >>>";
Status.Foreground = Brushes.Green;
Status.Background = Brushes.White;
}
}
private void Window_Loaded(object sender, RoutedEventArgs e) private void Window_Loaded(object sender, RoutedEventArgs e)
{ {
var cb = new System.Data.SqlClient.SqlConnectionStringBuilder(Properties.Settings.Default.eDosConnectionString); var cb = new System.Data.SqlClient.SqlConnectionStringBuilder(Properties.Settings.Default.eDosConnectionString);
@ -70,9 +87,11 @@ namespace eDosStation
{ {
bool ok = true; bool ok = true;
LocalRemote.init(); LocalRemote.init();
try try
{ {
thisStation = new Station(string.Empty); thisStation = new Station(string.Empty);
LocalRemote.SetStation(thisStation.ID_Station);
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
@ -85,7 +104,8 @@ namespace eDosStation
ok = false; ok = false;
} }
if (ok) try if (ok)
try
{ {
//var sp = new System.IO.Ports.SerialPort($"com{thisStation.ComPort}"); //var sp = new System.IO.Ports.SerialPort($"com{thisStation.ComPort}");
//sp.BaudRate = 9600; //sp.BaudRate = 9600;
@ -94,10 +114,10 @@ namespace eDosStation
//sp.Open(); //sp.Open();
//sp.DiscardInBuffer(); //sp.DiscardInBuffer();
//sp.Close(); //sp.Close();
#if SimulateEPD
thisStation.ComPort = 0;
#endif
ep = new EpdBaseClr.Epd2(thisStation.ComPort); ep = new EpdBaseClr.Epd2(thisStation.ComPort);
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
@ -111,13 +131,13 @@ namespace eDosStation
InstMessage w = new InstMessage(thisStation.tbComments); InstMessage w = new InstMessage(thisStation.tbComments);
w.ShowDialog(); w.ShowDialog();
ibComment.Child = thisStation.tbComments; ibComment.Child = thisStation.tbComments;
//itComment = thisStation.tbComments;
ibComment.Visibility = Visibility.Visible; ibComment.Visibility = Visibility.Visible;
} }
else else
ibComment.Visibility = Visibility.Hidden; ibComment.Visibility = Visibility.Hidden;
} }
} }
setLocalStatus();
} }
private void MEnc_Click(object sender, RoutedEventArgs e) private void MEnc_Click(object sender, RoutedEventArgs e)

View file

@ -39,7 +39,7 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>TRACE;DEBUG;SimulateEPD</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>