reconnect, step in error

This commit is contained in:
Luc Vandenbroucke 2024-05-22 13:31:10 +02:00
parent 0e64bb9068
commit 09aaefe69c
32 changed files with 890 additions and 475 deletions

View file

@ -213,7 +213,7 @@ WORD EpdBase::Epd2U::ReadStatus()
IssueCount = OperatingStatus = ErrorStatus = AlarmStatus = OtherAlarms = EEPROMBadSectors = 0; IssueCount = OperatingStatus = ErrorStatus = AlarmStatus = OtherAlarms = EEPROMBadSectors = 0;
RealTime = EpdClock = OffTime = EpdID = 0; RealTime = EpdClock = OffTime = EpdID = 0;
ErrorSource = ErrorReason = ErrorData = 0; ErrorSource = ErrorReason = ErrorData = 0;
HardVersion = SoftVersion = FunctionFlags = 0; HardVersion = HardVersionMinor= SoftVersion = FunctionFlags = 0;
if (port == 0) { if (port == 0) {
EpdID = 4567; EpdID = 4567;

View file

@ -79,7 +79,7 @@ namespace EpdBase
//Identification //Identification
DWORD EpdID=0; DWORD EpdID=0;
WORD HardVersion; WORD HardVersion, HardVersionMinor;
WORD SoftVersion; WORD SoftVersion;
WORD FunctionFlags; WORD FunctionFlags;

View file

@ -64,7 +64,7 @@ Epd3Base::Epd3U::Epd3U(int _comport)
IssueCount = OtherAlarms = EEPROMBadSectors = 0; IssueCount = OtherAlarms = EEPROMBadSectors = 0;
RealTime = EpdClock = OffTime = EpdID = 0; RealTime = EpdClock = OffTime = EpdID = 0;
ErrorSource = ErrorReason = ErrorData = 0; ErrorSource = ErrorReason = ErrorData = 0;
HardVersion = SoftVersion = FunctionFlags = 0; HardVersion = HardVersionMinor= SoftVersion = FunctionFlags = 0;
K1 = K2 = K3 = K4 = K4 = K6 = 0.0F; K1 = K2 = K3 = K4 = K4 = K6 = 0.0F;
HG = SG = BC = FB = 0; HG = SG = BC = FB = 0;
@ -183,7 +183,7 @@ int Epd3Base::Epd3U::OpenDev(DiscoveryId DeviceID)
{ {
Dll3RV = Connect3(epdComsHandle, DeviceID, true); Dll3RV = Connect3(epdComsHandle, DeviceID, true);
} }
else { Dll3RV = 0; } else { Dll3RV = r_InvalidCommsHandle; }
return Dll3RV; return Dll3RV;
} }
@ -193,7 +193,7 @@ int Epd3Base::Epd3U::ReOpenDev()
{ {
Dll3RV = Connect3(epdComsHandle, Epd, true); Dll3RV = Connect3(epdComsHandle, Epd, true);
} }
else { Dll3RV = 0; } else { Dll3RV = r_InvalidCommsHandle; } //no handle ..
return Dll3RV; return Dll3RV;
} }
@ -327,11 +327,12 @@ void Epd3Base::Epd3U::SetTime() //Only R3
int Epd3Base::Epd3U::ReadStatus() int Epd3Base::Epd3U::ReadStatus()
{ {
int r; //0=ok int r; //0=ok
int step = 0;
uint8_t length = 0; uint8_t length = 0;
countsRead = 0; utc = 0; seconds = 0; countsRead = 0; utc = 0; seconds = 0;
memset(WearerID, 0, WearerIDLength + 1); memset(WearerID, 0, WearerIDLength + 1);
memset(WearerName, 0, WearerNameLength + 1); memset(WearerName, 0, WearerNameLength + 1);
r = SetResponseTimeout(epdComsHandle, 2000);
Error = 0; Error = 0;
if (port == 0) { if (port == 0) {
EpdID = 4567; EpdID = 4567;
@ -352,10 +353,10 @@ int Epd3Base::Epd3U::ReadStatus()
IssueCount = OtherAlarms = EEPROMBadSectors = 0; IssueCount = OtherAlarms = EEPROMBadSectors = 0;
RealTime = EpdClock = OffTime = EpdID = 0; RealTime = EpdClock = OffTime = EpdID = 0;
ErrorSource = ErrorReason = ErrorData = 0; ErrorSource = ErrorReason = ErrorData = 0;
HardVersion = SoftVersion = FunctionFlags = 0; HardVersion = HardVersionMinor = SoftVersion = FunctionFlags = 0;
r = SetResponseTimeout(epdComsHandle, 2000); ReOpenDev();
step = 1;
token = BeginReadStatus(epdComsHandle, nullptr); token = BeginReadStatus(epdComsHandle, nullptr);
r = Commit3(epdComsHandle); r = Commit3(epdComsHandle);
r = EndReadStatus(epdComsHandle, token, &epd3status); r = EndReadStatus(epdComsHandle, token, &epd3status);
@ -375,6 +376,7 @@ int Epd3Base::Epd3U::ReadStatus()
MarkNumber_t MarkNumber; MarkNumber_t MarkNumber;
VersionNumber_t VersionNumber; VersionNumber_t VersionNumber;
step = 2;
token = BeginReadEpdIdentities(epdComsHandle, nullptr); token = BeginReadEpdIdentities(epdComsHandle, nullptr);
r = Commit3(epdComsHandle); r = Commit3(epdComsHandle);
r = EndReadEpdIdentities(epdComsHandle, token, &EpdID32, (EpdTypes*)&EpdType, &capabilities, &MarkNumber, &VersionNumber, NULL, 0); r = EndReadEpdIdentities(epdComsHandle, token, &EpdID32, (EpdTypes*)&EpdType, &capabilities, &MarkNumber, &VersionNumber, NULL, 0);
@ -387,10 +389,12 @@ int Epd3Base::Epd3U::ReadStatus()
isBG = (EpdType == EpdTypes::Mk2BetaGamma || EpdType == EpdTypes::Mk3BetaGamma); isBG = (EpdType == EpdTypes::Mk2BetaGamma || EpdType == EpdTypes::Mk3BetaGamma);
isNG = (EpdType == EpdTypes::Mk2Neutron || EpdType == EpdTypes::Mk3Neutron); isNG = (EpdType == EpdTypes::Mk2Neutron || EpdType == EpdTypes::Mk3Neutron);
HardVersion = MarkNumber.Major; HardVersion = MarkNumber.Major;
HardVersionMinor = MarkNumber.Minor;
SoftVersion = VersionNumber.Major; SoftVersion = VersionNumber.Major;
VersionOK = true; VersionOK = true;
DecodeStatus(); //Alarm status... DecodeStatus(); //Alarm status...
step = 3;
token = BeginReadCounts(epdComsHandle, nullptr, 0, nullptr); token = BeginReadCounts(epdComsHandle, nullptr, 0, nullptr);
r = Commit3(epdComsHandle); r = Commit3(epdComsHandle);
r = EndReadCounts(epdComsHandle, token, Counts, MaxCounts, &countsRead, &utc, &seconds); r = EndReadCounts(epdComsHandle, token, Counts, MaxCounts, &countsRead, &utc, &seconds);
@ -403,6 +407,7 @@ int Epd3Base::Epd3U::ReadStatus()
decodeCounters(countsRead); //HG,SG .. decodeCounters(countsRead); //HG,SG ..
//Wearer //Wearer
step = 4;
if (EPDIssued) { if (EPDIssued) {
IdString_t mk3WearerID; IdString_t mk3WearerID;
//Mk2 EPDs only support Name and Primary ID //Mk2 EPDs only support Name and Primary ID
@ -417,6 +422,7 @@ int Epd3Base::Epd3U::ReadStatus()
if (mk3WearerID.Length > WearerNameLength) mk3WearerID.Length = WearerNameLength; if (mk3WearerID.Length > WearerNameLength) mk3WearerID.Length = WearerNameLength;
memcpy(WearerName, mk3WearerID.Utf8String, mk3WearerID.Length); WearerName[mk3WearerID.Length] = 0; memcpy(WearerName, mk3WearerID.Utf8String, mk3WearerID.Length); WearerName[mk3WearerID.Length] = 0;
step = 5;
token = BeginReadWearerId(epdComsHandle, static_cast<uint16_t>(WearerIdType::WearerId_Primary), nullptr); token = BeginReadWearerId(epdComsHandle, static_cast<uint16_t>(WearerIdType::WearerId_Primary), nullptr);
r = Commit3(epdComsHandle); r = Commit3(epdComsHandle);
r = EndReadWearerId(epdComsHandle, token, &mk3WearerID); r = EndReadWearerId(epdComsHandle, token, &mk3WearerID);
@ -434,10 +440,12 @@ int Epd3Base::Epd3U::ReadStatus()
//Times //Times
//1601-01-01T00:00:00Z. //1601-01-01T00:00:00Z.
//MK2 .. some utc... but no real time clock //MK2 .. some utc... but no real time clock
step = 6;
if (utc == 0) { if (utc == 0) {
token = BeginReadRTC(epdComsHandle, nullptr); token = BeginReadRTC(epdComsHandle, nullptr);
r = Commit3(epdComsHandle); r = Commit3(epdComsHandle);
r = EndReadRTC(epdComsHandle, token, &utc); //EpdClock for MK2 r = EndReadRTC(epdComsHandle, token, &utc); //EpdClock for MK2
if (r) goto error;
EpdClock = utc; EpdClock = utc;
utc = TimeFunctions::NowToEpdTime(true); utc = TimeFunctions::NowToEpdTime(true);
} }
@ -450,7 +458,10 @@ int Epd3Base::Epd3U::ReadStatus()
FileTimeToSystemTime(&fUTC, &tRealTime); FileTimeToSystemTime(&fUTC, &tRealTime);
return r; return r;
error: error:
Error = r;
ErrorStep = step;
return r; return r;
} }
@ -463,6 +474,7 @@ int Epd3Base::Epd3U::ConnectAndStatus(int tokenSourceTimeout)
{ {
WORD dllStatus; WORD dllStatus;
int rv = 1; int rv = 1;
Error = 0; ErrorStep = 0;
if (CommsInitialized == 0) StartCom(); if (CommsInitialized == 0) StartCom();
if (CommsInitialized) { if (CommsInitialized) {
dllStatus = StartDiscover(tokenSourceTimeout); dllStatus = StartDiscover(tokenSourceTimeout);
@ -472,6 +484,7 @@ int Epd3Base::Epd3U::ConnectAndStatus(int tokenSourceTimeout)
else rv = 0; else rv = 0;
} }
else rv = 1; else rv = 1;
return rv; return rv;
} }
/// <summary> /// <summary>
@ -692,6 +705,7 @@ WORD Epd3Base::Epd3U::ReadCal()
decodeSensitivities(numSensitivities); decodeSensitivities(numSensitivities);
return r; return r;
error: error:
Error = r;
return r; return r;
} }
/// <summary> /// <summary>
@ -760,6 +774,7 @@ error:
/// <returns>0 OK</returns> /// <returns>0 OK</returns>
WORD Epd3Base::Epd3U::ReadDoses() WORD Epd3Base::Epd3U::ReadDoses()
{ {
int step = 0;
int32_t r = 1; int32_t r = 1;
eDosDose07Warning = eDosDose07Alarm = eDosDose10Warning = eDosDose10Alarm = eDosRate07Warning = eDosRate07Alarm = eDosRate10Warning = eDosRate10Alarm = eDosBatteryWarning = 0; eDosDose07Warning = eDosDose07Alarm = eDosDose10Warning = eDosDose10Alarm = eDosRate07Warning = eDosRate07Alarm = eDosRate10Warning = eDosRate10Alarm = eDosBatteryWarning = 0;
@ -777,13 +792,16 @@ WORD Epd3Base::Epd3U::ReadDoses()
numDoses = 0; utc = 0; numDoses = 0; utc = 0;
SetResponseTimeout(epdComsHandle, 2000); SetResponseTimeout(epdComsHandle, 2000);
step = 1;
token = BeginReadDoses(epdComsHandle, nullptr, 0, nullptr); token = BeginReadDoses(epdComsHandle, nullptr, 0, nullptr);
r = Commit3(epdComsHandle); r = Commit3(epdComsHandle);
if (!r) r = EndReadDoses(epdComsHandle, token, doses, MaxDoses, &numDoses, &utc); if (!r) r = EndReadDoses(epdComsHandle, token, doses, MaxDoses, &numDoses, &utc);
if (r != 0) if (r != 0)
goto error; goto error;
decodeDoses(numDoses); decodeDoses(numDoses);
step = 2;
token = BeginReadTotalDoses(epdComsHandle, nullptr, 0, nullptr); token = BeginReadTotalDoses(epdComsHandle, nullptr, 0, nullptr);
r = Commit3(epdComsHandle); r = Commit3(epdComsHandle);
if (!r) r = EndReadTotalDoses(epdComsHandle, token, totdoses, MaxDoses, &numtotDoses, &utc); if (!r) r = EndReadTotalDoses(epdComsHandle, token, totdoses, MaxDoses, &numtotDoses, &utc);
@ -791,14 +809,17 @@ WORD Epd3Base::Epd3U::ReadDoses()
goto error; goto error;
decodetotDoses(numtotDoses); decodetotDoses(numtotDoses);
step = 3;
token = BeginReadQualityData(epdComsHandle, nullptr); token = BeginReadQualityData(epdComsHandle, nullptr);
r = Commit3(epdComsHandle); r = Commit3(epdComsHandle);
if (!r) r = EndReadQualityData(epdComsHandle, token, &quality); if (!r) r = EndReadQualityData(epdComsHandle, token, &quality);
if (r != 0) if (r != 0)
goto error; goto error;
Knocks = quality.Knocks; Knocks = quality.Knocks;
Resets = quality.PowerCycles; Resets = quality.PowerCycles;
step = 4;
token = BeginReadPeakRates(epdComsHandle, nullptr, 0, nullptr); token = BeginReadPeakRates(epdComsHandle, nullptr, 0, nullptr);
r = Commit3(epdComsHandle); r = Commit3(epdComsHandle);
if (!r) r = EndReadPeakRates(epdComsHandle, token, peakRates, MaxPeakRates, &numRates); if (!r) r = EndReadPeakRates(epdComsHandle, token, peakRates, MaxPeakRates, &numRates);
@ -806,6 +827,7 @@ WORD Epd3Base::Epd3U::ReadDoses()
goto error; goto error;
decodePeakRates(numRates); decodePeakRates(numRates);
step = 5;
r= ReadSensitivitiesAndTresholds(); //K1 .. K6, SG , BC ,FB , HG r= ReadSensitivitiesAndTresholds(); //K1 .. K6, SG , BC ,FB , HG
if (r != 0) if (r != 0)
goto error; goto error;
@ -882,34 +904,43 @@ WORD Epd3Base::Epd3U::PrepareForIssue()
int rv = 0; int rv = 0;
int step = 0; int step = 0;
if (port == 0) return 0; if (port == 0) return 0;
rv = ReOpenDev(); ++step; step = 1;
if (WriteConfig32)
rv = WriteConfig();
if (rv != 0)
goto error;
++step;
if (DetectorsOn) { if (DetectorsOn) {
token = BeginEpdOnOff(epdComsHandle, 0, nullptr); token = BeginEpdOnOff(epdComsHandle, 0, nullptr);
rv = Commit3(epdComsHandle); rv = Commit3(epdComsHandle);
if (!rv) rv = EndEpdOnOff(epdComsHandle, token); if (!rv) rv = EndEpdOnOff(epdComsHandle, token);
rv = ReOpenDev();
} }
++step;
rv = ReOpenDev();
++step;
rv = ClearDoses();
if (rv != 0) if (rv != 0)
goto error; goto error;
++step;
step = 2;
if (WriteConfig32) {
rv = WriteConfig();
if (rv != 0)
goto error;
}
step = 3;
rv = ReOpenDev();
step = 4;
rv = ClearDoses();
if (rv != 0)
goto error;
step = 5;
rv = ClearAlarms(); rv = ClearAlarms();
if (rv != 0) if (rv != 0)
goto error; goto error;
return rv; return rv;
error: error:
ErrorStep = step;
Error = rv;
return rv; return rv;
} }
@ -996,12 +1027,18 @@ error:
WORD Epd3Base::Epd3U::DeIssue() WORD Epd3Base::Epd3U::DeIssue()
{ {
int r = 1; int r = 1;
int ErrorStep = 0;
if (port == 0) return 0; if (port == 0) return 0;
if (CurrentDeviceID==0) return 0; if (CurrentDeviceID==0) return 0;
ReOpenDev();
ErrorStep = 1;
r = ClearAlarms(); r = ClearAlarms();
ErrorStep = 2;
r = ClearDoses(); r = ClearDoses();
ErrorStep = 3;
if (EPDIssued) { if (EPDIssued) {
token = BeginDeissueEPD(epdComsHandle, nullptr); token = BeginDeissueEPD(epdComsHandle, nullptr);
r = Commit3(epdComsHandle); r = Commit3(epdComsHandle);
@ -1010,21 +1047,28 @@ WORD Epd3Base::Epd3U::DeIssue()
r = 0; // goto error; r = 0; // goto error;
} }
ErrorStep = 4;
token = BeginEpdOnOff(epdComsHandle, 0, nullptr); token = BeginEpdOnOff(epdComsHandle, 0, nullptr);
r = Commit3(epdComsHandle); r = Commit3(epdComsHandle);
r = EndEpdOnOff(epdComsHandle, token); r = EndEpdOnOff(epdComsHandle, token);
if (r != 0) if (r != 0)
goto error; goto error;
ErrorStep = 5;
EndCom(); EndCom();
return r; return r;
error: error:
Error = r;
return r; return r;
} }
WORD Epd3Base::Epd3U::WriteWearer() { WORD Epd3Base::Epd3U::WriteWearer() {
int32_t r = 0; int32_t r = 0;
int step = 0;
token = BeginSetBaselineCounters(epdComsHandle, nullptr); token = BeginSetBaselineCounters(epdComsHandle, nullptr);
r = Commit3(epdComsHandle); r = Commit3(epdComsHandle);
r = EndSetBaselineCounters(epdComsHandle, token); r = EndSetBaselineCounters(epdComsHandle, token);
@ -1038,6 +1082,7 @@ WORD Epd3Base::Epd3U::WriteWearer() {
mk3WearerID.Length = 23; mk3WearerID.Length = 23;
memcpy(mk3WearerID.Utf8String, WearerName, 23); memcpy(mk3WearerID.Utf8String, WearerName, 23);
step = 1;
token = BeginWriteWearerId(epdComsHandle, mk3WearerID, nullptr); token = BeginWriteWearerId(epdComsHandle, mk3WearerID, nullptr);
r = Commit3(epdComsHandle); r = Commit3(epdComsHandle);
r = EndWriteWearerId(epdComsHandle, token); r = EndWriteWearerId(epdComsHandle, token);
@ -1048,6 +1093,7 @@ WORD Epd3Base::Epd3U::WriteWearer() {
mk3WearerID.Length = 13; mk3WearerID.Length = 13;
memcpy(mk3WearerID.Utf8String, WearerID, 13); memcpy(mk3WearerID.Utf8String, WearerID, 13);
step = 2;
token = BeginWriteWearerId(epdComsHandle, mk3WearerID, nullptr); token = BeginWriteWearerId(epdComsHandle, mk3WearerID, nullptr);
r = Commit3(epdComsHandle); r = Commit3(epdComsHandle);
r = EndWriteWearerId(epdComsHandle, token); r = EndWriteWearerId(epdComsHandle, token);
@ -1056,7 +1102,9 @@ WORD Epd3Base::Epd3U::WriteWearer() {
return r; return r;
error: error:
ErrorStep = step;
Error = r;
return r; return r;
} }
/// <summary> /// <summary>
@ -1077,7 +1125,7 @@ WORD Epd3Base::Epd3U::Issue(bool PrepareDone)
if (r != 0) if (r != 0)
goto error; goto error;
} }
++step; //1
/*if (isMK3) { /*if (isMK3) {
token = BeginEnableProtectedSession_R3(epdComsHandle, 1, nullptr); token = BeginEnableProtectedSession_R3(epdComsHandle, 1, nullptr);
@ -1086,20 +1134,21 @@ WORD Epd3Base::Epd3U::Issue(bool PrepareDone)
if (r != 0) if (r != 0)
goto error; goto error;
}*/ }*/
step = 1;
ReOpenDev();
step = 2;
r = WriteAlarmTresholds(); r = WriteAlarmTresholds();
if (r != 0) if (r != 0)
goto error; goto error;
++step;//2
step = 3;
r = WriteWearer(); r = WriteWearer();
if (r != 0) if (r != 0)
goto error; goto error;
/*r = WriteCal();
if (r != 0)
goto error;*/
++step;//3 step = 4;
//EPDIssued //EPDIssued
//if (!DetectorsOn) { //if (!DetectorsOn) {
token = BeginEpdOnOff(epdComsHandle, 1, nullptr); token = BeginEpdOnOff(epdComsHandle, 1, nullptr);
@ -1111,19 +1160,22 @@ WORD Epd3Base::Epd3U::Issue(bool PrepareDone)
r=0; r=0;
//} //}
++step;//4 step = 5;
ReOpenDev();
tries = 1; tries = 1;
token = BeginIssueEPD(epdComsHandle, nullptr); token = BeginIssueEPD(epdComsHandle, nullptr);
r = Commit3(epdComsHandle); r = Commit3(epdComsHandle);
r = EndIssueEPD(epdComsHandle, token); r = EndIssueEPD(epdComsHandle, token);
if (r != 0) { if (r != 0) {
tries++; tries++;
if (r == r_ErrorNotConnected) ReOpenDev();
Sleep(500); Sleep(500);
token = BeginIssueEPD(epdComsHandle, nullptr); token = BeginIssueEPD(epdComsHandle, nullptr);
r = Commit3(epdComsHandle); r = Commit3(epdComsHandle);
r = EndIssueEPD(epdComsHandle, token); r = EndIssueEPD(epdComsHandle, token);
} }
if (r) if (r)
goto error; goto error;
/*if (isMK3) { /*if (isMK3) {
@ -1134,18 +1186,21 @@ WORD Epd3Base::Epd3U::Issue(bool PrepareDone)
goto error; goto error;
}*/ }*/
++step;//5 step = 6;
if (isMK3) { if (isMK3) {
r = DisCon(EndSessionControl); //stops protected session r = DisCon(EndSessionControl); //stops protected session
if (r) if (r)
goto error; goto error;
} }
++step;
step = 7;
EndCom(); EndCom();
return r; return r;
error: error:
ErrorStep = step;
Error = r;
return r; return r;
} }
@ -1195,8 +1250,6 @@ WORD Epd3Base::Epd3U::WriteCal()
token = BeginWriteSensitivities_R2(epdComsHandle, nullptr, (uint16_t)K1, (uint16_t)K2, (uint16_t)K3, (uint16_t)K4, (uint16_t)K5, (uint16_t)K6); token = BeginWriteSensitivities_R2(epdComsHandle, nullptr, (uint16_t)K1, (uint16_t)K2, (uint16_t)K3, (uint16_t)K4, (uint16_t)K5, (uint16_t)K6);
r = Commit3(epdComsHandle); r = Commit3(epdComsHandle);
if (r != 0)
goto error;
if (r != 0) if (r != 0)
goto error; goto error;
r = EndWriteSensitivities_R2(epdComsHandle, token); r = EndWriteSensitivities_R2(epdComsHandle, token);
@ -1219,13 +1272,32 @@ int Epd3Base::Epd3U::GetAll(bool Closeconnection)
return rv; return rv;
} }
int Epd3Base::Epd3U::GetAllDeissue() int Epd3Base::Epd3U::GetAllDeissue(bool reconnect)
{ {
int rv = 0; int rv = 0;
int step = 0;
if (reconnect)
rv = ReOpenDev();
if (!rv) goto error;
step = 1;
rv = ReadDoses(); //0 = success rv = ReadDoses(); //0 = success
if (!rv) goto error;
//rv = ReadAlarmTresholds(); //0 = success //rv = ReadAlarmTresholds(); //0 = success
step = 2;
rv = EPDReadExtraStatus(); rv = EPDReadExtraStatus();
if (!rv) goto error;
step = 3;
rv = DeIssue(); //does close rv = DeIssue(); //does close
if (!rv) goto error;
return rv;
error:
Error = rv;
ErrorStep = step;
return rv; return rv;
} }
@ -1233,29 +1305,35 @@ int Epd3Base::Epd3U::IssueAndCheck(float gain,float ChirpRate)
{ {
int rv = 0; int rv = 0;
int step = 0; int step = 0;
ReOpenDev();
if (isNG) { if (isNG) {
step = 1;
float kx = gain; float kx = gain;
rv = ReadCal(); rv = ReadCal();
if (rv != 0 || K6 != 1310) { rv = 1; goto error; } if (rv != 0 || K6 != 1310) { rv = 1; goto error; }
++step;
if (K3 != kx || K4 != kx) if (K3 != kx || K4 != kx)
{ {
step = 2;
K3 = K4 = kx; K3 = K4 = kx;
rv = WriteCal(); rv = WriteCal();
if (rv != 0) goto error; if (rv != 0) goto error;
} }
} }
++step; step = 3;
SetChirp( ChirpRate); SetChirp( ChirpRate);
++step; step = 4;
rv = PrepareForIssue(); rv = PrepareForIssue();
if (rv != 0) goto error; if (rv != 0) goto error;
++step; step = 5;
if (!rv) rv = Issue(true); // data already loaded if (!rv) rv = Issue(true); // data already loaded
if (rv != 0) goto error; if (rv != 0) goto error;
return rv; return rv;
error: error:
Error = rv;
ErrorStep = step;
return rv; return rv;
} }
@ -1377,6 +1455,7 @@ int Epd3Base::Epd3U::SetChirp(float Sensitivity)
{ {
uint32_t r = 1; uint32_t r = 1;
uint8_t enable = 0; uint8_t enable = 0;
if (Sensitivity > 0.001F) { if (Sensitivity > 0.001F) {
enable = 1; enable = 1;
token = BeginWriteChirpSensitivity(epdComsHandle, Sensitivity, nullptr); token = BeginWriteChirpSensitivity(epdComsHandle, Sensitivity, nullptr);

View file

@ -32,6 +32,7 @@ namespace Epd3Base {
WORD WriteConfig32 = 1; WORD WriteConfig32 = 1;
WORD Error = 0; WORD Error = 0;
WORD ErrorStep = 0;
WORD ErrorSource; WORD ErrorSource;
WORD ErrorReason; WORD ErrorReason;
WORD ErrorData; WORD ErrorData;
@ -108,7 +109,7 @@ namespace Epd3Base {
//Identification //Identification
DWORD EpdID = 0; DWORD EpdID = 0;
WORD HardVersion; WORD HardVersion, HardVersionMinor;
WORD SoftVersion; WORD SoftVersion;
WORD FunctionFlags; WORD FunctionFlags;
@ -266,7 +267,7 @@ namespace Epd3Base {
void decodePeakRates(int count); void decodePeakRates(int count);
public: public:
int GetAll(bool Closeconnection); int GetAll(bool Closeconnection);
int GetAllDeissue(); int GetAllDeissue(bool reconnect);
int IssueAndCheck(float gain, float ChirpRate); int IssueAndCheck(float gain, float ChirpRate);
int SetChirp(float Sensitivity); int SetChirp(float Sensitivity);
WORD ReadCal(); WORD ReadCal();

View file

@ -11,7 +11,7 @@ using namespace System::Security::Permissions;
[assembly:AssemblyConfigurationAttribute(L"")]; [assembly:AssemblyConfigurationAttribute(L"")];
[assembly:AssemblyCompanyAttribute(L"SCK CEN")]; [assembly:AssemblyCompanyAttribute(L"SCK CEN")];
[assembly:AssemblyProductAttribute(L"EpdBaseClr")]; [assembly:AssemblyProductAttribute(L"EpdBaseClr")];
[assembly:AssemblyCopyrightAttribute(L"Copyright (c) 2019-2021 Luc Vandenbroucke")]; [assembly:AssemblyCopyrightAttribute(L"Copyright (c) 2019-2024 Luc Vandenbroucke")];
[assembly:AssemblyTrademarkAttribute(L"")]; [assembly:AssemblyTrademarkAttribute(L"")];
[assembly:AssemblyCultureAttribute(L"")]; [assembly:AssemblyCultureAttribute(L"")];

View file

@ -182,7 +182,7 @@ int EpdBaseClr::Epd2::AfterGetStatus(EpdBase::Epd2U *epd)
operatingStatus = epd->OperatingStatus; operatingStatus = epd->OperatingStatus;
hasAlarm = epd->hasAlarm; hasAlarm = epd->hasAlarm;
EpdID = epd->EpdID; EpdID = epd->EpdID;
HardVersion = epd->HardVersion; HardVersion = epd->HardVersion;
SoftVersion = epd->SoftVersion; SoftVersion = epd->SoftVersion;
FunctionFlags = epd->FunctionFlags; FunctionFlags = epd->FunctionFlags;
CountsClock = epd->EpdClock; CountsClock = epd->EpdClock;
@ -207,6 +207,7 @@ int EpdBaseClr::Epd2::AfterGetStatus(Epd3Base::Epd3U* epd)
hasAlarm = epd->hasAlarm; hasAlarm = epd->hasAlarm;
EpdID = epd->EpdID; EpdID = epd->EpdID;
HardVersion = epd->HardVersion; HardVersion = epd->HardVersion;
HardVersionMinor = epd->HardVersionMinor;
SoftVersion = epd->SoftVersion; SoftVersion = epd->SoftVersion;
FunctionFlags = epd->FunctionFlags; FunctionFlags = epd->FunctionFlags;
CountsClock = epd->EpdClock; CountsClock = epd->EpdClock;
@ -339,7 +340,12 @@ int EpdBaseClr::Epd2::ClearAlarms()
int EpdBaseClr::Epd2::SetDeIssued() int EpdBaseClr::Epd2::SetDeIssued()
{ {
int rv = 0; int rv = 0;
if (isMK3) rv = epd3->DeIssue(); ErrorStep = 0; ErrorRV = 0;
if (isMK3) {
rv = epd3->DeIssue();
ErrorStep = epd3->ErrorStep;
ErrorRV = epd3->Error;
}
else rv = epd->DeIssue(); else rv = epd->DeIssue();
return rv; return rv;
} }
@ -348,7 +354,12 @@ int EpdBaseClr::Epd2::PrepareForIssue()
{ {
int rv = 0; int rv = 0;
PrepareForIssueError = 0; PrepareForIssueError = 0;
if (isMK3) rv= epd3->PrepareForIssue(); ErrorStep = 0; ErrorRV = 0;
if (isMK3) {
rv = epd3->PrepareForIssue();
ErrorStep = epd3->ErrorStep;
ErrorRV = epd3->Error;
}
else rv= epd->PrepareForIssue(); else rv= epd->PrepareForIssue();
if (rv != 0) PrepareForIssueError = epd->Error; if (rv != 0) PrepareForIssueError = epd->Error;
return rv; return rv;
@ -360,7 +371,12 @@ int EpdBaseClr::Epd2::PrepareForIssue()
int EpdBaseClr::Epd2::SetIssued() int EpdBaseClr::Epd2::SetIssued()
{ {
int rv = 0; int rv = 0;
if (isMK3) rv=SetIssued(epd3); ErrorStep = 0; ErrorRV = 0;
if (isMK3) {
rv=SetIssued(epd3);
ErrorStep = epd3->ErrorStep;
ErrorRV = epd3->Error;
}
else rv=SetIssued(epd); else rv=SetIssued(epd);
return rv; return rv;
} }
@ -369,15 +385,15 @@ int EpdBaseClr::Epd2::BeforeSetIssued(Epd3Base::Epd3U* epd)
int rv = 0; int rv = 0;
SetIssuedError = 0; SetIssuedError = 0;
epd->Hp07THDose = (float)Hp07THDose; epd->Hp07THDose = (float)Hp07THDose;
epd->Hp10THDose1 = Hp10THDose1; epd->Hp10THDose1 = (float)Hp10THDose1;
epd->Hp10THDose2 = Hp10THDose2; epd->Hp10THDose2 = (float)Hp10THDose2;
epd->Hp10Rate1On = Hp10Rate1On; epd->Hp10Rate1On = (float)Hp10Rate1On;
epd->Hp10Rate2On = Hp10Rate2On; epd->Hp10Rate2On = (float)Hp10Rate2On;
epd->Hp07RateOn = Hp07RateOn; epd->Hp07RateOn = (float)Hp07RateOn;
epd->Hp10Rate1Off = Hp10Rate1Off; epd->Hp10Rate1Off = (float)Hp10Rate1Off;
epd->Hp10Rate2Off = Hp10Rate2Off; epd->Hp10Rate2Off = (float)Hp10Rate2Off;
epd->Hp07RateOff = Hp07RateOff; epd->Hp07RateOff = (float)Hp07RateOff;
memset(epd->WearerID, ' ', WearerIDLength); epd->WearerID[WearerIDLength] = 0; memset(epd->WearerID, ' ', WearerIDLength); epd->WearerID[WearerIDLength] = 0;
char* str1 = (char*)(void*)Runtime::InteropServices::Marshal::StringToHGlobalAnsi(WearerID); char* str1 = (char*)(void*)Runtime::InteropServices::Marshal::StringToHGlobalAnsi(WearerID);
@ -571,10 +587,10 @@ int EpdBaseClr::Epd2::AfterReadTresholds(Epd3Base::Epd3U* epd)
Hp07Total = (double)epd->Hp07Total; Hp07Total = (double)epd->Hp07Total;
K1 = (int)epd->K1; K1 = (int)epd->K1;
K2 = epd->K2; K2 = (int)epd->K2;
K3 = epd->K3; K3 = (int)epd->K3;
K4 = epd->K4; K4 = (int)epd->K4;
K5 = epd->K5; K5 = (int)epd->K5;
K6 = (int)epd->K6; K6 = (int)epd->K6;
SG = epd->SG; SG = epd->SG;
BC = epd->BC; BC = epd->BC;
@ -640,9 +656,7 @@ int EpdBaseClr::Epd2::ReadExtraStatus(Epd3Base::Epd3U* epd)
return rv; return rv;
} }
int EpdBaseClr::Epd2::AfterGetDoses(EpdBase::Epd2U* epd)
int EpdBaseClr::Epd2::AfterGetDoses(EpdBase::Epd2U* epd)
{ {
eDoshasAlarm = eDosHasFault = false; eDoshasAlarm = eDosHasFault = false;
int rv = 0; int rv = 0;
@ -709,7 +723,6 @@ int EpdBaseClr::Epd2::AfterGetDoses(EpdBase::Epd2U* epd)
return rv; return rv;
} }
/// <summary> /// <summary>
/// Get Doses and tresholds, and close if requested /// Get Doses and tresholds, and close if requested
/// </summary> /// </summary>
@ -731,8 +744,9 @@ int EpdBaseClr::Epd2::GetAll(bool close)
} }
return rv; return rv;
} }
int EpdBaseClr::Epd2::GetAllDeissue() int EpdBaseClr::Epd2::GetAllDeissue(bool reconnect)
{ {
ErrorRV = ErrorStep = 0;
int rv = 0; int rv = 0;
if (!isMK3) { if (!isMK3) {
rv = epd->GetAllDeissue(); rv = epd->GetAllDeissue();
@ -741,7 +755,9 @@ int EpdBaseClr::Epd2::GetAllDeissue()
} }
else else
{ {
rv = epd3->GetAllDeissue(); rv = epd3->GetAllDeissue(reconnect);
ErrorRV = epd3->Error;
ErrorStep = epd3->ErrorStep;
rv = AfterGetDoses(epd3); rv = AfterGetDoses(epd3);
rv = AfterReadTresholds(epd3); rv = AfterReadTresholds(epd3);
} }
@ -761,7 +777,7 @@ int EpdBaseClr::Epd2::IssueAndCheck(float gain,float ChirpRate)
} }
else else
{ {
BeforeSetIssued(epd3); BeforeSetIssued(epd3); //geen interactie met epd
rv = epd3->IssueAndCheck(gain, ChirpRate); rv = epd3->IssueAndCheck(gain, ChirpRate);
} }
return rv; return rv;
@ -802,7 +818,7 @@ void EpdBaseClr::Epd2::InitData()
otherAlarms = 0; otherAlarms = 0;
errorStatus = 0; errorStatus = 0;
operatingStatus = 0; operatingStatus = 0;
HardVersion = 0; HardVersion = 0; HardVersionMinor = 0;
SoftVersion = 0; SoftVersion = 0;
FunctionFlags = 0; FunctionFlags = 0;
CountsClock = 0; CountsClock = 0;
@ -815,13 +831,20 @@ void EpdBaseClr::Epd2::InitData()
int EpdBaseClr::Epd2::ConnectAndStatus() int EpdBaseClr::Epd2::ConnectAndStatus()
{ {
int rv = 1; int rv = 1;
int step = 0;
ErrorStep = ErrorRV = 0;
if (!onlyMK2) epd->EndCom(); //indien Mk2 if (!onlyMK2) epd->EndCom(); //indien Mk2
InitData(); InitData();
//Sleep(100); //Sleep(100);
if (onlyMK2) step = 1;
if (onlyMK2 || !epd3)
rv = epd->ConnectAndStatus(tokenSourceTimeout); rv = epd->ConnectAndStatus(tokenSourceTimeout);
else else {
rv = epd3->ConnectAndStatus(tokenSourceTimeout); rv = epd3->ConnectAndStatus(tokenSourceTimeout);
}
if (rv==0) { if (rv==0) {
if (onlyMK2) { if (onlyMK2) {
DeviceCount = epd->DeviceCount; DeviceCount = epd->DeviceCount;
@ -860,8 +883,13 @@ int EpdBaseClr::Epd2::ConnectAndStatus()
else { else {
if (epd == nullptr) ConnectError = 99; if (epd == nullptr) ConnectError = 99;
else ConnectError = epd->Error; else ConnectError = epd->Error;
goto error;
} }
return rv; return rv;
error:
ErrorStep = step;
ErrorRV = rv;
return rv;
} }
void EpdBaseClr::Epd2::WaitEpd() void EpdBaseClr::Epd2::WaitEpd()
{ {
@ -879,7 +907,7 @@ void EpdBaseClr::Epd2::WaitEpd()
_EpdTO(this, gcnew EpdTOEventArgs(0, 0)); // epd3->ConnectTries, epd3->ConnectTimerFired)); _EpdTO(this, gcnew EpdTOEventArgs(0, 0)); // epd3->ConnectTries, epd3->ConnectTimerFired));
} }
else if (rv > 0 && _EpdError != nullptr) { else if (rv > 0 && _EpdError != nullptr) {
_EpdError(this, gcnew EpdErrorEventArgs(rv)); _EpdError(this, gcnew EpdErrorEventArgs(rv,ErrorRV,ErrorStep));
} }
return; return;
} }

View file

@ -19,6 +19,7 @@ namespace EpdBaseClr {
public: public:
int deviceID; int deviceID;
bool isIssued, isBG, isMK3; bool isIssued, isBG, isMK3;
EpdEventArgs(int epdID, bool epdIssued, bool isBG, bool isMK3) : EventArgs() EpdEventArgs(int epdID, bool epdIssued, bool isBG, bool isMK3) : EventArgs()
{ {
@ -43,10 +44,19 @@ namespace EpdBaseClr {
{ {
public: public:
int returnValue; int returnValue;
int ErrorRV; int ErrorStep;
EpdErrorEventArgs(int ReturnValue) : EventArgs() EpdErrorEventArgs(int ReturnValue) : EventArgs()
{ {
ErrorRV= ErrorStep = 0;
this->returnValue = ReturnValue; this->returnValue = ReturnValue;
} }
EpdErrorEventArgs(int ReturnValue, int errorRV, int errorStep) : EventArgs()
{
this->ErrorRV = errorRV;
this->ErrorStep = errorStep;
this->returnValue = ReturnValue;
}
}; };
public ref class EpdTOEventArgs : EventArgs public ref class EpdTOEventArgs : EventArgs
{ {
@ -156,6 +166,8 @@ namespace EpdBaseClr {
int ConnectError; int ConnectError;
int ReadDosesRV; int ReadDosesRV;
int DeviceCount = 0; int DeviceCount = 0;
int ErrorStep=0;
int ErrorRV = 0;
double Hp07; double Hp07;
double Hp10; double Hp10;
@ -202,7 +214,7 @@ namespace EpdBaseClr {
int errorStatus ; int errorStatus ;
int operatingStatus ; int operatingStatus ;
unsigned int EpdID ; unsigned int EpdID ;
int HardVersion ; int HardVersion, HardVersionMinor;
int SoftVersion ; int SoftVersion ;
int FunctionFlags ; int FunctionFlags ;
@ -296,13 +308,14 @@ namespace EpdBaseClr {
int tokenSourceTimeout; int tokenSourceTimeout;
int readRetries; int readRetries;
System::Threading::Tasks::Task^ waitTask; System::Threading::Tasks::Task^ waitTask;
int SetDeIssued();
public: public:
int SetDeIssued();
System::Threading::Tasks::Task^ Wait(int timeout, int Retries); System::Threading::Tasks::Task^ Wait(int timeout, int Retries);
void WaitEnd(); void WaitEnd();
int GetAll(bool close); int GetAll(bool close);
int GetAllDeissue(); int GetAllDeissue(bool reconnect);
int IssueAndCheck(float gain, float ChirpRate); int IssueAndCheck(float gain, float ChirpRate);
private: private:

View file

@ -125,7 +125,11 @@
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
<KeyContainer> <KeyContainer>
</KeyContainer> </KeyContainer>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link> </Link>
<PostBuildEvent>
<Command>%signer% $(TargetPath)</Command>
</PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile> <ClCompile>

Binary file not shown.

View file

@ -281,6 +281,25 @@ namespace eDosStation
if (oldState == ConnectionState.Closed) localConnection.Close(); if (oldState == ConnectionState.Closed) localConnection.Close();
} }
public int? ParaIntValue(SqlCommand cmd, string name)
{
int? rv = null;
if (cmd.Parameters.Contains(name) && cmd.Parameters[name].Value != DBNull.Value) rv = (int?)cmd.Parameters[name].Value;
return rv;
}
public bool? ParaBoolValue(SqlCommand cmd, string name)
{
bool? rv = null;
if (cmd.Parameters.Contains(name) && cmd.Parameters[name].Value != DBNull.Value) rv = (bool?)cmd.Parameters[name].Value;
return rv;
}
public string ParaStringValue(SqlCommand cmd, string name)
{
string rv = null;
if (cmd.Parameters.Contains(name) && cmd.Parameters[name].Value != DBNull.Value) rv = (string)cmd.Parameters[name].Value;
return rv;
}
public int VisitInfo(int EpdVisitID, out string name) public int VisitInfo(int EpdVisitID, out string name)
{ {
int? rv = 0; int? rv = 0;
@ -292,10 +311,10 @@ namespace eDosStation
checkCon(true); checkCon(true);
VisitInfoCommand.Connection = localConnection; VisitInfoCommand.Connection = localConnection;
VisitInfoCommand.ExecuteScalar(); VisitInfoCommand.ExecuteScalar();
rv = (int?)VisitInfoCommand.Parameters["RETURN_VALUE"].Value; rv = ParaIntValue(VisitInfoCommand, "RETURN_VALUE");
bool? hasExited = (bool?)VisitInfoCommand.Parameters["hasExited"].Value; bool? hasExited = ParaBoolValue(VisitInfoCommand, "hasExited");
bool? isManualExit = (bool?)VisitInfoCommand.Parameters["isManualExit"].Value; bool? isManualExit = ParaBoolValue(VisitInfoCommand, "isManualExit");
name = (string )VisitInfoCommand.Parameters["name"].Value; name = ParaStringValue(VisitInfoCommand, "name");
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {

View file

@ -15,10 +15,7 @@ namespace eDosStation
public partial class EntryBadge : Window public partial class EntryBadge : Window
{ {
private enum eEntryState { none, getuser, gettask, getepd, epdtimeout, epdError, epdOK, final, private enum eEntryState { none, getuser, gettask, getepd, epdtimeout, epdError, epdOK, final, NotAllowed, Initial }
NotAllowed,
Initial
}
private eEntryState EntryState; private eEntryState EntryState;
bool taskLoading = false; bool taskLoading = false;
const int PageTimeout = 10000; const int PageTimeout = 10000;
@ -64,7 +61,7 @@ namespace eDosStation
EntryState = eEntryState.epdError; EntryState = eEntryState.epdError;
System.Diagnostics.Debug.WriteLine("ERROR "); System.Diagnostics.Debug.WriteLine("ERROR ");
Dispatcher.InvokeAsync(() => { Dispatcher.InvokeAsync(() => {
MessageBox.Show($"EPD Error {e.returnValue}"); MessageBox.Show($"EPD Error {e.returnValue} {e.ErrorRV} {e.ErrorStep}");
Dispatcher.InvokeAsync(() => { SetTimedOutAndEnd(); }); Dispatcher.InvokeAsync(() => { SetTimedOutAndEnd(); });
}); });
} }
@ -550,6 +547,7 @@ namespace eDosStation
} }
EpdReading = false; EpdReading = false;
dispatcherTimer?.Stop(); dispatcherTimer?.Stop();
dispatcherTimer = null; dispatcherTimer = null;
this.Close(); this.Close();
} }
@ -651,14 +649,12 @@ namespace eDosStation
else ShowAndEnd(null,null); else ShowAndEnd(null,null);
} }
} }
private void ShowAndEnd(object sender, EventArgs e) private void ShowAndEnd(object sender, EventArgs e)
{ {
dispatcherTimer?.Stop(); dispatcherTimer?.Stop();
dispatcherTimer = null; dispatcherTimer = null;
endPage(); endPage();
} }
private void CountDown(object sender, EventArgs e) private void CountDown(object sender, EventArgs e)
{ {
double v = (ResultTime - DateTime.Now).TotalSeconds; double v = (ResultTime - DateTime.Now).TotalSeconds;

View file

@ -62,7 +62,7 @@
<TextBlock Grid.Row="1" Grid.Column="2" Text="Visit:" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,5,20,5" Foreground="{DynamicResource sckbP}" FontWeight="Bold" /> <TextBlock Grid.Row="1" Grid.Column="2" Text="Visit:" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,5,20,5" Foreground="{DynamicResource sckbP}" FontWeight="Bold" />
<TextBlock Grid.Row="1" Grid.Column="3" Name= "EpdVisit" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,5,20,5" Text="12345545" Foreground="{DynamicResource sckbP}" /> <TextBlock Grid.Row="1" Grid.Column="3" Name= "EpdVisit" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,5,20,5" Text="12345545" Foreground="{DynamicResource sckbP}" />
<TextBlock Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="4" Name="Name" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="50,5,20,5" Text="...." Foreground="{DynamicResource sckbP}" /> <TextBlock Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="4" Name="PersonName" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="50,5,20,5" Text="...." Foreground="{DynamicResource sckbP}" />
<TextBlock Grid.Row="3" Grid.Column="0" Text="Dose:" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,5,20,5" Foreground="{DynamicResource sckbP}" FontWeight="Bold" /> <TextBlock Grid.Row="3" Grid.Column="0" Text="Dose:" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,5,20,5" Foreground="{DynamicResource sckbP}" FontWeight="Bold" />
<StackPanel Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3" Orientation="Vertical" VerticalAlignment="Center" Name="DosePanel" > <StackPanel Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3" Orientation="Vertical" VerticalAlignment="Center" Name="DosePanel" >

View file

@ -27,8 +27,6 @@ namespace eDosStation
thisStation = curStation; thisStation = curStation;
dataInterface = curStation.dataInterface; dataInterface = curStation.dataInterface;
} }
private void CountDown(object sender, EventArgs e) private void CountDown(object sender, EventArgs e)
@ -61,7 +59,6 @@ namespace eDosStation
EpdReading = false; EpdReading = false;
dispatcherTimer?.Stop(); dispatcherTimer?.Stop();
Dispatcher.InvokeAsync(() => LoadDoses()); Dispatcher.InvokeAsync(() => LoadDoses());
} }
private void startEPDRead() private void startEPDRead()
@ -115,7 +112,7 @@ namespace eDosStation
{ {
Dispatcher.InvokeAsync(() => Dispatcher.InvokeAsync(() =>
{ {
rv = ep.SetDeIssued(); //rv = ep.SetDeIssued();
endWithMessage("This EPD is not issued"); endWithMessage("This EPD is not issued");
}); });
return; return;
@ -126,9 +123,10 @@ namespace eDosStation
return; return;
} }
if (int.TryParse(ep.WearerID, out EpdVisitID) && EpdVisitID % 100 != thisStation.ID_Station) int station = EpdVisitID % 100;
if (int.TryParse(ep.WearerID, out EpdVisitID) && station != thisStation.ID_Station)
{ {
endWithMessage($"This EPD was issued on another station (ID:{EpdVisitID % 100})"); endWithMessage($"This EPD was issued on another station (ID:{station})");
return; return;
} }
@ -137,11 +135,10 @@ namespace eDosStation
int Exited = dataInterface.VisitInfo(EpdVisitID, out WearerFullName); int Exited = dataInterface.VisitInfo(EpdVisitID, out WearerFullName);
if (Exited>0) if (Exited>0)
{ {
endWithMessage($"This EPD was already returned or had a manual exit (ID:{EpdVisitID % 100})"); endWithMessage($"This EPD was already returned or had a manual exit (ID:{station})");
return; return;
} }
//bool NoTimeout = false; //bool NoTimeout = false;
if (ep.alarmStatus != 0) if (ep.alarmStatus != 0)
@ -162,9 +159,9 @@ namespace eDosStation
ok.IsSelected = true; ok.IsSelected = true;
} }
rv = ep.GetAllDeissue(); rv = ep.GetAllDeissue(true); //reconnect
if (rv != 0) if (rv != 0)
MessageBox.Show($"GetDoses {rv} er:{ep.GetDosesError}"); MessageBox.Show($"GetDoses {rv} rv:{ep.ErrorRV} step:{ep.ErrorStep} er:{ep.GetDosesError}");
Wearer.Text = $"{ep.WearerName}"; Wearer.Text = $"{ep.WearerName}";
Wearer.Name = WearerFullName; Wearer.Name = WearerFullName;
@ -190,7 +187,7 @@ namespace eDosStation
} }
l.Dispose(); l.Dispose();
} }
Name.Text = ""; PersonName.Text = string.Empty;
return; return;
} }
@ -215,19 +212,17 @@ namespace eDosStation
catch (System.Exception ex) catch (System.Exception ex)
{ {
thisStation.splunkLog.WriteException(null, "StartEpd", ex); thisStation.splunkLog.WriteException(null, "StartEpd", ex);
MessageBox.Show($"{ex.Message}"); MessageBox.Show(ex.Message);
ep = null; ep = null;
} }
if (ep != null)
if (ep!=null)
{ {
ResultTime = DateTime.Now.AddSeconds(thisStation.ScreenEPDTimeout); ResultTime = DateTime.Now.AddSeconds(thisStation.ScreenEPDTimeout);
Progress.Value= Progress.Maximum = thisStation.ScreenEPDTimeout; Progress.Value = Progress.Maximum = thisStation.ScreenEPDTimeout;
dispatcherTimer.Start(); dispatcherTimer.Start();
startEPDRead(); startEPDRead();
} }
} }
private void BCloseExit_Click(object sender, RoutedEventArgs e) private void BCloseExit_Click(object sender, RoutedEventArgs e)

