#include "FeedControl.h" #include #include FeedControl::FeedControl(/* args */) : m_thre(0.3) { } FeedControl::~FeedControl() { } FeedControl::FeedMode FeedControl::GetPredictFeedMode() { return calcFeedMode(); } FeedControl::FeedMode FeedControl::calcFeedMode() { FeedMode mode = FeedMode::FMode_NOChange; auto infos = m_sessioninfo.GetRecordInfo(); if (infos.size() < 10) //样本数量大于10了 才做分纸模式分析切换 return mode; unsigned int nDoubleFeedTimes, nJamTimes, nFeedErrorTimes, nTotalScanned; nDoubleFeedTimes = nJamTimes = nFeedErrorTimes = nTotalScanned = 0; for (auto &item : infos) { if (!item.NormalDone) { if (item.DoubleFeed) nDoubleFeedTimes++; if (item.Jammed) nJamTimes++; if (item.FeedError) nFeedErrorTimes++; nTotalScanned += item.CurrentScaned; } } double percentHigh = nDoubleFeedTimes / 10.0; double percentLow = nFeedErrorTimes / 10.0; printf("\n percentHigh : %f percentLow : %f" , percentHigh,percentLow); if (percentHigh >= m_thre || percentLow >= m_thre) { mode = percentHigh >= percentLow ? FeedMode::FMode_High : FeedMode::FMode_Low; if(fabs(percentHigh - percentLow) < 0.2) mode = FeedMode::FMode_Mid; ResetMode(); } printf("\n Calc Feed Mode : %d" , (int)mode); return mode; } void FeedControl::AppendPattern(MotorSessionInfo::MBTaskRecordInfo info) { m_sessioninfo.UpdateRecordInfo(info); } void FeedControl::SetThre(double thre) { m_thre = thre; } void FeedControl::ResetMode() { m_sessioninfo.RemoveInfos(); }