Second, transceiver service detailed
1. Transceiver Service Analysis Summary
Transceiver Service is the core of the transceiver system, transceiver kernel is responsible for reading the port, transceiver definition and parameters set by channel console from the System Configuration library, runtime dynamic creation and control of communication port and its associated relationship, data collection, distribution, buffer scheduling, log, queue management. The transceiver shell is the implementation of the port that is supported for all types of data sending and receiving.
2. Transceiver Service Design Overview
Transceiver Service is developed by Delphi Service Application, Service application can run in System state rather than user state, by operating system Service control Manager ( SCM) is responsible for the operation of the program management, service has no user interface, belong to the system background program. The transceiver kernel is a series of transceiver methods for establishing and controlling the transceiver shell, while the transceiver Shell is a collection of objects responsible for communication.
Note: Due to performance and load considerations, transceiver kernel only logically realizes the functional division of the shelves, and the component modules are not implemented in a completely object-oriented way.
3. Transceiver Service Implementation Overview
I. Establishment of a service application
Choose New| from Delphi main Menu file Other ... Select New| in the New Items dialog box that pops up Service application, you can see the resulting program framework as follows:
program Project1
uses
Svcmgr,
Unit1 in ' Unit1.pas ' {service1:tservice};
{$R *. RES}
Begin
Application.initialize
Application.createform (TService1, Service1);
Application.Run;
End.
Unit Unit1;
Interface
uses
Windows, Messages, Sysutils, Classes, Graphics, Controls, Svcmgr, Dialogs;
Type
Tservi Ce1 = Class (TService)
Private
{private declarations}
Public
function Getservicecontroller:tservicecont roller; Override
{public declarations}
end;
Var
Service1:tservice1
Implementation
{$R *. DFM}
Procedure ServiceController (Ctrlcode:dword); stdcall
begin
Service1.controller (ctrlcode);
End;
function TService1.GetServiceController:TServiceController;
Begin
Result: = ServiceController,
end,
end.
You can see that, in addition to referencing the Svcmgr for service management in the uses unit, TService1 inherits from Tserviced instead of Tform and an overloaded Getservicecontroller function and stdcall process that is invoked in ServiceController mode, With Delphi to establish a service program and not too much special, Delphi fans may also cheer, this is the strong charm of Delphi Rad. In addition, Service application because can not be directly in the Run-time debugging, there is no user interface, development should consider debugging information without interface output to facilitate debugging error.