Exemplo n.º 1
0
 inline SampleRate fromTimeSpan(const TimeSpan& timeSpan)
 {
     if(timeSpan > TimeSpan::Seconds(1))
     {
         return SampleRate::Seconds(
             static_cast<uint32>(timeSpan.getSeconds()));
     }
     else
     {
         uint32 samplesPerSecond = static_cast<uint32>(
             TimeSpan::NANOSECONDS_PER_SECOND /
             timeSpan.getNanoseconds());
         return SampleRate::Hertz(samplesPerSecond);
     }
 }
Exemplo n.º 2
0
	void NodeEepromHelper::write_samplingDelay(TimeSpan delay)
	{
		uint64 valueToWrite = 0;

		//get the type of node
		WirelessModels::NodeModel nodeType = m_node->model();

		switch(nodeType)
		{
			//these nodes all store the sampling delay in microseconds
			case WirelessModels::node_shmLink:
			case WirelessModels::node_shmLink2:
			case WirelessModels::node_sgLink_herm:
			case WirelessModels::node_sgLink_herm_2600:
			case WirelessModels::node_sgLink_herm_2700:
			case WirelessModels::node_sgLink_herm_2800:
			case WirelessModels::node_sgLink_rgd:
				valueToWrite = delay.getMicroseconds();
				break;

			default:
				break;
		}

		//if the delay is 1 second or more
		if(delay >= TimeSpan::Seconds(1))
		{
			//the delay should be stored as seconds
			valueToWrite = delay.getSeconds();
			valueToWrite += 32768;	//set the most significant bit on
		}
		else
		{
			//the delay should be stored as milliseconds
			valueToWrite = delay.getMilliseconds();
		}

		write(NodeEepromMap::SAMPLING_DELAY, Value::UINT16(static_cast<uint16>(valueToWrite)));
	}
Exemplo n.º 3
0
	void NodeEepromHelper::write_timeBetweenBursts(const TimeSpan& timespan)
	{
		//get the time in seconds from the TimeSpan
		uint64 timeInSeconds = timespan.getSeconds();

		//0 = seconds, 1 = minutes
		uint16 timeResolution = 0;

		//if the total seconds in the timespan is more than we can set when using "seconds"
		if(timeInSeconds > TIME_BETWEEN_BURSTS_MAX_SECS)
		{
			//convert from seconds to minutes (rounding up)
			timeInSeconds = static_cast<uint16>(std::ceil(static_cast<float>(timeInSeconds / 60.0f)));

			//set the resolution to minutes
			timeResolution = 1;
		}

		//build the value to write from the resolution bit and the time in seconds
		uint16 valToWrite = (timeResolution << 15) + static_cast<uint16>(timeInSeconds);

		//write the value we calculated
		write(NodeEepromMap::TIME_BETW_SESSIONS, Value::UINT16(valToWrite));
	}