diff --git a/Drivers/ScanLab/Implementation/libmcdriver_scanlab_rtccontext.cpp b/Drivers/ScanLab/Implementation/libmcdriver_scanlab_rtccontext.cpp index 7fe3c6de..9b419090 100644 --- a/Drivers/ScanLab/Implementation/libmcdriver_scanlab_rtccontext.cpp +++ b/Drivers/ScanLab/Implementation/libmcdriver_scanlab_rtccontext.cpp @@ -1114,6 +1114,15 @@ void CRTCContext::AddMarkMovement(const LibMCDriver_ScanLab_double dTargetX, con m_nCurrentScanPositionY = intY; } +int32_t CRTCContext::ConvertDelaySecondsToTicks(double delay) +{ + // 1 tick = 1/64 us = 1e-6 / 64 s + // ticks = delay / (1e-6/64) = delay * 64e6 + const int64_t ticks = static_cast(std::llround(delay * 64.0e6)); + + // Clamp to [0 .. 32767] + return static_cast( (ticks < 0) ? 0 : (ticks > 32767) ? 32767 : ticks ); +} void CRTCContext::AddMicrovectorMovement(const LibMCDriver_ScanLab_uint64 nMicrovectorArrayBufferSize, const LibMCDriver_ScanLab::sMicroVector* pMicrovectorArrayBuffer) { @@ -1131,9 +1140,8 @@ void CRTCContext::AddMicrovectorMovement(const LibMCDriver_ScanLab_uint64 nMicro int32_t intX = (int32_t)dX; int32_t intY = (int32_t)dY; - - int32_t intDelayLaserOn = (pMicroVector->m_LaserOnDelay < 0.0) ? -1 : round(pMicroVector->m_LaserOnDelay * 100000); - int32_t intDelayLaserOff = (pMicroVector->m_LaserOffDelay < 0.0) ? -1 : round(pMicroVector->m_LaserOffDelay * 100000); + int32_t intDelayLaserOn = (pMicroVector->m_LaserOnDelay < 0.0) ? -1 : ConvertDelaySecondsToTicks(pMicroVector->m_LaserOnDelay); + int32_t intDelayLaserOff = (pMicroVector->m_LaserOffDelay < 0.0) ? -1 : ConvertDelaySecondsToTicks(pMicroVector->m_LaserOffDelay); m_pScanLabSDK->n_micro_vector_abs(m_CardNo, intX, intY, intDelayLaserOn, intDelayLaserOff); diff --git a/Drivers/ScanLab/Implementation/libmcdriver_scanlab_rtccontext.hpp b/Drivers/ScanLab/Implementation/libmcdriver_scanlab_rtccontext.hpp index 2f744bb0..7868cae2 100644 --- a/Drivers/ScanLab/Implementation/libmcdriver_scanlab_rtccontext.hpp +++ b/Drivers/ScanLab/Implementation/libmcdriver_scanlab_rtccontext.hpp @@ -213,6 +213,9 @@ class CRTCContext : public virtual IRTCContext, public virtual CBase { // Calls the SetTriggerX Call that is necessary for the specific OIE board void callSetTriggerOIE(uint32_t nPeriod); + // Converts a delay in seconds to RTC ticks + int32_t ConvertDelaySecondsToTicks(double delay); + public: CRTCContext(PRTCContextOwnerData pOwnerData, uint32_t nCardNo, bool bIsNetwork, LibMCEnv::PDriverEnvironment pDriverEnvironment); diff --git a/Implementation/LibMCEnv/libmcenv_datatable.cpp b/Implementation/LibMCEnv/libmcenv_datatable.cpp index f3a1ecae..c047b10a 100644 --- a/Implementation/LibMCEnv/libmcenv_datatable.cpp +++ b/Implementation/LibMCEnv/libmcenv_datatable.cpp @@ -841,9 +841,34 @@ class CDataTableColumn_Int32 : public CDataTableColumn void fillScatterplotChannel(AMC::CScatterplot* pScatterplot, const std::string& sChannel, const std::string& sColumn, double dScaleFactor, double dOffset) override { - throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_NOTIMPLEMENTED); - } + if (pScatterplot == nullptr) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDPARAM); + auto& channelEntries = pScatterplot->getChannelEntries(); + auto channelIter = channelEntries.find(sChannel); + + if (channelIter == channelEntries.end()) { + channelEntries[sChannel][sColumn] = std::vector(); + } + else { + auto& columnEntries = channelIter->second; + + if (columnEntries.find(sColumn) == columnEntries.end()) + columnEntries[sColumn] = std::vector(); + else { + std::string sException = "The channel = " + sChannel + " with the column = " + sColumn + " already exists"; + throw std::runtime_error(sException.c_str()); + } + } + + auto& vecColumn = channelEntries[sChannel][sColumn]; + + vecColumn.resize(m_Rows.size()); + + for (size_t nIndex = 0; nIndex < m_Rows.size(); nIndex++) { + vecColumn[nIndex] = (double)m_Rows.at(nIndex) * dScaleFactor + dOffset; + } + } };