diff --git a/EpdBase/EpdBase.cpp b/EpdBase/EpdBase.cpp
index 3d0d0cf..e4543e8 100644
--- a/EpdBase/EpdBase.cpp
+++ b/EpdBase/EpdBase.cpp
@@ -1,237 +1,241 @@
-#include "stdafx.h"
-#include "EpdBase.h"
-
-EpdBase::Epd2U::Epd2U(int comport)
-{
- port = comport;
- SetAutoCommit(0);
- Error = 123;
- //SetTimeouts(port, 20, 1000, 1000);
- //SetDiscoveryExpirationPeriod(port, 5000);
- InitRv= InitComms(port, 9600, 8, 0, 0);
- if (InitRv == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
-}
-
-EpdBase::Epd2U::~Epd2U()
-{
- DeinitComms(port);
- SetAutoCommit(0);
-}
-
-
-void EpdBase::Epd2U::StartDiscover()
-{
- FlushDiscoveryCache(port);
- DiscRV= Discover(port, DeviceIDs, MaxDevices, &DeviceCount);
- if (DiscRV == 1 && DeviceCount == 0) {
- OnRV = EpdOn();
- Commit();
- Sleep(1100);
- DiscRV = Discover(port, DeviceIDs, MaxDevices, &DeviceCount);
- }
-
-}
-
-void EpdBase::Epd2U::Open(DWORD DeviceID)
-{
- CurrentDeviceID = DeviceID;
- ConRV = Connect(DeviceID);
- if (ConRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
- else {
- OpenRV = OpenDevice(port, CurrentDeviceID);
- if (OpenRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
- }
-}
-
-void EpdBase::Epd2U::Close()
-{
- CloseDevice();
-}
-
-void EpdBase::Epd2U::DecodeFunctionFlags()
-{
- EpdType = (FunctionFlags & 0x0300) >> 8;
-}
-
-void EpdBase::Epd2U::DecodeStatus()
-{
- DetectorsOn = (OperatingStatus & 1) != 0;
- EPDIssued = (OperatingStatus & 4) != 0;
- EPDLocked = (OperatingStatus & 0x10)!=0;
- EPDTesting = (OperatingStatus & 0x20) != 0;
- EPDProcSec = (OperatingStatus & 0x40) != 0;
- EPDFaulty = (OperatingStatus & 0x80) != 0;
-
- EPDNewFault = (ErrorStatus & 1) != 0;
- EPDComFault = (ErrorStatus & 2) != 0;
- EPDCalFault = (ErrorStatus & 4) != 0;
- EPDDetFault = (ErrorStatus & 8) != 0;
- EPDEprFault = (ErrorStatus & 0x10) != 0;
- EPDTrhFault = (ErrorStatus & 0x20) != 0;
- EPDOthFault = (ErrorStatus & 0x80) != 0;
-
- AlarmDoseHP101G = (AlarmStatus & 1) != 0;
- AlarmDoseHP102G = (AlarmStatus & 2) != 0;
- AlarmDoseHP07N = (AlarmStatus & 4) != 0;
- AlarmRateHP101G = (AlarmStatus & 8) != 0;;
- AlarmRateHP102G = (AlarmStatus & 0x10) != 0;
- AlarmRateHP07N = (AlarmStatus & 0x20) != 0;
-
- //OtherAlarm
- OtherAlarmRateHp101G = (OtherAlarms & 1) != 0;
- OtherAlarmRateHp102G = (OtherAlarms & 2) != 0;
- OtherAlarmRateHp07N = (OtherAlarms & 4) != 0;
- OtherAlarmReturn = (OtherAlarms & 8) != 0;
- OtherAlarmBatLow = (OtherAlarms & 0x10) != 0;
- OtherAlarmCarrier = (OtherAlarms & 0x20) != 0;
- OtherAlarmBatVolt = (OtherAlarms & 0x40) != 0;
-
-}
-
-WORD EpdBase::Epd2U::ReadStatus()
-{
- memset(WearerID, 0, WearerIDLength+1);
- memset(WearerName, 0, WearerNameLength+1);
-
- EpdClock = RealTime = IssueCount = OffTime = OperatingStatus = ErrorStatus = AlarmStatus = OtherAlarms = EEPROMBadSectors = 0;
- ErrorSource = ErrorReason = ErrorData = 0;
-
- ReadStatusRV= ReadEpdStatus(&EpdClock, &RealTime, &IssueCount, &OffTime, &OperatingStatus, &ErrorStatus, &AlarmStatus, &OtherAlarms, &EEPROMBadSectors);
- if (ReadStatusRV == 0) {
- Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
- return ErrorReason;
- }
-
- EpdID = HardVersion = SoftVersion = FunctionFlags = 0;
- ReadEpdIDRV = ReadEpdID(
- &EpdID,
- &HardVersion,
- &SoftVersion,
- &FunctionFlags);
- if (ReadEpdIDRV == 0) {
- Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
- return ErrorReason;
- }
-
- CommitRV = Commit();
- if(CommitRV == 0) {
- Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
- return ErrorReason;
- }
- else {
- time_t t = RealTime;
- TimeFunctions::UnixTimeToSystemTime(t, &tRealTime);
- DecodeStatus();
- DecodeFunctionFlags();
- }
-
- if (ReadStatusRV == 1 && EPDIssued == 1) {
- ReadWearerRV = 3;
- ReadWearerRV = ReadWearer(
- WearerID,
- WearerIDLength,
- WearerName,
- WearerNameLength);
- CommitRV = Commit();
- if (CommitRV == 0) {
- Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
- return ErrorReason;
- }
- }
- else
- ReadWearerRV = 4;
-
-
-
- return 1;
-}
-
-WORD EpdBase::Epd2U::EPDReadConfig()
-{
- ReadConfigRV = ReadConfig(
- &CountDownTime,
- &ReturnTime,
- &ChirpRate,
- &TeleBaudSetting,
- &SelfTestInterval,
- &BatteryLoadTestInt,
- &GeneralControl,
- &CommsTimeout,
- &InhibitTimeout,
- &MinTxInterval,
- &MaxTxIntervals,
- &RandomiseWindow,
- &DoseIncThresh);
- if (ReadConfigRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
- CommitRV = Commit();
- if (CommitRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
- return CommitRV;
-}
-
-WORD EpdBase::Epd2U::TurnOff()
-{
- OffRV = EpdOff();
- if (OffRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
- EndSessionRV = EndSession(AlarmCtrl,10);
- if (EndSessionRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
-
- else {
- CommitRV = Commit();
- if (CommitRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
- }
- return CommitRV;
-}
-
-WORD EpdBase::Epd2U::TurnOn()
-{
-
- //OnRV = EpdOn();
- //if (OnRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
-
- EndSessionRV = EndSession(AlarmCtrl, 10);
- if (EndSessionRV == 0) {
- Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
- return 0;
- }
-
- /*
- CommitRV = Commit();
- if (CommitRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);*/
-
- return 0;
-}
-
-
-WORD EpdBase::Epd2U::ReadTresHolds()
-{
- ReadDoseTresholdRV = ReadAlarmDoseThresholds(&Hp10THDose1, &Hp10THDose2, &Hp07THDose);
- ReadAlarmRateThresholdsRV = ReadAlarmRateThresholds(
- &Hp10Rate1On,
- &Hp10Rate2On,
- &Hp07RateOn,
- &Hp10Rate1Off,
- &Hp10Rate2Off,
- &Hp07RateOff);
- ReadCalibrationDataRV = ReadCalibrationData(
- &K1,
- &K2,
- &K3,
- &K4,
- &K5,
- &K6,
- &SG,
- &BC,
- &FB,
- &HG);
- CommitRV = Commit();
- if (CommitRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
- return CommitRV;
-}
-
-WORD EpdBase::Epd2U::ReadDoses()
-{
-
- ReadDosesQualityRV = ReadPeaksRV = CommitRV = 0;
+#include "stdafx.h"
+#include "EpdBase.h"
+
+EpdBase::Epd2U::Epd2U(int comport)
+{
+ port = comport;
+ SetAutoCommit(0);
+ Error = 123;
+ //SetTimeouts(port, 20, 1000, 1000);
+ //SetDiscoveryExpirationPeriod(port, 5000);
+ InitRv= InitComms(port, 9600, 8, 0, 0);
+ if (InitRv == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+}
+
+EpdBase::Epd2U::~Epd2U()
+{
+ DeinitComms(port);
+ SetAutoCommit(0);
+}
+
+
+void EpdBase::Epd2U::StartDiscover()
+{
+ FlushDiscoveryCache(port);
+ DiscRV= Discover(port, DeviceIDs, MaxDevices, &DeviceCount);
+ if (DiscRV == 1 && DeviceCount == 0) {
+ OnRV = EpdOn();
+ Commit();
+ Sleep(1100);
+ DiscRV = Discover(port, DeviceIDs, MaxDevices, &DeviceCount);
+ }
+
+}
+
+void EpdBase::Epd2U::Open(DWORD DeviceID)
+{
+ CurrentDeviceID = DeviceID;
+ ConRV = Connect(DeviceID);
+ if (ConRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+ else {
+ OpenRV = OpenDevice(port, CurrentDeviceID);
+ if (OpenRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+ }
+}
+
+void EpdBase::Epd2U::Close()
+{
+ CloseDevice();
+ DeinitComms(port);
+}
+
+void EpdBase::Epd2U::DecodeFunctionFlags()
+{
+ EpdType = (FunctionFlags & 0x0300) >> 8;
+}
+
+void EpdBase::Epd2U::DecodeStatus()
+{
+ DetectorsOn = (OperatingStatus & 1) != 0;
+ EPDIssued = (OperatingStatus & 4) != 0;
+ EPDLocked = (OperatingStatus & 0x10)!=0;
+ EPDTesting = (OperatingStatus & 0x20) != 0;
+ EPDProcSec = (OperatingStatus & 0x40) != 0;
+ EPDFaulty = (OperatingStatus & 0x80) != 0;
+
+ EPDNewFault = (ErrorStatus & 1) != 0;
+ EPDComFault = (ErrorStatus & 2) != 0;
+ EPDCalFault = (ErrorStatus & 4) != 0;
+ EPDDetFault = (ErrorStatus & 8) != 0;
+ EPDEprFault = (ErrorStatus & 0x10) != 0;
+ EPDTrhFault = (ErrorStatus & 0x20) != 0;
+ EPDOthFault = (ErrorStatus & 0x80) != 0;
+
+ AlarmDoseHP101G = (AlarmStatus & 1) != 0;
+ AlarmDoseHP102G = (AlarmStatus & 2) != 0;
+ AlarmDoseHP07N = (AlarmStatus & 4) != 0;
+ AlarmRateHP101G = (AlarmStatus & 8) != 0;;
+ AlarmRateHP102G = (AlarmStatus & 0x10) != 0;
+ AlarmRateHP07N = (AlarmStatus & 0x20) != 0;
+
+ //OtherAlarm
+ OtherAlarmRateHp101G = (OtherAlarms & 1) != 0;
+ OtherAlarmRateHp102G = (OtherAlarms & 2) != 0;
+ OtherAlarmRateHp07N = (OtherAlarms & 4) != 0;
+ OtherAlarmReturn = (OtherAlarms & 8) != 0;
+ OtherAlarmBatLow = (OtherAlarms & 0x10) != 0;
+ OtherAlarmCarrier = (OtherAlarms & 0x20) != 0;
+ OtherAlarmBatVolt = (OtherAlarms & 0x40) != 0;
+
+}
+
+WORD EpdBase::Epd2U::ReadStatus()
+{
+ memset(WearerID, 0, WearerIDLength+1);
+ memset(WearerName, 0, WearerNameLength+1);
+
+ EpdClock = RealTime = IssueCount = OffTime = OperatingStatus = ErrorStatus = AlarmStatus = OtherAlarms = EEPROMBadSectors = 0;
+ ErrorSource = ErrorReason = ErrorData = 0;
+
+ ReadStatusRV= ReadEpdStatus(&EpdClock, &RealTime, &IssueCount, &OffTime, &OperatingStatus, &ErrorStatus, &AlarmStatus, &OtherAlarms, &EEPROMBadSectors);
+ if (ReadStatusRV == 0) {
+ Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+ return ErrorReason;
+ }
+
+ EpdID = HardVersion = SoftVersion = FunctionFlags = 0;
+ ReadEpdIDRV = ReadEpdID(
+ &EpdID,
+ &HardVersion,
+ &SoftVersion,
+ &FunctionFlags);
+ if (ReadEpdIDRV == 0) {
+ Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+ return ErrorReason;
+ }
+
+ CommitRV = Commit();
+ if(CommitRV == 0) {
+ Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+ return ErrorReason;
+ }
+ else {
+ time_t t = RealTime;
+ TimeFunctions::UnixTimeToSystemTime(t, &tRealTime);
+ DecodeStatus();
+ DecodeFunctionFlags();
+ }
+
+ if (ReadStatusRV == 1 && EPDIssued == 1) {
+ ReadWearerRV = 3;
+ ReadWearerRV = ReadWearer(
+ WearerID,
+ WearerIDLength,
+ WearerName,
+ WearerNameLength);
+ CommitRV = Commit();
+ if (CommitRV == 0) {
+ Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+ return ErrorReason;
+ }
+ }
+ else
+ ReadWearerRV = 4;
+
+
+
+ return 1;
+}
+
+WORD EpdBase::Epd2U::EPDReadConfig()
+{
+ ReadConfigRV = ReadConfig(
+ &CountDownTime,
+ &ReturnTime,
+ &ChirpRate,
+ &TeleBaudSetting,
+ &SelfTestInterval,
+ &BatteryLoadTestInt,
+ &GeneralControl,
+ &CommsTimeout,
+ &InhibitTimeout,
+ &MinTxInterval,
+ &MaxTxIntervals,
+ &RandomiseWindow,
+ &DoseIncThresh);
+ if (ReadConfigRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+ CommitRV = Commit();
+ if (CommitRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+ return CommitRV;
+}
+
+WORD EpdBase::Epd2U::TurnOff()
+{
+ OffRV = EpdOff();
+ if (OffRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+ EndSessionRV = EndSession(AlarmCtrl,10);
+ if (EndSessionRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+
+ else {
+ CommitRV = Commit();
+ if (CommitRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+ }
+ return CommitRV;
+}
+
+WORD EpdBase::Epd2U::TurnOn()
+{
+
+ //OnRV = EpdOn();
+ //if (OnRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+
+ EndSessionRV = EndSession(AlarmCtrl, 10);
+ if (EndSessionRV == 0) {
+ Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+ return 0;
+ }
+
+ /*
+ CommitRV = Commit();
+ if (CommitRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);*/
+
+ return 0;
+}
+
+
+WORD EpdBase::Epd2U::ReadTresHolds()
+{
+ Hp10THDose1 = Hp10THDose2 = Hp07THDose = 0;
+ ReadDoseTresholdRV = ReadAlarmDoseThresholds(&Hp10THDose1, &Hp10THDose2, &Hp07THDose);
+ CommitRV = Commit();
+ if (CommitRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+ ReadAlarmRateThresholdsRV = ReadAlarmRateThresholds(
+ &Hp10Rate1On,
+ &Hp10Rate2On,
+ &Hp07RateOn,
+ &Hp10Rate1Off,
+ &Hp10Rate2Off,
+ &Hp07RateOff);
+ ReadCalibrationDataRV = ReadCalibrationData(
+ &K1,
+ &K2,
+ &K3,
+ &K4,
+ &K5,
+ &K6,
+ &SG,
+ &BC,
+ &FB,
+ &HG);
+ CommitRV = Commit();
+ if (CommitRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+ return CommitRV;
+}
+
+WORD EpdBase::Epd2U::ReadDoses()
+{
+
+ ReadDosesQualityRV = ReadPeaksRV = CommitRV = 0;
ReadDosesQualityRV = ReadDosesQuality(
&Hp10Dose,
&Hp07Dose,
@@ -239,94 +243,94 @@ WORD EpdBase::Epd2U::ReadDoses()
&Hp07Total,
&Knocks,
&Resets,
- &QualityData);
-
- if (ReadDosesQualityRV == 0) {
- Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
- return 0;
- }
-
-
+ &QualityData);
+
+ if (ReadDosesQualityRV == 0) {
+ Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+ return 0;
+ }
+
+
ReadPeaksRV = ReadPeaks(
&Hp10Peak,
&Hp07Peak,
- &Hp10Time,
- &Hp07Time);
- if (ReadPeaksRV == 0) {
- Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
- return 0;
- }
-
- CommitRV = Commit();
- if (CommitRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
- return CommitRV;
-}
-
-WORD EpdBase::Epd2U::DeIssue()
-{
- ClearDoseRV = ClearTotalDoseRV = ClearPeakRatesRV = DeIssueEpdRV = 0;
-
- CommitRV = ClearFailFlag();
- if (CommitRV) CommitRV = ClearFaultFlags();
- if (CommitRV) CommitRV = ClearLatchedAlarms();
- if (CommitRV) CommitRV = Commit();
-
- if (CommitRV) CommitRV = ClearDose();
- if (CommitRV) CommitRV = ClearTotalDose();
- if (CommitRV) CommitRV = ClearPeakRates();
-
- if (CommitRV) CommitRV = DeIssueEpd();
- if (CommitRV) CommitRV = Commit();
- if (CommitRV && DetectorsOn) {
- CommitRV = EpdOff();
- CommitRV= Commit();
- Sleep(1000);// Versie < .. Commit & Sleep
- }
-
- if (CommitRV) { EndSession(0x16, 12); Commit(); }// Continuous high tone for 1.2 seconds
- else
- {
- FlushBuffers();
- Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData); EndSession(0x5E, 40); return 0;
- }
-
- return CommitRV;
-
-}
-
-
-WORD EpdBase::Epd2U::Issue()
-{
- IssueEpdRV = WriteAlarmDoseThresholdsRV = WriteAlarmRateThresholdsRV = WriteWearerNameRV = OnRV = CommitRV = 0;
-
-
- DWORD OKRV = SetFailFlag(); // all actions have been completed
- if (OKRV) OKRV = Commit();
-
- if (OKRV) OKRV = WriteAlarmDoseThresholds(Hp10THDose1, Hp10THDose2, Hp07THDose);
- if (OKRV) OKRV = WriteAlarmRateThresholds(Hp10Rate1On, Hp10Rate2On, Hp07RateOn, Hp10Rate1Off, Hp10Rate2Off, Hp07RateOff);
- if (OKRV) OKRV = Commit();
- if (OKRV) OKRV = IssueEpd(WearerID, WearerIDLength);
- if (OKRV) OKRV = Commit();
-
- if (OKRV) OKRV = WriteWearerName(WearerName,WearerNameLength);
- if (OKRV) OKRV = ClearFailFlag(); // all actions have been completed
- if (OKRV) OKRV = Commit();
-
- if (!DetectorsOn) {
- OKRV = EpdOn(); OKRV=Commit(); Sleep(1000);
- }
-
- if (OKRV) {
- EndSession(0x16, 12);
- Commit();
- } // Continuous high tone for 1.2 seconds
- else
- {
- FlushBuffers();
- Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData); EndSession(0x5E, 40);
- }
-
-
- return OKRV;
+ &Hp10Time,
+ &Hp07Time);
+ if (ReadPeaksRV == 0) {
+ Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+ return 0;
+ }
+
+ CommitRV = Commit();
+ if (CommitRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
+ return CommitRV;
+}
+
+WORD EpdBase::Epd2U::DeIssue()
+{
+ ClearDoseRV = ClearTotalDoseRV = ClearPeakRatesRV = DeIssueEpdRV = 0;
+
+ CommitRV = ClearFailFlag();
+ if (CommitRV) CommitRV = ClearFaultFlags();
+ if (CommitRV) CommitRV = ClearLatchedAlarms();
+ if (CommitRV) CommitRV = Commit();
+
+ if (CommitRV) CommitRV = ClearDose();
+ if (CommitRV) CommitRV = ClearTotalDose();
+ if (CommitRV) CommitRV = ClearPeakRates();
+
+ if (CommitRV) CommitRV = DeIssueEpd();
+ if (CommitRV) CommitRV = Commit();
+ if (CommitRV && DetectorsOn) {
+ CommitRV = EpdOff();
+ CommitRV= Commit();
+ Sleep(1000);// Versie < .. Commit & Sleep
+ }
+
+ if (CommitRV) { EndSession(0x16, 12); Commit(); }// Continuous high tone for 1.2 seconds
+ else
+ {
+ FlushBuffers(port);
+ Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData); EndSession(0x5E, 40); return 0;
+ }
+
+ return CommitRV;
+
+}
+
+
+WORD EpdBase::Epd2U::Issue()
+{
+ IssueEpdRV = WriteAlarmDoseThresholdsRV = WriteAlarmRateThresholdsRV = WriteWearerNameRV = OnRV = CommitRV = 0;
+
+
+ DWORD OKRV = SetFailFlag(); // all actions have been completed
+ if (OKRV) OKRV = Commit();
+
+ if (OKRV) OKRV = WriteAlarmDoseThresholds(Hp10THDose1, Hp10THDose2, Hp07THDose);
+ if (OKRV) OKRV = WriteAlarmRateThresholds(Hp10Rate1On, Hp10Rate2On, Hp07RateOn, Hp10Rate1Off, Hp10Rate2Off, Hp07RateOff);
+ if (OKRV) OKRV = Commit();
+ if (OKRV) OKRV = IssueEpd(WearerID, WearerIDLength);
+ if (OKRV) OKRV = Commit();
+
+ if (OKRV) OKRV = WriteWearerName(WearerName,WearerNameLength);
+ if (OKRV) OKRV = ClearFailFlag(); // all actions have been completed
+ if (OKRV) OKRV = Commit();
+
+ if (!DetectorsOn) {
+ OKRV = EpdOn(); OKRV=Commit(); Sleep(1000);
+ }
+
+ if (OKRV) {
+ EndSession(0x16, 12);
+ Commit();
+ } // Continuous high tone for 1.2 seconds
+ else
+ {
+ FlushBuffers(port);
+ Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData); EndSession(0x5E, 40);
+ }
+
+
+ return OKRV;
}
\ No newline at end of file
diff --git a/EpdBaseClr/EpdBaseClr.cpp b/EpdBaseClr/EpdBaseClr.cpp
index 15a431c..e52dc29 100644
--- a/EpdBaseClr/EpdBaseClr.cpp
+++ b/EpdBaseClr/EpdBaseClr.cpp
@@ -10,6 +10,16 @@ EpdBaseClr::Epd2::Epd2(int port)
}
+EpdBaseClr::Epd2::~Epd2()
+{
+ delete b;
+ this->!Epd2();
+}
+
+EpdBaseClr::Epd2::!Epd2()
+{
+}
+
int EpdBaseClr::Epd2::Connect()
{
b->CurrentDeviceID = 0;
@@ -19,6 +29,16 @@ int EpdBaseClr::Epd2::Connect()
return DiscRV;
}
+int EpdBaseClr::Epd2::Close()
+{
+ b->CurrentDeviceID = 0;
+ epd->Close();
+ delete epd;
+ return 0;
+}
+
+
+
int EpdBaseClr::Epd2::GetStatus()
{
//ReadStatus
@@ -29,6 +49,16 @@ int EpdBaseClr::Epd2::GetStatus()
WearerID = gcnew String((char *)epd->WearerID);
WearerName = gcnew String((char *)epd->WearerName);
isOn = (epd->DetectorsOn != 0);
+ epdType = epd->EpdType;
+ alarmStatus = epd->AlarmStatus;
+ otherAlarms = epd->OtherAlarms;
+ errorStatus = epd->ErrorStatus;
+ operatingStatus = epd->OperatingStatus;
+
+ EpdID = epd->EpdID;
+ HardVersion = epd->HardVersion;
+ SoftVersion = epd->SoftVersion;
+ FunctionFlags = epd->FunctionFlags;
return StatusRV;
}
@@ -36,19 +66,22 @@ int EpdBaseClr::Epd2::GetStatus()
int EpdBaseClr::Epd2::GetDoses()
{
Hp10 = Hp07 = 0.0;
- ReadDosesRV = epd->ReadDoses();
-
- if (ReadDosesRV == 1) {
- Hp10 = (double)epd->Hp10Dose / 64.0;
- Hp07 = (double)epd->Hp07Dose / 64.0;
- Hp07Peak = (double)epd->Hp07Peak / 64.0;
- Hp10Peak = (double)epd->Hp10Peak / 64.0;
- }
-
- //epd->SoftVersion
- return ReadDosesRV;
-}
-
+ ReadDosesRV = epd->ReadDoses();
+
+ if (ReadDosesRV == 1) {
+ Hp10 = (double)epd->Hp10Dose / 64.0;
+ Hp07 = (double)epd->Hp07Dose / 64.0;
+ Hp07Peak = (double)epd->Hp07Peak / 64.0;
+ Hp10Peak = (double)epd->Hp10Peak / 64.0;
+ }
+
+ Hp10PeakTime = System::DateTime::Now.AddSeconds(-(epd->Hp10Time - epd->EpdClock));
+ Hp07PeakTime = System::DateTime::Now.AddSeconds(-(epd->Hp07Time - epd->EpdClock));
+
+
+ return ReadDosesRV;
+}
+
int EpdBaseClr::Epd2::SetDeIssued()
{
return epd->DeIssue();
@@ -56,8 +89,9 @@ int EpdBaseClr::Epd2::SetDeIssued()
int EpdBaseClr::Epd2::SetIssued()
{
- epd->AlarmDoseHP07N = alarmHP07;
- epd->AlarmDoseHP101G = alarmHP10;
+ epd->AlarmDoseHP07N = Hp07THDose;
+ epd->AlarmDoseHP101G = Hp10THDose1;
+ epd->AlarmDoseHP102G = Hp10THDose1;
memset(epd->WearerID, ' ', WearerIDLength); epd->WearerID[WearerIDLength] = 0;
char* str1 = (char*)(void *)Runtime::InteropServices::Marshal::StringToHGlobalAnsi(WearerID);
@@ -66,7 +100,6 @@ int EpdBaseClr::Epd2::SetIssued()
_memccpy( epd->WearerID+WearerIDLength-l, str1, l, WearerIDLength);
Runtime::InteropServices::Marshal::FreeHGlobal((IntPtr)str1);
-
memset(epd->WearerName, 0, WearerNameLength + 1);
char* str2 = (char*)(void*)Runtime::InteropServices::Marshal::StringToHGlobalAnsi(WearerName);
_memccpy(epd->WearerName, str2, strlen(str2), WearerNameLength);
@@ -74,5 +107,34 @@ int EpdBaseClr::Epd2::SetIssued()
epd->Issue();
+ return 0;
+}
+
+int EpdBaseClr::Epd2::ReadTresholds()
+{
+ epd->ReadTresHolds();
+
+ Hp10THDose1 = (double)epd->Hp10THDose1 / 64.0;
+ Hp10THDose2 = (double)epd->Hp10THDose2 / 64.0;
+ Hp07THDose = (double)epd->Hp07THDose / 64.0;
+
+ Hp10Rate1On = (double)epd->Hp10Rate1On;
+ Hp10Rate2On = (double)epd->Hp10Rate2On ;
+ Hp07RateOn = (double)epd->Hp07RateOn ;
+ Hp10Rate1Off = (double)epd->Hp10Rate1Off ;
+ Hp10Rate2Off = (double)epd->Hp10Rate2Off ;
+ Hp07RateOff = (double)epd->Hp07RateOff ;
+
+ K1 = epd->K1;
+ K2 = epd->K2;
+ K3 = epd->K3;
+ K4 = epd->K4;
+ K5 = epd->K5;
+ K6 = epd->K6;
+ SG = epd->SG;
+ BC = epd->BC;
+ FB = epd->FB;
+ HG = epd->HG;
+
return 0;
}
\ No newline at end of file
diff --git a/EpdBaseClr/EpdBaseClr.h b/EpdBaseClr/EpdBaseClr.h
index f5e9030..5b11851 100644
--- a/EpdBaseClr/EpdBaseClr.h
+++ b/EpdBaseClr/EpdBaseClr.h
@@ -5,11 +5,11 @@ using namespace System;
namespace EpdBaseClr {
- public ref class sEpdBase
- {
- public :
- DateTime^ RealTime;
- unsigned int CurrentDeviceID;
+ public ref class sEpdBase
+ {
+ public :
+ DateTime^ RealTime;
+ unsigned int CurrentDeviceID;
};
@@ -36,16 +36,58 @@ namespace EpdBaseClr {
double Hp10;
double Hp07Peak;
double Hp10Peak;
+ System::DateTime Hp10PeakTime;
+ System::DateTime Hp07PeakTime;
double alarmHP07;
double alarmHP10;
+ double Hp10THDose1;
+ double Hp10THDose2;
+ double Hp07THDose;
+
+ double Hp10Rate1On;
+ double Hp10Rate2On;
+ double Hp07RateOn;
+ double Hp10Rate1Off;
+ double Hp10Rate2Off;
+ double Hp07RateOff;
+
+ int K1;
+ int K2;
+ int K3;
+ int K4;
+ int K5;
+ int K6;
+ int SG;
+ int BC;
+ int FB;
+ int HG;
+
+
+
+
+ int epdType;
+ int alarmStatus ;
+ int otherAlarms ;
+ int errorStatus ;
+ int operatingStatus ;
+ unsigned int EpdID ;
+ int HardVersion ;
+ int SoftVersion ;
+ int FunctionFlags ;
+
+
Epd2(int port);
+ ~Epd2();
+ !Epd2();
int Connect();
+ int Close();
+
int GetStatus();
int GetDoses();
@@ -54,6 +96,8 @@ namespace EpdBaseClr {
int SetIssued();
+ int ReadTresholds();
+
};
diff --git a/eDosStation/App.config b/eDosStation/App.config
index 5754728..72e7aa7 100644
--- a/eDosStation/App.config
+++ b/eDosStation/App.config
@@ -1,6 +1,18 @@
+
+
+
+
+
+
+
+
+ 6
+
+
+
\ No newline at end of file
diff --git a/eDosStation/EpdEntry.xaml b/eDosStation/EpdEntry.xaml
index 2bfe890..adde4ca 100644
--- a/eDosStation/EpdEntry.xaml
+++ b/eDosStation/EpdEntry.xaml
@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:eDosStation"
mc:Ignorable="d"
- Title="Entry" Height="450" Width="800" Loaded="Window_Loaded">
+ Title="Entry" Height="450" Width="800" Loaded="Window_Loaded" Unloaded="Window_Unloaded">
@@ -34,12 +34,15 @@
-
+
-
+
-
+
+
+
+
diff --git a/eDosStation/EpdEntry.xaml.cs b/eDosStation/EpdEntry.xaml.cs
index bc937c5..8bc0bf9 100644
--- a/eDosStation/EpdEntry.xaml.cs
+++ b/eDosStation/EpdEntry.xaml.cs
@@ -50,7 +50,7 @@ namespace eDosStation
private void Window_Loaded(object sender, RoutedEventArgs e)
{
- ep = new EpdBaseClr.Epd2(3);
+ ep = new EpdBaseClr.Epd2(Properties.Settings.Default.comport);
ep.Connect();
if (ep.DiscRV == 1 && ep.b.CurrentDeviceID > 0)
{
@@ -98,14 +98,20 @@ namespace eDosStation
private void BIssue_Click(object sender, RoutedEventArgs e)
{
bIssue.IsEnabled = false;
- ep.alarmHP07 = double.Parse(aHP07.Text);
- ep.alarmHP10 = double.Parse(aHP10.Text);
+ ep.Hp07THDose = double.Parse(HP07AlarmDose.Text);
+ ep.Hp10THDose1 = double.Parse(HP10AlarmDose1.Text);
+ ep.Hp10THDose2 = double.Parse(HP10AlarmDose2.Text);
ep.WearerID = wID.Text;
ep.WearerName = wName.Text;
ep.SetIssued();
this.Close();
}
+
+ private void Window_Unloaded(object sender, RoutedEventArgs e)
+ {
+ ep.Dispose();
+ }
}
}
diff --git a/eDosStation/EpdExit.xaml.cs b/eDosStation/EpdExit.xaml.cs
index 312c866..2d62b35 100644
--- a/eDosStation/EpdExit.xaml.cs
+++ b/eDosStation/EpdExit.xaml.cs
@@ -55,7 +55,7 @@ namespace eDosStation
private void Window_Loaded(object sender, RoutedEventArgs e)
{
- ep = new EpdBaseClr.Epd2(3);
+ ep = new EpdBaseClr.Epd2(Properties.Settings.Default.comport);
ep.Connect();
if (ep.DiscRV == 1 && ep.b.CurrentDeviceID > 0)
{
diff --git a/eDosStation/LOG.INI b/eDosStation/LOG.INI
new file mode 100644
index 0000000..e69de29
diff --git a/eDosStation/Properties/Settings.Designer.cs b/eDosStation/Properties/Settings.Designer.cs
index fa8f0ef..c597404 100644
--- a/eDosStation/Properties/Settings.Designer.cs
+++ b/eDosStation/Properties/Settings.Designer.cs
@@ -8,23 +8,31 @@
//
//------------------------------------------------------------------------------
-namespace eDosStation.Properties
-{
-
-
+namespace eDosStation.Properties {
+
+
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
- internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
- {
-
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
- public static Settings Default
- {
- get
- {
+
+ public static Settings Default {
+ get {
return defaultInstance;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("6")]
+ public int comport {
+ get {
+ return ((int)(this["comport"]));
+ }
+ set {
+ this["comport"] = value;
+ }
+ }
}
}
diff --git a/eDosStation/Properties/Settings.settings b/eDosStation/Properties/Settings.settings
index 8f2fd95..892eb40 100644
--- a/eDosStation/Properties/Settings.settings
+++ b/eDosStation/Properties/Settings.settings
@@ -1,7 +1,9 @@
-
-
-
-
-
+
+
+
+
+ 6
+
+
\ No newline at end of file
diff --git a/eDosStation/ShowEPDDose.xaml b/eDosStation/ShowEPDDose.xaml
index 61ecf38..c261460 100644
--- a/eDosStation/ShowEPDDose.xaml
+++ b/eDosStation/ShowEPDDose.xaml
@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:eDosStation"
mc:Ignorable="d"
- Title="ShowEPDDose" Height="450" Width="800" Loaded="Window_Loaded">
+ Title="ShowEPDDose" Height="450" Width="800" Loaded="Window_Loaded" Unloaded="Window_Unloaded">
@@ -14,7 +14,7 @@
-
+
@@ -26,11 +26,17 @@
-
+
+
+
+
+
+
+
diff --git a/eDosStation/ShowEPDDose.xaml.cs b/eDosStation/ShowEPDDose.xaml.cs
index 21f1283..0beb89b 100644
--- a/eDosStation/ShowEPDDose.xaml.cs
+++ b/eDosStation/ShowEPDDose.xaml.cs
@@ -30,8 +30,6 @@ namespace eDosStation
InitializeComponent();
}
-
-
private void LoadDoses()
{
ep.GetStatus();
@@ -42,13 +40,17 @@ namespace eDosStation
HpDose07.Text = $"HP07: {ep.Hp07:0.00 µ Sv} ";
HpDose10.Text = $"Hp10: {ep.Hp10:0.00 µ Sv}";
-
-
+ ep.ReadTresholds();
+ HP10AlarmDose1.Text = $"Alarm HP10(1) {ep.Hp10THDose1:0.00 µ Sv}";
+ HP10AlarmDose2.Text = $"Alarm HP10(2) {ep.Hp10THDose2:0.00 µ Sv}";
+ HP07AlarmDose.Text = $"Alarm HP07 {ep.Hp07THDose:0.00 µ Sv}";
+ //int Hp10THDose2;
+ //int Hp07THDose;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
- ep = new EpdBaseClr.Epd2(3);
+ ep = new EpdBaseClr.Epd2(Properties.Settings.Default.comport);
ep.Connect();
if (ep.DiscRV == 1 && ep.b.CurrentDeviceID > 0)
{
@@ -92,5 +94,10 @@ namespace eDosStation
}
}
+
+ private void Window_Unloaded(object sender, RoutedEventArgs e)
+ {
+ ep.Dispose();
+ }
}
}