Пример #1
0
      void
      handleCAMPR(std::auto_ptr<NMEAReader>& stn)
      {
        unsigned src = 0;
        *stn >> src;
        unsigned dst = 0;
        *stn >> dst;

        if (dst != m_address)
          return;

        double ttime = 0;
        try
        {
          *stn >> ttime;
        }
        catch (...)
        { }

        if (ttime < 0)
          ttime = 0;

        m_acop_out.op = IMC::AcousticOperation::AOP_RANGE_RECVED;
        m_acop_out.system = m_acop.system;
        m_acop_out.range = ttime * m_args.sspeed;
        dispatch(m_acop_out);
        resetOp();
      }
Пример #2
0
      void
      handleCAMUA(std::auto_ptr<NMEAReader>& stn)
      {
        unsigned src = 0;
        *stn >> src;
        unsigned dst = 0;
        *stn >> dst;

        // Get value.
        std::string val;
        *stn >> val;

        unsigned value = 0;
        std::sscanf(val.c_str(), "%04X", &value);

        if (value == c_code_abort_ack)
        {
          m_acop_out.op = IMC::AcousticOperation::AOP_ABORT_ACKED;
          m_acop_out.system = m_acop.system;
          dispatch(m_acop_out);
          resetOp();
        }
        if (value == c_code_plan_ack)
        {
          inf(DTR("plan started"));
          m_pc->setDestination(m_pc->getSource());
          m_pc->setDestinationEntity(m_pc->getSourceEntity());
          m_pc->setSource(getSystemId());
          m_pc->setSourceEntity(getEntityId());
          m_pc->type = IMC::PlanControl::PC_SUCCESS;
          m_pc->flags = 0;
          dispatch(*m_pc);
        }
        else if (value & c_mask_qtrack)
        {
          unsigned beacon = (value & c_mask_qtrack_beacon) >> 10;
          unsigned range = (value & c_mask_qtrack_range);
          IMC::LblRangeAcceptance msg;
          msg.setSource(m_mimap[src]);
          msg.id = beacon;
          msg.range = range;
          msg.acceptance = IMC::LblRangeAcceptance::RR_ACCEPTED;
          dispatch(msg);
          inf("%s %u: %u", DTR("range to"), beacon, range);
        }
Пример #3
0
void Client::connect()
{
	reset_socket();
	// [!]IRainman moved to two function:
	// void Client::on(Failed, const string& aLine)
	// void Client::disconnect(bool graceLess)
	clearAvailableBytes();
	
	setAutoReconnect(true);
	setReconnDelay(120 + Util::rand(0, 60));
	const FavoriteHubEntry* fhe = reloadSettings(true);
	// [!]IRainman fix.
	resetRegistered(); // [!]
	resetOp(); // [+]
	// [-] setMyIdentity(Identity(ClientManager::getInstance()->getMe(), 0)); [-]
	// [-] setHubIdentity(Identity()); [-]
	// [~] IRainman fix.
	
	state = STATE_CONNECTING;
	
	try
	{
#ifdef FLYLINKDC_USE_CS_CLIENT_SOCKET
		FastLock lock(csSock); // [+] brain-ripper
#endif
		m_client_sock = BufferedSocket::getBufferedSocket(m_separator);
		m_client_sock->addListener(this);
		m_client_sock->connect(m_address,
		                       m_port,
		                       m_secure,
		                       BOOLSETTING(ALLOW_UNTRUSTED_HUBS),
		                       true);
		dcdebug("Client::connect() %p\n", (void*)this);
	}
	catch (const Exception& e)
	{
		state = STATE_DISCONNECTED;
		fire(ClientListener::Failed(), this, e.getError());
	}
	m_isActivMode = ClientManager::isActive(fhe); // [+] IRainman opt.
	updateActivity();
}
Пример #4
0
      void
      handleSNTTA(std::auto_ptr<NMEAReader>& stn)
      {
        double ttime = 0;

        try
        {
          *stn >> ttime;
        }
        catch (...)
        {
          // No travel-time.
          return;
        }

        if (ttime < 0)
          ttime = 0;

        m_acop_out.op = IMC::AcousticOperation::AOP_RANGE_RECVED;
        m_acop_out.system = m_acop.system;
        m_acop_out.range = ttime * m_args.sspeed;
        dispatch(m_acop_out);
        resetOp();
      }
Пример #5
0
// Destructor
Session::~Session()
{
	resetOp();
}