extra options
This commit is contained in:
parent
71c7c1d3bc
commit
dc62df2cea
17 changed files with 257 additions and 122 deletions
|
|
@ -33,11 +33,11 @@ DWORD EpdBase::Epd2U::StartCom()
|
|||
CommsInitialized = 1;
|
||||
return 1;
|
||||
}
|
||||
if (CommsInitialized==0)
|
||||
if (CommsInitialized == 0)
|
||||
do {
|
||||
InitRv = InitComms(port, 9600, 8, 0, 0);
|
||||
if (InitRv == 0) {
|
||||
rv= GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
|
||||
rv = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
|
||||
Sleep(300); //DeinitComms(port);
|
||||
}
|
||||
else {
|
||||
|
|
@ -47,16 +47,15 @@ DWORD EpdBase::Epd2U::StartCom()
|
|||
SetDiscoveryExpirationPeriod(port, DiscoveryExpirationPeriod);
|
||||
}
|
||||
} while (InitRv == 0 && mx > 0);
|
||||
|
||||
if (InitRv == 0) ErrorReason = 1;
|
||||
CommsInitialized = InitRv;
|
||||
isBG = isNG = VersionOK = hasAlarm = false;
|
||||
return ErrorReason;
|
||||
|
||||
if (InitRv == 0) { ErrorReason = 1; CommsInitialized = 0; }
|
||||
else { ErrorReason = 0; CommsInitialized = 1; }
|
||||
isBG = isNG = VersionOK = hasAlarm = false;
|
||||
return ErrorReason;
|
||||
}
|
||||
|
||||
void EpdBase::Epd2U::EndCom()
|
||||
{
|
||||
|
||||
if (port > 0 && CommsInitialized==1) DeinitComms(port);
|
||||
CommsInitialized = 0;
|
||||
}
|
||||
|
|
@ -86,7 +85,7 @@ int EpdBase::Epd2U::StartDiscover( int EpdTimeout)
|
|||
LARGE_INTEGER wt; //100 nanoseconds *10000 = millisec
|
||||
//union { LARGE_INTEGER li; FILETIME ft; LONGLONG ll; } t1, t2;
|
||||
//wt.QuadPart = -300000000LL;
|
||||
wt.QuadPart = Int32x32To64(maxDiscoverTime, -10000); //10 seconden proberen
|
||||
wt.QuadPart = Int32x32To64(maxDiscoverTime, -15000); //15 seconden proberen
|
||||
SetWaitableTimer(hWaitTimer, &wt, 0, NULL, NULL, 0);
|
||||
while (DeviceCount == 0 && wo != 0) //tries-- > 0 &&
|
||||
{
|
||||
|
|
@ -98,7 +97,6 @@ int EpdBase::Epd2U::StartDiscover( int EpdTimeout)
|
|||
wo = WaitForSingleObject(hWaitTimer, 100);
|
||||
if (wo == 0) {ConnectTimerFired = 1; DiscRV = 1; }
|
||||
}
|
||||
//GetSystemTimeAsFileTime(&t2.ft);
|
||||
CancelWaitableTimer(hWaitTimer);
|
||||
}
|
||||
return DiscRV;
|
||||
|
|
@ -113,7 +111,7 @@ int EpdBase::Epd2U::Open(DWORD DeviceID)
|
|||
{
|
||||
int rv = 0;
|
||||
CurrentDeviceID = DeviceID;
|
||||
if (port > 0) {
|
||||
if (port > 0 && CommsInitialized==1) {
|
||||
ConRV = Connect(DeviceID);
|
||||
if (ConRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
|
||||
else {
|
||||
|
|
@ -124,13 +122,12 @@ int EpdBase::Epd2U::Open(DWORD DeviceID)
|
|||
else { OpenRV = ConRV = 1; rv = 0; }
|
||||
return rv;
|
||||
}
|
||||
|
||||
void EpdBase::Epd2U::Close()
|
||||
{
|
||||
if (port > 0) CloseDevice();
|
||||
if (port > 0 && CurrentDeviceID>0) CloseDevice();
|
||||
CurrentDeviceID = 0;
|
||||
FlushBuffers(port);
|
||||
}
|
||||
|
||||
int EpdBase::Epd2U::CloseAndSignal(WORD EndSessionControl, WORD duration)
|
||||
{
|
||||
int rv = 0;
|
||||
|
|
@ -141,8 +138,6 @@ int EpdBase::Epd2U::CloseAndSignal(WORD EndSessionControl, WORD duration)
|
|||
Close();
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
void EpdBase::Epd2U::DecodeFunctionFlags()
|
||||
{
|
||||
EpdType = (FunctionFlags & 0x1F00) >> 8;
|
||||
|
|
|
|||
|
|
@ -116,17 +116,12 @@ DWORD Epd3Base::Epd3U::StartCom()
|
|||
return Dll3RV;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Epd3Base::Epd3U::EndCom()
|
||||
{
|
||||
int rv;
|
||||
if (CommsInitialized == 1) {
|
||||
if (epdComsHandle != INVALID_HANDLE_VALUE) {
|
||||
|
||||
DisCon(0);
|
||||
|
||||
Dll3RV = CloseReader(epdComsHandle);
|
||||
if (Dll3RV) {
|
||||
rv = 1;
|
||||
|
|
@ -205,12 +200,11 @@ int Epd3Base::Epd3U::DisCon(UINT16 alarm)
|
|||
else
|
||||
Dll3RV = Disconnect(epdComsHandle);
|
||||
Dll3RV = WaitForSingleObject(hCompletion, 2000);
|
||||
if (Dll3RV == WAIT_OBJECT_0) rv = 0;
|
||||
else if (Dll3RV == WAIT_TIMEOUT) {
|
||||
rv = 2;
|
||||
switch (Dll3RV) {
|
||||
case WAIT_OBJECT_0: rv = 0; break;
|
||||
case WAIT_TIMEOUT: rv = 2; break;
|
||||
default: rv = 3; break;
|
||||
}
|
||||
else
|
||||
rv = 3;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
@ -284,9 +278,7 @@ void Epd3Base::Epd3U::DecodeStatus()
|
|||
OtherAlarmBatLow = checkStatus(epd3status.AlarmStatus, AlarmStatusFlags::LowBattery);
|
||||
OtherAlarmCarrier = checkStatus(epd3status.AlarmStatus, AlarmStatusFlags::TelemetryAlert);
|
||||
OtherAlarmBatVolt = checkStatus(epd3status.AlarmStatus, AlarmStatusFlags::LowBattery);
|
||||
|
||||
hasAlarm = ((int)epd3status.FaultStatus != 0) || AlarmDoseHP07N || AlarmRateHP07N || AlarmDoseHP101G || AlarmDoseHP102G || AlarmRateHP101G || AlarmRateHP102G;
|
||||
|
||||
}
|
||||
|
||||
void Epd3Base::Epd3U::SetTime() //Only R3
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ EpdBaseClr::Epd2::Epd2(int port)
|
|||
Hp07Name = gcnew String(tHp07);
|
||||
isTitleNG = false;
|
||||
}
|
||||
|
||||
EpdBaseClr::Epd2::~Epd2()
|
||||
{
|
||||
if (epd != nullptr) {
|
||||
|
|
@ -32,7 +31,6 @@ EpdBaseClr::Epd2::~Epd2()
|
|||
EpdBaseClr::Epd2::!Epd2()
|
||||
{
|
||||
}
|
||||
|
||||
int EpdBaseClr::Epd2::SetFeedbackSound(byte sound, UINT16 sound3)
|
||||
{
|
||||
epd->EndSessionControl = sound;
|
||||
|
|
@ -72,10 +70,8 @@ int EpdBaseClr::Epd2::Connect(bool reinit, int EPDTimeout)
|
|||
int EpdBaseClr::Epd2::Close()
|
||||
{
|
||||
EpdID= 0;
|
||||
if (epd !=nullptr)
|
||||
epd->EndCom();
|
||||
if (epd3 != nullptr)
|
||||
epd3->EndCom();
|
||||
if (epd !=nullptr) epd->EndCom();
|
||||
if (epd3 != nullptr) epd3->EndCom();
|
||||
return 0;
|
||||
}
|
||||
int EpdBaseClr::Epd2::DecodeStatus(Epd3Base::Epd3U* epd)
|
||||
|
|
@ -218,7 +214,6 @@ int EpdBaseClr::Epd2::AfterGetStatus()
|
|||
else rv=AfterGetStatus(epd);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
|
@ -246,7 +241,6 @@ int EpdBaseClr::Epd2::GetDoses(EpdBase::Epd2U* epd)
|
|||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
int EpdBaseClr::Epd2::AfterGetDoses(Epd3Base::Epd3U* epd)
|
||||
{
|
||||
int rv = 0;
|
||||
|
|
@ -311,8 +305,6 @@ int EpdBaseClr::Epd2::GetDoses(Epd3Base::Epd3U* epd)
|
|||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
int EpdBaseClr::Epd2::ClearAlarms()
|
||||
{
|
||||
int rv = 0;
|
||||
|
|
@ -320,7 +312,6 @@ int EpdBaseClr::Epd2::ClearAlarms()
|
|||
else rv = epd->ClearAlarms();
|
||||
return rv;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
|
@ -352,8 +343,6 @@ int EpdBaseClr::Epd2::SetIssued()
|
|||
else rv=SetIssued(epd);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
int EpdBaseClr::Epd2::BeforeSetIssued(Epd3Base::Epd3U* epd)
|
||||
{
|
||||
int rv = 0;
|
||||
|
|
@ -398,7 +387,6 @@ int EpdBaseClr::Epd2::SetIssued(Epd3Base::Epd3U* epd)
|
|||
if (rv != 0) SetIssuedError = epd->Error;
|
||||
return rv;
|
||||
}
|
||||
|
||||
int EpdBaseClr::Epd2::BeforeSetIssued(EpdBase::Epd2U* epd)
|
||||
{
|
||||
int rv = 0;
|
||||
|
|
@ -466,7 +454,6 @@ int EpdBaseClr::Epd2::WriteCalibration(EpdBase::Epd2U* epd)
|
|||
return rv;
|
||||
|
||||
}
|
||||
|
||||
int EpdBaseClr::Epd2::WriteCalibration(Epd3Base::Epd3U* epd)
|
||||
{
|
||||
epd->K1 = (float)K1;
|
||||
|
|
@ -500,7 +487,6 @@ int EpdBaseClr::Epd2::ReadTresholds()
|
|||
rv = ReadTresholds(epd);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int EpdBaseClr::Epd2::AfterReadTresholds(EpdBase::Epd2U* epd)
|
||||
{
|
||||
int rv = 0;
|
||||
|
|
@ -544,7 +530,6 @@ int EpdBaseClr::Epd2::ReadTresholds(EpdBase::Epd2U* epd)
|
|||
rv = AfterReadTresholds(epd);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int EpdBaseClr::Epd2::AfterReadTresholds(Epd3Base::Epd3U* epd)
|
||||
{
|
||||
int rv = 0;
|
||||
|
|
@ -747,7 +732,7 @@ int EpdBaseClr::Epd2::SwitchCon()
|
|||
{
|
||||
int rv = 0;
|
||||
if (isMK3) {
|
||||
if (epd3->epdComsHandle == INVALID_HANDLE_VALUE) {
|
||||
if (epd3->epdComsHandle != INVALID_HANDLE_VALUE) {
|
||||
epd->EndCom();
|
||||
Sleep(100);
|
||||
rv=epd3->StartCom();
|
||||
|
|
@ -791,22 +776,35 @@ void EpdBaseClr::Epd2::InitData()
|
|||
int EpdBaseClr::Epd2::ConnectAndStatus()
|
||||
{
|
||||
int rv = 1;
|
||||
epd->EndCom();
|
||||
if (!onlyMK2) epd->EndCom(); //indien Mk2
|
||||
InitData();
|
||||
Sleep(100);
|
||||
rv = epd3->ConnectAndStatus(tokenSourceTimeout);
|
||||
if (onlyMK2)
|
||||
rv = epd->ConnectAndStatus(tokenSourceTimeout);
|
||||
else
|
||||
rv = epd3->ConnectAndStatus(tokenSourceTimeout);
|
||||
if (rv==0) {
|
||||
DeviceCount = epd3->DeviceCount;
|
||||
EpdID = epd3->EpdID;
|
||||
epd->EpdID = epd3->EpdID;
|
||||
isMK3 = epd3->isMK3;
|
||||
isBG = epd3->isBG;
|
||||
isNG = epd3->isNG;
|
||||
if (onlyMK2) {
|
||||
DeviceCount = epd->DeviceCount;
|
||||
EpdID = epd->EpdID;
|
||||
epd->EpdID = epd->EpdID;
|
||||
isMK3 = 0;
|
||||
isBG = epd->isBG;
|
||||
isNG = epd->isNG;
|
||||
}
|
||||
else {
|
||||
DeviceCount = epd3->DeviceCount;
|
||||
EpdID = epd3->EpdID;
|
||||
epd->EpdID = epd3->EpdID;
|
||||
isMK3 = epd3->isMK3;
|
||||
isBG = epd3->isBG;
|
||||
isNG = epd3->isNG;
|
||||
}
|
||||
if (isMK3) {
|
||||
AfterGetStatus(epd3);
|
||||
}
|
||||
else {
|
||||
rv = SwitchCon();
|
||||
if (!onlyMK2)rv = SwitchCon();
|
||||
AfterGetStatus(epd);
|
||||
}
|
||||
if (isTitleNG != isNG) {
|
||||
|
|
@ -823,6 +821,7 @@ int EpdBaseClr::Epd2::ConnectAndStatus()
|
|||
ConnectError = epd->Error;
|
||||
return rv;
|
||||
}
|
||||
|
||||
void EpdBaseClr::Epd2::WaitEpd()
|
||||
{
|
||||
int rv = 0; //start
|
||||
|
|
@ -843,8 +842,9 @@ void EpdBaseClr::Epd2::WaitEpd()
|
|||
}
|
||||
return;
|
||||
}
|
||||
System::Threading::Tasks::Task^ EpdBaseClr::Epd2::Wait(int timeout, int Retries)
|
||||
System::Threading::Tasks::Task^ EpdBaseClr::Epd2::Wait(int timeout, int Retries, bool _onlyMK2)
|
||||
{
|
||||
onlyMK2 = _onlyMK2;
|
||||
if (waitTask == nullptr)
|
||||
{
|
||||
tokenSourceTimeout = timeout;
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ namespace EpdBaseClr {
|
|||
|
||||
|
||||
public:
|
||||
bool onlyMK2;
|
||||
EpdBase::Epd2U *epd;
|
||||
Epd3Base::Epd3U* epd3;
|
||||
|
||||
|
|
@ -290,7 +291,7 @@ namespace EpdBaseClr {
|
|||
|
||||
public:
|
||||
int SetDeIssued();
|
||||
System::Threading::Tasks::Task^ Wait(int timeout, int Retries);
|
||||
System::Threading::Tasks::Task^ Wait(int timeout, int Retries, bool onlyMK2);
|
||||
void WaitEnd();
|
||||
int GetAll(bool close);
|
||||
int GetAllDeissue();
|
||||
|
|
@ -302,7 +303,10 @@ namespace EpdBaseClr {
|
|||
int AfterGetStatus();
|
||||
int SwitchCon();
|
||||
void InitData();
|
||||
|
||||
void WaitEpd();
|
||||
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@
|
|||
<ClInclude Include="EpdBaseClr.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="VariableCapture.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AssemblyInfo.cpp" />
|
||||
|
|
@ -151,6 +152,7 @@
|
|||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="VariableCapture.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="app.rc" />
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@
|
|||
<ClInclude Include="Resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="VariableCapture.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="EpdBaseClr.cpp">
|
||||
|
|
@ -35,6 +38,9 @@
|
|||
<ClCompile Include="stdafx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="VariableCapture.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="app.rc">
|
||||
|
|
|
|||
0
EpdBaseClr/Helper.h
Normal file
0
EpdBaseClr/Helper.h
Normal file
65
EpdBaseClr/VariableCapture.cpp
Normal file
65
EpdBaseClr/VariableCapture.cpp
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#include "stdafx.h"
|
||||
#include "VariableCapture.h"
|
||||
|
||||
|
||||
generic<typename T1>
|
||||
public ref class VariableCapture
|
||||
{
|
||||
private:
|
||||
Action<T1>^ delegateWithParams;
|
||||
T1 item1;
|
||||
|
||||
VariableCapture(Action<T1>^ delegateWithParams, T1 item1)
|
||||
{
|
||||
this->delegateWithParams = delegateWithParams;
|
||||
this->item1 = item1;
|
||||
|
||||
}
|
||||
void RunDelegate()
|
||||
{
|
||||
this->delegateWithParams(item1);
|
||||
}
|
||||
|
||||
public:
|
||||
static Action^ Capture(Action<T1>^ delegateWithParams, T1 item1)
|
||||
{
|
||||
VariableCapture<T1>^ capture = gcnew VariableCapture<T1>(delegateWithParams, item1);
|
||||
return gcnew Action(capture, &VariableCapture<T1>::RunDelegate);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
generic<typename T1,typename T2>
|
||||
public ref class VariableCapture2
|
||||
{
|
||||
private:
|
||||
Action<T1,T2>^ delegateWithParams;
|
||||
T1 item1;
|
||||
T2 item2;
|
||||
|
||||
VariableCapture2(Action<T1,T2>^ delegateWithParams, T1 item1, T2 item2)
|
||||
{
|
||||
this->delegateWithParams = delegateWithParams;
|
||||
this->item1 = item1;
|
||||
this->item2 = item2;
|
||||
|
||||
}
|
||||
void RunDelegate()
|
||||
{
|
||||
this->delegateWithParams(item1,item2);
|
||||
}
|
||||
|
||||
public:
|
||||
static Action^ Capture(Action<T1,T2>^ delegateWithParams, T1 item1, T2 item2)
|
||||
{
|
||||
VariableCapture2<T1,T2>^ capture = gcnew VariableCapture2<T1,T2>(delegateWithParams, item1,item2);
|
||||
return gcnew Action(capture, &VariableCapture2<T1,T2>::RunDelegate);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*Usage
|
||||
Action^ delegateWithoutParams = VariableCapture<int, String^>::Capture(delegateWithParams, 7, "foo");
|
||||
*/
|
||||
5
EpdBaseClr/VariableCapture.h
Normal file
5
EpdBaseClr/VariableCapture.h
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#pragma once
|
||||
using namespace System;
|
||||
|
||||
//generic<typename T1, typename T2> ref class VariableCapture;
|
||||
//generic<typename T1, typename T2> ref class VariableCapture2;
|
||||
|
|
@ -37,7 +37,6 @@ namespace eDosStation
|
|||
{
|
||||
InitializeComponent();
|
||||
dataInterface = curStation.dataInterface;
|
||||
|
||||
thisStation = curStation;
|
||||
_User = null;
|
||||
taskLoading = false;
|
||||
|
|
@ -487,7 +486,6 @@ namespace eDosStation
|
|||
}
|
||||
public void endPage()
|
||||
{
|
||||
|
||||
dispatcherTimer?.Stop();
|
||||
dispatcherTimer = null;
|
||||
this.Close();
|
||||
|
|
@ -504,7 +502,6 @@ namespace eDosStation
|
|||
}
|
||||
private void TaskOK_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
bool isOk = false;
|
||||
switch (TaskOK.Tag)
|
||||
{
|
||||
|
|
@ -545,7 +542,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); }),DispatcherPriority.Background);
|
||||
Dispatcher.InvokeAsync(new Action(() => { ep.Wait(thisStation.EPDTimeOut, 1,thisStation.OnlyMK2); }),DispatcherPriority.Background);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,13 +21,13 @@ namespace eDosStation
|
|||
public EpdExit(Station curStation)
|
||||
{
|
||||
InitializeComponent();
|
||||
//ep = curEP;
|
||||
ep = new EpdBaseClr.Epd2(curStation.ComPort);
|
||||
ep.SetFeedbackSound(curStation.useBeep,curStation.useBeepMK3());
|
||||
|
||||
//ep = new EpdBaseClr.Epd2(curStation.ComPort);
|
||||
//ep.SetFeedbackSound(curStation.useBeep,curStation.useBeepMK3());
|
||||
//ep.EpdRead += Ep_EpdRead;
|
||||
//ep.EpdError += Ep_EpdError;
|
||||
//ep.EpdTO += Ep_EpdTO;
|
||||
|
||||
ep.EpdRead += Ep_EpdRead;
|
||||
ep.EpdError += Ep_EpdError;
|
||||
ep.EpdTO += Ep_EpdTO;
|
||||
thisStation = curStation;
|
||||
dataInterface = curStation.dataInterface;
|
||||
|
||||
|
|
@ -160,7 +160,25 @@ namespace eDosStation
|
|||
Wait.IsSelected = true;
|
||||
dispatcherTimer.Start();
|
||||
ResultTime = DateTime.Now.AddMilliseconds(thisStation.EPDTimeOut);
|
||||
Dispatcher.InvokeAsync(() => ep.Wait(thisStation.EPDTimeOut, thisStation.EPDRetries), DispatcherPriority.Background);
|
||||
|
||||
//StartEPD
|
||||
if (ep == null)
|
||||
try
|
||||
{
|
||||
ep = new EpdBaseClr.Epd2(thisStation.ComPort);
|
||||
ep.SetFeedbackSound(thisStation.useBeep, thisStation.useBeepMK3());
|
||||
ep.EpdRead += Ep_EpdRead;
|
||||
ep.EpdError += Ep_EpdError;
|
||||
ep.EpdTO += Ep_EpdTO;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
thisStation.splunkLog.WriteException(null, "StartEpd", ex);
|
||||
MessageBox.Show($"{ex.Message}");
|
||||
ep = null;
|
||||
}
|
||||
|
||||
Dispatcher.InvokeAsync(() => ep.Wait(thisStation.EPDTimeOut, thisStation.EPDRetries, thisStation.OnlyMK2), DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
private void BCloseExit_Click(object sender, RoutedEventArgs e)
|
||||
|
|
@ -182,7 +200,10 @@ namespace eDosStation
|
|||
dispatcherTimer = null;
|
||||
if (ep != null) { ep.WaitEnd(); ep.Dispose(); ep = null; }
|
||||
}
|
||||
catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); }
|
||||
catch (System.Exception ex) {
|
||||
thisStation.splunkLog.WriteException("EpdExit", "Closing", ex);
|
||||
System.Diagnostics.Debug.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void endWithMessage(string message)
|
||||
|
|
|
|||
|
|
@ -22,17 +22,35 @@ namespace eDosStation
|
|||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string ers = string.Empty;
|
||||
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); ;
|
||||
}
|
||||
|
||||
var w = new ShowEPDDose(thisStation);
|
||||
w.ShowDialog();
|
||||
}
|
||||
|
||||
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); ;
|
||||
}
|
||||
|
||||
thisStation.splunkLog?.WriteSplunkLog("Show Dose done", LSWLib.CLog.iseverity.info);
|
||||
}
|
||||
private void BEntry_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string ers = string.Empty;
|
||||
thisStation.splunkLog?.WriteSplunkLog("Entry", LSWLib.CLog.iseverity.info);
|
||||
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); ;
|
||||
}
|
||||
|
||||
var w = new EntryBadge(thisStation);
|
||||
w.ShowDialog();
|
||||
|
|
@ -40,38 +58,41 @@ namespace eDosStation
|
|||
simulData = w.simulData;
|
||||
#endif
|
||||
w = null;
|
||||
if (thisStation.RestartCom)
|
||||
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); ;
|
||||
}
|
||||
thisStation.splunkLog?.WriteSplunkLog("Entry done", LSWLib.CLog.iseverity.info);
|
||||
}
|
||||
|
||||
private void BExit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string ers = string.Empty;
|
||||
thisStation.splunkLog?.WriteSplunkLog("Exit", LSWLib.CLog.iseverity.info);
|
||||
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); ;
|
||||
}
|
||||
|
||||
var w = new EpdExit(thisStation);
|
||||
#if SimulateEPD
|
||||
w.simulData = simulData;
|
||||
#endif
|
||||
w.ShowDialog();
|
||||
w = null;
|
||||
if (thisStation.RestartCom)
|
||||
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); ;
|
||||
}
|
||||
thisStation.splunkLog?.WriteSplunkLog("Exit Done", LSWLib.CLog.iseverity.info);
|
||||
}
|
||||
|
||||
private void MenuItem_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Settings s = new Settings(thisStation);
|
||||
s.ShowDialog();
|
||||
}
|
||||
|
||||
private void setLocalStatus()
|
||||
{
|
||||
if (!dataInterface.isOnline())
|
||||
|
|
@ -87,7 +108,6 @@ namespace eDosStation
|
|||
Offline = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void setErrorStatus(string errMsg)
|
||||
{
|
||||
thisStation.splunkLog?.WriteSplunkLog("Errorstatus", LSWLib.CLog.iseverity.err, null, errMsg);
|
||||
|
|
@ -95,7 +115,6 @@ namespace eDosStation
|
|||
Status.Foreground = Brushes.Yellow;
|
||||
Status.Background = Brushes.Red;
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
bool ok = true;
|
||||
|
|
@ -168,35 +187,29 @@ namespace eDosStation
|
|||
BgTimer_Tick(null, null);
|
||||
bgTimer.Start();
|
||||
}
|
||||
|
||||
private void BgTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
setLocalStatus();
|
||||
tbTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
|
||||
}
|
||||
|
||||
private void MEnc_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//string cfg = System.IO.Path.Combine(Environment.CurrentDirectory, System.AppDomain.CurrentDomain.FriendlyName );
|
||||
//Config.ToggleConfigEncryption(cfg);
|
||||
}
|
||||
|
||||
private void Window_GotFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
bgTimer.Start();
|
||||
}
|
||||
|
||||
private void Window_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
bgTimer.Stop();
|
||||
}
|
||||
|
||||
private void mAbout_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
About x = new About(thisStation);
|
||||
x.ShowDialog();
|
||||
}
|
||||
|
||||
private void mExit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
bgTimer?.Stop();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
xmlns:local="clr-namespace:eDosStation"
|
||||
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
|
||||
mc:Ignorable="d"
|
||||
Title="Settings" Height="338.281" Width="617.009"
|
||||
Title="Settings" Height="464.627" Width="617.009"
|
||||
FontFamily="Segoe UI" FontSize="20"
|
||||
Loaded="Window_Loaded">
|
||||
<Grid >
|
||||
|
|
@ -21,11 +21,13 @@
|
|||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="20" />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition Width="250"/>
|
||||
<ColumnDefinition Width="400"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="EPD Reader Com port"></TextBlock>
|
||||
|
|
@ -57,7 +59,14 @@
|
|||
<TextBlock Grid.Row="9" Grid.Column="0" Text="Restart COM" Height="23" Margin="0,0,0.2,0" VerticalAlignment="Top"></TextBlock>
|
||||
<CheckBox Grid.Row="9" Grid.ColumnSpan="2" Name="cbRestartCom" Grid.Column="1" Padding="10,0,10,0" VerticalAlignment="Center" />
|
||||
|
||||
<telerik:RadButton Grid.Row="11" Grid.Column="0" Name="bOK" Content="OK" Click="BOK_Click" Style="{DynamicResource OkCancelButton}" />
|
||||
<telerik:RadButton Grid.Row="11" Grid.Column="1" Name="bCancel" Content="Cancel" Click="BCancel_Click" Style="{DynamicResource OkCancelButton}" HorizontalAlignment="Right" />
|
||||
<TextBlock Grid.Row="10" Grid.Column="0" Text="Restart COM voor entry/exit" Height="23" Margin="0,0,0.2,0" VerticalAlignment="Top"></TextBlock>
|
||||
<CheckBox Grid.Row="10" Grid.ColumnSpan="2" Name="cbRestartComFirst" Grid.Column="1" Padding="10,0,10,0" VerticalAlignment="Center" />
|
||||
|
||||
<TextBlock Grid.Row="11" Grid.Column="0" Text="Alleen MK2" Height="23" Margin="0,0,0.2,0" VerticalAlignment="Top"></TextBlock>
|
||||
<CheckBox Grid.Row="11" Grid.ColumnSpan="2" Name="cbOnlyMK2" Grid.Column="1" Padding="10,0,10,0" VerticalAlignment="Center" />
|
||||
|
||||
|
||||
<telerik:RadButton Grid.Row="13" Grid.Column="0" Name="bOK" Content="OK" Click="BOK_Click" Style="{DynamicResource OkCancelButton}" />
|
||||
<telerik:RadButton Grid.Row="13" Grid.Column="1" Name="bCancel" Content="Cancel" Click="BCancel_Click" Style="{DynamicResource OkCancelButton}" HorizontalAlignment="Right" />
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
|
|||
|
|
@ -62,6 +62,11 @@ namespace eDosStation
|
|||
thisStation.checkUser = cbCheckUsers.IsChecked != null ? cbCheckUsers.IsChecked.Value : false;
|
||||
thisStation.RestartCom = cbRestartCom.IsChecked != null ? cbRestartCom.IsChecked.Value : false;
|
||||
thisStation.EPDTimeOut = int.Parse(tEPDTimeout.Text);
|
||||
|
||||
thisStation.OnlyMK2 = cbOnlyMK2.IsChecked != null ? cbOnlyMK2.IsChecked.Value : false;
|
||||
thisStation.RestartComFirst = cbRestartComFirst.IsChecked != null ? cbRestartComFirst.IsChecked.Value : false;
|
||||
|
||||
|
||||
thisStation.Update();
|
||||
this.Close();
|
||||
if (thisStation.Error > 0)
|
||||
|
|
@ -169,7 +174,6 @@ namespace eDosStation
|
|||
MessageBox.Show($"SerINstallations err {ex.Message}");
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
tBeep.SelectedValue = thisStation.useBeep;
|
||||
|
|
@ -177,6 +181,8 @@ namespace eDosStation
|
|||
cbCheckUsers.IsChecked= thisStation.checkUser;
|
||||
cbRestartCom.IsChecked = thisStation.RestartCom;
|
||||
tEPDTimeout.Text = thisStation.EPDTimeOut.ToString();
|
||||
cbRestartComFirst.IsChecked = thisStation.RestartComFirst;
|
||||
cbOnlyMK2.IsChecked = thisStation.OnlyMK2;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,10 +8,9 @@
|
|||
mc:Ignorable="d"
|
||||
Title="ShowEPDDose" Height="548.4" Width="858.8"
|
||||
Loaded="Window_Loaded"
|
||||
Unloaded="Window_Unloaded"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
FontFamily="Segoe UI"
|
||||
WindowStyle="None">
|
||||
WindowStyle="None" Closing="Window_Closing">
|
||||
<DockPanel>
|
||||
<StatusBar DockPanel.Dock="Bottom" >
|
||||
<StatusBarItem Name="statusEPD" Content="Epd" />
|
||||
|
|
|
|||
|
|
@ -19,19 +19,7 @@ namespace eDosStation
|
|||
public ShowEPDDose(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;
|
||||
|
||||
dispatcherTimer = new DispatcherTimer(DispatcherPriority.Normal);
|
||||
dispatcherTimer.Interval = TimeSpan.FromMilliseconds(thisStation.EPDTimeOut / 10);
|
||||
Progress.Maximum = Progress.Value = dispatcherTimer.Interval.TotalSeconds * 10;
|
||||
dispatcherTimer.Tick += CountDown;
|
||||
|
||||
}
|
||||
|
||||
private void CountDown(object sender, EventArgs e)
|
||||
|
|
@ -77,8 +65,6 @@ namespace eDosStation
|
|||
|
||||
if (rv != 0) MessageBox.Show("Communication error");
|
||||
|
||||
|
||||
|
||||
isIssued.Text = ep.EPDIssued ? "Yes" : "no";
|
||||
string sPersID = ep.WearerName.Trim();
|
||||
Wearer.Text = sPersID;
|
||||
|
|
@ -137,44 +123,54 @@ namespace eDosStation
|
|||
}
|
||||
else
|
||||
epdUserMargin.Text = "--";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Dispatcher.InvokeAsync(() => ep.Wait(thisStation.EPDTimeOut, 1),DispatcherPriority.Background);
|
||||
ep = new EpdBaseClr.Epd2(thisStation.ComPort);
|
||||
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.Tick += CountDown;
|
||||
|
||||
Dispatcher.InvokeAsync(() => ep.Wait(thisStation.EPDTimeOut, 1, thisStation.OnlyMK2),DispatcherPriority.Background);
|
||||
ResultTime = DateTime.Now.AddMilliseconds(thisStation.EPDTimeOut);
|
||||
dispatcherTimer.Start();
|
||||
}
|
||||
|
||||
private void endPage()
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
|
||||
private void RadButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
endPage();
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
dispatcherTimer?.Stop();
|
||||
dispatcherTimer = null;
|
||||
try
|
||||
{
|
||||
if (ep != null)
|
||||
{
|
||||
ep.WaitEnd();
|
||||
ep.Dispose();
|
||||
ep = null;
|
||||
}
|
||||
} catch (System.Exception ex)
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine(ex.Message);
|
||||
}
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void Window_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
endPage();
|
||||
}
|
||||
|
||||
private void RadButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
endPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ namespace eDosStation
|
|||
public bool RestartCom { get; set; }
|
||||
public int EPDTimeOut { get; internal set; }
|
||||
public int EPDRetries { get; internal set; }
|
||||
public bool OnlyMK2 { get; internal set; }
|
||||
public bool RestartComFirst { get; internal set; }
|
||||
|
||||
public bool Changed = false;
|
||||
public int Error = 0;
|
||||
public string ErrorMessage;
|
||||
|
|
@ -149,6 +152,22 @@ namespace eDosStation
|
|||
if (rs.IsDBNull(c)) RestartCom= false; else RestartCom = (bool)Values[c];
|
||||
}
|
||||
catch { EPDRetries = 2; }
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
c = rs.GetOrdinal("RestartComFirst");
|
||||
if (rs.IsDBNull(c)) RestartComFirst = false; else RestartComFirst = (bool)Values[c];
|
||||
}
|
||||
catch { RestartComFirst = false; }
|
||||
|
||||
try
|
||||
{
|
||||
c = rs.GetOrdinal("OnlyMK2");
|
||||
if (rs.IsDBNull(c)) OnlyMK2 = false; else OnlyMK2= (bool)Values[c];
|
||||
}
|
||||
catch { OnlyMK2 = false; }
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -208,6 +227,7 @@ namespace eDosStation
|
|||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
splunkLog.WriteException("Station", "GetInstallationsComments", ex);
|
||||
Error = 2;
|
||||
ErrorMessage = ex.Message;
|
||||
if (stationLog != null) stationLog.WriteLine($"GetStationComments error {ex.Message} {System.DateTime.Now}");
|
||||
|
|
@ -245,9 +265,12 @@ namespace eDosStation
|
|||
cmd.SetIfExists("EPDTimeout", EPDTimeOut);
|
||||
cmd.SetIfExists("EPDRetries", EPDRetries);
|
||||
cmd.SetIfExists("RestartCom", RestartCom);
|
||||
cmd.SetIfExists("RestartComFirst", RestartComFirst);
|
||||
cmd.SetIfExists("OnlyMK2", OnlyMK2);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
splunkLog.WriteException("Station", "SetParams", ex);
|
||||
Error = 1;
|
||||
ErrorMessage = ex.Message;
|
||||
if (stationLog != null) stationLog.WriteLine($"GetStationSettings error {ex.Message} {System.DateTime.Now}");
|
||||
|
|
@ -265,6 +288,7 @@ namespace eDosStation
|
|||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (System.Exception ex) {
|
||||
splunkLog.WriteException("Station", "UpdateToDb", ex);
|
||||
if (stationLog != null) stationLog.WriteLine($"UpdateToDb error {ex.Message} co {co.DataSource} {System.DateTime.Now}");
|
||||
}
|
||||
}
|
||||
|
|
@ -286,6 +310,7 @@ namespace eDosStation
|
|||
{
|
||||
Error = 1;
|
||||
ErrorMessage = ex.Message;
|
||||
splunkLog.WriteException("Station", "Update", ex);
|
||||
if (stationLog != null) stationLog.WriteLine($"UpdateToDb error {ex.Message} co {co.DataSource} {System.DateTime.Now}");
|
||||
}
|
||||
co?.Close();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue