Removed the last of C++0x

This commit is contained in:
Mark Watkins 2011-06-02 15:18:25 +10:00
parent cd3ec94fe6
commit ae2cb136b7
7 changed files with 159 additions and 105 deletions

View File

@ -7815,7 +7815,7 @@
<wx/datectrl.h>
<wx/dateevt.h>
1306810322 source:/home/mark/projects/git/sleepyhead/SleepyHeadApp.cpp
1306990964 source:/home/mark/projects/git/sleepyhead/SleepyHeadApp.cpp
"wx_pch.h"
<iostream>
<wx/log.h>
@ -7838,7 +7838,7 @@
"sleeplib/machine.h"
"graphs/graph.h"
1306984890 /home/mark/projects/git/sleepyhead/libs/sleeplib/machine.h
1306991807 /home/mark/projects/git/sleepyhead/libs/sleeplib/machine.h
<wx/string.h>
<wx/variant.h>
<wx/dir.h>
@ -7876,7 +7876,7 @@
<sleeplib/machine.h>
<list>
1306989702 /home/mark/projects/git/sleepyhead/version.h
1306991808 /home/mark/projects/git/sleepyhead/version.h
1306724655 /home/mark/projects/git/sleepyhead/libs/sleeplib/prs1_loader.h
"machine.h"
@ -7927,7 +7927,7 @@
<wx/ffile.h>
<wx/utils.h>
1306988397 source:/home/mark/projects/git/sleepyhead/libs/sleeplib/machine.cpp
1306991808 source:/home/mark/projects/git/sleepyhead/libs/sleeplib/machine.cpp
<tr1/random>
<wx/colour.h>
<wx/log.h>
@ -7948,7 +7948,7 @@
<wx/stdpaths.h>
"preferences.h"
1306989333 source:/home/mark/projects/git/sleepyhead/libs/sleeplib/profiles.cpp
1306990963 source:/home/mark/projects/git/sleepyhead/libs/sleeplib/profiles.cpp
<wx/filefn.h>
<wx/filename.h>
<wx/utils.h>
@ -7960,7 +7960,7 @@
"machine_loader.h"
"tinyxml/tinyxml.h"
1306989439 source:/home/mark/projects/git/sleepyhead/libs/sleeplib/prs1_loader.cpp
1306991577 source:/home/mark/projects/git/sleepyhead/libs/sleeplib/prs1_loader.cpp
<wx/dir.h>
<wx/filename.h>
<wx/ffile.h>

View File

@ -42,6 +42,7 @@ bool SleepyHeadApp::OnInit()
wxInitAllImageHandlers();
//wxDateTime::SetCountry(wxDateTime::USA);
SetAppName(_("SleepyHead"));
PRS1Loader::Register();
Profiles::Scan();

View File

