Skip to content

Commit

Permalink
Revert to v0.5 to retain nohal edits.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rasbats committed Jan 2, 2019
1 parent b25ab09 commit 6649f9b
Show file tree
Hide file tree
Showing 9 changed files with 2,590 additions and 2,209 deletions.
18 changes: 3 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ SET(VERBOSE_NAME ShipDriver)
SET(TITLE_NAME ShipDriver)
SET(CPACK_PACKAGE_CONTACT "Mike Rossiter")

SET(VERSION_MAJOR "2")
SET(VERSION_MINOR "0")
SET(VERSION_MAJOR "0")
SET(VERSION_MINOR "5")

#SET(CMAKE_BUILD_TYPE Debug)

Expand Down Expand Up @@ -43,26 +43,14 @@ SET(SRC_ShipDriver
src/ShipDrivergui_impl.cpp
src/ShipDrivergui_impl.h
src/ocpn_plugin.h
src/folder.xpm
src/AisMaker.h
src/AisMaker.cpp
src/GribRecord.cpp
src/tinystr.h
src/tinyxml.h
src/tinyxml.cpp
src/tinyxmlerror.cpp
src/tinyxmlparser.cpp

src/wxJSON/jsonval.cpp
src/wxJSON/jsonreader.cpp
src/wxJSON/jsonwriter.cpp

)


ADD_LIBRARY(${PACKAGE_NAME} SHARED ${SRC_ShipDriver})

ADD_DEFINITIONS(-DTIXML_USE_STL)

INCLUDE("cmake/PluginInstall.cmake")
INCLUDE("cmake/PluginLocalization.cmake")
INCLUDE("cmake/PluginPackage.cmake")
2,882 changes: 1,441 additions & 1,441 deletions ShipDriver_pi.fbp

Large diffs are not rendered by default.

121 changes: 2 additions & 119 deletions src/ShipDriver_pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "ShipDrivergui_impl.h"
#include "ShipDrivergui.h"
#include "ocpn_plugin.h"
#include "folder.xpm"

class ShipDriver_pi;
class Dlg;
Expand Down Expand Up @@ -87,7 +88,7 @@ ShipDriver_pi::~ShipDriver_pi(void)

if (pConf) {

pConf->SetPath(_T("/Settings/ShipDriver_pi"));
pConf->SetPath(_T("/Settings/otidalroute"));

pConf->Write(_T("shipdriverUseAis"), m_bCopyUseAis);
pConf->Write(_T("shipdriverUseFile"), m_bCopyUseFile);
Expand Down Expand Up @@ -146,7 +147,6 @@ int ShipDriver_pi::Init(void)
WANTS_NMEA_SENTENCES|
WANTS_AIS_SENTENCES|
WANTS_PREFERENCES|
WANTS_PLUGIN_MESSAGING |
WANTS_CONFIG
);
}
Expand Down Expand Up @@ -265,7 +265,6 @@ void ShipDriver_pi::ShowPreferencesDialog(wxWindow* parent)

SaveConfig();


RequestRefresh(m_parent_window); // refresh main window
}

Expand Down Expand Up @@ -403,122 +402,6 @@ void ShipDriver_pi::SetCursorLatLon(double lat, double lon)
m_cursor_lon = lon;
}

void ShipDriver_pi::SetPluginMessage(wxString &message_id, wxString &message_body)
{
if (message_id == _T("GRIB_TIMELINE"))
{
wxJSONReader r;
wxJSONValue v;
r.Parse(message_body, &v);

wxDateTime time;
time.Set
(v[_T("Day")].AsInt(), (wxDateTime::Month)v[_T("Month")].AsInt(), v[_T("Year")].AsInt(),
v[_T("Hour")].AsInt(), v[_T("Minute")].AsInt(), v[_T("Second")].AsInt());

wxString dt;
dt = time.Format(_T("%Y-%m-%d %H:%M "));

if (m_pDialog){
m_pDialog->m_GribTimelineTime = time.ToUTC();
//m_pDialog->m_textCtrl1->SetValue(dt);
}
}
if (message_id == _T("GRIB_TIMELINE_RECORD"))
{
wxJSONReader r;
wxJSONValue v;
r.Parse(message_body, &v);

static bool shown_warnings;
if (!shown_warnings) {
shown_warnings = true;

int grib_version_major = v[_T("GribVersionMajor")].AsInt();
int grib_version_minor = v[_T("GribVersionMinor")].AsInt();

int grib_version = 1000 * grib_version_major + grib_version_minor;
int grib_min = 1000 * GRIB_MIN_MAJOR + GRIB_MIN_MINOR;
int grib_max = 1000 * GRIB_MAX_MAJOR + GRIB_MAX_MINOR;

if (grib_version < grib_min || grib_version > grib_max) {
wxMessageDialog mdlg(m_parent_window,
_("Grib plugin version not supported.")
+ _T("\n\n") +
wxString::Format(_("Use versions %d.%d to %d.%d"), GRIB_MIN_MAJOR, GRIB_MIN_MINOR, GRIB_MAX_MAJOR, GRIB_MAX_MINOR),
_("Weather Routing"), wxOK | wxICON_WARNING);
mdlg.ShowModal();
}
}

wxString sptr = v[_T("TimelineSetPtr")].AsString();
wxCharBuffer bptr = sptr.To8BitData();
const char* ptr = bptr.data();

GribRecordSet *gptr;
sscanf(ptr, "%p", &gptr);

double dir, spd;

m_bGribValid = GribCurrent(gptr, m_grib_lat, m_grib_lon, dir, spd);

m_tr_spd = spd;
m_tr_dir = dir;

//wxMessageBox(wxString::Format(_T("%5.2f"), spd));
}
}