View file

@ -10,6 +10,7 @@ namespace eDosStation
/// </summary> /// </summary>
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
const string className = "MainWindow";
public DataInterface dataInterface; public DataInterface dataInterface;
public Station thisStation; public Station thisStation;
DispatcherTimer bgTimer; DispatcherTimer bgTimer;
@ -25,10 +26,10 @@ namespace eDosStation
private void Button_Click(object sender, RoutedEventArgs e) private void Button_Click(object sender, RoutedEventArgs e)
{ {
string ers = string.Empty; string ers = string.Empty;
if (thisStation.RestartCom && (thisStation.RestartComFirst == true)) if (thisStation.RestartCom && (thisStation.RestartComFirst == true))
{ {
ers = devcon.Restart(); thisStation.DeviceRestart();
if (!string.IsNullOrEmpty(ers)) thisStation.splunkLog?.WriteSplunkLog("Restart USB error", LSWLib.CLog.iseverity.err, null, ers); ;
} }
var w = new ShowEPDDose(thisStation); var w = new ShowEPDDose(thisStation);
@ -36,64 +37,65 @@ namespace eDosStation
if (thisStation.RestartCom && (thisStation.RestartComFirst == true)) if (thisStation.RestartCom && (thisStation.RestartComFirst == true))
{ {
ers = devcon.Restart(); thisStation.DeviceRestart();
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); thisStation.splunkLog?.WriteSplunkLog("Show Dose done", LSWLib.CLog.iseverity.info);
} }
private void BEntry_Click(object sender, RoutedEventArgs e) private void BEntry_Click(object sender, RoutedEventArgs e)
{ {
const string module = "BEntry_Click";
string ers = string.Empty; string ers = string.Empty;
thisStation.splunkLog?.WriteSplunkLog("Entry", LSWLib.CLog.iseverity.info); thisStation.splunkLog?.WriteSplunkLog(module, LSWLib.CLog.iseverity.info);
string step = "DeviceRestart";
try try
{ {
if (thisStation.RestartCom && (thisStation.RestartComFirst == true)) if (thisStation.RestartCom && (thisStation.RestartComFirst == true))
{ {
ers = devcon.Restart(); thisStation.DeviceRestart();
if (!string.IsNullOrEmpty(ers)) thisStation.splunkLog?.WriteSplunkLog("Restart USB error", LSWLib.CLog.iseverity.err, null, ers); ;
} }
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
thisStation.splunkLog.WriteException(null, "Devcon, rqstart 2", ex); thisStation.splunkLog?.WriteException(module, step, ex);
} }
step = "EntryBadge";
try try
{ {
var w = new EntryBadge(thisStation); var w = new EntryBadge(thisStation);
w.ShowDialog(); w.ShowDialog();
#if SimulateEPD #if SimulateEPD
simulData = w.simulData; simulData = w.simulData;
#endif #endif
w = null; w = null;
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
thisStation.splunkLog.WriteException(null, "Start entry", ex); thisStation.splunkLog?.WriteException(module, step, ex);
} }
step = "DeviceReset2";
try try
{ {
if (thisStation.RestartCom && !(thisStation.RestartComFirst == true)) if (thisStation.RestartCom && !(thisStation.RestartComFirst == true))
{ {
ers = devcon.Restart(); thisStation.DeviceRestart();
if (!string.IsNullOrEmpty(ers)) thisStation.splunkLog?.WriteSplunkLog("Restart USB error", LSWLib.CLog.iseverity.err, null, ers); ;
} }
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
thisStation.splunkLog.WriteException(null, "Devcon, rqstart 2", ex); thisStation.splunkLog.WriteException(module, step, ex);
} }
thisStation.splunkLog?.WriteSplunkLog("Entry done", LSWLib.CLog.iseverity.info); thisStation.splunkLog?.WriteSplunkLog("Entry done", LSWLib.CLog.iseverity.info);
} }
private void BExit_Click(object sender, RoutedEventArgs e) private void BExit_Click(object sender, RoutedEventArgs e)
{ {
const string module = "BExit_Click";
string ers = string.Empty; string ers = string.Empty;
thisStation.splunkLog?.WriteSplunkLog("Exit", LSWLib.CLog.iseverity.info); thisStation.splunkLog?.WriteSplunkLog(module, LSWLib.CLog.iseverity.info);
if (thisStation.RestartCom && thisStation.RestartComFirst==true) if (thisStation.RestartCom && thisStation.RestartComFirst)
{ {
ers = devcon.Restart(); ers = thisStation.DeviceRestart();
if (!string.IsNullOrEmpty(ers)) thisStation?.splunkLog.WriteSplunkLog("Restart USB error", LSWLib.CLog.iseverity.err, null, ers); ;
} }
var w = new EpdExit(thisStation); var w = new EpdExit(thisStation);
@ -102,17 +104,23 @@ namespace eDosStation
#endif #endif
w.ShowDialog(); w.ShowDialog();
w = null; w = null;
if (thisStation.RestartCom && !(thisStation.RestartComFirst==true)) if (thisStation.RestartCom && !(thisStation.RestartComFirst))
{ {
ers = devcon.Restart(); ers = thisStation.DeviceRestart();
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); thisStation.splunkLog?.WriteSplunkLog("Exit Done", LSWLib.CLog.iseverity.info);
} }
private void MenuItem_Click(object sender, RoutedEventArgs e) private void MenuItem_Click(object sender, RoutedEventArgs e)
{ {
Settings s = new Settings(thisStation); const string module = "MenuSettings";
s.ShowDialog(); try
{
var s = new Settings(thisStation);
s.ShowDialog();
} catch (System.Exception ex)
{
thisStation?.splunkLog?.WriteException(className, module, ex);
}
} }
private void setLocalStatus() private void setLocalStatus()
{ {

View file

@ -51,5 +51,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.14.0.0")] [assembly: AssemblyVersion("2.15.0.0")]
[assembly: AssemblyFileVersion("2.14.0.0")] [assembly: AssemblyFileVersion("2.15.0.0")]

View file

@ -1 +1 @@
Thu 05/16/2024 15:51:50.20 Fri 05/24/2024 15:12:34.56

View file

@ -15,7 +15,7 @@ namespace eDosStation
public byte Value { get; set; } public byte Value { get; set; }
public beepclass(string txt, byte val) public beepclass(string txt, byte val)
{ {
Text = txt; Value = val; Text = txt; Value = val;
} }
} }
@ -24,78 +24,142 @@ namespace eDosStation
public string Text { get; set; } public string Text { get; set; }
public readerclass(string txt) public readerclass(string txt)
{ {
Text = txt; Text = txt;
} }
} }
public partial class Settings : Window public partial class Settings : Window
{ {
public LSWDesfirePublic.CCard dfReader = null; const string className = "Settings";
private System.Threading.Tasks.Task ReaderTask = null; //private System.Threading.Tasks.Task ReaderTask;
User _User; //User _User;
Station thisStation; Station thisStation;
ObservableCollection<beepclass> beepValues = new ObservableCollection<beepclass>(); ObservableCollection<beepclass> beepValues;
ObservableCollection<readerclass> readerValues = new ObservableCollection<readerclass>(); ObservableCollection<readerclass> readerValues;
public Settings( Station tStation) public Settings(Station tStation)
{ {
thisStation = tStation; try
InitializeComponent(); {
//_User = null;
thisStation = null;
//dfReader = null; ReaderTask = null;
beepValues = new ObservableCollection<beepclass>();
readerValues = new ObservableCollection<readerclass>();
InitializeComponent();
if (tStation != null) thisStation = tStation;
if (tStation != null) tStation.splunkLog?.WriteSplunkLog(className, LSWLib.CLog.iseverity.info, "created");
}
catch (System.Exception ex)
{
if (tStation != null) tStation.splunkLog?.WriteException(className, className, ex);
}
} }
private void BOK_Click(object sender, RoutedEventArgs e) private void BOK_Click(object sender, RoutedEventArgs e)
{ {
string thiscom = cComPort.SelectedItem.ToString().Replace("COM",""); const string module = "BOK_Click";
thisStation.ComPort = int.Parse(thiscom); string step="init";
try
DataSet1.InstallationRow ir = CIns1.SelectedItem as DataSet1.InstallationRow;
thisStation.Inst_CODE1 = ir.Inst_CODE;
thisStation.Inst_Name1 = ir.InstallationName;
ir = CIns2.SelectedItem as DataSet1.InstallationRow;
thisStation.Inst_CODE2 = ir.Inst_CODE;
thisStation.Inst_Name2 = ir.InstallationName;
thisStation.useBeep = (byte)tBeep.SelectedValue;
if (cbValidation.IsChecked == null) cbValidation.IsChecked = false;
thisStation.useTestButtons = cbValidation.IsChecked.Value;
thisStation.Reader = (string)cbReaders.SelectedValue;
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.AllowMultipleEPD = cbAllowMultipleEPD.IsChecked != null ? cbAllowMultipleEPD.IsChecked.Value : false;
//thisStation.WriteConfig32 = cbWriteConfig32.IsChecked != null ? cbWriteConfig32.IsChecked.Value : false;
thisStation.Update();
this.Close();
if (thisStation.Error > 0)
{ {
MessageBox.Show($"Error {thisStation.ErrorMessage}"); step = "comport";
string thiscom = cComPort.SelectedItem.ToString().Replace("COM", string.Empty);
thisStation.ComPort = int.Parse(thiscom);
DataSet1.InstallationRow ir;
step = "code1";
ir = CIns1.SelectedItem as DataSet1.InstallationRow;
if (ir != null)
{
thisStation.Inst_CODE1 = ir.Inst_CODE;
thisStation.Inst_Name1 = ir.InstallationName;
} else
{
thisStation.Inst_CODE1 = 0;
thisStation.Inst_Name1 = string.Empty;
}
step = "code2";
ir = CIns2.SelectedItem as DataSet1.InstallationRow;
if (ir != null)
{
thisStation.Inst_CODE2 = ir.Inst_CODE;
thisStation.Inst_Name2 = ir.InstallationName;
}
else
{
thisStation.Inst_CODE2 = 0;
thisStation.Inst_Name2 = string.Empty;
}
step = "usebeep";
if (tBeep.HasItems && tBeep.SelectedIndex != -1) {
thisStation.useBeep = (byte)tBeep.SelectedValue;
} else
thisStation.useBeep = (byte)0b00011110;
step = "validation++";
if (cbValidation.IsChecked == null) cbValidation.IsChecked = false;
thisStation.useTestButtons = cbValidation.IsChecked.Value;
step = "Reader";
thisStation.Reader = (string)cbReaders.SelectedValue;
step = "checkUser";
thisStation.checkUser = cbCheckUsers.IsChecked != null ? cbCheckUsers.IsChecked.Value : false;
thisStation.RestartCom = cbRestartCom.IsChecked != null ? cbRestartCom.IsChecked.Value : false;
step = "EPDTimeOut";
thisStation.EPDTimeOut = int.Parse(tEPDTimeout.Text);
step = "OnlyMK2";
thisStation.OnlyMK2 = cbOnlyMK2.IsChecked != null ? cbOnlyMK2.IsChecked.Value : false;
step = "RestartComFirst";
thisStation.RestartComFirst = cbRestartComFirst.IsChecked != null ? cbRestartComFirst.IsChecked.Value : false;
step = "AllowMultipleEPD";
thisStation.AllowMultipleEPD = cbAllowMultipleEPD.IsChecked != null ? cbAllowMultipleEPD.IsChecked.Value : false;
//thisStation.WriteConfig32 = cbWriteConfig32.IsChecked != null ? cbWriteConfig32.IsChecked.Value : false;
step = "Update";
thisStation.Update();
if (thisStation.Error > 0)
{
thisStation?.splunkLog?.WriteSplunkLog(module, LSWLib.CLog.iseverity.err, thisStation.ErrorMessage);
MessageBox.Show($"Error {thisStation.ErrorMessage}");
}
} }
catch (System.Exception ex)
{
thisStation?.splunkLog?.WriteException(module, step, ex);
}
thisStation?.splunkLog?.WriteSplunkLog(module, LSWLib.CLog.iseverity.info, "done");
this.Close();
} }
private void BCancel_Click(object sender, RoutedEventArgs e) private void BCancel_Click(object sender, RoutedEventArgs e)
{ {
const string module = "BCancel_Click";
thisStation?.splunkLog?.WriteSplunkLog(module, LSWLib.CLog.iseverity.info, "saved");
this.Close(); this.Close();
} }
private void Window_Loaded(object sender, RoutedEventArgs e) private void Window_Loaded(object sender, RoutedEventArgs e)
{ {
string step = "devcon";
string eDosCom = null; string eDosCom = null;
try try
{ {
eDosCom = devcon.FindEdosCom(); eDosCom = thisStation?.find();
thisStation.splunkLog?.WriteSplunkLog(step, LSWLib.CLog.iseverity.info, eDosCom);
} }
catch { } catch (System.Exception ex)
{
thisStation?.splunkLog?.WriteException(className, step, ex);
}
step = "GetReaderList";
try try
{ {
using (var a = new LSWDesfirePublic.CCard()) using (var a = new LSWDesfirePublic.CCard())
{ {
a.GetReaderList(); a.GetReaderList();
@ -103,30 +167,46 @@ namespace eDosStation
} }
cbReaders.ItemsSource = readerValues; cbReaders.ItemsSource = readerValues;
cbReaders.SelectedValue = thisStation.Reader; cbReaders.SelectedValue = thisStation.Reader;
} catch (System.Exception ex) thisStation.splunkLog?.WriteSplunkLog(step, LSWLib.CLog.iseverity.info);
{
MessageBox.Show($"Readers err {ex.Message}");
}
try {
foreach (string cn in System.IO.Ports.SerialPort.GetPortNames())
{
cComPort.Items.Add(cn);
}
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
MessageBox.Show($"Serial err {ex.Message}"); thisStation?.splunkLog?.WriteException(className, step, ex);
MessageBox.Show($"Readers err {ex.Message}");
} }
beepValues.Add(new beepclass("Loud High freq Beep" , 0b00010111 )); step = "GetPortNames";
beepValues.Add(new beepclass("Loud Low freq Beep" , 0b00011111 )); try
beepValues.Add(new beepclass("Normal High freq Beep", 0b00010110 )); {
beepValues.Add(new beepclass("Normal Low freq Beep" , 0b00011110 )); foreach (string cn in System.IO.Ports.SerialPort.GetPortNames())
beepValues.Add(new beepclass("No Beep (only led)" , 0b00011010 )); {
cComPort.Items.Add(cn);
}
thisStation.splunkLog?.WriteSplunkLog(step, LSWLib.CLog.iseverity.info);
}
catch (System.Exception ex)
{
thisStation?.splunkLog?.WriteException(className, step, ex);
MessageBox.Show($"Serial err {ex.Message}");
}
step = "BeepValues";
try
{
beepValues.Add(new beepclass("Loud High freq Beep", 0b00010111));
beepValues.Add(new beepclass("Loud Low freq Beep", 0b00011111));
beepValues.Add(new beepclass("Normal High freq Beep", 0b00010110));
beepValues.Add(new beepclass("Normal Low freq Beep", 0b00011110));
beepValues.Add(new beepclass("No Beep (only led)", 0b00011010));
tBeep.ItemsSource = beepValues;
thisStation.splunkLog?.WriteSplunkLog(step, LSWLib.CLog.iseverity.info);
}
catch (System.Exception ex)
{
thisStation?.splunkLog?.WriteException(className, step, ex);
MessageBox.Show($"Serial err {ex.Message}");
}
// 7 6 5 4 3210 // 7 6 5 4 3210
// 1 0 0 1 1 1 0 0 1 1 1 0 0001 // 1 0 0 1 1 1 0 0 1 1 1 0 0001
@ -160,17 +240,28 @@ namespace eDosStation
//beepValues.Add(new beepclass("Beep", 22)); //beepValues.Add(new beepclass("Beep", 22));
//beepValues.Add(new beepclass("No Beep", 18)); //beepValues.Add(new beepclass("No Beep", 18));
tBeep.ItemsSource = beepValues;
string thisComport = $"COM{thisStation.ComPort}"; step = "Select com";
if (!string.IsNullOrEmpty(eDosCom)) thisComport = eDosCom; try
if (!cComPort.Items.Contains(thisComport)) cComPort.Items.Add(thisComport); {
cComPort.SelectedItem = thisComport; string thisComport = $"COM{thisStation.ComPort}";
if (!string.IsNullOrEmpty(eDosCom)) thisComport = eDosCom;
if (!cComPort.Items.Contains(thisComport)) cComPort.Items.Add(thisComport);
cComPort.SelectedItem = thisComport;
thisStation.splunkLog?.WriteSplunkLog(step, LSWLib.CLog.iseverity.info);
}
catch (System.Exception ex)
{
thisStation?.splunkLog?.WriteException(className, step, ex);
MessageBox.Show($"Serial err {ex.Message}");
}
try { step = "tbInstallations";
DataSet1.InstallationDataTable tbInstallations; try
using (var ta = new DataSet1TableAdapters.InstallationTableAdapter()) {
tbInstallations = ta.GetData(); DataSet1.InstallationDataTable tbInstallations;
using (var ta = new DataSet1TableAdapters.InstallationTableAdapter())
tbInstallations = ta.GetData();
tbInstallations.AddInstallationRow(0, "-"); tbInstallations.AddInstallationRow(0, "-");
foreach (DataSet1.InstallationRow r in tbInstallations.Rows) foreach (DataSet1.InstallationRow r in tbInstallations.Rows)
{ {
@ -179,112 +270,123 @@ namespace eDosStation
} }
CIns1.SelectedValue = thisStation.Inst_CODE1; CIns1.SelectedValue = thisStation.Inst_CODE1;
CIns2.SelectedValue = thisStation.Inst_CODE2; CIns2.SelectedValue = thisStation.Inst_CODE2;
thisStation.splunkLog?.WriteSplunkLog(step, LSWLib.CLog.iseverity.info);
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
MessageBox.Show($"SerINstallations err {ex.Message}"); thisStation?.splunkLog?.WriteException(className, step, ex);
MessageBox.Show($"SetINstallations err {ex.Message}");
} }
step = "setCheckBoxes";
try try
{ {
tBeep.SelectedValue = thisStation.useBeep; tBeep.SelectedValue = thisStation.useBeep;
cbValidation.IsChecked = thisStation.useTestButtons; cbValidation.IsChecked = thisStation.useTestButtons;
cbCheckUsers.IsChecked= thisStation.checkUser; cbCheckUsers.IsChecked = thisStation.checkUser;
cbRestartCom.IsChecked = thisStation.RestartCom; cbRestartCom.IsChecked = thisStation.RestartCom;
tEPDTimeout.Text = thisStation.EPDTimeOut.ToString(); tEPDTimeout.Text = thisStation.EPDTimeOut.ToString();
cbRestartComFirst.IsChecked = thisStation.RestartComFirst; cbRestartComFirst.IsChecked = thisStation.RestartComFirst;
cbOnlyMK2.IsChecked = thisStation.OnlyMK2; cbOnlyMK2.IsChecked = thisStation.OnlyMK2;
cbAllowMultipleEPD.IsChecked = thisStation.AllowMultipleEPD; cbAllowMultipleEPD.IsChecked = thisStation.AllowMultipleEPD;
thisStation.splunkLog?.WriteSplunkLog(step, LSWLib.CLog.iseverity.info);
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
thisStation?.splunkLog?.WriteException(className, step, ex);
MessageBox.Show($"Settings err {ex.Message}"); MessageBox.Show($"Settings err {ex.Message}");
} }
try { step = "CheckCon";
try
{
bool rv = thisStation.dataInterface.checkCon(false); bool rv = thisStation.dataInterface.checkCon(false);
thisStation.splunkLog?.WriteSplunkLog(step, LSWLib.CLog.iseverity.info);
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
thisStation?.splunkLog?.WriteException(className, step, ex);
MessageBox.Show($"Interface check {ex.Message}"); MessageBox.Show($"Interface check {ex.Message}");
} }
//StartReader(); step = "endLoaded";
thisStation?.splunkLog?.WriteSplunkLog(step, LSWLib.CLog.iseverity.info);
} }
#region BadgeReader #region BadgeReader
public void StartReader() //public void StartReader()
{ //{
if (dfReader == null) // if (dfReader == null)
{ // {
dfReader = new LSWDesfirePublic.CCard(); // dfReader = new LSWDesfirePublic.CCard();
dfReader.GetReaderList(); // dfReader.GetReaderList();
if (dfReader.readersList.Contains(thisStation.Reader)) // if (dfReader.readersList.Contains(thisStation.Reader))
{ // {
dfReader.SetReader(thisStation.Reader); // dfReader.SetReader(thisStation.Reader);
dfReader.Badged += DFReader_Badged; // dfReader.Badged += DFReader_Badged;
dfReader.BadgeTO += DfReader_BadgeTO; // dfReader.BadgeTO += DfReader_BadgeTO;
dfReader.BadgeError += DfReader_BadgeError; // dfReader.BadgeError += DfReader_BadgeError;
ReaderTask = dfReader.Wait(5000, 10); // ReaderTask = dfReader.Wait(5000, 10);
} // }
else // else
{ // {
StringBuilder er = new StringBuilder($"Badgelezer \"{thisStation.Reader}\" niet gevonden!.\nDeze lezers zijn beschikbaar:\n"); // StringBuilder er = new StringBuilder($"Badgelezer \"{thisStation.Reader}\" niet gevonden!.\nDeze lezers zijn beschikbaar:\n");
dfReader.GetReaderList(); // dfReader.GetReaderList();
foreach (string r in dfReader.readersList) er.AppendLine($"-> {r}"); // foreach (string r in dfReader.readersList) er.AppendLine($"-> {r}");
MessageBox.Show(er.ToString(), "Badge Lezer", MessageBoxButton.OK, MessageBoxImage.Exclamation); // MessageBox.Show(er.ToString(), "Badge Lezer", MessageBoxButton.OK, MessageBoxImage.Exclamation);
dfReader.Dispose(); dfReader = null; // dfReader.Dispose(); dfReader = null;
} // }
} // }
} //}
void CheckBadge() //void CheckBadge()
{ //{
thisStation.splunkLog?.KvSet(LSWLib.CLog.skeys.persID, _User.PersID); // thisStation.splunkLog?.KvSet(LSWLib.CLog.skeys.persID, _User.PersID);
thisStation.splunkLog?.WriteSplunkLog("CheckBadge", LSWLib.CLog.iseverity.info, _User.PersID.ToString(), null); // thisStation.splunkLog?.WriteSplunkLog("CheckBadge", LSWLib.CLog.iseverity.info, _User.PersID.ToString(), null);
//Dispatcher.InvokeAsync(() => { ShowUserInfo(); }); // //Dispatcher.InvokeAsync(() => { ShowUserInfo(); });
} //}
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();
_User = thisStation.dataInterface.GetUser(null, persID.ToString(), true); // _User = thisStation.dataInterface.GetUser(null, persID.ToString(), true);
Dispatcher.InvokeAsync(CheckBadge, DispatcherPriority.Normal); // Dispatcher.InvokeAsync(CheckBadge, DispatcherPriority.Normal);
} //}
private void DfReader_BadgeError(LSWDesfirePublic.CCard Sender, LSWDesfirePublic.BadgeErrorEventArgs e) //private void DfReader_BadgeError(LSWDesfirePublic.CCard Sender, LSWDesfirePublic.BadgeErrorEventArgs e)
{ //{
// endPage(); // // endPage();
} //}
private void DfReader_BadgeTO(LSWDesfirePublic.CCard Sender, EventArgs e) //private void DfReader_BadgeTO(LSWDesfirePublic.CCard Sender, EventArgs e)
{ //{
//this.Dispatcher.InvokeAsync(new Action(() => endPage()), DispatcherPriority.Normal); // //this.Dispatcher.InvokeAsync(new Action(() => endPage()), DispatcherPriority.Normal);
} //}
private void DFReader_Badged(LSWDesfirePublic.CCard Sender, LSWDesfirePublic.BadgeEventArgs e) //private void DFReader_Badged(LSWDesfirePublic.CCard Sender, LSWDesfirePublic.BadgeEventArgs e)
{ //{
if (e.PersID > 0) // if (e.PersID > 0)
this.Dispatcher.InvokeAsync(new Action(() => showBadge(e.PersID, e.UID)), DispatcherPriority.Background); // this.Dispatcher.InvokeAsync(new Action(() => showBadge(e.PersID, e.UID)), DispatcherPriority.Background);
else // else
{ // {
string msg = $"No PersID found on badge {e.UID}"; // string msg = $"No PersID found on badge {e.UID}";
MessageBox.Show(msg, "Error", MessageBoxButton.OK); // MessageBox.Show(msg, "Error", MessageBoxButton.OK);
thisStation.splunkLog?.WriteSplunkLog("Badged", LSWLib.CLog.iseverity.warning, null, msg); // thisStation.splunkLog?.WriteSplunkLog("Badged", LSWLib.CLog.iseverity.warning, null, msg);
} // }
} //}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) //private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{ //{
//try // //try
//{ // //{
// if (dfReader != null ) // // if (dfReader != null )
// { // // {
// dfReader.WaitEnd(); // // dfReader.WaitEnd();
// System.Threading.Thread.Sleep(2000); // // System.Threading.Thread.Sleep(2000);
// dfReader.Dispose(); // // dfReader.Dispose();
// dfReader = null; // // dfReader = null;
// } // // }
//} // //}
//catch (System.Exception ex) // //catch (System.Exception ex)
//{ // //{
// System.Diagnostics.Debug.WriteLine(ex.Message); // // System.Diagnostics.Debug.WriteLine(ex.Message);
//} // //}
} //}
#endregion #endregion
} }
} }