@ -12,54 +12,29 @@ extern wxProgressDialog *loader_progress;
map<MachineID,Machine *> MachList;
map<MachineType,wxString> MachineTypeString= {
/*map<MachineType,wxString> MachineTypeString= {
{MT_UNKNOWN, wxT("Unknown")},
{MT_CPAP, wxT("CPAP")},
{MT_OXIMETER, wxT("Oximeter")},
{MT_SLEEPSTAGE, wxT("SleepStage")}
};
}; */
map<wxString,MachineType> MachineTypeLookup= {
/*map<wxString,MachineType> MachineTypeLookup= {
{ MachineTypeString[MT_UNKNOWN].Lower(), MT_UNKNOWN },
{ MachineTypeString[MT_CPAP].Lower(), MT_CPAP },
{ MachineTypeString[MT_OXIMETER].Lower(), MT_OXIMETER },
{ MachineTypeString[MT_SLEEPSTAGE].Lower(), MT_SLEEPSTAGE}
};
// This is technically gui related.. however I have something in mind for it.
const map<MachineCode,FlagType> DefaultFlagTypes= {
{CPAP_Obstructive, FT_BAR},
{CPAP_Hypopnea, FT_BAR},
{CPAP_RERA, FT_BAR},
{CPAP_VSnore, FT_BAR},
{PRS1_VSnore2, FT_BAR},
{CPAP_FlowLimit, FT_BAR},
{CPAP_ClearAirway, FT_BAR},
{CPAP_CSR, FT_SPAN},
{PRS1_PressurePulse,FT_DOT},
{CPAP_Pressure, FT_DOT}
};
const unsigned char flagalpha=0x80;
const map<MachineCode,wxColour> DefaultFlagColours= {
{CPAP_Obstructive, wxColour(0x80,0x80,0xff,flagalpha)},
{CPAP_Hypopnea, wxColour(0x00,0x00,0xff,flagalpha)},
{CPAP_RERA, wxColour(0x40,0x80,0xff,flagalpha)},
{CPAP_VSnore, wxColour(0xff,0x20,0x20,flagalpha)},
{CPAP_FlowLimit, wxColour(0x20,0x20,0x20,flagalpha)},
{CPAP_ClearAirway, wxColour(0xff,0x40,0xff,flagalpha)},
{CPAP_CSR, wxColour(0x40,0xff,0x40,flagalpha)},
{PRS1_VSnore2, wxColour(0xff,0x20,0x20,flagalpha)},
{PRS1_PressurePulse,wxColour(0xff,0x40,0xff,flagalpha)}
};
map<CPAPMode,wxString> CPAPModeNames={
}; */
map<CPAPMode,wxString> CPAPModeNames;
/*={
{MODE_UNKNOWN,wxT("Undetermined")},
{MODE_CPAP,wxT("CPAP")},
{MODE_APAP,wxT("APAP")},
{MODE_BIPAP,wxT("BIPAP")},
{MODE_ASV,wxT("ASV")}
};
map<PRTypes,wxString> PressureReliefNames={
};*/
map<PRTypes,wxString> PressureReliefNames;
/*={
{PR_UNKNOWN,_("Undetermined")},
{PR_NONE,_("None")},
{PR_CFLEX,wxT("C-Flex")},
@ -68,10 +43,13 @@ map<PRTypes,wxString> PressureReliefNames={
{PR_BIFLEX,wxT("Bi-Flex")},
{PR_EPR,wxT("Exhalation Pressure Relief (EPR)")},
{PR_SMARTFLEX,wxT("SmartFlex")}
};
}; */
// Master list. Look up local name table first.. then these if not found.
map<MachineCode,wxString> DefaultMCShortNames= {
map<MachineCode,wxString> DefaultMCShortNames;
/*= {
{CPAP_Obstructive, wxT("OA")},
{CPAP_Hypopnea, wxT("H")},
{CPAP_RERA, wxT("RE")},
@ -102,8 +80,71 @@ map<MachineCode,wxString> DefaultMCLongNames= {
{CPAP_IAP, wxT("BIPAP Inhalation Pressure")},
{PRS1_VSnore2, wxT("Vibratory Snore")},
{PRS1_PressurePulse,wxT("Pressue Pulse")}
}; */
void InitMapsWithoutAwesomeInitializerLists()
{
CPAPModeNames[MODE_UNKNOWN]=wxT("Undetermined");
CPAPModeNames[MODE_CPAP]=wxT("CPAP");
CPAPModeNames[MODE_APAP]=wxT("APAP");
CPAPModeNames[MODE_BIPAP]=wxT("BIPAP");
CPAPModeNames[MODE_ASV]=wxT("ASV");
PressureReliefNames[PR_UNKNOWN]=_("Undetermined");
PressureReliefNames[PR_NONE]=_("None");
PressureReliefNames[PR_CFLEX]=wxT("C-Flex");
PressureReliefNames[PR_CFLEXPLUS]=wxT("C-Flex+");
PressureReliefNames[PR_AFLEX]=wxT("A-Flex");
PressureReliefNames[PR_BIFLEX]=wxT("Bi-Flex");
PressureReliefNames[PR_EPR]=wxT("Exhalation Pressure Relief (EPR)");
PressureReliefNames[PR_SMARTFLEX]=wxT("SmartFlex");
DefaultMCShortNames[CPAP_Obstructive]=wxT("OA");
DefaultMCShortNames[CPAP_Hypopnea]=wxT("H");
DefaultMCShortNames[CPAP_RERA]=wxT("RE");
DefaultMCShortNames[CPAP_ClearAirway]=wxT("CA");
DefaultMCShortNames[CPAP_CSR]=wxT("CSR");
DefaultMCShortNames[CPAP_VSnore]=wxT("VS");
DefaultMCShortNames[CPAP_FlowLimit]=wxT("FL");
DefaultMCShortNames[CPAP_Pressure]=wxT("P");
DefaultMCShortNames[CPAP_Leak]=wxT("LR");
DefaultMCShortNames[CPAP_EAP]=wxT("EAP");
DefaultMCShortNames[CPAP_IAP]=wxT("IAP");
DefaultMCShortNames[PRS1_VSnore2]=wxT("VS");
DefaultMCShortNames[PRS1_PressurePulse]=wxT("PP");
}
// This is technically gui related.. however I have something in mind for it.
/*const map<MachineCode,FlagType> DefaultFlagTypes= {
{CPAP_Obstructive, FT_BAR},
{CPAP_Hypopnea, FT_BAR},
{CPAP_RERA, FT_BAR},
{CPAP_VSnore, FT_BAR},
{PRS1_VSnore2, FT_BAR},
{CPAP_FlowLimit, FT_BAR},
{CPAP_ClearAirway, FT_BAR},
{CPAP_CSR, FT_SPAN},
{PRS1_PressurePulse,FT_DOT},
{CPAP_Pressure, FT_DOT}
};
const unsigned char flagalpha=0x80;
const map<MachineCode,wxColour> DefaultFlagColours= {
{CPAP_Obstructive, wxColour(0x80,0x80,0xff,flagalpha)},
{CPAP_Hypopnea, wxColour(0x00,0x00,0xff,flagalpha)},
{CPAP_RERA, wxColour(0x40,0x80,0xff,flagalpha)},
{CPAP_VSnore, wxColour(0xff,0x20,0x20,flagalpha)},
{CPAP_FlowLimit, wxColour(0x20,0x20,0x20,flagalpha)},
{CPAP_ClearAirway, wxColour(0xff,0x40,0xff,flagalpha)},
{CPAP_CSR, wxColour(0x40,0xff,0x40,flagalpha)},
{PRS1_VSnore2, wxColour(0xff,0x20,0x20,flagalpha)},
{PRS1_PressurePulse,wxColour(0xff,0x40,0xff,flagalpha)}
}; */
//////////////////////////////////////////////////////////////////////////////////////////
// Machine Base-Class implmementation
//////////////////////////////////////////////////////////////////////////////////////////
@ -611,14 +652,12 @@ void Day::OpenWaveforms()
//////////////////////////////////////////////////////////////////////////////////////////
// Event implmementation
//////////////////////////////////////////////////////////////////////////////////////////
Event::Event(wxDateTime time,MachineCode code,list<EventDataType> data)
Event::Event(wxDateTime time,MachineCode code, EventDataType * data, int fields)
:e_time(time),e_code(code)
{
e_fields=0;
list<EventDataType>::iterator i;
for (i=data.begin(); i!=data.end(); i++) {
e_data.push_back(*i);
e_fields++;
e_fields=fields;
for (int i=0; i<fields; i++) {
e_data.push_back(data[i]);
}
}
@ -651,7 +690,7 @@ CPAP::CPAP(Profile *p,MachineID id):Machine(p,id)
{
m_type=MT_CPAP;
FlagColours=DefaultFlagColours;
// FlagColours=DefaultFlagColours;
}
CPAP::~CPAP()
@ -1226,12 +1265,12 @@ bool Session::LoadEvents(wxString filename)
if (!f.Unpack(i16)) throw UnpackError(); // Time Delta
d+=wxTimeSpan::Seconds(i16);
}
list<EventDataType> ED;
EventDataType ED[max_number_event_fields];
for (int c=0; c<mcfields[mc]; c++) {
if (!f.Unpack(fl)); //throw UnpackError(); // Data Fields in float format
ED.push_back(fl);
ED[c]=fl;
}
Event *ev=new Event(d,mc,ED);
Event *ev=new Event(d,mc,ED,mcfields[mc]);
AddEvent(ev);
}

View File

@ -28,14 +28,17 @@ typedef long SessionID;
class BoundsError {};
enum MachineType: short { MT_UNKNOWN=0,MT_CPAP,MT_OXIMETER,MT_SLEEPSTAGE };
const int max_number_event_fields=10;
enum MachineType//: short
{ MT_UNKNOWN=0,MT_CPAP,MT_OXIMETER,MT_SLEEPSTAGE };
// I wish C++ could extend enums.
// Could be implimented by MachineLoader's register function requesting a block of integer space,
// and a map to name strings.
// Be cautious when extending these.. add to the end of each groups to preserve file formats.
enum MachineCode:
wxInt16 {
enum MachineCode//:wxInt16
{
// General Event Codes
CPAP_Obstructive=0, CPAP_Hypopnea, CPAP_ClearAirway, CPAP_RERA, CPAP_VSnore, CPAP_FlowLimit,
CPAP_Leak, CPAP_Pressure, CPAP_EAP, CPAP_IAP, CPAP_CSR, CPAP_FlowRate,
@ -55,16 +58,17 @@ wxInt16 {
PRS1_SystemLockStatus, PRS1_SystemResistanceStatus, PRS1_SystemResistanceSetting, PRS1_HoseDiameter, PRS1_AutoOff, PRS1_MaskAlert, PRS1_ShowAHI,
};
void InitMapsWithoutAwesomeInitializerLists();
enum FlagType:
short { FT_BAR, FT_DOT, FT_SPAN };
enum FlagType//:short
{ FT_BAR, FT_DOT, FT_SPAN };
enum CPAPMode:
short {
enum CPAPMode//:short
{
MODE_UNKNOWN=0,MODE_CPAP,MODE_APAP,MODE_BIPAP,MODE_ASV
};
enum PRTypes:
short {
enum PRTypes//:short
{
PR_UNKNOWN=0,PR_NONE,PR_CFLEX,PR_CFLEXPLUS,PR_AFLEX,PR_BIFLEX,PR_EPR,PR_SMARTFLEX
};
@ -73,8 +77,8 @@ extern map<PRTypes,wxString> PressureReliefNames;
extern map<CPAPMode,wxString> CPAPModeNames;
// These are types supported by wxVariant class. To retain compatability, add to the end of this list only..
enum MCDataType:
wxInt8 { MC_bool=0, MC_long, MC_float, MC_double, MC_string, MC_datetime };
enum MCDataType//:wxInt8
{ MC_bool=0, MC_long, MC_float, MC_double, MC_string, MC_datetime };
typedef wxInt16 SampleFormat;
typedef float EventDataType;
@ -196,7 +200,7 @@ class Event
{
friend class Session;
public:
Event(wxDateTime time,MachineCode code,list<EventDataType> data);
Event(wxDateTime time,MachineCode code,EventDataType * data,int fields);
~Event();
const EventDataType operator[](short i) {
if (i<e_fields) return e_data[i];

View File

@ -235,6 +235,8 @@ Profile *Get()
void Scan()
{
InitMapsWithoutAwesomeInitializerLists();
p_pref=new Preferences(wxT("Preferences"));
p_layout=new Preferences(wxT("Layout"));

View File

@ -22,11 +22,7 @@ License: GPL
extern wxProgressDialog *loader_progress;
map<int,wxString> ModelMap= {
{34,wxT("RemStar Pro with C-Flex+")},
{35,wxT("RemStar Auto with A-Flex")},
{37,wxT("RemStar BIPAP Auto with Bi-Flex")}
};
map<int,wxString> ModelMap;
PRS1::PRS1(Profile *p,MachineID id):CPAP(p,id)
{
@ -34,7 +30,7 @@ PRS1::PRS1(Profile *p,MachineID id):CPAP(p,id)
properties[wxT("Brand")]=wxT("Philips Respironics");
properties[wxT("Model")]=wxT("System One");
SleepFlags= { CPAP_RERA, PRS1_VSnore2, CPAP_FlowLimit, CPAP_Hypopnea, CPAP_Obstructive, CPAP_ClearAirway, CPAP_CSR };
//SleepFlags= { CPAP_RERA, PRS1_VSnore2, CPAP_FlowLimit, CPAP_Hypopnea, CPAP_Obstructive, CPAP_ClearAirway, CPAP_CSR };
}
PRS1::~PRS1()
{
@ -469,11 +465,15 @@ bool PRS1Loader::OpenSummary(Session *session,wxString filename)
bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,time_t timestamp)
{
vector<MachineCode> Codes= {
MachineCode Codes[]={
PRS1_Unknown00, PRS1_Unknown01, CPAP_Pressure, CPAP_EAP, PRS1_PressurePulse, CPAP_RERA, CPAP_Obstructive, CPAP_ClearAirway,
PRS1_Unknown08, PRS1_Unknown09, CPAP_Hypopnea, PRS1_Unknown0B, CPAP_FlowLimit, CPAP_VSnore, PRS1_Unknown0E, CPAP_CSR, PRS1_Unknown10,
CPAP_Leak, PRS1_Unknown12
};
int ncodes=sizeof(Codes)/sizeof(MachineCode);
EventDataType data[4];
wxDateTime start;
start.Set(timestamp);
wxDateTime t=start;
@ -496,12 +496,12 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,time_t
case 0x00: // Unknown
case 0x01: // Unknown
case 0x02: // Pressure
data0=buffer[pos++]/10.0;
session->AddEvent(new Event(t,cpapcode, {data0}));
data[0]=buffer[pos++]/10.0;
session->AddEvent(new Event(t,cpapcode, data,1));
break;
case 0x04: // Pressure Pulse
data0=buffer[pos++];
session->AddEvent(new Event(t,cpapcode, {data0}));
data[0]=buffer[pos++];
session->AddEvent(new Event(t,cpapcode, data,1));
break;
case 0x05: // RERA
@ -510,50 +510,50 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,time_t
case 0x0a: // Hypopnea
case 0x0c: // Flow Limitation
tt-=wxTimeSpan::Seconds((buffer[pos++])); // Subtract Time Offset
session->AddEvent(new Event(tt,cpapcode, {}));
session->AddEvent(new Event(tt,cpapcode,data,0));
break;
case 0x0d: // Vibratory Snore
session->AddEvent(new Event(t,cpapcode, {}));
session->AddEvent(new Event(t,cpapcode, data,0));
break;
case 0x03: // BIPAP Pressure
case 0x0b: // Unknown
case 0x11: // Leak Rate
data0=buffer[pos++];
data1=buffer[pos++];
data[0]=buffer[pos++];
data[1]=buffer[pos++];
if (code==0x11) {
session->AddEvent(new Event(t,cpapcode, {data0}));
if (data1>0) {
session->AddEvent(new Event(tt,PRS1_VSnore2, {data1}));
session->AddEvent(new Event(t,cpapcode, data,1));
if (data[1]>0) {
session->AddEvent(new Event(tt,PRS1_VSnore2, &data[1],1));
}
} else if (code==0x03) {
data0/=10.0;
data1/=10.0;
session->AddEvent(new Event(t,CPAP_EAP, {data1}));
session->AddEvent(new Event(t,CPAP_IAP, {data0}));
data[0]/=10.0;
data[1]/=10.0;
session->AddEvent(new Event(t,CPAP_EAP, &data[1], 1));
session->AddEvent(new Event(t,CPAP_IAP, data, 1));
} else {
session->AddEvent(new Event(t,cpapcode, {data0,data1}));
session->AddEvent(new Event(t,cpapcode, data, 2));
}
break;
case 0x0e: // Unknown
case 0x10: // Unknown
data0=buffer[pos++];
data1=buffer[pos++];
data2=buffer[pos++];
session->AddEvent(new Event(t,cpapcode, {data0,data1,data2}));
data[0]=buffer[pos++];
data[1]=buffer[pos++];
data[2]=buffer[pos++];
session->AddEvent(new Event(t,cpapcode, data, 3));
break;
case 0x0f: // Cheyne Stokes Respiration
data0=buffer[pos+1]<<8 | buffer[pos];
data[0]=buffer[pos+1]<<8 | buffer[pos];
pos+=2;
data1=buffer[pos++];
data[1]=buffer[pos++];
tt-=wxTimeSpan::Seconds(data1);
session->AddEvent(new Event(tt,cpapcode, {data0,data1}));
session->AddEvent(new Event(tt,cpapcode, data, 2));
break;
case 0x12: // Summary
data0=buffer[pos++];
data1=buffer[pos++];
data2=buffer[pos+1]<<8 | buffer[pos];
data[0]=buffer[pos++];
data[1]=buffer[pos++];
data[2]=buffer[pos+1]<<8 | buffer[pos];
pos+=2;
session->AddEvent(new Event(t,cpapcode, {data0,data1,data2}));
session->AddEvent(new Event(t,cpapcode, data,3));
break;
default:
// ERROR!!!
@ -729,6 +729,13 @@ bool PRS1Loader::OpenWaveforms(Session *session,wxString filename)
return true;
}
void InitModelMap()
{
ModelMap[34]=wxT("RemStar Pro with C-Flex+");
ModelMap[35]=wxT("RemStar Auto with A-Flex");
ModelMap[37]=wxT("RemStar BIPAP Auto with Bi-Flex");
};
bool initialized=false;
void PRS1Loader::Register()
@ -736,6 +743,7 @@ void PRS1Loader::Register()
if (initialized) return;
wxLogVerbose(wxT("Registering PRS1Loader"));
RegisterLoader(new PRS1Loader());
InitModelMap();
initialized=true;
}

View File

@ -16,14 +16,14 @@ namespace AutoVersion{
//Standard Version Type
static const long MAJOR = 0;
static const long MINOR = 7;
static const long BUILD = 2786;
static const long REVISION = 9853;
static const long BUILD = 2807;
static const long REVISION = 9954;
//Miscellaneous Version Types
static const long BUILDS_COUNT = 8265;
#define RC_FILEVERSION 0,7,2786,9853
#define RC_FILEVERSION_STRING "0, 7, 2786, 9853\0"
static const char FULLVERSION_STRING[] = "0.7.2786.9853";
static const long BUILDS_COUNT = 8303;
#define RC_FILEVERSION 0,7,2807,9954
#define RC_FILEVERSION_STRING "0, 7, 2807, 9954\0"
static const char FULLVERSION_STRING[] = "0.7.2807.9954";
//These values are to keep track of your versioning state, don't modify them.
static const long BUILD_HISTORY = 62;