Check-in [c7f855ce62]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:In DEBUG mode, write out every sentinel update (at least while the sentinel window is visible), so we can analyze more easily what exactly happened.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | feature/sentinel-thread
Files: files | file ages | folders
SHA1:c7f855ce624564663bc6b0ba083af7af85346431
User & Date: Martijn 2015-08-12 17:29:21
Context
2016-02-14
12:25
Updated projects to Delphi 10 Seattle. Moved whatsnew for ZPreview to separate file. check-in: d51c3cafcf user: tinus tags: feature/sentinel-thread
2015-08-12
17:29
In DEBUG mode, write out every sentinel update (at least while the sentinel window is visible), so we can analyze more easily what exactly happened. check-in: c7f855ce62 user: Martijn tags: feature/sentinel-thread
2015-08-11
20:48
Try to clean up the thread on shutdown. check-in: d421e12eaf user: Martijn tags: feature/sentinel-thread
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ZPreview/src/Delphi/F_Sentinel.dfm.

15
16
17
18
19
20
21


22
23
24
25
26
27
28
  Font.Name = 'Tahoma'
  Font.Style = []
  FormStyle = fsStayOnTop
  OldCreateOrder = False
  Position = poDesigned
  ScreenSnap = True
  OnActivate = FormActivate


  OnDeactivate = FormDeactivate
  OnHide = FormShowHide
  OnShow = FormShowHide
  PixelsPerInch = 96
  TextHeight = 13
  object lvwFields: TListView
    AlignWithMargins = True







>
>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  Font.Name = 'Tahoma'
  Font.Style = []
  FormStyle = fsStayOnTop
  OldCreateOrder = False
  Position = poDesigned
  ScreenSnap = True
  OnActivate = FormActivate
  OnCreate = FormCreate
  OnDestroy = FormDestroy
  OnDeactivate = FormDeactivate
  OnHide = FormShowHide
  OnShow = FormShowHide
  PixelsPerInch = 96
  TextHeight = 13
  object lvwFields: TListView
    AlignWithMargins = True

Changes to ZPreview/src/Delphi/F_Sentinel.pas.

8
9
10
11
12
13
14


15
16


17
18
19
20
21
22
23
..
29
30
31
32
33
34
35


















36
37
38
39
40
41
42
43
44
45
46
47
48
49
..
52
53
54
55
56
57
58

59
60
61
62
63
64
65
66








67
68
69
70
71
72
73
..
93
94
95
96
97
98
99













100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137














138
139
140
141
142
143
144

type
  TfrmInfoSentinel = class(TForm)
    lvwFields: TListView;
    procedure FormActivate(Sender: TObject);
    procedure FormDeactivate(Sender: TObject);
    procedure FormShowHide(Sender: TObject);


  private
    { Private declarations }


  public
    { Public declarations }
    procedure Populate(const Sentinel: TZaapSentinelFile);
    procedure PopulateProblems(const Sentinel: TZaapSentinelFile; const ClearFirst: Boolean);
  end;

var
................................................................................
  SysUtils,
  F_Main, M_Main;

{$R *.dfm}

{ ================================================================================================ }
{ TfrmSentinelInfo }



















{ ------------------------------------------------------------------------------------------------ }
procedure TfrmInfoSentinel.FormActivate(Sender: TObject);
begin
//  AlphaBlend := False;
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmInfoSentinel.FormDeactivate(Sender: TObject);
begin
  AlphaBlend := True;
end;

{ ------------------------------------------------------------------------------------------------ }
................................................................................
  frmMain.ActionManager.FindItemByAction(frmMain.actViewSentinel).Action.Checked := Visible;
  AlphaBlend := True;
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmInfoSentinel.Populate(const Sentinel: TZaapSentinelFile);
var

  LGroupID: integer;
  function AddRow(const Name, Value, Chars: string): TListItem; overload;
  begin
    Result := lvwFields.Items.Add;
    Result.GroupID := LGroupID;
    Result.Caption := Name;
    Result.SubItems.Add(Value);
    Result.SubItems.Add(Chars);








  end;
  function AddRow(const Name: string; const Value: Cardinal): TListItem; overload;
  begin
    Result := AddRow(Name, IntToStr(Value), '');
  end;
  function AddRow(const Name: string; const Value: AnsiChar): TListItem; overload;
  begin