View file

@ -25,6 +25,8 @@ namespace eDosStation
{ {
InitializeComponent(); InitializeComponent();
thisStation = curStation; thisStation = curStation;
EpdReading = false;
FinalTimeOut = false;
EntryState = eEntryState.none; EntryState = eEntryState.none;
} }
@ -43,6 +45,7 @@ namespace eDosStation
} }
} }
#region EPD Callback
private void Ep_EpdTO(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdTOEventArgs e) private void Ep_EpdTO(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdTOEventArgs e)
{ {
System.Diagnostics.Debug.WriteLine("TIME OUT"); System.Diagnostics.Debug.WriteLine("TIME OUT");
@ -53,17 +56,20 @@ namespace eDosStation
{ {
System.Diagnostics.Debug.WriteLine("ERROR "); System.Diagnostics.Debug.WriteLine("ERROR ");
Dispatcher.InvokeAsync(() => { Dispatcher.InvokeAsync(() => {
MessageBox.Show($"EPD Error {e.returnValue}"); MessageBox.Show($"EPD Error {e.returnValue} {e.ErrorRV} {e.ErrorStep}");
Dispatcher.InvokeAsync(() => { SetTimedOutAndEnd(); }); Dispatcher.InvokeAsync(() => { SetTimedOutAndEnd(); });
}); });
} }
private void Ep_EpdRead(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdEventArgs e) private void Ep_EpdRead(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdEventArgs e)
{ {
EpdReading = false; dispatcherTimer?.Stop(); EpdReading = false;
dispatcherTimer?.Stop();
Dispatcher.InvokeAsync(() => LoadDoses()); Dispatcher.InvokeAsync(() => LoadDoses());
} }
#endregion
private void LoadDoses() private void LoadDoses()
{ {
int rv = 0; int rv = 0;
@ -82,7 +88,7 @@ namespace eDosStation
{ {
hasAlarm.Text = "Yes"; hasAlarm.Text = "Yes";
} else } else
hasAlarm.Text = "no"; hasAlarm.Text = "No";
epdid.Text = ep.EpdID.ToString(); epdid.Text = ep.EpdID.ToString();
var stype = new StringBuilder(); var stype = new StringBuilder();

View file

@ -41,6 +41,13 @@ namespace eDosStation
public double InfoScreenTimeout { get; internal set; } public double InfoScreenTimeout { get; internal set; }
public bool WriteConfig32 { get; internal set; } public bool WriteConfig32 { get; internal set; }
public const int defInst_CODE1 = 1;
public const int defInst_CODE2 = 11;
public const string defInst_Name1 = "BR1";
public const string defInst_Name2 = "Venus";
public cDevCon DevCon;
public bool Changed = false; public bool Changed = false;
public int Error = 0; public int Error = 0;
public string ErrorMessage; public string ErrorMessage;
@ -63,10 +70,10 @@ namespace eDosStation
Error = 0; Error = 0;
ErrorMessage = string.Empty; ErrorMessage = string.Empty;
ComPort = 0; ComPort = 0;
Inst_CODE1 = 1; Inst_CODE1 = defInst_CODE1;
Inst_CODE2 = 11; Inst_CODE2 = defInst_CODE2;
Inst_Name1 = "BR1"; Inst_Name1 = defInst_Name1;
Inst_Name2 = "Venus"; Inst_Name2 = defInst_Name2;
TestCSN = System.Configuration.ConfigurationManager.AppSettings["TestCSN"]; TestCSN = System.Configuration.ConfigurationManager.AppSettings["TestCSN"];
TestCode = System.Configuration.ConfigurationManager.AppSettings["TestCode"]; TestCode = System.Configuration.ConfigurationManager.AppSettings["TestCode"];
insComments = new StringBuilder(); insComments = new StringBuilder();
@ -121,7 +128,7 @@ namespace eDosStation
RestartComFirst = rs.BoolOrDefault("RestartComFirst", false); RestartComFirst = rs.BoolOrDefault("RestartComFirst", false);
OnlyMK2 = rs.BoolOrDefault("OnlyMK2", false); OnlyMK2 = rs.BoolOrDefault("OnlyMK2", false);
AllowMultipleEPD = rs.BoolOrDefault("AllowMultipleEPD", false); AllowMultipleEPD = rs.BoolOrDefault("AllowMultipleEPD", false);
WriteConfig32 = false; // rs.BoolOrDefault("WriteConfig32", false); WriteConfig32 = true; // rs.BoolOrDefault("WriteConfig32", false);
} }
else else
{ {
@ -138,7 +145,7 @@ namespace eDosStation
EPDTimeOut = 10000; EPDTimeOut = 10000;
EPDRetries = 2; EPDRetries = 2;
AllowMultipleEPD = false; AllowMultipleEPD = false;
WriteConfig32 = false; WriteConfig32 = true;
} }
rs.Close(); rs.Close();
splunkLog.WriteSplunkLog("StationInit", spl1.iseverity.info); splunkLog.WriteSplunkLog("StationInit", spl1.iseverity.info);
@ -193,12 +200,11 @@ namespace eDosStation
} }
co?.Close(); co?.Close();
} }
DevCon = new cDevCon(ComPort, splunkLog);
} }
private void CmdSetParams(SqlCommand cmd) private void CmdSetParams(SqlCommand cmd)
{ {
//for (int ix = 0; ix < cmd.Parameters.Count; ix++)
// System.Diagnostics.Debug.WriteLine(cmd.Parameters[ix].ParameterName);
try try
{ {
cmd.SetIfExists("ComPort", ComPort); cmd.SetIfExists("ComPort", ComPort);
@ -228,10 +234,10 @@ namespace eDosStation
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
splunkLog.WriteException("Station", "SetParams", ex); splunkLog?.WriteException("Station", "SetParams", ex);
Error = 1; Error = 1;
ErrorMessage = ex.Message; ErrorMessage = ex.Message;
if (stationLog != null) stationLog.WriteLine($"GetStationSettings error {ex.Message} {System.DateTime.Now}"); stationLog?.WriteLine($"GetStationSettings error {ex.Message} {System.DateTime.Now}");
} }
} }
private void UpdateToDb(SqlConnection co, SqlCommand cmd) private void UpdateToDb(SqlConnection co, SqlCommand cmd)
@ -243,14 +249,15 @@ namespace eDosStation
cmd.Parameters.Clear(); cmd.Parameters.Clear();
SqlCommandBuilder.DeriveParameters(cmd); SqlCommandBuilder.DeriveParameters(cmd);
CmdSetParams(cmd); CmdSetParams(cmd);
splunkLog.KvAddCommand(spl1.skeys.sqlQuery, cmd); splunkLog?.KvAddCommand(spl1.skeys.sqlQuery, cmd);
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
splunkLog?.WriteSplunkLog(taskName,spl1.iseverity.info);
} }
catch (System.Exception ex) { catch (System.Exception ex) {
splunkLog.WriteException(moduleName, taskName, ex); splunkLog?.WriteException(moduleName, taskName, ex);
if (stationLog != null) stationLog.WriteLine($"{taskName} error {ex.Message} co {co.DataSource} {System.DateTime.Now}"); stationLog?.WriteLine($"{taskName} error {ex.Message} co {co.DataSource} {System.DateTime.Now}");
} }
splunkLog.KvClear(); splunkLog?.KvClear();
} }
public void Update() public void Update()
{ {
@ -262,26 +269,46 @@ namespace eDosStation
try try
{ {
co = dataInterface.getCon(true); co = dataInterface.getCon(true);
splunkLog.KvAddCommand(spl1.skeys.sqlQuery,cmd); splunkLog?.KvAddCommand(spl1.skeys.sqlQuery,cmd);
UpdateToDb(co, cmd); UpdateToDb(co, cmd);
co.Close(); co.Close();
co = dataInterface.getConCentral(true); co = dataInterface.getConCentral(true);
splunkLog.KvClear(spl1.skeys.sqlQuery); splunkLog?.KvClear(spl1.skeys.sqlQuery);
splunkLog.KvAddCommand(spl1.skeys.sqlQuery, cmd); splunkLog?.KvAddCommand(spl1.skeys.sqlQuery, cmd);
UpdateToDb(co, cmd); UpdateToDb(co, cmd);
splunkLog?.WriteSplunkLog(taskName,spl1.iseverity.info);
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Error = 1; Error = 1;
ErrorMessage = ex.Message; ErrorMessage = ex.Message;
splunkLog.WriteException(moduleName, taskName, ex); splunkLog?.WriteException(moduleName, taskName, ex);
if (stationLog != null) stationLog.WriteLine($"{taskName} error {ex.Message} co {co.DataSource} {System.DateTime.Now}"); stationLog?.WriteLine($"{taskName} error {ex.Message} co {co.DataSource} {System.DateTime.Now}");
} }
co?.Close(); co?.Close();
splunkLog.KvClear(); splunkLog?.KvClear();
} }
} }
public string find()
{
string rv = "COM" + ComPort.ToString();
if (DevCon != null)
{
if (DevCon.hasCommand) rv = DevCon.FindEdosCom();
else rv = DevCon.comdefault;
}
return rv;
}
public string DeviceRestart()
{
string er = null;
if (DevCon != null && DevCon.hasCommand) er=DevCon.Restart();
if (!string.IsNullOrEmpty(er)) splunkLog?.WriteSplunkLog("DeviceRestart", spl1.iseverity.err, er);
return er;
}
} }
} }

