| 1 | unit Device;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils, Channel, Forms, Int, FormEx, Generics.Collections;
|
|---|
| 7 |
|
|---|
| 8 | type
|
|---|
| 9 | TDeviceClass = (dcNone, dcKeyboard, dcMouse, dcStorage, dcScreen, dcConsole,
|
|---|
| 10 | dcTimer);
|
|---|
| 11 |
|
|---|
| 12 | TFormDevice = class;
|
|---|
| 13 |
|
|---|
| 14 | TReadEvent = function (DataSize: TIntSize): TInt of object;
|
|---|
| 15 | TWriteEvent = procedure (DataSize: TIntSize; Value: TInt) of object;
|
|---|
| 16 | TReadEvents = TList<TReadEvent>;
|
|---|
| 17 | TWriteEvents = TList<TWriteEvent>;
|
|---|
| 18 |
|
|---|
| 19 | { THandlers }
|
|---|
| 20 |
|
|---|
| 21 | THandlers = class
|
|---|
| 22 | ReadHandlers: TReadEvents;
|
|---|
| 23 | WriteHandlers: TWriteEvents;
|
|---|
| 24 | constructor Create;
|
|---|
| 25 | destructor Destroy; override;
|
|---|
| 26 | end;
|
|---|
| 27 |
|
|---|
| 28 | { TDevice }
|
|---|
| 29 |
|
|---|
| 30 | TDevice = class
|
|---|
| 31 | Name: string;
|
|---|
| 32 | DeviceClass: TDeviceClass;
|
|---|
| 33 | Form: TFormDevice;
|
|---|
| 34 | function GetHandlers: THandlers; virtual;
|
|---|
| 35 | end;
|
|---|
| 36 |
|
|---|
| 37 | { TFormDevice }
|
|---|
| 38 |
|
|---|
| 39 | TFormDevice = class(TFormEx)
|
|---|
| 40 | protected
|
|---|
| 41 | function GetDevice: TDevice; virtual;
|
|---|
| 42 | procedure SetDevice(AValue: TDevice); virtual;
|
|---|
| 43 | public
|
|---|
| 44 | property Device: TDevice read GetDevice write SetDevice;
|
|---|
| 45 | end;
|
|---|
| 46 |
|
|---|
| 47 | resourcestring
|
|---|
| 48 | SNone = 'None';
|
|---|
| 49 | SKeyboard = 'Keyboard';
|
|---|
| 50 | SMouse = 'Mouse';
|
|---|
| 51 | SStorage = 'Storage';
|
|---|
| 52 | SScreen = 'Screen';
|
|---|
| 53 | SConsole = 'Console';
|
|---|
| 54 | STimer = 'Timer';
|
|---|
| 55 |
|
|---|
| 56 | const
|
|---|
| 57 | DeviceClassText: array[TDeviceClass] of string = (SNone, SKeyboard, SMouse,
|
|---|
| 58 | SStorage, SScreen, SConsole, STimer);
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 | implementation
|
|---|
| 62 |
|
|---|
| 63 | { TFormDevice }
|
|---|
| 64 |
|
|---|
| 65 | function TFormDevice.GetDevice: TDevice;
|
|---|
| 66 | begin
|
|---|
| 67 | Result := nil;
|
|---|
| 68 | end;
|
|---|
| 69 |
|
|---|
| 70 | procedure TFormDevice.SetDevice(AValue: TDevice);
|
|---|
| 71 | begin
|
|---|
| 72 | end;
|
|---|
| 73 |
|
|---|
| 74 | { THandlers }
|
|---|
| 75 |
|
|---|
| 76 | constructor THandlers.Create;
|
|---|
| 77 | begin
|
|---|
| 78 | ReadHandlers := TReadEvents.Create;
|
|---|
| 79 | WriteHandlers := TWriteEvents.Create;
|
|---|
| 80 | end;
|
|---|
| 81 |
|
|---|
| 82 | destructor THandlers.Destroy;
|
|---|
| 83 | begin
|
|---|
| 84 | FreeAndNil(ReadHandlers);
|
|---|
| 85 | FreeAndNil(WriteHandlers);
|
|---|
| 86 | inherited;
|
|---|
| 87 | end;
|
|---|
| 88 |
|
|---|
| 89 | { TDevice }
|
|---|
| 90 |
|
|---|
| 91 | function TDevice.GetHandlers: THandlers;
|
|---|
| 92 | begin
|
|---|
| 93 | Result := nil;
|
|---|
| 94 | end;
|
|---|
| 95 |
|
|---|
| 96 | end.
|
|---|
| 97 |
|
|---|