在此是一般的omd檔格式,除了各種量測項目需要放進去(設計成各種副程式)命名原則在此此也是特別設計的(但是在此做了馬賽克)
COmdFile1.h
#ifndef OMDFILE1_H
#define OMDFILE1_H
#include "COmdFileFactor.h"
#include "DNA.h"
#include "DnaConfig.h"
#include "debugFile.h"
class COmdFile1 : public COmdFileFactor
{
debugFile m_debugLog;
BOOL m_isOld;
public:
COmdFile1(const BOOL& old = FALSE);
virtual ~COmdFile1();
private:
void omd2txt();
void o2tW1();
void o2tW2_1();
void o2tW2_2();
void o2tD1();
void o2tD2();
void o2tD3();
//...
private:
DNA m_omdDNA;
const CString getInch() const;
void t2oDNAnRNA();
void DNA_sortable(DNA& );
void DNA_Unsortable(DNA& );
private:
void txt2omd();
void t2oHead();
void t2oW1();
void t2oWRGBD();
void t2oW2();
void t2oD1();
void t2oD2();
void t2oD3();
//...
void t2oDelDNAinEmptyRNA();
};
#endif //OMDFILE1_H
COmdFile1.cpp
o2t、t2o用這種命名會比open save更能隱喻更多資訊。
o2t指的是omd to txt,t2o指的是txt to omd,兩個方向正是讀與寫的方向。- o2t(omd to txt) = save
- t2o(txt to omd) = open
可以發現,相同的項目,檔案save時,就會混合在一起寫入,但是在檔案open時就可以一項一項的讀取。
檔案open時,在儲存到記憶體後,還要去除掉沒有存值(也就是在這個檔案中,值為 0的項目)這其實也算是沒有設計得很美的地方,不過這樣的格式,本身也不美,不具彈性。
void COmdFile1::omd2txt()
{
CString& PanelId = m_omdFileHead.oPnlID();
CString& MsrDevice = m_omdFileHead.oMsrDvc();
CString& ProbeIndex = m_omdFileHead.oPrb();
CString& ChannelId = m_omdFileHead.oCHID();
CString& LcmInch = m_omdFileHead.oInch();
m_dTxt.push_back("Panel ID\t" + PanelId +
"\tMeasurement device\t" + MsrDevice +
"\tProbe\t" + ProbeIndex +
"\tCH\t" + ChannelId +
"\tInch\t" + LcmInch + "\n");
o2tWRGB1nG1();
o2tW1nD1();
o2tD2();
o2tD3();
o2tW2_1();
o2tW2_2();
o2tD4();
o2tD5();
o2tW3();
m_fTxt.iTxtData(m_dTxt);
}
void COmdFile1::txt2omd()
{
m_fTxt.oTxtData(m_dTxt);
//檔頭
t2oHead();
//初始化裝資料的這些容器
t2oDNAnRNA();
//檔案資料
t2oWRGBD();
t2oG1();
t2oW1();
t2oW2();
t2oW3();
t2oD1();
t2oD2();
t2oD3();
t2oD4();
m_dOmd.DeleteEmptyCell();
t2oDelDNAinEmptyRNA();
m_omdFileHead.iDNA(m_omdDNA);
m_dTxt.clear();
}
讀取/儲存實作
讀取時,在此利用繼承自COmdFileFactor的「類Excel」儲存格操作介面、也可以利用CartridgeFinder做RNA的搜尋,讓程式碼可讀性加分。(在此的code也做了馬賽克)可讀性想知道的訊息:
- 讀出H8這一格存成白色9點離邊1/4,第1點的Lv值
- 將白色9點離邊1/4,第1點的Lv值找出來,回傳字串格式(sFind),排在字串的這個位置
void COmdFile1::t2oW9()
{
m_dOmd.Find("白","9","1","1/4").GetBullet().i(VluK_Lv, GetCell('H', 8) );
m_dOmd.Find("白","9","2","1/4").GetBullet().i(VluK_Lv, GetCell('I', 8) );
m_dOmd.Find("白","9","3","1/4").GetBullet().i(VluK_Lv, GetCell('J', 8) );
m_dOmd.Find("白","9","4","1/4").GetBullet().i(VluK_Lv, GetCell('H', 9) );
m_dOmd.Find("白","9","5","1/4").GetBullet().i(VluK_Lv, GetCell('I', 9) );
m_dOmd.Find("白","9","6","1/4").GetBullet().i(VluK_Lv, GetCell('J', 9) );
m_dOmd.Find("白","9","7","1/4").GetBullet().i(VluK_Lv, GetCell('H', 10) );
m_dOmd.Find("白","9","8","1/4").GetBullet().i(VluK_Lv, GetCell('I', 10) );
m_dOmd.Find("白","9","9","1/4").GetBullet().i(VluK_Lv, GetCell('J', 10) );
m_dOmd.Find("白","9","1","1/4").GetBullet().i(VluK_Sx, GetCell('N', 8) );
m_dOmd.Find("白","9","2","1/4").GetBullet().i(VluK_Sx, GetCell('O', 8) );
m_dOmd.Find("白","9","3","1/4").GetBullet().i(VluK_Sx, GetCell('P', 8) );
m_dOmd.Find("白","9","4","1/4").GetBullet().i(VluK_Sx, GetCell('N', 9) );
m_dOmd.Find("白","9","5","1/4").GetBullet().i(VluK_Sx, GetCell('O', 9) );
m_dOmd.Find("白","9","6","1/4").GetBullet().i(VluK_Sx, GetCell('P', 9) );
m_dOmd.Find("白","9","7","1/4").GetBullet().i(VluK_Sx, GetCell('N', 10) );
m_dOmd.Find("白","9","8","1/4").GetBullet().i(VluK_Sx, GetCell('O', 10) );
m_dOmd.Find("白","9","9","1/4").GetBullet().i(VluK_Sx, GetCell('P', 10) );
m_dOmd.Find("白","9","1","1/4").GetBullet().i(VluK_Sy, GetCell('T', 8) );
m_dOmd.Find("白","9","2","1/4").GetBullet().i(VluK_Sy, GetCell('U', 8) );
m_dOmd.Find("白","9","3","1/4").GetBullet().i(VluK_Sy, GetCell('V', 8) );
m_dOmd.Find("白","9","4","1/4").GetBullet().i(VluK_Sy, GetCell('T', 9) );
m_dOmd.Find("白","9","5","1/4").GetBullet().i(VluK_Sy, GetCell('U', 9) );
m_dOmd.Find("白","9","6","1/4").GetBullet().i(VluK_Sy, GetCell('V', 9) );
m_dOmd.Find("白","9","7","1/4").GetBullet().i(VluK_Sy, GetCell('T', 10) );
m_dOmd.Find("白","9","8","1/4").GetBullet().i(VluK_Sy, GetCell('U', 10) );
m_dOmd.Find("白","9","9","1/4").GetBullet().i(VluK_Sy, GetCell('V', 10) );
m_dOmd.Find("白","9","1","1/4").GetBullet().i(VluK_T, GetCell('Z' , 8) );
m_dOmd.Find("白","9","2","1/4").GetBullet().i(VluK_T, GetCell("AA", 8) );
m_dOmd.Find("白","9","3","1/4").GetBullet().i(VluK_T, GetCell("AB", 8) );
m_dOmd.Find("白","9","4","1/4").GetBullet().i(VluK_T, GetCell('Z' , 9) );
m_dOmd.Find("白","9","5","1/4").GetBullet().i(VluK_T, GetCell("AA", 9) );
m_dOmd.Find("白","9","6","1/4").GetBullet().i(VluK_T, GetCell("AB", 9) );
m_dOmd.Find("白","9","7","1/4").GetBullet().i(VluK_T, GetCell('Z' , 10) );
m_dOmd.Find("白","9","8","1/4").GetBullet().i(VluK_T, GetCell("AA", 10) );
m_dOmd.Find("白","9","9","1/4").GetBullet().i(VluK_T, GetCell("AB", 10) );
m_dOmd.Find("白","9","1","1/4").GetBullet().i(VluK_Duv, GetCell("AF", 8) );
m_dOmd.Find("白","9","2","1/4").GetBullet().i(VluK_Duv, GetCell("AG", 8) );
m_dOmd.Find("白","9","3","1/4").GetBullet().i(VluK_Duv, GetCell("AH", 8) );
m_dOmd.Find("白","9","4","1/4").GetBullet().i(VluK_Duv, GetCell("AF", 9) );
m_dOmd.Find("白","9","5","1/4").GetBullet().i(VluK_Duv, GetCell("AG", 9) );
m_dOmd.Find("白","9","6","1/4").GetBullet().i(VluK_Duv, GetCell("AH", 9) );
m_dOmd.Find("白","9","7","1/4").GetBullet().i(VluK_Duv, GetCell("AF", 10) );
m_dOmd.Find("白","9","8","1/4").GetBullet().i(VluK_Duv, GetCell("AG", 10) );
m_dOmd.Find("白","9","9","1/4").GetBullet().i(VluK_Duv, GetCell("AH", 10) );
}
void COmdFile1::o2tW9nD1()
{
m_dTxt.push_back("黑色 \t" + m_dOmd.sFind("黑","1","1"," ",VluK_Lv) + "\t" +
m_dOmd.sFind("黑","1","1"," ",VluK_Sx) + "\t" +
m_dOmd.sFind("黑","1","1"," ",VluK_Sy) + "\t" +
m_dOmd.sFind("黑","1","1"," ",VluK_Du) + "\t" +
m_dOmd.sFind("黑","1","1"," ",VluK_Dv) + "\t" +
"9點均齊度\tL\t\t\t\t\t9點均齊度\tx\t\t\t\t\t9點均齊度\ty\t\t\t\t\t9點均齊度\tT\t\t\t\t\t9點均齊度\tduv\n");
m_dTxt.push_back("\t\t\t\t\t\t離邊6分之1\t" + m_dOmd.sFind("白","9","1","1/6",VluK_Lv) + "\t" +
m_dOmd.sFind("白","9","2","1/6",VluK_Lv) + "\t" +
m_dOmd.sFind("白","9","3","1/6",VluK_Lv) + "\t\t\t\t" +
m_dOmd.sFind("白","9","1","1/6",VluK_Sx) + "\t" +
m_dOmd.sFind("白","9","2","1/6",VluK_Sx) + "\t" +
m_dOmd.sFind("白","9","3","1/6",VluK_Sx) + "\t\t\t\t" +
m_dOmd.sFind("白","9","1","1/6",VluK_Sy) + "\t" +
m_dOmd.sFind("白","9","2","1/6",VluK_Sy) + "\t" +
m_dOmd.sFind("白","9","3","1/6",VluK_Sy) + "\t\t\t\t" +
m_dOmd.sFind("白","9","1","1/6",VluK_T) + "\t" +
m_dOmd.sFind("白","9","2","1/6",VluK_T) + "\t" +
m_dOmd.sFind("白","9","3","1/6",VluK_T) + "\t\t\t\t" +
m_dOmd.sFind("白","9","1","1/6",VluK_Duv) + "\t" +
m_dOmd.sFind("白","9","2","1/6",VluK_Duv) + "\t" +
m_dOmd.sFind("白","9","3","1/6",VluK_Duv) + "\n");
m_dTxt.push_back("\t\t\t\t\t\t\t"+ m_dOmd.sFind("白","9","4","1/6",VluK_Lv) + "\t" +
m_dOmd.sFind("白","9","5","1/6",VluK_Lv) + "\t" +
m_dOmd.sFind("白","9","6","1/6",VluK_Lv) + "\t\t\t\t" +
m_dOmd.sFind("白","9","4","1/6",VluK_Sx) + "\t" +
m_dOmd.sFind("白","9","5","1/6",VluK_Sx) + "\t" +
m_dOmd.sFind("白","9","6","1/6",VluK_Sx) + "\t\t\t\t" +
m_dOmd.sFind("白","9","4","1/6",VluK_Sy) + "\t" +
m_dOmd.sFind("白","9","5","1/6",VluK_Sy) + "\t" +
m_dOmd.sFind("白","9","6","1/6",VluK_Sy) + "\t\t\t\t" +
m_dOmd.sFind("白","9","4","1/6",VluK_T) + "\t" +
m_dOmd.sFind("白","9","5","1/6",VluK_T) + "\t" +
m_dOmd.sFind("白","9","6","1/6",VluK_T) + "\t\t\t\t" +
m_dOmd.sFind("白","9","4","1/6",VluK_Duv) + "\t" +
m_dOmd.sFind("白","9","5","1/6",VluK_Duv) + "\t" +
m_dOmd.sFind("白","9","6","1/6",VluK_Duv) + "\n");
m_dTxt.push_back("\t\t\t\t\t\t\t"+ m_dOmd.sFind("白","9","7","1/6",VluK_Lv) + "\t" +
m_dOmd.sFind("白","9","8","1/6",VluK_Lv) + "\t" +
m_dOmd.sFind("白","9","9","1/6",VluK_Lv) + "\t\t\t\t" +
m_dOmd.sFind("白","9","7","1/6",VluK_Sx) + "\t" +
m_dOmd.sFind("白","9","8","1/6",VluK_Sx) + "\t" +
m_dOmd.sFind("白","9","9","1/6",VluK_Sx) + "\t\t\t\t" +
m_dOmd.sFind("白","9","7","1/6",VluK_Sy) + "\t" +
m_dOmd.sFind("白","9","8","1/6",VluK_Sy) + "\t" +
m_dOmd.sFind("白","9","9","1/6",VluK_Sy) + "\t\t\t\t" +
m_dOmd.sFind("白","9","7","1/6",VluK_T) + "\t" +
m_dOmd.sFind("白","9","8","1/6",VluK_T) + "\t" +
m_dOmd.sFind("白","9","9","1/6",VluK_T) + "\t\t\t\t" +
m_dOmd.sFind("白","9","7","1/6",VluK_Duv) + "\t" +
m_dOmd.sFind("白","9","8","1/6",VluK_Duv) + "\t" +
m_dOmd.sFind("白","9","9","1/6",VluK_Duv) + "\n");
m_dTxt.push_back("\n");
}
沒有留言:
張貼留言