diff --git a/GUIFrame.cpp b/GUIFrame.cpp index 16fd7026..76936a25 100644 --- a/GUIFrame.cpp +++ b/GUIFrame.cpp @@ -52,6 +52,12 @@ GUIFrame::GUIFrame( wxWindow* parent, wxWindowID id, const wxString& title, cons ViewMenuDaily = new wxMenuItem( ViewMenu, wxID_ANY, wxString( _("&Daily") ) + wxT('\t') + wxT("F6"), wxEmptyString, wxITEM_NORMAL ); ViewMenu->Append( ViewMenuDaily ); + wxMenuItem* m_separator3; + m_separator3 = ViewMenu->AppendSeparator(); + + ViewMenuSerial = new wxMenuItem( ViewMenu, wxID_ANY, wxString( _("Show Serial Numbers") ) , wxEmptyString, wxITEM_CHECK ); + ViewMenu->Append( ViewMenuSerial ); + wxMenuItem* m_separator2; m_separator2 = ViewMenu->AppendSeparator(); @@ -61,8 +67,8 @@ GUIFrame::GUIFrame( wxWindow* parent, wxWindowID id, const wxString& title, cons menubar->Append( ViewMenu, _("&View") ); - MachineMenu = new wxMenu(); - menubar->Append( MachineMenu, _("&Machine") ); + ProfileMenu = new wxMenu(); + menubar->Append( ProfileMenu, _("&Profiles") ); ToolsMenu = new wxMenu(); wxMenuItem* ToolsMenuScreenshot; @@ -95,6 +101,7 @@ GUIFrame::GUIFrame( wxWindow* parent, wxWindowID id, const wxString& title, cons this->Connect( FileMenuExit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnQuit ) ); this->Connect( ViewMenuSummary->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnViewMenuSummary ) ); this->Connect( ViewMenuDaily->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnViewMenuDaily ) ); + this->Connect( ViewMenuSerial->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnShowSerial ) ); this->Connect( ViewMenuFullscreen->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnFullscreen ) ); this->Connect( ToolsMenuScreenshot->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnScreenshot ) ); this->Connect( HelpMenuAbout->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnAbout ) ); @@ -109,6 +116,7 @@ GUIFrame::~GUIFrame() this->Disconnect( wxID_QUIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnQuit ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnViewMenuSummary ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnViewMenuDaily ) ); + this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnShowSerial ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnFullscreen ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnScreenshot ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnAbout ) ); @@ -177,24 +185,44 @@ SummaryPanel::SummaryPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, fgSizer->Fit( ScrolledWindow ); m_panel1 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_panel1->SetMaxSize( wxSize( -1,40 ) ); - m_mgr.AddPane( m_panel1, wxAuiPaneInfo() .Bottom() .Caption( wxT("Date Range") ).CloseButton( false ).MaximizeButton( false ).MinimizeButton( false ).PinButton( true ).Dock().Resizable().FloatingSize( wxSize( -1,-1 ) ).DockFixed( false ).Row( 0 ).Position( 1 ).BestSize( wxSize( 300,40 ) ).MinSize( wxSize( 300,40 ) ).MaxSize( wxSize( 300,40 ) ) ); + m_mgr.AddPane( m_panel1, wxAuiPaneInfo() .Bottom() .Caption( wxT("Date Range") ).CloseButton( false ).MaximizeButton( false ).MinimizeButton( false ).PinButton( true ).Dock().Resizable().FloatingSize( wxSize( -1,-1 ) ).DockFixed( false ).Row( 0 ).Position( 1 ).BestSize( wxSize( 570,42 ) ).MinSize( wxSize( 570,42 ) ).MaxSize( wxSize( -1,42 ) ) ); wxBoxSizer* bSizer1; bSizer1 = new wxBoxSizer( wxHORIZONTAL ); - m_staticText1 = new wxStaticText( m_panel1, wxID_ANY, _("Start"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText1->Wrap( -1 ); - bSizer1->Add( m_staticText1, 0, wxALIGN_TOP|wxLEFT|wxTOP, 12 ); + rbAll = new wxRadioButton( m_panel1, wxID_RB, _("Everything"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); + bSizer1->Add( rbAll, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - StartDatePicker = new wxDatePickerCtrl( m_panel1, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT ); - bSizer1->Add( StartDatePicker, 0, wxALL, 5 ); + rbLastWeek = new wxRadioButton( m_panel1, wxID_ANY, _("Last Week"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer1->Add( rbLastWeek, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - m_staticText2 = new wxStaticText( m_panel1, wxID_ANY, _("End"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText2->Wrap( -1 ); - bSizer1->Add( m_staticText2, 0, wxALIGN_TOP|wxLEFT|wxTOP, 12 ); + rbLastMonth = new wxRadioButton( m_panel1, wxID_ANY, _("Last Month"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer1->Add( rbLastMonth, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0 ); - EndDatePicker = new wxDatePickerCtrl( m_panel1, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT ); - bSizer1->Add( EndDatePicker, 0, wxALL, 5 ); + rbCustomDate = new wxRadioButton( m_panel1, wxID_ANY, _("Custom"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer1->Add( rbCustomDate, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0 ); + + sdLabel = new wxStaticText( m_panel1, wxID_ANY, _("Start"), wxDefaultPosition, wxDefaultSize, 0 ); + sdLabel->Wrap( -1 ); + sdLabel->Enable( false ); + + bSizer1->Add( sdLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 ); + + StartDatePicker = new wxDatePickerCtrl( m_panel1, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_SHOWCENTURY|wxDP_SPIN ); + StartDatePicker->Enable( false ); + + bSizer1->Add( StartDatePicker, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0 ); + + edLabel = new wxStaticText( m_panel1, wxID_ANY, _("End"), wxDefaultPosition, wxDefaultSize, 0 ); + edLabel->Wrap( -1 ); + edLabel->Enable( false ); + + bSizer1->Add( edLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 ); + + EndDatePicker = new wxDatePickerCtrl( m_panel1, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_SPIN ); + EndDatePicker->Enable( false ); + + bSizer1->Add( EndDatePicker, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0 ); m_panel1->SetSizer( bSizer1 ); m_panel1->Layout(); @@ -203,6 +231,10 @@ SummaryPanel::SummaryPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, m_mgr.Update(); // Connect Events + rbAll->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( SummaryPanel::OnRBSelect ), NULL, this ); + rbLastWeek->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( SummaryPanel::OnRBSelect ), NULL, this ); + rbLastMonth->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( SummaryPanel::OnRBSelect ), NULL, this ); + rbCustomDate->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( SummaryPanel::OnRBSelect ), NULL, this ); StartDatePicker->Connect( wxEVT_DATE_CHANGED, wxDateEventHandler( SummaryPanel::OnStartDateChanged ), NULL, this ); EndDatePicker->Connect( wxEVT_DATE_CHANGED, wxDateEventHandler( SummaryPanel::OnEndDateChanged ), NULL, this ); } @@ -210,6 +242,10 @@ SummaryPanel::SummaryPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, SummaryPanel::~SummaryPanel() { // Disconnect Events + rbAll->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( SummaryPanel::OnRBSelect ), NULL, this ); + rbLastWeek->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( SummaryPanel::OnRBSelect ), NULL, this ); + rbLastMonth->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( SummaryPanel::OnRBSelect ), NULL, this ); + rbCustomDate->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( SummaryPanel::OnRBSelect ), NULL, this ); StartDatePicker->Disconnect( wxEVT_DATE_CHANGED, wxDateEventHandler( SummaryPanel::OnStartDateChanged ), NULL, this ); EndDatePicker->Disconnect( wxEVT_DATE_CHANGED, wxDateEventHandler( SummaryPanel::OnEndDateChanged ), NULL, this ); diff --git a/GUIFrame.h b/GUIFrame.h index 9a3cfc0c..31571cc6 100644 --- a/GUIFrame.h +++ b/GUIFrame.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,7 @@ /////////////////////////////////////////////////////////////////////////// #define wxID_QUIT 1000 +#define wxID_RB 1001 /////////////////////////////////////////////////////////////////////////////// /// Class GUIFrame @@ -47,7 +49,8 @@ class GUIFrame : public wxFrame wxMenuBar* menubar; wxMenu* FileMenu; wxMenu* ViewMenu; - wxMenu* MachineMenu; + wxMenuItem* ViewMenuSerial; + wxMenu* ProfileMenu; wxMenu* ToolsMenu; wxMenu* HelpMenu; wxStatusBar* statusBar; @@ -59,6 +62,7 @@ class GUIFrame : public wxFrame virtual void OnQuit( wxCommandEvent& event ) { event.Skip(); } virtual void OnViewMenuSummary( wxCommandEvent& event ) { event.Skip(); } virtual void OnViewMenuDaily( wxCommandEvent& event ) { event.Skip(); } + virtual void OnShowSerial( wxCommandEvent& event ) { event.Skip(); } virtual void OnFullscreen( wxCommandEvent& event ) { event.Skip(); } virtual void OnScreenshot( wxCommandEvent& event ) { event.Skip(); } virtual void OnAbout( wxCommandEvent& event ) { event.Skip(); } @@ -112,19 +116,24 @@ class SummaryPanel : public wxPanel wxScrolledWindow* ScrolledWindow; wxFlexGridSizer* fgSizer; wxPanel* m_panel1; - wxStaticText* m_staticText1; + wxRadioButton* rbAll; + wxRadioButton* rbLastWeek; + wxRadioButton* rbLastMonth; + wxRadioButton* rbCustomDate; + wxStaticText* sdLabel; wxDatePickerCtrl* StartDatePicker; - wxStaticText* m_staticText2; + wxStaticText* edLabel; wxDatePickerCtrl* EndDatePicker; // Virtual event handlers, overide them in your derived class + virtual void OnRBSelect( wxCommandEvent& event ) { event.Skip(); } virtual void OnStartDateChanged( wxDateEvent& event ) { event.Skip(); } virtual void OnEndDateChanged( wxDateEvent& event ) { event.Skip(); } public: - SummaryPanel( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 775,447 ), long style = wxTAB_TRAVERSAL ); wxAuiManager m_mgr; + SummaryPanel( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 868,599 ), long style = wxTAB_TRAVERSAL ); wxAuiManager m_mgr; ~SummaryPanel(); diff --git a/SleepyHead.depend b/SleepyHead.depend index c4e9de41..efb56c97 100644 --- a/SleepyHead.depend +++ b/SleepyHead.depend @@ -7785,12 +7785,12 @@ "wx/progdlg.h" "wx/dialog.h" -1306577554 source:/home/mark/projects/git/sleepyhead/GUIFrame.cpp +1306753008 source:/home/mark/projects/git/sleepyhead/GUIFrame.cpp "wx/wxprec.h" "GUIFrame.h" -1306577554 /home/mark/projects/git/sleepyhead/GUIFrame.h +1306753008 /home/mark/projects/git/sleepyhead/GUIFrame.h @@ -7810,16 +7810,18 @@ + -1306414983 source:/home/mark/projects/git/sleepyhead/SleepyHeadApp.cpp +1306741958 source:/home/mark/projects/git/sleepyhead/SleepyHeadApp.cpp "wx_pch.h" + "SleepyHeadApp.h" "SleepyHeadMain.h" "version.h" @@ -7829,13 +7831,13 @@ 1305881106 /home/mark/projects/git/sleepyhead/SleepyHeadApp.h -1306662900 /home/mark/projects/git/sleepyhead/SleepyHeadMain.h +1306753017 /home/mark/projects/git/sleepyhead/SleepyHeadMain.h "SleepyHeadApp.h" "GUIFrame.h" "sleeplib/machine.h" "graphs/graph.h" -1306682653 /home/mark/projects/git/sleepyhead/libs/sleeplib/machine.h +1306726896 /home/mark/projects/git/sleepyhead/libs/sleeplib/machine.h @@ -7869,13 +7871,13 @@ "tinyxml/tinyxml.h" -1306659032 /home/mark/projects/git/sleepyhead/graphs/graph.h +1306750273 /home/mark/projects/git/sleepyhead/graphs/graph.h -1306683584 /home/mark/projects/git/sleepyhead/version.h +1306756665 /home/mark/projects/git/sleepyhead/version.h -1306549105 /home/mark/projects/git/sleepyhead/libs/sleeplib/prs1_loader.h +1306724655 /home/mark/projects/git/sleepyhead/libs/sleeplib/prs1_loader.h "machine.h" "machine_loader.h" "profiles.h" @@ -7883,14 +7885,14 @@ 1306415040 /home/mark/projects/git/sleepyhead/libs/sleeplib/machine_loader.h "profiles.h" -1306415066 /home/mark/projects/git/sleepyhead/libs/sleeplib/profiles.h +1306754109 /home/mark/projects/git/sleepyhead/libs/sleeplib/profiles.h "machine.h" "preferences.h" "tinyxml/tinyxml.h" -1306683142 source:/home/mark/projects/git/sleepyhead/SleepyHeadMain.cpp +1306756567 source:/home/mark/projects/git/sleepyhead/SleepyHeadMain.cpp "wx_pch.h" "version.h" @@ -7902,14 +7904,16 @@ + "SleepyHeadMain.h" "sleeplib/profiles.h" -1306658943 source:/home/mark/projects/git/sleepyhead/graphs/graph.cpp +1306756303 source:/home/mark/projects/git/sleepyhead/graphs/graph.cpp "graph.h" + "sleeplib/profiles.h" 1306485891 source:/home/mark/projects/git/sleepyhead/libs/sleeplib/binary_file.cpp @@ -7919,7 +7923,7 @@ -1306683485 source:/home/mark/projects/git/sleepyhead/libs/sleeplib/machine.cpp +1306753649 source:/home/mark/projects/git/sleepyhead/libs/sleeplib/machine.cpp @@ -7940,7 +7944,7 @@ "preferences.h" -1306673434 source:/home/mark/projects/git/sleepyhead/libs/sleeplib/profiles.cpp +1306755802 source:/home/mark/projects/git/sleepyhead/libs/sleeplib/profiles.cpp @@ -7952,7 +7956,7 @@ "machine_loader.h" "tinyxml/tinyxml.h" -1306681892 source:/home/mark/projects/git/sleepyhead/libs/sleeplib/prs1_loader.cpp +1306724998 source:/home/mark/projects/git/sleepyhead/libs/sleeplib/prs1_loader.cpp @@ -8004,3 +8008,71 @@ 1305166122 /opt/mingw/usr/i686-pc-mingw32/include/wx-2.8/wx/generic/datectrl.h +1302101440 /usr/include/wx-2.8/wx/fs_mem.h + "wx/defs.h" + "wx/filesys.h" + +1305166121 /opt/mingw/usr/i686-pc-mingw32/include/wx-2.8/wx/fs_mem.h + "wx/defs.h" + "wx/filesys.h" + +1302101441 /usr/include/wx-2.8/wx/statline.h + "wx/defs.h" + "wx/control.h" + "wx/univ/statline.h" + "wx/msw/statline.h" + "wx/gtk/statline.h" + "wx/gtk1/statline.h" + "wx/os2/statline.h" + "wx/mac/statline.h" + "wx/cocoa/statline.h" + "wx/generic/statline.h" + +1302101441 /usr/include/wx-2.8/wx/gtk/statline.h + "wx/defs.h" + +1305215600 /usr/include/wx-2.9/wx/datectrl.h + "wx/defs.h" + "wx/control.h" + "wx/datetime.h" + "wx/palmos/datectrl.h" + "wx/msw/datectrl.h" + "wx/generic/datectrl.h" + +1305215600 /usr/include/wx-2.9/wx/generic/datectrl.h + "wx/calctrl.h" + "wx/combo.h" + +1305215599 /usr/include/wx-2.9/wx/combo.h + "wx/defs.h" + "wx/control.h" + "wx/renderer.h" + "wx/bitmap.h" + "wx/msw/combo.h" + "wx/generic/combo.h" + +1305215599 /usr/include/wx-2.9/wx/renderer.h + "wx/gdicmn.h" + "wx/colour.h" + "wx/font.h" + "wx/bitmap.h" + "wx/string.h" + +1305215599 /usr/include/wx-2.9/wx/generic/combo.h + +1305215600 /usr/include/wx-2.9/wx/progdlg.h + "wx/defs.h" + "wx/palmos/progdlg.h" + "wx/generic/progdlgg.h" + +1305215599 /usr/include/wx-2.9/wx/generic/progdlgg.h + "wx/defs.h" + "wx/progdlg.h" + "wx/dialog.h" + +1305215598 /usr/include/wx-2.9/wx/fs_mem.h + "wx/defs.h" + "wx/filesys.h" + "wx/hashmap.h" + "wx/bitmap.h" + diff --git a/SleepyHeadApp.cpp b/SleepyHeadApp.cpp index 4a1bd851..cd4665e6 100644 --- a/SleepyHeadApp.cpp +++ b/SleepyHeadApp.cpp @@ -20,6 +20,8 @@ #include #include #include +#include + #include "SleepyHeadApp.h" #include "SleepyHeadMain.h" #include "version.h" @@ -36,6 +38,9 @@ bool SleepyHeadApp::OnInit() wxLog *logger=new wxLogStream(&std::cout); wxLog::SetActiveTarget(logger); + wxFileSystem::AddHandler(new wxMemoryFSHandler); + + wxInitAllImageHandlers(); //wxDateTime::SetCountry(wxDateTime::USA); SetAppName(_("SleepyHead")); PRS1Loader::Register(); diff --git a/SleepyHeadMain.cpp b/SleepyHeadMain.cpp index 09179be8..0a57fe06 100644 --- a/SleepyHeadMain.cpp +++ b/SleepyHeadMain.cpp @@ -25,7 +25,11 @@ #include #include #include -#include "SleepyHeadMain.h" +#include + + + +#include "SleepyHeadMain.h" #include "sleeplib/profiles.h" //#include "graphs/sleepflagsgraph.h" //#include "graphs/cpap_wavegraph.h" @@ -66,7 +70,6 @@ wxString wxbuildinfo(wxbuildinfoformat format) SleepyHeadFrame::SleepyHeadFrame(wxFrame *frame) : GUIFrame(frame) { - wxInitAllImageHandlers(); loader_progress=new wxProgressDialog(wxT("SleepyHead"),wxT("Please Wait..."),100,this, wxPD_APP_MODAL|wxPD_AUTO_HIDE|wxPD_SMOOTH); loader_progress->Hide(); wxString title=wxTheApp->GetAppName()+wxT(" v")+wxString(AutoVersion::FULLVERSION_STRING,wxConvUTF8); @@ -77,20 +80,16 @@ SleepyHeadFrame::SleepyHeadFrame(wxFrame *frame) wxLogError(wxT("Couldn't get active profile")); abort(); } + UpdateProfiles(); - UpdateMachineMenu(); - int id=0; - if (pref.Exists("DefaultMachine")) { - id=pref[wxT("DefaultMachine")].GetInteger(); - } else { - pref[wxT("DefaultMachine")]=(long)0; - } + if (pref.Exists("ShowSerialNumbers")) ViewMenuSerial->Check(pref["ShowSerialNumbers"]); - //wxDisableAsserts(); + +// wxDisableAsserts(); // Create AUINotebook Tabs wxCommandEvent dummy; - OnViewMenuDaily(dummy); // Daily Page OnViewMenuSummary(dummy); // Summary Page + OnViewMenuDaily(dummy); // Daily Page this->Connect(wxID_ANY, wxEVT_DO_SCREENSHOT, wxCommandEventHandler(SleepyHeadFrame::DoScreenshot)); //this->Connect(wxID_ANY, wxEVT_MACHINE_SELECTED, wxCommandEventHandler(SleepyHeadFrame::OnMachineSelected)); @@ -110,34 +109,33 @@ SleepyHeadFrame::~SleepyHeadFrame() delete loader_progress; } } -void SleepyHeadFrame::UpdateMachineMenu() +void SleepyHeadFrame::UpdateProfiles() { - cpap_machines=profile->GetMachines(MT_CPAP); + // cpap_machines=profile->GetMachines(MT_CPAP); - wxMenuItemList z=MachineMenu->GetMenuItems(); - int i=MachineMenuID; - for (int j=0;jGetMenuItems(); + + int i=ProfileMenuID; + for (unsigned int j=0;jDisconnect(i,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(SleepyHeadFrame::OnMachineSelected)); - MachineMenu->Remove(mi); + this->Disconnect(i,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(SleepyHeadFrame::OnProfileSelected)); + ProfileMenu->Remove(mi); i++; } - i=MachineMenuID; + i=ProfileMenuID; - for (auto m=cpap_machines.begin();m!=cpap_machines.end();m++) { - wxMenuItem *item=MachineMenu->AppendRadioItem(i,(*m)->properties[wxT("Serial")],wxEmptyString); - this->Connect(i,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(SleepyHeadFrame::OnMachineSelected)); + for (auto p=Profiles::profiles.begin();p!=Profiles::profiles.end();p++) { + Profile &pro=*(Profiles::profiles[p->first]); + wxMenuItem *item=ProfileMenu->AppendRadioItem(i,pro["Realname"],wxEmptyString); + + if (p->first==pref["Profile"].GetString()) { + item->Check(true); + } + + this->Connect(i,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(SleepyHeadFrame::OnProfileSelected)); i++; } - - long l=pref[wxT("DefaultMachine")]; - MachineMenu->Check(l+MachineMenuID,true); - - /*if (vm.size()>=1) { - machine=vm[0]; - } else machine=NULL; */ - } void SleepyHeadFrame::OnClose(wxCloseEvent &event) @@ -157,12 +155,12 @@ void SleepyHeadFrame::OnFullscreen(wxCommandEvent& event) ShowFullScreen(false); } } -void SleepyHeadFrame::OnMachineSelected(wxCommandEvent& event) +void SleepyHeadFrame::OnProfileSelected(wxCommandEvent& event) { - int id=event.GetId()-MachineMenuID; + int id=event.GetId()-ProfileMenuID; - wxLogMessage(wxT("Machine Selected:")+wxString::Format(wxT("%i"),id)); - Machine *m=cpap_machines[id]; + wxLogMessage(wxT("Profile Selected:")+wxString::Format(wxT("%i"),id)); + /*Machine *m=cpap_machines[id]; if (m) { pref[wxT("DefaultMachine")]=(long)id; @@ -174,10 +172,10 @@ void SleepyHeadFrame::OnMachineSelected(wxCommandEvent& event) } idx=main_auinotebook->GetPageIndex(summary); if (idx!=wxNOT_FOUND) { - summary->RefreshData(m); + summary->ResetProfile(profile) summary->Refresh(); - } - event.Skip(); + } */ + //event.Skip(); //Refresh(); } void SleepyHeadFrame::OnScreenshot(wxCommandEvent& event) @@ -186,7 +184,7 @@ void SleepyHeadFrame::OnScreenshot(wxCommandEvent& event) //wxWindow::DoUpdateWindowUI(); wxWindow::UpdateWindowUI(); //Refresh(true); // Make sure the menu is closed.. (It pushes the Update event in front of the manual event we push next) - // Update(true); + //Update(true); wxCommandEvent MyEvent( wxEVT_DO_SCREENSHOT); wxPostEvent(this, MyEvent); @@ -196,7 +194,7 @@ void SleepyHeadFrame::DoScreenshot( wxCommandEvent &event ) { wxRect r=GetRect(); -#if defined(__UNIX__) +#if defined(__UNIX__) // Borrowed.. this need fixing. int cx=r.x, cy=r.y; ClientToScreen(&cx,&cy); int border_width = cx - r.x; @@ -204,10 +202,6 @@ void SleepyHeadFrame::DoScreenshot( wxCommandEvent &event ) r.width += (border_width * 2); r.height += title_bar_height + border_width; #endif - int x=r.x; - int y=r.y; - int w=r.width; - int h=r.height; wxScreenDC sdc; wxMemoryDC mdc; @@ -232,6 +226,10 @@ void SleepyHeadFrame::DoScreenshot( wxCommandEvent &event ) } } } +void SleepyHeadFrame::OnShowSerial(wxCommandEvent& event) +{ + pref["ShowSerialNumbers"]=event.IsChecked(); +} void SleepyHeadFrame::OnAbout(wxCommandEvent &event) { @@ -253,7 +251,7 @@ void SleepyHeadFrame::OnImportSD(wxCommandEvent &event) loader_progress->Update(100); loader_progress->Show(false); - UpdateMachineMenu(); // Also updates cpap_machines list. + /*//UpdateMachineMenu(); // Also updates cpap_machines list. auto q=MachineMenu->GetMenuItems().rbegin(); int i=0; @@ -263,15 +261,18 @@ void SleepyHeadFrame::OnImportSD(wxCommandEvent &event) i=(*q)->GetId()-MachineMenuID; } m=cpap_machines[i]; + */ int idx=main_auinotebook->GetPageIndex(daily); if (idx!=wxNOT_FOUND) { - daily->RefreshData(m); + daily->ResetDate(); + daily->RefreshData(); daily->Refresh(); } idx=main_auinotebook->GetPageIndex(summary); if (idx!=wxNOT_FOUND) { - summary->RefreshData(m); + summary->ResetProfile(profile); // resets the date ranges.. + summary->RefreshData(); summary->Refresh(); } @@ -279,17 +280,11 @@ void SleepyHeadFrame::OnImportSD(wxCommandEvent &event) void SleepyHeadFrame::OnViewMenuDaily( wxCommandEvent& event ) { int idx=main_auinotebook->GetPageIndex(daily); - int id; + unsigned int id; if (idx==wxNOT_FOUND) { - daily=new Daily(this); + daily=new Daily(this,profile); main_auinotebook->AddPage(daily,_("Daily"),true); - if (pref.Exists(wxT("DefaultMachine"))) - id=pref["DefaultMachine"].GetInteger(); - else id=0; - if (idRefreshData(m); - } + daily->RefreshData(); daily->Refresh(); } else { @@ -303,36 +298,28 @@ void SleepyHeadFrame::OnViewMenuSummary( wxCommandEvent& event ) int id,idx=main_auinotebook->GetPageIndex(summary); if (idx==wxNOT_FOUND) { - summary=new Summary(this); + summary=new Summary(this,profile); main_auinotebook->AddPage(summary,_("Summary"),true); - if (pref.Exists(wxT("DefaultMachine"))) - id=pref["DefaultMachine"].GetInteger(); - else id=0; - if (idRefreshData(m); - } + summary->ResetProfile(profile); + summary->RefreshData(); summary->Refresh(); } else { main_auinotebook->SetSelection(idx); } } -Summary::Summary(wxWindow *win) -:SummaryPanel(win) +Summary::Summary(wxWindow *win,Profile *_profile) +:SummaryPanel(win),profile(_profile) { - machine=NULL; + AddData(ahidata=new HistoryData(profile)); + AddData(pressure=new HistoryCodeData(profile,CPAP_PressureAverage)); + AddData(pressure_eap=new HistoryCodeData(profile,BIPAP_EAPAverage)); + AddData(pressure_iap=new HistoryCodeData(profile,BIPAP_IAPAverage)); - const int days_shown=60; - - AddData(ahidata=new HistoryData(machine,days_shown)); - AddData(pressure=new HistoryCodeData(machine,CPAP_PressureAverage,days_shown)); - AddData(pressure_eap=new HistoryCodeData(machine,BIPAP_EAPAverage,days_shown)); - AddData(pressure_iap=new HistoryCodeData(machine,BIPAP_IAPAverage,days_shown)); - AddData(leak=new HistoryCodeData(machine,CPAP_LeakMedian,days_shown)); - AddData(usage=new UsageHistoryData(machine,days_shown,UHD_Hours)); - AddData(waketime=new UsageHistoryData(machine,days_shown,UHD_Waketime)); - AddData(bedtime=new UsageHistoryData(machine,days_shown,UHD_Bedtime)); + AddData(leak=new HistoryCodeData(profile,CPAP_LeakMedian)); + AddData(usage=new UsageHistoryData(profile,UHD_Hours)); + AddData(waketime=new UsageHistoryData(profile,UHD_Waketime)); + AddData(bedtime=new UsageHistoryData(profile,UHD_Bedtime)); AHI=new gGraphWindow(ScrolledWindow,-1,wxT("AHI"),wxPoint(0,0), wxSize(400,200), wxNO_BORDER); AHI->SetMargins(10,15,60,80); @@ -361,39 +348,54 @@ Summary::Summary(wxWindow *win) //USAGE->AddLayer(new gLineChart(usage,wxGREEN)); fgSizer->Add(USAGE,1,wxEXPAND); - + // Logo.LoadFile(wxT("./pic.png")); + //wxMemoryFSHandler::AddFile(_T("test.png"), Logo, wxBITMAP_TYPE_PNG); // RefreshData(); } Summary::~Summary() { + wxMemoryFSHandler::RemoveFile(_T("test.png")); } - -void Summary::RefreshData(Machine *m) +void Summary::ResetProfile(Profile *p) +{ + profile=p; + for (auto h=Data.begin();h!=Data.end();h++) { + (*h)->SetProfile(p); + (*h)->ResetDateRange(); + } + if (profile->FirstDay().IsValid()) { + StartDatePicker->SetRange(profile->FirstDay()+wxTimeSpan::Day(),profile->LastDay()+wxTimeSpan::Day()); + EndDatePicker->SetRange(profile->FirstDay()+wxTimeSpan::Day(),profile->LastDay()+wxTimeSpan::Day()); + StartDatePicker->SetValue(profile->FirstDay()+wxTimeSpan::Day()); + EndDatePicker->SetValue(profile->LastDay()+wxTimeSpan::Day()); + } +} +void Summary::RefreshData() { - if (!m) return; - machine=m; - for (auto h=Data.begin();h!=Data.end();h++) { - (*h)->SetMachine(m); (*h)->Update(); } wxString submodel=_("Unknown Model"); double ahi=ahidata->GetAverage(); double avp=pressure->GetAverage(); + // double aeap=pressure_eap->GetAverage(); + //double aiap=pressure_iap->GetAverage(); double bt=fmod(bedtime->GetAverage(),12.0); double ua=usage->GetAverage(); double wt=waketime->GetAverage(); //fmod(bt+ua,12.0); - wxString html=wxT("\n"); + wxString html=wxT(""); - if (machine) { - html=html+wxT("\n"); - if (machine->properties.find(wxT("SubModel"))!=machine->properties.end()) + //html=html+wxT(""); + html=html+wxT("
")+_("Machine Information")+wxT("
\n"); + + html=html+wxT("\n"); + /*if (machine->properties.find(wxT("SubModel"))!=machine->properties.end()) submodel=wxT("
\n ")+machine->properties[wxT("SubModel")]; html=html+wxT("\n"); - html=html+wxT(""); + html=html+wxT(""); */ html=html+wxT("\n"); html=html+wxT("\n"); html=html+wxT("\n"); @@ -405,19 +407,66 @@ void Summary::RefreshData(Machine *m) html=html+wxT("\n"); html=html+wxT("\n"); html=html+wxT("
")+_("Machine Information has been removed because this page has become machine agnostic. Not sure what to display here.")+wxT("
")+machine->properties[wxT("Brand")]+wxT("
")+machine->properties[wxT("Model")]+wxT(" ")+machine->properties[wxT("ModelNumber")]+submodel+wxT("
")+_("Firmware")+wxT(" ")+machine->properties[wxT("SoftwareVersion")]+wxT("
")+_("Firmware")+wxT(" ")+machine->properties[wxT("SoftwareVersion")]+wxT("
  
")+_("Indice Averages")+wxT("
")+_("AHI")+wxT("")+wxString::Format(wxT("%0.2f"),ahi)+wxT("
")+_("Waketime")+wxT("")+wxString::Format(wxT("%02.0f:%02i"),wt,int(wt*60) % 60)+wxT("
")+_("Hours/Night")+wxT("")+wxString::Format(wxT("%02.0f:%02i"),ua,int(ua*60)%60)+wxT("
"); - } else { - html=html+_("Please import some data."); - } html+=wxT(""); HTMLInfo->SetPage(html); +} +void Summary::EnableDatePickers(bool b) +{ + StartDatePicker->Enable(b); + sdLabel->Enable(b); + EndDatePicker->Enable(b); + edLabel->Enable(b); +} +void Summary::OnRBSelect( wxCommandEvent& event ) +{ + wxDateTime start=StartDatePicker->GetValue(); + wxDateTime end=EndDatePicker->GetValue(); + if (rbCustomDate->GetValue()) { + EnableDatePickers(true); + } else if (rbAll->GetValue()) { + start=profile->FirstDay()-wxTimeSpan::Day(); + end=profile->LastDay(); + } else if (rbLastMonth->GetValue()) { + end=profile->LastDay(); + start=end-wxTimeSpan::Days(30); + } else if (rbLastWeek->GetValue()) { + end=profile->LastDay(); + start=end-wxTimeSpan::Days(7); + } + if ((start==StartDatePicker->GetValue()) && (end==EndDatePicker->GetValue())) + return; + + StartDatePicker->SetValue(start); + EndDatePicker->SetValue(end); + + for (auto h=Data.begin();h!=Data.end();h++) { + (*h)->SetDateRange(start,end); + } } -Daily::Daily(wxWindow *win) -:DailyPanel(win) +void Summary::OnStartDateChanged( wxDateEvent& event ) +{ + wxDateTime start=StartDatePicker->GetValue()-wxTimeSpan::Days(2); + wxDateTime end=EndDatePicker->GetValue()-wxTimeSpan::Day(); + for (auto h=Data.begin();h!=Data.end();h++) { + (*h)->SetDateRange(start,end); + } +} +void Summary::OnEndDateChanged( wxDateEvent& event ) +{ + wxDateTime start=StartDatePicker->GetValue()-wxTimeSpan::Days(2); + wxDateTime end=EndDatePicker->GetValue()-wxTimeSpan::Day(); + for (auto h=Data.begin();h!=Data.end();h++) { + (*h)->SetDateRange(start,end); + } +} + + +Daily::Daily(wxWindow *win,Profile *p) +:DailyPanel(win),profile(p) { - machine=NULL; AddData(tap_eap=new TAPData(CPAP_EAP)); AddData(tap_iap=new TAPData(CPAP_IAP)); @@ -520,54 +569,53 @@ Daily::Daily(wxWindow *win) fgSizer->Add(TAP,1,wxEXPAND); fgSizer->Add(TAP_IAP,1,wxEXPAND); fgSizer->Add(TAP_EAP,1,wxEXPAND); - //fgSizer->Layout(); - - foobar_datehack=false; // this exists due to a wxGTK bug. - // RefreshData(); + ResetDate(); } Daily::~Daily() { } -void Daily::RefreshData(Machine *m) +void Daily::ResetDate() { - if (!m) return; - machine=m; - - - wxDateTime day=m->LastDay()+wxTimeSpan::Days(1); - Calendar->SetDate(day); - day.ResetTime(); - day.SetHour(0); - //et-=wxTimeSpan::Days(1); - UpdateGraphs(day); - wxCalendarEvent ev; - ev.SetDate(day); - OnCalendarMonth(ev); - OnCalendarDay(ev); -} -///usr/local/bin/upx ./bin/Windows/SleepyHead - -void Daily::OnCalendarDay( wxCalendarEvent& event ) -{ - if (foobar_datehack) { - OnCalendarMonth(event); - foobar_datehack=false; + foobar_datehack=false; // this exists due to a wxGTK bug. + // RefreshData(); + wxDateTime date; + if (profile->LastDay().IsValid()) { + date=profile->LastDay(); + Calendar->SetDate(date); + } else { + Calendar->SetDate(wxDateTime::Today()); } - if (!machine) return; - wxDateTime day=event.GetDate(); - day.ResetTime(); - day.SetHour(0); - day-=wxTimeSpan::Days(1); - Day *d; - if (machine && (machine->day.find(day)!=machine->day.end()) && (d=machine->day[day]) && (d->size()>0)) { // && ((d->last()-d->first())>wxTimeSpan::Minutes(15))) { - //HTMLInfo->SetPage(wxT("")); + wxCalendarEvent ev; + ev.SetDate(date); + OnCalendarMonth(ev); +} +void Daily::RefreshData() +{ + wxDateTime date=Calendar->GetDate(); + date.ResetTime(); + date.SetHour(0); + date-=wxTimeSpan::Days(1); + + Day *d=NULL; + + if (profile->daylist.find(date)!=profile->daylist.end()) { + vector::iterator di; + for (di=profile->daylist[date].begin();di!=profile->daylist[date].end();di++) { + if ((*di)->machine_type()==MT_CPAP) { + d=(*di); + break; + } + + } + } + UpdateGraphs(d); + + if (d) { CPAPMode mode=(CPAPMode)d->summary_max(CPAP_Mode); - UpdateGraphs(day); if (mode!=MODE_BIPAP) { - TAP_EAP->Show(false); TAP_IAP->Show(false); TAP->Show(true); @@ -577,16 +625,9 @@ void Daily::OnCalendarDay( wxCalendarEvent& event ) TAP_EAP->Show(true); } - //TAP_EAP->Refresh(); - //TAP_IAP->Refresh(); - //TAP->Refresh(); fgSizer->Layout(); -// Update(); ScrolledWindow->FitInside(); - //ScrolledWindow->Refresh(); -// wxWindow::UpdateWindowUI(); -// Session *s=(*machine->day[day])[0]; PRTypes pr=(PRTypes)d->summary_max(CPAP_PressureReliefType); wxString epr=PressureReliefNames[pr]+wxString::Format(wxT(" x%i"),(int)d->summary_max(CPAP_PressureReliefSetting)); wxString modestr=CPAPModeNames[mode]; @@ -607,15 +648,18 @@ void Daily::OnCalendarDay( wxCalendarEvent& event ) wxString html=wxT("\n"); html=html+wxT("\n"); - if (machine->properties.find(wxT("SubModel"))!=machine->properties.end()) - submodel=wxT("
")+machine->properties[wxT("SubModel")]; - html=html+wxT("\n"); + if (d->machine->properties.find(wxT("SubModel"))!=d->machine->properties.end()) + submodel=wxT("
")+d->machine->properties[wxT("SubModel")]; + html=html+wxT("\n"); + if (pref.Exists("ShowSerialNumbers") && pref["ShowSerialNumbers"]) { + html=html+wxT("\n"); + } html=html+wxT("\n"); html=html+wxT("\n"); - html=html+wxT("\n"); - html=html+wxT("\n"); - html=html+wxT("\n"); - html=html+wxT("\n"); + html=html+wxT("\n"); + html=html+wxT("\n"); + html=html+wxT("\n"); + html=html+wxT("\n"); html=html+wxT("\n"); html=html+wxT("\n"); html=html+wxT("\n"); @@ -655,36 +699,40 @@ void Daily::OnCalendarDay( wxCalendarEvent& event ) html=html+wxT("\n"); html=html+wxT("\n"); - html=html+wxT("\n"); - if (mode==MODE_CPAP) { - html=html+wxT("\n"); - } else if (mode==MODE_APAP) { - html=html+wxT("\n"); - html=html+wxT("\n"); - } else if (mode==MODE_BIPAP) { - html=html+wxT("\n"); - html=html+wxT("\n"); + if (d->summary_avg(CPAP_BrokenSummary)==1) { + html=html+wxT("\n"); + } else { + html=html+wxT("\n"); + + if (mode==MODE_CPAP) { + html=html+wxT("\n"); + } else if (mode==MODE_APAP) { + html=html+wxT("\n"); + html=html+wxT("\n"); + } else if (mode==MODE_BIPAP) { + html=html+wxT("\n"); + html=html+wxT("\n"); + } + html=html+wxT("\n"); + html=html+wxT("\n"); + + // check HumidiferStatus.. + wxString str; + if (bool(d->summary_max(CPAP_HumidifierStatus))) { + str=wxString::Format(wxT("x%i"),(int)d->summary_max(CPAP_HumidifierSetting)); + } else str=wxT("No"); + html=html+wxT("\n"); + html=html+wxT("\n"); + html=html+wxT("\n"); + html=html+wxT("\n"); + html=html+wxT("\n"); + html=html+wxT("\n"); + if (bool(d->summary_max(PRS1_SystemResistanceStatus))) { + str=wxString::Format(wxT("x%i"),(int)d->summary_max(PRS1_SystemResistanceSetting)); + } else str=wxT("No"); + html=html+wxT("\n"); } - html=html+wxT("\n"); - html=html+wxT("\n"); - - // check HumidiferStatus.. - wxString str; - if (bool(d->summary_max(CPAP_HumidifierStatus))) { - str=wxString::Format(wxT("x%i"),(int)d->summary_max(CPAP_HumidifierSetting)); - } else str=wxT("No"); - html=html+wxT("\n"); - html=html+wxT("\n"); - html=html+wxT("\n"); - html=html+wxT("\n"); - html=html+wxT("\n"); - html=html+wxT("\n"); - if (bool(d->summary_max(PRS1_SystemResistanceStatus))) { - str=wxString::Format(wxT("x%i"),(int)d->summary_max(PRS1_SystemResistanceSetting)); - } else str=wxT("No"); - html=html+wxT("\n"); - html=html+wxT("\n"); html=html+wxT("\n"); for (auto i=d->begin();i!=d->end();i++) { @@ -704,21 +752,24 @@ void Daily::OnCalendarDay( wxCalendarEvent& event ) HTMLInfo->SetPage(html); } else { HTMLInfo->SetPage(_("No CPAP Machine Data Available")); - UpdateGraphs(wxInvalidDateTime); } } -void Daily::UpdateGraphs(wxDateTime d) -{ - Day *day=NULL; - if (!machine) return; - if (d!=wxInvalidDateTime) { - if (machine->day.find(d)!=machine->day.end()) { - day=machine->day[d]; - } - } - for (auto g=Data.begin();g!=Data.end();g++) { +///usr/local/bin/upx ./bin/Windows/SleepyHead +void Daily::OnCalendarDay( wxCalendarEvent& event ) +{ + if (foobar_datehack) { + OnCalendarMonth(event); + foobar_datehack=false; + } + RefreshData(); +} +void Daily::UpdateGraphs(Day *day) +{ + //if (!day) return; + + for (auto g=Data.begin();g!=Data.end();g++) { (*g)->Update(day); } }; @@ -737,13 +788,14 @@ void Daily::OnCalendarMonth( wxCalendarEvent& event ) static wxFont f=*wxNORMAL_FONT; //wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); f.SetWeight(wxBOLD); - if (!machine) return; + //if (!machine) return; for (int i=1;i<31;i++) { int j=wxDateTime::GetNumberOfDays(m,y); if (i>j) break; wxDateTime d(i,m,y,0,0,0,0); d-=wxTimeSpan::Days(1); - if ((machine->day.find(d)!=machine->day.end())) { + + if ((profile->daylist.find(d)!=profile->daylist.end())) { #if wxCHECK_VERSION(2,9,0) Calendar->Mark(i,true); #else diff --git a/SleepyHeadMain.h b/SleepyHeadMain.h index ca793b65..c11368cf 100644 --- a/SleepyHeadMain.h +++ b/SleepyHeadMain.h @@ -24,14 +24,27 @@ class Summary:public SummaryPanel { public: - Summary(wxWindow *win); + Summary(wxWindow *win,Profile *_profile); virtual ~Summary(); + void RefreshData(); + void ResetProfile(Profile *p); + void AddData(HistoryData *d) { Data.push_back(d); }; + +// void SetProfile(Profile *p); + HistoryData *ahidata,*pressure,*leak,*usage,*bedtime,*waketime,*pressure_iap,*pressure_eap; gGraphWindow *AHI,*PRESSURE,*LEAK,*USAGE; - void RefreshData(Machine *m); - void AddData(HistoryData *d) { Data.push_back(d); }; + + wxBitmap Logo; + protected: - Machine *machine; + virtual void OnRBSelect( wxCommandEvent& event ); + virtual void OnStartDateChanged( wxDateEvent& event ); + virtual void OnEndDateChanged( wxDateEvent& event ); + + void EnableDatePickers(bool b); + + Profile *profile; list Data; }; @@ -39,29 +52,30 @@ protected: class Daily:public DailyPanel { public: - Daily(wxWindow *win); + Daily(wxWindow *win,Profile *p); virtual ~Daily(); - void RefreshData(Machine *m); - + void ResetDate(); + void RefreshData(); + // void SetProfile(Profile *p); protected: virtual void OnCalendarDay( wxCalendarEvent& event ); virtual void OnCalendarMonth( wxCalendarEvent& event ); void AddData(gPointData *d) { Data.push_back(d); }; - void UpdateGraphs(wxDateTime date); + void UpdateGraphs(Day *day); bool foobar_datehack; gPointData *tap,*tap_eap,*tap_iap,*g_ahi,*frw,*prd,*leakdata,*pressure_iap,*pressure_eap; gPointData *flags[10]; gGraphWindow *PRD,*FRW,*G_AHI,*TAP,*LEAK,*SF,*TAP_EAP,*TAP_IAP; - Machine *machine; + Profile *profile; list Data; }; const wxEventType wxEVT_DO_SCREENSHOT = wxNewEventType(); const wxEventType wxEVT_MACHINE_SELECTED = wxNewEventType(); -const int MachineMenuID=wxID_HIGHEST; +const int ProfileMenuID=wxID_HIGHEST; class SleepyHeadFrame: public GUIFrame { @@ -78,9 +92,10 @@ class SleepyHeadFrame: public GUIFrame virtual void OnImportSD(wxCommandEvent& event); virtual void OnViewMenuDaily(wxCommandEvent& event); virtual void OnViewMenuSummary(wxCommandEvent& event); - virtual void OnMachineSelected(wxCommandEvent& event); + virtual void OnShowSerial(wxCommandEvent& event); + virtual void OnProfileSelected(wxCommandEvent& event); - virtual void UpdateMachineMenu(); + virtual void UpdateProfiles(); Summary *summary; Daily *daily; diff --git a/WxWizFrame.fbp b/WxWizFrame.fbp index 7841226f..438a32dc 100644 --- a/WxWizFrame.fbp +++ b/WxWizFrame.fbp @@ -285,6 +285,25 @@ OnViewMenuDaily + + m_separator3 + none + + + + 0 + 1 + + wxID_ANY + wxITEM_CHECK + Show Serial Numbers + ViewMenuSerial + protected + + + OnShowSerial + + m_separator2 none @@ -306,8 +325,8 @@ - &Machine - MachineMenu + &Profiles + ProfileMenu protected @@ -918,7 +937,7 @@ Resizable 1 - 775,447 + 868,599 0 @@ -1142,7 +1161,7 @@ 1 1 - 300,40 + 570,42 Date Range 1 @@ -1162,10 +1181,10 @@ 0 wxID_ANY - 300,40 + -1,42 0 -1,40 - 300,40 + 570,42 0 1 @@ -1220,10 +1239,98 @@ wxHORIZONTAL none - 12 - wxALIGN_TOP|wxLEFT|wxTOP + 5 + wxALIGN_CENTER_VERTICAL|wxLEFT 0 - + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_RB + Everything + + + 0 + + + 0 + + 1 + rbAll + 1 + + + protected + 1 + + + Resizable + + 1 + + wxRB_GROUP + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + OnRBSelect + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxLEFT + 0 + 1 1 1 @@ -1248,6 +1355,270 @@ 0 0 wxID_ANY + Last Week + + + 0 + + + 0 + + 1 + rbLastWeek + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + OnRBSelect + + + + + + + + + + 0 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Last Month + + + 0 + + + 0 + + 1 + rbLastMonth + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + OnRBSelect + + + + + + + + + + 0 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Custom + + + 0 + + + 0 + + 1 + rbCustomDate + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + OnRBSelect + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + + 1 + + 0 + 0 + wxID_ANY Start @@ -1257,7 +1628,7 @@ 0 1 - m_staticText1 + sdLabel 1 @@ -1306,11 +1677,11 @@ - - 5 - wxALL + + 0 + wxALIGN_CENTER_VERTICAL|wxALL 0 - + 1 1 1 @@ -1328,7 +1699,7 @@ Dock 0 Left - 1 + 0 1 @@ -1355,7 +1726,7 @@ 1 - wxDP_DEFAULT + wxDP_SHOWCENTURY|wxDP_SPIN 0 @@ -1392,11 +1763,11 @@ - - 12 - wxALIGN_TOP|wxLEFT|wxTOP + + 5 + wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT 0 - + 1 1 1 @@ -1414,7 +1785,7 @@ Dock 0 Left - 1 + 0 1 @@ -1430,7 +1801,7 @@ 0 1 - m_staticText2 + edLabel 1 @@ -1479,11 +1850,11 @@ - - 5 - wxALL + + 0 + wxALIGN_CENTER_VERTICAL|wxALL 0 - + 1 1 1 @@ -1501,7 +1872,7 @@ Dock 0 Left - 1 + 0 1 @@ -1528,7 +1899,7 @@ 1 - wxDP_DEFAULT + wxDP_SPIN 0 diff --git a/graphs/graph.cpp b/graphs/graph.cpp index 4f052cd3..c70d7553 100644 --- a/graphs/graph.cpp +++ b/graphs/graph.cpp @@ -9,6 +9,7 @@ License: LGPL #include #include #include "graph.h" +#include "sleeplib/profiles.h" #if !wxCHECK_VERSION(2,9,0) wxColor zwxYELLOW=wxColor(0xb0,0xb0,0x40,0xff); @@ -819,12 +820,12 @@ void gBarChart::Plot(wxDC & dc, gGraphWindow & w) double xx=w.max_x - w.min_x; double days=int(xx); - days=data->np[0]; + //days=data->np[0]; - /*days=0; + days=0; for (int i=0;inp[0];i++) { - if ((data->point[0][i].x > w.min_x) && (data->point[0][i].xpoint[0][i].x >= w.min_x) && (data->point[0][i].xnp[0];i++) { - //if (data->point[0][i].x < w.min_x) continue; - //if (data->point[0][i].x > w.max_x) break; + if (data->point[0][i].x < w.min_x) continue; + if (data->point[0][i].x >= w.max_x) break; dc.SetBrush(*wxTRANSPARENT_BRUSH); t1=px; px+=barwidth+1; @@ -1150,11 +1151,11 @@ void gLineChart::DrawXTicks(wxDC & dc,gGraphWindow &w) if (min_tick<=0.25/86400.0) min_tick=0.25/86400; - } else { + } else { // Day ticks.. show_time=false; st=st2; min_tick=1; - double mtiks=(y+20.0)/width; + double mtiks=(x+20.0)/width; double mt=mtiks*xx; min_tick=mt; if (min_tick<1) min_tick=1; @@ -1186,7 +1187,7 @@ void gLineChart::DrawXTicks(wxDC & dc,gGraphWindow &w) int hour,minute,second,millisecond; wxDateTime d; for (double i=st; i<=w.max_x; i+=min_tick) { //600.0/86400.0) { - d.Set(i+2400000.5+.000001+1); // JDN vs MJD vs Rounding errors + d.Set(i+2400000.5+.000001); // JDN vs MJD vs Rounding errors if (show_time) { minute=d.GetMinute(); @@ -1211,11 +1212,11 @@ void gLineChart::DrawXTicks(wxDC & dc,gGraphWindow &w) dc.DrawLine(px,py,px,py+6); dc.GetTextExtent(fd,&x,&y); - if (!show_time) { - dc.DrawRotatedText(fd, px-(y/2)+2, py+x+14, 90); - } else { + //if (!show_time) { + // dc.DrawRotatedText(fd, px-(y/2)+2, py+x+14, 90); + //} else { dc.DrawText(fd, px-(x/2), py+y); - } + //} } @@ -1917,14 +1918,26 @@ void FlagData::Reload(Day *day) m_ready=true; } -HistoryData::HistoryData(Machine *_machine,int _days) -:gPointData(_days*2),machine(_machine),days(_days) +HistoryData::HistoryData(Profile * _profile) +:gPointData(1024),profile(_profile) { AddSegment(max_points); + if (profile->LastDay().IsValid()) { + real_min_x=profile->FirstDay().GetMJD()-1; + real_max_x=profile->LastDay().GetMJD()+1; + } } HistoryData::~HistoryData() { } +void HistoryData::ResetDateRange() +{ + if (profile->LastDay().IsValid()) { + real_min_x=profile->FirstDay().GetMJD()-1; + real_max_x=profile->LastDay().GetMJD()+1; + } + Reload(NULL); +} double HistoryData::Calc(Day *day) { return (day->count(CPAP_Obstructive)+day->count(CPAP_Hypopnea)+day->count(CPAP_ClearAirway))/day->hours(); @@ -1932,27 +1945,31 @@ double HistoryData::Calc(Day *day) void HistoryData::Reload(Day *day) { - if (!machine) return; - - auto d=machine->day.rbegin(); - int i=0; - while (d!=machine->day.rend() && (i<=days)) { - d++; - i++; - } + wxDateTime date; vc=0; + int i=0; bool first=true; - double x,y; - max_y=0; - i=0; - do { - d--; - y=Calc(d->second); - x=d->first.GetMJD(); + bool done=false; + double y; + for (int x=real_min_x;x<=real_max_x;x++) { + date.Set(x+2400000.5); + date.ResetTime(); + if (profile->daylist.find(date)==profile->daylist.end()) continue; + + y=0; + int z=0; + vector & daylist=profile->daylist[date]; + for (auto dd=daylist.begin(); dd!=daylist.end(); dd++) { // average any multiple data sets + Day *d=(*dd); + y=Calc(d); + z++; + } + if (z>1) y /= z; + point[vc][i].x=x; + point[vc][i].y=y; if (first) { - max_x=x; - min_x=x; - min_y=y; + max_x=min_x=x; + max_y=min_y=y; first=false; } if (y>max_y) max_y=y; @@ -1960,14 +1977,16 @@ void HistoryData::Reload(Day *day) if (xmax_x) max_x=x; - point[vc][i].x=x; - point[vc][i].y=y; i++; - } while (d!=machine->day.rbegin() && (imax_points) { + wxLogError(wxT("max_points is not enough in HistoryData")); + done=true; + } + if (done) break; + } np[vc]=i; vc++; - min_y=0; - max_y=ceil(max_y); + max_x+=1; real_min_x=min_x; real_max_x=max_x; real_min_y=min_y; @@ -1983,10 +2002,22 @@ double HistoryData::GetAverage() val/=np[0]; return val; } +void HistoryData::SetDateRange(wxDateTime start,wxDateTime end) +{ + double x1=start.GetMJD()+1; + double x2=end.GetMJD()+1; + if (x1 < real_min_x) x1=real_min_x; + if (x2 > real_max_x) x2=real_max_x; + min_x=x1; + max_x=x2; + for (auto i=notify_layers.begin();i!=notify_layers.end();i++) { + (*i)->DataChanged(this); + } // Do nothing else.. Callers responsibility to Refresh window. +} -HistoryCodeData::HistoryCodeData(Machine *_machine,MachineCode _code,int _days) -:HistoryData(_machine,_days),code(_code) +HistoryCodeData::HistoryCodeData(Profile *_profile,MachineCode _code) +:HistoryData(_profile),code(_code) { } HistoryCodeData::~HistoryCodeData() @@ -1997,8 +2028,8 @@ double HistoryCodeData::Calc(Day *day) return day->summary_avg(code); } -UsageHistoryData::UsageHistoryData(Machine *_machine,int _days,T_UHD _uhd) -:HistoryData(_machine,_days),uhd(_uhd) +UsageHistoryData::UsageHistoryData(Profile *_profile,T_UHD _uhd) +:HistoryData(_profile),uhd(_uhd) { } UsageHistoryData::~UsageHistoryData() diff --git a/graphs/graph.h b/graphs/graph.h index 77df90c2..7c44d15a 100644 --- a/graphs/graph.h +++ b/graphs/graph.h @@ -444,27 +444,26 @@ public: class HistoryData:public gPointData { public: - HistoryData(Machine *_machine,int _days); + HistoryData(Profile * _profile); virtual ~HistoryData(); - void SetMachine(Machine *_machine) { machine=_machine; Reload(); }; - Machine * GetMachine() { return machine; }; - void SetDays(int i) { days=i; }; - int GetDays() { return days; }; + void SetProfile(Profile *_profile) { profile=_profile; Reload(); }; + Profile * GetProfile() { return profile; }; double GetAverage(); virtual double Calc(Day *day); virtual void Reload(Day *day=NULL); + virtual void ResetDateRange(); + virtual void SetDateRange(wxDateTime start,wxDateTime end); // virtual void Reload(Machine *machine=NULL); protected: - Machine *machine; - int days; + Profile * profile; }; class HistoryCodeData:public HistoryData { public: - HistoryCodeData(Machine *_machine,MachineCode _code,int _days); + HistoryCodeData(Profile *_profile,MachineCode _code); virtual ~HistoryCodeData(); virtual double Calc(Day *day); protected: @@ -476,7 +475,7 @@ enum T_UHD { UHD_Bedtime, UHD_Waketime, UHD_Hours }; class UsageHistoryData:public HistoryData { public: - UsageHistoryData(Machine *_machine,int _days,T_UHD _uhd); + UsageHistoryData(Profile *_profile,T_UHD _uhd); virtual ~UsageHistoryData(); virtual double Calc(Day *day); protected: diff --git a/libs/sleeplib/machine.cpp b/libs/sleeplib/machine.cpp index 0f277394..7762c3ca 100644 --- a/libs/sleeplib/machine.cpp +++ b/libs/sleeplib/machine.cpp @@ -53,12 +53,14 @@ const map DefaultFlagColours= { {PRS1_PressurePulse,wxColour(0xff,0x40,0xff,flagalpha)} }; map CPAPModeNames={ + {MODE_UNKNOWN,wxT("Undetermined")}, {MODE_CPAP,wxT("CPAP")}, {MODE_APAP,wxT("APAP")}, {MODE_BIPAP,wxT("BIPAP")}, {MODE_ASV,wxT("ASV")} }; map PressureReliefNames={ + {PR_UNKNOWN,_("Undetermined")}, {PR_NONE,_("None")}, {PR_CFLEX,wxT("C-Flex")}, {PR_CFLEXPLUS,wxT("C-Flex+")}, @@ -137,7 +139,7 @@ Session *Machine::SessionExists(SessionID session) return NULL; } } -void Machine::AddSession(Session *s) +Day *Machine::AddSession(Session *s,Profile *p) { wxDateTime date=s->first(); date.ResetTime(); @@ -156,11 +158,11 @@ void Machine::AddSession(Session *s) ok=true; } } - } else { + } else { // No day record yesterday wxDateTime t=s->first(); t.ResetTime(); wxTimeSpan j=s->first()-t; - if (jsession()]=s; -/* wxDateTime s1=s->first(); - wxDateTime s2=s->last(); - if (s1==s2) return; // leave this session out of daylist.. it's dodgy. DELETE? - - - wxDateTime date,d1=s1; - date=d1; - d1.SetHour(15); - - if (s1date) firstday=date; if (lastdayAddDay(date,day[date]); } - //wxLogMessage(wxT("Using Day ")+date.Format()+wxT(" to store ")+s1.Format()+wxT(" ")+s2.Format()); day[date]->AddSession(s); + + return day[date]; } bool Machine::Load() @@ -239,7 +228,7 @@ bool Machine::Load() // wxPrintf(s+wxT(" O=%i H=%i CA=%i \n"),sess->summary[CPAP_Obstructive].GetLong(),sess->summary[CPAP_Hypopnea].GetLong(),sess->summary[CPAP_ClearAirway].GetLong()); sess->LoadEvents(s->second[1]); sess->LoadWaveforms(s->second[2]); - AddSession(sess); + AddSession(sess,profile); } else { delete sess; } @@ -262,7 +251,8 @@ bool Machine::Save() ////////////////////////////////////////////////////////////////////////////////////////// // Day Class implmementation ////////////////////////////////////////////////////////////////////////////////////////// -Day::Day() +Day::Day(Machine *m) +:machine(m) { d_firstsession=true; sessions.clear(); @@ -271,6 +261,11 @@ Day::~Day() { } +MachineType Day::machine_type() +{ + return machine->GetType(); +}; + void Day::AddSession(Session *s) { if (!s) { @@ -758,7 +753,7 @@ double Session::weighted_avg_event_field(MachineCode mc,int field) void Session::AddEvent(Event * e) { events[e->code()].push_back(e); - // if (e->time()>s_last) s_last=e->time(); + if (e->time()>s_last) s_last=e->time(); // wxLogMessage(e->time().Format(wxT("%Y-%m-%d %H:%M:%S"))+wxString::Format(wxT(" %04i %02i "),e->code(),e->fields())); } void Session::AddWaveform(Waveform *w) diff --git a/libs/sleeplib/machine.h b/libs/sleeplib/machine.h index c4f1db03..a4f1be73 100644 --- a/libs/sleeplib/machine.h +++ b/libs/sleeplib/machine.h @@ -47,7 +47,7 @@ wxInt16 { CPAP_PressureMaxAchieved, CPAP_PressurePercentValue, CPAP_PressurePercentName, CPAP_PressureAverage, CPAP_PressureMedian, CPAP_LeakMedian,CPAP_LeakMinimum,CPAP_LeakMaximum,CPAP_LeakAverage,CPAP_Duration, - BIPAP_EAPAverage,BIPAP_IAPAverage,BIPAP_EAPMin,BIPAP_EAPMax,BIPAP_IAPMin,BIPAP_IAPMax, + BIPAP_EAPAverage,BIPAP_IAPAverage,BIPAP_EAPMin,BIPAP_EAPMax,BIPAP_IAPMin,BIPAP_IAPMax,CPAP_BrokenSummary, // PRS1 Specific Codes PRS1_PressurePulse=0x1000, PRS1_VSnore2, @@ -61,11 +61,11 @@ short { FT_BAR, FT_DOT, FT_SPAN }; enum CPAPMode: short { - MODE_CPAP=0,MODE_APAP,MODE_BIPAP,MODE_ASV + MODE_UNKNOWN=0,MODE_CPAP,MODE_APAP,MODE_BIPAP,MODE_ASV }; enum PRTypes: short { - PR_NONE=0,PR_CFLEX,PR_CFLEXPLUS,PR_AFLEX,PR_BIFLEX,PR_EPR,PR_SMARTFLEX + PR_UNKNOWN=0,PR_NONE,PR_CFLEX,PR_CFLEXPLUS,PR_AFLEX,PR_BIFLEX,PR_EPR,PR_SMARTFLEX }; extern map DefaultMCShortNames; @@ -81,14 +81,16 @@ typedef float EventDataType; class Session; class Profile; +class Machine; class Day { public: - Day(); + Day(Machine *m); ~Day(); void AddSession(Session *s); + MachineType machine_type(); EventDataType min(MachineCode code,int field=0); EventDataType max(MachineCode code,int field=0); @@ -117,6 +119,7 @@ public: vector::iterator end() { return sessions.end(); }; size_t size() { return sessions.size(); }; + Machine *machine; protected: vector sessions; @@ -141,7 +144,7 @@ public: map properties; Session * SessionExists(SessionID session); - void AddSession(Session *s); + Day *AddSession(Session *s,Profile *p); void SetClass(wxString t) { m_class=t; diff --git a/libs/sleeplib/profiles.cpp b/libs/sleeplib/profiles.cpp index 22ebcc1e..acd04ba6 100644 --- a/libs/sleeplib/profiles.cpp +++ b/libs/sleeplib/profiles.cpp @@ -22,12 +22,15 @@ Preferences *p_pref; Preferences *p_layout; Profile::Profile() +:Preferences(),is_first_day(true) { p_name=wxT("Profile"); p_path=pref.Get("{home}{sep}Profiles"); machlist.clear(); + m_first=m_last=wxInvalidDateTime; } Profile::Profile(wxString path) +:Preferences(),is_first_day(true) { const wxString xmlext=wxT(".xml"); p_name=wxT("Profile"); @@ -38,6 +41,7 @@ Profile::Profile(wxString path) if (!p_path.EndsWith(sep)) p_path+=sep; p_filename=p_path+p_name+xmlext; machlist.clear(); + m_first=m_last=wxInvalidDateTime; } Profile::~Profile() @@ -119,6 +123,18 @@ TiXmlElement * Profile::ExtraSave() } +void Profile::AddDay(wxDateTime date,Day *day) { + //date+=wxTimeSpan::Day(); + if (is_first_day) { + m_first=m_last=date; + is_first_day=false; + } + if (m_first>date) m_first=date; + if (m_last machlist; void AddMachine(Machine *m); void LoadMachineData(); void Import(wxString path); + + void AddDay(wxDateTime date,Day *day); + vector GetMachines(MachineType t); Machine * GetMachine(MachineType t,wxDateTime date); virtual void ExtraLoad(TiXmlHandle *root); virtual TiXmlElement * ExtraSave(); + map > daylist; + const wxDateTime & FirstDay() { return m_first; }; + const wxDateTime & LastDay() { return m_last; }; + +protected: + wxDateTime m_first,m_last; + }; extern Preferences *p_pref; diff --git a/libs/sleeplib/prs1_loader.cpp b/libs/sleeplib/prs1_loader.cpp index 998dcaba..a0659a00 100644 --- a/libs/sleeplib/prs1_loader.cpp +++ b/libs/sleeplib/prs1_loader.cpp @@ -127,7 +127,7 @@ bool PRS1Loader::Open(wxString & path,Profile *profile) wxString s=*sn; m=CreateMachine(s,profile); - if (m) OpenMachine(m,newpath+wxFileName::GetPathSeparator()+(*sn)); + if (m) OpenMachine(m,newpath+wxFileName::GetPathSeparator()+(*sn),profile); } return PRS1List.size(); @@ -174,7 +174,7 @@ bool PRS1Loader::ParseProperties(Machine *m,wxString filename) return true; } -int PRS1Loader::OpenMachine(Machine *m,wxString path) +int PRS1Loader::OpenMachine(Machine *m,wxString path,Profile *profile) { wxLogDebug(wxT("Opening PRS1 ")+path); @@ -267,18 +267,17 @@ int PRS1Loader::OpenMachine(Machine *m,wxString path) wxLogWarning(wxT("PRS1Loader: Couldn't open event file ")+s->second[1]); } } - const double ignore_thresh=300.0/3600.0;// Ignore useless sessions under 5 minute - if (sess->hours()<=ignore_thresh) { - delete sess; - continue; - } - m->AddSession(sess); - if (!s->second[2].IsEmpty()) { if (!OpenWaveforms(sess,s->second[2])) { wxLogWarning(wxT("PRS1Loader: Couldn't open event file ")+s->second[2]); } } + const double ignore_thresh=300.0/3600.0;// Ignore useless sessions under 5 minute + if (sess->hours()<=ignore_thresh) { + delete sess; + continue; + } + m->AddSession(sess,profile); if (sess->summary.find(CPAP_Obstructive)!=sess->summary.end()) { sess->summary[CPAP_Obstructive]=(long)sess->count_events(CPAP_Obstructive); @@ -309,14 +308,25 @@ int PRS1Loader::OpenMachine(Machine *m,wxString path) sess->summary[BIPAP_EAPAverage]=sess->weighted_avg_event_field(CPAP_EAP,0); sess->summary[BIPAP_EAPMin]=sess->min_event_field(CPAP_EAP,0); sess->summary[BIPAP_EAPMax]=sess->max_event_field(CPAP_EAP,0); - } else { sess->summary[CPAP_PressureMedian]=sess->avg_event_field(CPAP_Pressure,0); sess->summary[CPAP_PressureAverage]=sess->weighted_avg_event_field(CPAP_Pressure,0); sess->summary[CPAP_PressureMinAchieved]=sess->min_event_field(CPAP_Pressure,0); sess->summary[CPAP_PressureMaxAchieved]=sess->max_event_field(CPAP_Pressure,0); + if (sess->summary.find(CPAP_PressureMin)==sess->summary.end()) { + sess->summary[CPAP_BrokenSummary]=true; + sess->set_last(sess->first()); + if (sess->summary[CPAP_PressureMinAchieved]==sess->summary[CPAP_PressureMaxAchieved]) { + sess->summary[CPAP_Mode]=(long)MODE_CPAP; + } else { + sess->summary[CPAP_Mode]=(long)MODE_UNKNOWN; + } + sess->summary[CPAP_PressureReliefType]=(long)PR_UNKNOWN; + } + } + sess->summary[CPAP_LeakMinimum]=sess->min_event_field(CPAP_Leak,0); sess->summary[CPAP_LeakMaximum]=sess->max_event_field(CPAP_Leak,0); // should be merged.. sess->summary[CPAP_LeakMedian]=sess->avg_event_field(CPAP_Leak,0); @@ -358,8 +368,7 @@ bool PRS1Loader::OpenSummary(Session *session,wxString filename) if (ext!=1) return false; - if (size<0x30) - return false; + //size|=(header[3]<<16) | (header[4]<<24); // the jury is still out on the 32bitness of one. doesn't matter here anyway. size-=(hl+2); @@ -368,6 +377,11 @@ bool PRS1Loader::OpenSummary(Session *session,wxString filename) if (sum!=header[hl-1]) return false; + if (size<=19) { + wxLogWarning(wxT("Ignoring short session file ")+filename); + return false; + } + wxDateTime date(timestamp); //wxDateTime tmpdate=date; //wxLogMessage(date.Format()+wxT(" UTC=")+tmpdate.Format()); @@ -381,6 +395,8 @@ bool PRS1Loader::OpenSummary(Session *session,wxString filename) if (brset_first(date); session->set_last(date); diff --git a/libs/sleeplib/prs1_loader.h b/libs/sleeplib/prs1_loader.h index f592ace2..d1b144d7 100644 --- a/libs/sleeplib/prs1_loader.h +++ b/libs/sleeplib/prs1_loader.h @@ -37,7 +37,7 @@ public: protected: wxString last; map PRS1List; - int OpenMachine(Machine *m,wxString path); + int OpenMachine(Machine *m,wxString path,Profile *profile); bool ParseProperties(Machine *m,wxString filename); bool OpenSummary(Session *session,wxString filename); bool OpenEvents(Session *session,wxString filename); diff --git a/version.h b/version.h index e2dce237..eb674661 100644 --- a/version.h +++ b/version.h @@ -16,14 +16,14 @@ namespace AutoVersion{ //Standard Version Type static const long MAJOR = 0; static const long MINOR = 7; - static const long BUILD = 1951; - static const long REVISION = 5273; + static const long BUILD = 2233; + static const long REVISION = 6877; //Miscellaneous Version Types - static const long BUILDS_COUNT = 6389; - #define RC_FILEVERSION 0,7,1951,5273 - #define RC_FILEVERSION_STRING "0, 7, 1951, 5273\0" - static const char FULLVERSION_STRING[] = "0.7.1951.5273"; + static const long BUILDS_COUNT = 7025; + #define RC_FILEVERSION 0,7,2233,6877 + #define RC_FILEVERSION_STRING "0, 7, 2233, 6877\0" + static const char FULLVERSION_STRING[] = "0.7.2233.6877"; //These values are to keep track of your versioning state, don't modify them. static const long BUILD_HISTORY = 62;
")+_("Machine Information")+wxT("
")+machine->properties[wxT("Brand")]+wxT("
")+machine->properties[wxT("Model")]+wxT(" ")+machine->properties[wxT("ModelNumber")]+submodel+wxT("
")+d->machine->properties[wxT("Brand")]+wxT("
")+d->machine->properties[wxT("Model")]+wxT(" ")+d->machine->properties[wxT("ModelNumber")]+submodel+wxT("
")+d->machine->properties[wxT("Serial")]+wxT("
  
")+_("Sleep Times")+wxT("
")+_("Date")+wxT("")+machine->day[day]->first().Format(wxT("%x"))+wxT("
")+_("Sleep")+wxT("")+machine->day[day]->first().Format(wxT("%H:%M"))+wxT("
")+_("Wake")+wxT("")+machine->day[day]->last().Format(wxT("%H:%M"))+wxT("
")+_("Total Time")+wxT("")+machine->day[day]->total_time().Format(wxT("%H:%M hours"))+wxT("
")+_("Date")+wxT("")+d->first().Format(wxT("%x"))+wxT("
")+_("Sleep")+wxT("")+d->first().Format(wxT("%H:%M"))+wxT("
")+_("Wake")+wxT("")+d->last().Format(wxT("%H:%M"))+wxT("
")+_("Total Time")+wxT("")+d->total_time().Format(wxT("%H:%M hours"))+wxT("
  
")+_("Indices")+wxT("
")+_("AHI")+wxT("")+wxString::Format(wxT("%0.2f"),ahi)+wxT("
")+_("Avg Leak")+wxT("")+wxString::Format(wxT("%.2f"),d->summary_avg(CPAP_LeakAverage))+wxT("
  
")+_("System Settings")+wxT("
")+_("Pressure")+wxT("")+wxString::Format(wxT("%.1fcmH2O"),d->summary_min(CPAP_PressureMin))+wxT("
")+_("Min Pressure")+wxT("")+wxString::Format(wxT("%.1fcmH2O"),d->summary_min(CPAP_PressureMin))+wxT("
")+_("Max Pressure")+wxT("")+wxString::Format(wxT("%.1fcmH2O"),d->summary_max(CPAP_PressureMax))+wxT("
")+_("IPAP Pressure")+wxT("")+wxString::Format(wxT("%.1fcmH2O"),d->summary_min(CPAP_PressureMin))+wxT("
")+_("EPAP Pressure")+wxT("")+wxString::Format(wxT("%.1fcmH2O"),d->summary_max(CPAP_PressureMax))+wxT("
")+_("No System Settings Recorded")+wxT("
")+_("System Settings")+wxT("
")+_("Pressure")+wxT("")+wxString::Format(wxT("%.1fcmH2O"),d->summary_min(CPAP_PressureMin))+wxT("
")+_("Min Pressure")+wxT("")+wxString::Format(wxT("%.1fcmH2O"),d->summary_min(CPAP_PressureMin))+wxT("
")+_("Max Pressure")+wxT("")+wxString::Format(wxT("%.1fcmH2O"),d->summary_max(CPAP_PressureMax))+wxT("
")+_("IPAP Pressure")+wxT("")+wxString::Format(wxT("%.1fcmH2O"),d->summary_min(CPAP_PressureMin))+wxT("
")+_("EPAP Pressure")+wxT("")+wxString::Format(wxT("%.1fcmH2O"),d->summary_max(CPAP_PressureMax))+wxT("
")+_("Ramp-Time")+wxT("")+wxString::Format(wxT("%imin"),(int)d->summary_max(CPAP_RampTime))+wxT("
")+_("Ramp-Prs.")+wxT("")+wxString::Format(wxT("%.1fcmH2O"),d->summary_min(CPAP_RampStartingPressure))+wxT("
")+_("Humidifier")+wxT("")+str+wxT("
")+_("System-Lock")+wxT("")+(bool(d->summary_max(PRS1_SystemLockStatus)) ? _("On") : _("Off"))+wxT("
")+_("Auto-Off")+wxT("")+(bool(d->summary_max(PRS1_AutoOff)) ? _("On") : _("Off"))+wxT("
")+_("Mask-Alert")+wxT("")+(bool(d->summary_max(PRS1_MaskAlert)) ? _("On") : _("Off"))+wxT("
")+_("Show-AHI")+wxT("")+(bool(d->summary_max(PRS1_ShowAHI)) ? _("On") : _("Off"))+wxT("
")+_("Hose-Size")+wxT("")+(bool(d->summary_max(PRS1_HoseDiameter)) ? _("22mm") : _("15mm"))+wxT("
")+_("Sys-Resist.")+wxT("")+str+wxT("
")+_("Ramp-Time")+wxT("")+wxString::Format(wxT("%imin"),(int)d->summary_max(CPAP_RampTime))+wxT("
")+_("Ramp-Prs.")+wxT("")+wxString::Format(wxT("%.1fcmH2O"),d->summary_min(CPAP_RampStartingPressure))+wxT("
")+_("Humidifier")+wxT("")+str+wxT("
")+_("System-Lock")+wxT("")+(bool(d->summary_max(PRS1_SystemLockStatus)) ? _("On") : _("Off"))+wxT("
")+_("Auto-Off")+wxT("")+(bool(d->summary_max(PRS1_AutoOff)) ? _("On") : _("Off"))+wxT("
")+_("Mask-Alert")+wxT("")+(bool(d->summary_max(PRS1_MaskAlert)) ? _("On") : _("Off"))+wxT("
")+_("Show-AHI")+wxT("")+(bool(d->summary_max(PRS1_ShowAHI)) ? _("On") : _("Off"))+wxT("
")+_("Hose-Size")+wxT("")+(bool(d->summary_max(PRS1_HoseDiameter)) ? _("22mm") : _("15mm"))+wxT("
")+_("Sys-Resist.")+wxT("")+str+wxT("
  
")+_("Session Files")+wxT("