#include #include #include #include #include #include #include #include #include #include #include #include Aladin::Aladin() : mIsOkay(false) { mRawData.size(2046); } Aladin::~Aladin() { } bool Aladin::openRaw(const String &strPathFileName) { BYTE header[4]; FileHandle inFile; if(!inFile.open(strPathFileName,FileHandle::Read,FileHandle::ShareRead,FileHandle::Open,FileHandle::Normal))return false; if(inFile.size()!=mRawData.size()+sizeof(header))return false; if(!inFile.read(header,sizeof(header)))return false; if(::memcmp(header,"UUU\0",sizeof(header)))return false; if(!inFile.read(&mRawData[0],mRawData.size()))return false; mIsOkay=readRaw(mRawData); return mIsOkay; } bool Aladin::openLog(const String &strPathFileName) { File inFile; char header[]={'L','O','G','1'}; char rdHeader[sizeof(header)]; if(!inFile.open(strPathFileName,"rb"))return false; if(!inFile.read(&rdHeader,sizeof(rdHeader)))return false; if(::memcmp(rdHeader,header,sizeof(rdHeader)))return false; if(!mStatus.readFrom(inFile))return false; if(!mInformation.readFrom(inFile))return false; if(!mLogBook.readFrom(inFile))return false; if(!mProfiles.readFrom(inFile))return false; inFile.close(); mIsOkay=true; return true; } bool Aladin::openDevice(const String &port,GUIWindow &parent) { DeviceControlBlock dcb; CommControl control; String strCommState; AppReg appReg; Block iconNames; mIsOkay=false; if(IDCANCEL==::MessageBox(parent,"Place computer in Log Book mode and press OK to continue.","Prompt",MB_OKCANCEL))return false; if(port.isNull())return false; if(!control.open(CommControl::stringToPort(port)))return false; strCommState+=String("baud=")+appReg.getBaud()+String(" "); strCommState+=String("parity=")+appReg.getParity()+String(" "); strCommState+=String("data=")+appReg.getDataBits()+String(" "); strCommState+=String("stop=")+appReg.getStopBits()+String(" "); control.setDeviceControlBlock(strCommState); control.getDeviceControlBlock(dcb); dcb.dtrControl(DeviceControlBlock::DtrControlEnable); dcb.rtsControl(DeviceControlBlock::RtsControlDisable); control.setDeviceControlBlock(dcb); iconNames.insert(&String("ASM1")); iconNames.insert(&String("ASM2")); iconNames.insert(&String("ASM3")); iconNames.insert(&String("ASM4")); iconNames.insert(&String("ASM5")); iconNames.insert(&String("ASM6")); iconNames.insert(&String("ASM7")); iconNames.insert(&String("ASM8")); iconNames.insert(&String("ASM9")); iconNames.insert(&String("ASM10")); Progress progress(parent,"Sync..., (Press ESC to cancel)",iconNames); progress.range(3); progress.canCancel(true); progress.show(true); progress.setText("Performing sync-point on device..."); progress++; while(!(mIsOkay=getControlData(control,progress))) { progress.setText("Performing sync-point on device..."); progress.yieldTask(); parent.update(); if(!progress.isOkay())break; progress.reset(); progress.range(3); progress++; } progress.destroy(); ::MessageBeep(0); ::MessageBox(parent,"Please disconnect the device","Acquisition",MB_OK); dcb.dtrControl(DeviceControlBlock::DtrControlDisable); dcb.rtsControl(DeviceControlBlock::RtsControlDisable); control.setDeviceControlBlock(dcb); control.close(); if(mIsOkay)return mIsOkay=readRaw(mRawData); ::MessageBox(parent,"Capture Failed","Acquisition",MB_OK); return mIsOkay; } bool Aladin::saveRaw(const String &strPathFileName) { char header[]={'U','U','U','\0'}; File outFile; if(!outFile.open(strPathFileName,"wb"))return false; if(!outFile.write(header,sizeof(header)))return false; if(!outFile.write(&mRawData[0],mRawData.size()))return false; return true; } bool Aladin::saveText(const String &strPathFileName) { File outFile; if(!outFile.open(strPathFileName,"wb"))return false; outFile.writeLine("Entry Time Max Depth Bottom Time Surface Time Temperature (C)"); outFile.writeLine("-----------------------------------------------------------------------"); for(int index=0;index&)mProfiles)[pIndex]; outFile.writeLine(" "); outFile.writeLine(" "); outFile.writeLine(String("Profile_")+String().fromInt(pIndex+1)); outFile.writeLine("Time Depth"); for(int diveIndex=0;diveIndex &body) { if(!mStatus.readFrom(body))return false; if(!mInformation.readFrom(body))return false; if(!mProfiles.readFrom(body,mInformation,mStatus))return false; if(!mLogBook.readFrom(body,mStatus))return false; return true; } void Aladin::addDiveLog(Worksheet &worksheet,const LogBook &logBook,int startRow,int startCol) { worksheet.setAt(startRow,startCol+(5/2),"DiveLog"); worksheet.setAt(startRow,startCol,"Entry Time"); worksheet.setAt(startRow,startCol+1,"Max Depth"); worksheet.setAt(startRow,startCol+2,"Bottom Time"); worksheet.setAt(startRow,startCol+3,"Surface Time"); worksheet.setAt(startRow,startCol+4,"Temperature"); for(int index=0;index&)profiles)[pIndex]; sRow=startRow; String strTitle(String("Profile_")+String().fromInt(pIndex+1)); worksheet.setAt(sRow++,startCol,strTitle); worksheet.setAt(sRow,startCol,"Time"); worksheet.setAt(sRow++,startCol+1,"Depth"); for(int diveIndex=0;diveIndex