Changeset 416


Ignore:
Timestamp:
Aug 20, 2012, 2:45:39 PM (12 years ago)
Author:
chronos
Message:
  • Added: TDeviceConnector in PinConnection package for generalized routing serial data to various TCommNode objects.
Location:
PinConnection
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • PinConnection/PinConnection.lpk

    r413 r416  
    2222    <License Value="GNU/GPL"/>
    2323    <Version Minor="4"/>
    24     <Files Count="15">
     24    <Files Count="16">
    2525      <Item1>
    2626        <Filename Value="USerialPort.pas"/>
     
    8080      </Item14>
    8181      <Item15>
     82        <Filename Value="UCommConnector.pas"/>
     83        <UnitName Value="UCommConnector"/>
     84      </Item15>
     85      <Item16>
    8286        <Filename Value="UPinConnection.pas"/>
    8387        <HasRegisterProc Value="True"/>
    8488        <UnitName Value="UPinConnection"/>
    85       </Item15>
     89      </Item16>
    8690    </Files>
    8791    <i18n>
  • PinConnection/PinConnection.pas

    r413 r416  
    1010  USerialPort, UPacketBurst, UCommFrame, UCommHub, UCommPin, UCommSerialPort,
    1111  UCommThread, UCommConcentrator, UCommDelay, UCommTCPClient, UCommTCPServer,
    12   UCommTelnet, UCommTelnetComPortOption, UCommMark, UPinConnection,
    13   LazarusPackageIntf;
     12  UCommTelnet, UCommTelnetComPortOption, UCommMark, UCommConnector,
     13  UPinConnection, LazarusPackageIntf;
    1414
    1515implementation
  • PinConnection/UCommConcentrator.pas

    r414 r416  
    115115  FPins.Concentrator := Self;
    116116  FMain := TCommPin.Create;
     117  FMain.Node := Self;
    117118  FMain.OnSetSatus := MainSetStatus;
    118119  FMain.OnReceive := MainReceive;
  • PinConnection/UCommSerialPort.pas

    r414 r416  
    2020  protected
    2121    procedure SetActive(const AValue: Boolean); override;
     22    procedure AssignTo(Dest: TPersistent); override;
    2223  public
    2324    SerialPort: TSerialPort;
     
    4344  inherited;
    4445  SerialPort.Active := AValue;
     46end;
     47
     48procedure TCommSerialPort.AssignTo(Dest: TPersistent);
     49begin
     50  if Dest is TCommSerialPort then begin
     51    TCommSerialPort(Dest).SerialPort.Assign(SerialPort);
     52  end else inherited;
    4553end;
    4654
  • PinConnection/UCommTCPClient.pas

    r413 r416  
    3535    procedure ReceiveData(Sender: TCommPin; Stream: TListByte);
    3636    procedure SetActive(const AValue: Boolean);
     37  protected
     38    procedure AssignTo(Dest: TPersistent); override;
    3739  public
    3840    Socket: TTCPBlockSocket;
     
    9193    FreeAndNil(FReceiveThread);
    9294  end;
     95end;
     96
     97procedure TCommTCPClient.AssignTo(Dest: TPersistent);
     98begin
     99  if Dest is TCommTCPClient then begin
     100    TCommTCPClient(Dest).Address := Address;
     101    TCommTCPClient(Dest).Port := Port;
     102  end
     103  else inherited;
    93104end;
    94105
  • PinConnection/UCommTelnet.pas

    r414 r416  
    5757    ServerChecked: Boolean;
    5858    SupportedByServer: Boolean;
     59    procedure Assign(Source: TTelnetOption); virtual;
    5960    function CheckOption: Boolean;
    6061    procedure SendCommand(Request, Response: TListByte);
     
    7879    procedure ReadResponse(Response: TListByte);
    7980    function ResponseCount: Integer;
     81  protected
     82    procedure AssignTo(Dest: TPersistent); override;
    8083  public
    8184    Options: TListObject;
     
    9295    procedure SendSubCommand(OptionCode: TTelnetCommand; Request, Response: TListByte);
    9396    procedure SendCommand(Code: TTelnetCode; Request, Response: TListByte);
     97    procedure Purge;
    9498    constructor Create(AOwner: TComponent); override;
    9599    destructor Destroy; override;
     
    114118  if FActive = AValue then Exit;
    115119  FActive := AValue;
     120end;
     121
     122procedure TTelnetOption.Assign(Source: TTelnetOption);
     123begin
     124  SupportedByServer := Source.SupportedByServer;
     125  ServerChecked := Source.ServerChecked;
     126  Code := Source.Code;
     127  FOnRequest := Source.FOnRequest;
     128  Active := Source.FActive;
    116129end;
    117130
     
    306319end;
    307320
     321procedure TCommTelnet.AssignTo(Dest: TPersistent);
     322var
     323  I: Integer;
     324begin
     325  if Dest is TCommTelnet then begin
     326    TCommTelnet(Dest).Timeout := Timeout;
     327    TCommTelnet(Dest).PortType := PortType;
     328    TCommTelnet(Dest).ErrorCount := ErrorCount;
     329    TCommTelnet(Dest).OptionsNegotationEnable := OptionsNegotationEnable;
     330    for I := 0 to Options.Count - 1 do begin
     331      TTelnetOption(TCommTelnet(Dest).Options[I]).Assign(TTelnetOption(Options[I]));
     332      TTelnetOption(TCommTelnet(Dest).Options[I]).Telnet := TCommTelnet(Dest);
     333    end;
     334  end else inherited;
     335end;
     336
    308337procedure TCommTelnet.Register(Option: TTelnetOption);
    309338begin
     
    399428end;
    400429
     430procedure TCommTelnet.Purge;
     431begin
     432  FState := tsNormal;
     433  FResponses.Clear;
     434end;
     435
    401436constructor TCommTelnet.Create(AOwner: TComponent);
    402437begin
  • PinConnection/UCommTelnetComPortOption.pas

    r412 r416  
    4141    constructor Create;
    4242    destructor Destroy; override;
     43    procedure Assign(Source: TTelnetOption); override;
    4344    property FlowControl: TFlowControl read GetFlowControl write SetFlowControl;
    4445    property DataBits: TDataBits read GetDataBits write SetDataBits;
     
    224225end;
    225226
     227procedure TTelnetOptionComPort.Assign(Source: TTelnetOption);
     228begin
     229  FBaudRate := TTelnetOptionComPort(Source).FBaudRate;
     230  FDTR := TTelnetOptionComPort(Source).FDTR;
     231  FRTS := TTelnetOptionComPort(Source).FRTS;
     232  inherited Assign(Source);
     233end;
     234
    226235end.
    227236
Note: See TracChangeset for help on using the changeset viewer.