View file

@ -1,72 +1,72 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">> <assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">>
<assemblyIdentity version="1.0.0.0" name="SCKCEN.HPH.eDosStation"/> <assemblyIdentity version="1.0.0.0" name="SCKCEN.HPH.eDosStation"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security> <security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false" /> <!--<requestedExecutionLevel level="asInvoker" uiAccess="false" />-->
<!--<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" /> <!--<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />--> <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />-->
</requestedPrivileges> </requestedPrivileges>
</security> </security>
</trustInfo> </trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application> <application>
<!-- A list of the Windows versions that this application has been tested on <!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. --> and Windows will automatically select the most compatible environment. -->
<!-- Windows Vista --> <!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />--> <!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 --> <!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />--> <!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 --> <!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />--> <!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 --> <!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />--> <!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 --> <!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" /> <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application> </application>
</compatibility> </compatibility>
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher <!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. --> also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
<!-- <!--
<application xmlns="urn:schemas-microsoft-com:asm.v3"> <application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings> <windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware> <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings> </windowsSettings>
</application> </application>
--> -->
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) --> <!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<dependency> <dependency>
<dependentAssembly> <dependentAssembly>
<assemblyIdentity <assemblyIdentity
type="win32" type="win32"
name="Microsoft.Windows.Common-Controls" name="Microsoft.Windows.Common-Controls"
version="6.0.0.0" version="6.0.0.0"
processorArchitecture="*" processorArchitecture="*"
publicKeyToken="6595b64144ccf1df" publicKeyToken="6595b64144ccf1df"
language="*" language="*"
/> />
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
<asmv3:application> <asmv3:application>
<asmv3:windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings"> <asmv3:windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
<ws2:longPathAware>true</ws2:longPathAware> <ws2:longPathAware>true</ws2:longPathAware>
</asmv3:windowsSettings> </asmv3:windowsSettings>
</asmv3:application> </asmv3:application>
</assembly> </assembly>

