Example #1
0
    void WirelessPacketCollector::addDataPacket(const WirelessPacket& packet)
    {
        //create a boost_lock for thread safety
        mutex_lock_guard lock(m_packetMutex);

        //update the last communication time
        NodeCommTimes::updateCommTime(packet.nodeAddress());

        try
        {
            //add a different packet depending on its type
            switch(packet.type())
            {
                //Low Duty Cycle packet
                case WirelessPacket::packetType_LDC:
                    m_dataPackets.push_back(LdcPacket(packet));
                    break;

                //Sync Sampling Packet
                case WirelessPacket::packetType_SyncSampling:
                    m_dataPackets.push_back(SyncSamplingPacket(packet));
                    break;

                //Buffered LDC packet
                case WirelessPacket::packetType_BufferedLDC:
                    m_dataPackets.push_back(BufferedLdcPacket(packet));
                    break;

                //Low Duty Cycle with 16 channels packet
                case WirelessPacket::packetType_LDC_16ch:
                    m_dataPackets.push_back(LdcPacket_16ch(packet));
                    break;

                //Sync Sampling with 16 channels packet
                case WirelessPacket::packetType_SyncSampling_16ch:
                    m_dataPackets.push_back(SyncSamplingPacket_16ch(packet));
                    break;

                //Buffered LDC with 16 channels packet
                case WirelessPacket::packetType_BufferedLDC_16ch:
                    m_dataPackets.push_back(BufferedLdcPacket_16ch(packet));
                    break;

                //Asynchronous Digital packet
                case WirelessPacket::packetType_AsyncDigital:
                    m_dataPackets.push_back(AsyncDigitalPacket(packet));
                    break;

                //Asynchronous Digital/Analog packet
                case WirelessPacket::packetType_AsyncDigitalAnalog:
                    m_dataPackets.push_back(AsyncDigitalAnalogPacket(packet));
                    break;

                //Structural Health Monitor packet
                case WirelessPacket::packetType_SHM:
                    m_dataPackets.push_back(ShmPacket(packet));
                    break;

                //HclSmartBearing Raw packet
                case WirelessPacket::packetType_HclSmartBearing_Raw:
                    m_dataPackets.push_back(HclSmartBearing_RawPacket(packet));
                    break;

                //Raw Angle Strain packet
                case WirelessPacket::packetType_rawAngleStrain:
                    m_dataPackets.push_back(RawAngleStrainPacket(packet));
                    break;

                //Beacon Echo packet
                case WirelessPacket::packetType_beaconEcho:
                    m_dataPackets.push_back(BeaconEchoPacket(packet));
                    break;
                    
                //RF Sweep packet
                case WirelessPacket::packetType_rfScanSweep:
                    m_dataPackets.push_back(RfSweepPacket(packet));
                    break;

                //Diagnostic packet
                case WirelessPacket::packetType_diagnostic:
                    m_dataPackets.push_back(DiagnosticPacket(packet));
                    break;

                //Roller packet
                case WirelessPacket::packetType_roller:
                    m_dataPackets.push_back(RollerPacket(packet));
                    break;

                //bad packet type, this function shouldn't have been called
                default:
                    throw Error("Unknown Packet Type");
            }

            //notify the read thread, if it is waiting for data to be put into the buffer
            m_emptyBufferCondition.notify_one();
        }
        catch(std::exception&)
        {
            //there was an error building one of the packets, just return
        }
    }
Example #2
0
	void WirelessPacketCollector::addDataPacket(const WirelessPacket& packet)
	{
		//create a boost_lock for thread safety
		mutex_lock_guard lock(m_packetMutex);

		try
		{

			//add a different packet depending on its type
			switch(packet.type())
			{
				//Low Duty Cycle packet
				case WirelessPacket::packetType_LDC:
					m_dataPackets.push_back(LdcPacket(packet));
					break;

				//Sync Sampling Packet
				case WirelessPacket::packetType_SyncSampling:
					m_dataPackets.push_back(SyncSamplingPacket(packet));
					break;

				//Buffered LDC packet
				case WirelessPacket::packetType_BufferedLDC:
					m_dataPackets.push_back(BufferedLdcPacket(packet));
					break;

				//Low Duty Cycle with 16 channels packet
				case WirelessPacket::packetType_LDC_16ch:
					m_dataPackets.push_back(LdcPacket_16ch(packet));
					break;

				//Sync Sampling with 16 channels packet
				case WirelessPacket::packetType_SyncSampling_16ch:
					m_dataPackets.push_back(SyncSamplingPacket_16ch(packet));
					break;

				//Buffered LDC with 16 channels packet
				case WirelessPacket::packetType_BufferedLDC_16ch:
					m_dataPackets.push_back(BufferedLdcPacket_16ch(packet));
					break;

				//Asynchronous Digital packet
				case WirelessPacket::packetType_AsyncDigital:
					m_dataPackets.push_back(AsyncDigitalPacket(packet));
					break;

				//Asynchronous Digital/Analog packet
				case WirelessPacket::packetType_AsyncDigitalAnalog:
					m_dataPackets.push_back(AsyncDigitalAnalogPacket(packet));
					break;

				//Structural Health Monitor packet
				case WirelessPacket::packetType_SHM:
					m_dataPackets.push_back(ShmPacket(packet));
					break;

				//HclSmartBearing Raw packet
				case WirelessPacket::packetType_HclSmartBearing_Raw:
					m_dataPackets.push_back(HclSmartBearing_RawPacket(packet));
					break;

				//bad packet type, this function shouldn't have been called
				default:
					throw Error("Unknown Packet Type");
			}

			//notify the read thread, if it is waiting for data to be put into the buffer
			m_emptyBufferCondition.notify_one();
		}
		catch(Error&)
		{
			//there was an error building one of the packets, just return
		}
	}