................................................................................
    Result := AddRow(Name, '(' + IntToStr(Length(Values)) + ')', Value);
  end;
var
  Column: TCollectionItem;
  Buffer: array[0..1023] of Char;
  BufferSize: integer;
begin













  lvwFields.Items.BeginUpdate;
  try
    lvwFields.Clear;
    LGroupID := 0;
    lvwFields.Groups[LGroupID].Header := Sentinel.Filename;
    try
      AddRow('Sequence', Sentinel.Pamphlet.Sequence);
      AddRow('HWnd',     '0x'+IntToHex(Sentinel.Pamphlet.HWnd, 4), IntToStr(Sentinel.Pamphlet.HWnd));
      AddRow('Handshake', Sentinel.Pamphlet.Handshake);
      AddRow('Screen status', Sentinel.Pamphlet.ScreenStatus);
      AddRow('Command', Sentinel.Pamphlet.Command);
      AddRow('Command char', Sentinel.Pamphlet.CommandChar);
      AddRow('Page', Sentinel.Pamphlet.Page);
      AddRow('Block size', Sentinel.Pamphlet.BlockSize);
      AddRow('Revision', Sentinel.Pamphlet.Revision);
      AddRow('Stats', Sentinel.Pamphlet.Stats);
      AddRow('(reserved)', Sentinel.Pamphlet.Reserved1);
      AddRow('This path', Sentinel.ThisPath);
      AddRow('Other path', Sentinel.OtherPath);
      AddRow('Entry line', Sentinel.EntryLine);
      AddRow('Checksum', '0x'+IntToHex(Sentinel.Checksum, 4), IntToStr(Sentinel.Checksum));
      AddRow('Sequence', Sentinel.CheckSeq);
      if Sentinel.HasProblem then begin
        PopulateProblems(Sentinel, False);
      end;
    except
      BufferSize := ExceptionErrorMessage(ExceptObject, ExceptAddr, Buffer, Length(Buffer));
      with lvwFields.Items.Add do begin
        GroupID := 1;
        SubItems.Add('');
        SubItems.Add(Copy(Buffer, 1, BufferSize));
      end;
    end;
    for Column in lvwFields.Columns do begin
      TListColumn(Column).Width := -2;
    end;
  finally
    lvwFields.Items.EndUpdate;














  end;
end {TfrmSentinelInfo.Populate};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmInfoSentinel.PopulateProblems(const Sentinel: TZaapSentinelFile; const ClearFirst: Boolean);
var
  Line: string;







>
>


>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






<







 







>








>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
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
..
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201

