File: TOPOGRFY\TP_GUI.CPP
1 //##############################################################################
2 // //
3 // TP_GUI.CPP //
4 // //
5 // Subsystem : Topographie / Oberfläche //
6 // Benutzung durch andere Subsysteme erforderlich: NEIN //
7 //----------------------------------------------------------------------------//
8 // Autoren: Thomas Kullmann, Günther Reinecker (2002) //
9 // //
10 // Stand : 20.01.2003 //
11 // //
12 //##############################################################################
13
14 #include "internls\evrythng.h" // GermanVersion
15 #include "winresrc\rc_def.h" // Ressourcen-IDs
16
17 #include "topogrfy\tp_gui.h" // SCHNITTSTELLE für diese Datei
18
19 #include "mespara\mespara.h" //! neu: klier Allgemeine Einstellungen
20 #include "protocol\protocol.h" //! neu: klier Protokollbuch
21
22 //--||--\\--||--//--||--\\--||--//--||--\\--||--//--||--\\--||--//--||--\\--||--
23
24 //#############################################################################
25 // TTopographyExecDlg
26 //#############################################################################
27
28 //-----------------------------------------------------------------------------
29 // Konstruktor
30
31 TTopographyExecDlg::TTopographyExecDlg() : TModalDlg( "TOPOGRAPHYEXECDLG", GetMainInstance() ), m_lnkTopography( 0 ), m_lnkTimerMeasuring( 0 ), m_lnkTimerMultiExpose( 0 )
32 {
33 m_lnkTopography= TTopography::GetInstance(); // einzige globale Instanz der Klasse //POLLING, d.h. KEINE Referenz auf uns übergeben
34 m_lnkTimerMeasuring= new TInterfaceTimer( this, 2000 ); //Oberserver, d.h. Timer benachrichtigt uns
35 m_lnkTimerMultiExpose= new TInterfaceTimer( this, 500 ); //Oberserver, d.h. Timer benachrichtigt uns
36 // falls Detektor noch nicht gesetzt, auf aktuellen Detektor setzen
37 m_lnkTopography->DoInitDetectors();
38 // Motor (wenn möglich) auf Omega, sonst auf aktuellen Motor setzen
39 // aktuelle Settings im Motor speichern, um diese beim Verlassen wiederherzustellen
40 // FALSE -> Omega ist nicht verfügbar
41 if ( !m_lnkTopography->DoInitMotor() )
42 MessageBox(sth_tp_NoOmega, sth_tp_MsgBoxError, MBSTOP);
43
44 m_lnkTopography->SetCurrentTime( 0 );
45 m_lnkTopography->SetStartTime( 0 );
46 m_lnkTopography->SetRestShots( m_lnkTopography->GetNumberCycle() );
47 m_lnkTopography->DoInitWorkPoint(); // Parameter des Makro initialisieren
48 m_lnkTopography->SetStartPointOk( FALSE );
49 };
50
51 //-----------------------------------------------------------------------------
52 // Initialisierung zur Darstellung des 'Topographie Durchfuehrung' Fensters
53
54 BOOL TTopographyExecDlg::Dlg_OnInit(HWND, HWND, LPARAM)
55 {
56 char buf[MaxString];
57 if ( !m_lnkTopography->GetDetector()->GetCounterWnd() )
58 (new TCounterWindow(GetMainInstance(), m_lnkTopography->GetDetector()))->Show();
59
60 // Initialisieren der Parameter, Messzeit, usw...
61 // Beschriftung und Werte im Fenster
62 GetTimeString(buf, m_lnkTopography->GetCurTime());
63 CtrlSetText( id_MeasurementTime, buf);
64 CtrlSetFloat( id_Angle, 0, m_lnkTopography->GetMotorDigits(eDF), _DECIMAL );
65 CtrlSetLong( id_RemainderCyclus, m_lnkTopography->GetNumberCycle());
66 if ( m_lnkTopography->IsMultipleShot() )
67 CtrlSetText( cm_SwitchControl, sth_tp_StartMultiExposure );
68 else
69 CtrlSetText( cm_SwitchControl, sth_tp_StartSingleExposure );
70 Dlg_OnInitialize();
71 Dlg_OnParamSet();
72 return TRUE;
73 };
74 //-----------------------------------------------------------------------------
75 // Zeitueberpruefung fuer die Mehrfachbelichtung und Beepton nach Messzeitende
76
77 void TTopographyExecDlg::OnTimer( TBasicTimer *const aTimer )
78 {
79 // Gesamtmesszeit war abgelaufen; Ausgabe eines regelmaessigen Beeptons
80 if (aTimer == m_lnkTimerMeasuring)
81 {
82 MessageBeep(0);
83 DelayTime(100);
84 MessageBeep(0);
85 return;
86 };
87 // Zeitueberpruefung waehrend der Mehrfachbelichtung
88 if (aTimer == m_lnkTimerMultiExpose)
89 {
90 Dlg_OnParamSet();
91 Dlg_OnMultipleExpose();
92 return;
93 };
94 };
95 //-----------------------------------------------------------------------------
96 // Timeout für die Mehrfachbelichtung
97
98 void TTopographyExecDlg::Dlg_OnMultipleExpose( void )
99 {
100 char buf[MaxString];
101
102 if ( (m_lnkTopography->GetCurTime() / 1000) < (DWORD)m_lnkTopography->GetMeasurementTime() )
103 return; // ob noch innerhalb der Messzeit
104
105 m_lnkTimerMultiExpose->StopTimer();
106 m_lnkTopography->SetRestShots( m_lnkTopography->GetRestShots() - 1 ); // Messzyklen verringern
107 // falls noch Messzyklen vorhanden
108 if ( m_lnkTopography->GetRestShots() )
109 {
110 CtrlSetLong( id_RemainderCyclus, m_lnkTopography->GetRestShots());
111 // Weiterfuehrung der Probe, der Timer wird durch den case Zweig cm_SteeringReady
112 // in Dlg_OnCommand (nach Ende der Steering Aktion) neu gesetzt
113 sprintf(buf, m_lnkTopography->GetDigitFormat(eSF), m_lnkTopography->GetAngleBetweenShots() );
114 m_lnkTopography->DoStartMeasure(MoveToPoint, Relative, 0, buf, GetHandle() );
115 return;
116 };
117 // alle Messzyklen beendet
118 CtrlSetLong( id_RemainderCyclus, m_lnkTopography->GetRestShots());
119 m_lnkTopography->SetExceptionOccured( TRUE );
120 m_lnkTopography->SetAdditionalTime( TRUE ); // Zusatzzeit; Hinweisbox anzeigen
121
122 m_lnkTimerMeasuring->StartTimer(); // Beep Timer
123 MessageBox(sth_tp_MeasureTimeEnd, sth_tp_MsgBoxInfo, MBINFO);
124 PostMessage( GetHandle(), WM_COMMAND, cm_SwitchControl, 0 );
125 m_lnkTimerMeasuring->StopTimer();
126 };
127 //-----------------------------------------------------------------------------
128 // Behandlung der Nachrichten cm_SwitchControl
129
130 void TTopographyExecDlg::Dlg_OnSwitchControl( void )
131 {
132 char buf[2*MaxString];
133
134 // Ende der Messzeit erreicht, Benutzer hat Hinweisfenster quittiert -> Nachregelmechanismus anhalten
135 if ( m_lnkTopography->IsControlActive() )
136 {
137 if ( m_lnkTopography->IsMultipleShot() )
138 m_lnkTimerMultiExpose->StopTimer();
139 else
140 m_lnkTopography->DoStopMeasure();
141 // Herstellen des Ausgangszustandes
142 m_lnkTopography->SetTimeFinish( FALSE );
143 m_lnkTopography->SetTimeRunning( FALSE );
144 m_lnkTopography->SetAdditionalTime( FALSE );
145 m_lnkTopography->SetStartTime( 0 );
146 m_lnkTopography->SetCurrentTime( 0 );
147 // Buttonbeschriftung von stoppen auf starten aendern
148 if ( m_lnkTopography->IsMultipleShot() )
149 CtrlSetText( cm_SwitchControl, sth_tp_StartMultiExposure);
150 else
151 CtrlSetText( cm_SwitchControl, sth_tp_StartSingleExposure);
152
153 m_lnkTopography->SetControlActive( !m_lnkTopography->IsControlActive() );
154 Dlg_OnParamSet();
155 m_lnkTopography->SetControlActive( FALSE );
156
157 // Klier Protokollbuch geändert 01.03.2003
158 if ( IsProtocolTopographyOn() )
159 {
160 if ( !m_lnkTopography->IsMultipleShot() )
161 SetProtocolTopographyImpsnach( m_lnkTopography->GetStrngIntensity() );
162 SetProtocolTopographyDFvor( m_lnkTopography->GetStrngStartPoint() );
163 SetProtocolTopographyDFnach( m_lnkTopography->GetAngle() );
164 SaveProtocolTopographyParameter();
165 ViewOnProtocolTopographyDlg();
166 if ( IsProtocolTopographyOn() )
167 SetProtocolTopographyReadOnly();
168 SetProtocolTopographyOff();
169 }
170 CtrlSetEnabled(cm_GotoWorkPoint, TRUE); // aktiviert Button 'Startpositon einstellen';
171 return;
172 };
173 // Messung gestartet; Anzeigefelder und Buttonbeschriftungen anpassen,
174 // Zeitzaehlung beginnen, bei Mehrfachbelichtung Timer starten, bei
175 // Einfachbelichtung Steering fuer Nachregelung starten
176
177 // Klier Protokollbuch geändert 01.03.2003
178 if ( MessageBox(sth_tp_SaveAtProtocol, sth_tp_MsgBoxProtocol, MBASK) == IDYES)
179 {
180 SetProtocolTopographyOn();
181 SetProtocolTopographyImpMax( m_lnkTopography->GetStrngPeakIntensity() );
182 int nOldTopographyMotor= m_lnkTopography->GetMotor();
183 m_lnkTopography->SetMotor( Collimator );
184
185 SetProtocolTopographyKKruemmung( m_lnkTopography->GetAngle() );
186 m_lnkTopography->SetMotor( nOldTopographyMotor );
187 SetProtocolTopographyHWB( m_lnkTopography->GetStrngHwb() );
188 SetProtocolTopographyEXPT( m_lnkTopography->GetMeasurementTime() );
189 SetProtocolTopographyINCDF( m_lnkTopography->GetControlStep() );
190 SetProtocolTopographyNBEXPOS( m_lnkTopography->GetNumberCycle() );
191 if ( m_lnkTopography->IsMultipleShot() )
192 {
193 SetProtocolTopographyRSA( m_lnkTopography->GetStartAngle() );
194 SetProtocolTopographyABE( m_lnkTopography->GetAngleBetweenShots() );
195 }
196 else
197 {
198 SetProtocolTopographyCRT( m_lnkTopography->GetMaxTime() );
199 SetProtocolTopographySTE();
200 SetProtocolTopographyCONLIMIT();
201 if ( m_lnkTopography->IsSmallAngleSide() )
202 SetProtocolTopographyCONPOINT( -(m_lnkTopography->GetWorkPoint()) );
203 else
204 SetProtocolTopographyCONPOINT( m_lnkTopography->GetWorkPoint() );
205 }
206 ViewOnProtocolTopographyDlg();
207 }
208 else
209 SetProtocolTopographyOff();
210
211 m_lnkTopography->SetExceptionOccured( FALSE );
212 m_lnkTopography->SetCurrentTime( 0 );
213 GetTimeString(buf, m_lnkTopography->GetCurTime());
214 CtrlSetText( id_RemainderTime, buf);
215
216 // Millisekunden seit Systemstart
217 m_lnkTopography->SetStartTime( GetTickCount() );
218 m_lnkTopography->SetCurrentTime( GetTickCount() );
219 m_lnkTopography->SetTimeRunning( TRUE );
220 CtrlSetText( id_Text, "");
221
222 // bei Mehrfachbelichtung
223 if ( m_lnkTopography->IsMultipleShot() )
224 {
225 // Startposition wurde anfahren
226 m_lnkTopography->SetRestShots( m_lnkTopography->GetNumberCycle() );
227 m_lnkTimerMultiExpose->StartTimer();
228 CtrlSetText( cm_SwitchControl, sth_tp_StopMultiExposure);
229 }
230 else
231 {
232 m_lnkTopography->SetAngleWidth( m_lnkTopography->GetControlStep() ); // Motorschrittweite setzen
233 // Millisekunden seit Systemstart
234 m_lnkTopography->SetStartTime( GetTickCount() );
235 m_lnkTopography->SetCurrentTime( GetTickCount() );
236 sprintf(buf, m_lnkTopography->GetDigitFormat( eDF ), m_lnkTopography->GetControlRange() ); // Parameter für Nachregelung laden
237 // ausfuehren des Kommandos ControlFlank
238 if ( m_lnkTopography->IsSmallAngleSide() )
239 m_lnkTopography->DoStartMeasure(ControlFlank, SmallSide, 0, buf, GetHandle() );
240 else
241 m_lnkTopography->DoStartMeasure(ControlFlank, LargeSide, 0, buf, GetHandle() );
242 CtrlSetText( cm_SwitchControl, sth_tp_StopSingleExposure);
243 };
244 m_lnkTopography->SetControlActive( TRUE );
245 CtrlSetEnabled(cm_GotoWorkPoint, FALSE);
246 };
247 //-----------------------------------------------------------------------------
248 // Behandlung der Nachricht cm_Initialize
249
250 void TTopographyExecDlg::Dlg_OnInitialize( void )
251 {
252 char buf[2*MaxString];
253
254 // Detector mit Zeitintervall zum Zaehlen, maximaler Impulsrate und Messfehlerwert (0.02) initialisieren
255 m_lnkTopography->DoSetDetectorParams( m_lnkTopography->GetMaxTime(), m_lnkTopography->GetMaxCounts(), FALSE );
256 // Eintragen von Werten im Fenster 'Topographie'
257 CtrlSetFloat( id_ExposureTime, m_lnkTopography->GetMaxTime(), 1, _DECIMAL);
258
259 m_lnkTopography->SetRestShots( m_lnkTopography->GetNumberCycle() );
260 CtrlSetLong( id_RemainderCyclus, m_lnkTopography->GetRestShots());
261
262 m_lnkTopography->SetAngleWidth( m_lnkTopography->GetControlStep() );
263 // Warnung, falls Motor oder Counter vor Aufruf von 'Topographie Durchführung' nicht gesetzt sind
264 if ( !m_lnkTopography->IsSetupOk() )
265 {
266 char *stSettingsIncomplete1= LoadString(sth_tp_SettingsIncomplete1);
267 strcpy(buf, stSettingsIncomplete1 );
268 _FREELIST(stSettingsIncomplete1);
269
270 char *stSettingsIncomplete2= LoadString(sth_tp_SettingsIncomplete2);
271 strcat(buf, stSettingsIncomplete2 );
272 _FREELIST(stSettingsIncomplete2);
273
274 char *stSettingsIncomplete3= LoadString(sth_tp_SettingsIncomplete3);
275 strcat(buf, stSettingsIncomplete3 );
276 _FREELIST(stSettingsIncomplete3);
277
278 CtrlSetText(id_Text, (LPSTR)buf);
279 };
280 };
281 //-----------------------------------------------------------------------------
282 // Behandlung der Nachricht cm_GotoWorkPoint
283
284 void TTopographyExecDlg::Dlg_OnGotoWorkPoint( void )
285 {
286 char buf[2*MaxString];
287
288 if ( (m_lnkTopography->IsStartPointOk()) && (m_lnkTopography->IsMultipleShot()) )
289 {
290 // prevents the multiple relative movement
291 MessageBox(sth_tp_StartpointReached, sth_tp_MsgBoxInfo, MBINFO);
292 return;
293 };
294 CtrlSetEnabled(cm_SwitchControl, FALSE); // 'Startposition anfahren' und
295 CtrlSetEnabled(cm_GotoWorkPoint, FALSE); // 'Regelung starten' bzw 'Topographie starten' deaktivieren
296 CtrlSetText( id_Text, sth_tp_GoToStartpoint);
297
298 m_lnkTopography->SetAngleWidth( m_lnkTopography->GetMoveStep() ); // Motorschrittweite setzen
299 // Anfahren des um dStartAngle vom aktuellen Stand entfernten Punktes
300 if ( m_lnkTopography->IsMultipleShot() )
301 {
302 sprintf(buf, m_lnkTopography->GetDigitFormat( eDF ), m_lnkTopography->GetStartAngle());
303 m_lnkTopography->DoStartMeasure(MoveToPoint, Relative, 0, buf, GetHandle());
304 }
305 else
306 m_lnkTopography->DoStartMeasure(m_lnkTopography->GetMWorkPoint(), GetHandle()); // Anfahren
307 };
308 //-----------------------------------------------------------------------------
309 // Behandlung der Nachricht cm_SetupPosition
310
311 void TTopographyExecDlg::Dlg_OnSetupPosition( void )
312 {
313 char buf[2*MaxString];
314
315 CtrlSetEnabled(cm_SwitchControl, TRUE); // 'Startposition anfahren' und
316 CtrlSetEnabled(cm_GotoWorkPoint, TRUE); // 'Regelung starten' bzw 'Topographie starten' aktivieren
317
318 // Ausgabe Hinweistext
319 char *stSettingsComplete1= LoadString(sth_tp_SettingsComplete1);
320 strcpy(buf, stSettingsComplete1 );
321 _FREELIST(stSettingsComplete1);
322
323 char *stSettingsComplete2= LoadString(sth_tp_SettingsComplete2);
324 strcat(buf, stSettingsComplete2 );
325 _FREELIST(stSettingsComplete2);
326
327 char *stSettingsComplete3= LoadString(sth_tp_SettingsComplete3);
328 strcat(buf, stSettingsComplete3 );
329 _FREELIST(stSettingsComplete3);
330
331 CtrlSetText( id_Text, (LPSTR)buf);
332
333 m_lnkTopography->SetStartPointOk( TRUE );
334 if ( m_lnkTopography->IsMultipleShot() )
335 {
336 // 19.11.02 Steering.dStartPoint wird auf die aktuelle Motorposition plus Verschiebungsweite gesetzt
337 // Warum??? dStartPoint wird im Topographie Zusammenhang eigentlich nicht genutzt
338 m_lnkTopography->SetStrngStartPoint( m_lnkTopography->GetAngle() + m_lnkTopography->GetStartAngle());
339 Dlg_OnParamSet();
340 };
341 };
342 //-----------------------------------------------------------------------------
343 // Behandlung der Nachricht cm_SteeringReady
344
345 void TTopographyExecDlg::Dlg_OnSteeringReady( void )
346 {
347 // falls Steering Aktion bezügl. eines Umsetzungsschritts bei der Mehrfachbelichtung
348 // --> Timer fuer die naechste Runde neu initialisieren
349 if ( (m_lnkTopography->IsControlActive()) && (m_lnkTopography->IsMultipleShot()) )
350 {
351 m_lnkTopography->SetStartTime( GetTickCount() );
352 m_lnkTopography->SetCurrentTime( GetTickCount() );
353 m_lnkTopography->SetTimeRunning( TRUE );
354 m_lnkTimerMultiExpose->StartTimer();
355 return;
356 };
357 // Steering-Aktion hat sich auf Arbeitspunkt bzw. Startposition anfahren bezogen
358 PostMessage(GetHandle(), WM_COMMAND, cm_SetupPosition, 0);
359 };
360 //-----------------------------------------------------------------------------
361 // Behandlung der Nachricht cm_CounterSet
362
363 void TTopographyExecDlg::Dlg_OnCounterSet( void )
364 {
365 if (m_lnkTopography->IsMultipleShot())
366 return;
367
368 m_lnkTopography->DoSaveMonitorSignal();
369 m_lnkTopography->GetDetector()->UpdateViews(TRUE); // Anzeige des Zaehlerfensters aktualisieren
370 m_lnkTopography->DetectorRequest();
371 // Anzeige der Regel-Größen
372 Dlg_OnParamSet();
373 PostMessage(GetHandle(), WM_COMMAND, cm_InquireExeption, 0 );
374 };
375 //-----------------------------------------------------------------------------
376 // Neue Eingabe im Feld Messzeit
377
378 void TTopographyExecDlg::Dlg_OnExposureTime( void )
379 {
380 BOOL bValid;
381 if ( !m_lnkTopography->SetMaxTime( CtrlGetFloat(id_ExposureTime, 1, _DECIMAL, bValid)) )
382 {
383 MessageBox( sth_tp_ValueMaxTime, sth_tp_MsgBoxError, MBSTOP );
384 return;
385 }
386 m_lnkTopography->DoSetDetectorParams( m_lnkTopography->GetMaxTime(), m_lnkTopography->GetMaxCounts(), FALSE);
387 CtrlSetFloat( id_ExposureTime, m_lnkTopography->GetMaxTime(), 1, _DECIMAL); // Ausgabe der neuen Detektormesszeit
388 };
389 //-----------------------------------------------------------------------------
390 // Behandlung bei Nachricht cm_TopographyParam
391
392 void TTopographyExecDlg::Dlg_OnTopographyParam( void )
393 {
394 TModalDlg *dlg;
395
396 // 'Topographie Einstellungen' Dialog
397 dlg= new TTopographyAdjustDlg(TRUE);
398 if ( dlg ) dlg->ExecuteDialog( GetHandle() );
399 _FREEOBJ(dlg);
400
401 m_lnkTopography->DoSetDetectorParams( m_lnkTopography->GetMaxTime(), m_lnkTopography->GetMaxCounts(), TRUE);
402 m_lnkTopography->SetAngleWidth(m_lnkTopography->GetControlStep()); // neue Motorschrittweite setzen
403 CtrlSetFloat( id_ExposureTime, m_lnkTopography->GetMaxTime(), 1, _DECIMAL); // Ausgabe der neuen Detektormesszeit
404 };
405 //-----------------------------------------------------------------------------
406 // Behandlung bei Nachricht cm_ParamSet
407
408 void TTopographyExecDlg::Dlg_OnParamSet( void )
409 {
410 char buf[MaxString];
411
412 CtrlSetLong( id_RemainderCyclus, m_lnkTopography->GetRestShots());
413 if ( !m_lnkTopography->IsControlActive() )
414 return;
415
416 // abgelaufende Zeit berechnen
417 if ( m_lnkTopography->IsTimeRunning() )
418 {
419 // klier Protokollbuch
420 if ( (m_lnkTopography->GetCurTime() == m_lnkTopography->GetStartTime()) && (!m_lnkTopography->IsMultipleShot() && IsProtocolTopographyOn()) )
421 SetProtocolTopographyImpsvor( m_lnkTopography->GetStrngIntensity() );
422 m_lnkTopography->SetCurrentTime( GetTickCount() );
423 m_lnkTopography->SetCurrentTime( m_lnkTopography->GetCurTime() - m_lnkTopography->GetStartTime() );
424 };
425 CtrlSetDouble( id_Angle, m_lnkTopography->GetAngle() - m_lnkTopography->GetStrngStartPoint(), m_lnkTopography->GetMotorDigits(eDF), _DECIMAL); // Drift anzeigen
426 // Ausgabe der zusätzlichen Meßzeit
427 GetTimeString(buf, m_lnkTopography->GetCurTime());
428 if ( m_lnkTopography->HasAdditionalTime() )
429 CtrlSetText( id_RemainderTime, buf);
430 else
431 CtrlSetText( id_MeasurementTime, buf);
432 return;
433 };
434 //-----------------------------------------------------------------------------
435 // Behandlung bei Nachricht cm_InquireException
436
437 void TTopographyExecDlg::Dlg_OnInquireException( void )
438 {
439 if ( m_lnkTopography->IsExeptionOccured() )
440 return;
441
442 // Intensitaet unter Minimum
443 if ( m_lnkTopography->GetStrngIntensity() < (0.01 * m_lnkTopography->GetStrngStartIntensity()) )
444 {
445 m_lnkTopography->SetExceptionOccured( TRUE );
446 m_lnkTimerMeasuring->StartTimer(); // Beep Timer
447 MessageBox( sth_tp_ExceptionOnIntensity, sth_tp_MsgBoxInfo, MBINFO );
448 m_lnkTimerMeasuring->StopTimer();
449 };
450 if ( m_lnkTopography->IsMultipleShot() )
451 return;
452
453 // Abweichung vom Arbeitspunkt ist zu gross
454 if ( m_lnkTopography->GetMaxAngleEscape() < fabs(m_lnkTopography->GetStrngStartPoint() - m_lnkTopography->GetStrngDistance()) )
455 {
456 m_lnkTopography->SetExceptionOccured( TRUE );
457 MessageBox( sth_tp_ExceptionOnWorkPoint, sth_tp_MsgBoxInfo, MBINFO );
458 m_lnkTimerMeasuring->StopTimer();
459 };
460 // Messzeit ist abgelaufen
461 if ( (m_lnkTopography->GetCurTime() / 1000) > (DWORD) m_lnkTopography->GetMeasurementTime() )
462 {
463 m_lnkTopography->SetExceptionOccured( TRUE );
464 m_lnkTopography->SetTimeFinish( TRUE );
465 m_lnkTopography->SetAdditionalTime( TRUE );
466 m_lnkTopography->SetStartTime( GetTickCount() );
467
468 m_lnkTimerMeasuring->StartTimer(); // Beep Timer
469 MessageBox( sth_tp_ExceptionOnTime, sth_tp_MsgBoxInfo, MBINFO );
470 m_lnkTimerMeasuring->StopTimer();
471 PostMessage(GetHandle(), WM_COMMAND, cm_SwitchControl, 0 );
472 };
473 };
474 //-----------------------------------------------------------------------------
475 // Behandlung verschiedener Nachrichten
476
477 void TTopographyExecDlg::Dlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
478 {
479 static HWND hDlgItem= NULL;
480
481 switch ( id )
482 {
483 // Aenderung des Messzustandes (Messung laeuft <-> keine Messung)
484 case cm_SwitchControl:
485 Dlg_OnSwitchControl();
486 break;
487
488 // Initalisierung
489 case cm_Initialize:
490 Dlg_OnInitialize();
491 break;
492
493 // Button "Startposition einstellen" wurde ausgewaehlt
494 case cm_GotoWorkPoint:
495 Dlg_OnGotoWorkPoint();
496 break;
497
498 // Arbeitspunkt wurde eingestellt
499 case cm_SetupPosition:
500 Dlg_OnSetupPosition();
501 break;
502
503 // Steering ist mit seiner Aktion fertig
504 case cm_SteeringReady:
505 Dlg_OnSteeringReady();
506 break;
507
508 // es liegen neue Zaehlerwerte vor
509 case cm_CounterSet:
510 Dlg_OnCounterSet();
511 break;
512
513 // Nutzer hat Eingabefeld Detektor-Messzeit angewaehlt
514 case id_ExposureTime:
515 hDlgItem= Ctrl( id_ExposureTime);
516 break;
517
518 // Nutzer hat Return gedrueckt
519 case IDOK:
520 // falls das Return sich nicht auf ein Dialogfeld bezieht, Standardbehandlung durch TModalDlg
521 if ( !hDlgItem )
522 {
523 TModalDlg::Dlg_OnCommand(hwnd, id, hwndCtl, codeNotify);
524 break;
525 };
526 // Der Nutzer hat mit Return eine neue Meßzeit eingegeben
527 if ( hDlgItem == Ctrl( id_ExposureTime) )
528 Dlg_OnExposureTime();
529 hDlgItem= NULL;
530 CtrlSetFocus(cm_SwitchControl);
531 break;
532
533 // Button "Einstellungen" wurde betaetigt
534 case cm_TopographyParam:
535 Dlg_OnTopographyParam();
536 break;
537
538 // Anzeigen im Topographie Ausfuehren Fenster aktualisieren
539 case cm_ParamSet:
540 Dlg_OnParamSet();
541 break;
542
543 // es ist moeglicherweise ein Abbruchfall eingetreten
544 case cm_InquireExeption:
545 Dlg_OnInquireException();
546 break;
547
548 case IDCANCEL:
549 if ( IsProtocolTopographyOn() )
550 SetProtocolTopographyOff(); //! neu: klier Protokollbuch
551 // Kullmann+Reinecker: Hier muss kein break hin, weiter bei TModalDlg::Dlg_OnCommand!
552
553 default:
554 TModalDlg::Dlg_OnCommand(hwnd, id, hwndCtl, codeNotify);
555 };
556 };
557 //-----------------------------------------------------------------------------
558 // Beenden des 'Topographie Durchführung' Fenster
559
560 void TTopographyExecDlg::LeaveDialog( void )
561 {
562 m_lnkTimerMeasuring->StopTimer(); // Beep Timer
563 m_lnkTimerMultiExpose->StopTimer(); // Beep Timer
564 m_lnkTopography->DoLoadMotorSettings(); // Settings des aktuellen Motors zurückschreiben
565 m_lnkTopography->DoResetDetectorParams(); // Detektor zuruecksetzen
566 m_lnkTopography= 0; // Funktionalität freigeben, ABER diese existiert noch
567 };
568
569 //#############################################################################
570 // TTopographyAdjustDlg
571 //#############################################################################
572
573 //-----------------------------------------------------------------------------
574 // Konstruktor
575 // aCtrlStatus gibt an, ob das Fenster von 'Topographie Durchführung' aus gerufen wurde
576
577 TTopographyAdjustDlg::TTopographyAdjustDlg(BOOL aCtrlStatus) : TModalDlg( "TOPOGRAPHYADJUSTDLG", GetMainInstance() )
578 {
579 m_lnkTopography= TTopography::GetInstance(); //POLLING, d.h. KEINE Referenz auf uns übergeben
580 m_bCtrlStatus= aCtrlStatus;
581 // falls Detektor noch nicht gesetzt, auf aktuellen Detektor setzen
582 m_lnkTopography->DoInitDetectors();
583 // Motor (wenn möglich) auf Omega, sonst auf aktuellen Motor setzen
584 // aktuelle Settings im Motor speichern, um diese beim Verlassen wiederherzustellen
585 // FALSE -> Omega ist nicht verfügbar
586 if ( !m_lnkTopography->DoInitMotor() )
587 MessageBox( sth_tp_NoOmega, sth_tp_MsgBoxError, MBSTOP );
588 };
589 // ----------------------------------------------------------------------------
590 // Initalisierung
591
592 BOOL TTopographyAdjustDlg::Dlg_OnInit ( HWND, HWND, LPARAM )
593 {
594 if ( m_bCtrlStatus )
595 {
596 // Wird das Einstellungsfenster von dem Topographie Fenster aus aufgerufen,
597 // so ist nur fuer einige Werte die Eingabe moeglich. Alle anderen Eingabefelder
598 // werden hier deaktiviert und ausgegraut.
599 CtrlSetEnabled(id_ChooseMotor, FALSE);
600 // 02.08.2002 Toter Code : EnableWindow(Ctrl(cm_RotateMotor),FALSE);
601 CtrlSetEnabled(id_ChooseDetector, FALSE);
602 CtrlSetEnabled(id_WorkPoint, FALSE);
603 CtrlSetEnabled(id_Shots, FALSE);
604 CtrlSetEnabled(id_MaxAngleEscape, FALSE);
605 CtrlSetEnabled(id_StepWidth, FALSE);
606 CtrlSetEnabled(id_From, FALSE);
607 CtrlSetEnabled(id_ControlRange, FALSE);
608 CtrlSetEnabled(id_MoveStep, FALSE);
609 CtrlSetEnabled(id_MultipleShot, FALSE);
610 CtrlSetChecked(id_MultipleShot, m_lnkTopography->IsMultipleShot());
611 // 19.11.02 : EnableWindow(Ctrl(id_ControlStep),FALSE);
612 }
613 else
614 {
615 CtrlSetChecked(id_MultipleShot, m_lnkTopography->IsMultipleShot());
616 CtrlSetEnabled(id_StepWidth, m_lnkTopography->IsMultipleShot());
617 CtrlSetEnabled(id_From, m_lnkTopography->IsMultipleShot());
618 CtrlSetEnabled(id_Shots, m_lnkTopography->IsMultipleShot());
619 };
620 // Motoren- /Detektorenauswahlliste aufbauen
621 TDetectorManager::DetectorManager().FillDetectorComboBox( Ctrl(id_ChooseDetector) );
622 for (int i= 0; i < m_lnkTopography->GetMotorCount(); i++)
623 CtrlAddString( id_ChooseMotor, m_lnkTopography->GetMotorName(i) );
624 Dlg_OnParamSet();
625 return TRUE;
626 };
627 // ----------------------------------------------------------------------------
628 // Behandlung der Nachricht cm_ParamSet
629
630 void TTopographyAdjustDlg::Dlg_OnParamSet()
631 {
632 CtrlSetSelString(id_ChooseMotor, m_lnkTopography->GetMotorName(m_lnkTopography->GetActMotor()) );
633 CtrlSetSelString(id_ChooseDetector, m_lnkTopography->GetDetector()->GetCharacteristic() );
634
635 // Steuerelement: 'Arbeitspunkt' -> 'Lage'
636 float fValue= m_lnkTopography->GetWorkPoint() * 100;
637 if ( m_lnkTopography->IsSmallAngleSide() )
638 fValue *= -1.0;
639 CtrlSetFloat( id_WorkPoint, fValue, 1, _DECIMAL);
640
641 // Steuerelement: 'Arbeitspunkt' -> 'Anfahren mit'
642 CtrlSetFloat( id_MoveStep, m_lnkTopography->GetMoveStep(), m_lnkTopography->GetMotorDigits(eSF), _DECIMAL);
643 CtrlSetText( id_MoveStepUnit, m_lnkTopography->GetMotorUnit() ); // die Einheit des aktuellen Antriebs
644
645 // Steuerelement: 'Actuator' -> 'Beschränkung auf'
646 CtrlSetFloat( id_MaxAngleEscape, m_lnkTopography->GetMaxAngleEscape(), 1, _DECIMAL);
647 CtrlSetText( id_Unit, m_lnkTopography->GetMotorUnit()); // die Einheit des aktuellen Antriebs
648
649 // Steuerelement: 'Belichtungsregelung' -> 'Schritt'
650 CtrlSetFloat( id_ControlStep, m_lnkTopography->GetControlStep(), m_lnkTopography->GetMotorDigits(eSF), _DECIMAL);
651 CtrlSetText( id_ControlStepUnit, m_lnkTopography->GetMotorUnit() ); // die Einheit des aktuellen Antriebs
652
653 // Steuerelement: 'Belichtungsregelung' -> 'Bereich'
654 CtrlSetFloat( id_ControlRange, m_lnkTopography->GetControlRange() * 100, 2, _DECIMAL);
655
656 // Steuerelement: 'Detektor-Parameter' -> 'Zeit'
657 CtrlSetFloat( id_MaxTime, m_lnkTopography->GetMaxTime(), 1, _DECIMAL);
658
659 // Steuerelement: 'Mehrfachbelichtung'
660 CtrlSetChecked( id_MultipleShot, m_lnkTopography->IsMultipleShot() );
661
662 // Steuerelement: 'Mehrfach-Belichtung' -> 'Schrittweite'
663 CtrlSetFloat( id_StepWidth, m_lnkTopography->GetAngleBetweenShots(), m_lnkTopography->GetMotorDigits(eSF), _DECIMAL);
664
665 // Steuerelement: 'Mehrfach-Belichtung' -> 'Startwert'
666 CtrlSetDouble( id_From, m_lnkTopography->GetStartAngle(), m_lnkTopography->GetMotorDigits(eDF), _DECIMAL);
667 CtrlSetText( id_FromUnit, m_lnkTopography->GetMotorUnit() ); // die Einheit des aktuellen Antriebs
668
669 // Steuerelement: 'Mehrfach-Belichtung' -> 'Anzahl'
670 CtrlSetLong( id_Shots, m_lnkTopography->GetNumberCycle());
671
672 // Steuerelement: 'Belichtungszeit'
673 CtrlSetLong( id_MeasurementTime, (LONG)(m_lnkTopography->GetMeasurementTime() / 60) );
674
675 // Steuerelement: 'Detektor-Parameter' -> 'Counts'
676 CtrlSetLong( id_MaxCounts, m_lnkTopography->GetMaxCounts());
677
678 //CtrlSetFocus( IDCANCEL ); 11.12.2002 Kullmann. Reinecker funktioniert nicht richtig
679 // das Ctrl hat zwar den Focus, dieser ist aber nicht sichtbar
680 };
681 // ----------------------------------------------------------------------------
682 // Behandlung der Nachricht id_ChooseMotor
683
684 void TTopographyAdjustDlg::Dlg_OnChooseMotor( UINT aCodeNotify )
685 {
686 if ( aCodeNotify != CBN_SELCHANGE )
687 return; // nur Auswahl eines Eintrags interessiert uns
688
689 BOOL bValid= FALSE;
690 int idx= CtrlGetSel( id_ChooseMotor );
691 if ( (m_lnkTopography->GetMotor() != idx) && (idx != CB_ERR) )
692 { // wirklich ein neuer Motor gewählt?
693 m_lnkTopography->SetMotor( idx ); // initialisiert den ausgewaehlten Motor
694 // Aktualisierung der Antriebsliste und aller antriebsspezifischen Einheiten und Nachkommastellen
695 CtrlSetSelString(id_ChooseMotor, m_lnkTopography->GetMotorName(m_lnkTopography->GetActMotor()) );
696
697 CtrlSetFloat( id_MoveStep, CtrlGetFloat(id_MoveStep, m_lnkTopography->GetMotorDigits(eSF), _DECIMAL, bValid), m_lnkTopography->GetMotorDigits(eSF), _DECIMAL);
698 CtrlSetText( id_MoveStepUnit, m_lnkTopography->GetMotorUnit() ); // die Einheit des aktuellen Antriebs
699
700 CtrlSetText( id_Unit, m_lnkTopography->GetMotorUnit()); // die Einheit des aktuellen Antriebs
701
702 CtrlSetFloat( id_ControlStep, CtrlGetFloat(id_ControlStep, m_lnkTopography->GetMotorDigits(eSF), _DECIMAL, bValid), m_lnkTopography->GetMotorDigits(eSF), _DECIMAL);
703 CtrlSetText( id_ControlStepUnit, m_lnkTopography->GetMotorUnit() ); // die Einheit des aktuellen Antriebs
704
705 CtrlSetFloat( id_StepWidth, CtrlGetFloat(id_StepWidth, m_lnkTopography->GetMotorDigits(eSF), _DECIMAL, bValid), m_lnkTopography->GetMotorDigits(eSF), _DECIMAL);
706 CtrlSetText( id_StepWidthUnit, m_lnkTopography->GetMotorUnit() ); // die Einheit des aktuellen Antriebs
707
708 CtrlSetFloat( id_From, CtrlGetFloat(id_From, m_lnkTopography->GetMotorDigits(eDF), _DECIMAL, bValid), m_lnkTopography->GetMotorDigits(eDF), _DECIMAL);
709 CtrlSetText( id_FromUnit, m_lnkTopography->GetMotorUnit() ); // die Einheit des aktuellen Antriebs
710 };
711 };
712 // ----------------------------------------------------------------------------
713 // Behandlung der Nachricht id_ChooseDetector
714
715 void TTopographyAdjustDlg::Dlg_OnChooseDetector( UINT aCodeNotify )
716 {
717 if ( aCodeNotify != CBN_SELCHANGE )
718 return; // nur Auswahl eines Eintrags interessiert uns
719
720 int idx= CtrlGetSel( id_ChooseDetector);
721 if ( (m_lnkTopography->GetDetector() != TDetectorManager::DetectorManager().GetDetector(idx)) && (idx != CB_ERR) )
722 {
723 // setzt den ausgewaehlten Detektor als aktuellen Detektor ein, aktualisiert die Anzeige
724 m_lnkTopography->SetDetector( TDetectorManager::DetectorManager().GetDetector(idx) );
725 // Aktualisierung der Detektorliste
726 CtrlSetSelString(id_ChooseDetector, m_lnkTopography->GetDetector()->GetCharacteristic());
727 };
728 };
729 // ----------------------------------------------------------------------------
730 // Behandlung der Nachricht von id_MultipleShot
731
732 void TTopographyAdjustDlg::Dlg_OnMultipleShot()
733 {
734 // Bei Aktivierung der Checkbox MultipleShot
735 // Eingabefelder im Bereich Mehrfachbelichtung werden aktiviert
736 // Arbeitspunkt, Lage und Belichtungsregelung Bereich deaktiviert
737 // Bei Deaktivierung entsprechend umgekehrte Aktivierung/Deaktivierung der Eingabefelder
738 m_lnkTopography->SetMultipleShot( CtrlIsChecked( id_MultipleShot ) );
739 CtrlSetEnabled(id_Shots, m_lnkTopography->IsMultipleShot());
740 CtrlSetEnabled(id_From, m_lnkTopography->IsMultipleShot());
741 CtrlSetEnabled(id_StepWidth, m_lnkTopography->IsMultipleShot());
742 CtrlSetEnabled(id_WorkPoint, !m_lnkTopography->IsMultipleShot());
743 CtrlSetEnabled(id_ControlRange, !m_lnkTopography->IsMultipleShot());
744 };
745 // ----------------------------------------------------------------------------
746 // Bearbeitung der Nachrichten an das 'Topographie Einstellen' Fenster
747
748 void TTopographyAdjustDlg::Dlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
749 {
750 switch ( id )
751 {
752 // aktualisieren der Anzeige/Eingabefelder
753 case cm_ParamSet:
754 Dlg_OnParamSet();
755 break;
756
757 // Motor Auswahlbox wurde angewaehlt
758 case id_ChooseMotor:
759 Dlg_OnChooseMotor( codeNotify );
760 break;
761
762 // Detektor Auswahlbox wurde angewaehlt
763 case id_ChooseDetector:
764 Dlg_OnChooseDetector( codeNotify );
765 break;
766
767 // 02.08.02 Toter Code : war Schnellwahl-Knopf für Motorauswahl
768 /*
769 case cm_RotateMotor:
770 mlSetAxis(nMotor+1);
771 nMotor= mlGetAxis();
772 FORWARD_WM_COMMAND(hwnd,cm_ParamSet,0,0,SendMessage);
773 break;
774 */
775
776 // Aktivieren bzw. Deaktivieren der Mehrfachbelichtungs-Checkbox
777 case id_MultipleShot:
778 Dlg_OnMultipleShot();
779 break;
780
781 default:
782 TModalDlg::Dlg_OnCommand(hwnd, id, hwndCtl, codeNotify);
783 };
784 };
785 // ----------------------------------------------------------------------------
786 // Testet alle Eingabefelder, ob die Werte im Wertebereich liegen und uebernimmt sie in TTopographie
787
788 BOOL TTopographyAdjustDlg::CanClose(void)
789 {
790 BOOL bValid= TRUE;
791 BOOL bInputOk= TRUE;
792
793 m_lnkTopography->SetMultipleShot( CtrlIsChecked( id_MultipleShot ) ); // Feststellen ob Mehrfachbelichtung ausgewaehlt
794
795 // Steuerelement: 'Belichtungsregelung' -> 'Bereich'
796 if ( !m_lnkTopography->SetControlRange( CtrlGetFloat(id_ControlRange, 2, _DECIMAL, bValid)) )
797 {
798 MessageBox( sth_tp_ValueExposureRange, sth_tp_MsgBoxError, MBSTOP );
799 bInputOk= FALSE;
800 };
801 // Steuerelement: 'Belichtungsregelung' -> 'Schritt'
802 if ( !m_lnkTopography->SetControlStep( CtrlGetFloat(id_ControlStep, m_lnkTopography->GetMotorDigits(eSF), _DECIMAL, bValid)) )
803 {
804 MessageBox( sth_tp_ValueExposureStep, sth_tp_MsgBoxError, MBSTOP );
805 bInputOk= FALSE;
806 };
807 // Steuerelement: 'Belichtungszeit'
808 if ( !m_lnkTopography->SetMeasurementTime( (LONG)(CtrlGetLong(id_MeasurementTime, bValid) * 60) ))
809 {
810 MessageBox( sth_tp_ValueExposureTime, sth_tp_MsgBoxError, MBSTOP );
811 bInputOk= FALSE;
812 };
813 // Steuerelement: 'Mehrfach-Belichtung' -> 'Anzahl'
814 if ( !m_lnkTopography->SetNumberCycle( (WORD)CtrlGetLong(id_Shots, bValid)) )
815 {
816 MessageBox( sth_tp_ValueCycles, sth_tp_MsgBoxError, MBSTOP );
817 bInputOk= FALSE;
818 };
819 // Steuerelement: 'Mehrfach-Belichtung' -> 'Schrittweite'
820 if ( !m_lnkTopography->SetAngleBetweenShots( CtrlGetFloat(id_StepWidth, m_lnkTopography->GetMotorDigits(eSF), _DECIMAL, bValid)) )
821 {
822 MessageBox( sth_tp_ValueMultiStep, sth_tp_MsgBoxError, MBSTOP );
823 bInputOk= FALSE;
824 };
825 // Steuerelement: 'Mehrfach-Belichtung' -> 'Startwert'
826 if ( !m_lnkTopography->SetStartAngle( CtrlGetFloat(id_From, m_lnkTopography->GetMotorDigits(eDF), _DECIMAL, bValid)) )
827 {
828 MessageBox( sth_tp_ValueMultiStart, sth_tp_MsgBoxError, MBSTOP );
829 bInputOk= FALSE;
830 };
831 // Steuerelement: 'Arbeitspunkt' -> 'Anfahren mit'
832 if ( !m_lnkTopography->SetMoveStep( CtrlGetFloat(id_MoveStep, m_lnkTopography->GetMotorDigits(eSF), _DECIMAL, bValid)) )
833 {
834 MessageBox( sth_tp_ValueWorkpointStep, sth_tp_MsgBoxError, MBSTOP );
835 bInputOk= FALSE;
836 };
837 // Steuerelement: 'Arbeitspunkt' -> 'Lage'
838 if ( !m_lnkTopography->SetWorkPoint( CtrlGetFloat(id_WorkPoint, 1, _DECIMAL, bValid)) )
839 {
840 MessageBox( sth_tp_ValueWorkpointPos, sth_tp_MsgBoxError, MBSTOP );
841 bInputOk= FALSE;
842 };
843 m_lnkTopography->SetSmallAngleSide( CtrlGetFloat(id_WorkPoint, 1, _DECIMAL, bValid) < 0.0 );
844
845 // Steuerelement: 'Actuator' -> 'Beschränkung auf'
846 if ( !m_lnkTopography->SetMaxAngleEscape( CtrlGetFloat(id_MaxAngleEscape, 1, _DECIMAL, bValid)) )
847 {
848 MessageBox( sth_tp_ValueMaxAngle, sth_tp_MsgBoxError, MBSTOP );
849 bInputOk= FALSE;
850 };
851 // Steuerelement: 'Detektor-Parameter' -> 'Zeit'
852 if ( !m_lnkTopography->SetMaxTime( CtrlGetFloat(id_MaxTime, 1, _DECIMAL, bValid)) )
853 {
854 MessageBox( sth_tp_ValueMaxTime, sth_tp_MsgBoxError, MBSTOP );
855 bInputOk= FALSE;
856 };
857 // Steuerelement: 'Detektor-Parameter' -> 'Counts'
858 if ( !m_lnkTopography->SetMaxCounts( CtrlGetLong(id_MaxCounts, bValid)) )
859 {
860 MessageBox( sth_tp_ValueCounts, sth_tp_MsgBoxError, MBSTOP );
861 bInputOk= FALSE;
862 };
863 return ( bValid && bInputOk );
864 };
865 // ----------------------------------------------------------------------------
866 // Aufraeumen beim Schliessen des Einstellungen Topographie Fenster
867
868 void TTopographyAdjustDlg::LeaveDialog(void)
869 {
870 m_lnkTopography->DoLoadMotorSettings(); // Settings des aktuellen Motors zurückschreiben
871 m_lnkTopography= 0;
872 };
873 // ----------------------------------------------------------------------------
874 // __LastLine__
875