prepare for read dose

This commit is contained in:
Luc 2021-05-18 15:42:46 +02:00
parent 5cc711e946
commit ef8362bb60
6 changed files with 101 additions and 14 deletions

View file

@ -117,10 +117,10 @@ int MK3::Epd2::GetStatus()
return StatusRV;
}
//int MK3::Epd2::GetDoses()
//{
// Hp10 = Hp07 = 0.0;
// ReadDosesRV = epd->ReadDoses();
int MK3::Epd2::GetDoses()
{
Hp10 = Hp07 = 0.0;
int ReadDosesRV = epd->ReadDoses();
//
// if (ReadDosesRV == 1) {
// GetDosesError = 0;
@ -161,8 +161,8 @@ int MK3::Epd2::GetStatus()
// FB = epd->FB;
// HG = epd->HG;
//
// return ReadDosesRV;
//}
return ReadDosesRV;
}
//
//int MK3::Epd2::SetDeIssued()
//{

View file

@ -134,7 +134,7 @@ namespace MK3 {
int GetStatus();
//int GetDoses();
int GetDoses();
//int SetDeIssued();
//int SetIssued();
//int PrepareForIssue();

View file

@ -282,16 +282,16 @@ WORD MK3::Epd2U::ReadStatus()
r = Commit(epdComsHandle);
r = WaitForSingleObject(Ev1, 10000); // no time-out interval
r = EndReadWearerId(epdComsHandle, token, &mk3WearerID);
if (mk3WearerID.Length > 23) mk3WearerID.Length = 23;
memcpy(WearerName, mk3WearerID.Utf8String, mk3WearerID.Length); WearerName[mk3WearerID.Length - 1] = 0;
if (mk3WearerID.Length > WearerNameLength) mk3WearerID.Length = WearerNameLength;
memcpy(WearerName, mk3WearerID.Utf8String, mk3WearerID.Length); WearerName[mk3WearerID.Length] = 0;
ResetEvent(Ev1);
token = BeginReadWearerId(epdComsHandle, static_cast<uint16_t>(WearerIdType::WearerId_Primary), completion);
r = Commit(epdComsHandle);
r = WaitForSingleObject(Ev1, 10000); // no time-out interval
r = EndReadWearerId(epdComsHandle, token, &mk3WearerID);
if (mk3WearerID.Length > 13) mk3WearerID.Length = 13;
memcpy(this->WearerID, mk3WearerID.Utf8String, mk3WearerID.Length); WearerName[mk3WearerID.Length - 1] = 0;
if (mk3WearerID.Length > WearerIDLength) mk3WearerID.Length = WearerIDLength;
memcpy(this->WearerID, mk3WearerID.Utf8String, mk3WearerID.Length); WearerName[mk3WearerID.Length] = 0;
for (int i = 0; i < mk3WearerID.Length; i++)
if (WearerID[i] == 0xb) WearerID[i] = '0'; else WearerID[i] |= 0x30;
@ -343,4 +343,83 @@ WORD MK3::Epd2U::ReadStatus()
// }
//}
return CommitRV;
}
}
WORD MK3::Epd2U::ReadDoses()
{
if (port == 0) {
Hp10Dose = Hp07Dose = Hp10Total = Hp07Total = Knocks = Resets = QualityData = 21;
Hp10Peak = Hp07Peak = Hp10Time = Hp07Time = 1000;
ErrorSource = ErrorReason = ErrorData = 0;
K1 = 1; K2 = 2; K3 = 3; K4 = 4; K5 = 5; K6 = 6;
SG = 7; BC = 8; FB = 9; HG = 10;
return 1;
}
ReadDosesQualityRV = ReadPeaksRV = CommitRV = 0;
numDoses = 0; utc = 0;
ResetEvent(Ev1);
//token = BeginReadDoses(epdComsHandle, new uint8_t[]{ 0, 1 }, 2 , completion);
token = BeginReadDoses(epdComsHandle, nullptr, 0, completion);
int32_t r = Commit(epdComsHandle);
r = WaitForSingleObject(Ev1, 10000); // no time-out interval
r = EndReadDoses(epdComsHandle, token, doses, 2, &numDoses, &utc);
//int32_t EPDDLL_API EndReadQualityData(CommsHandle hComms, CompletionToken token, Mk3QualityData_t * quality )
//ReadDosesQualityRV = ReadDosesQuality(
// &Hp10Dose,
// &Hp07Dose,
// &Hp10Total,
// &Hp07Total,
// &Knocks,
// &Resets,
// &QualityData);
//if (ReadDosesQualityRV == 0) {
// Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
// return 0;
//}
//BeginReadPeakRates(CommsHandle hComms, uint8_t ids[], uint8_t length, CompletionCallback callback )
/*ReadPeaksRV = ReadPeaks(
&Hp10Peak,
&Hp07Peak,
&Hp10Time,
&Hp07Time);
if (ReadPeaksRV == 0) {
Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
return 0;
}*/
// EPD2 :
// int32_t EPDDLL_API EndReadCalibrationData_R2 (CommsHandle hComms, CompletionToken token, uint16_t *HGSens10, uint16_t *SGSens10, uint16_t *HGSens07, uint16_t *SGSens07, uint16_t *FBSens07, uint16_t *BCSens07, uint16_t *SGthresh, uint16_t *BCthresh, uint16_t *FBthresh, uint16_t *HGthresh)
// EPD3
//
//CompletionToken EPDDLL_API BeginReadSensitivities_R3(CommsHandle hComms, uint8_t sensIds[], uint8_t length, CompletionCallback callback )
//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::PrepareForIssue()
//{
// if (port == 0) return 1;
// CommitRV = WriteConfig();
// if (CommitRV) CommitRV = Commit();
// if (CommitRV) CommitRV = ClearDose();
// if (CommitRV) CommitRV = ClearTotalDose();
// if (CommitRV) CommitRV = ClearPeakRates();
// if (CommitRV) CommitRV = Commit();
// return CommitRV;
//}

View file

@ -212,6 +212,10 @@ namespace MK3
BYTE byStatus3;
BYTE byStatus4;
MeasValue_t doses[4];
uint8_t numDoses;
uint32_t utc;
int StartDiscover();
void Open(DiscoveryId DeviceID);
void CloseDev();
@ -230,7 +234,7 @@ namespace MK3
WORD TurnOn();
//WORD WriteCal();
//WORD ReadTresHolds();
//WORD ReadDoses();
WORD ReadDoses();
//WORD PrepareForIssue();
//WORD DeIssue();

View file

@ -20,6 +20,8 @@ namespace TestEPD3Dll
x.Connect(false);
var rv = x.GetStatus();
}
}
}

View file

@ -64,8 +64,10 @@ void GetEPD()
r = EndReadStatus(epdComsHandle, token, &status);
numDoses = 0; utc = 0;
ResetEvent(Ev1);
token = BeginReadDoses(epdComsHandle, new uint8_t[]{0, 1}, 2, completion);
//token = BeginReadDoses(epdComsHandle, new uint8_t[]{ 0, 1 }, 2 , completion);
token = BeginReadDoses(epdComsHandle, nullptr, 0 , completion);
r = Commit(epdComsHandle);
r = WaitForSingleObject(Ev1, 10000); // no time-out interval
std::cout << "got doses\n";