#pragma once #include "LsbCreator.h" #include "CalibrationPoint.h" #include namespace Incart::Usb { struct IMicroMonLsbCreator : public ILsbCreator { virtual float createLsb(uint8_t channelNumber_, const std::vector& calibrationPoints)=0; }; struct MicroMonEcgLsbCreator : public IMicroMonLsbCreator { float createLsb(uint8_t channelNumber_, const std::vector& calibrationPoints) override { float lsb = 1.0; const CalibrationPoint& firstPoint = calibrationPoints[channelNumber_ * 2]; const CalibrationPoint& secondPoint = calibrationPoints[channelNumber_ * 2 + 1]; int32_t secondPointValue = static_cast(secondPoint.AdcValue); int32_t firstPointValue = static_cast(firstPoint.AdcValue); if (firstPoint.IsValid && secondPoint.IsValid && ((secondPointValue - firstPointValue) != 0)) { // считаем lsb "по-честному" для выдачи результата в мВ lsb = 10.0 / (static_cast(secondPointValue) - firstPointValue); } return lsb; } }; struct MicroMonReoLsbCreator : public IMicroMonLsbCreator { float createLsb(uint8_t channelNumber_, const std::vector& calibrationPoints) override { float lsb = 1.0; const CalibrationPoint& firstPoint = calibrationPoints[channelNumber_ * 2]; const CalibrationPoint& secondPoint = calibrationPoints[channelNumber_ * 2 + 1]; int32_t secondPointValue = static_cast(secondPoint.AdcValue); int32_t firstPointValue = static_cast(firstPoint.AdcValue); if (firstPoint.IsValid && secondPoint.IsValid && ((secondPointValue - firstPointValue) != 0)) { // считаем lsb "по-честному" для выдачи результата в Ом lsb = 1000.0f / (static_cast(secondPointValue) - firstPointValue); } return lsb; } }; struct MicroMonExternAccLsbCreator : public IMicroMonLsbCreator { float createLsb(uint8_t channelNumber_, const std::vector& calibrationPoints) override { float lsb = 0.001f; const CalibrationPoint& firstPoint = calibrationPoints[channelNumber_ * 2]; const CalibrationPoint& secondPoint = calibrationPoints[channelNumber_ * 2 + 1]; int32_t secondPointValue = static_cast(secondPoint.AdcValue); int32_t firstPointValue = static_cast(firstPoint.AdcValue); if (firstPoint.IsValid && secondPoint.IsValid && ((secondPointValue - firstPointValue) != 0)) { // считаем lsb "по-честному" в g lsb = 1.0 / (static_cast(secondPointValue) - firstPointValue); } return lsb; } }; struct MicroMonInnerAccLsbCreator : public IMicroMonLsbCreator { float createLsb(uint8_t channelNumber_, const std::vector& calibrationPoints) override { float lsb = 0.001f; const CalibrationPoint& firstPoint = calibrationPoints[channelNumber_ * 2]; const CalibrationPoint& secondPoint = calibrationPoints[channelNumber_ * 2 + 1]; int32_t secondPointValue = static_cast(secondPoint.AdcValue); int32_t firstPointValue = static_cast(firstPoint.AdcValue); //std::cout << "[MicroMonInnerAccLsbCreator.createLsb] " << firstPoint.IsValid << " " << secondPoint.IsValid << " (" << firstPoint.AdcValue << "; " << secondPoint.AdcValue << ")" << std::endl; if (firstPoint.IsValid && secondPoint.IsValid && ((secondPointValue - firstPointValue) != 0)) { // считаем lsb "по-честному" в g lsb = 1.0 / (static_cast(secondPointValue) - firstPointValue); } return lsb; } }; struct MicroMonPrsLsbCreator : public IMicroMonLsbCreator { float createLsb(uint8_t /*channelNumber_*/, const std::vector& /*calibrationPoints*/) override { return 0.001f * 1000; } }; struct MicroMonTonLsbCreator : public IMicroMonLsbCreator { float createLsb(uint8_t /*channelNumber_*/, const std::vector& /*calibrationPoints*/) override { return -1.0f * 1000; } }; struct MicroMonOxyLsbCreator : public IMicroMonLsbCreator { float createLsb(uint8_t /*channelNumber_*/, const std::vector& /*calibrationPoints*/) override { return -1.0f * 1000; } }; } // namespace Incart::Usb