120
eDosStation/cDevCon.cs Normal file
View file

@ -0,0 +1,120 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using cspl = LSWLib.CLog;
namespace eDosStation
{
public class cDevCon
{
public StringBuilder error = null;
public bool hasError;
public bool hasCommand;
public string DevConFolder, DevConExePath;
public string comdefault;
cspl spl;
System.Diagnostics.Process DevConProcess = null;
const string usbIdentifier = @"USB\VID_0EBB&PID_0340&MI_00";
const string cDevConFolder = "extra";
const string cDevConexe = "devcon.exe";
const string className = "devcon";
public static bool IsAdministrator()
{
return (new System.Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsIdentity.GetCurrent()))
.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator);
}
public cDevCon(int iCOM, cspl _spl)
{
spl = _spl;
comdefault = "COM" + iCOM.ToString();
hasCommand = false;
DevConProcess = null;
error = new StringBuilder();
hasError = false;
if (IsAdministrator())
{
DevConFolder = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, cDevConFolder);
if (System.IO.Directory.Exists(DevConFolder))
{
DevConExePath = System.IO.Path.Combine(DevConFolder, cDevConexe);
if (System.IO.File.Exists(DevConExePath)) hasCommand = true;
}
}
else spl?.WriteSplunkLog("cDecCon", cspl.iseverity.warning, "No Admin");
}
private string ExecuteDevcon(string command)
{
const string module = "ExecuteDevcon";
if (!hasCommand) return string.Empty;
hasError = false;
error.Clear();
StringBuilder sb = new StringBuilder();
try
{
using (DevConProcess = new System.Diagnostics.Process())
{
DevConProcess.StartInfo.WorkingDirectory = DevConFolder;
DevConProcess.StartInfo.FileName = DevConExePath;
DevConProcess.StartInfo.Arguments = $"{command} \"{usbIdentifier}\"";
DevConProcess.StartInfo.RedirectStandardOutput = true;
DevConProcess.StartInfo.UseShellExecute = false;
DevConProcess.Start();
var i = DevConProcess.StandardOutput;
if (i!=null)
while (!i.EndOfStream)
{
sb.AppendLine(i.ReadLine());
}
DevConProcess.WaitForExit();
spl?.WriteSplunkLog(module, cspl.iseverity.info);
}
}
catch (System.Exception ex)
{
spl?.WriteException(className, module, ex);
hasError = true;
sb.Clear();
error.Append(ex.Message);
}
return sb.ToString();
}
public string FindEdosCom()
{
const string module = "FindEdosCom";
string eDosCom = comdefault;
if (hasCommand)
try
{
string cp = ExecuteDevcon("find");
if (!string.IsNullOrEmpty(cp))
{
var ix = cp.IndexOf("(COM");
if (ix >= 0) eDosCom = cp.Substring(ix + 1, 4);
}
}
catch (System.Exception ex)
{
spl?.WriteException(className, module, ex);
}
return eDosCom;
}
public string Restart()
{
string rv = string.Empty;
error.Clear();
hasError = false;
if (hasCommand)
{
rv = ExecuteDevcon("restart");
if (hasError) rv = error.ToString();
}
return rv;
}
}
}

