diff --git a/EpdBase3/Epd3.h b/EpdBase3/Epd3.h index 84aba27..9202135 100644 --- a/EpdBase3/Epd3.h +++ b/EpdBase3/Epd3.h @@ -434,7 +434,7 @@ extern "C" //enkel 3.1 CompletionToken EPDDLL_API BeginTestLed_R3(CommsHandle hComms, float seconds, CompletionCallback callback); - int32_t EPDDLL_API EmdTestLed_R3(CommsHandle hComms, CompletionToken token); + int32_t EPDDLL_API EndTestLed_R3(CommsHandle hComms, CompletionToken token); CompletionToken EPDDLL_API BeginTestVibe_R3(CommsHandle hComms, float seconds, CompletionCallback callback); int32_t EPDDLL_API EndTestVibe_R3(CommsHandle hComms, CompletionToken token); diff --git a/EpdBase3/Epd3Base.cpp b/EpdBase3/Epd3Base.cpp index 6756f17..0db099f 100644 --- a/EpdBase3/Epd3Base.cpp +++ b/EpdBase3/Epd3Base.cpp @@ -7,6 +7,8 @@ #define noDeissueWithClear #define ProtectSession +constexpr int SleepAfterClear = 1000; + //-102 = permission Epd3Base::Epd3U* current; @@ -32,8 +34,6 @@ int Epd3Base::Epd3U::SetFunctionReturnValue(enum eFunctions f, BYTE CanIgnore) return CurrentStep; } - - void Epd3Base::Epd3U::SetCommitReturnValue(int step, int32_t rv) { if (CurrentStep >= 0 && CurrentStep < MaxSteps) @@ -47,12 +47,13 @@ void Epd3Base::Epd3U::SetCommitReturnValue(int32_t rv) uint32_t Epd3Base::Epd3U::SetEndReturnValue(int step, int32_t rv) { - if (step >= 0 && step < MaxSteps) + if (step >= 0 && step < MaxSteps) { StepReturnValues[step][2] = rv; - if (rv != 0) { - HasStepError = 1; - if (StepReturnValues[step][3]) rv = 0; //if canIngore set rv ok - Error = GetErrorCode(); + if (rv != 0) { + HasStepError = 1; + if (StepReturnValues[step][3]) rv = 0; //if canIngore set rv ok + Error = GetErrorCode(); + } } return rv; } @@ -62,7 +63,6 @@ uint32_t Epd3Base::Epd3U::SetEndReturnValue(int32_t rv) return SetEndReturnValue(CurrentStep, rv); } - int32_t Epd3Base::Epd3U::CommitAndSetRV() { int32_t r = Commit3(epdComsHandle); @@ -78,7 +78,6 @@ int32_t Epd3Base::Epd3U::CommitAndSetRV(int idx[], int len) return r; } - int32_t Epd3Base::Epd3U::CommitAndEnd2RV(int32_t (WINAPI *endFunction2)(CommsHandle hComms, CompletionToken token), CompletionToken token) { int32_t r = Commit3(epdComsHandle); @@ -95,7 +94,6 @@ int32_t Epd3Base::Epd3U::End2RV(int step, int32_t(WINAPI* endFunction2)(CommsHan return r; } - void WINAPI completion(CommsHandle hComms, CompletionToken token) { SetEvent(current->hCompletion); @@ -123,6 +121,7 @@ void WINAPI connectcallback(CommsHandle hComms, DiscoveryId ID) void WINAPI disconnectcallback(CommsHandle hComms, DiscoveryId ID) { + OutputDebugStringW(L"**** Disconnect ****\n"); current->isConnected = 0; current->CurrentDeviceID = 0; current->DeviceCount = 0; @@ -193,10 +192,29 @@ Epd3Base::Epd3U::~Epd3U() //if (hWaitTimer != 0) { CloseHandle(hWaitTimer); hWaitTimer = 0; } } +int Epd3Base::Epd3U::DisconnectAndConnect() +{ + int rv = 0; + rv = Disconnect(epdComsHandle); + Sleep(200); + rv = SetConnectCallback(epdComsHandle, connectcallback); + int tries = 3; rv = 1; + while (rv && --tries>=0) { + rv = Connect3(epdComsHandle, Epd, true); + snprintf(DiagnosticsWrite, DiagnosticsWriteSize, "**** DisconnectAndConnect rv=%d tries %d ****\n", rv, tries); + OutputDebugStringA(DiagnosticsWrite); + Sleep(100); + } + + return rv; +} + + DWORD Epd3Base::Epd3U::StartCom() { ErrorReason = 0; ConnectRetries = 0; + OpenRetries = 0; int step = 1; int mx = 10; @@ -208,29 +226,34 @@ DWORD Epd3Base::Epd3U::StartCom() if (CommsInitialized == 0 || epdComsHandle == nullptr) { step = 2; + SetFunctionReturnValue(fCreateReaderInterface, 0); epdComsHandle = CreateReaderInterface(); - if (epdComsHandle == nullptr) { - ++ConnectRetries; - step = 3; - Sleep(100); + if (!epdComsHandle ) step = 3; + while (epdComsHandle == nullptr && ++ConnectRetries < 4) { + Sleep(200); epdComsHandle = CreateReaderInterface(); //try again; } + SetCommitReturnValue(0); + if (epdComsHandle) SetEndReturnValue(0); else SetEndReturnValue(-1); + if (epdComsHandle != nullptr) { step = 4; + SetFunctionReturnValue(fOpenReader, 0); Dll3RV = OpenReader(epdComsHandle, comPort); //-6 = r_OperationFailed - if (Dll3RV) { //retry - ++ConnectRetries; - step = 5; - Sleep(100); + if (Dll3RV) step = 5; + while (Dll3RV && ++OpenRetries <4 ) { //retry + Sleep(200); Dll3RV = OpenReader(epdComsHandle, comPort); } + SetCommitReturnValue(0); + if (!Dll3RV) SetEndReturnValue(0); else SetEndReturnValue(-1); + if (Dll3RV == 0) { step = 7; CommsInitialized = 1; Dll3RV = SetMultipleDiscoveryMode(epdComsHandle, false); Dll3RV = SetResponseTimeout(epdComsHandle, ResponseTimeout); - //Dll3RV = GetRetryCount(epdComsHandle, &retries); = 3 } } else { @@ -248,10 +271,14 @@ error: void Epd3Base::Epd3U::EndCom(bool doDiscon) { int rv; + if (CommsInitialized == 1 || CurrentDeviceID != 0) { if (CommsInitialized == 1) { + snprintf(DiagnosticsWrite, DiagnosticsWriteSize, "**** EndCom(%d) is Connected=%d ****\n", doDiscon, isConnected); + OutputDebugStringA(DiagnosticsWrite); + if (epdComsHandle != nullptr) { - if (doDiscon) { DisCon(0); } + if (doDiscon && isConnected) { DisCon(0); } //Dll3RV = CloseReader(epdComsHandle); // not necessary if followed by DestroyReaderInterface //if (Dll3RV) { // rv = 1; @@ -293,7 +320,6 @@ int Epd3Base::Epd3U::StartDiscover(int tokentimeout) ResetEvent(hCompletion); ConnectTimerFired = 0; isConnected = 0; - Dll3RV = StartDiscovery(epdComsHandle, discovery); if (Dll3RV == 0) { @@ -325,6 +351,8 @@ int Epd3Base::Epd3U::OpenDev(DiscoveryId DeviceID) { Dll3RV = Connect3(epdComsHandle, DeviceID, true); SetDisconnectCallback(epdComsHandle, disconnectcallback); + OutputDebugStringA("**** Open ****\n"); + } else { Dll3RV = r_InvalidCommsHandle; } return Dll3RV; @@ -334,27 +362,47 @@ int Epd3Base::Epd3U::ReOpenDev() { if (epdComsHandle != nullptr) { + SetDisconnectCallback(epdComsHandle, disconnectcallback); Dll3RV = Connect3(epdComsHandle, Epd, true); + OutputDebugStringA("**** ReOpen ****\n"); } else { + OutputDebugStringA("**** ReOpen no epdComsHandle ****\n"); Dll3RV = r_InvalidCommsHandle; } //no handle .. return Dll3RV; } +// + int Epd3Base::Epd3U::DisCon(UINT16 alarm) { + // 5432109876543210 + constexpr UINT16 ca = 0b1001110011000111; int rv = 0; int step = 0; + snprintf(DiagnosticsWrite, DiagnosticsWriteSize, "**** Discon(%hu) ****\n", alarm); + OutputDebugStringA(DiagnosticsWrite); if (CurrentDeviceID != 0) { ResetEvent(hCompletion); current = this; step = 1; Dll3RV = SetDisconnectCallback(epdComsHandle, disconnectcallback); if (alarm) { + + snprintf(DiagnosticsWrite, DiagnosticsWriteSize, "**** DisconnectAndNotify(%hX,15) HardVersionMinor: %d ****\n", ca, HardVersionMinor); + + if (HardVersionMinor > 0) { + SetFunctionReturnValue(TestVibe, 0); + token = BeginTestVibe_R3(epdComsHandle, 1.0 , nullptr); + rv = CommitAndEnd2RV(EndTestVibe_R3, token); + } + + OutputDebugStringA(DiagnosticsWrite); SetFunctionReturnValue(fDisconnectAndNotify,0); - Dll3RV = DisconnectAndNotify(epdComsHandle, alarm, 12); //1.2 secon + Dll3RV = DisconnectAndNotify(epdComsHandle, ca, 12); //1.2 secon SetCommitReturnValue(0); SetEndReturnValue(Dll3RV); + Sleep(1200); } else { SetFunctionReturnValue(fDisconnect,0); Dll3RV = Disconnect(epdComsHandle); @@ -434,7 +482,6 @@ void Epd3Base::Epd3U::DecodeStatus() EPDEprFault = checkStatus(epd3status.FaultStatus, FaultStatusFlags::EepromFailure); EPDTrhFault = checkStatus(epd3status.FaultStatus, FaultStatusFlags::BadThreshold); - for (int ix = 0; ix < 4; ix++) { DoseAlarmFlags status = epd3status.DoseAlarms[ix].Status; @@ -485,17 +532,39 @@ int Epd3Base::Epd3U::SetTime() //Only R3 utc = TimeFunctions::NowToEpdTime(Epd.Gen == EpdGeneration::Mk2); token = BeginWriteRTC_R3(epdComsHandle, utc, nullptr); r = CommitAndEnd2RV(EndWriteRTC_R3, token); - /*r = CommitSetRV(); - if (!r) r = EndWriteRTC_R3(epdComsHandle, token); - SetEndReturnValue(r);*/ } return r; } + +void WINAPI ReadStatusCompletion(CommsHandle hComms, CompletionToken token) +{ + int rv = EndReadStatus(current->epdComsHandle, token, ¤t->epd3status); + rv = current->SetEndReturnValue(rv); + current->IssueCount = current->epd3status.IssueCount; + current->OperatingStatus = current->epd3status.OperatingStatus; + current->AlarmStatus = current->epd3status.AlarmStatus; + current->ErrorStatus = current->epd3status.FaultStatus; + current->OtherAlarms = current->epd3status.OtherBits; + current->DecodeStatus(); //Alarm status... + snprintf(current->DiagnosticsWrite, DiagnosticsWriteSize, "**** ReadStatusCompletion %04x ****\n", current->OperatingStatus); + OutputDebugStringA(current->DiagnosticsWrite); + SetEvent(current->hCompletion); +} + +int Epd3Base::Epd3U::ReadStatusOnly() +{ + int rv = 0; + ResetEvent(hCompletion); + SetFunctionReturnValue(eFunctions::ReadStatus, 0); + token = BeginReadStatus(epdComsHandle, ReadStatusCompletion); + rv = CommitAndSetRV(); + return rv; +} /// /// /// /// 0 = ok -int Epd3Base::Epd3U::ReadStatus() +int Epd3Base::Epd3U::ReadStatus(bool onlyStatus) { int rv; //0=ok //constexpr int maxbatch = 2; @@ -531,24 +600,9 @@ int Epd3Base::Epd3U::ReadStatus() HardVersion = HardVersionMinor = SoftVersion = FunctionFlags = 0; step = 1; - //batchstep = 0; + SetFunctionReturnValue(eFunctions::ReadStatus,0); token = BeginReadStatus(epdComsHandle, nullptr); - - //batchstep = 1; - // - //s[batchstep] = SetFunctionReturnValue(ReadEpdIdentities, 0); - //btoken[batchstep] = BeginReadEpdIdentities(epdComsHandle, nullptr); - - //batchstep = 2; - //s[batchstep] = SetFunctionReturnValue(ReadCounts, 0); - //btoken[batchstep] = BeginReadCounts(epdComsHandle, nullptr, 0, nullptr); - - /*batchstep = 3; - s[batchstep] = SetFunctionReturnValue(ReadRTC, 0); - btoken[batchstep] = BeginReadRTC(epdComsHandle, nullptr);*/ - - // after rv = CommitAndSetRV(); //batchstep = 0; //ReadStatus @@ -562,8 +616,11 @@ int Epd3Base::Epd3U::ReadStatus() AlarmStatus = epd3status.AlarmStatus; ErrorStatus = epd3status.FaultStatus; OtherAlarms = epd3status.OtherBits; + DecodeStatus(); //Alarm status... - uint32_t EpdID32; + if (onlyStatus) goto exitroutine; + + uint32_t EpdID32 ; uint32_t capabilities; MarkNumber_t MarkNumber; VersionNumber_t VersionNumber; @@ -571,6 +628,12 @@ int Epd3Base::Epd3U::ReadStatus() step = 2; //batchstep = 1; //ReadEpdIdentities + + EpdID32 = 0; + MarkNumber.Major = 0; + MarkNumber.Minor=0; + VersionNumber.Major = 0; + SetFunctionReturnValue(ReadEpdIdentities,0); token = BeginReadEpdIdentities(epdComsHandle, nullptr); rv = CommitAndSetRV(); @@ -586,24 +649,18 @@ int Epd3Base::Epd3U::ReadStatus() HardVersionMinor = MarkNumber.Minor; SoftVersion = VersionNumber.Major; VersionOK = true; - - DecodeStatus(); //Alarm status... + step = 3; - //batchstep = 2; + SetFunctionReturnValue(ReadCounts,0); token = BeginReadCounts(epdComsHandle, nullptr, 0, nullptr); rv = CommitAndSetRV(); if (!rv) rv = EndReadCounts(epdComsHandle, token, Counts, MaxCounts, &countsRead, &utc, &seconds); rv= SetEndReturnValue(rv); - // - 101 = InvalidParam - // - 104 = FunctionFail, - if (rv) goto error; // (r != 0 && r != -104) { Error = GetErrorCode(); goto error; } + if (rv) goto error; decodeCounters(countsRead); //HG,SG .. - //Wearer - - //Times //1601-01-01T00:00:00Z. //MK2 .. some utc... but no real time clock @@ -630,16 +687,8 @@ int Epd3Base::Epd3U::ReadStatus() step = 4; if (EPDIssued) { IdString_t mk3WearerID; + mk3WearerID.Length = 0; //Mk2 EPDs only support Name and Primary ID - //batchstep = 0; - //s[batchstep]=SetFunctionReturnValue(ReadWearerId, 0); - //btoken[batchstep] = BeginReadWearerId(epdComsHandle, static_cast(WearerIdType::WearerId_Name), nullptr); - - //batchstep = 1; - //s[batchstep] = SetFunctionReturnValue(ReadWearerId, 0); - //btoken[batchstep] = BeginReadWearerId(epdComsHandle, static_cast(WearerIdType::WearerId_Primary), nullptr); - - //rv = CommitAndSetRV(s, 2); //batchstep = 0; SetFunctionReturnValue(ReadWearerId, 0); @@ -669,6 +718,7 @@ int Epd3Base::Epd3U::ReadStatus() if (WearerID[i] == 0xb) WearerID[i] = '0'; else WearerID[i] |= 0x30; } + exitroutine: return rv; error: @@ -698,7 +748,7 @@ int Epd3Base::Epd3U::ConnectAndStatus(int tokenSourceTimeout) if (dllStatus != 1) rv = 1; //Connect error else if (DeviceCount < 1) rv = 2; //TO - else if (isMK3 && ReadStatus() != 0) rv = 1; //Read Error + else if (isMK3 && ReadStatus(false) != 0) rv = 1; //Read Error else rv = 0; } else rv = 1; @@ -725,7 +775,6 @@ void Epd3Base::Epd3U::decodeSensitivities(int count) { } } } - void Epd3Base::Epd3U::decodetotDoses(int count) { //doses @@ -754,7 +803,6 @@ void Epd3Base::Epd3U::decodeDoses(int count) } } } - void Epd3Base::Epd3U::decodePeakRates(int count) { //Rates @@ -782,7 +830,6 @@ void Epd3Base::Epd3U::decodePeakRates(int count) } } } - void Epd3Base::Epd3U::decodeCounters(int count) { HG = SG = BC = FB = 0; @@ -796,7 +843,6 @@ void Epd3Base::Epd3U::decodeCounters(int count) } } } - void Epd3Base::Epd3U::decodeBaseCounters(int count) { D1 = D2 = D3 = D4 = 0; @@ -810,7 +856,6 @@ void Epd3Base::Epd3U::decodeBaseCounters(int count) } } } - void Epd3Base::Epd3U::decodeTreshold(Mk3AlarmThresholds_t* th) { float* pThDose = nullptr, * pThRate = nullptr, * pTHDoseWarning = nullptr, * pTHRateWarning = nullptr; @@ -844,7 +889,6 @@ void Epd3Base::Epd3U::decodeTreshold(Mk3AlarmThresholds_t* th) } } } - void Epd3Base::Epd3U::encodeTreshold(Mk3AlarmThresholds_t* th) { //th.MeasId @@ -1107,7 +1151,6 @@ int Epd3Base::Epd3U::ClearDoses() return rv; } - int Epd3Base::Epd3U::ClearAlarms() { constexpr int maxbatch = 2; @@ -1134,7 +1177,6 @@ int Epd3Base::Epd3U::ClearAlarms() Error = rv; return rv; } - WORD Epd3Base::Epd3U::PrepareForIssue() { int rv = 0; @@ -1177,16 +1219,19 @@ WORD Epd3Base::Epd3U::PrepareForIssue() if (rv != 0) goto error; - Sleep(2000); + OutputDebugStringA("**** After clear ****\n"); + Disconnect(epdComsHandle); + Sleep(SleepAfterClear); return rv; error: + snprintf(DiagnosticsWrite, DiagnosticsWriteSize, "**** After clear step %d error %d ****\n", step, rv); + OutputDebugStringA(DiagnosticsWrite); ErrorStep = step; Error = rv; return rv; } - WORD Epd3Base::Epd3U::ReadAlarmConfig() { //Alleen MK3 ? leeg bij MK2 @@ -1196,7 +1241,6 @@ WORD Epd3Base::Epd3U::ReadAlarmConfig() { if (!r) { r = EndReadAlarmConfiguration(epdComsHandle, token, alarmConfig, MaxAlarmConfig, &numAlarm); SetEndReturnValue(r); } return numAlarm; } - WORD Epd3Base::Epd3U::ReadAlarmTresholds() { //Alleen MK3 ? leeg bij MK2 bool isNeutron = (EpdType == EpdTypes::Mk2Neutron || EpdType == EpdTypes::Mk3Neutron); @@ -1225,7 +1269,6 @@ WORD Epd3Base::Epd3U::ReadAlarmTresholds() { return r; } - WORD Epd3Base::Epd3U::WriteAlarmTresholds() { //Alleen MK3 ? leeg bij MK2 uint32_t r; @@ -1264,7 +1307,6 @@ error: return r; } - WORD Epd3Base::Epd3U::DeIssue() { int r = 1; @@ -1272,42 +1314,35 @@ WORD Epd3Base::Epd3U::DeIssue() if (port == 0) return 0; if (CurrentDeviceID == 0) return 0; - if (EPDIssued) { - + if (EPDIssued) + { #if DeissueWithClear - ErrorStep = 2; - r = ClearDoses(); - - ErrorStep = 1; - r = ClearAlarms(); - - //needed after clear alarms - Sleep(2000); + ErrorStep = 2; + r = ClearDoses(); + ErrorStep = 1; + r = ClearAlarms(); + //needed after clear alarms + Sleep(2000); #endif - - SetFunctionReturnValue(eFunctions::DeissueEPD,0); - token = BeginDeissueEPD(epdComsHandle, nullptr); - r = CommitAndEnd2RV(EndDeissueEPD,token); - //r = Commit3(epdComsHandle); SetCommitReturnValue(r); if (!r) r = EndDeissueEPD(epdComsHandle, token); SetEndReturnValue(r); - Sleep(2000); + SetFunctionReturnValue(eFunctions::DeissueEPD, 0); + token = BeginDeissueEPD(epdComsHandle, nullptr); + r = CommitAndEnd2RV(EndDeissueEPD, token); + Sleep(100); } SetFunctionReturnValue(eFunctions::EpdOnOff,0); token = BeginEpdOnOff(epdComsHandle, 0, nullptr); r = CommitAndEnd2RV(EndEpdOnOff, token); - //r = Commit3(epdComsHandle); SetCommitReturnValue(r); if (!r) r = EndEpdOnOff(epdComsHandle, token); SetEndReturnValue(r); Sleep(100); - EndCom(true); if (r) goto error; - return r; error: + Error = r; return r; } - WORD Epd3Base::Epd3U::WriteWearer() { int32_t r = 0; @@ -1371,8 +1406,6 @@ WORD Epd3Base::Epd3U::Issue(bool PrepareDone) //normaal is preparedone=tru if (r) goto error; } - - step = 1; if (!isConnected) r = ReOpenDev(); if (r) goto error; @@ -1421,7 +1454,7 @@ WORD Epd3Base::Epd3U::Issue(bool PrepareDone) //normaal is preparedone=tru } if (r) goto error; - + EPDIssued = 1; step = 6; @@ -1430,8 +1463,6 @@ WORD Epd3Base::Epd3U::Issue(bool PrepareDone) //normaal is preparedone=tru } step = 7; - EndCom(false); - return r; error: @@ -1530,9 +1561,11 @@ int Epd3Base::Epd3U::GetAllDeissue(bool reconnect) rv = DeIssue(); //does close if (rv) goto error; - + EndCom(isConnected); return rv; + error: + EndCom(isConnected); Error = rv; ErrorStep = step; return rv; @@ -1543,6 +1576,10 @@ int Epd3Base::Epd3U::IssueAndCheck(float gain, float ChirpRate) { int rv = 0; int step = 0; + DWORD wrv = 0; + int rv1 = -1, rv2 = -1; + + ResetStepReturnValues(); if (!isConnected) rv = ReOpenDev(); if (rv) goto error; @@ -1551,11 +1588,22 @@ int Epd3Base::Epd3U::IssueAndCheck(float gain, float ChirpRate) rv = SetTime(); //synctime + OutputDebugStringW(L"**** Prepare ****\n"); step = 2; rv = PrepareForIssue(); //Set epd on, clear doses and alarms if (rv) goto error; - + rv = ReOpenDev(); + rv = ReadStatusOnly(); + wrv= WaitForSingleObject(hCompletion, 2000); + if (wrv == WAIT_OBJECT_0) rv = 0; + else if (wrv == WAIT_TIMEOUT) { + rv = 1; + } + + //rv1 = StepReturnValues[CurrentStep][1]; + //rv2 = StepReturnValues[CurrentStep][2]; + step = 3; if (isNG) { step = 1; @@ -1571,7 +1619,6 @@ int Epd3Base::Epd3U::IssueAndCheck(float gain, float ChirpRate) } } - step = 3; if (!isConnected) rv = ReOpenDev(); rv = SetChirp(ChirpRate); @@ -1581,14 +1628,20 @@ int Epd3Base::Epd3U::IssueAndCheck(float gain, float ChirpRate) rv = SetChirp(ChirpRate); } if (rv) goto error; - step = 5; rv = Issue(true); // data already loaded if (rv) goto error; + //debug + /*rv = 1; EPDIssued = 0; goto error;*/ + + + EndCom(isConnected); return rv; + error: + EndCom(isConnected); Error = rv; ErrorStep = step; return rv; @@ -1600,11 +1653,12 @@ int Epd3Base::Epd3U::WriteConfig(void) int32_t r = 0; ECLen = 32; + snprintf(DiagnosticsWrite,DiagnosticsWriteSize,"**** WriteCfg v %d.%d ****\n", HardVersion, HardVersionMinor); + OutputDebugStringA(DiagnosticsWrite); // Become admin - SetFunctionReturnValue(eFunctions::WriteAccessLevel,0); + SetFunctionReturnValue(eFunctions::WriteAccessLevelAdmin,0); token = BeginWriteAccessLevel(epdComsHandle, AccessLevel_t::Admin, EC, ECLen, nullptr); r = CommitAndEnd2RV(EndWriteAccessLevel,token); - if (!r) { displayIds = new QuickAccessDisplay_t[6]{ { 0,0x0021 }, @@ -1623,17 +1677,33 @@ int Epd3Base::Epd3U::WriteConfig(void) if (!r) { //Unmanaged%20HtmlFiles/_display_ids.html numItems = 9; - enables = new DisplayAttributeMap_t[9]{ - { 0,0xDFFF,0xFFFF }, - { 1,0xDFFF,0xFF07 }, - { 2,0xDFFF,0xFFFF }, - { 3,0xDFFF,0xFFFF }, - { 4,0xDFFF,0xFE01 }, - { 5,0xDFFF,0xFFFF }, - { 6,0xDFFF,0xFFFF }, - { 7,0xDFFF,0xFFFB }, - { 8,0xDFFF,0xFFFF } - }; + if (HardVersionMinor > 0) { + enables = new DisplayAttributeMap_t[9]{ + { 0,0x3FFF,0xFFFF }, + { 1,0x3FFF,0xFF01 }, //{ 1,0x0FFF,0xFFE1 } + { 2,0x3FFF,0xFE0F }, + { 3,0x3FFF,0xFE0F }, + { 4,0x3FFF,0xFE01 }, + { 5,0x3FFF,0xFF0B }, + { 6,0x3FFF,0xFFF9 }, + { 7,0x3FFF,0xFFD3 }, + { 8,0x3FFF,0xFFFF } + }; + } + else { + enables = new DisplayAttributeMap_t[9]{ + { 0,0x0FFF, 0xFFFF }, + { 1,0x0FFF,0xFFE1 }, + { 2,0x0FFF,0xFE07 }, + { 3,0x0FFF,0xFE07 }, + { 4,0x0FFF,0xFE01 }, + { 5,0x0FFF,0xFF0B }, + { 6,0x0FFF,0xFFF9 }, + { 7,0x0FFF,0xFFD3 }, + { 8,0x0FFF,0xFFFF } + }; + } + // 0x1 Operation Menu Back /0x2 On / Off 0x4 Clear Dose 0x8 Toggle Telemtry 0x10 Responder Trigger // 1 0 0 0 0 @@ -1651,7 +1721,7 @@ int Epd3Base::Epd3U::WriteConfig(void) 0x0000 , 0x0000 , 0x0000 , - 0x0006 , + 0x0004 , 0x0000 }; @@ -1691,23 +1761,24 @@ int Epd3Base::Epd3U::WriteConfig(void) if (!r) { //OffModeDisplay - //batchstep = 0; dutyCycle = (OffModeDutyCycle)0; offModeDispId = (OffModeDisplayId_t)1; SetFunctionReturnValue(eFunctions::WriteOffModeDisplay_R3,1); token = BeginWriteOffModeDisplay_R3(epdComsHandle, dutyCycle, offModeDispId, nullptr); r = CommitAndEnd2RV(EndWriteOffModeDisplay_R3, token); - //SwitchOnFromButton - //batchstep = 1; uint8_t OnOfenabled = 0; - //s[batchstep] = SetFunctionReturnValue(eFunctions::WriteSwitchOnFromButton_R3, 0); - //btoken[batchstep] = BeginWriteSwitchOnFromButton_R3(epdComsHandle, OnOfenabled, nullptr); - SetFunctionReturnValue(eFunctions::WriteSwitchOnFromButton_R3, 0); token = BeginWriteSwitchOnFromButton_R3(epdComsHandle, OnOfenabled, nullptr); r = CommitAndEnd2RV(EndWriteSwitchOnFromButton_R3, token); + SetFunctionReturnValue(eFunctions::WriteAccessLevelOpen, 0); + token = BeginWriteAccessLevel(epdComsHandle, AccessLevel_t::Open,nullptr,0, nullptr); + r = CommitAndEnd2RV(EndWriteAccessLevel, token); + + Sleep(200); + r = DisconnectAndConnect(); + Error = r; } @@ -1737,4 +1808,4 @@ int Epd3Base::Epd3U::SetChirp(float Sensitivity) return r; error: return r; -} \ No newline at end of file +} diff --git a/EpdBase3/Epd3Base.h b/EpdBase3/Epd3Base.h index 16288fe..d6f5a1a 100644 --- a/EpdBase3/Epd3Base.h +++ b/EpdBase3/Epd3Base.h @@ -18,10 +18,12 @@ #define MaxSteps 50 #define MaxBatch 4 #define ResponseTimeout 2500 +#define DiagnosticsWriteSize 256 namespace Epd3Base { enum eFunctions { - ReadSensitivities, ReadDetectorThresholds, fReadDoses, ReadTotalDoses, ReadQualityData, ReadPeakRates, ClearTotalDose, ClearDose, ClearPeakRates, ClearFaultStatus, ClearLatchedAlarms, EpdOnOff, ReadAlarmConfiguration, ReadAlarmThresholds, WriteAlarmThresholds, WriteRateOffPercentage, DeissueEPD, SetBaselineCounters, WriteWearerId, ReadBaselineCounts, MfrLogin_R2, WriteSensitivities_R2, WriteAccessLevel + ReadSensitivities, ReadDetectorThresholds, fReadDoses, ReadTotalDoses, ReadQualityData, ReadPeakRates, ClearTotalDose, ClearDose, ClearPeakRates, ClearFaultStatus, ClearLatchedAlarms, EpdOnOff, ReadAlarmConfiguration, ReadAlarmThresholds, WriteAlarmThresholds, WriteRateOffPercentage, DeissueEPD, SetBaselineCounters, WriteWearerId, ReadBaselineCounts, MfrLogin_R2, WriteSensitivities_R2 + , WriteAccessLevelAdmin, WriteAccessLevelOpen , WriteQuickAccessDisplays_R3, WriteDisplayEnables_R3, WriteDisplayEnablePermissions_R3, WriteAlarmConfiguration_R3, WriteOffModeDisplay_R3, WriteSwitchOnFromButton_R3 , WriteChirpSensitivity, WriteChirpEnable_R3 , WriteRTC_R3 @@ -30,6 +32,8 @@ namespace Epd3Base { , fDisconnect , fDisconnectAndNotify , fStartDiscover , IssueEPD, EnableProtectedSession + , fCreateReaderInterface,fOpenReader + , TestVibe }; class Epd3U { @@ -57,6 +61,7 @@ namespace Epd3Base { WORD ErrorData; int ConnectRetries = 0; + int OpenRetries = 0; BYTE isConnected = 0; int32_t Dll3RV; @@ -271,12 +276,14 @@ namespace Epd3Base { int OpenDev(DiscoveryId DeviceID); int ReOpenDev(); int DisCon(UINT16 alarm); + int DisconnectAndConnect(); void CloseDev(bool CloseAll); void DecodeStatus(); int SetTime(); - int ReadStatus(); + int ReadStatusOnly(void); + int ReadStatus(bool statusOnly); protected: void decodeCounters(int count); @@ -288,8 +295,8 @@ namespace Epd3Base { void decodetotDoses(int count); void decodeDoses(int count); void decodePeakRates(int count); - public: + public: int SetFunctionReturnValue(eFunctions f, BYTE CanIgnore); void SetCommitReturnValue(int rv); void SetCommitReturnValue(int step, int rv); @@ -325,6 +332,9 @@ namespace Epd3Base { private: int WriteConfig(void); void ResetStepReturnValues(); + + public: + char DiagnosticsWrite[DiagnosticsWriteSize]; }; } diff --git a/EpdBaseClr/EpdBaseClr.cpp b/EpdBaseClr/EpdBaseClr.cpp index 66de5c9..4d92d24 100644 --- a/EpdBaseClr/EpdBaseClr.cpp +++ b/EpdBaseClr/EpdBaseClr.cpp @@ -781,7 +781,7 @@ int EpdBaseClr::Epd2::GetAll(bool close) return rv; } -//main entry point for exit +// Main entry point for exit int EpdBaseClr::Epd2::GetAllDeissue(bool reconnect) { ErrorRV = ErrorStep = 0; @@ -806,16 +806,18 @@ int EpdBaseClr::Epd2::GetAllDeissue(bool reconnect) /// /// /// -int EpdBaseClr::Epd2::IssueAndCheck(float gain,float ChirpRate, bool WriteConfig) +int EpdBaseClr::Epd2::IssueAndCheck(float gain, float ChirpRate, bool WriteConfig) { int rv = 0; if (!isMK3) { BeforeSetIssued(epd); rv = epd->IssueAndCheck(gain); - } else { + } + else { epd3->WriteConfig32 = WriteConfig; BeforeSetIssued(epd3); //geen interactie met epd rv = epd3->IssueAndCheck(gain, ChirpRate); // set step,error + EPDIssued = epd3->EPDIssued; } return rv; } diff --git a/TestMK3/TestMK3.cpp b/TestMK3/TestMK3.cpp index 1f754b8..a595719 100644 --- a/TestMK3/TestMK3.cpp +++ b/TestMK3/TestMK3.cpp @@ -7,7 +7,7 @@ -char comPort[] = "COM7"; +char comPort[] = "COM3"; CommsHandle epdComsHandle; uint32_t EpdID; EpdGeneration EpdGen; diff --git a/eDosLocal/UpdateLocal.sql b/eDosLocal/UpdateLocal.sql index 76c4a72..9b6cb84 100644 --- a/eDosLocal/UpdateLocal.sql +++ b/eDosLocal/UpdateLocal.sql @@ -390,7 +390,13 @@ UPDATE [dbo].[Visit] SET InitError=@InitError WHERE ID_Station=@ID_Station AND I go GRANT EXECUTE ON [dbo].[VisitInitConfirm] TO [eDosStation]; GO -ALTER PROCEDURE [dbo].[VisitInit] @PersID INT, +ALTER TABLE DBO.PersonInfoSnapshot ADD Info XML; +GO +IF OBJECT_ID('[dbo].[LocalEPD]') IS NULL BEGIN +CREATE TABLE [dbo].[LocalEPD] ( [ID_STATION] INT NOT NULL , [EPD_InternalID] VARCHAR(8) NOT NULL, [ID_EPD] INT NOT NULL, [LastUsed] DATETIME null, PRIMARY KEY([ID_STATION],[EPD_InternalID]) ) +end +GO +CREATE OR ALTER PROCEDURE [dbo].[VisitInit] @PersID INT, @ID_Task INT, @Inst_CODE INT, @EPD_InternalID INT, @@ -399,32 +405,177 @@ ALTER PROCEDURE [dbo].[VisitInit] @PersID INT, @ID_Station INT NULL, @ID_Visit INT, @ENTRY_EPD_CLOCK DECIMAL(10, 0) NULL, - @epdType TINYINT = NULL + @epdType TINYINT = NULL, + @InitError INT = 0 AS --Local !! -DECLARE @ID_EPD INT; +DECLARE @ID_EPD INT ; +DECLARE @now DATETIME = GETDATE() ; IF @ID_Station IS NULL SELECT @ID_Station = [ID_Station] FROM [dbo].[StationSettings] - WHERE [PCNr] = HOST_NAME(); + WHERE [PCNr] = HOST_NAME() ; SELECT @ID_EPD = [ID_EPD] FROM [dbo].[EPD] -WHERE [EPD_InternalID] = @EPD_InternalID; +WHERE [EPD_InternalID] = @EPD_InternalID ; IF @ID_EPD IS NULL BEGIN INSERT [dbo].[EPD]([EPD_InternalID], [EPD_sn], [EPDType]) - VALUES(@EPD_InternalID, CONVERT(VARCHAR(8), @EPD_InternalID), CASE WHEN @epdType IS NOT NULL THEN @epdType - WHEN @isBG = 0 THEN 2 ELSE 0 END); + VALUES(@EPD_InternalID, CONVERT(VARCHAR(8), @EPD_InternalID), CASE WHEN @epdType IS NOT NULL + THEN @epdType + WHEN @isBG = 0 + THEN 2 + ELSE 0 + END) ; - SET @ID_EPD = SCOPE_IDENTITY(); -END; + SET @ID_EPD = SCOPE_IDENTITY() ; +END ; -INSERT [dbo].[Visit]([ID_Station], [PersID], [Inst_CODE], [ID_Visit], [ID_Task], [EntryTime], [ID_EPD], [isBG], [isComplete], [isDeleted], [isAlarmCleared], [isAlarm], [isManualExit], [ENTRY_EPD_CLOCK], [EXIT_EPD_CLOCK], [epdType], [epdID],InitError) -VALUES(@ID_Station, @PersID, @Inst_CODE, @ID_Visit, @ID_Task, GETDATE(), @ID_EPD, @isBG, 0, 0, 0, 0, 0, @ENTRY_EPD_CLOCK, @ENTRY_EPD_CLOCK, @epdType, @EPD_InternalID,0); +IF NOT EXISTS + ( + SELECT + * + FROM [dbo].[LocalEPD] + WHERE [ID_Station] = @ID_Station + AND [EPD_InternalID] = @EPD_InternalID + ) + INSERT [dbo].[LocalEPD]([ID_EPD], [ID_Station], [EPD_InternalID], LastUsed) + VALUES(@ID_EPD, @ID_Station, CONVERT(VARCHAR(8), @EPD_InternalID), @now) ; +ELSE + UPDATE + [dbo].[LocalEPD] + SET + [LastUsed] = @now + WHERE [ID_Station] = @ID_Station + AND [EPD_InternalID] = @EPD_InternalID ; + + + + +INSERT [dbo].[Visit]([ID_Station], [PersID], [Inst_CODE], [ID_Visit], [ID_Task], [EntryTime], [ID_EPD], [isBG], [isComplete], [isDeleted], [isAlarmCleared], [isAlarm], [isManualExit], [ENTRY_EPD_CLOCK], [EXIT_EPD_CLOCK], [epdType], [epdID], [InitError] ) +VALUES(@ID_Station, @PersID, @Inst_CODE, @ID_Visit, @ID_Task, @now, @ID_EPD, @isBG, 0, 0, 0, 0, 0, @ENTRY_EPD_CLOCK, @ENTRY_EPD_CLOCK, @epdType, @EPD_InternalID, @InitError ) ; + +SET @EPDVisitID = @ID_Visit * 100+@ID_Station ; -SET @EPDVisitID = @ID_Visit * 100 + @ID_Station; GO +USE [eDosLocal] +GO +/****** Object: StoredProcedure [dbo].[GetPersonInfo] Script Date: 9/11/2024 10:10:40 AM ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE OR ALTER PROCEDURE [dbo].[GetPersonInfo] + @CSN CHAR(14) = NULL, + @PersID INT = NULL, + @AllowMultipleEPD BIT = 0, + @CheckUser BIT = 1 +AS +BEGIN + --DECLARE @PersID INT = 12103, @CSN CHAR(14) = null,@AllowMultipleEPD BIT = 0; + SET NOCOUNT ON; + + DECLARE @lid_station INT, + @lid_visit INT; + + IF @PersID IS NULL + SELECT @PersID = [PersID] + FROM [dbo].[PersonInfoSnapshot] + WHERE [CSN] = @CSN COLLATE SQL_Latin1_General_CP850_BIN; + + SET NOCOUNT OFF; + + SELECT TOP (1) + @lid_station = [ID_Station], + @lid_visit = [ID_Visit] + FROM [dbo].[Visit] + WHERE [PersID] = @PersID + AND [ReturnTime] IS NULL + AND [EntryTime] > DATEADD(YEAR, -1, GETDATE()) + AND [InitError]=0; + + SELECT [a].[PersID], + [a].[Type], + [a].[CSN], + [a].[FirstName], + [a].[LastName], + [a].[NickName], + [AccessAllow] = CONVERT( BIT, + CASE + WHEN @AllowMultipleEPD = 1 + AND [a].[hasEPD] = 1 THEN + 0 + ELSE + [a].[AccessAllow] + END + ), + [a].[Language], + [a].[MarginHP10_M], + [a].[MarginHP10_Y], + [a].[Margin], + [a].[VisitIDLocked], + [a].[ID_CommentToPerson], + [a].[Comment], + [a].[Deleted], + [ReasonNoAccess] = CASE + WHEN @AllowMultipleEPD = 1 + AND [a].[hasEPD] = 1 THEN + 'EPD not returned' + WHEN ISNULL([VisitIDLocked], 0) > 0 THEN + 'Locked because of alarm' + ELSE + [a].[ReasonNoAccess] + END, + [a].[Dose_52W_microSv], + [a].[hasEPD], + [activeStation] = @lid_station, + [activeVisit] = @lid_visit, + [a].[isAgent] + FROM + ( + SELECT [p].[PersID], + [p].[Type], + [p].[CSN], + [p].[FirstName], + [p].[LastName], + [p].[NickName], + [AccessAllow] = CASE + WHEN @CheckUser = 0 THEN + 1 + ELSE + [p].[AccessAllow] + END, + [p].[Language], + [p].[MarginHP10_M], + [p].[MarginHP10_Y], + [p].[Margin], + [p].[VisitIDLocked], + [p].[ID_CommentToPerson], + [p].[Comment], + [p].[Deleted], + [p].[ReasonNoAccess], + [p].[Dose_52W_microSv], + [hasEPD] = CONVERT( BIT, + CASE + WHEN @lid_visit IS NOT NULL THEN + 1 + ELSE + 0 + END + ), + [isAgent] = CONVERT( BIT, + CASE + WHEN [p].[isAgent] IS NULL THEN + 0 + ELSE + [p].[isAgent] + END + ) + FROM [dbo].[PersonInfoSnapshot] [p] + WHERE [p].[PersID] = @PersID + ) [a]; +END; diff --git a/eDosLocal/eDosLocal.sqlproj b/eDosLocal/eDosLocal.sqlproj index 6d0de8d..661e5b8 100644 --- a/eDosLocal/eDosLocal.sqlproj +++ b/eDosLocal/eDosLocal.sqlproj @@ -1,64 +1,68 @@ - - - - Debug - AnyCPU - eDosLocal - 2.0 - 4.1 - {3a150025-d770-4521-ba21-16843b2d5359} - Microsoft.Data.Tools.Schema.Sql.Sql130DatabaseSchemaProvider - Database - - - eDosLocal - eDosLocal - 1033, CI - BySchemaAndSchemaType - True - v4.5 - CS - Properties - False - True - True - - - bin\Release\ - $(MSBuildProjectName).sql - False - pdbonly - true - false - true - prompt - 4 - - - bin\Debug\ - $(MSBuildProjectName).sql - false - true - full - false - true - true - prompt - 4 - - - 11.0 - - True - 11.0 - - - - - - - - - - + + + + Debug + AnyCPU + eDosLocal + 2.0 + 4.1 + {3a150025-d770-4521-ba21-16843b2d5359} + Microsoft.Data.Tools.Schema.Sql.Sql130DatabaseSchemaProvider + Database + + + eDosLocal + eDosLocal + 1033, CI + BySchemaAndSchemaType + True + v4.5 + CS + Properties + False + True + True + + + bin\Release\ + $(MSBuildProjectName).sql + False + pdbonly + true + false + true + prompt + 4 + + + bin\Debug\ + $(MSBuildProjectName).sql + false + true + full + false + true + true + prompt + 4 + + + 11.0 + + True + 11.0 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/eDosLocal/eDosLocalProcedures.sql b/eDosLocal/eDosLocalProcedures.sql new file mode 100644 index 0000000..1bbba85 Binary files /dev/null and b/eDosLocal/eDosLocalProcedures.sql differ diff --git a/eDosLocal/eDosLocalTables.sql b/eDosLocal/eDosLocalTables.sql new file mode 100644 index 0000000..c8ae38b Binary files /dev/null and b/eDosLocal/eDosLocalTables.sql differ diff --git a/eDosStation/DataInterface.cs b/eDosStation/DataInterface.cs index 5d23ce2..011ef42 100644 --- a/eDosStation/DataInterface.cs +++ b/eDosStation/DataInterface.cs @@ -220,6 +220,7 @@ namespace eDosStation , new System.Data.SqlClient.SqlParameter("ID_Visit",SqlDbType.Int,0,System.Data.ParameterDirection.Input,false,0,0,null,System.Data.DataRowVersion.Default,null) , new System.Data.SqlClient.SqlParameter("ENTRY_EPD_CLOCK",SqlDbType.Decimal,0,System.Data.ParameterDirection.Input,false,10,0,null,System.Data.DataRowVersion.Default,null) , new System.Data.SqlClient.SqlParameter("epdType",SqlDbType.TinyInt,0,System.Data.ParameterDirection.Input,false,0,0,null,System.Data.DataRowVersion.Default,null) + , new System.Data.SqlClient.SqlParameter("InitError",SqlDbType.Int,0,System.Data.ParameterDirection.Input,false,0,0,null,System.Data.DataRowVersion.Default,null) }); VisitInitConfirmCommand = new System.Data.SqlClient.SqlCommand("[dbo].[VisitInitConfirm]", localConnection) { CommandType = System.Data.CommandType.StoredProcedure }; diff --git a/eDosStation/DecodeResults.cs b/eDosStation/DecodeResults.cs index 25067ce..1f6325c 100644 --- a/eDosStation/DecodeResults.cs +++ b/eDosStation/DecodeResults.cs @@ -33,7 +33,8 @@ namespace eDosStation "ReadBaselineCounts", "MfrLogin_R2", "WriteSensitivities_R2", - "WriteAccessLevel", + "WriteAccessLevelAmin", + "WriteAccessLevelOpen", "WriteQuickAccessDisplays_R3", "WriteDisplayEnables_R3", "WriteDisplayEnablePermissions_R3", @@ -45,6 +46,8 @@ namespace eDosStation ,"DestroyReaderInterface" //0=ok ,"Disconnect" , "DisconnectAndNotify" //0=ok ,"StartDiscover","IssueEPD","EnableProtectedSession_R3" + ,"CreateReaderInterface" + ,"OpenReader","TestVibe" }; private static string GetName(int func) diff --git a/eDosStation/EntryBadge.xaml b/eDosStation/EntryBadge.xaml index d792334..9e59d53 100644 --- a/eDosStation/EntryBadge.xaml +++ b/eDosStation/EntryBadge.xaml @@ -46,8 +46,8 @@ - - + + @@ -98,7 +98,7 @@ - + @@ -291,8 +291,8 @@ - - + + @@ -300,7 +300,7 @@ - + @@ -319,6 +319,7 @@ + @@ -335,44 +336,41 @@ - + Ready Please take your EPD - - + + + - - + + + + - - + + + - - - - - - - - - - - - - - - - + + + + + + + + + @@ -383,7 +381,7 @@ - + @@ -395,7 +393,6 @@ - diff --git a/eDosStation/EntryBadge.xaml.cs b/eDosStation/EntryBadge.xaml.cs index 64850f7..fd18034 100644 --- a/eDosStation/EntryBadge.xaml.cs +++ b/eDosStation/EntryBadge.xaml.cs @@ -239,17 +239,18 @@ namespace eDosStation dataInterface.VisitInitCommand.Parameters["ENTRY_EPD_CLOCK"].Value = ep.CountsClock; dataInterface.VisitInitCommand.Parameters["epdType"].Value = (byte)ep.epdType; dataInterface.VisitInitCommand.Parameters["EPDVisitID"].Value = 0; - using (var l = new SqlLog()) - try - { - dataInterface.VisitInitCommand.ExecuteNonQuery(); - l.LogCommand(dataInterface.VisitInitCommand); - } - catch (System.Exception ex) - { - l.LogCommand(ex.Message); - MessageBox.Show(ex.Message); - } + dataInterface.VisitInitCommand.Parameters["InitError"].Value = 0; + //using (var l = new SqlLog()) + // try + // { + // dataInterface.VisitInitCommand.ExecuteNonQuery(); + // l.LogCommand(dataInterface.VisitInitCommand); + // } + // catch (System.Exception ex) + // { + // l.LogCommand(ex.Message); + // MessageBox.Show(ex.Message); + // } //StationVisitID = (int?)dataInterface.VisitInitCommand.Parameters["EPDVisitID"].Value; StationVisitID = ID_Visit * 100 + thisStation.ID_Station; //co.Close(); @@ -318,6 +319,7 @@ namespace eDosStation if (!CurTaskRow.IsChirpRateNull()) ChirpRate = (int)CurTaskRow.ChirpRate; //doing stuff on EPD + int rv = ep.IssueAndCheck(gain, ChirpRate, thisStation.WriteConfig); if (rv != 0 || thisStation.LogAll || ep.HasStepError()) @@ -330,28 +332,50 @@ namespace eDosStation lbHP07.Text = ep.Hp07Name; lbHP10.Text = ep.Hp10Name; - if (rv != 0) + if (ep.EPDIssued) { - MessageBox.Show($"SetIssued error {rv}"); - step = "SqlConfirmVisit"; - dataInterface.VisitInitConfirmCommand.Connection = co; - dataInterface.VisitInitConfirmCommand.Parameters["ID_Station"].Value = thisStation.ID_Station; - dataInterface.VisitInitConfirmCommand.Parameters["ID_Visit"].Value = ID_Visit; - dataInterface.VisitInitConfirmCommand.Parameters["InitError"].Value = rv; - try + using (var l = new SqlLog()) { - dataInterface.VisitInitConfirmCommand.ExecuteNonQuery(); - //l.LogCommand(dataInterface.VisitInitCommand); - } - catch (System.Exception ex) - { - //l.LogCommand(ex.Message); - MessageBox.Show(ex.Message); - thisStation.splunkLog.WriteException(module, step, ex); + try + { + dataInterface.VisitInitCommand.Parameters["InitError"].Value = rv; + dataInterface.VisitInitCommand.ExecuteNonQuery(); + l.LogCommand(dataInterface.VisitInitCommand); + } + catch (System.Exception ex) + { + l.LogCommand(ex.Message); + thisStation.splunkLog.WriteException(module, step, ex); + MessageBox.Show(ex.Message); + } + + //if (rv != 0) + //{ + // MessageBox.Show($"SetIssued error {rv}"); + // step = "SqlConfirmVisit"; + // dataInterface.VisitInitConfirmCommand.Connection = co; + // dataInterface.VisitInitConfirmCommand.Parameters["ID_Station"].Value = thisStation.ID_Station; + // dataInterface.VisitInitConfirmCommand.Parameters["ID_Visit"].Value = ID_Visit; + // dataInterface.VisitInitConfirmCommand.Parameters["InitError"].Value = rv; + // try + // { + // dataInterface.VisitInitConfirmCommand.ExecuteNonQuery(); + // //l.LogCommand(dataInterface.VisitInitCommand); + // } + // catch (System.Exception ex) + // { + // //l.LogCommand(ex.Message); + // MessageBox.Show(ex.Message); + // thisStation.splunkLog.WriteException(module, step, ex); + // l.LogCommand(ex.Message); + // } + //} } } + else + MessageBox.Show("No registration",string.Empty,MessageBoxButton.OK,MessageBoxImage.Error); co.Close(); - ShowFinal(); + ShowFinal(rv); } } else @@ -369,8 +393,27 @@ namespace eDosStation new Action(delegate { })); } - private void ShowFinal() + + private void ShowFinal(int ReturnValue) { + Run run; + FinalHeader.Inlines.Clear(); + if (ReturnValue == 0) { + FinalHeader.Inlines.Add(Properties.Resources.FinalEpdOkHeader); + FinalHeader.Inlines.Add(new LineBreak()); + run = new Run(Properties.Resources.FinalEpdOkSecond); + run.Foreground = System.Windows.Media.Brushes.Green; + run.Background= System.Windows.Media.Brushes.White; + FinalHeader.Inlines.Add(run); + } else { + FinalHeader.Inlines.Add(Properties.Resources.FinalEpdNotOkHeader); + FinalHeader.Inlines.Add(new LineBreak()); + run = new Run(Properties.Resources.FinalEpdNotOkSecond); + run.Foreground = System.Windows.Media.Brushes.Red; + run.Background = System.Windows.Media.Brushes.Yellow; + FinalHeader.Inlines.Add(run); + } + FinalTimeOut = false; dispatcherTimer = new DispatcherTimer(DispatcherPriority.Background); dispatcherTimer.Interval = thisStation.InfoProgressbarInterval; @@ -378,7 +421,7 @@ namespace eDosStation ResultTime = DateTime.Now.AddSeconds(thisStation.InfoScreenTimeout); pWaitEpd.Value = pWaitEpd.Maximum = thisStation.InfoScreenTimeout; pWaitEpd.Visibility = Visibility.Visible; - tWaitFor.Text = "EPD Ready "; + panelWait.Visibility = Visibility.Collapsed; panelDone.Visibility = Visibility.Visible; bEpdCancel.Content = "OK"; bEpdCancel.IsEnabled = true; diff --git a/eDosStation/MainWindow.xaml.cs b/eDosStation/MainWindow.xaml.cs index e2a98b7..df5640e 100644 --- a/eDosStation/MainWindow.xaml.cs +++ b/eDosStation/MainWindow.xaml.cs @@ -27,7 +27,7 @@ namespace eDosStation { string ers = string.Empty; - if (thisStation.RestartCom && (thisStation.RestartComFirst == true)) + if (thisStation.RestartCom && thisStation.RestartComFirst ) { thisStation.DeviceRestart(); } @@ -35,7 +35,7 @@ namespace eDosStation var w = new ShowEPDDose(thisStation); w.ShowDialog(); - if (thisStation.RestartCom && (thisStation.RestartComFirst == true)) + if (thisStation.RestartCom && !thisStation.RestartComFirst ) { thisStation.DeviceRestart(); } @@ -49,7 +49,7 @@ namespace eDosStation string step = "DeviceRestart"; try { - if (thisStation.RestartCom && (thisStation.RestartComFirst == true)) + if (thisStation.RestartCom && thisStation.RestartComFirst) { thisStation.DeviceRestart(); } @@ -77,7 +77,7 @@ namespace eDosStation step = "DeviceReset2"; try { - if (thisStation.RestartCom && !(thisStation.RestartComFirst == true)) + if (thisStation.RestartCom && !thisStation.RestartComFirst) { thisStation.DeviceRestart(); } @@ -104,7 +104,7 @@ namespace eDosStation #endif w.ShowDialog(); w = null; - if (thisStation.RestartCom && !(thisStation.RestartComFirst)) + if (thisStation.RestartCom && !thisStation.RestartComFirst) { ers = thisStation.DeviceRestart(); } diff --git a/eDosStation/Properties/AssemblyInfo.cs b/eDosStation/Properties/AssemblyInfo.cs index b3f6de5..7cf8c82 100644 --- a/eDosStation/Properties/AssemblyInfo.cs +++ b/eDosStation/Properties/AssemblyInfo.cs @@ -58,5 +58,8 @@ using System.Windows; //2.22 No clear bij deissue. //2.27 Display wait while issuing //2.28 After testing -[assembly: AssemblyVersion("2.28.0.0")] -[assembly: AssemblyFileVersion("2.28.0.0")] +//2.29 Met endcom +//2.30 check reset voor OF na EPD verbinding +//2.31 extra disconnect/connect +[assembly: AssemblyVersion("2.31.0.0")] +[assembly: AssemblyFileVersion("2.31.0.0")] diff --git a/eDosStation/Properties/Resources.Designer.cs b/eDosStation/Properties/Resources.Designer.cs index 9eec954..0e7533d 100644 --- a/eDosStation/Properties/Resources.Designer.cs +++ b/eDosStation/Properties/Resources.Designer.cs @@ -61,7 +61,7 @@ namespace eDosStation.Properties { } /// - /// Looks up a localized string similar to Thu 05/16/2024 15:48:58.18 + /// Looks up a localized string similar to Wed 09/11/2024 10:46:38.88 ///. /// internal static string BuildDate { @@ -69,5 +69,43 @@ namespace eDosStation.Properties { return ResourceManager.GetString("BuildDate", resourceCulture); } } + + /// + /// Looks up a localized string similar to EPD Failed !. + /// + internal static string FinalEpdNotOkHeader { + get { + return ResourceManager.GetString("FinalEpdNotOkHeader", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Please try again + ///. + /// + internal static string FinalEpdNotOkSecond { + get { + return ResourceManager.GetString("FinalEpdNotOkSecond", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to EPD Ready. + /// + internal static string FinalEpdOkHeader { + get { + return ResourceManager.GetString("FinalEpdOkHeader", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Please take your EPD + ///. + /// + internal static string FinalEpdOkSecond { + get { + return ResourceManager.GetString("FinalEpdOkSecond", resourceCulture); + } + } } } diff --git a/eDosStation/Properties/Resources.resx b/eDosStation/Properties/Resources.resx index 8a639f7..5c445af 100644 --- a/eDosStation/Properties/Resources.resx +++ b/eDosStation/Properties/Resources.resx @@ -121,4 +121,18 @@ ..\Resources\BuildDate.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + EPD Failed ! + + + Please try again + + + + EPD Ready + + + Please take your EPD + + \ No newline at end of file diff --git a/eDosStation/Resources/BuildDate.txt b/eDosStation/Resources/BuildDate.txt index 72ec4f5..48fce2d 100644 --- a/eDosStation/Resources/BuildDate.txt +++ b/eDosStation/Resources/BuildDate.txt @@ -1 +1 @@ -Mon 09/09/2024 10:26:16.80 +Wed 09/11/2024 13:50:26.43 diff --git a/eDosStation/Settings.xaml b/eDosStation/Settings.xaml index accee93..ec269b9 100644 --- a/eDosStation/Settings.xaml +++ b/eDosStation/Settings.xaml @@ -6,10 +6,10 @@ xmlns:local="clr-namespace:eDosStation" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" mc:Ignorable="d" - Title="Settings" Height="448.033" Width="702.744" + Title="Settings" Height="479.533" Width="702.744" FontFamily="Segoe UI" FontSize="20" Loaded="Window_Loaded"> - + diff --git a/eDosStation/cDevCon.cs b/eDosStation/cDevCon.cs index 11766fe..e5740dc 100644 --- a/eDosStation/cDevCon.cs +++ b/eDosStation/cDevCon.cs @@ -44,7 +44,8 @@ namespace eDosStation if (System.IO.File.Exists(DevConExePath)) hasCommand = true; } } - else spl?.WriteSplunkLog(className, cspl.iseverity.warning, "No Admin"); + else + spl?.WriteSplunkLog(className, cspl.iseverity.warning, "No Admin"); } private string ExecuteDevcon(string command) { diff --git a/scripts/Upgrader.ps1 b/scripts/Upgrader.ps1 index af80787..51f2a23 100644 --- a/scripts/Upgrader.ps1 +++ b/scripts/Upgrader.ps1 @@ -213,17 +213,17 @@ exit # aWdpQ2VydCwgSW5jLjE7MDkGA1UEAxMyRGlnaUNlcnQgVHJ1c3RlZCBHNCBSU0E0 # MDk2IFNIQTI1NiBUaW1lU3RhbXBpbmcgQ0ECEAVEr/OUnQg5pr/bP1/lYRYwDQYJ # YIZIAWUDBAIBBQCgaTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3 -# DQEJBTEPFw0yNDA5MDkwOTA4NDJaMC8GCSqGSIb3DQEJBDEiBCDbjZuxJgcSDufz -# +ekiprJJKPMdOid8HFavnX4C8hgeWzANBgkqhkiG9w0BAQEFAASCAgAvDFz5Vo34 -# 2MO+GnnnzbqXIY3Lsho9iLPCjIl6OkJbH4HbzvU5UUEo2fGVsnINfIfOVN+slEal -# 9dpPaFdpczYf9zEGxPYpOumWqRdIY8Xl550IF5S834PiAMzlMAu7iwjDjEspk7bG -# wcxKI+DdSdru4Uj88gbJWWYbt0967R7bi6TmFzuYC38g4sknmq9AklgykrtypG+I -# inlzP3iorB9m3IfD3PmG7Rqp1qAsai4aXvyzEpM8SD/HNYlXyWa5/2GbqX3Qjhd6 -# XtSqFsRfZcDThGpbi53I0LxbRYc5mWUpOgCbFq3u/fWmqJ2MYQXbmP2p0zkGu4jL -# w3l7ENgL1gGJfralDftUr+UN6tjAuUtPoV3h5tvnr22EjX+Hs8g44dXtL4FN/pfL -# wkDvPLSBjhxoaND0/i4IzgAwWPaVuLWTSUDaZaBnxPskpfavhyT+a0V7RUutv2NZ -# FULkI2AnX0fs8kF5XIy1K0WEAM5cyMvhD4PlZm6orNlFZI79WQ2BzDrBqUrtWQs7 -# PddaEKi+fckABsYeV9AaGsfpbt5WsUHTG8fBK4ZL3Z5saCFgc90ZxdRf+XKwwtTL -# FqMom33K3eSpMKabSMYAI2kNGVvMWP3HnfSpqAcKsZy7dNYG25ljZkVZKmF5JV9G -# 2951cTy1Qfx/bm2EKcXM3J2uFM5DfpPalA== +# DQEJBTEPFw0yNDA5MTExMTUwNDNaMC8GCSqGSIb3DQEJBDEiBCDbjZuxJgcSDufz +# +ekiprJJKPMdOid8HFavnX4C8hgeWzANBgkqhkiG9w0BAQEFAASCAgCdOGquU2OU +# Q2fyo4YjFnW1g0vehLEpsMqn4snKEefbFcWDaEVlB+6+md4HrStpfx9de5woy+yQ +# EdEI6CXC4FBu/vDo9kocHE2RGPNKBmXfBnVHX8G0VhyyjsqePymv9LpcM18IRgpf +# nAgBEPIeQPLc132O2iCBKr1P8/y1kuY5QbG8e5hkLP5rk6ZB5Nw5eId1oy/vMTs3 +# DEOiIaO4Cgbguxp5z4xJ2x4xXO0rYC4NP4DYAMIEUdr2TbqR0DpfibMqandsV/dK +# Dr6MSW4G6nTkEyo+QVh+xfmgFjO+RaQwYLfIXKfuwP6W7k+nhKCNKMYRoAyjqrsC +# Lp/Y2WIS498FLt8qGBXOK4aTEbwCcM799m8qIKnPF2l034Y/mkjaG8G1l4xl25SA +# ITWdQdBe0NQTJ0IXRX+PLejQbQlIe/tSdAMLlSYc1+MddMi+Qf1XB5IhqORDsRUL +# KKc9IqhOhZDoyBwkRxWse8lqN0mioOwHUnrlv2lTDDivkaXckuzC7pPLdFAmTHxo +# cwuMd+I2VmLgH2U7x5lALCSuPt9fbNAxvprHUTHniZVrtNH8EcCZXWs6puAgawDI +# LNCVc78XsA510FxdJJec+XDmx3XrC/OVP9d8H51QAzZVCak0z+tZSifHyErb19LL +# On+wO7ZduMmE9xHuwyZsuasFK1IXkxgH5w== # SIG # End signature block diff --git a/scripts/installatie.ps1 b/scripts/installatie.ps1 index 8c342a5..af8bf58 100644 --- a/scripts/installatie.ps1 +++ b/scripts/installatie.ps1 @@ -328,17 +328,17 @@ exit # aWdpQ2VydCwgSW5jLjE7MDkGA1UEAxMyRGlnaUNlcnQgVHJ1c3RlZCBHNCBSU0E0 # MDk2IFNIQTI1NiBUaW1lU3RhbXBpbmcgQ0ECEAVEr/OUnQg5pr/bP1/lYRYwDQYJ # YIZIAWUDBAIBBQCgaTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3 -# DQEJBTEPFw0yNDA5MDkwOTA4NDJaMC8GCSqGSIb3DQEJBDEiBCAcllG2mSPxCJ8u -# oQsIqOunNyELPZuVN2PuUwDZLmIbpTANBgkqhkiG9w0BAQEFAASCAgANDH5u1OSV -# cJXiELrSQ0jqn+XQjgAPQMtzrKQA3ukod36kbfHudvnp1YlOTffz3LsAayEXf9Wv -# HxyAF+RDHBFjcQuQRgye5HhOWNphB7xfFbMFgjQtC7pgH7vSCqqS42Zh4h9PlQCx -# i4AfLS78d6W40Thf5ZS5TCtPE9+FjMxwOE6/4rVp0xMT1EVa6KCKczP6z9mLOVA9 -# O9CYau+9l2s3dbOHPMRYU9HPGkn6ilziy2K2skVeUuRB8bbxEFoKpcIWt7720mQ5 -# Irsw8ByyYLjNSJkCnO0nZc2xaNrHgScimeCfpQY3wIUwVV/62LMIAYLID47Xvm4h -# kBjlhgO6fKcsrowiTbtCZLZtlZNBpjX7KBrFYLsFPCKWRS3mx7/jgdgoIs5Jr0dD -# BGt6GYOIaapVqKvEk7p0YSpJ+tuNuz1V9jM6Yd1LmhqqeY1sJTTW058pU3DhMa9J -# g/s9VCUaT/L51NPwnghM54l7flsjMG3RWhySONatjnQeLIwAt50iVpKrrQpGuZIR -# WAacqX7HuGuPUWWZbKgwfaRtwUB6n6ArTqMh45AqZDzBAgSVU1UZUd52khO+GwR0 -# yucq9tFyys+iKQc4aXcHOaCvuAdbIxoQbv+3FGW0wUL2syI0/03TV/+sxOe9OlW0 -# gIyTzYLvf/X1/sTlkFHCtPZmnIrTyVRxbA== +# DQEJBTEPFw0yNDA5MTExMTUwNDNaMC8GCSqGSIb3DQEJBDEiBCAcllG2mSPxCJ8u +# oQsIqOunNyELPZuVN2PuUwDZLmIbpTANBgkqhkiG9w0BAQEFAASCAgBVDloKj3Yf +# n7yhN54T1PZ1nKLtvU5/k4jYu5LOQzopTJJJqE9vzLLOLLhw0MlieXsuoXBDdijX +# nA6SwUsP+eJFoQlXhAQtjEbAM7CPCNou3sGxo5tAG3RpF3N9Aq2KISXO06vtyAq+ +# 7ISuD/3omQ31Ub8g0kOvvEBb2mZaLXT84G2BYI9asyhVmYEFG4Qq4ufSm04gWUxB +# w2KAWni3czEg6h1e5a3HzZeylYBYMVRZlbbjRYL+tdSgDX6Lfq4b/kWGRKdhdnWH +# cloLsXREiWaD8k0EamjPWD7Sl/wFv8reyZCBLdRTmOaPxdUxeeyhdaD6qsExDnUD +# YXiwCMGRQ+zR/zUlsHObK3igwISU2/XUs1JaDav58lP+jV+MFb5deHL+I50KYdZH +# /4GiYRQnsZzUHuDkycay9iFSZss9WAxdEfXilnZI7rPNRVcIzTd60Rq3mIdtQXEn +# 3zkmcCTQq4MB2O50I9fHUGT6q3SgUE4vACSqx8VdnmgWXjTnVCglNw1dYKC9FMr0 +# AAUx+Ao6pKxc+HPfln2D3Oi12ChCmIpkyq6FCU9QgshyKiYNuwDa0YX+P3EfGWct +# vrUb0qgQA+QrnIESLN74WMDkjJpKcbr3sfOX+8hnTkQUfBv+75Ib/Vi2PalMCUFs +# PSOnDjh++ps5WMcZ0rNM6AnZRZ11bXKeyQ== # SIG # End signature block diff --git a/scripts/installatie2.ps1 b/scripts/installatie2.ps1 index 094c613..d1d1516 100644 --- a/scripts/installatie2.ps1 +++ b/scripts/installatie2.ps1 @@ -192,17 +192,17 @@ exit # aWdpQ2VydCwgSW5jLjE7MDkGA1UEAxMyRGlnaUNlcnQgVHJ1c3RlZCBHNCBSU0E0 # MDk2IFNIQTI1NiBUaW1lU3RhbXBpbmcgQ0ECEAVEr/OUnQg5pr/bP1/lYRYwDQYJ # YIZIAWUDBAIBBQCgaTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3 -# DQEJBTEPFw0yNDA5MDkwOTA4NDJaMC8GCSqGSIb3DQEJBDEiBCDpOCR32+BElOsp -# pr9o2qvS6Cq0zGXXv8N/urfnLBwlITANBgkqhkiG9w0BAQEFAASCAgCNlSoY6fdc -# g6JHWpkvaNL5I5tHlHg5mXiy9aWHLNT6vWVke6fBNDLpfiRp7JjoPiBA0sWXh563 -# Vb0xjsJbW3ubDegN6jG+TbD5AH0vFXyANmVGjw8Mi4ylMMCw4QXvNo83QSQDttk7 -# ykJaYnk+DPAbU0h2/NWvkRK4y2kBGdOjTjkp4ZKubc/0rsiJg4EOnsvMz12+GNiT -# frMAGcuix6kUe6IqdS0PjnNp8ne7oN2Nb2AuyJt944VBfVh518xPPDEtbeT2pR7X -# 6P521k2fkOQZZpuZE/PzPSXyZ/1qB8UDbteTOpNEMKuEKy0wrIyxQf3C/mldAerW -# 39YVgAjSCCcNW0IKF9ndLq+0xH3Ie9WppP3rvx4t9Xu1Ypq8HsrfwAMG+W1lern4 -# zVCDsGPvl0HHeHHX7ZAKqNpMmkl0oAvO+KXs1VMK7EcM80MSUwzNRfHZURAlcC08 -# j4QIt1kPqGnsKrWeMk0I6Wk81FgOJY27QG+ms4utIbbKVAFiPGXS7QcIXfFKDdu+ -# VsaBfr9SSGQj/LYBupJIbhfRHyTt8A9M2svNYvliiG+sJGtxYGhLLjMRwDCIBAAV -# DiXSiys+jpF9yKNl7jSMjQM18u2lnKa9ZU0KB24Q244Fkjli3suRoVHU14UltG2q -# gmuXlJyR/K7fBS1/gQ7nBuDu6WyTdKNVmg== +# DQEJBTEPFw0yNDA5MTExMTUwNDNaMC8GCSqGSIb3DQEJBDEiBCDpOCR32+BElOsp +# pr9o2qvS6Cq0zGXXv8N/urfnLBwlITANBgkqhkiG9w0BAQEFAASCAgBuJTD9TYOz +# QLhMKqUMcdjaOt5sPzOp10XEmwiUgAHGxTSkhsuMyfuDMblGrOPOwRgcgiJBzDur +# AwqHknWsPr3DN3VFwXKBAudJfcj1C+iMWIhDdHT4kVHpDJWjropSL0D9Y64UUAGc +# E/8rBldSffjSxWgsgpSFaAwZTEBHCI3XUg3yaQvIiEj3X4BVY51sin+mrxpOSIc0 +# Lz3ZtK92x8G+7mFo5/Vu+ztskVGqL1qZoFH1Igu5GynAx13ob4hjnirotzNlxP6m +# anjirjCn127GGBwttrSgIAkp+kVkU3QIurE2jfV7G4/+QmAO6bQB1jX3kWzgJFxq +# 9SUcRavTIBh7hK2Bk+5sAFUHgPaTVLOHWbsUGOs4nudBem+Y14+zDg7hgwtPMca6 +# XKsZ03t4seH+AjfJBNfrPgVpp1hyZy9Zww7SNIcdkYmYd6UA7Zn9JtMj7ILnRcbL +# RYLP1Caq3+PmG2v5pOgoVjzpcTtfOztFLdrh0WOUWJpoRiQBd2AEWhGNuor2LUkF +# 4M5KuMVoYZysX/hFXnRJiKHVtybu7LvlUg53TuPN34TAyA78ORM3upYRJ8zD+oY1 +# igE6ReWNGSqHNoR73SNfjcBo8k4DnMNDlg3/K1U9SPhFILGGanmGKM4iEP+sUqxJ +# HLW92mevPa0g1JJaWnNnsnfQqXFOoNktEQ== # SIG # End signature block diff --git a/syncEdosLocal/Program.cs b/syncEdosLocal/Program.cs index 2b30403..5dbbe3f 100644 --- a/syncEdosLocal/Program.cs +++ b/syncEdosLocal/Program.cs @@ -154,6 +154,8 @@ namespace syncEdosLocal } public static bool DoorloopToDo(System.Data.SqlClient.SqlConnection fromConnection, string toConstr, System.Data.SqlClient.SqlInfoMessageEventHandler im, ref bool error, ref bool warning) { + int ciIgnoreError = -1; + bool ignorederror = false; ds = new DataSet(); DataTable dtTables = new DataTable("Tables"); ds.Tables.Add(dtTables); @@ -164,6 +166,8 @@ namespace syncEdosLocal { spLog.KvClear(); cmd.CommandType = CommandType.StoredProcedure; + SqlParameter pa = new SqlParameter("@withIgnoreError", true); + cmd.Parameters.Add(pa); spLog.KvAddCommand(spl.skeys.sqlQuery, cmd); using (var ncta = new System.Data.SqlClient.SqlDataAdapter(cmd)) { @@ -171,6 +175,7 @@ namespace syncEdosLocal { ncta.Fill(dtTables); int r = dtTables.Rows.Count; + ciIgnoreError = dtTables.Columns.IndexOf("ignoreError"); spLog.KvAdd(spl.skeys.recordsAffected, r); spLog.WriteSplunkLog(string.Empty, spl.iseverity.info, "LoadTables"); } @@ -230,6 +235,7 @@ namespace syncEdosLocal foreach (DataRow rtr in dtTables.Rows) { + ucmd.Parameters["OBJECT_ID"].Value = (int)rtr[0]; string src = rtr[1].ToString(); dest = rtr[2].ToString(); @@ -277,11 +283,19 @@ namespace syncEdosLocal int cnt = 0; qry = LSWLib.SqlCommands.getColumnsQry(fromConnection, src); SqlConnection[] curDests = new SqlConnection[] { toConnection }; + System.Diagnostics.Debug.WriteLine(Task); + ignorederror = false; cnt = Bulker.Execute(Task, fromConnection, curDests, qry, CommandType.Text, dest, 0, ref error); ucmd.Parameters["lastRecords"].Value = cnt; if (dest.Contains("PersonInfo")) Result.Persons = cnt; else if (dest.Contains("TaskInfo")) Result.Tasks = cnt; + if (error && ciIgnoreError >= 0 && rtr[ciIgnoreError] is bool && (bool)rtr[ciIgnoreError]) + { + error = false; + ignorederror = true; + spLog.WriteSplunkLog(string.Empty, spLog.splunkSeverity, "ignored", Task); + } if (sqlCmdsActivate != null) using (var cmd = new System.Data.SqlClient.SqlCommand(sqlCmdsActivate.ToString(), toConnection)) @@ -306,7 +320,7 @@ namespace syncEdosLocal spLog.WriteSplunkLog(string.Empty, spLog.splunkSeverity, "constraintsActivated", spLog.splunkError); } } - ucmd.Parameters["syncError"].Value = error; + ucmd.Parameters["syncError"].Value = error | ignorederror; ucmd.ExecuteNonQuery(); if (error) break; } @@ -516,43 +530,43 @@ namespace syncEdosLocal try { cr["ReturnTime"] = lr["ReturnTime"]; - cr["Hp10Dose"] = lr["Hp10Dose"]; - cr["Hp07Dose"] = lr["Hp07Dose"]; - cr["Hp10Total"] = lr["Hp10Total"]; - cr["Hp07Total"] = lr["Hp07Total"]; - cr["Hp10Peak"] = lr["Hp10Peak"]; - cr["Hp07Peak"] = lr["Hp07Peak"]; - cr["Hp10Time"] = lr["Hp10Time"]; - cr["Hp07Time"] = lr["Hp07Time"]; - cr["QualityData"] = lr["QualityData"]; - cr["K1"] = lr["K1"]; - cr["K2"] = lr["K2"]; - cr["K3"] = lr["K3"]; - cr["K4"] = lr["K4"]; - cr["K5"] = lr["K5"]; - cr["K6"] = lr["K6"]; - cr["SG"] = lr["SG"]; - cr["BC"] = lr["BC"]; - cr["FB"] = lr["FB"]; - cr["HG"] = lr["HG"]; - cr["alarmStatus"] = lr["alarmStatus"]; - cr["otherAlarms"] = lr["otherAlarms"]; - cr["errorStatus"] = lr["errorStatus"]; - cr["operatingStatus"] = lr["operatingStatus"]; - cr["isAlarm"] = lr["isAlarm"]; - cr["isAlarmCleared"] = lr["isAlarmCleared"]; - cr["ENTRY_EPD_CLOCK"] = lr["ENTRY_EPD_CLOCK"]; - cr["EXIT_EPD_CLOCK"] = lr["EXIT_EPD_CLOCK"]; - cr["TIME_LOST"] = lr["TIME_LOST"]; - cr["eDosBatteryWarning"] = lr["eDosBatteryWarning"]; - cr["eDosDose07Warning"] = lr["eDosDose07Warning"]; - cr["eDosDose07Alarm"] = lr["eDosDose07Alarm"]; - cr["eDosRate07Warning"] = lr["eDosRate07Warning"]; - cr["eDosRate07Alarm"] = lr["eDosRate07Alarm"]; - cr["eDosDose10Warning"] = lr["eDosDose10Warning"]; - cr["eDosDose10Alarm"] = lr["eDosDose10Alarm"]; - cr["eDosRate10Warning"] = lr["eDosRate10Warning"]; - cr["eDosRate10Alarm"] = lr["eDosRate10Alarm"]; + cr["Hp10Dose"] = lr["Hp10Dose"]; + cr["Hp07Dose"] = lr["Hp07Dose"]; + cr["Hp10Total"] = lr["Hp10Total"]; + cr["Hp07Total"] = lr["Hp07Total"]; + cr["Hp10Peak"] = lr["Hp10Peak"]; + cr["Hp07Peak"] = lr["Hp07Peak"]; + cr["Hp10Time"] = lr["Hp10Time"]; + cr["Hp07Time"] = lr["Hp07Time"]; + cr["QualityData"] = lr["QualityData"]; + cr["K1"] = lr["K1"]; + cr["K2"] = lr["K2"]; + cr["K3"] = lr["K3"]; + cr["K4"] = lr["K4"]; + cr["K5"] = lr["K5"]; + cr["K6"] = lr["K6"]; + cr["SG"] = lr["SG"]; + cr["BC"] = lr["BC"]; + cr["FB"] = lr["FB"]; + cr["HG"] = lr["HG"]; + cr["alarmStatus"] = lr["alarmStatus"]; + cr["otherAlarms"] = lr["otherAlarms"]; + cr["errorStatus"] = lr["errorStatus"]; + cr["operatingStatus"] = lr["operatingStatus"]; + cr["isAlarm"] = lr["isAlarm"]; + cr["isAlarmCleared"] = lr["isAlarmCleared"]; + cr["ENTRY_EPD_CLOCK"] = lr["ENTRY_EPD_CLOCK"]; + cr["EXIT_EPD_CLOCK"] = lr["EXIT_EPD_CLOCK"]; + cr["TIME_LOST"] = lr["TIME_LOST"]; + cr["eDosBatteryWarning"] = lr["eDosBatteryWarning"]; + cr["eDosDose07Warning"] = lr["eDosDose07Warning"]; + cr["eDosDose07Alarm"] = lr["eDosDose07Alarm"]; + cr["eDosRate07Warning"] = lr["eDosRate07Warning"]; + cr["eDosRate07Alarm"] = lr["eDosRate07Alarm"]; + cr["eDosDose10Warning"] = lr["eDosDose10Warning"]; + cr["eDosDose10Alarm"] = lr["eDosDose10Alarm"]; + cr["eDosRate10Warning"] = lr["eDosRate10Warning"]; + cr["eDosRate10Alarm"] = lr["eDosRate10Alarm"]; } catch (System.Exception ex) { @@ -581,6 +595,6 @@ namespace syncEdosLocal { spLog?.Connection_InfoMessageLog(e, ref messages); } - + } }