File: DETECUSE\dllmain.cpp
1 /*
2 $Header: /vol/baal-vol3/projekt98/quellen/XCTL_32/DETECUSE/dllmain.cpp,v 1.6 2004/05/06 07:33:25 reinecke Exp $
3
4 Projekt : XCTL
5 Subsystem : Detektoren
6 Autor : Jan Picard <picard@informatik.hu-berlin.de> 2001-2002
7 Institut fuer Informatik,
8 Humboldt-Universitaet Berlin
9 Inhalt : In dieser Datei finden sich allgemeine Dinge, die zum Erstellen
10 der counters.dll noetig sind.
11 */
12
13 #include "utils\u_utils.h"
14 #pragma hdrstop
15
16 #include "detecuse\detecuse.h"
17 #include "detecuse\detecgui.h"
18
19 #include "hardware\hwio.h"
20 #include "hardware\hwguids.h"
21
22 //#include "utils\CheckMemory.h" // CHECKMEM
23
24 //--||--\\--||--//--||--\\--||--//--||--\\--||--//--||--\\--||--//--||--\\--||--
25
26 // Globale Deklarationen fuer das DLL-Handling
27 HINSTANCE hModuleInstance;
28 static char dlVersion[ ]= "V 1.52 ("__DATE__")";
29
30 //Verwaltungsstrukturen (Treiber)
31 DeviceList DetectorDrivers;
32 ControllerList DetectorControllers;
33
34 BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwFunction, LPVOID)
35 {
36 switch (dwFunction)
37 {
38 case DLL_PROCESS_ATTACH:
39 // Initialize function array.
40 hModuleInstance= hModule;
41
42 //Initialisieren der Geräteliste für die Detectoren
43 RegisterDrivers(&DetectorDrivers,GUID_RADICON,RADICON);
44 RegisterDrivers(&DetectorDrivers,GUID_TAM9513,GENERIC);
45 RegisterDrivers(&DetectorDrivers,GUID_BRAUNPSD,BRAUN);
46 RegisterDrivers(&DetectorDrivers,GUID_STOEPSD,STOE);
47 break;
48
49 case DLL_PROCESS_DETACH:
50 //CHECKMEM("COUNTERS.DLL"); //hp
51 break;
52 };
53 return TRUE;
54 }
55
56 LPCSTR __declspec(dllexport) WINAPI dlGetVersion( void )
57 {
58 return ( LPCSTR ) dlVersion;
59 };
60
61 HINSTANCE __declspec(dllexport) WINAPI dlGetInstance( void )
62 {
63 return hModuleInstance;
64 };
65
66 Controller* GetController(EDeviceType DeviceID, LPTSTR HardwareID, ControllerList* Controllers, DeviceList* Drivers,
67 DWORD* index)
68 {
69 char szDeviceName[257];
70 memset(szDeviceName, '\0', 257);
71
72 Controller* pCon= Controllers->GetController(DeviceID, HardwareID);
73
74 if (!pCon)
75 { //neuen Controller anlegen
76 switch (DeviceID)
77 {
78 case RADICON:
79 strcpy(szDeviceName, "Radicon");
80 pCon= new TRadiconController(DeviceID, HardwareID, Drivers);
81 break;
82
83 case BRAUN:
84 strcpy(szDeviceName, "BraunPsd");
85 pCon= new TBraunPsdController(DeviceID, HardwareID, Drivers);
86 break;
87
88 case GENERIC:
89 strcpy(szDeviceName, "TAm9513");
90 pCon= new TGenericController(DeviceID, HardwareID, Drivers);
91 //pCon= new StandardController(DeviceID,HardwareID,Drivers);
92 break;
93
94 case STOE:
95 strcpy(szDeviceName, "StoePsd");
96 pCon= new StandardController(DeviceID, HardwareID, Drivers);
97 break;
98
99 default:
100 strcpy(szDeviceName, "Unbekanntes Gerät");
101 pCon= new StandardController(DeviceID, HardwareID, Drivers);
102 break;
103 }
104
105 if (!pCon)
106 {
107 MessageBox(0, "Fehler bei Initialisierung des Controllers", szDeviceName, MB_OK);
108 return (0);
109 }
110
111 if (!pCon->AddClient())
112 {
113 MessageBox(0, "Maximale Anzahl von Clients überschritten.\nEs liegt eine Fehlkonfiguration vor.", szDeviceName, MB_OK);
114 return (0);
115 }
116
117 Controllers->Add(pCon);
118 }
119
120 if (index)
121 *index= Controllers->GetControllerIndex(DeviceID, HardwareID);
122
123 return (pCon);
124 }
125