View file

@ -1,72 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace eDosStation
{
class devcon
{
static StringBuilder error = null;
static bool hasError;
static private string ExecuteDevcon(string command)
{
StringBuilder sb = new StringBuilder();
System.Diagnostics.Process p = null;
string curPath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "extra");
string devcon;
if (System.IO.Directory.Exists(curPath))
{
devcon = System.IO.Path.Combine(curPath, "devcon.exe");
if (System.IO.File.Exists(devcon))
{
try
{
using (p = new System.Diagnostics.Process())
{
p.StartInfo.WorkingDirectory = curPath;
p.StartInfo.FileName = devcon;
p.StartInfo.Arguments = $"{command} \"USB\\VID_0EBB&PID_0340&MI_00\"";
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.Start();
var i = p.StandardOutput;
while (!i.EndOfStream)
{
sb.AppendLine(i.ReadLine());
}
p.WaitForExit();
}
} catch(System.Exception ex)
{
hasError = true;
error.Append(ex.Message);
}
}
}
return sb.ToString();
}
static public string FindEdosCom()
{
string eDosCom = null;
try
{
string cp = devcon.ExecuteDevcon("find");
var ix = cp.IndexOf("(COM");
if (ix >= 0) eDosCom = cp.Substring(ix + 1, 4);
}
catch { }
return eDosCom;
}
static public string Restart()
{
error = new StringBuilder(); hasError = false;
string cp = devcon.ExecuteDevcon("restart");
if (hasError) return error.ToString(); else return string.Empty;
}
}
}