type
  TfrmInfoSentinel = class(TForm)
    lvwFields: TListView;
    procedure FormActivate(Sender: TObject);
    procedure FormDeactivate(Sender: TObject);
    procedure FormShowHide(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    FLog: TStreamWriter;
    FHeadersWritten: boolean;
  public
    { Public declarations }
    procedure Populate(const Sentinel: TZaapSentinelFile);
    procedure PopulateProblems(const Sentinel: TZaapSentinelFile; const ClearFirst: Boolean);
  end;

var
................................................................................
  SysUtils,
  F_Main, M_Main;

{$R *.dfm}

{ ================================================================================================ }
{ TfrmSentinelInfo }

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmInfoSentinel.FormCreate(Sender: TObject);
var
  LogFile: string;
begin
  FHeadersWritten := False;
  LogFile := ExtractFilePath(Application.ExeName) + 'sentinel-' + FormatDateTime('yyyy-mm-dd"T"hh.nn.ss.zzz', Now) + '.log';
  {$IFDEF DEBUG}
  FLog := TStreamWriter.Create(TFileStream.Create(LogFile, fmCreate or fmShareDenyWrite), TEncoding.UTF8);
  FLog.OwnStream;
  {$ENDIF}
end;
{ ------------------------------------------------------------------------------------------------ }
procedure TfrmInfoSentinel.FormDestroy(Sender: TObject);
begin
  FLog.Free;
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmInfoSentinel.FormActivate(Sender: TObject);
begin
//  AlphaBlend := False;
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmInfoSentinel.FormDeactivate(Sender: TObject);
begin
  AlphaBlend := True;
end;

{ ------------------------------------------------------------------------------------------------ }
................................................................................
  frmMain.ActionManager.FindItemByAction(frmMain.actViewSentinel).Action.Checked := Visible;
  AlphaBlend := True;
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmInfoSentinel.Populate(const Sentinel: TZaapSentinelFile);
var
  LHeaders, LFields: TStringList;
  LGroupID: integer;
  function AddRow(const Name, Value, Chars: string): TListItem; overload;
  begin
    Result := lvwFields.Items.Add;
    Result.GroupID := LGroupID;
    Result.Caption := Name;
    Result.SubItems.Add(Value);
    Result.SubItems.Add(Chars);
    if Assigned(LFields) then begin
      LFields.Add(Value);
      LFields.Add(Chars);
      if Assigned(LHeaders) then begin
        LHeaders.Add(Name);
        LHeaders.Add('');
      end;
    end;
  end;
  function AddRow(const Name: string; const Value: Cardinal): TListItem; overload;
  begin
    Result := AddRow(Name, IntToStr(Value), '');
  end;
  function AddRow(const Name: string; const Value: AnsiChar): TListItem; overload;
  begin
................................................................................
    Result := AddRow(Name, '(' + IntToStr(Length(Values)) + ')', Value);
  end;
var
  Column: TCollectionItem;
  Buffer: array[0..1023] of Char;
  BufferSize: integer;
begin
  LFields := nil;
  LHeaders := nil;
  if Assigned(FLog) then begin
    LFields := TStringList.Create;
    LFields.Add(FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', Now));
    LFields.Add(Sentinel.Filename);
    if FHeadersWritten = False then begin
      LHeaders := TStringList.Create;
      LHeaders.Add('Timestamp');
      LHeaders.Add('Sentinel');
    end;
  end;
  try
    lvwFields.Items.BeginUpdate;
    try
      lvwFields.Clear;
      LGroupID := 0;
      lvwFields.Groups[LGroupID].Header := Sentinel.Filename;
      try
        AddRow('Sequence',      Sentinel.Pamphlet.Sequence);
        AddRow('HWnd',          '0x'+IntToHex(Sentinel.Pamphlet.HWnd, 4), IntToStr(Sentinel.Pamphlet.HWnd));
        AddRow('Handshake',     Sentinel.Pamphlet.Handshake);
        AddRow('Screen status', Sentinel.Pamphlet.ScreenStatus);
        AddRow('Command',       Sentinel.Pamphlet.Command);
        AddRow('Command char',  Sentinel.Pamphlet.CommandChar);
        AddRow('Page',          Sentinel.Pamphlet.Page);
        AddRow('Block size',    Sentinel.Pamphlet.BlockSize);
        AddRow('Revision',      Sentinel.Pamphlet.Revision);
        AddRow('Stats',         Sentinel.Pamphlet.Stats);
        AddRow('(reserved)',    Sentinel.Pamphlet.Reserved1);
        AddRow('This path',     Sentinel.ThisPath);
        AddRow('Other path',    Sentinel.OtherPath);
        AddRow('Entry line',    Sentinel.EntryLine);
        AddRow('Checksum',      '0x'+IntToHex(Sentinel.Checksum, 4),      IntToStr(Sentinel.Checksum));
        AddRow('Sequence',      Sentinel.CheckSeq);
        if Sentinel.HasProblem then begin
          PopulateProblems(Sentinel, False);
        end;
      except
        BufferSize := ExceptionErrorMessage(ExceptObject, ExceptAddr, Buffer, Length(Buffer));
        with lvwFields.Items.Add do begin
          GroupID := 1;
          SubItems.Add('');
          SubItems.Add(Copy(Buffer, 1, BufferSize));
        end;
      end;
      for Column in lvwFields.Columns do begin
        TListColumn(Column).Width := -2;
      end;
    finally
      lvwFields.Items.EndUpdate;
    end;

    if Assigned(LFields) then begin
      LFields.Delimiter := #9;
      if Assigned(LHeaders) then begin
        LHeaders.Delimiter := LFields.Delimiter;
        FLog.WriteLine(LHeaders.DelimitedText);
        FHeadersWritten := True;
      end;
      FLog.WriteLine(LFields.DelimitedText);
    end;
  finally
    LFields.Free;
    LHeaders.Free;
  end;
end {TfrmSentinelInfo.Populate};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmInfoSentinel.PopulateProblems(const Sentinel: TZaapSentinelFile; const ClearFirst: Boolean);
var
  Line: string;