Ejemplo n.º 1
0
void RoutePoint::ShowScaleWarningMessage(ChartCanvas *canvas)
{
    wxString strA = _("The ScaMin value for new waypoints is set to");
    wxString strB = _("but current chartscale is");
    wxString strC = _("Therefore the new waypoint will not be visible at this zoom level.");
    wxString MessStr = wxString::Format(_T("%s %i,\n %s %i.\n%s"),strA, (int)GetScaMin(), strB, canvas->GetScaleValue(), strC);
    OCPNMessageBox( canvas, MessStr);
}
Ejemplo n.º 2
0
void AISTargetQueryDialog::OnIdTrkCreateClick( wxCommandEvent& event )
{
    if( m_MMSI != 0 ) { //  Faulty MMSI could be reported as 0
        AIS_Target_Data *td = g_pAIS->Get_Target_Data_From_MMSI( m_MMSI );
        if( td )
        {
            if ( td->b_PersistTrack ) //The target was tracked and the user wants to stop it
            {
                td->b_PersistTrack = false;
                g_pAIS->m_persistent_tracks.erase(td->MMSI);
                m_createTrkBtn->SetLabel(_("Record Track"));
            }
            else
            {
                RoutePoint *rp = NULL;
                RoutePoint *rp1 = NULL;
                    
                Track *t = new Track();

                t->m_RouteNameString = wxString::Format( _T("AIS %s (%u) %s %s"), td->GetFullName().c_str(), td->MMSI, wxDateTime::Now().FormatISODate().c_str(), wxDateTime::Now().FormatISOTime().c_str() );
                wxAISTargetTrackListNode *node = td->m_ptrack->GetFirst();
                while( node )
                {
                    AISTargetTrackPoint *ptrack_point = node->GetData();
                    vector2D point( ptrack_point->m_lon, ptrack_point->m_lat );
                    rp1 = t->AddNewPoint( point, wxDateTime(ptrack_point->m_time).ToUTC() );
                    if( rp )
                    {
                        pSelect->AddSelectableTrackSegment( rp->m_lat, rp->m_lon, rp1->m_lat,
                            rp1->m_lon, rp, rp1, t );
                    }
                    rp = rp1;
                    node = node->GetNext();
                }
                
                pRouteList->Append( t );
                pConfig->AddNewRoute( t, -1 );
                t->RebuildGUIDList(); // ensure the GUID list is intact and good

                if( pRouteManagerDialog && pRouteManagerDialog->IsShown() )
                    pRouteManagerDialog->UpdateTrkListCtrl();
                Refresh( false );
         
                if( wxID_YES == OCPNMessageBox(NULL,
                    _("The recently captured track of this target has been recorded.\nDo you want to continue recording until the end of the current OpenCPN session?"),
                    _("OpenCPN Info"), wxYES_NO | wxCENTER, 60 ) )
                {
                    td->b_PersistTrack = true;
                    g_pAIS->m_persistent_tracks[td->MMSI] = t;
                }
            }
        }
    }
}
Ejemplo n.º 3
0
bool RoutePoint::SendToGPS(const wxString & com_name, wxGauge *pProgress)
{
    bool result = false;
    if( g_pMUX ) result = g_pMUX->SendWaypointToGPS( this, com_name, pProgress );

    wxString msg;
    if( result ) msg = _("Waypoint(s) Uploaded successfully.");
    else
        msg = _("Error on Waypoint Upload.  Please check logfiles...");

    OCPNMessageBox( NULL, msg, _("OpenCPN Info"), wxOK | wxICON_INFORMATION );

    return result;
}
Ejemplo n.º 4
0
bool Route::SendToGPS(const wxString & com_name, bool bsend_waypoints, wxGauge *pProgress )
{
    bool result = false;

    if( g_pMUX ) {
        ::wxBeginBusyCursor();
         result = g_pMUX->SendRouteToGPS( this, com_name, bsend_waypoints, pProgress );
        ::wxEndBusyCursor();
    }

    wxString msg;
    if( result ) msg = _("Route Uploaded successfully.");
    else
        msg = _("Error on Route Upload.  Please check logfiles...");

    OCPNMessageBox( NULL, msg, _("OpenCPN Info"), wxOK | wxICON_INFORMATION );

    return result;
}
Ejemplo n.º 5
0
bool RoutePoint::SendToGPS(const wxString & com_name, wxGauge *pProgress)
{
    int result = 0;
    if( g_pMUX )
        result = g_pMUX->SendWaypointToGPS( this, com_name, pProgress );

    wxString msg;
    if( 0 == result )
        msg = _("Waypoint(s) Transmitted.");
    else{
        if( result == ERR_GARMIN_INITIALIZE )
            msg = _("Error on Waypoint Upload.  Garmin GPS not connected");
        else               
            msg = _("Error on Waypoint Upload.  Please check logfiles...");
    }

    OCPNMessageBox( NULL, msg, _("OpenCPN Info"), wxOK | wxICON_INFORMATION );

    return (result == 0);
}
Ejemplo n.º 6
0
int Route::SendToGPS(const wxString & com_name, bool bsend_waypoints, wxGauge *pProgress )
{
    int result = 0;

    if( g_pMUX ) {
        ::wxBeginBusyCursor();
        result = g_pMUX->SendRouteToGPS( this, com_name, bsend_waypoints, pProgress );
        ::wxEndBusyCursor();
    }

    wxString msg;
    if( 0 == result )
        msg = _("Route Transmitted.");
    else {
        if( result == ERR_GARMIN_INITIALIZE )
            msg = _("Error on Route Upload.  Garmin GPS not connected");
        else
            msg = _("Error on Route Upload.  Please check logfiles...");

        OCPNMessageBox( NULL, msg, _("OpenCPN Info"), wxOK | wxICON_INFORMATION );
    }

    return (result == 0);
}
Ejemplo n.º 7
0
int Garmin_GPS_SendRoute( wxString &port_name, Route *pr, wxGauge *pProgress)
{
      int ret_val = 0;

      int route_number = 1;

      //    If the device supports unique numbered waypoints,
      //    Then we must query the device to find an empty number
      if((gps_rte_hdr_type == pD200) || (gps_rte_hdr_type == pD201))
      {
      //    Retrieve <ALL> routes from the device
            GPS_PWay *pprouteway;
            int32 npacks = GPS_A200_Get(port_name.mb_str(), &pprouteway);
            if(npacks < 0)
                  return npacks;

            if ( pProgress )
            {
                  pProgress->SetValue ( 60 );
                  pProgress->Refresh();
                  pProgress->Update();
            }

            //  Iterate on the packets, finding the first route number from [0..9] that is not present

            //    An array of route numbers, set element to true as encountered
            bool brn[10];
            for(int i=0 ; i < 10 ; i++)
               brn[i] = false;

            for(int ip=0 ; ip < npacks ; ip++)
            {
                  GPS_PWay pway = pprouteway[ip];
                  if(pway->isrte)
                  {
                        if((pway->rte_num < 10))
                              brn[pway->rte_num] = true;
                  }
            }

            //    Find the first candidate within [1..9] that is unused
            bool bfound_empty = false;
            for(int i=1 ; i < 10 ; i++)
            {
                  if(brn[i] == false)
                  {
                        route_number = i;
                        bfound_empty = true;
                        break;
                  }
            }

            //  Ask the user if it is all right to overwrite
            if(!bfound_empty)
            {
                  int rv = OCPNMessageBox(NULL, _("Overwrite Garmin device route number 1?"),
                                          _("OpenCPN Message"), wxOK | wxCANCEL | wxICON_QUESTION);
                  if(rv != wxOK)
                        return 0;
            }

      }


      // Based on the route transfer protocol create the array of transfer packets
      GPS_SWay **ppway;
      int elements = 0;
      if (gps_route_transfer == pA201)
	ppway = Garmin_GPS_Create_A201_Route(pr, route_number, &elements);
      else
	ppway = Garmin_GPS_Create_A200_Route(pr, route_number, &elements);


      //    Transmit the Route to the GPS receiver
      int xfer_result = GPS_Command_Send_Route(port_name.mb_str(), ppway, elements);
      ret_val = xfer_result;

      //  Free all the memory
      for(int i=0 ; i < elements ; i++)
            GPS_Way_Del(&ppway[i]);

      free(ppway);


      if ( pProgress )
      {
            pProgress->SetValue ( 80 );
            pProgress->Refresh();
            pProgress->Update();
      }

      VerifyPortClosed();
      return ret_val;
}