View file

@ -303,7 +303,7 @@
<DependentUpon>DataSet1.xsd</DependentUpon> <DependentUpon>DataSet1.xsd</DependentUpon>
</Compile> </Compile>
<Compile Include="Decoder.cs" /> <Compile Include="Decoder.cs" />
<Compile Include="devcon.cs" /> <Compile Include="cDevCon.cs" />
<Compile Include="EntryBadge.xaml.cs"> <Compile Include="EntryBadge.xaml.cs">
<DependentUpon>EntryBadge.xaml</DependentUpon> <DependentUpon>EntryBadge.xaml</DependentUpon>
</Compile> </Compile>
@ -489,7 +489,7 @@
<Error Condition="!Exists('..\packages\Microsoft.VisualStudio.SlowCheetah.4.0.50\build\Microsoft.VisualStudio.SlowCheetah.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.VisualStudio.SlowCheetah.4.0.50\build\Microsoft.VisualStudio.SlowCheetah.targets'))" /> <Error Condition="!Exists('..\packages\Microsoft.VisualStudio.SlowCheetah.4.0.50\build\Microsoft.VisualStudio.SlowCheetah.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.VisualStudio.SlowCheetah.4.0.50\build\Microsoft.VisualStudio.SlowCheetah.targets'))" />
</Target> </Target>
<PropertyGroup> <PropertyGroup>
<PostBuildEvent>"C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\signtool.exe" sign /sha1 857150b64ef7d3e679c8cbde425d2a0b5e58ffaa /fd sha256 /d "Integrity &amp; Authenticity" /tr "http://timestamp.digicert.com" $(TargetPath)</PostBuildEvent> <PostBuildEvent>%25signer%25 $(TargetPath)</PostBuildEvent>
</PropertyGroup> </PropertyGroup>
<Import Project="..\packages\LSWDesfirePublic.1.3.9\build\LSWDesfirePublic.targets" Condition="Exists('..\packages\LSWDesfirePublic.1.3.9\build\LSWDesfirePublic.targets')" /> <Import Project="..\packages\LSWDesfirePublic.1.3.9\build\LSWDesfirePublic.targets" Condition="Exists('..\packages\LSWDesfirePublic.1.3.9\build\LSWDesfirePublic.targets')" />
<Import Project="..\packages\Microsoft.VisualStudio.SlowCheetah.4.0.50\build\Microsoft.VisualStudio.SlowCheetah.targets" Condition="Exists('..\packages\Microsoft.VisualStudio.SlowCheetah.4.0.50\build\Microsoft.VisualStudio.SlowCheetah.targets')" /> <Import Project="..\packages\Microsoft.VisualStudio.SlowCheetah.4.0.50\build\Microsoft.VisualStudio.SlowCheetah.targets" Condition="Exists('..\packages\Microsoft.VisualStudio.SlowCheetah.4.0.50\build\Microsoft.VisualStudio.SlowCheetah.targets')" />

