diff --git a/CMakeLists.txt b/CMakeLists.txt index fde8ae8f..05d63709 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,8 @@ SET(SRC_ShipDriver src/AisMaker.h src/AisMaker.cpp src/GribRecord.cpp + src/GribRecordSet.h + src/GribRecord.h src/tinyxml.h src/tinyxml.cpp src/tinyxmlerror.cpp @@ -57,7 +59,11 @@ IF(WIN32) SET(SRC_JSON src/wxJSON/jsonval.cpp src/wxJSON/jsonreader.cpp - src/wxJSON/jsonwriter.cpp) + src/wxJSON/jsonwriter.cpp + src/wx/json_defs.h + src/wx/jsonval.h + src/wx/jsonreader.h + src/wx/jsonwriter.h) ENDIF(WIN32) diff --git a/src/GribRecordSet.h b/src/GribRecordSet.h index 835a2f6c..9f5092eb 100644 --- a/src/GribRecordSet.h +++ b/src/GribRecordSet.h @@ -26,24 +26,57 @@ #include "GribRecord.h" - // These are indexes into the array -enum { Idx_WIND_VX, Idx_WIND_VX850, Idx_WIND_VX700, Idx_WIND_VX500, Idx_WIND_VX300, - Idx_WIND_VY, Idx_WIND_VY850, Idx_WIND_VY700, Idx_WIND_VY500, Idx_WIND_VY300, - Idx_WIND_GUST, Idx_PRESSURE, Idx_HTSIGW, Idx_WVDIR, Idx_WVPER, - Idx_SEACURRENT_VX, Idx_SEACURRENT_VY, Idx_PRECIP_TOT, Idx_CLOUD_TOT, - Idx_AIR_TEMP, Idx_AIR_TEMP850, Idx_AIR_TEMP700, Idx_AIR_TEMP500, Idx_AIR_TEMP300, - Idx_SEA_TEMP, Idx_CAPE, - Idx_HUMID_RE, Idx_HUMID_RE850, Idx_HUMID_RE700, Idx_HUMID_RE500, Idx_HUMID_RE300, - Idx_GEOP_HGT,Idx_GEOP_HGT850, Idx_GEOP_HGT700, Idx_GEOP_HGT500, Idx_GEOP_HGT300, - Idx_COUNT }; + // These are indexes into the array +enum { + Idx_WIND_VX, Idx_WIND_VX850, Idx_WIND_VX700, Idx_WIND_VX500, Idx_WIND_VX300, + Idx_WIND_VY, Idx_WIND_VY850, Idx_WIND_VY700, Idx_WIND_VY500, Idx_WIND_VY300, + Idx_WIND_GUST, Idx_PRESSURE, Idx_HTSIGW, Idx_WVDIR, Idx_WVPER, + Idx_SEACURRENT_VX, Idx_SEACURRENT_VY, Idx_PRECIP_TOT, Idx_CLOUD_TOT, + Idx_AIR_TEMP, Idx_AIR_TEMP850, Idx_AIR_TEMP700, Idx_AIR_TEMP500, Idx_AIR_TEMP300, + Idx_SEA_TEMP, Idx_CAPE, + Idx_HUMID_RE, Idx_HUMID_RE850, Idx_HUMID_RE700, Idx_HUMID_RE500, Idx_HUMID_RE300, + Idx_GEOP_HGT, Idx_GEOP_HGT850, Idx_GEOP_HGT700, Idx_GEOP_HGT500, Idx_GEOP_HGT300, + Idx_COUNT +}; class GribRecordSet { public: - GribRecordSet() { - for(int i=0; i= 0 && i < Idx_COUNT); + if (m_GribRecordUnref[i] == true) { + delete m_GribRecordPtrArray[i]; + } + m_GribRecordPtrArray[i] = pGR; + m_GribRecordUnref[i] = true; + } + + void RemoveGribRecords() { + for (int i = 0; i < Idx_COUNT; i++) { + if (m_GribRecordUnref[i] == true) { + delete m_GribRecordPtrArray[i]; + } + } + } + + time_t m_Reference_Time; + unsigned int m_ID; - time_t m_Reference_Time; - GribRecord *m_GribRecordPtrArray[Idx_COUNT]; + GribRecord *m_GribRecordPtrArray[Idx_COUNT]; +private: + // grib records files are stored and owned by reader mapGribRecords + // interpolated grib are not, keep track of them + bool m_GribRecordUnref[Idx_COUNT]; }; diff --git a/src/ShipDriver_pi.cpp b/src/ShipDriver_pi.cpp index d9643a06..b5e76ffe 100644 --- a/src/ShipDriver_pi.cpp +++ b/src/ShipDriver_pi.cpp @@ -147,7 +147,7 @@ int ShipDriver_pi::Init(void) WANTS_NMEA_SENTENCES| WANTS_AIS_SENTENCES| WANTS_PREFERENCES| - WANTS_PLUGIN_MESSAGING | + WANTS_PLUGIN_MESSAGING| WANTS_CONFIG ); } @@ -452,6 +452,7 @@ void ShipDriver_pi::SetPluginMessage(wxString &message_id, wxString &message_bod } wxString sptr = v[_T("TimelineSetPtr")].AsString(); + wxCharBuffer bptr = sptr.To8BitData(); const char* ptr = bptr.data(); @@ -482,6 +483,13 @@ bool ShipDriver_pi::GribWind(GribRecordSet *grib, double lat, double lon, return false; VWG *= 3.6 / 1.852; // knots + +#if 0 +// test + VWG = 0.; + WG = 0.; +#endif + return true; } diff --git a/src/ShipDriver_pi.h b/src/ShipDriver_pi.h index 090daab8..165fcf08 100644 --- a/src/ShipDriver_pi.h +++ b/src/ShipDriver_pi.h @@ -51,8 +51,8 @@ #define GRIB_MIN_MINOR 1 -#define PLUGIN_VERSION_MAJOR 0 -#define PLUGIN_VERSION_MINOR 6 +#define PLUGIN_VERSION_MAJOR 2 +#define PLUGIN_VERSION_MINOR 0 #define MY_API_VERSION_MAJOR 1 #define MY_API_VERSION_MINOR 6