// ----------------------------------------------------------------------
		bool 
			GeoRoutingProcessor::
			process_message( const shawn::ConstMessageHandle& mh ) 
			throw()
		{
			const GeoRoutingBeaconMessage* bm = dynamic_cast<const GeoRoutingBeaconMessage*>( mh.get() );
			if(bm)
			{
				return bm->routing_instance_w()->process_beacon_message(owner_w(),*bm);
			}
			const GeoRoutingPerimeterMessage* pm = dynamic_cast<const GeoRoutingPerimeterMessage*>( mh.get() );
			if(pm)
			{
				GeoRouting* routing_instance = static_cast<GeoRouting*>( pm->routing_instance_w() );
				return routing_instance->process_perimeter_message(owner_w(),*pm);
			}
			const GeoRoutingGreedyMessage* gm = dynamic_cast<const GeoRoutingGreedyMessage*>( mh.get() );
			if(gm)
			{
				GeoRouting* routing_instance = static_cast<GeoRouting*>( gm->routing_instance_w() );
				return routing_instance->process_greedy_message(owner_w(),*gm);
			}
			return Processor::process_message( mh );
		}
   // ----------------------------------------------------------------------
   bool
   SimpleAppProcessor::
   process_message( const shawn::ConstMessageHandle& mh ) 
      throw()
   {
      const SimpleAppMessage* msg = 
          dynamic_cast<const SimpleAppMessage*>( mh.get() );

      if( msg != NULL )
      { 
         if( owner() != msg->source() )
         { 
            neighbours_.insert( &msg->source() );
            INFO( logger(), "Received message from '" 
                            << msg->source().label() 
                            << "'" );
        
         }
         return true;
      }

      return Processor::process_message( mh );
   }
Example #3
0
	// ----------------------------------------------------------------------
	bool 
		LocalizationDLSModule::
		process_message( const shawn::ConstMessageHandle& mh) throw(){
			const LocalizationDLSInitMessage* msg = dynamic_cast<const LocalizationDLSInitMessage*>(mh.get());
			if(msg!=NULL){
				if(owner().proc_type()!=owner().unknown 
					|| state_ != dls_wait)
					return true;
				else{		
					matrix_a_ = msg->matrix_A();
					vector_r_ = new SimpleMatrix<double>(*(msg->vector_R()));
					covariance_a_= msg->covariance();
					linearization_tool_= msg->linearization_tool();
					beacons_=msg->beacons();
					state_ = dls_work;
					send( new LocalizationDLSInitMessage(msg) );
				}
				return true;
			}
			return LocalizationModule::process_message(mh);
	}
   // ----------------------------------------------------------------------
	bool   ExtIfaceProcessor::process_message( const shawn::ConstMessageHandle& mh ) throw()
	{
		const shawn::SimulationEnvironment& se = owner().world().simulation_controller().environment();
		const ExtIfaceWiselibMessage* message = dynamic_cast<const ExtIfaceWiselibMessage*> ( mh.get() );
		if ( message != NULL )
		{
			if ( message->source().id()!=owner().id() && (message->destination() == owner().id() || message->destination() == BROADCAST_ADDRESS) )
			{
				for ( ReceiverListIterator it = delegates_.begin();	it != delegates_.end(); ++it )
				{
					(*it)( message->source().id(), message->payload_size(), message->payload() );
				}
				if (!ext_delegates_.empty() )
				{
					node_id_t const from=message->source().id();
					double const ux=owner().real_position().x();
					double const uy=owner().real_position().y();
					double const uz=owner().real_position().z();
					double const vx=owner().world().find_node_by_id(from)->real_position().x();
					double const vy=owner().world().find_node_by_id(from)->real_position().y();
					double const vz=owner().world().find_node_by_id(from)->real_position().z();
					double const dist=std::sqrt((vx-ux)*(vx-ux)+(vy-uy)*(vy-uy)+(vz-uz)*(vz-uz));
					ExtendedData ex;
					double vrange = owner().world().find_node_by_id(from)->transmission_range();
					double urange = owner().transmission_range();
					double g_range = owner().world().communication_model().communication_upper_bound();
					double rssi_up = se.required_double_param( "rssi_up");
					double rssi_low = rssi_up - se.required_double_param( "rssi_low");
					double lqi_up = se.required_double_param( "lqi_limit_up_ratio");
					double lqi_low = se.required_double_param( "lqi_limit_low_ratio");
					double byte_var = se.required_double_param( "byte_var" );
					int len = message->payload_size();
					int max_len = message->max_len();
					double max_dist = g_range*vrange;
					ex.set_link_metric( rssi(dist, max_dist, rssi_up, rssi_low, byte_var, len, max_len ) );
					ex.set_rssi( rssi(dist, max_dist, rssi_up, rssi_low, byte_var, len, max_len ) );
					ex.set_lqi( lqi(dist, max_dist, rssi_up, rssi_low, lqi_up, lqi_low, byte_var, len, max_len  ) );
					for ( ExtendedReceiverListIterator it = ext_delegates_.begin(); it != ext_delegates_.end(); ++it )
					{
						(*it)(from, message->payload_size(), message->payload(), ex);
					}
				}
			}
			return true;
		}
		return shawn::Processor::process_message( mh );
	}
// ----------------------------------------------------------------------
bool
SimplifiedGeoRoutingProcessor::
process_message( const shawn::ConstMessageHandle& mh )
throw()
{
    const SimplifiedGeoRoutingPerimeterMessage* pm = dynamic_cast<const SimplifiedGeoRoutingPerimeterMessage*>( mh.get() );
    if(pm)
    {
        SimplifiedGeoRouting* routing_instance = static_cast<SimplifiedGeoRouting*>( pm->routing_instance_w() );
        return routing_instance->process_perimeter_message(owner_w(),*pm);
    }
    const SimplifiedGeoRoutingGreedyMessage* gm = dynamic_cast<const SimplifiedGeoRoutingGreedyMessage*>( mh.get() );
    if(gm)
    {
        SimplifiedGeoRouting* routing_instance = static_cast<SimplifiedGeoRouting*>( gm->routing_instance_w() );
        return routing_instance->process_greedy_message(owner_w(),*gm);
    }
    return Processor::process_message( mh );
}