File: MOTRSTRG\M_LAYER.CPP
1 #include "utils\u_utils.h"
2 #include "winresrc\rc_def.h" // Ressourcen-IDs
3 #pragma hdrstop
4
5 #include "motrstrg\motrstrg.h"
6 #include "motrstrg\m_layer.h"
7 #include "motrstrg\m_motcom.h"
8 #include "motrstrg\m_mothw.h"
9
10 #include "hardware\hwio.h"
11 #include "hardware\hwguids.h"
12
13 #include "utils\CheckMemory.h" // CHECKMEM
14
15 //--||--\\--||--//--||--\\--||--//--||--\\--||--//--||--\\--||--//--||--\\--||--
16
17 HINSTANCE hModuleInstance;
18
19 static char mlVersion[ ]= "V 1.51 ("__DATE__")";
20
21 static int bModulLoaded= FALSE;
22 static BOOL bReadyHit;
23 static int MoveFinishIdx;
24 static int nTimeTicks= 20;
25 static int nCallBackAction= 0;
26 static const nScanSize= 150;
27 static long Scan[ nScanSize + 1 ];
28 static UINT nEvent;
29 static UINT nCycle= nScanSize;
30 static BOOL bScanReady= TRUE;
31 static BOOL bShowEncoder= FALSE;
32
33 DeviceList MotorDrivers;
34 ControllerList MotorControllers;
35
36 extern int nC812;
37
38 char buf[ MaxString ];
39
40 LPMList _MOTORCLASS lpMList= NULL; // Kullmann, Reinecker (02.08.02) exportiert
41
42 LPCSTR _MOTORCLASS WINAPI mlGetVersion( void )
43 {
44 return ( LPCSTR ) mlVersion;
45 };
46
47 HINSTANCE _MOTORCLASS WINAPI mlGetInstance( void )
48 {
49 return hModuleInstance;
50 };
51
52 //******************************************************************************
53 //***** Routines for optimizing the motors *************************************
54 //******************************************************************************
55
56 // forward declaration, s.u.
57 void _MOTORCLASS CALLBACK mSavePosition( UINT, UINT, DWORD, DWORD, DWORD );
58
59 int _MOTORCLASS WINAPI mGetScanSize( void )
60 {
61 return nScanSize;
62 };
63
64 // VORSICHT: 2. int-Parameter ist nicht deklariert
65 void _MOTORCLASS WINAPI mStartMoveScan( int tic, int )
66 {
67 if ( !bScanReady )
68 return;
69 nCycle= 0;
70 memset( Scan, 0, nScanSize );
71 bReadyHit= FALSE;
72 bScanReady= FALSE;
73 nTimeTicks= tic;
74 lpMList -> MP() -> StartCheckScan();
75 };
76
77 void TC_812ISA::StartCheckScan( void )
78 {
79 // timeBeginPeriod(1);
80 nCallBackAction= 1;
81 nEvent= timeSetEvent( nTimeTicks, 1, (LPTIMECALLBACK)mSavePosition, 0,
82 TIME_PERIODIC );
83 MoveByPosition( wPositionWidth );
84 };
85
86 void TC_832::StartCheckScan( void )
87 {
88 // timeBeginPeriod(1);
89 nCallBackAction= 1;
90 nEvent= timeSetEvent( nTimeTicks, 1, (LPTIMECALLBACK)mSavePosition, 0,
91 TIME_PERIODIC );
92 MoveByPosition( wPositionWidth );
93 };
94
95 LPLONG _MOTORCLASS WINAPI mGetMoveScan( void )
96 {
97 bScanReady= TRUE;
98 return ( LPLONG ) Scan;
99 };
100
101 int _MOTORCLASS WINAPI mGetMoveFinishIdx( void )
102 {
103 return MoveFinishIdx;
104 };
105
106 void _MOTORCLASS CALLBACK mSavePosition( UINT nEvent, UINT, DWORD, DWORD, DWORD )
107 {
108 switch ( nCallBackAction )
109 {
110 case 1:
111 lpMList -> MP() -> GetPosition( FALSE );
112 Scan[ nCycle++ ]= lpMList -> MP() -> GetPosition(); //Neu : Kullmann, Reinecker (27.07.02) lPosition ersetzt
113 if ( !bReadyHit )
114 if ( lpMList -> MP() -> IsMoveFinish() )
115 {
116 bReadyHit= TRUE;
117 MoveFinishIdx= nCycle - 1;
118 }
119 if ( nCycle >= nScanSize )
120 {
121 timeKillEvent( nEvent );
122 nCycle= 0;
123 PostMessage( GetScanHandle(), WM_COMMAND, cm_MoveScanReady, 0 );
124 }
125 break;
126
127 case 2:
128 nCycle= 0;
129 MoveFinishIdx= 1;
130 PostMessage( GetScanHandle(), WM_COMMAND, cm_MoveScanReady, 0 );
131 break;
132 }
133 };
134 //******************************************************************************
135 //******************************************************************************
136
137 //******************************************************************************
138 //***** C-Call interface for TMList ********************************************
139 //******************************************************************************
140 BOOL _MOTORCLASS WINAPI mlInitializeMotorsDLL( void )
141 {
142 bModulLoaded= FALSE;
143 bShowEncoder= GetPrivateProfileInt( "Steuerprogramm", "ArrangeMode", 0,
144 GetCFile( ) );
145 if ( !lpMList->InitializeModule( ) )
146 return FALSE;
147 // Motors.dll initialisiert, ini-Datei erfolgreich eingelesen
148 bModulLoaded= TRUE;
149 return TRUE;
150 };
151
152 BOOL _MOTORCLASS WINAPI mlSetAxis( int axis )
153 {
154 // bestimmte Achse wird aktiviert
155 if ( lpMList->SetAxis( axis ) )
156 return TRUE;
157 lpMList->SetAxis( 0 );
158 return FALSE;
159 };
160
161 int _MOTORCLASS WINAPI mlGetAxis( void )
162 {
163 // Rueckgabe der aktiven Achse
164 return lpMList->GetAxis( );
165 //TMList::GetAxis() ist inline in m_motcom.h definiert
166 };
167
168 int _MOTORCLASS WINAPI mlGetIdByName( EAxisType at )
169 {
170 int id= -1;
171 // Rückgabe der Achsen-ID
172 switch ( at )
173 {
174 case X:
175 id= lpMList->AD_X;
176 break;
177
178 case Y:
179 id= lpMList->AD_Y;
180 break;
181
182 case Z:
183 id= lpMList->AD_Z;
184 break;
185
186 case Omega:
187 id= lpMList->AD_Omega;
188 break;
189
190 case Theta:
191 id= lpMList->AD_Theta;
192 break;
193
194 case Phi:
195 id= lpMList->AD_Phi;
196 break;
197
198 case Psi:
199 id= lpMList->AD_Psi;
200 break;
201
202 case Encoder:
203 id= lpMList->AD_Encoder;
204 break;
205
206 case Monochromator:
207 id= lpMList->AD_Monochromator;
208 break;
209
210 case Absorber:
211 id= lpMList->AD_Absorber;
212 break;
213
214 case Collimator:
215 id= lpMList->AD_Collimator;
216 break;
217
218 case DF:
219 id= lpMList->AD_DF;
220 break;
221
222 case DC:
223 id= lpMList->AD_DC;
224 break;
225
226 case Tilt:
227 id= lpMList->AD_Tilt;
228 break;
229
230 case Rotation:
231 id= lpMList->AD_Rotation;
232 break;
233 }
234 return id;
235 };
236
237 EAxisType _MOTORCLASS WINAPI mlParsingAxis( LPSTR axisname )
238 {
239 return lpMList->ParsingAxis( axisname );
240 };
241
242 BOOL _MOTORCLASS WINAPI mlIsAxisValid( EAxisType type )
243 {
244 switch ( type )
245 {
246 case X:
247 return ( lpMList->AD_X > -1 );
248
249 case Y:
250 return ( lpMList->AD_Y > -1 );
251
252 case Z:
253 return ( lpMList->AD_Z > -1 );
254
255 case Omega:
256 return ( lpMList->AD_Omega > -1 );
257
258 case Theta:
259 return ( lpMList->AD_Theta > -1 );
260
261 case Phi:
262 return ( lpMList->AD_Phi > -1 );
263
264 case Psi:
265 return ( lpMList->AD_Psi > -1 );
266
267 case Encoder:
268 return ( lpMList->AD_Encoder > -1 );
269
270 case Monochromator:
271 return ( lpMList->AD_Monochromator > -1 );
272
273 case Absorber:
274 return ( lpMList->AD_Absorber > -1 );
275
276 case Collimator:
277 return ( lpMList->AD_Collimator > -1 );
278
279 case DF:
280 return ( lpMList->AD_DF > -1 );
281
282 case DC:
283 return ( lpMList->AD_DC > -1 );
284
285 case Tilt:
286 return ( lpMList->AD_Tilt > -1 );
287
288 case Rotation:
289 return ( lpMList->AD_Rotation > -1 );
290
291 default:
292 return FALSE;
293 }
294 };
295
296 BOOL _MOTORCLASS WINAPI mlIsServerOK( void )
297 {
298 return bModulLoaded;
299 };
300
301 int _MOTORCLASS WINAPI mlGetAxisNumber( void )
302 {
303 return lpMList->GetAxisNumber( );
304 };
305
306 double _MOTORCLASS WINAPI mlGetOffset( int mid )
307 {
308 return lpMList->MP( mid ) ->GetAngleBias(); //Neu : Kullmann, Reinecker (27.07.02) dAngleBias ersetzt
309 };
310
311 void _MOTORCLASS WINAPI mlSetAngleDefault( void )
312 {
313 lpMList->SetAngleDefault( );
314 };
315
316 void _MOTORCLASS WINAPI mlOptimizingDlg( void )
317 {
318 PostMessage( GetFrameHandle( ), WM_COMMAND, cm_CallExecuteScan, 0l );
319 lpMList->MP( ) ->OptimizingDlg( );
320 };
321
322 UINT _MOTORCLASS WINAPI mlGetDigits ( int mid )
323 {
324 return lpMList->MP( mid ) ->GetDigits();
325 }
326
327 double _MOTORCLASS WINAPI mlGetValue( int mid, EValueType vtype )
328 {
329 switch ( vtype )
330 {
331 case Distance:
332 return lpMList->MP( mid ) -> GetAngle(); //Neu : Kullmann, Reinecker (27.07.02) dAngle ersetzt
333
334 case MinDistance:
335 //Neu : Kullmann, Reinecker (27.07.02) dAngleMin ersetzt
336 return min( lpMList->MP( mid ) -> GetAngleMin(),
337 lpMList->MP( mid ) -> GetAngleMax() ); //29.01.2003 Kullmann+Reinecker: GetAngleMin ersetzt durch min(AngleMin, AngleMax)
338
339 case MaxDistance:
340 //Neu : Kullmann, Reinecker (27.07.02) dAngleMax ersetzt
341 return max( lpMList->MP( mid ) -> GetAngleMin(),
342 lpMList->MP( mid ) -> GetAngleMax() ); //29.01.2003 Kullmann+Reinecker: GetAngleMax ersetzt durch max(AngleMin, AngleMax)
343
344 case MinDistanceRel:
345 //Neu : 17.07.2003
346 return min( lpMList->MP( mid ) -> GetAngleRelativeMin(),
347 lpMList->MP( mid ) -> GetAngleRelativeMax() );
348
349 case MaxDistanceRel:
350 //Neu : 17.07.2003
351 return max( lpMList->MP( mid ) -> GetAngleRelativeMin(),
352 lpMList->MP( mid ) -> GetAngleRelativeMax() );
353
354 case Speed:
355 return lpMList->MP( mid ) -> GetSpeed();
356
357 case MinSpeed:
358 return lpMList->MP( mid ) -> GetMinSpeed();
359
360 case MaxSpeed:
361 return lpMList->MP( mid ) -> GetMaxSpeed();
362
363 case Width:
364 return lpMList->MP( mid ) -> GetAngleWidth();
365
366 case MinWidth:
367 return lpMList->MP( mid ) -> GetMinAngleWidth();
368
369 case Acceleration:
370 return lpMList->MP( mid ) -> GetAcceleration();
371
372 default:
373 return 1.0;
374 }
375 };
376
377 double _MOTORCLASS WINAPI mlGetAngleRelativeMin( int mid )
378 {
379 return lpMList->MP( mid ) -> GetAngleRelativeMin();
380 };
381
382 double _MOTORCLASS WINAPI mlGetAngleRelativeMax( int mid )
383 {
384 return lpMList->MP( mid ) -> GetAngleRelativeMax();
385 };
386
387 BOOL _MOTORCLASS WINAPI mlMoveToDistance( int mid, double distance )
388 {
389 // Wurde motors.dll korrekt initialisiert ?
390 // wenn INI-Datei nicht erfolgreich geladen -> FALSE
391 if ( !bModulLoaded )
392 return FALSE;
393 // VORSICHT: keine Fehlerkontrolle bei Fkt.-Ausfuehrung
394 // distance ist ein Winkelmass und muss in MoveToAngel() in Position
395 // uebertragen ( Translate()-Fkt. ) werden
396 // Keine Behandlung von MoveToAngle()-Rueckgabewert FALSE
397 // (Winkel distance ist keine gueltige Position bzw.
398 // MoveAbsolute() in MoveToPosition() des akt. Motors schlaegt fehl)
399 lpMList->MP( mid ) ->MoveToAngle( distance );
400 // VORSICHT: Fkt. gibt immer TRUE zurueck - Fehler ??
401 return TRUE;
402 };
403
404 BOOL _MOTORCLASS WINAPI mlIsMoveFinish( int mid )
405 {
406 return lpMList->MP( mid ) ->IsMoveFinish( );
407 };
408
409 void _MOTORCLASS WINAPI mlSetParametersDlg( void )
410 {
411 lpMList->SetParametersDlg( );
412 };
413
414 void _MOTORCLASS WINAPI mlPositionControlDlg( void )
415 {
416 lpMList->PositionControlDlg( );
417 };
418
419 void _MOTORCLASS WINAPI mlSaveModuleSettings( void )
420 {
421 lpMList->SaveModuleSettings( );
422 };
423
424 void _MOTORCLASS WINAPI mlInquireReferencePointDlg( BOOL task ) // Parameter geändert int -> BOOL (08.08.02)
425 {
426 lpMList->InquireReferencePointDlg( task );
427 };
428
429 //******************************************************************************
430 //***** C-Call interface for TMotor ********************************************
431 //******************************************************************************
432 BOOL _MOTORCLASS WINAPI mSetLine( int number, BOOL state )
433 {
434 // wurde motors.dll korrekt initialisiert ? NEIN -> Abbruch
435 if ( !bModulLoaded )
436 return FALSE;
437 return lpMList->MP( nC812 ) ->SetLine( number, state );
438 };
439
440 void _MOTORCLASS WINAPI mlSetRelativeZero( int axis, BOOL yes, double value )
441 {
442 if ( yes )
443 // lpMList->MP(axis) -> dAngleBias -= value;
444 lpMList->MP(axis) -> SetAngleBias( lpMList->MP(axis)->GetAngleBias() - value ); //Neu : Kullmann, Reinecker (27.07.02) dAngleBias ersetzt
445 else
446 // lpMList->MP(axis) -> dAngleBias= 0.0;
447 lpMList->MP(axis) -> SetAngleBias( 0.0 ); //Neu : Kullmann, Reinecker (27.07.02) dAngleBias ersetzt
448 }
449 void _MOTORCLASS WINAPI mSetRelativeZero( BOOL yes, double value )
450 {
451 if ( yes )
452 // lpMList->MP( ) -> dAngleBias -= value;
453 lpMList->MP( ) -> SetAngleBias( lpMList->MP( )->GetAngleBias() - value ); //Neu : Kullmann, Reinecker (27.07.02) dAngleBias ersetzt
454 else
455 // lpMList->MP( ) -> dAngleBias= 0.0;
456 lpMList->MP( ) -> SetAngleBias( 0.0 ); //Neu : Kullmann, Reinecker (27.07.02) dAngleBias ersetzt
457 }
458
459 BOOL _MOTORCLASS WINAPI mlIsDistanceRelative( int axis )
460 {
461 return ( lpMList->MP(axis) ->GetAngleBias() != 0.0 ); //Neu : Kullmann, Reinecker (27.07.02) dAngleBias ersetzt
462 }
463 BOOL _MOTORCLASS WINAPI mIsDistanceRelative( void )
464 {
465 return ( lpMList->MP( ) ->GetAngleBias() != 0.0 ); //Neu : Kullmann, Reinecker (27.07.02) dAngleBias ersetzt
466 }
467
468 BOOL _MOTORCLASS WINAPI mIsRangeHit( void )
469 {
470 return lpMList->MP( ) -> IsRangeHit( );
471 };
472
473 BOOL _MOTORCLASS WINAPI mMoveByDistance( double angle )
474 {
475 // wurde motors.dll korrekt initialisiert ? NEIN -> Abbruch
476 if ( !bModulLoaded )
477 return FALSE;
478 // VORSICHT: keine Fehlerkontrolle bei Fkt.-Ausfuehrung
479 lpMList->MP( ) ->MoveByAngle( angle );
480 // VORSICHT: Fkt. gibt immer TRUE zurueck - Fehler ??
481 return TRUE;
482 };
483
484 BOOL _MOTORCLASS WINAPI mMoveToDistance( double angle )
485 {
486 // Wurde motors.dll korrekt initialisiert ?
487 // wenn INI-Datei nicht erfolgreich geladen -> FALSE
488 if ( !bModulLoaded )
489 return FALSE;
490 // VORSICHT: keine Fehlerkontrolle bei Fkt.-Ausfuehrung
491 // distance ist ein Winkelmass und muss in MoveToAngel() in Position
492 // uebertragen ( Translate()-Fkt. ) werden
493 // Keine Behandlung von MoveToAngle()-Rueckgabewert FALSE
494 // (Winkel distance ist keine gueltige Position bzw.
495 // MoveAbsolute() in MoveToPosition() des akt. Motors schlaegt fehl)
496 lpMList->MP( ) -> MoveToAngle( angle );
497 // VORSICHT: Fkt. gibt immer TRUE zurueck - Fehler ??
498 return TRUE;
499 };
500
501 BOOL _MOTORCLASS WINAPI mIsMoveFinish( void )
502 {
503 // wurde motors.dll korrekt initialisiert ?
504 // VORSICHT: im Fehlerfall (keine korrekte Init.) Rueckgabe TRUE ??
505 if ( !bModulLoaded )
506 return TRUE;
507 return lpMList->MP( ) ->IsMoveFinish( );
508 };
509
510 BOOL _MOTORCLASS WINAPI mlGetDistance( int mid, double& distance )
511 {
512 // Falls Motor nicht in Fahrt & kein Auslesefehler
513 // dann ist in MemberVar dAngel akt. Winkel gespeichert
514 if ( lpMList->MP( mid ) ->GetAngle( TRUE ) )
515 {
516 // Distanz wird als Winkel dAngel zurueckgeliefert
517 distance= lpMList->MP( mid ) ->GetAngle(); //Neu : Kullmann, Reinecker (27.07.02) dAngle ersetzt
518 return TRUE;
519 }
520 distance= 0.0;
521 return FALSE;
522 };
523 BOOL _MOTORCLASS WINAPI mGetDistance( double &ang )
524 {
525 // Falls Motor nicht in Fahrt & kein Auslesefehler
526 // dann ist in MemberVar dAngel akt. Winkel gespeichert
527 if ( lpMList->MP( ) ->GetAngle( TRUE ) )
528 {
529 // Distanz wird als Winkel dAngel zurueckgeliefert
530 ang= lpMList->MP( ) ->GetAngle(); //Neu : Kullmann, Reinecker (27.07.02) dAngle ersetzt
531 if ( !bShowEncoder )
532 return TRUE;
533 sprintf( buf, "%ld", lpMList->MP( ) -> GetPosition() ); //Neu : Kullmann, Reinecker (27.07.02) lPosition ersetzt
534 SetStatus( buf );
535 return TRUE;
536 }
537 ang= 0.0;
538 return FALSE;
539 };
540
541 double _MOTORCLASS WINAPI mlGetDistanceProcess( int axis )
542 {
543 lpMList->MP(axis) ->GetAngle( 0 );
544 return lpMList->MP(axis) -> GetAngle(); //Neu : Kullmann, Reinecker (27.07.02) dAngle ersetzt
545 };
546 double _MOTORCLASS WINAPI mGetDistanceProcess( void )
547 {
548 lpMList->MP( ) ->GetAngle( 0 );
549 return lpMList->MP( ) -> GetAngle(); //Neu : Kullmann, Reinecker (27.07.02) dAngle ersetzt
550 };
551
552 //! neu Kullmann+Reinecker: Statt GetDF() verwenden wir lieber eine andere Konvertierungsfkt.
553 UINT _MOTORCLASS WINAPI mGetDigits ( void )
554 {
555 return lpMList->MP( ) ->GetDigits();
556 };
557
558 void _MOTORCLASS WINAPI mStopDrive( BOOL restart )
559 {
560 lpMList->MP( ) ->StopDrive( restart );
561 };
562
563 double _MOTORCLASS WINAPI mGetValue( EValueType vtype )
564 {
565 switch ( vtype )
566 {
567 case Distance:
568 return lpMList->MP() -> GetAngle(); //Neu : Kullmann, Reinecker (27.07.02) dAngle ersetzt
569
570 case MinDistance:
571 //Neu : Kullmann, Reinecker (27.07.02) dAngleMin ersetzt
572 return min( lpMList->MP() -> GetAngleMin(),
573 lpMList->MP() -> GetAngleMax() ); //29.01.2003 Kullmann+Reinecker: GetAngleMin ersetzt durch min(AngleMin, AngleMax)
574
575 case MaxDistance:
576 //Neu : Kullmann, Reinecker (27.07.02) dAngleMax ersetzt
577 return max( lpMList->MP() -> GetAngleMin(),
578 lpMList->MP() -> GetAngleMax() ); //29.01.2003 Kullmann+Reinecker: GetAngleMax ersetzt durch max(AngleMin, AngleMax)
579
580 case MinDistanceRel:
581 //Neu : 17.07.2003
582 return min( lpMList->MP() -> GetAngleRelativeMin(),
583 lpMList->MP() -> GetAngleRelativeMax() );
584
585 case MaxDistanceRel:
586 //Neu : 17.07.2003
587 return max( lpMList->MP() -> GetAngleRelativeMin(),
588 lpMList->MP() -> GetAngleRelativeMax() );
589
590 case Speed:
591 return lpMList->MP() -> GetSpeed();
592
593 case MinSpeed:
594 return lpMList->MP() -> GetMinSpeed();
595
596 case MaxSpeed:
597 return lpMList->MP() -> GetMaxSpeed();
598
599 case Width:
600 return lpMList->MP() -> GetAngleWidth();
601
602 case MinWidth:
603 return lpMList->MP() -> GetMinAngleWidth();
604
605 case Acceleration:
606 return lpMList->MP() -> GetAcceleration();
607
608 default:
609 return 1.0;
610 }
611 };
612
613 double _MOTORCLASS WINAPI mGetAngleRelativeMin( void )
614 {
615 return lpMList->MP() -> GetAngleRelativeMin();
616 }
617
618 double _MOTORCLASS WINAPI mGetAngleRelativeMax( void )
619 {
620 return lpMList->MP() -> GetAngleRelativeMax();
621 }
622
623 BOOL _MOTORCLASS WINAPI mlSetValue( int axis, EValueType vtype, double value )
624 {
625 switch ( vtype )
626 {
627 case Speed:
628 return lpMList->MP(axis) -> SetSpeed( value );
629
630 case Width:
631 return lpMList->MP(axis) -> SetAngleWidth( value );
632
633 // VORSICHT: nicht zu setzende Cases: immer FALSE
634 default:
635 return FALSE;
636 }
637 };
638 BOOL _MOTORCLASS WINAPI mSetValue( EValueType vtype, double value )
639 {
640 switch ( vtype )
641 {
642 case Speed:
643 return lpMList->MP( ) -> SetSpeed( value );
644
645 case Width:
646 return lpMList->MP( ) -> SetAngleWidth( value );
647
648 // VORSICHT: nicht zu setzende Cases: immer FALSE
649 default:
650 return FALSE;
651 }
652 };
653
654 EUnitType _MOTORCLASS WINAPI mlGetUnit( int axis ) {
655 return lpMList->MP(axis)->GetUnit(); //Neu : Kullmann, Reinecker (27.07.02) eUnit ersetzt
656 }
657 EUnitType _MOTORCLASS WINAPI mGetUnit( void )
658 {
659 return lpMList->MP( )->GetUnit(); //Neu : Kullmann, Reinecker (27.07.02) eUnit ersetzt
660 };
661
662 BOOL _MOTORCLASS WINAPI mlIsCalibrated( int axis )
663 {
664 return lpMList->MP(axis) ->IsCalibrated( );
665 };
666 BOOL _MOTORCLASS WINAPI mIsCalibrated( void )
667 {
668 return lpMList->MP( ) ->IsCalibrated( );
669 };
670
671 void _MOTORCLASS WINAPI mActivateDrive( void )
672 {
673 lpMList->MP( ) ->ActivateDrive( );
674 };
675
676 void _MOTORCLASS WINAPI mlSetCorrectionState( int axis, BOOL onoff )
677 {
678 lpMList->MP(axis) ->SetCorrectionState( onoff );
679 };
680 void _MOTORCLASS WINAPI mSetCorrectionState( BOOL onoff )
681 {
682 lpMList->MP( ) ->SetCorrectionState( onoff );
683 };
684
685 LPCSTR _MOTORCLASS WINAPI mlGetAxisName( int axis )
686 {
687 return lpMList->MP(axis) ->pCharacteristic( );
688 };
689 LPCSTR _MOTORCLASS WINAPI mGetAxisName( void )
690 {
691 return lpMList->MP( ) ->pCharacteristic( );
692 };
693
694 LPCSTR _MOTORCLASS WINAPI mlGetUnitName( int mid ) {
695 return lpMList->MP( mid )->GetUnitName();
696 }
697 LPCSTR _MOTORCLASS WINAPI mGetUnitName( void )
698 {
699 return ( LPCSTR ) lpMList->MP( ) ->GetUnitName(); //Neu : Kullmann, Reinecker (27.07.02) szUnit ersetzt
700 };
701
702 LPCSTR _MOTORCLASS WINAPI mGetSF( void )
703 {
704 return lpMList->MP( ) ->pSF( );
705 };
706
707 LPCSTR _MOTORCLASS WINAPI mGetDF( void )
708 {
709 return lpMList->MP( ) ->pDF( );
710 };
711
712 int _MOTORCLASS WINAPI mExecuteCmd( LPSTR cmd )
713 {
714 return lpMList->MP( ) ->ExecuteCmd( cmd );
715 };
716
717 void _MOTORCLASS WINAPI mPushSettings( void )
718 {
719 lpMList->MP( ) ->PushSettings( );
720 };
721
722 void _MOTORCLASS WINAPI mPopSettings( EMParameter mp )
723 {
724 lpMList->MP( ) ->PopSettings( mp );
725 };
726
727 //******************************************************************************
728 //******************************************************************************
729 TMFunctionTable MFT;
730
731 BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwFunction, LPVOID)
732 {
733 if ( !lpMList )
734 lpMList= ( LPMList ) new TMList( 10 ); // TMList zweiten Parameter, hier: NULL, entfernt (08.08.02)
735
736 switch ( dwFunction )
737 {
738 case DLL_PROCESS_ATTACH:
739 hModuleInstance= hModule;
740 if ( !lpMList )
741 lpMList= ( LPMList ) new TMList( 10 ); // TMList zweiten Parameter, hier: NULL, entfernt (08.08.02)
742 // Initialize function array.
743 MFT.InitializeMotorsDLL= ( TInitializeMotorsDLL ) mlInitializeMotorsDLL;
744 MFT.SetAxis= ( TSetAxis ) mlSetAxis;
745 MFT.GetAxis= ( TGetAxis ) mlGetAxis;
746 MFT.MoveToDistance= ( TMoveToDistance ) mMoveToDistance;
747 MFT.MoveByDistance= ( TMoveByDistance ) mMoveByDistance;
748 MFT.SetLine= ( TSetLine ) mSetLine;
749 MFT.IsMoveFinish= ( TIsMoveFinish ) mIsMoveFinish;
750 MFT.GetDistance= ( TGetDistance ) mGetDistance;
751 MFT.IsServerOK= ( TIsServerOK ) mlIsServerOK;
752
753 RegisterDrivers(&MotorDrivers,GUID_C812,C812);
754 RegisterDrivers(&MotorDrivers,GUID_C832,C832);
755 break;
756
757 case DLL_PROCESS_DETACH:
758 bModulLoaded= FALSE;
759 //CHECKMEM("MOTORS.DLL"); //hp
760 break;
761 }
762
763 return TRUE;
764 }
765
766 Controller* GetController(EDeviceType DeviceID, LPTSTR HardwareID, ControllerList* Controllers, DeviceList* Drivers,
767 DWORD* index)
768 {
769 char szDeviceName[257];
770 memset(szDeviceName, '\0', 257);
771
772 Controller* pCon= Controllers->GetController(DeviceID, HardwareID);
773
774 if (!pCon)
775 { //neuen Controller anlegen
776 switch (DeviceID)
777 {
778 case C812:
779 strcpy(szDeviceName, "C-812");
780 pCon= new TC_812Controller(DeviceID, HardwareID, Drivers);
781 break;
782
783 case C832:
784 strcpy(szDeviceName, "C-832");
785 pCon= new TC_832Controller(DeviceID, HardwareID, Drivers);
786 break;
787
788 default:
789 strcpy(szDeviceName, "Unbekanntes Gerät");
790 pCon= new StandardController(DeviceID, HardwareID, Drivers);
791 }
792
793 if (!pCon)
794 {
795 MessageBox(0, "Fehler bei Initialisierung des Controllers", szDeviceName, MBINFO);
796 return (0);
797 }
798
799 if (!pCon->AddClient())
800 {
801 MessageBox(0, "Maximale Anzahl von Clients überschritten.\nEs liegt eine Fehlkonfiguration vor.", szDeviceName, MBINFO);
802 return (0);
803 }
804
805 Controllers->Add(pCon);
806 }
807
808 if (index)
809 *index= Controllers->GetControllerIndex(DeviceID, HardwareID);
810
811 return (pCon);
812 }
813
814
815
816 // __LastLine__
817