#pragma once #include "ByteArrayProvider.h" namespace Incart::Usb { struct CalibrationPoint { uint8_t PointIndex; uint8_t ChannelType; uint8_t ChannelNumber; uint32_t AdcValue; double PhysicalValue; int8_t Range; bool IsValid = true; CalibrationPoint() { } CalibrationPoint(uint8_t _pointIndex, uint8_t _channelType, uint8_t _channelNumber, uint32_t _adcValue, double _physicalValue, int8_t _range) : PointIndex(_pointIndex), ChannelType(_channelType), ChannelNumber(_channelNumber),AdcValue(_adcValue), PhysicalValue(_physicalValue), Range(_range) { } CalibrationPoint(uint8_t _pointIndex, uint8_t _channelType, uint8_t _channelNumber, uint8_t* _data, size_t _dataSize) : PointIndex(_pointIndex), ChannelType(_channelType), ChannelNumber(_channelNumber) { AdcValue = static_cast(Common::ByteArrayProvider::ulongFromArray(_data, _dataSize, 0)); PhysicalValue = static_cast(Common::ByteArrayProvider::intThreeBytesFromArray(_data, _dataSize, 4)); Range = static_cast(_data[7]); } std::vector toArray(size_t* _length = nullptr) { if (_length != nullptr) { *_length = 11; } std::vector data{ ChannelType, ChannelNumber, PointIndex, /* adcValue */ 0x00, 0x00, 0x00, 0x00, /* physicalValue */ 0x00, 0x00, 0x00, static_cast(Range) }; Common::ByteArrayProvider::setDWordToArray(AdcValue, &data[0], 3); Common::ByteArrayProvider::setIntThreeBytesToArray(&data[0], static_cast(PhysicalValue), 7); return data; } }; } // namespace Incart::Usb