BIN
eDosStation/eDosStation.tar Normal file

Binary file not shown.

BIN
eDosStation/eDosStation.zip Normal file

Binary file not shown.

31
eDosStation/sync.cmd Normal file
View file

@ -0,0 +1,31 @@
pause "eDosStation to Sqlsrv7 "
set src="D:\l\src\cs2024\eDosStation\eDosStation\bin\Release"
set C="%cd:"=%\bin\release"
if /I %src%==%C% (echo "Path OK ") else (echo "Path issue !")
Pause was ok ?
set dst="\\sqlsrv7\c$\Soft\eDos2023"
::set zip="eDosStation.tar"
::tar -cf %zip% -C %src% --exclude *.zip *.*
set zip="eDosStation.zip"
"c:\program files\7-zip\7z.exe" a -r %zip% .\bin\release\*.*
xcopy %zip% %dst% /i /h /R /y
:: %src:"=% remove quotes
:: %src:"=%\*.*9 remove quotes and add \*.*
:: /i If destination does not exist and copying more than one file, assumes that destination must be a directory.
:: /h Copies hidden and system files also.
:: /r Overwrites read-only files
:: /y uppresses prompting to confirm you want to overwrite an existing destination file.
:: /s Copies directories and subdirectories except empty ones
pause

BIN
eDosStation/x.zip Normal file

Binary file not shown.

View file

@ -11,7 +11,7 @@ namespace syncEdosLocal
class cResult class cResult
{ {
const string className = "cResult";
public DateTime timestamp; public DateTime timestamp;
public int VisitsNew, VisitsSkipped, VisitsAddedExits, VisitsAddedEntries; public int VisitsNew, VisitsSkipped, VisitsAddedExits, VisitsAddedEntries;
public int ID_Visit_Min, ID_Visit_Max; public int ID_Visit_Min, ID_Visit_Max;
@ -441,20 +441,20 @@ namespace syncEdosLocal
DataSet1.CentralVisitsRow cr; DataSet1.CentralVisitsRow cr;
try try
{ {
using (var ta = new DataSet1TableAdapters.LocalVisitsTableAdapter()) using (var localTA = new DataSet1TableAdapters.LocalVisitsTableAdapter())
using (var tc = new DataSet1TableAdapters.CentralVisitsTableAdapter()) using (var centralTA = new DataSet1TableAdapters.CentralVisitsTableAdapter())
{ {
ta.Connection = coLocal; localTA.Connection = coLocal;
tc.Connection = coCentral; centralTA.Connection = coCentral;
tc.ClearBeforeFill = false; centralTA.ClearBeforeFill = false;
ta.Fill(ds.LocalVisits); localTA.Fill(ds.LocalVisits);
spLog.KvAdd(spl.skeys.recordsAffected, ds.LocalVisits.Rows.Count); spLog.KvAdd(spl.skeys.recordsAffected, ds.LocalVisits.Rows.Count);
foreach (DataSet1.LocalVisitsRow lr in ds.LocalVisits.Rows) foreach (DataSet1.LocalVisitsRow lr in ds.LocalVisits.Rows)
{ {
Result.CheckVisitID(lr.ID_Visit); //min max Result.CheckVisitID(lr.ID_Visit); //min max
cr = ds.CentralVisits.FindByID_StationID_Visit(lr.ID_Station, lr.ID_Visit); cr = ds.CentralVisits.FindByID_StationID_Visit(lr.ID_Station, lr.ID_Visit);
if (cr == null) if (cr == null)
tc.Fill(ds.CentralVisits, lr.ID_Station, lr.ID_Visit); centralTA.Fill(ds.CentralVisits, lr.ID_Station, lr.ID_Visit);
cr = ds.CentralVisits.FindByID_StationID_Visit(lr.ID_Station, lr.ID_Visit); cr = ds.CentralVisits.FindByID_StationID_Visit(lr.ID_Station, lr.ID_Visit);
if (cr == null) if (cr == null)
{ {
@ -470,34 +470,48 @@ namespace syncEdosLocal
case 2: if ((lr.VisitStatus & 1) == 1) { copyEntry(lr, cr); lr.syncedEntry = lr.syncedExit = true; Result.VisitsAddedEntries++; } break; case 2: if ((lr.VisitStatus & 1) == 1) { copyEntry(lr, cr); lr.syncedEntry = lr.syncedExit = true; Result.VisitsAddedEntries++; } break;
} }
} }
ta.Update(ds.LocalVisits); localTA.Update(ds.LocalVisits);
tc.Update(ds.CentralVisits); centralTA.Update(ds.CentralVisits);
} }
spLog.KvAdd(spl.skeys.recordsAffected, Result.VisitsNew);
spLog?.WriteSplunkLog(sStep, spl.iseverity.info);
spLog.KvClear(); spLog.KvClear();
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
error = true; error = true;
Result.ErrorMessage = ex.Message; Result.ErrorMessage = ex.Message;
spLog.WriteException(null, sStep, ex); spLog.WriteException(moduleName, sStep, ex);
} }
ds.Dispose();
} }
private static void copyEntry(DataSet1.LocalVisitsRow lr, DataSet1.CentralVisitsRow cr) private static void copyEntry(DataSet1.LocalVisitsRow lr, DataSet1.CentralVisitsRow cr)
{ {
cr["ID_Station"] = lr["ID_Station"]; const string module = "copyEntry";
cr["ID_Visit"] = lr["ID_Visit"]; try
cr["Inst_CODE"] = lr["Inst_CODE"]; {
cr["PersID"] = lr["PersID"]; cr["ID_Station"] = lr["ID_Station"];
cr["ID_Task"] = lr["ID_Task"]; cr["ID_Visit"] = lr["ID_Visit"];
cr["EntryTime"] = lr["EntryTime"]; cr["Inst_CODE"] = lr["Inst_CODE"];
cr["ID_EPD"] = lr["ID_EPD"]; cr["PersID"] = lr["PersID"];
cr["isBG"] = lr["isBG"]; cr["ID_Task"] = lr["ID_Task"];
cr["ENTRY_EPD_CLOCK"] = lr["ENTRY_EPD_CLOCK"]; cr["EntryTime"] = lr["EntryTime"];
cr["epdType"] = lr["epdType"]; cr["ID_EPD"] = lr["ID_EPD"];
cr["isBG"] = lr["isBG"];
cr["ENTRY_EPD_CLOCK"] = lr["ENTRY_EPD_CLOCK"];
cr["epdType"] = lr["epdType"];
}
catch (System.Exception ex)
{
spLog?.WriteException(moduleName, null, ex);
}
} }
private static void copyExit(DataSet1.LocalVisitsRow lr, DataSet1.CentralVisitsRow cr) private static void copyExit(DataSet1.LocalVisitsRow lr, DataSet1.CentralVisitsRow cr)
{ {
cr["ReturnTime"] = lr["ReturnTime"]; const string module = "copyExit";
try
{
cr["ReturnTime"] = lr["ReturnTime"];
cr["Hp10Dose"] = lr["Hp10Dose"]; cr["Hp10Dose"] = lr["Hp10Dose"];
cr["Hp07Dose"] = lr["Hp07Dose"]; cr["Hp07Dose"] = lr["Hp07Dose"];
cr["Hp10Total"] = lr["Hp10Total"]; cr["Hp10Total"] = lr["Hp10Total"];
@ -535,18 +549,31 @@ namespace syncEdosLocal
cr["eDosDose10Alarm"] = lr["eDosDose10Alarm"]; cr["eDosDose10Alarm"] = lr["eDosDose10Alarm"];
cr["eDosRate10Warning"] = lr["eDosRate10Warning"]; cr["eDosRate10Warning"] = lr["eDosRate10Warning"];
cr["eDosRate10Alarm"] = lr["eDosRate10Alarm"]; cr["eDosRate10Alarm"] = lr["eDosRate10Alarm"];
}
catch (System.Exception ex)
{
spLog?.WriteException(moduleName, null, ex);
}
} }
private static DataSet1.CentralVisitsRow copyrow(DataSet1.LocalVisitsRow lr, DataSet1.CentralVisitsDataTable centralVisits) private static DataSet1.CentralVisitsRow copyrow(DataSet1.LocalVisitsRow lr, DataSet1.CentralVisitsDataTable centralVisits)
{ {
DataSet1.CentralVisitsRow cr = centralVisits.NewCentralVisitsRow(); DataSet1.CentralVisitsRow cr = centralVisits.NewCentralVisitsRow();
foreach (DataColumn sc in lr.Table.Columns) const string module = "copyExit";
if (lr.Table.Columns.Contains(sc.ColumnName)) cr[sc.ColumnName] = lr[sc.ColumnName]; try
centralVisits.AddCentralVisitsRow(cr); {
foreach (DataColumn sc in lr.Table.Columns)
if (lr.Table.Columns.Contains(sc.ColumnName)) cr[sc.ColumnName] = lr[sc.ColumnName];
centralVisits.AddCentralVisitsRow(cr);
}
catch (System.Exception ex)
{
spLog?.WriteException(moduleName, null, ex);
}
return cr; return cr;
} }
private static void Connection_InfoMessage(object sender, System.Data.SqlClient.SqlInfoMessageEventArgs e) private static void Connection_InfoMessage(object sender, System.Data.SqlClient.SqlInfoMessageEventArgs e)
{ {
spLog.Connection_InfoMessageLog(e, ref messages); spLog?.Connection_InfoMessageLog(e, ref messages);
} }
} }

31
syncEdosLocal/sync.cmd Normal file
View file

@ -0,0 +1,31 @@
pause syndEdosLocal to Sqlsrv7 "
set src="D:\l\src\cs2024\eDosStation\syncEdosLocal\bin\Release"
set C="%cd:"=%\bin\release"
if /I %src%==%C% (echo "Path OK ") else (echo "Path issue !")
Pause was ok ?
set dst="\\sqlsrv7\c$\Soft\eDos2023"
::set zip="eDosStation.tar"
::tar -cf %zip% -C %src% --exclude *.zip *.*
set zip="syncEdosLocal.zip"
"c:\program files\7-zip\7z.exe" a -r %zip% .\bin\release\*.*
xcopy %zip% %dst% /i /h /R /y
:: %src:"=% remove quotes
:: %src:"=%\*.*9 remove quotes and add \*.*
:: /i If destination does not exist and copying more than one file, assumes that destination must be a directory.
:: /h Copies hidden and system files also.
:: /r Overwrites read-only files
:: /y uppresses prompting to confirm you want to overwrite an existing destination file.
:: /s Copies directories and subdirectories except empty ones
pause

Binary file not shown.

Binary file not shown.

BIN
x.zip Normal file

Binary file not shown.