示例#1
0
static void dataCb(hbm::streaming::SubscribedSignal& subscribedSignal, uint64_t ntpTimestamp, const double* pValues, size_t count)
{
	signalInfos_t::iterator iter = signalFiles.find(subscribedSignal.signalNumber());
	if(iter==signalFiles.end()) {
		return;
	}

	iter->second->addData(ntpTimestamp, pValues,  count);
}
示例#2
0
static void signalMetaInformationCb(hbm::streaming::SubscribedSignal& subscribedSignal, const std::string& method, const Json::Value& params)
{
	unsigned int signalNumber = subscribedSignal.signalNumber();
	if(method=="subscribe") {
		std::unique_ptr < signalInfo_t > pSignalInfo(new signalInfo_t(subscribedSignal.signalReference()));
		pSignalInfo->addMetaInfo(method, params);
		signalFiles.insert(std::pair < unsigned int, std::unique_ptr < signalInfo_t > > (signalNumber, std::move(pSignalInfo)));
	} else if(method=="unsubscribe") {
		signalFiles.erase(signalNumber);
	} else {
		signalInfos_t::iterator iter = signalFiles.find(signalNumber);
		if(iter==signalFiles.end()) {
			std::cerr << "received meta information for signal that is not known to be subscribed" << std::endl;
			return;
		}
		iter->second->addMetaInfo(method, params);
	}
}
示例#3
0
文件: ramp.cpp 项目: gatzka/cppstream
static void dataCb(hbm::streaming::SubscribedSignal& subscribedSignal, uint64_t timeStamp, const double* pValues, size_t count)
{
	unsigned int signalNumber = subscribedSignal.signalNumber();
	lastRampValues_t::iterator iter = m_lastRampValues.find(signalNumber);

	if(iter==m_lastRampValues.end()) {
		lastRampValues lastValues;
		lastValues.timeStamp = timeStamp;
		lastValues.amplitude = pValues[count-1];
		m_lastRampValues.insert(std::make_pair(signalNumber, lastValues));
	} else {
		double valueDiff = pValues[0] - iter->second.amplitude;
		if(fabs(valueDiff - rampValueDiff) > epsilon) {
			throw std::runtime_error (subscribedSignal.signalReference() + ": unexpected value in ramp!");
		} else if (iter->second.timeStamp>=timeStamp){
			throw std::runtime_error (subscribedSignal.signalReference() + ": unexpected time stamp in ramp!");
		} else {
			iter->second.amplitude = pValues[count-1];
		}
	}
}