Ejemplo n.º 1
0
// Edit existing search
LRESULT ADLSearchFrame::onEdit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
    // Get selection info
    int i = ctrlList.GetNextItem(-1, LVNI_SELECTED);
    if(i < 0)
    {
        // Nothing selected
        return 0;
    }

    // Edit existing
    ADLSearchManager::SearchCollection& collection = ADLSearchManager::getInstance()->collection;
    ADLSearch* search = collection[i];

    // Invoke dialog with selected search
    ADLSProperties dlg(search);
    if(dlg.DoModal((HWND)*this) == IDOK)
    {
        // Update search collection
        collection[i] = search;

        // Update list control
        UpdateSearch(i);
    }

    return 0;
}
Ejemplo n.º 2
0
// Add new search
LRESULT ADLSearchFrame::onAdd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 
{
	// Invoke edit dialog with fresh search
	ADLSearch search;
	ADLSProperties dlg(&search);
	if(dlg.DoModal((HWND)*this) == IDOK)
	{
		// Add new search to the end or if selected, just before
		ADLSearchManager::SearchCollection& collection = ADLSearchManager::getInstance()->collection;
		

		int i = ctrlList.GetNextItem(-1, LVNI_SELECTED);
		if(i < 0)
		{
			// Add to end
			collection.push_back(search);
			i = collection.size() - 1;
		}
		else
		{
			// Add before selection
			collection.insert(collection.begin() + i, search);
		}

		// Update list control
		int j = i;
		while(j < (int)collection.size())
		{
			UpdateSearch(j++);
		}
		ctrlList.EnsureVisible(i, FALSE);
	}

	return 0;
}
Ejemplo n.º 3
0
  bool Estimate(double *V_westb, double *theta_westb, double *error) {
    int i;

    bool scanned[NUM_V_POINTS];
    for (i=0; i<NUM_V_POINTS; i++) {
      scanned[i]=false;
    }

    // scan for 6 points around current best estimate.
    // if a better estimate is found, keep scanning around
    // that point, and don't repeat scans

    bool improved = false;
    bool continue_search = true;
    bool full_search = false;
    while (continue_search) {
      continue_search = false;
      int ib = VtoI(V_west_best);
      int il, ih;
      if (full_search) {
        il = 0;
        ih = NUM_V_POINTS-1;
      } else {
        il = min(NUM_V_POINTS-1,max(0,ib-3));
        ih = min(NUM_V_POINTS-1,max(0,ib+3));
      } 
      for (i=il; i<=ih && i<NUM_V_POINTS; i++) {
	if (scanned[i]) {
          continue; 
        } else {
          scanned[i]= true;
          // see if we can find a better estimate
          double V_west = ItoV(i);
          if (UpdateSearch(V_west)) {
            improved = true;
            continue_search = true; // earnt more search
          }
        }
      }
      
      if (!continue_search && !full_search && (error_best>100)) {
        full_search = true;
        continue_search = true;
        // if no improvement and still large error,
        // try searching all speeds that haven't been checked yet.
      }
    }

    // return true if estimate was improved
    *V_westb = V_west_best;
    *theta_westb = theta_west_best;
    while (*theta_westb<0) {
      *theta_westb += 2.0*M_PI;
    }
    *error = error_best/10.0;
    return improved;
  };
Ejemplo n.º 4
0
 double StartSearch(double V_start, double theta_start) {
   V_west_best = V_start;
   theta_west_best = theta_start;
   error_best = 10000;    
   UpdateSearch(V_start);
   V_west_best = V_start;
   theta_west_best = theta_start;
   return error_best/10.0;
 }
