OnlyMK2
This commit is contained in:
parent
90f259527c
commit
9c5be9f801
12 changed files with 135 additions and 61 deletions
|
|
@ -249,20 +249,22 @@ WORD EpdBase::Epd2U::ReadStatus()
|
|||
isNG = ff == 3;
|
||||
VersionOK = (isBG && SoftVersion >= 11) || (isNG && SoftVersion >= 3);
|
||||
|
||||
if (CommitRV == 1 && EPDIssued == 1)
|
||||
{
|
||||
CommitRV = ReadWearer(
|
||||
WearerID,
|
||||
WearerIDLength,
|
||||
WearerName,
|
||||
WearerNameLength);
|
||||
if (CommitRV == 1) CommitRV = Commit();
|
||||
if (CommitRV == 0) {
|
||||
Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
|
||||
rv = ReadStatusRV = ErrorReason;
|
||||
return rv;
|
||||
if (CommitRV == 1) {
|
||||
if (EPDIssued == 1) {
|
||||
CommitRV = ReadWearer(
|
||||
WearerID,
|
||||
WearerIDLength,
|
||||
WearerName,
|
||||
WearerNameLength);
|
||||
if (CommitRV == 1) CommitRV = Commit();
|
||||
if (CommitRV == 0) {
|
||||
Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
|
||||
rv = ReadStatusRV = ErrorReason;
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else //Set waerer=0
|
||||
{
|
||||
rv = 0;
|
||||
for (int i = 0; i < WearerIDLength; i++)
|
||||
if (WearerID[i] == 0xb) WearerID[i] = '0'; else WearerID[i] |= 0x30;
|
||||
|
|
@ -602,7 +604,7 @@ int EpdBase::Epd2U::ConnectAndStatus(int tokenSourceTimeout)
|
|||
dllStatus = StartDiscover(tokenSourceTimeout);
|
||||
if (dllStatus != 1) rv = 1; //Connect error
|
||||
else if (DeviceCount < 1) rv = 2; //TO
|
||||
else if (ReadStatus() != 1) rv = 1; //Read Error
|
||||
else if (ReadStatus() != 0) rv = 1; //Read Error
|
||||
else rv = 0;
|
||||
}
|
||||
return rv;
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@
|
|||
#include "EpdBaseClr.h"
|
||||
#pragma managed
|
||||
|
||||
EpdBaseClr::Epd2::Epd2(int port)
|
||||
EpdBaseClr::Epd2::Epd2(int port, bool OnlyMK2)
|
||||
{
|
||||
//HANDLE hMod = LoadLibrary(L"Reader2.dll");
|
||||
EpdID = 0;
|
||||
isMK3 = EPDIssued = isBG = 0;
|
||||
onlyMK2 = OnlyMK2;
|
||||
epd = new EpdBase::Epd2U(port);
|
||||
epd3 = new Epd3Base::Epd3U(port);
|
||||
if (!OnlyMK2) epd3 = new Epd3Base::Epd3U(port); else epd3 = nullptr;
|
||||
this->InitRV = epd->InitRv;
|
||||
Hp10Name = gcnew String(tHp10);
|
||||
Hp07Name = gcnew String(tHp07);
|
||||
|
|
@ -34,7 +35,7 @@ EpdBaseClr::Epd2::!Epd2()
|
|||
int EpdBaseClr::Epd2::SetFeedbackSound(byte sound, UINT16 sound3)
|
||||
{
|
||||
epd->EndSessionControl = sound;
|
||||
epd3->EndSessionControl = sound3;
|
||||
if (epd3!=nullptr) epd3->EndSessionControl = sound3;
|
||||
return 0;
|
||||
}
|
||||
/// <summary>
|
||||
|
|
@ -70,7 +71,7 @@ int EpdBaseClr::Epd2::Connect(bool reinit, int EPDTimeout)
|
|||
int EpdBaseClr::Epd2::Close()
|
||||
{
|
||||
EpdID= 0;
|
||||
if (epd !=nullptr) epd->EndCom();
|
||||
if (epd != nullptr) epd->EndCom();
|
||||
if (epd3 != nullptr) epd3->EndCom();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -812,7 +813,7 @@ int EpdBaseClr::Epd2::ConnectAndStatus()
|
|||
if (onlyMK2) {
|
||||
DeviceCount = epd->DeviceCount;
|
||||
EpdID = epd->EpdID;
|
||||
epd3->EpdID = epd->EpdID;
|
||||
if (epd3 != nullptr) epd3->EpdID = EpdID;
|
||||
isMK3 = 0;
|
||||
isBG = epd->isBG;
|
||||
isNG = epd->isNG;
|
||||
|
|
@ -829,7 +830,7 @@ int EpdBaseClr::Epd2::ConnectAndStatus()
|
|||
AfterGetStatus(epd3);
|
||||
}
|
||||
else {
|
||||
if (!onlyMK2)rv = SwitchCon();
|
||||
if (!onlyMK2) rv = SwitchCon();
|
||||
AfterGetStatus(epd);
|
||||
}
|
||||
if (isTitleNG != isNG) {
|
||||
|
|
@ -866,9 +867,8 @@ void EpdBaseClr::Epd2::WaitEpd()
|
|||
}
|
||||
return;
|
||||
}
|
||||
System::Threading::Tasks::Task^ EpdBaseClr::Epd2::Wait(int timeout, int Retries, bool _onlyMK2)
|
||||
System::Threading::Tasks::Task^ EpdBaseClr::Epd2::Wait(int timeout, int Retries)
|
||||
{
|
||||
onlyMK2 = _onlyMK2;
|
||||
if (waitTask == nullptr)
|
||||
{
|
||||
tokenSourceTimeout = timeout;
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ namespace EpdBaseClr {
|
|||
bool eDosRate10Alarm = false;
|
||||
bool eDosBatteryWarning= false;
|
||||
|
||||
Epd2(int port);
|
||||
Epd2(int port, bool OnlyMK2);
|
||||
~Epd2();
|
||||
!Epd2();
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ namespace EpdBaseClr {
|
|||
|
||||
public:
|
||||
int SetDeIssued();
|
||||
System::Threading::Tasks::Task^ Wait(int timeout, int Retries, bool onlyMK2);
|
||||
System::Threading::Tasks::Task^ Wait(int timeout, int Retries);
|
||||
void WaitEnd();
|
||||
int GetAll(bool close);
|
||||
int GetAllDeissue();
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ GO
|
|||
|
||||
SET QUOTED_IDENTIFIER ON;
|
||||
GO
|
||||
IF NOT EXISTS (SELECT * FROM sys.columns WHERE object_id=OBJECT_ID('[dbo].[PersonInfoSnapshot]') AND name='isAgent')
|
||||
ALTER TABLE [dbo].[PersonInfoSnapshot] ADD isAgent BIT NULL;
|
||||
GO
|
||||
|
||||
ALTER PROCEDURE [dbo].[GetPersonInfo] @CSN CHAR(14) = NULL,
|
||||
@PersID INT = NULL,
|
||||
|
|
@ -62,14 +65,14 @@ AS BEGIN
|
|||
[a].[ID_CommentToPerson],
|
||||
[a].[Comment],
|
||||
[a].[Deleted],
|
||||
[ReasonNoAccess] = CASE
|
||||
WHEN @AllowMultipleEPD = 1 AND [a].[hasEPD] = 1 THEN 'EPD not returned'
|
||||
WHEN [VisitIDLocked] IS NOT NULL THEN 'Locked because of alarm'
|
||||
ELSE [a].[ReasonNoAccess] END,
|
||||
[ReasonNoAccess] = CASE WHEN @AllowMultipleEPD = 1
|
||||
AND [a].[hasEPD] = 1 THEN 'EPD not returned'
|
||||
WHEN [VisitIDLocked] IS NOT NULL THEN 'Locked because of alarm' ELSE [a].[ReasonNoAccess] END,
|
||||
[a].[Dose_52W_microSv],
|
||||
[a].[hasEPD],
|
||||
[activeStation] = @lid_station,
|
||||
[activeVisit] = @lid_visit
|
||||
[activeVisit] = @lid_visit,
|
||||
[a].[isAgent]
|
||||
FROM(SELECT
|
||||
[p].[PersID],
|
||||
[p].[Type],
|
||||
|
|
@ -88,12 +91,12 @@ AS BEGIN
|
|||
[p].[Deleted],
|
||||
[p].[ReasonNoAccess],
|
||||
[p].[Dose_52W_microSv],
|
||||
[hasEPD] = CONVERT(BIT, CASE WHEN @lid_visit IS NOT NULL THEN 1 ELSE 0 END)
|
||||
[hasEPD] = CONVERT(BIT, CASE WHEN @lid_visit IS NOT NULL THEN 1 ELSE 0 END),
|
||||
[isAgent] = CONVERT(BIT, CASE WHEN [p].[isAgent] IS NULL THEN 0 ELSE [p].[isAgent] END)
|
||||
FROM [dbo].[PersonInfoSnapshot] [p]
|
||||
WHERE [p].[PersID] = @PersID) [a];
|
||||
END;
|
||||
|
||||
|
||||
go
|
||||
|
||||
---- Luc 2022-03-25
|
||||
|
|
|
|||
|
|
@ -390,28 +390,24 @@ namespace eDosStation
|
|||
if (tb.Rows.Count > 0)
|
||||
{
|
||||
DataRow dr = tb.Rows[0];
|
||||
//Values = new object[rs.FieldCount];
|
||||
//int rv = rs.GetValues(Values);
|
||||
u.PersID = (int)dr["PersID"];
|
||||
u.PersID = (int) dr["PersID"];
|
||||
u.LastName = dr["LastName"].ToString();
|
||||
u.FirstName = dr["FirstName"].ToString();
|
||||
//u.conCode = Values[rs.GetOrdinal("conCode")].ToString();
|
||||
u.Language = dr["Language"].ToString();
|
||||
u.AccessAllow = dr["AccessAllow"] as bool?;
|
||||
decimal? m = dr["Margin"] as decimal?;
|
||||
if (m.HasValue) u.Margin = (double)m.Value; else u.Margin = null;
|
||||
//u.Margin = (double ?)Values[rs.GetOrdinal("Margin")] ;
|
||||
u.VisitIDLocked = dr["VisitIDLocked"] as int?;
|
||||
u.AccessAllow = dr.BoolOrFalse("AccessAllow");
|
||||
u.Margin = dr.DoubleOrNull("Margin") ;
|
||||
u.VisitIDLocked = dr.IntOrDefault("VisitIDLocked",0);
|
||||
u.ReasonNoAccess = dr["ReasonNoAccess"].ToString().Replace("\\n", "\n");
|
||||
u.UserComment = dr["Comment"].ToString();
|
||||
|
||||
if (isEntry && !AllowMultipleEPD && tb.Columns.Contains("hasEPD"))
|
||||
{
|
||||
u.hasEPD = (bool)dr["hasEPD"];
|
||||
u.hasEPD = dr.BoolOrFalse("hasEPD");
|
||||
if (u.hasEPD) u.ReasonNoAccess = "You have an EPD in use"; //!!! not for return !!!!
|
||||
}
|
||||
else u.hasEPD = false;
|
||||
u.activeVisit = dr["activeVisit"] as int?;
|
||||
u.activeVisit = dr.IntOrNull("activeVisit");
|
||||
u.isAgent = dr.BoolOrFalse("isAgent");
|
||||
u.AllOk = (!CheckUser || (u.AccessAllow == true && u.VisitIDLocked == 0));
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -546,7 +546,7 @@ namespace eDosStation
|
|||
ResultTime = DateTime.Now.AddMilliseconds(thisStation.EPDTimeOut);
|
||||
dispatcherTimer.Start();
|
||||
pWaitEpd.Value = pWaitEpd.Maximum = thisStation.EPDTimeOut/1000;
|
||||
Dispatcher.InvokeAsync(new Action(() => { ep.Wait(thisStation.EPDTimeOut, 1,thisStation.OnlyMK2); }),DispatcherPriority.Background);
|
||||
Dispatcher.InvokeAsync(new Action(() => { ep.Wait(thisStation.EPDTimeOut, 1); }),DispatcherPriority.Background);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -589,7 +589,7 @@ namespace eDosStation
|
|||
else if (!_User.AllOk)
|
||||
{
|
||||
if (_User.AccessAllow != true) { TaskOK.Content = "No Access"; TaskOK.Tag = "A"; }
|
||||
else if (_User.VisitIDLocked > 0) { TaskOK.Content = "Locked"; TaskOK.Tag = "L"; }
|
||||
else if (_User.VisitIDLocked.HasValue && _User.VisitIDLocked> 0) { TaskOK.Content = "Locked"; TaskOK.Tag = "L"; }
|
||||
else if (exceeded == true) { TaskOK.Content = "No Margin"; TaskOK.Tag = "M"; }
|
||||
dataInterface.stationLog?.WriteLine($"User {_User.PersID} not ok ");
|
||||
thisStation.splunkLog?.WriteSplunkLog(TaskName, LSWLib.CLog.iseverity.warning, TaskOK.Content.ToString());
|
||||
|
|
@ -728,7 +728,7 @@ namespace eDosStation
|
|||
if (ep==null)
|
||||
try
|
||||
{
|
||||
ep = new EpdBaseClr.Epd2(thisStation.ComPort);
|
||||
ep = new EpdBaseClr.Epd2(thisStation.ComPort, thisStation.OnlyMK2);
|
||||
ep.SetFeedbackSound(thisStation.useBeep, thisStation.useBeepMK3());
|
||||
ep.EpdRead += Ep_EpdRead;
|
||||
ep.EpdError += Ep_EpdError;
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ namespace eDosStation
|
|||
if (ep == null)
|
||||
try
|
||||
{
|
||||
ep = new EpdBaseClr.Epd2(thisStation.ComPort);
|
||||
ep = new EpdBaseClr.Epd2(thisStation.ComPort, thisStation.OnlyMK2);
|
||||
ep.SetFeedbackSound(thisStation.useBeep, thisStation.useBeepMK3());
|
||||
ep.EpdRead += Ep_EpdRead;
|
||||
ep.EpdError += Ep_EpdError;
|
||||
|
|
@ -182,7 +182,7 @@ namespace eDosStation
|
|||
ep = null;
|
||||
}
|
||||
if (ep!=null)
|
||||
Dispatcher.InvokeAsync(() => ep.Wait(thisStation.EPDTimeOut, thisStation.EPDRetries, thisStation.OnlyMK2), DispatcherPriority.Background);
|
||||
Dispatcher.InvokeAsync(() => ep.Wait(thisStation.EPDTimeOut, thisStation.EPDRetries ), DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
private void BCloseExit_Click(object sender, RoutedEventArgs e)
|
||||
|
|
|
|||
|
|
@ -46,22 +46,43 @@ namespace eDosStation
|
|||
{
|
||||
string ers = string.Empty;
|
||||
thisStation.splunkLog?.WriteSplunkLog("Entry", LSWLib.CLog.iseverity.info);
|
||||
if (thisStation.RestartCom && (thisStation.RestartComFirst == true))
|
||||
try
|
||||
{
|
||||
ers = devcon.Restart();
|
||||
if (!string.IsNullOrEmpty(ers)) thisStation.splunkLog?.WriteSplunkLog("Restart USB error", LSWLib.CLog.iseverity.err, null, ers); ;
|
||||
if (thisStation.RestartCom && (thisStation.RestartComFirst == true))
|
||||
{
|
||||
ers = devcon.Restart();
|
||||
if (!string.IsNullOrEmpty(ers)) thisStation.splunkLog?.WriteSplunkLog("Restart USB error", LSWLib.CLog.iseverity.err, null, ers); ;
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
thisStation.splunkLog.WriteException(null, "Devcon, rqstart 2", ex);
|
||||
}
|
||||
|
||||
var w = new EntryBadge(thisStation);
|
||||
w.ShowDialog();
|
||||
try
|
||||
{
|
||||
var w = new EntryBadge(thisStation);
|
||||
w.ShowDialog();
|
||||
#if SimulateEPD
|
||||
simulData = w.simulData;
|
||||
#endif
|
||||
w = null;
|
||||
if (thisStation.RestartCom && !(thisStation.RestartComFirst==true))
|
||||
w = null;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
ers = devcon.Restart();
|
||||
if (!string.IsNullOrEmpty(ers)) thisStation.splunkLog?.WriteSplunkLog("Restart USB error", LSWLib.CLog.iseverity.err, null, ers); ;
|
||||
thisStation.splunkLog.WriteException(null, "Start entry", ex);
|
||||
}
|
||||
try
|
||||
{
|
||||
if (thisStation.RestartCom && !(thisStation.RestartComFirst == true))
|
||||
{
|
||||
ers = devcon.Restart();
|
||||
if (!string.IsNullOrEmpty(ers)) thisStation.splunkLog?.WriteSplunkLog("Restart USB error", LSWLib.CLog.iseverity.err, null, ers); ;
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
thisStation.splunkLog.WriteException(null, "Devcon, rqstart 2", ex);
|
||||
}
|
||||
thisStation.splunkLog?.WriteSplunkLog("Entry done", LSWLib.CLog.iseverity.info);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,5 +51,5 @@ using System.Windows;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.6.2.0")]
|
||||
[assembly: AssemblyFileVersion("2.6.2.0")]
|
||||
[assembly: AssemblyVersion("2.7.3.0")]
|
||||
[assembly: AssemblyFileVersion("2.7.3.0")]
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ namespace eDosStation
|
|||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ep = new EpdBaseClr.Epd2(thisStation.ComPort);
|
||||
ep = new EpdBaseClr.Epd2(thisStation.ComPort,thisStation.OnlyMK2);
|
||||
ep.SetFeedbackSound(thisStation.useBeep, thisStation.useBeepMK3());
|
||||
ep.EpdRead += Ep_EpdRead;
|
||||
ep.EpdError += Ep_EpdError;
|
||||
|
|
@ -144,7 +144,7 @@ namespace eDosStation
|
|||
Progress.Maximum = Progress.Value = dispatcherTimer.Interval.TotalSeconds * 10;
|
||||
dispatcherTimer.Tick += CountDown;
|
||||
|
||||
Dispatcher.InvokeAsync(() => ep.Wait(thisStation.EPDTimeOut, 1, thisStation.OnlyMK2),DispatcherPriority.Background);
|
||||
Dispatcher.InvokeAsync(() => ep.Wait(thisStation.EPDTimeOut, 1),DispatcherPriority.Background);
|
||||
ResultTime = DateTime.Now.AddMilliseconds(thisStation.EPDTimeOut);
|
||||
dispatcherTimer.Start();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ namespace eDosStation
|
|||
public int Error = 0;
|
||||
public string ErrorMessage;
|
||||
internal int? activeVisit;
|
||||
internal bool? isAgent;
|
||||
|
||||
public string FullUserName()
|
||||
{
|
||||
|
|
@ -40,7 +41,7 @@ namespace eDosStation
|
|||
|
||||
public bool AllowShowTask()
|
||||
{
|
||||
return AllOk == true && !hasEPD && VisitIDLocked == null;
|
||||
return AllOk == true && !hasEPD && (VisitIDLocked == null || VisitIDLocked==0);
|
||||
}
|
||||
|
||||
public User()
|
||||
|
|
|
|||
|
|
@ -122,5 +122,56 @@ static public class extensions
|
|||
catch { rv = defaultValue; }
|
||||
return rv;
|
||||
}
|
||||
public static int IntOrDefault(this System.Data.DataRow dr, string colName, int iDefault)
|
||||
{
|
||||
int value;
|
||||
int ci = dr.Table.Columns.IndexOf(colName);
|
||||
if (ci >= 0 && dr[ci] is int) value = (int)dr[ci];
|
||||
else value = iDefault;
|
||||
return value;
|
||||
}
|
||||
|
||||
public static int? IntOrNull(this System.Data.DataRow dr, string colName)
|
||||
{
|
||||
int? value;
|
||||
int ci = dr.Table.Columns.IndexOf(colName);
|
||||
if (ci >= 0 && dr[ci] is int?) value = (int ?)dr[ci];
|
||||
else value = null;
|
||||
return value;
|
||||
}
|
||||
public static bool BoolOrFalse(this System.Data.DataRow dr, string colName)
|
||||
{
|
||||
bool value;
|
||||
int ci = dr.Table.Columns.IndexOf(colName);
|
||||
if (ci >= 0)
|
||||
{
|
||||
switch (dr[ci])
|
||||
{
|
||||
case bool b: value = b; break;
|
||||
case int i: value = i != 0; break;
|
||||
default: value = false; break;
|
||||
}
|
||||
}
|
||||
else value = false;
|
||||
return value;
|
||||
}
|
||||
|
||||
public static double? DoubleOrNull(this System.Data.DataRow dr, string colName)
|
||||
{
|
||||
double? value;
|
||||
int ci = dr.Table.Columns.IndexOf(colName);
|
||||
if (ci >= 0)
|
||||
{
|
||||
switch (dr[ci])
|
||||
{
|
||||
case decimal d: value = (double)d; break;
|
||||
case double df: value = df; break;
|
||||
case float ff: value = (double)ff; break;
|
||||
default: value = null; break;
|
||||
}
|
||||
}
|
||||
else value = null;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue