diff --git a/CompareDef/Program.cs b/CompareDef/Program.cs index 1c26e66..d33bbaf 100644 --- a/CompareDef/Program.cs +++ b/CompareDef/Program.cs @@ -22,7 +22,9 @@ namespace CompareDef { s.ReadLine(); s.ReadLine(); +#pragma warning disable CS0168 // The variable 'l' is declared but never used string l; +#pragma warning restore CS0168 // The variable 'l' is declared but never used while (!s.EndOfStream) { var a = s.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries); diff --git a/EpdBase3/Epd3Base.cpp b/EpdBase3/Epd3Base.cpp index d59e322..4d68d8c 100644 --- a/EpdBase3/Epd3Base.cpp +++ b/EpdBase3/Epd3Base.cpp @@ -9,6 +9,51 @@ //-102 = permission Epd3Base::Epd3U* current; + +void Epd3Base::Epd3U::ResetStepReturnValues() +{ + CurrentStep = -1; + for (int i = MaxSteps - 1; i >= 0; --i) for (int j = 0; j < 3; j++) StepReturnValues[i][j] = 0; +} + +void Epd3Base::Epd3U::SetFunctionReturnValue(enum eFunctions f) +{ + if (CurrentStep < -1) CurrentStep = -1; + if (CurrentStep < MaxSteps - 1) { + ++CurrentStep; + StepReturnValues[CurrentStep][0] = f; + StepReturnValues[CurrentStep][1] = -1; + StepReturnValues[CurrentStep][2] = -1; + } +} + +void Epd3Base::Epd3U::SetCommitReturnValue(int32_t rv) +{ + if (CurrentStep>=0 && CurrentStep= 0 && CurrentStep < MaxSteps) + StepReturnValues[CurrentStep][2] = rv; +} + +int32_t Epd3Base::Epd3U::CommitAndSetRV() +{ + int32_t r = Commit3(epdComsHandle); + SetCommitReturnValue(r); + return r; +} + +int32_t Epd3Base::Epd3U::CommitAndEnd2RV(int32_t (WINAPI *endFunction2)(CommsHandle hComms, CompletionToken token), CompletionToken token) +{ + int32_t r = Commit3(epdComsHandle); + SetCommitReturnValue(r); + if (!r) r = (*endFunction2)(epdComsHandle, token); + SetEndReturnValue(r); + return r; +} + void WINAPI completion(CommsHandle hComms, CompletionToken token) { SetEvent(current->hCompletion); @@ -95,6 +140,7 @@ Epd3Base::Epd3U::Epd3U(int _comport) if (_comport == 0) return; if (hCompletion == 0) hCompletion = CreateEvent(NULL, TRUE, FALSE, NULL); + //if (hWaitTimer == 0) hWaitTimer = CreateEvent(NULL, TRUE, FALSE, NULL); } @@ -170,7 +216,10 @@ void Epd3Base::Epd3U::EndCom() //if (Dll3RV) { // rv = 1; //} + SetFunctionReturnValue(eFunctions::fDestroyReaderInterface); Dll3RV = DestroyReaderInterface(epdComsHandle); + SetCommitReturnValue(0); + SetEndReturnValue(Dll3RV); if (Dll3RV) rv = 1; } } @@ -205,6 +254,7 @@ int Epd3Base::Epd3U::StartDiscover(int tokentimeout) ConnectTimerFired = 0; isConnected = 0; + Dll3RV = StartDiscovery(epdComsHandle, discovery); if (Dll3RV == 0) { Dll3RV = WaitForSingleObject(hCompletion, tokentimeout); @@ -260,10 +310,15 @@ int Epd3Base::Epd3U::DisCon(UINT16 alarm) current = this; step = 1; Dll3RV = SetDisconnectCallback(epdComsHandle, disconnectcallback); - if (alarm) + if (alarm) { + SetFunctionReturnValue(fDisconnectAndNotify); Dll3RV = DisconnectAndNotify(epdComsHandle, EndSessionControl, 12); - else + SetCommitReturnValue(0); SetEndReturnValue(Dll3RV); + } else { + SetFunctionReturnValue(fDisconnect); Dll3RV = Disconnect(epdComsHandle); + SetCommitReturnValue(0); SetEndReturnValue(Dll3RV); + } if (Dll3RV) { rv = Dll3RV; goto error; } @@ -289,7 +344,7 @@ void Epd3Base::Epd3U::CloseDev(bool CloseAll) if (epdComsHandle != nullptr) { DisCon(0); if (CloseAll) { - CloseReader(epdComsHandle); + //CloseReader(epdComsHandle); DestroyReaderInterface(epdComsHandle); epdComsHandle = nullptr; } @@ -384,10 +439,13 @@ int Epd3Base::Epd3U::SetTime() //Only R3 int r = 0; if (Epd.Gen == EpdGeneration::Mk3) { + SetFunctionReturnValue(WriteRTC_R3); utc = TimeFunctions::NowToEpdTime(Epd.Gen == EpdGeneration::Mk2); token = BeginWriteRTC_R3(epdComsHandle, utc, nullptr); - r = Commit3(epdComsHandle); + CommitAndEnd2RV(EndWriteRTC_R3, token); + /*r = CommitSetRV(); if (!r) r = EndWriteRTC_R3(epdComsHandle, token); + SetEndReturnValue(r);*/ } return r; } @@ -427,9 +485,13 @@ int Epd3Base::Epd3U::ReadStatus() HardVersion = HardVersionMinor = SoftVersion = FunctionFlags = 0; step = 1; + + SetFunctionReturnValue(eFunctions::ReadStatus); token = BeginReadStatus(epdComsHandle, nullptr); r = Commit3(epdComsHandle); + SetCommitReturnValue(r); if (!r) r = EndReadStatus(epdComsHandle, token, &epd3status); + SetEndReturnValue(r); if (r != 0) { Error = GetErrorCode(); goto error; @@ -447,9 +509,11 @@ int Epd3Base::Epd3U::ReadStatus() VersionNumber_t VersionNumber; step = 2; + SetFunctionReturnValue(ReadEpdIdentities); token = BeginReadEpdIdentities(epdComsHandle, nullptr); - r = Commit3(epdComsHandle); + r = Commit3(epdComsHandle); SetCommitReturnValue(r); if (!r) r = EndReadEpdIdentities(epdComsHandle, token, &EpdID32, (EpdTypes*)&EpdType, &capabilities, &MarkNumber, &VersionNumber, NULL, 0); + SetEndReturnValue(r); if (r != 0) { Error = GetErrorCode(); goto error; @@ -466,9 +530,11 @@ int Epd3Base::Epd3U::ReadStatus() DecodeStatus(); //Alarm status... step = 3; + SetFunctionReturnValue(ReadCounts); token = BeginReadCounts(epdComsHandle, nullptr, 0, nullptr); - r = Commit3(epdComsHandle); + r = Commit3(epdComsHandle); SetCommitReturnValue(r); if (!r) r = EndReadCounts(epdComsHandle, token, Counts, MaxCounts, &countsRead, &utc, &seconds); + SetEndReturnValue(r); // - 101 = InvalidParam // - 104 = FunctionFail, if (r != 0 && r != -104) { @@ -482,9 +548,11 @@ int Epd3Base::Epd3U::ReadStatus() if (EPDIssued) { IdString_t mk3WearerID; //Mk2 EPDs only support Name and Primary ID + SetFunctionReturnValue(ReadWearerId); token = BeginReadWearerId(epdComsHandle, static_cast(WearerIdType::WearerId_Name), nullptr); - r = Commit3(epdComsHandle); + r = Commit3(epdComsHandle); SetCommitReturnValue(r); r = EndReadWearerId(epdComsHandle, token, &mk3WearerID); + SetEndReturnValue(r); if (r != 0) { Error = GetErrorCode(); goto error; @@ -494,9 +562,11 @@ int Epd3Base::Epd3U::ReadStatus() memcpy(WearerName, mk3WearerID.Utf8String, mk3WearerID.Length); WearerName[mk3WearerID.Length] = 0; step = 5; + SetFunctionReturnValue(ReadWearerId); token = BeginReadWearerId(epdComsHandle, static_cast(WearerIdType::WearerId_Primary), nullptr); - r = Commit3(epdComsHandle); + r = Commit3(epdComsHandle); SetCommitReturnValue(r); if (!r) r = EndReadWearerId(epdComsHandle, token, &mk3WearerID); + SetEndReturnValue(r); if (r != 0) { Error = GetErrorCode(); goto error; @@ -513,9 +583,11 @@ int Epd3Base::Epd3U::ReadStatus() //MK2 .. some utc... but no real time clock step = 6; if (utc == 0) { + SetFunctionReturnValue(ReadRTC); token = BeginReadRTC(epdComsHandle, nullptr); - r = Commit3(epdComsHandle); + r = CommitAndSetRV(); if (!r) r = EndReadRTC(epdComsHandle, token, &utc); //EpdClock for MK2 + SetEndReturnValue(r); if (r) goto error; EpdClock = utc; utc = TimeFunctions::NowToEpdTime(true); @@ -546,16 +618,19 @@ int Epd3Base::Epd3U::ConnectAndStatus(int tokenSourceTimeout) WORD dllStatus; int rv = 1; Error = 0; ErrorStep = 0; hasAlarm = hasFault = 0; + ResetStepReturnValues(); if (CommsInitialized == 0) StartCom(); if (CommsInitialized) { + SetFunctionReturnValue(fStartDiscover); dllStatus = StartDiscover(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 rv = 0; + SetCommitReturnValue(0); SetEndReturnValue(rv); } else rv = 1; - return rv; } /// @@ -768,9 +843,12 @@ void Epd3Base::Epd3U::decodedTresholds(int numdTresholds) WORD Epd3Base::Epd3U::ReadCal() { int r = 0; + SetFunctionReturnValue(ReadSensitivities); token = BeginReadSensitivities(epdComsHandle, nullptr, 0, nullptr); - r = Commit3(epdComsHandle); + r = CommitAndSetRV(); + //r = Commit3(epdComsHandle); SetCommitReturnValue(r); r = EndReadSensitivities(epdComsHandle, token, sensitivities, MaxSensitivities, &numSensitivities); + SetEndReturnValue(r); if (r != 0) goto error; decodeSensitivities(numSensitivities); @@ -824,15 +902,16 @@ WORD Epd3Base::Epd3U::ReadSensitivitiesAndTresholds() HG = HGthresh; } else { + SetFunctionReturnValue(ReadDetectorThresholds); token = BeginReadDetectorThresholds_R3(epdComsHandle, nullptr, 0, nullptr); r = Commit3(epdComsHandle); + SetCommitReturnValue(r); r = EndReadDetectorThresholds_R3(epdComsHandle, token, dTresholds, MaxTresholds, &numTresholds); + SetEndReturnValue(r); if (r != 0) goto error; decodedTresholds(numTresholds); // HG, SG, BC, FB, BC, FB - r = ReadCal();// K1 = K2 = K3 = K4 = K4 = K6 - } return r; error: @@ -845,7 +924,6 @@ error: /// 0 OK WORD Epd3Base::Epd3U::ReadDoses() { - int step = 0; int32_t r = 1; eDosDose07Warning = eDosDose07Alarm = eDosDose10Warning = eDosDose10Alarm = eDosRate07Warning = eDosRate07Alarm = eDosRate10Warning = eDosRate10Alarm = eDosBatteryWarning = 0; @@ -862,42 +940,52 @@ WORD Epd3Base::Epd3U::ReadDoses() numDoses = 0; utc = 0; - step = 1; + SetFunctionReturnValue(eFunctions::fReadDoses); token = BeginReadDoses(epdComsHandle, nullptr, 0, nullptr); r = Commit3(epdComsHandle); + SetCommitReturnValue(r); if (!r) r = EndReadDoses(epdComsHandle, token, doses, MaxDoses, &numDoses, &utc); + SetEndReturnValue(r); if (r != 0) goto error; decodeDoses(numDoses); - step = 2; + SetFunctionReturnValue(eFunctions::ReadTotalDoses); token = BeginReadTotalDoses(epdComsHandle, nullptr, 0, nullptr); r = Commit3(epdComsHandle); + SetCommitReturnValue(r); if (!r) r = EndReadTotalDoses(epdComsHandle, token, totdoses, MaxDoses, &numtotDoses, &utc); + SetEndReturnValue(r); if (r != 0) goto error; decodetotDoses(numtotDoses); - step = 3; + SetFunctionReturnValue(eFunctions::ReadQualityData); token = BeginReadQualityData(epdComsHandle, nullptr); r = Commit3(epdComsHandle); + SetCommitReturnValue(r); if (!r) r = EndReadQualityData(epdComsHandle, token, &quality); + SetEndReturnValue(r); if (r != 0) goto error; Knocks = quality.Knocks; Resets = quality.PowerCycles; - step = 4; + + SetFunctionReturnValue(eFunctions::ReadPeakRates); token = BeginReadPeakRates(epdComsHandle, nullptr, 0, nullptr); r = Commit3(epdComsHandle); + SetCommitReturnValue(r); if (!r) r = EndReadPeakRates(epdComsHandle, token, peakRates, MaxPeakRates, &numRates); + SetEndReturnValue(r); + if (r != 0) goto error; decodePeakRates(numRates); - step = 5; + r = ReadSensitivitiesAndTresholds(); //K1 .. K6, SG , BC ,FB , HG if (r != 0) goto error; @@ -906,7 +994,6 @@ WORD Epd3Base::Epd3U::ReadDoses() error: Error = r; - ErrorStep = step; return r; } /// @@ -916,25 +1003,33 @@ error: int Epd3Base::Epd3U::ClearDoses() { int r = 1; - int step = 1; - + + SetFunctionReturnValue(eFunctions::ClearTotalDose); token = BeginClearTotalDose(epdComsHandle, nullptr); r = Commit3(epdComsHandle); + SetCommitReturnValue(r); if (!r) r = EndClearTotalDose(epdComsHandle, token); + SetEndReturnValue(r); if (r != 0 && r != r_InvalidOp) goto error; - step++; + + SetFunctionReturnValue(eFunctions::ClearDose); token = BeginClearDose(epdComsHandle, nullptr); r = Commit3(epdComsHandle); + SetCommitReturnValue(r); if (!r) r = EndClearDose(epdComsHandle, token); + SetEndReturnValue(r); if (r != 0 && r != r_InvalidOp) goto error; - step++; + + SetFunctionReturnValue(eFunctions::ClearPeakRates); token = BeginClearPeakRates(epdComsHandle, nullptr); r = Commit3(epdComsHandle); + SetCommitReturnValue(r); if (!r) r = EndClearPeakRates(epdComsHandle, token); + SetEndReturnValue(r); if (r != 0 && r != r_InvalidOp) goto error; @@ -942,7 +1037,6 @@ int Epd3Base::Epd3U::ClearDoses() return r; error: - ErrorStep = step; Error = r; return r; } @@ -950,19 +1044,23 @@ error: int Epd3Base::Epd3U::ClearAlarms() { int r = 0; - int step = 0; + - step++; + SetFunctionReturnValue(eFunctions::ClearFaultStatus); token = BeginClearFaultStatus(epdComsHandle, nullptr); r = Commit3(epdComsHandle); + SetCommitReturnValue(r); if (!r) r = EndClearFaultStatus(epdComsHandle, token); + SetEndReturnValue(r); if (r != 0 && r != -105) goto error; - step++; + SetFunctionReturnValue(eFunctions::ClearLatchedAlarms); token = BeginClearLatchedAlarms(epdComsHandle, nullptr); r = Commit3(epdComsHandle); + SetCommitReturnValue(r); if (!r) r = EndClearLatchedAlarms(epdComsHandle, token); + SetEndReturnValue(r); if (r != 0 && r != -105) goto error; @@ -980,7 +1078,7 @@ WORD Epd3Base::Epd3U::PrepareForIssue() int step = 0; if (port == 0) return 0; - step = 1; + /*if (DetectorsOn) { token = BeginEpdOnOff(epdComsHandle, 0, nullptr); rv = Commit3(epdComsHandle); @@ -990,9 +1088,12 @@ WORD Epd3Base::Epd3U::PrepareForIssue() if (rv != 0) goto error;*/ + SetFunctionReturnValue(eFunctions::ClearLatchedAlarms); token = BeginEpdOnOff(epdComsHandle, 1, nullptr); rv = Commit3(epdComsHandle); + SetCommitReturnValue(rv); if (!rv) rv = EndEpdOnOff(epdComsHandle, token); + SetEndReturnValue(rv); if (rv != 0) rv = 0; @@ -1028,9 +1129,13 @@ error: WORD Epd3Base::Epd3U::ReadAlarmConfig() { //Alleen MK3 ? leeg bij MK2 + + SetFunctionReturnValue(eFunctions::ReadAlarmConfiguration); token = BeginReadAlarmConfiguration(epdComsHandle, nullptr, 0, nullptr); int32_t r = Commit3(epdComsHandle); + SetCommitReturnValue(r); r = EndReadAlarmConfiguration(epdComsHandle, token, alarmConfig, MaxAlarmConfig, &numAlarm); + SetEndReturnValue(r); return numAlarm; } @@ -1044,16 +1149,22 @@ WORD Epd3Base::Epd3U::ReadAlarmTresholds() { if (isNeutron) measID = (uint8_t)MeasurementId::Meas_Hp10N; else measID = (uint8_t)MeasurementId::Meas_Hp07; hp07tresholds.MeasId = measID; + SetFunctionReturnValue(eFunctions::ReadAlarmThresholds); token = BeginReadAlarmThresholds(epdComsHandle, (uint8_t)hp07tresholds.MeasId, nullptr, 0, nullptr); r = Commit3(epdComsHandle); + SetCommitReturnValue(r); r = EndReadAlarmThresholds(epdComsHandle, token, &hp07tresholds); + SetEndReturnValue(r); decodeTreshold(&hp07tresholds); if (isNeutron) measID = (uint8_t)MeasurementId::Meas_Hp10G; else measID = (uint8_t)MeasurementId::Meas_Hp10; hp10tresholds.MeasId = measID; + SetFunctionReturnValue(eFunctions::ReadAlarmThresholds); token = BeginReadAlarmThresholds(epdComsHandle, (uint8_t)hp10tresholds.MeasId, nullptr, 0, nullptr); r = Commit3(epdComsHandle); + SetCommitReturnValue(r); r = EndReadAlarmThresholds(epdComsHandle, token, &hp10tresholds); + SetEndReturnValue(r); decodeTreshold(&hp10tresholds); return r; @@ -1070,32 +1181,27 @@ WORD Epd3Base::Epd3U::WriteAlarmTresholds() { hp10tresholds.MeasId = measID; encodeTreshold(&hp10tresholds); + SetFunctionReturnValue(eFunctions::WriteAlarmThresholds); token = BeginWriteAlarmThresholds(epdComsHandle, (uint8_t)hp10tresholds.MeasId, (uint8_t)hp10tresholds.NumberThresholds, hp10tresholds.Thresholds, nullptr); - r = Commit3(epdComsHandle); - if (r != 0) - goto error; - r = EndWriteAlarmThresholds(epdComsHandle, token); - if (r != 0) - goto error; + r = CommitAndEnd2RV(EndWriteAlarmThresholds, token); + //r = Commit3(epdComsHandle); SetCommitReturnValue(r); if (r != 0) goto error; r = EndWriteAlarmThresholds(epdComsHandle, token); SetEndReturnValue(r); + if (r != 0) goto error; if (isNeutron) measID = (uint8_t)MeasurementId::Meas_Hp10N; else measID = (uint8_t)MeasurementId::Meas_Hp07; hp07tresholds.MeasId = measID; encodeTreshold(&hp07tresholds); hp07tresholds.NumberThresholds = 4; + SetFunctionReturnValue(eFunctions::WriteAlarmThresholds); token = BeginWriteAlarmThresholds(epdComsHandle, (uint8_t)hp07tresholds.MeasId, (uint8_t)hp07tresholds.NumberThresholds, hp07tresholds.Thresholds, nullptr); - r = Commit3(epdComsHandle); - if (r != 0) - goto error; - r = EndWriteAlarmThresholds(epdComsHandle, token); - if (r != 0) - goto error; + r = CommitAndEnd2RV(EndWriteAlarmThresholds, token); + //r = Commit3(epdComsHandle); SetCommitReturnValue(r); if (r != 0) goto error; r = EndWriteAlarmThresholds(epdComsHandle, token); SetEndReturnValue(r); + if (r != 0) goto error; + SetFunctionReturnValue(eFunctions::WriteRateOffPercentage); token = BeginWriteRateOffPercentage(epdComsHandle, RatePct, 2, nullptr); - r = Commit3(epdComsHandle); - if (r != 0) - goto error; - r = EndWriteRateOffPercentage(epdComsHandle, token); + r = CommitAndEnd2RV(EndWriteRateOffPercentage, token); + //r = Commit3(epdComsHandle); SetCommitReturnValue(r); if (r != 0) goto error; r = EndWriteRateOffPercentage(epdComsHandle, token); SetEndReturnValue(r); if (r != 0) goto error; @@ -1109,7 +1215,7 @@ error: WORD Epd3Base::Epd3U::DeIssue() { int r = 1; - int ErrorStep = 0; + if (port == 0) return 0; if (CurrentDeviceID == 0) return 0; @@ -1121,28 +1227,24 @@ WORD Epd3Base::Epd3U::DeIssue() ErrorStep = 1; r = ClearAlarms(); - //needed after clear alarms Sleep(2000); #endif - - ErrorStep = 3; + + SetFunctionReturnValue(eFunctions::DeissueEPD); token = BeginDeissueEPD(epdComsHandle, nullptr); - r = Commit3(epdComsHandle); - if (!r) r = EndDeissueEPD(epdComsHandle, token); - if (r) - r = 0; + r = CommitAndEnd2RV(EndDeissueEPD,token); + //r = Commit3(epdComsHandle); SetCommitReturnValue(r); if (!r) r = EndDeissueEPD(epdComsHandle, token); SetEndReturnValue(r); + Sleep(2000); } - Sleep(1000); - ErrorStep = 4; + SetFunctionReturnValue(eFunctions::EpdOnOff); token = BeginEpdOnOff(epdComsHandle, 0, nullptr); - r = Commit3(epdComsHandle); - if (!r) r = EndEpdOnOff(epdComsHandle, token); - //if (r) goto error; - Sleep(1000); - ErrorStep = 5; + r = CommitAndEnd2RV(EndEpdOnOff, token); + //r = Commit3(epdComsHandle); SetCommitReturnValue(r); if (!r) r = EndEpdOnOff(epdComsHandle, token); SetEndReturnValue(r); + Sleep(100); + EndCom(); return r; @@ -1157,9 +1259,10 @@ WORD Epd3Base::Epd3U::WriteWearer() { int32_t r = 0; int step = 0; + SetFunctionReturnValue(eFunctions::SetBaselineCounters); token = BeginSetBaselineCounters(epdComsHandle, nullptr); - r = Commit3(epdComsHandle); - r = EndSetBaselineCounters(epdComsHandle, token); + r = CommitAndEnd2RV(EndSetBaselineCounters, token); + //r = Commit3(epdComsHandle); SetCommitReturnValue(r); r = EndSetBaselineCounters(epdComsHandle, token); SetEndReturnValue(r); if (r != 0) goto error; @@ -1170,10 +1273,10 @@ WORD Epd3Base::Epd3U::WriteWearer() { mk3WearerID.Length = 23; memcpy(mk3WearerID.Utf8String, WearerName, 23); - step = 1; + SetFunctionReturnValue(eFunctions::WriteWearerId); token = BeginWriteWearerId(epdComsHandle, mk3WearerID, nullptr); - r = Commit3(epdComsHandle); - r = EndWriteWearerId(epdComsHandle, token); + r = CommitAndEnd2RV(EndWriteWearerId, token); + //r = Commit3(epdComsHandle); SetCommitReturnValue(r); r = EndWriteWearerId(epdComsHandle, token); SetEndReturnValue(r); if (r != 0) goto error; @@ -1181,17 +1284,17 @@ WORD Epd3Base::Epd3U::WriteWearer() { mk3WearerID.Length = 13; memcpy(mk3WearerID.Utf8String, WearerID, 13); - step = 2; + SetFunctionReturnValue(eFunctions::WriteWearerId); token = BeginWriteWearerId(epdComsHandle, mk3WearerID, nullptr); - r = Commit3(epdComsHandle); - r = EndWriteWearerId(epdComsHandle, token); + r = CommitAndEnd2RV(EndWriteWearerId, token); + //r = Commit3(epdComsHandle); SetCommitReturnValue(r); r = EndWriteWearerId(epdComsHandle, token); SetEndReturnValue(r); if (r != 0) goto error; return r; error: - ErrorStep = step; + Error = r; return r; } @@ -1218,8 +1321,8 @@ WORD Epd3Base::Epd3U::Issue(bool PrepareDone) //normaal is preparedone=tru if (isMK3) { Control = EndSessionControl; token = BeginEnableProtectedSession_R3(epdComsHandle, 1, nullptr); - r = Commit3(epdComsHandle); - r = EndEnableProtectedSession_R3(epdComsHandle, token); + r = CommitAndEnd2RV(EndEnableProtectedSession_R3, token); + //r = Commit3(epdComsHandle); r = EndEnableProtectedSession_R3(epdComsHandle, token); if (r != 0) goto error; } @@ -1243,9 +1346,10 @@ WORD Epd3Base::Epd3U::Issue(bool PrepareDone) //normaal is preparedone=tru step = 4; //EPDIssued //if (!DetectorsOn) { + SetFunctionReturnValue(eFunctions::EpdOnOff); token = BeginEpdOnOff(epdComsHandle, 1, nullptr); - r = Commit3(epdComsHandle); - if (!r) r = EndEpdOnOff(epdComsHandle, token); + r = CommitAndEnd2RV(EndEpdOnOff, token); + //r = Commit3(epdComsHandle); SetCommitReturnValue(r); if (!r) r = EndEpdOnOff(epdComsHandle, token); SetEndReturnValue(r); // OKRV = EpdOn(); OKRV = Commit3(); if (r != 0) r = 0; @@ -1255,16 +1359,18 @@ WORD Epd3Base::Epd3U::Issue(bool PrepareDone) //normaal is preparedone=tru //ReOpenDev(); tries = 1; + SetFunctionReturnValue(eFunctions::EpdOnOff); token = BeginIssueEPD(epdComsHandle, nullptr); - r = Commit3(epdComsHandle); - r = EndIssueEPD(epdComsHandle, token); + r = CommitAndEnd2RV(EndIssueEPD, token); + //r = Commit3(epdComsHandle); SetCommitReturnValue(r); r = EndIssueEPD(epdComsHandle, token); SetEndReturnValue(r); if (r != 0) { tries++; if (r == r_ErrorNotConnected) ReOpenDev(); Sleep(500); + SetFunctionReturnValue(eFunctions::EpdOnOff); token = BeginIssueEPD(epdComsHandle, nullptr); - r = Commit3(epdComsHandle); - r = EndIssueEPD(epdComsHandle, token); + r = CommitAndEnd2RV(EndIssueEPD, token); + //r = Commit3(epdComsHandle); SetCommitReturnValue(r); r = EndIssueEPD(epdComsHandle, token); SetEndReturnValue(r); } if (r) goto error; @@ -1300,9 +1406,11 @@ WORD Epd3Base::Epd3U::EPDReadExtraStatus() &byStatus4); if (CommitRV == 1) CommitRV = Commit3();*/ + SetFunctionReturnValue(eFunctions::ReadBaselineCounts); token = BeginReadBaselineCounts(epdComsHandle, nullptr); - r = Commit3(epdComsHandle); - if (!r) r = EndReadBaselineCounts(epdComsHandle, token, Counts, 10, &utc, &countsRead); + r = CommitAndSetRV();// Commit3(epdComsHandle); SetCommitReturnValue(r); + if (!r) r = EndReadBaselineCounts(epdComsHandle, token, Counts, 10, &utc, &countsRead); + SetEndReturnValue(r); if (!r) decodeBaseCounters(countsRead); //if (CommitRV == 1) CommitRV = ReadCounts(&D1, &D2, &D3, &D4, &CountsClock); //if (CommitRV == 1) CommitRV = Commit3(); @@ -1325,19 +1433,22 @@ WORD Epd3Base::Epd3U::WriteCal() if (EpdType == EpdTypes::Mk2Neutron) { Password = 9; + + SetFunctionReturnValue(eFunctions::MfrLogin_R2); token = BeginMfrLogin_R2(epdComsHandle, Password, nullptr); - uint32_t r = Commit3(epdComsHandle); + uint32_t r = Commit3(epdComsHandle); SetCommitReturnValue(r); if (r != 0) goto error; - r = EndMfrLogin_R2(epdComsHandle, token); + r = EndMfrLogin_R2(epdComsHandle, token); SetEndReturnValue(r); if (r != 0) goto error; + SetFunctionReturnValue(eFunctions::WriteSensitivities_R2); 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); SetCommitReturnValue(r); if (r != 0) goto error; - r = EndWriteSensitivities_R2(epdComsHandle, token); + r = EndWriteSensitivities_R2(epdComsHandle, token); SetEndReturnValue(r); if (r != 0) goto error; } @@ -1361,7 +1472,9 @@ int Epd3Base::Epd3U::GetAllDeissue(bool reconnect) { int rv = 0; int step = 0; - //reconnect ?? + + ResetStepReturnValues(); + step = 1; rv = ReadDoses(); //0 = success if (rv) goto error; @@ -1373,6 +1486,7 @@ int Epd3Base::Epd3U::GetAllDeissue(bool reconnect) step = 3; rv = DeIssue(); //does close + if (rv) goto error; return rv; @@ -1438,9 +1552,11 @@ int Epd3Base::Epd3U::WriteConfig(void) int32_t r = 0; ECLen = 32; + SetFunctionReturnValue(eFunctions::WriteAccessLevel); token = BeginWriteAccessLevel(epdComsHandle, AccessLevel_t::Admin, EC, ECLen, nullptr); - r = Commit3(epdComsHandle); + r = Commit3(epdComsHandle); SetCommitReturnValue(r); r = EndWriteAccessLevel(epdComsHandle, token); + SetEndReturnValue(r); if (!r) { displayIds = new QuickAccessDisplay_t[6]{ @@ -1453,9 +1569,10 @@ int Epd3Base::Epd3U::WriteConfig(void) }; numDisplays = 6; + SetFunctionReturnValue(eFunctions::WriteQuickAccessDisplays_R3); token = BeginWriteQuickAccessDisplays_R3(epdComsHandle, displayIds, numDisplays, nullptr); - r = Commit3(epdComsHandle); - r = EndWriteQuickAccessDisplays_R3(epdComsHandle, token); + r = Commit3(epdComsHandle); SetCommitReturnValue(r); + r = EndWriteQuickAccessDisplays_R3(epdComsHandle, token); SetEndReturnValue(r); } if (!r) { //Unmanaged%20HtmlFiles/_display_ids.html @@ -1474,9 +1591,10 @@ int Epd3Base::Epd3U::WriteConfig(void) // 0x1 Operation Menu Back /0x2 On / Off 0x4 Clear Dose 0x8 Toggle Telemtry 0x10 Responder Trigger // 1 0 0 0 0 + SetFunctionReturnValue(eFunctions::WriteDisplayEnables_R3); token = BeginWriteDisplayEnables_R3(epdComsHandle, enables, numItems, nullptr); - r = Commit3(epdComsHandle); - r = EndWriteDisplayEnables_R3(epdComsHandle, token); + r = Commit3(epdComsHandle); SetCommitReturnValue(r); + r = EndWriteDisplayEnables_R3(epdComsHandle, token); SetEndReturnValue(r); } if (!r) { uint8_t numMenus = 9; @@ -1492,9 +1610,10 @@ int Epd3Base::Epd3U::WriteConfig(void) 0x0000 }; + SetFunctionReturnValue(eFunctions::WriteDisplayEnablePermissions_R3); token = BeginWriteDisplayEnablePermissions_R3(epdComsHandle, AccessLevel_t::Admin, permissions, numDisplays, nullptr); - r = Commit3(epdComsHandle); - r = EndWriteDisplayEnablePermissions_R3(epdComsHandle, token); + r = Commit3(epdComsHandle); SetCommitReturnValue(r); + r = EndWriteDisplayEnablePermissions_R3(epdComsHandle, token); SetEndReturnValue(r); } if (!r) { //AlarmConfiguration @@ -1516,25 +1635,30 @@ int Epd3Base::Epd3U::WriteConfig(void) { (AlarmIds)3,1,0x0000,0x18A5,60 }, }; + SetFunctionReturnValue(eFunctions::WriteAlarmConfiguration_R3); token = BeginWriteAlarmConfiguration_R3(epdComsHandle, alarmConfigIds, alarmConfigLen, nullptr); - r = Commit3(epdComsHandle); - r = EndWriteAlarmConfiguration_R3(epdComsHandle, token); + r = Commit3(epdComsHandle); SetCommitReturnValue(r); + r = EndWriteAlarmConfiguration_R3(epdComsHandle, token); SetEndReturnValue(r); } //OffModeDisplay if (!r) { dutyCycle = (OffModeDutyCycle)0; offModeDispId = (OffModeDisplayId_t)1; - token = BeginWriteOffModeDisplay_R3(epdComsHandle, dutyCycle, offModeDispId, completion); - r = Commit3(epdComsHandle); - r = EndWriteOffModeDisplay_R3(epdComsHandle, token); + SetFunctionReturnValue(eFunctions::WriteOffModeDisplay_R3); + token = BeginWriteOffModeDisplay_R3(epdComsHandle, dutyCycle, offModeDispId, nullptr); + r = CommitAndEnd2RV(EndWriteOffModeDisplay_R3, token); + /*r = Commit3(epdComsHandle); SetCommitReturnValue(r); + r = EndWriteOffModeDisplay_R3(epdComsHandle, token); SetEndReturnValue(r);*/ } //SwitchOnFromButton if (!r) { uint8_t OnOfenabled = 0; - token = BeginWriteSwitchOnFromButton_R3(epdComsHandle, OnOfenabled, completion); - r = Commit3(epdComsHandle); - r = EndWriteSwitchOnFromButton_R3(epdComsHandle, token); + SetFunctionReturnValue(eFunctions::WriteSwitchOnFromButton_R3); + token = BeginWriteSwitchOnFromButton_R3(epdComsHandle, OnOfenabled, nullptr); + r = CommitAndEnd2RV(EndWriteSwitchOnFromButton_R3, token); + /*r = Commit3(epdComsHandle); SetCommitReturnValue(r); + r = EndWriteSwitchOnFromButton_R3(epdComsHandle, token); SetEndReturnValue(r);*/ } return r; } @@ -1546,16 +1670,20 @@ int Epd3Base::Epd3U::SetChirp(float Sensitivity) if (Sensitivity > 0.001F) { enable = 1; + SetFunctionReturnValue(eFunctions::WriteChirpSensitivity); token = BeginWriteChirpSensitivity(epdComsHandle, Sensitivity, nullptr); - r = Commit3(epdComsHandle); - if (!r) r = EndWriteChirpSensitivity(epdComsHandle, token); + r = CommitAndEnd2RV(EndWriteChirpSensitivity , token); + /*r = Commit3(epdComsHandle); SetCommitReturnValue(r); + if (!r) r = EndWriteChirpSensitivity(epdComsHandle, token); SetEndReturnValue(r);*/ } if (r) goto error; if (!r) { + SetFunctionReturnValue(eFunctions::WriteChirpEnable_R3); token = BeginWriteChirpEnable_R3(epdComsHandle, enable, nullptr); - r = Commit3(epdComsHandle); - if (!r) r = EndWriteChirpEnable_R3(epdComsHandle, token); + r = CommitAndEnd2RV(EndWriteChirpEnable_R3, token); + /*r = Commit3(epdComsHandle); SetCommitReturnValue(r); + if (!r) r = EndWriteChirpEnable_R3(epdComsHandle, token); SetEndReturnValue(r);*/ } if (r) goto error; diff --git a/EpdBase3/Epd3Base.h b/EpdBase3/Epd3Base.h index f8aea88..f9a4c5c 100644 --- a/EpdBase3/Epd3Base.h +++ b/EpdBase3/Epd3Base.h @@ -1,4 +1,6 @@ #pragma once + + #pragma unmanaged #include #pragma unmanaged @@ -13,8 +15,19 @@ #define MaxCounts 6 #define MaxAlarmConfig 10 #define MaxTresholds 10 +#define MaxSteps 50 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 + , WriteQuickAccessDisplays_R3, WriteDisplayEnables_R3, WriteDisplayEnablePermissions_R3, WriteAlarmConfiguration_R3, WriteOffModeDisplay_R3, WriteSwitchOnFromButton_R3 + , WriteChirpSensitivity, WriteChirpEnable_R3 + , WriteRTC_R3 + , ReadStatus, ReadEpdIdentities, ReadCounts, ReadWearerId, ReadRTC + , fDestroyReaderInterface + , fDisconnect , fDisconnectAndNotify + , fStartDiscover + }; class Epd3U { public: @@ -28,6 +41,8 @@ namespace Epd3Base { const WORD MaxDevices = 10; WORD DeviceCount = 0; DWORD DeviceIDs[10]; + int32_t StepReturnValues[MaxSteps][3]; + int CurrentStep; WORD WriteConfig32 = 1; @@ -56,7 +71,7 @@ namespace Epd3Base { Epd3U(int _comport); ~Epd3U(); DWORD StartCom(); - void EndCom(); + void EndCom(void); int StartDiscover(int tokentimeout); @@ -201,8 +216,6 @@ namespace Epd3Base { DWORD BaseCountsClock; - - BYTE ConnectTimerFired; @@ -235,7 +248,6 @@ namespace Epd3Base { DetectorThreshold_t dTresholds[MaxTresholds]; - DisplayAttributeMap_t* enables; uint8_t numItems; @@ -274,6 +286,12 @@ namespace Epd3Base { void decodeDoses(int count); void decodePeakRates(int count); public: + + void SetFunctionReturnValue(eFunctions f); + void SetCommitReturnValue(int rv); + void SetEndReturnValue(int rv); + int32_t CommitAndSetRV(); + int32_t CommitAndEnd2RV(int32_t (WINAPI *endFunction2)(CommsHandle hComms, CompletionToken token), CompletionToken token); int GetAll(bool Closeconnection); int GetAllDeissue(bool reconnect); int IssueAndCheck(float gain, float ChirpRate); @@ -298,6 +316,7 @@ namespace Epd3Base { WORD PrepareForIssue(); private: int WriteConfig(void); + void ResetStepReturnValues(); }; } diff --git a/EpdBaseClr/EpdBaseClr.cpp b/EpdBaseClr/EpdBaseClr.cpp index 1d4a6a8..c825b87 100644 --- a/EpdBaseClr/EpdBaseClr.cpp +++ b/EpdBaseClr/EpdBaseClr.cpp @@ -2,6 +2,25 @@ #include "EpdBaseClr.h" #pragma managed +int EpdBaseClr::Epd2::GetSteps() +{ + int nsteps = (int)epd3->CurrentStep + 1; + if (nsteps>0) { + StepReturnValues = gcnew System::Collections::Generic::List(nsteps); + cStepValues^ x; + for (int i = 0; ifunc = (Int32)epd3->StepReturnValues[i][0]; + x->commitrv = epd3->StepReturnValues[i][1]; + x->endrv = epd3->StepReturnValues[i][2]; + StepReturnValues->Add(x); + } + } + else if (StepReturnValues != nullptr) StepReturnValues->Clear(); + return nsteps; +} + EpdBaseClr::Epd2::Epd2(int port, bool OnlyMK2) { //HANDLE hMod = LoadLibrary(L"Reader2.dll"); @@ -783,13 +802,14 @@ int EpdBaseClr::Epd2::GetAllDeissue(bool reconnect) /// /// /// -int EpdBaseClr::Epd2::IssueAndCheck(float gain,float ChirpRate) +int EpdBaseClr::Epd2::IssueAndCheck(float gain,float ChirpRate, bool WriteConfig) { int rv = 0; if (!isMK3) { BeforeSetIssued(epd); rv = epd->IssueAndCheck(gain); } else { + epd3->WriteConfig32 = WriteConfig; BeforeSetIssued(epd3); //geen interactie met epd rv = epd3->IssueAndCheck(gain, ChirpRate); // set step,error } @@ -962,4 +982,4 @@ void EpdBaseClr::Epd2::WaitEnd() tokenSource = nullptr; Close(); } -} \ No newline at end of file +} diff --git a/EpdBaseClr/EpdBaseClr.h b/EpdBaseClr/EpdBaseClr.h index d3028e8..cbfff4d 100644 --- a/EpdBaseClr/EpdBaseClr.h +++ b/EpdBaseClr/EpdBaseClr.h @@ -14,6 +14,29 @@ namespace EpdBaseClr { const char* cEpdError = "Setreader Error"; ref class Epd2; + public ref class cStepValues + { + public: + Int32 func; + Int32 commitrv; + Int32 endrv; + cStepValues(); + ~ cStepValues(); + + private: + + }; + + cStepValues:: cStepValues() + { + func = -1; commitrv = -1; endrv = -1; + } + + cStepValues::~ cStepValues() + { + } + + public ref class EpdEventArgs : EventArgs { public: @@ -85,8 +108,8 @@ namespace EpdBaseClr { { /*private: DateTime^ Jan2000;*/ - const wchar_t* tHp07 = L"HP07"; - const wchar_t* tHp10 = L"HP10"; + const wchar_t* tHp07 = L"HP07"; + const wchar_t* tHp10 = L"HP10"; const wchar_t* tHp07N = L"HPN"; const wchar_t* tHp10G = L"HP10G"; @@ -98,6 +121,7 @@ namespace EpdBaseClr { dEpdRead^ _EpdRead; dEpdTO^ _EpdTO; dEpdError^ _EpdError; + event dEpdRead^ EpdRead { @@ -140,6 +164,7 @@ namespace EpdBaseClr { //bool hasAlarm = false; public: + bool onlyMK2; EpdBase::Epd2U *epd; Epd3Base::Epd3U* epd3; @@ -148,6 +173,7 @@ namespace EpdBaseClr { String^ Hp10Name; bool isTitleNG; + DateTime^ RealTime; String^ WearerName; String^ WearerID; @@ -274,6 +300,12 @@ namespace EpdBaseClr { ~Epd2(); !Epd2(); + //int StepReturnValues[50][3]; + //int StepReturnMax; + //array StepReturnValues; + System::Collections::Generic::List^ StepReturnValues; + + int SetFeedbackSound(byte sound, UINT16 sound3); private: @@ -318,7 +350,9 @@ namespace EpdBaseClr { void WaitEnd(); int GetAll(bool close); int GetAllDeissue(bool reconnect); - int IssueAndCheck(float gain, float ChirpRate); + int IssueAndCheck(float gain, float ChirpRate, bool WriteConfig); + + int GetSteps(); private: int AfterGetStatus(EpdBase::Epd2U* epd); diff --git a/MK3/MK3Base.cpp b/MK3/MK3Base.cpp index 2c465b1..8dcc75d 100644 --- a/MK3/MK3Base.cpp +++ b/MK3/MK3Base.cpp @@ -618,11 +618,13 @@ WORD MK3::Epd2U::ReadSensitivitiesAndTresholds() BC = BCthresh; FB = FBthresh; HG = HGthresh; + } else { ResetEvent(Ev1); token = BeginReadDetectorThresholds_R3(epdComsHandle,nullptr,0, completion); r = Commit3(epdComsHandle); + r = WaitForSingleObject(Ev1, 10000); // no time-out interval r = EndReadDetectorThresholds_R3(epdComsHandle, token, dTresholds, MaxTresholds, &numTresholds); decodedTresholds(numTresholds); diff --git a/TestEPD3Dll/Program.cs b/TestEPD3Dll/Program.cs index 3eae45b..b914c5a 100644 --- a/TestEPD3Dll/Program.cs +++ b/TestEPD3Dll/Program.cs @@ -16,7 +16,9 @@ namespace TestEPD3Dll DateTime dt2 = DateTime.Now.AddSeconds(-254246887); //254245176 +#pragma warning disable CS0168 // The variable 'rv' is declared but never used int rv; +#pragma warning restore CS0168 // The variable 'rv' is declared but never used MK3.Epd2 x = new MK3.Epd2(7); x.Connect(false); diff --git a/eDosStation/App.Debug.config b/eDosStation/App.Debug.config index 33ab507..d466e33 100644 --- a/eDosStation/App.Debug.config +++ b/eDosStation/App.Debug.config @@ -15,5 +15,7 @@ + + \ No newline at end of file diff --git a/eDosStation/App.Release.config b/eDosStation/App.Release.config index e36bc80..2cb82ef 100644 --- a/eDosStation/App.Release.config +++ b/eDosStation/App.Release.config @@ -1,4 +1,8 @@ - - - + + + + + + + \ No newline at end of file diff --git a/eDosStation/App.config b/eDosStation/App.config index d7140bf..e0590ac 100644 --- a/eDosStation/App.config +++ b/eDosStation/App.config @@ -43,6 +43,8 @@ + + diff --git a/eDosStation/DecodeResults.cs b/eDosStation/DecodeResults.cs new file mode 100644 index 0000000..bad417e --- /dev/null +++ b/eDosStation/DecodeResults.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using cspl = LSWLib.CLog; + +namespace eDosStation +{ + static class DecodeResults + { + static readonly string[] names = + { + "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", + "WriteQuickAccessDisplays_R3", + "WriteDisplayEnables_R3", + "WriteDisplayEnablePermissions_R3", + "WriteAlarmConfiguration_R3", + "WriteOffModeDisplay_R3", + "WriteSwitchOnFromButton_R3", + "WriteChirpSensitivity", + "WriteChirpEnable_R3","WriteRTC_R3","ReadStatus","ReadEpdIdentities","ReadCounts","ReadWearerId","ReadRTC" + ,"DestroyReaderInterface" //0=ok + ,"Disconnect" , "DisconnectAndNotify" //0=ok + ,"StartDiscover" + }; + + private static string GetName(int func) + { + if (func >= 0 && func < names.Length) return names[func]; else return func.ToString(); + } + private static string Getresult(int rval) + { + string rv; + switch (rval) { + case 0: rv = "r_OK"; break; + case -1: rv = "r_UnknownError"; break; + case -2: rv = "r_InvalidCommsHandle"; break; + case -3: rv = "r_InvalidPortName"; break; + case -4: rv = "r_PortAlreadyOpen"; break; + case -5: rv = "r_PortClosed"; break; + case -6: rv = "r_OperationFailed"; break; + case -7: rv = "r_InvalidState"; break; + case -8: rv = "r_InvalidCompletionToken"; break; + case -9: rv = "r_OperationTimeout"; break; + case -100: rv = "r_UnknownCmd"; break; + case -101: rv = "r_InvalidParam"; break; + case -102: rv = "r_InsufficientPriv"; break; + case -103: rv = "r_UnsupportedOp"; break; + case -104: rv = "r_FunctionFail"; break; + case -105: rv = "r_InvalidOp"; break; + case -106: rv = "r_IncompleteCommand"; break; + case -107: rv = "r_ResponseTooBig"; break; //response exceeded single frame length + case -108: rv = "r_ErrorBadStoredData"; break; + case -109: rv = "r_InvalidResponseDataLength"; break; + case -110: rv = "r_PayloadTooBig"; break; + case -111: rv = "r_ParseFailure"; break; + case -112: rv = "r_EEPROMWriteFailure"; break; + case -113: rv = "r_Busy"; break; + case -121: rv = "r_EEPROMReadFailure"; break; + case -122: rv = "r_WearerNameMismatch"; break; + case -123: rv = "r_DataTooLongForBuffer"; break; + case -200: rv = "r_ErrorUnexpectedResponse"; break; + case -201: rv = "r_ErrorNotProcessed"; break; //command not processed due to previous failure + case -202: rv = "r_ErrorNotConnected"; break; + case -203: rv = "r_ErrorUserCancelled"; break; + default: rv = rval.ToString(); break; + } + return rv; + } + + public static string decodesteps(System.Collections.Generic.List Lst) + { + if (Lst != null) + { + System.Text.StringBuilder sb = new StringBuilder(); + for (int s = 0; s < Lst.Count; s++) + { + sb.Append(GetName(Lst[s].func)); + sb.Append(": commit : "); + sb.Append(Getresult(Lst[s].commitrv)); + sb.Append(": End : "); + sb.AppendLine(Getresult(Lst[s].endrv)); + } + return sb.ToString(); + } + else return "List Empty"; + } + + public static void logsteps(string module, System.Collections.Generic.List Lst, cspl spl) + { + if (Lst!=null) + for (int s = 0; s < Lst.Count; s++) + { + string msg = $"{s} {GetName(Lst[s].func)} commit: {Getresult(Lst[s].commitrv)} end : {Getresult(Lst[s].endrv)} ({Lst[s].endrv})"; + spl?.WriteSplunkLog(module, Lst[s].commitrv == 0 && Lst[s].endrv == 0 ? cspl.iseverity.info : cspl.iseverity.err,msg); + } + } + + } +} diff --git a/eDosStation/Decoder.cs b/eDosStation/Decoder.cs index cb263d4..e78b173 100644 --- a/eDosStation/Decoder.cs +++ b/eDosStation/Decoder.cs @@ -51,5 +51,8 @@ namespace eDosStation if (ep.OtherAlarmCarrier > 0) tb_Add("Carrier present"); if (ep.OtherAlarmBatVolt > 0) tb_Add("Battery Volt"); } + + + } } diff --git a/eDosStation/EntryBadge.xaml.cs b/eDosStation/EntryBadge.xaml.cs index fd9f3d5..2682b87 100644 --- a/eDosStation/EntryBadge.xaml.cs +++ b/eDosStation/EntryBadge.xaml.cs @@ -196,6 +196,7 @@ namespace eDosStation //} private void DoEPD() { + const string module = "EntryBadge DoEpd"; int? StationVisitID = null; int? ID_Visit = null; @@ -300,15 +301,23 @@ namespace eDosStation float ChirpRate = 0F; if (!CurTaskRow.IsFNGain_ANGainValueNull()) gain = (int)CurTaskRow.FNGain_ANGainValue; if (!CurTaskRow.IsChirpRateNull()) ChirpRate = (int)CurTaskRow.ChirpRate; - int rv = ep.IssueAndCheck(gain, ChirpRate); + + int rv = ep.IssueAndCheck(gain, ChirpRate, thisStation.WriteConfig); if (rv != 0) { MessageBox.Show($"SetIssued error {rv}"); } + if (rv != 0 || thisStation.LogAll) + { + //MessageBox.Show($"GetDoses {rv} rv:{ep.ErrorRV} step:{ep.ErrorStep} er:{ep.GetDosesError}"); + ep.GetSteps(); + if (rv!=0 ) MessageBox.Show(DecodeResults.decodesteps(ep.StepReturnValues)); + DecodeResults.logsteps(module, ep.StepReturnValues, thisStation.splunkLog); + } + lbHP07.Text = ep.Hp07Name; lbHP10.Text = ep.Hp10Name; - ShowFinal(); } } @@ -338,6 +347,12 @@ namespace eDosStation } private void GetEPD() { + const string module = "EntryBadge.getEPD"; + if (thisStation.LogAll) { + var s = ep.GetSteps(); + DecodeResults.logsteps(module, ep.StepReturnValues, thisStation.splunkLog); + } + if (ep.DeviceCount == 1 && ep.EpdID > 0) { statusEPD.Text = string.Empty; @@ -350,7 +365,6 @@ namespace eDosStation System.Diagnostics.Debug.WriteLine("TIME OUT"); Dispatcher.InvokeAsync(() => { SetTimedOutAndEnd(); }); } - } private void SetFilter(bool isAlara) { diff --git a/eDosStation/EpdExit.xaml.cs b/eDosStation/EpdExit.xaml.cs index 6239fb8..f29a663 100644 --- a/eDosStation/EpdExit.xaml.cs +++ b/eDosStation/EpdExit.xaml.cs @@ -92,6 +92,7 @@ namespace eDosStation private void LoadDoses() { + const string module = "EpdExit LoadDoses"; int EpdVisitID; #if SimulateEPD ep.epdType = simulData.EdpType; @@ -106,6 +107,12 @@ namespace eDosStation int rv = 0; EpdVisitID = 0; + if (thisStation.LogAll) + { + var s = ep.GetSteps(); + DecodeResults.logsteps(module, ep.StepReturnValues, thisStation.splunkLog); + } + if (ep==null || !ep.EPDIssued) { Dispatcher.InvokeAsync(() => @@ -165,8 +172,14 @@ namespace eDosStation } rv = ep.GetAllDeissue(true); //reconnect - if (rv != 0) - MessageBox.Show($"GetDoses {rv} rv:{ep.ErrorRV} step:{ep.ErrorStep} er:{ep.GetDosesError}"); + if (rv != 0 || thisStation.LogAll) + { + //MessageBox.Show($"GetDoses {rv} rv:{ep.ErrorRV} step:{ep.ErrorStep} er:{ep.GetDosesError}"); + ep.GetSteps(); + if (rv!=0) MessageBox.Show(DecodeResults.decodesteps(ep.StepReturnValues)); + DecodeResults.logsteps(module, ep.StepReturnValues, thisStation.splunkLog); + } + Wearer.Text = $"{ep.WearerName}"; Wearer.Name = WearerFullName; diff --git a/eDosStation/Properties/AssemblyInfo.cs b/eDosStation/Properties/AssemblyInfo.cs index ffdd69c..ece3309 100644 --- a/eDosStation/Properties/AssemblyInfo.cs +++ b/eDosStation/Properties/AssemblyInfo.cs @@ -56,5 +56,5 @@ using System.Windows; //2.18 : more tested //2.20 Thermo : workflow bij issue ( en toevoegen time set) //2.22 No clear bij deissue. -[assembly: AssemblyVersion("2.22.0.0")] -[assembly: AssemblyFileVersion("2.22.0.0")] +[assembly: AssemblyVersion("2.24.0.0")] +[assembly: AssemblyFileVersion("2.24.0.0")] diff --git a/eDosStation/Resources/BuildDate.txt b/eDosStation/Resources/BuildDate.txt index 7fd5646..b5a5114 100644 --- a/eDosStation/Resources/BuildDate.txt +++ b/eDosStation/Resources/BuildDate.txt @@ -1 +1 @@ -Fri 08/30/2024 7:24:09.58 +Wed 09/04/2024 13:00:31.36 diff --git a/eDosStation/ShowEPDDose.xaml.cs b/eDosStation/ShowEPDDose.xaml.cs index cac67aa..a84cb4d 100644 --- a/eDosStation/ShowEPDDose.xaml.cs +++ b/eDosStation/ShowEPDDose.xaml.cs @@ -11,14 +11,18 @@ namespace eDosStation public partial class ShowEPDDose : Window { private enum eEntryState { none, getepd, epdtimeout, epdError, epdOK, final }; +#pragma warning disable CS0414 // The field 'ShowEPDDose.EntryState' is assigned but its value is never used private eEntryState EntryState; +#pragma warning restore CS0414 // The field 'ShowEPDDose.EntryState' is assigned but its value is never used Station thisStation; EpdBaseClr.Epd2 ep; DispatcherTimer dispatcherTimer; private DateTime ResultTime; private User thisUser; +#pragma warning disable CS0414 // The field 'ShowEPDDose.EpdReading' is assigned but its value is never used private bool EpdReading; +#pragma warning restore CS0414 // The field 'ShowEPDDose.EpdReading' is assigned but its value is never used private bool FinalTimeOut; public ShowEPDDose(Station curStation) diff --git a/eDosStation/Station.cs b/eDosStation/Station.cs index 5f664c6..8cffe1a 100644 --- a/eDosStation/Station.cs +++ b/eDosStation/Station.cs @@ -56,6 +56,9 @@ namespace eDosStation public TextBlock tbComments; public DataInterface dataInterface; public System.Collections.Generic.Dictionary beepMk3Map; + internal bool LogAll; + internal bool WriteConfig; + public ushort useBeepMK3() { if (beepMk3Map.ContainsKey(useBeep)) @@ -77,6 +80,14 @@ namespace eDosStation Inst_Name2 = defInst_Name2; TestCSN = System.Configuration.ConfigurationManager.AppSettings["TestCSN"]; TestCode = System.Configuration.ConfigurationManager.AppSettings["TestCode"]; + if (System.Configuration.ConfigurationManager.AppSettings["LogAll"] != null) + LogAll = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["LogAll"]); + else + LogAll = false; + if (System.Configuration.ConfigurationManager.AppSettings["WriteConfig"] != null) + WriteConfig = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["WriteConfig"]); + else + WriteConfig = false; insComments = new StringBuilder(); tbComments = new TextBlock(); tbComments.FontSize = 20; diff --git a/eDosStation/eDosStation.csproj b/eDosStation/eDosStation.csproj index 0079566..ab8d798 100644 --- a/eDosStation/eDosStation.csproj +++ b/eDosStation/eDosStation.csproj @@ -304,6 +304,7 @@ + EntryBadge.xaml diff --git a/eDosStation/eDosStation.zip b/eDosStation/eDosStation.zip index 9ba3827..a2de0e7 100644 Binary files a/eDosStation/eDosStation.zip and b/eDosStation/eDosStation.zip differ diff --git a/syncEdosLocal/Program.cs b/syncEdosLocal/Program.cs index 1e99780..2b30403 100644 --- a/syncEdosLocal/Program.cs +++ b/syncEdosLocal/Program.cs @@ -487,7 +487,9 @@ namespace syncEdosLocal } private static void copyEntry(DataSet1.LocalVisitsRow lr, DataSet1.CentralVisitsRow cr) { +#pragma warning disable CS0219 // The variable 'module' is assigned but its value is never used const string module = "copyEntry"; +#pragma warning restore CS0219 // The variable 'module' is assigned but its value is never used try { cr["ID_Station"] = lr["ID_Station"]; @@ -508,7 +510,9 @@ namespace syncEdosLocal } private static void copyExit(DataSet1.LocalVisitsRow lr, DataSet1.CentralVisitsRow cr) { +#pragma warning disable CS0219 // The variable 'module' is assigned but its value is never used const string module = "copyExit"; +#pragma warning restore CS0219 // The variable 'module' is assigned but its value is never used try { cr["ReturnTime"] = lr["ReturnTime"]; @@ -558,7 +562,9 @@ namespace syncEdosLocal private static DataSet1.CentralVisitsRow copyrow(DataSet1.LocalVisitsRow lr, DataSet1.CentralVisitsDataTable centralVisits) { DataSet1.CentralVisitsRow cr = centralVisits.NewCentralVisitsRow(); +#pragma warning disable CS0219 // The variable 'module' is assigned but its value is never used const string module = "copyExit"; +#pragma warning restore CS0219 // The variable 'module' is assigned but its value is never used try { foreach (DataColumn sc in lr.Table.Columns)