Skip to content

Commit

Permalink
Add Follower/Buddy to MMSIEditDialog in MMSI properties.\n Hinder CPA…
Browse files Browse the repository at this point in the history
… alert when selected
  • Loading branch information
Hakansv committed Oct 28, 2015
1 parent cbb14bd commit 8169db0
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 23 deletions.
3 changes: 2 additions & 1 deletion include/AIS_Decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class MMSIProperties
int TrackType;
bool m_bignore;
bool m_bMOB;
bool m_bVDM;
bool m_bVDM;
bool m_bFollower; //Hås
bool m_bPersistentTrack;
};

Expand Down
13 changes: 7 additions & 6 deletions include/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -758,11 +758,12 @@ class OpenGLOptionsDlg : private Uncopyable, public wxDialog {
#define ID_MMSI_PROPS_LIST 10073

enum {
mlMMSI = 0,
mlTrackMode,
mlIgnore,
mlMOB,
mlVDM
mlMMSI = 0,
mlTrackMode,
mlIgnore,
mlMOB,
mlVDM,
mlFollower //Hås
}; // MMSIListCtrl Columns;

class MMSIListCtrl : private Uncopyable, public wxListCtrl {
Expand Down Expand Up @@ -808,7 +809,7 @@ class MMSIEditDialog : private Uncopyable, public wxDialog {
wxTextCtrl *m_MMSICtl;
wxRadioButton *m_rbTypeTrackDefault, *m_rbTypeTrackAlways;
wxRadioButton *m_rbTypeTrackNever;
wxCheckBox *m_cbTrackPersist, *m_IgnoreButton, *m_MOBButton, *m_VDMButton;
wxCheckBox *m_cbTrackPersist, *m_IgnoreButton, *m_MOBButton, *m_VDMButton, *m_FollowerButton;
wxButton *m_CancelButton, *m_OKButton;

DECLARE_EVENT_TABLE()
Expand Down
43 changes: 34 additions & 9 deletions src/AIS_Decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1954,6 +1954,20 @@ void AIS_Decoder::UpdateAllAlarms( void )
continue;
}

// No alert for my Follower HåS
bool hit = false;
for(unsigned int i=0 ; i < g_MMSI_Props_Array.GetCount() ; i++){
MMSIProperties *props = g_MMSI_Props_Array.Item(i);
if(td->MMSI == props->MMSI){
if (props->m_bFollower) {
hit = true;
td->n_alert_state = AIS_NO_ALERT;
}
break;
}
}
if (hit) continue;

// Skip distant targets if requested
if( g_bCPAMax ) {
if( td->Range_NM > g_CPAMax_NM ) {
Expand Down Expand Up @@ -2433,8 +2447,8 @@ MMSIProperties::MMSIProperties( wxString &spec )
if(s.Len()){
if(s.Upper() == _T("IGNORE"))
m_bignore = true;
}
}

s = tkz.GetNextToken();
if(s.Len()){
if(s.Upper() == _T("MOB"))
Expand All @@ -2446,7 +2460,13 @@ MMSIProperties::MMSIProperties( wxString &spec )
if(s.Upper() == _T("VDM"))
m_bVDM = true;
}


s = tkz.GetNextToken();
if (s.Len()){
if (s.Upper() == _T("FOLLOWER"))
m_bFollower = true;
}

s = tkz.GetNextToken();
if(s.Len()){
if(s.Upper() == _T("PERSIST"))
Expand All @@ -2465,7 +2485,8 @@ void MMSIProperties::Init(void )
TrackType = TRACKTYPE_DEFAULT;
m_bignore = false;
m_bMOB = false;
m_bVDM = false;
m_bVDM = false;
m_bFollower = false;
m_bPersistentTrack = false;
}

Expand All @@ -2488,18 +2509,22 @@ wxString MMSIProperties::Serialize( void )
if(m_bignore){
sMMSI << _T("ignore");
}
sMMSI << _T(";");
sMMSI << _T(";");

if(m_bMOB){
sMMSI << _T("MOB");
}
sMMSI << _T(";");

if(m_bVDM){
sMMSI << _T("VDM");
}

sMMSI << _T(";");
}
sMMSI << _T(";");

if (m_bFollower){ //Hås
sMMSI << _T("Follower");
}
sMMSI << _T(";");

if(m_bPersistentTrack){
sMMSI << _T("PERSIST");
Expand Down
30 changes: 23 additions & 7 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,15 +450,17 @@ void MMSIEditDialog::CreateControls(void) {

m_IgnoreButton = new wxCheckBox(this, wxID_ANY, _("Ignore this MMSI"));
mmsiSizer->Add(m_IgnoreButton, 0, wxEXPAND, 5);

m_MOBButton = new wxCheckBox(this, wxID_ANY,
_("Handle this MMSI as SART/PLB(AIS) MOB."));
mmsiSizer->Add(m_MOBButton, 0, wxEXPAND, 5);

m_VDMButton =
new wxCheckBox(this, wxID_ANY, _("Convert AIVDM to AIVDO for this MMSI"));
m_VDMButton = new wxCheckBox(this, wxID_ANY, _("Convert AIVDM to AIVDO for this MMSI"));
mmsiSizer->Add(m_VDMButton, 0, wxEXPAND, 5);

m_FollowerButton = new wxCheckBox(this, wxID_ANY, _("This MMSI is my Follower - No CPA Alert")); //Hås
mmsiSizer->Add(m_FollowerButton, 0, wxEXPAND, 5);

wxBoxSizer* btnSizer = new wxBoxSizer(wxHORIZONTAL);
mainSizer->Add(btnSizer, 0, wxALIGN_RIGHT | wxALL, 5);

Expand Down Expand Up @@ -492,6 +494,7 @@ void MMSIEditDialog::CreateControls(void) {
m_IgnoreButton->SetValue(m_props->m_bignore);
m_MOBButton->SetValue(m_props->m_bMOB);
m_VDMButton->SetValue(m_props->m_bVDM);
m_FollowerButton->SetValue(m_props->m_bFollower); //Hås

SetColorScheme(GLOBAL_COLOR_SCHEME_RGB);
}
Expand All @@ -518,7 +521,8 @@ void MMSIEditDialog::OnMMSIEditOKClick(wxCommandEvent& event) {

m_props->m_bignore = m_IgnoreButton->GetValue();
m_props->m_bMOB = m_MOBButton->GetValue();
m_props->m_bVDM = m_VDMButton->GetValue();
m_props->m_bVDM = m_VDMButton->GetValue();
m_props->m_bFollower = m_FollowerButton->GetValue(); //Hås
m_props->m_bPersistentTrack = m_cbTrackPersist->GetValue();
}

Expand Down Expand Up @@ -572,13 +576,16 @@ wxString MMSIListCtrl::OnGetItemText(long item, long column) const {
break;
case mlIgnore:
if (props->m_bignore) ret = _T( "X" );
break;
break;
case mlMOB:
if (props->m_bMOB) ret = _T( "X" );
break;
case mlVDM:
if (props->m_bVDM) ret = _T( "X" );
break;
break;
case mlFollower: //Hås
if (props->m_bFollower) ret = _T("X");
break;
default:
ret = _T( "??" );
break;
Expand Down Expand Up @@ -662,7 +669,7 @@ MMSI_Props_Panel::MMSI_Props_Panel(wxWindow* parent)
wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL);
SetSizer(topSizer);

wxString MMSI_props_column_spec = _T( "120;120;100;100;100;100;100" );
wxString MMSI_props_column_spec = _T("120;120;100;100;100;100;100"); //Håa
// Parse the global column width string as read from config file
wxStringTokenizer tkz(MMSI_props_column_spec, _T(";"));
wxString s_width = tkz.GetNextToken();
Expand Down Expand Up @@ -725,6 +732,15 @@ MMSI_Props_Panel::MMSI_Props_Panel(wxWindow* parent)
width);
s_width = tkz.GetNextToken();

width = dx * 8;//Hås
if (s_width.ToLong(&lwidth)) {
width = wxMax(dx * 2, lwidth);
width = wxMin(width, dx * 30);
}
m_pListCtrlMMSI->InsertColumn(tlTYPE, _("Follower"), wxLIST_FORMAT_CENTER,
width);
s_width = tkz.GetNextToken();

topSizer->Add(m_pListCtrlMMSI, 1, wxEXPAND | wxALL, 0);

m_pButtonNew = new wxButton(this, wxID_ANY, _("New..."), wxDefaultPosition,
Expand Down

0 comments on commit 8169db0

Please sign in to comment.