bool ShipDriver_pi::GribWind(GribRecordSet *grib, double lat, double lon,
double &WG, double &VWG)
{
if (!grib)
return false;

if (!GribRecord::getInterpolatedValues(VWG, WG,
grib->m_GribRecordPtrArray[Idx_WIND_VX],
grib->m_GribRecordPtrArray[Idx_WIND_VY], lon, lat))
return false;

VWG *= 3.6 / 1.852; // knots
return true;
}

wxString ShipDriver_pi::StandardPath()
{
wxStandardPathsBase& std_path = wxStandardPathsBase::Get();
wxString s = wxFileName::GetPathSeparator();

#if defined(__WXMSW__)
wxString stdPath = std_path.GetConfigDir();
#elif defined(__WXGTK__) || defined(__WXQT__)
wxString stdPath = std_path.GetUserDataDir();
#elif defined(__WXOSX__)
wxString stdPath = (std_path.GetUserConfigDir() + s + _T("opencpn"));
#endif

stdPath += s + _T("plugins");
if (!wxDirExists(stdPath))
wxMkdir(stdPath);

stdPath += s + _T("ShipDriver");

#ifdef __WXOSX__
// Compatibility with pre-OCPN-4.2; move config dir to
// ~/Library/Preferences/opencpn if it exists
wxString oldPath = (std_path.GetUserConfigDir() + s + _T("plugins") + s + _T("ShipDriver"));
if (wxDirExists(oldPath) && !wxDirExists(stdPath)) {
wxLogMessage("ShipDriver_pi: moving config dir %s to %s", oldPath, stdPath);
wxRenameFile(oldPath, stdPath);
}
#endif

if (!wxDirExists(stdPath))
wxMkdir(stdPath);

stdPath += s; // is this necessary?
return stdPath;
}



Expand Down
46 changes: 2 additions & 44 deletions src/ShipDriver_pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,48 +39,15 @@

#include "ocpn_plugin.h" //Required for OCPN plugin functions
#include "ShipDrivergui_impl.h"
#include "wx/jsonreader.h"
#include "wx/jsonwriter.h"
#include <wx/datetime.h>
#include "GribRecordSet.h"

// Define minimum and maximum versions of the grib plugin supported
#define GRIB_MAX_MAJOR 4
#define GRIB_MAX_MINOR 1
#define GRIB_MIN_MAJOR 4
#define GRIB_MIN_MINOR 1



#define PLUGIN_VERSION_MAJOR 2
#define PLUGIN_VERSION_MINOR 0
#define PLUGIN_VERSION_MAJOR 0
#define PLUGIN_VERSION_MINOR 5

#define MY_API_VERSION_MAJOR 1
#define MY_API_VERSION_MINOR 6

class Dlg;

static inline bool GribCurrent(GribRecordSet *grib, double lat, double lon,
double &C, double &VC)
{
if (!grib)
return false;

if (!GribRecord::getInterpolatedValues(VC, C,
grib->m_GribRecordPtrArray[Idx_WIND_VX],
grib->m_GribRecordPtrArray[Idx_WIND_VY],
lon, lat))
return false;

VC *= 3.6 / 1.852; // knots

//C += 180;
if (C > 360)
C -= 360;
return true;
}


//----------------------------------------------------------------------------------------------------------
// The PlugIn Class Definition
//----------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -135,15 +102,6 @@ class ShipDriver_pi : public opencpn_plugin_16
double GetCursorLon(void) { return m_cursor_lon; }

void ShowPreferencesDialog(wxWindow* parent);
void SetPluginMessage(wxString &message_id, wxString &message_body);
bool GribWind(GribRecordSet *grib, double lat, double lon, double &WG, double &VWG);

bool m_bGribValid;
double m_grib_lat, m_grib_lon;
double m_tr_spd;
double m_tr_dir;

wxString StandardPath();

private:

Expand Down
15 changes: 4 additions & 11 deletions src/ShipDrivergui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ ShipDriverBase::ShipDriverBase( wxWindow* parent, wxWindowID id, const wxString&
m_textCtrlRudderStbd = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE|wxTE_READONLY );
m_textCtrlRudderStbd->SetFont( wxFont( 10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxT("Arial") ) );

bSizer131->Add( m_textCtrlRudderStbd, 0, wxALIGN_CENTER_VERTICAL, 0 );
bSizer131->Add( m_textCtrlRudderStbd, 0, wxALIGN_BOTTOM|wxALIGN_CENTER_VERTICAL, 0 );


