Skip to content

Commit

Permalink
Smoothing not applied of first run
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsavulescu committed Nov 8, 2024
1 parent 2865c04 commit 72b3db4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
8 changes: 5 additions & 3 deletions RAMS7200LibFacade.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,11 @@ void RAMS7200LibFacade::doSmoothing(std::vector<DPInfo>&& dpItems, std::vector<T
auto& var = it->second;
const auto dataSize = var._toDP.Amount * Common::S7Utils::DataSizeByte(var._toDP.WordLen);
if(var._toDP.pdata == nullptr) {
var._toDP.pdata = new char[dataSize];
}
if (std::memcmp(var._toDP.pdata, item.pdata, dataSize) != 0) {
Common::S7Utils::TS7AllocateDataItemForAddress(var._toDP);
std::memcpy(var._toDP.pdata, item.pdata, dataSize);
toDPItems.emplace_back(DPInfo.dpAddress.c_str(), dataSize, static_cast<char*>(item.pdata));
Common::Logger::globalInfo(Common::Logger::L4, DPInfo.dpAddress.c_str(), "--> Smoothing initialized");
} else if (std::memcmp(var._toDP.pdata, item.pdata, dataSize) != 0) {
std::memcpy(var._toDP.pdata, item.pdata, dataSize);
toDPItems.emplace_back(DPInfo.dpAddress.c_str(), dataSize, static_cast<char*>(item.pdata));
Common::Logger::globalInfo(Common::Logger::L4, DPInfo.dpAddress.c_str(), "--> Smoothing updated");
Expand Down
7 changes: 1 addition & 6 deletions RAMS7200MS.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@
#include <algorithm>


RAMS7200MSVar::RAMS7200MSVar(std::string varName, int pollTime, TS7DataItem type) : varName(varName), pollTime(pollTime), _toPlc(type), _toDP(type)
{
if(Common::Constants::getSmoothing()){
Common::S7Utils::TS7AllocateDataItemForAddress(_toDP);
}
}
RAMS7200MSVar::RAMS7200MSVar(std::string varName, int pollTime, TS7DataItem type) : varName(varName), pollTime(pollTime), _toPlc(type), _toDP(type){}

void RAMS7200MS::addVar(std::string varName, int pollTime)
{
Expand Down

0 comments on commit 72b3db4

Please sign in to comment.