-
Notifications
You must be signed in to change notification settings - Fork 2
/
COmdFile0.cpp
110 lines (94 loc) · 2.54 KB
/
COmdFile0.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// OmdFile1.cpp: implementation of the COmdFile0 class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "COmdFile0.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////////
//輸出輸入文件格式
//oForm() output form
//iForm() input form
//////////////////////////////////////////////////////////////////////////
BOOL COmdFile0::Open(LPCTSTR _S)
{
CFileException _Fx;
getOpenSample(_S, _Fx);
openWhichKindOmefile();
return m_Omd->Open(_S, _Fx);
};
BOOL COmdFile0::Open(LPCTSTR _S, CFileException& _Fx)
{
getOpenSample(_S, _Fx);
openWhichKindOmefile();
return m_Omd->Open(_S, _Fx);
};
//BOOL COmdFile0::Save(CString _S, CFileException& _Fx, OmdCarData _D)
BOOL COmdFile0::Save(LPCTSTR _S, CFileException& _Fx, RNA& _R)
{
saveWhichKindOmefile(_R); //如何選用適當的呢?
CString savePathName;
savePathName.Format("%s", _S);
if (m_GmOmd != 0)
{
CString path;
path = savePathName.Left( savePathName.ReverseFind('.'));
CString pathGm;
pathGm = path + "_gamma.omd";
return m_GmOmd->Save(pathGm, _Fx) && m_Omd->Save(_S, _Fx);
}
else
return m_Omd->Save(_S, _Fx);
};
void COmdFile0::getOpenSample(LPCTSTR _path, CFileException& _fx)
{
CTxtFile *fpTxt = new CTxtFile();
fpTxt->Open(_path, _fx);
fpTxt->oTxtData(m_dTxt);
fpTxt->Close();
delete fpTxt;
};
void COmdFile0::openWhichKindOmefile()
{
KindOfOmd omdKind;
if (m_dTxt.at(0).Find(':') != -1)
omdKind = OMD_OLD;
else if (m_dTxt.at(0).Find("Gamma") != -1)
omdKind = OMD_GAMMA;
else
omdKind = OMD_AtYPE;
switch(omdKind)
{
case OMD_AtYPE: m_Omd = new COmdFile1(OMD_AtYPE); break;
case OMD_GAMMA: m_Omd = new COmdFileGm(); break;
case OMD_OLD:
default: m_Omd = new COmdFile1(OMD_OLD);
}
}
void COmdFile0::saveWhichKindOmefile(RNA& _R)
{
// KindOfOmd omdKind = OMD_AtYPE;
CString str;
for (int i = 0; i < 256; ++i)
{
str.Format("%d", i);
if ((_R.Find("白","gamma",str,"0 255 255").GetSqncArea() != AA_00) || //有量測 = .GetMsrFlowNo() != 99
(_R.Find("紅","gamma",str,"0 255 255").GetSqncArea() != AA_00) ||
(_R.Find("綠","gamma",str,"0 255 255").GetSqncArea() != AA_00) ||
(_R.Find("藍","gamma",str,"0 255 255").GetSqncArea() != AA_00))
{
//omdKind = OMD_GAMMA;
m_GmOmd = new COmdFileGm();
break;
}
}
m_Omd = new COmdFile1(OMD_AtYPE);
// switch(omdKind)
// {
// case OMD_GAMMA: m_GmOmd = new COmdFileGm(); break;
// default: m_Omd = new COmdFile1(OMD_AtYPE);
// }
}