#include #include #include #include bool Profiles::readFrom(Array &array,Information &info,CurrentStatus &status) { int index=0; int endIndex; int time; WORD headerLength; WORD depth; BYTE warnings; BYTE decoInfo; double conversion=3.281; remove(); try { while(true) { while(Marker!=array[index]&&indexarray.size()||index>=0x5FF)break; // String string; // ::sprintf(string,"Reading profile at offset: %d (0x%08lx) %02lx,%02lx,%02lx \n",index,index,(int)array.elementAt(index),(int)array.elementAt(index+1),(int)array.elementAt(index+2)); // ::OutputDebugString(string); index++; if(info.isNitroxOnly())index+=23; else if(info.isO2())index+=24; else index+=22; time=20; insert(&DiveProfile()); DiveProfile &diveProfile=operator[](size()-1); endIndex=getNextMarkerPos(array,index); while(index>=6; depth=(int)((((double)depth*10.00/64.00)*conversion)+.5); index+=sizeof(WORD); if(index>=0x5FF)break; ProfileData profileData(depth,time,warnings); diveProfile.insert(&ProfileData(depth,time,warnings)); // ::OutputDebugString(String("Time:")+String().fromInt(time)+String(" Depth:")+String().fromInt(depth)+String("\n")); if(index>=endIndex) { index-=sizeof(WORD); break; } if(depth==0)break; if(!(time%60)) { decoInfo=array[index]; index++; } time+=20; } // ::OutputDebugString("*********************************************************\n"); } } catch(ArrayIndexOutOfBoundsException exception) { ::OutputDebugString(exception.toString()+String("\n")); return false; } return true; } int Profiles::getNextMarkerPos(Array &array,int currIndex) { while(currIndex=array.size())return array.size()-1; return currIndex; }