bSizer131->Add( 0, 0, 1, wxEXPAND, 5 );
Expand Down Expand Up @@ -217,13 +217,10 @@ ShipDriverBase::ShipDriverBase( wxWindow* parent, wxWindowID id, const wxString&

fgSizer82->Add( m_button7, 1, wxALL|wxEXPAND, 2 );

m_buttonWind = new wxButton( this, wxID_ANY, _("Sail"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonWind->SetFont( wxFont( 12, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxT("Arial") ) );
m_buttonWind->SetBackgroundColour( wxColour( 0, 255, 0 ) );
m_buttonWind->SetToolTip( _("Using Sails") );
m_buttonWind->SetMinSize( wxSize( 50,-1 ) );
m_button8 = new wxButton( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_button8->SetMinSize( wxSize( 50,-1 ) );

fgSizer82->Add( m_buttonWind, 1, wxALL|wxEXPAND, 2 );
fgSizer82->Add( m_button8, 1, wxALL|wxEXPAND, 2 );

m_buttonMinus1 = new wxButton( this, wxID_ANY, _("-1"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonMinus1->SetFont( wxFont( 12, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxT("Arial") ) );
Expand Down Expand Up @@ -255,7 +252,6 @@ ShipDriverBase::ShipDriverBase( wxWindow* parent, wxWindowID id, const wxString&

this->SetSizer( bSizer10 );
this->Layout();
bSizer10->Fit( this );
m_timer1.SetOwner( this, wxID_ANY );

this->Centre( wxBOTH );
Expand All @@ -267,7 +263,6 @@ ShipDriverBase::ShipDriverBase( wxWindow* parent, wxWindowID id, const wxString&
m_bpStop->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ShipDriverBase::OnStop ), NULL, this );
m_buttonStandby->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ShipDriverBase::OnStandby ), NULL, this );
m_buttonAuto->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ShipDriverBase::OnAuto ), NULL, this );
m_buttonWind->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ShipDriverBase::OnWind ), NULL, this );
m_buttonMinus1->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ShipDriverBase::OnMinus1 ), NULL, this );
m_buttonMinus10->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ShipDriverBase::OnMinus10 ), NULL, this );
m_buttonPlus10->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ShipDriverBase::OnPlus10 ), NULL, this );
Expand All @@ -284,7 +279,6 @@ ShipDriverBase::~ShipDriverBase()
m_bpStop->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ShipDriverBase::OnStop ), NULL, this );
m_buttonStandby->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ShipDriverBase::OnStandby ), NULL, this );
m_buttonAuto->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ShipDriverBase::OnAuto ), NULL, this );
m_buttonWind->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ShipDriverBase::OnWind ), NULL, this );
m_buttonMinus1->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ShipDriverBase::OnMinus1 ), NULL, this );
m_buttonMinus10->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ShipDriverBase::OnMinus10 ), NULL, this );
m_buttonPlus10->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ShipDriverBase::OnPlus10 ), NULL, this );
Expand Down Expand Up @@ -335,7 +329,6 @@ shipdriverPreferences::shipdriverPreferences( wxWindow* parent, wxWindowID id, c

this->SetSizer( sbSizer1 );
this->Layout();
sbSizer1->Fit( this );

this->Centre( wxBOTH );
}
Expand Down
7 changes: 3 additions & 4 deletions src/ShipDrivergui.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ShipDriverBase : public wxDialog
wxButton* m_buttonStandby;
wxButton* m_buttonAuto;
wxButton* m_button7;
wxButton* m_buttonWind;
wxButton* m_button8;
wxButton* m_buttonMinus1;
wxButton* m_buttonMinus10;
wxButton* m_buttonPlus10;
Expand All @@ -64,7 +64,6 @@ class ShipDriverBase : public wxDialog
virtual void OnStop( wxCommandEvent& event ) { event.Skip(); }
virtual void OnStandby( wxCommandEvent& event ) { event.Skip(); }
virtual void OnAuto( wxCommandEvent& event ) { event.Skip(); }
virtual void OnWind( wxCommandEvent& event ) { event.Skip(); }
virtual void OnMinus1( wxCommandEvent& event ) { event.Skip(); }
virtual void OnMinus10( wxCommandEvent& event ) { event.Skip(); }
virtual void OnPlus10( wxCommandEvent& event ) { event.Skip(); }
Expand All @@ -81,7 +80,7 @@ class ShipDriverBase : public wxDialog
wxSlider* m_SliderSpeed;
wxTimer m_timer1;

ShipDriverBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
ShipDriverBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 300,300 ), long style = wxDEFAULT_DIALOG_STYLE );
~ShipDriverBase();

};
Expand All @@ -103,7 +102,7 @@ class shipdriverPreferences : public wxDialog
wxCheckBox* m_cbAisToFile;
wxTextCtrl* m_textCtrlMMSI;

shipdriverPreferences( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Preferences"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxCAPTION|wxRESIZE_BORDER );
shipdriverPreferences( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Preferences"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 222,214 ), long style = wxCAPTION );
~shipdriverPreferences();

};
Expand Down
Loading

0 comments on commit 6649f9b

Please sign in to comment.