summaryrefslogtreecommitdiff
path: root/fernbedienung.lpr
blob: e7a2412ba4b33e113d30b5991838e15841f0097a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
program fernbedienung;

{$mode objfpc}{$H+}

{$DEFINE UseCThreads}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes, SysUtils, CustApp, lesethreadunit
  { you can add units after this },
  lowlevelunit, irdecoderunit, gitupdateunit;

type

  { tFernbedienung }

  tFernbedienung = class(tCustomApplication)
  protected
    procedure doRun; override;
  private
    irDecoder:   tIRDecoder;
    inputDatei:  string;
    watte,debug: boolean;
  public
    constructor create(theOwner: TComponent); override;
  end;


  { tFernbedienung }

procedure tFernbedienung.doRun;
var
  errorMsg: String;
begin
  // quick check parameters
  errorMsg:=checkOptions('WdI:','Watte debug Input:');

  if (errorMsg='') and
     not hasOption('I','Input') then
    errorMsg:='Erwarte Input: ''-I $Input''';

  if errorMsg<>'' then begin
    showException(exception.create(errorMsg));
    terminate;
    exit;
  end;

  inputDatei:=getOptionValue('I','Input');
  watte:=hasOption('W','Watte');
  debug:=hasOption('d','debug');

  irDecoder:=tIRDecoder.create(inputDatei,extractfilepath(paramstr(0))+'befehle.konf',watte,debug);

  repeat
    repeat
      while irDecoder.zeileVerarbeitet do;
    until not irDecoder.befehlVerarbeitet;
    sleep(100);
  until false;

  irDecoder.free;
  // stop program loop
  Terminate;
end;


constructor tFernbedienung.create(theOwner: TComponent);
begin
  inherited Create(TheOwner);
  stopOnException:=True;
end;

var
  application: tFernbedienung;
begin
  application:=tFernbedienung.Create(nil);
  application.title:='Fernbedienung';
  application.run;
  application.free;
end.