File: MESPARA\MESPARA.CPP
1 //******************************************************************************
2 //Datei : mespara.cpp
3 //Projekt : XCTL
4 //Subsystem : Protokollbuch
5 //Autor : Jens Klier <klier@informatik.hu-berlin.de>
6 // Institut fuer Informatik,
7 // Humboldt-Universitaet Berlin
8 //Inhalt : Implementation der Klasse TMeasurementParameter
9 //******************************************************************************
10 //!neu klier Protokollbuch
11
12 #include "internls\evrythng.h" // extern Main
13
14 #include "mespara\mespara.h"
15 #include <string.h>
16 #include <stdlib.h>
17 #include <ctype.h>
18
19 //--||--\\--||--//--||--\\--||--//--||--\\--||--//--||--\\--||--//--||--\\--||--
20
21 TMeasurementParameter::TMeasurementParameter()
22 {};
23
24 void TMeasurementParameter::Load( LPCSTR IniFile )
25 {
26 char buf[MaxString];
27
28 strcpy(szApplication, "Steuerprogramm");
29 GetPrivateProfileString(szApplication, "User", "Nutzer", sUser, MaxString, IniFile );
30 GetPrivateProfileString(szApplication, "Target", "Probe", sTarget, MaxString,
31 IniFile );
32 GetPrivateProfileString(szApplication, "Substrat", "Si", sTargetBulk, MaxString,
33 IniFile );
34 GetPrivateProfileString(szApplication, "WaveLength", "1.534", buf, MaxString,
35 IniFile );
36 SetWaveLength(buf);
37 GetPrivateProfileString(szApplication, "Reflection", "[001]", buf, 10, IniFile);
38 SetReflection(buf);
39 GetPrivateProfileString(szApplication, "Orientation", "[001]", buf, 10, IniFile);
40 SetOrientation(buf);
41 GetPrivateProfileString(szApplication, "Comment", "", sComment, 2*MaxString, IniFile);
42 SetCurrent( GetPrivateProfileInt(szApplication, "Current", 10, IniFile) );
43 SetVoltage( GetPrivateProfileInt(szApplication, "Voltage", 20, IniFile) );
44 };
45
46 void TMeasurementParameter::Save( LPCSTR IniFile )
47 {
48 char buf[MaxString];
49
50 WritePrivateProfileString(szApplication, "WaveLength", GetWaveLength(buf), IniFile);
51 WritePrivateProfileString(szApplication, "User", sUser, IniFile);
52 WritePrivateProfileString(szApplication, "Target", sTarget, IniFile);
53 WritePrivateProfileString(szApplication, "Substrat", sTargetBulk, IniFile);
54 WritePrivateProfileString(szApplication, "Reflection", GetReflection(buf), IniFile);
55 WritePrivateProfileString(szApplication, "Orientation", GetOrientation(buf), IniFile);
56 WritePrivateProfileString(szApplication, "Comment", sComment, IniFile);
57 WritePrivateProfileString(szApplication, "Current", GetCurrent(buf), IniFile);
58 WritePrivateProfileString(szApplication, "Voltage", GetVoltage(buf), IniFile);
59 };
60
61 LPCSTR TMeasurementParameter::GetComment()
62 {
63 return sComment;
64 };
65
66 void TMeasurementParameter::SetComment( LPCSTR sCom )
67 {
68 strcpy(sComment, sCom);
69 };
70
71 LPSTR TMeasurementParameter::GetReflection( LPSTR sRef )
72 {
73 GetHKL(thklReflection, sRef);
74 return sRef;
75 };
76
77 LPSTR TMeasurementParameter::GetReflection( THKL& thklRef, LPSTR sRef )
78 {
79 thklRef= thklReflection;
80 GetHKL(thklReflection, sRef);
81 return sRef;
82 };
83
84 BOOL TMeasurementParameter::SetReflection( LPCSTR sRef )
85 {
86 return SetHKL(thklReflection, sRef);
87 };
88
89 LPSTR TMeasurementParameter::GetOrientation( LPSTR sOri )
90 {
91 GetHKL(thklOrientation, sOri);
92 return sOri;
93 };
94
95 LPSTR TMeasurementParameter::GetOrientation( THKL& thklOri, LPSTR sOri )
96 {
97 thklOri= thklOrientation;
98 GetHKL(thklOrientation, sOri);
99 return sOri;
100 };
101
102 BOOL TMeasurementParameter::SetOrientation( LPCSTR sOri )
103 {
104 return SetHKL(thklOrientation, sOri);
105 };
106
107 LPCSTR TMeasurementParameter::GetUser()
108 {
109 return sUser;
110 };
111
112 void TMeasurementParameter::SetUser( LPCSTR sUse )
113 {
114 strcpy(sUser, sUse);
115 };
116
117 LPCSTR TMeasurementParameter::GetTarget()
118 {
119 return sTarget;
120 };
121
122 void TMeasurementParameter::SetTarget( LPCSTR sTar )
123 {
124 strcpy(sTarget, sTar);
125 };
126
127 LPCSTR TMeasurementParameter::GetTargetBulk()
128 {
129 return sTargetBulk;
130 };
131
132 void TMeasurementParameter::SetTargetBulk( LPCSTR sTaB )
133 {
134 strcpy(sTargetBulk, sTaB);
135 };
136
137 LPSTR TMeasurementParameter::GetWaveLength( LPSTR sWaL)
138 {
139 sprintf(sWaL, "%.3f", fWaveLength);
140 return sWaL;
141 };
142
143 float TMeasurementParameter::GetWaveLength()
144 {
145 return fWaveLength;
146 };
147
148 BOOL TMeasurementParameter::SetWaveLength( LPCSTR sWaL )
149 {
150 char *stopstring;
151
152 fWaveLength= strtod(sWaL, &stopstring);
153 if (strlen(stopstring) == 0)
154 return TRUE;
155 else
156 return FALSE;
157 };
158
159 LPSTR TMeasurementParameter::GetVoltage( LPSTR sVol)
160 {
161 sprintf(sVol, "%d", iVoltage);
162 return sVol;
163 };
164
165 int TMeasurementParameter::GetVoltage()
166 {
167 return iVoltage;
168 };
169
170 BOOL TMeasurementParameter::SetVoltage( LPCSTR sVol )
171 {
172 iVoltage= atoi(sVol);
173 if ( iVoltage != 0)
174 return TRUE;
175 else
176 return FALSE;
177 };
178
179 BOOL TMeasurementParameter::SetVoltage( const int& iVol )
180 {
181 iVoltage= iVol;
182 if ( iVoltage != 0)
183 return TRUE;
184 else
185 return FALSE;
186 };
187
188 LPSTR TMeasurementParameter::GetCurrent( LPSTR sCur )
189 {
190 sprintf(sCur, "%d", iCurrent);
191 return sCur;
192 };
193
194 int TMeasurementParameter::GetCurrent()
195 {
196 return iCurrent;
197 };
198
199 BOOL TMeasurementParameter::SetCurrent( LPCSTR sCur )
200 {
201 iCurrent= atoi(sCur);
202 if ( iCurrent != 0)
203 return TRUE;
204 else
205 return FALSE;
206 };
207
208 BOOL TMeasurementParameter::SetCurrent( const int& iCur )
209 {
210 iCurrent= iCur;
211 if ( iCurrent != 0)
212 return TRUE;
213 else
214 return FALSE;
215 };
216
217 //! bestimmt 3 Integerwerte zwischen -9 und 9 aus einem String
218 //! wird nur in Verbindung mit Orientation,Reflection benutzt
219 //! 1.Parameter(ausgabe) Struktur von 3 integerwerten
220 //! 2.Parameter(eingabe) String
221 BOOL TMeasurementParameter::SetHKL( THKL& thklHKL, LPCSTR sHKL )
222 {
223 int i, k, digit, alpha;
224 THKL tmp;
225 BOOL bNoError;
226
227 i= digit= alpha= 0;
228 tmp.h= tmp.k= tmp.l= 0;
229 bNoError= TRUE;
230 for (k= 0; k < strlen(sHKL); k++)
231 {
232 if (isdigit(sHKL[k]))
233 digit++;
234 if (isalpha(sHKL[k]))
235 alpha++;
236 }
237 if ((digit != 3) || (alpha != 0))
238 {
239 thklHKL= tmp;
240 return FALSE;
241 }
242 while ( '[' == sHKL[ i ] )
243 i++;
244 while ( ' ' == sHKL[ i ] )
245 i++;
246 if ( '-' == sHKL[ i ] )
247 tmp.h= max( '0' - sHKL[ ++i ], -9 );
248 else
249 tmp.h= min( sHKL[ i ] - '0', 9 );
250 if (!isdigit(sHKL[i]))
251 {
252 bNoError= FALSE;
253 tmp.h= 0;
254 }
255 i++;
256 while ( ' ' == sHKL[ i ] )
257 i++;
258 if ( '-' == sHKL[ i ] )
259 tmp.k= max( '0' - sHKL[ ++i ], -9 );
260 else
261 tmp.k= min( sHKL[ i ] - '0', 9 );
262 if (!isdigit(sHKL[i]))
263 {
264 bNoError= FALSE;
265 tmp.k= 0;
266 }
267 i++;
268 while ( ' ' == sHKL[ i ] )
269 i++;
270 if ( '-' == sHKL[ i ] )
271 tmp.l= max( '0' - sHKL[ ++i ], -9 );
272 else
273 tmp.l= min( sHKL[ i ] - '0', 9 );
274 if (!isdigit(sHKL[i]))
275 {
276 bNoError= FALSE;
277 tmp.l= 0;
278 }
279 thklHKL= tmp;
280 return bNoError;
281 };
282
283
284 //! bildet aus 3 Integerwerten einen String
285 //! wird nur in Verbindung mit Orientation,Reflection benutzt
286 //! 1.Parameter(eingabe) Struktur von 3 integerwerten
287 //! 2.Parameter(ausgabe) String
288 void TMeasurementParameter::GetHKL( THKL& thklHKL, LPSTR sHKL )
289 {
290 sprintf( sHKL, "[%d%d%d]", thklHKL.h, thklHKL.k, thklHKL.l );
291 };
292
293
294
295
296
297
298