Ejemplo n.º 5
0
// Load all searches from manager
void ADLSearchFrame::LoadAll()
{
	// Clear current contents
	ctrlList.DeleteAllItems();

	// Load all searches
	ADLSearchManager::SearchCollection& collection = ADLSearchManager::getInstance()->collection;
	for(unsigned long l = 0; l < collection.size(); l++) {
		UpdateSearch(l, FALSE);
	}
}
Ejemplo n.º 6
0
void CKadSearchListCtrl::SearchRef(const Kademlia::CSearch *search)
{
	try
	{
		ASSERT( search != NULL );
		LVFINDINFO find;
		find.flags = LVFI_PARAM;
		find.lParam = (LPARAM)search;
		int iItem = FindItem(&find);
		if (iItem != -1)
			UpdateSearch(iItem, search);
	}
	catch(...){ASSERT(0);}
}
Ejemplo n.º 7
0
void CKadSearchListCtrl::SearchAdd(const Kademlia::CSearch* search)
{
	try
	{
		ASSERT( search != NULL );
		int iItem = InsertItem(LVIF_TEXT|LVIF_PARAM,GetItemCount(),NULL,0,0,0,(LPARAM)search);
		if (iItem >= 0)
		{
			UpdateSearch(iItem, search);
			UpdateKadSearchCount();
		}
	}
	catch(...){ASSERT(0);}
}
Ejemplo n.º 8
0
// Add new search
LRESULT ADLSearchFrame::onAdd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
    // Invoke edit dialog with fresh search
    if (ADLSearchManager::getInstance()->getRunning() > 0) {
        LogManager::getInstance()->message(CSTRING(ADLSEARCH_IN_PROGRESS), LogManager::LOG_ERROR);
        return 0;
    }

    ADLSearch* search = new ADLSearch();
    ADLSProperties dlg(search);
    if(dlg.DoModal((HWND)*this) == IDOK)
    {
        // Add new search to the end or if selected, just before
        ADLSearchManager::SearchCollection& collection = ADLSearchManager::getInstance()->collection;


        int i = ctrlList.GetNextItem(-1, LVNI_SELECTED);
        if(i < 0)
        {
            // Add to end
            if (!ADLSearchManager::getInstance()->addCollection(search, true, true)) {
                return 0;
            }
            i = collection.size() - 1;
        }
        else
        {
            // Add before selection
            if (!ADLSearchManager::getInstance()->addCollection(search, true, true, true, i)) {
                return 0;
            }
        }

        // Update list control
        int j = i;
        while(j < (int)collection.size())
        {
            UpdateSearch(j++);
        }
        ctrlList.EnsureVisible(i, FALSE);
    }

    return 0;
}
Ejemplo n.º 9
0
void CKadSearchListCtrl::SearchAdd(const Kademlia::CSearch *search)
{
	// ==> Run eMule as NT Service [leuk_he/Stulle] - Stulle
	if (theApp.IsRunningAsService(SVC_LIST_OPT))
		return;
	// <== Run eMule as NT Service [leuk_he/Stulle] - Stulle

	try
	{
		ASSERT( search != NULL );
		int iItem = InsertItem(LVIF_TEXT | LVIF_PARAM, GetItemCount(), NULL, 0, 0, 0, (LPARAM)search);
		if (iItem >= 0)
		{
			UpdateSearch(iItem, search);
			UpdateKadSearchCount();
		}
	}
	catch(...){ASSERT(0);}
}
Ejemplo n.º 10
0
void AATDistance::AddPoint(double longitude, double latitude,
                           int taskwaypoint) {
  if (taskwaypoint<0) return;

  bool was_entered = has_entered[taskwaypoint];
  has_entered[taskwaypoint] = true;

  if (!AATEnabled || DoOptimizeRoute()) return; // nothing else to do for non-AAT tasks

  LockTaskData();

  // should only add ONE point to start.
  // If restart, need to reset

  if (num_points[taskwaypoint]<MAXNUM_AATDISTANCE) {

    int n = num_points[taskwaypoint];

    bool new_point= false;

    if (n>1) {
      double dist;
      DistanceBearing(lat_points[taskwaypoint][n-2],
                      lon_points[taskwaypoint][n-2],
                      latitude,
                      longitude, &dist, NULL);
      if (dist>distancethreshold[taskwaypoint]) {
        new_point = true;
      }
    } else {
      // first point in sector
      new_point = true;

      if ((!was_entered) && (taskwaypoint>0) &&
          !Task[taskwaypoint].AATTargetLocked) {
        double qdist, bearing0, bearing1;
        DistanceBearing(Task[taskwaypoint-1].AATTargetLat,
                        Task[taskwaypoint-1].AATTargetLon,
                        latitude,
                        longitude,
                        &qdist, &bearing0);
        DistanceBearing(Task[taskwaypoint-1].AATTargetLat,
                        Task[taskwaypoint-1].AATTargetLon,
                        Task[taskwaypoint].AATTargetLat,
                        Task[taskwaypoint].AATTargetLon,
                        &qdist, &bearing1);
        // JMWAAT
        Task[taskwaypoint].AATTargetOffsetRadial = 0.0;
        // 20080615 JMW
	// was AngleLimit180(bearing1-bearing0);
	// now project along track line
	// target will be moved by ShiftTargetFromBehind
      }

    }
    if (taskwaypoint==0) {
      // force updating of start point
      new_point = true;
    }

    if (new_point) {
      if (taskwaypoint>0) {
        num_points[taskwaypoint]++;
        if (num_points[taskwaypoint]==MAXNUM_AATDISTANCE) {
          ThinData(taskwaypoint);
        }
      } else {
        // just replace current start
        num_points[taskwaypoint]= 1;
      }
    }

    // always replace last point
    lat_points[taskwaypoint][max(0,num_points[taskwaypoint]-1)]= latitude;
    lon_points[taskwaypoint][max(0,num_points[taskwaypoint]-1)]= longitude;

    // update max search for this and future waypoints
    if (taskwaypoint>0) {
      for (int i= taskwaypoint; i<MAXTASKPOINTS-1; i++) {
        UpdateSearch(i);
      }
      if (taskwaypoint == ActiveTaskPoint) {
        DistanceCovered_internal(longitude, latitude, true);
      }
    }
  }
  UnlockTaskData();

}