-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMSRThreadUnit.pas
More file actions
154 lines (132 loc) · 4.48 KB
/
Copy pathMSRThreadUnit.pas
File metadata and controls
154 lines (132 loc) · 4.48 KB
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
84
85
86
87
88
89
90
91
92
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
145
146
147
148
149
150
151
152
153
154
unit MSRThreadUnit;
interface
uses
Classes,
SysUtils,
Windows,
MMC1Unit,
SPC_Unit,
CommonCDSettingsUnit;
type
TMSRThread = class(TThread)
private
{ Private declarations }
First_sector : LongInt;
Last_sector : LongInt;
save_speed : Boolean;
elasped_times_str : TStrings;
command_to_MSR : Byte;
SubChSelMode : Byte;
s : String;
procedure ShowErrMsg;
protected
procedure Execute; override;
procedure Measure;
public
Constructor Create(Thread_done_proc : TNotifyEvent;
in_First_sector : LongInt;
in_Last_sector : LongInt;
in_save_speed : Boolean;
in_elasped_times_str : TStrings;
in_command_to_MSR : Byte;
in_SubChSelMode : Byte);
end;
implementation
Uses
MainFormUnit;
Constructor TMSRThread.Create(Thread_done_proc : TNotifyEvent;
in_First_sector : LongInt;
in_Last_sector : LongInt;
in_save_speed : Boolean;
in_elasped_times_str : TStrings;
in_command_to_MSR : Byte;
in_SubChSelMode : Byte);
Begin
First_sector :=in_First_sector;
Last_sector :=in_Last_sector;
save_speed :=in_save_speed;
elasped_times_str:=in_elasped_times_str;
command_to_MSR:=in_command_to_MSR;
SubChSelMode:=in_SubChSelMode;
OnTerminate:=Thread_done_proc;
FreeOnTerminate := True;
Inherited Create(False);
End;
procedure TMSRThread.Execute;
begin
Measure;
end;
Procedure TMSRThread.ShowErrMsg;
Begin
Form1.MSR_form.MSRProgressForm.ShowErrMsg(s);
End;
Procedure TMSRThread.Measure;
Var
HSA_sector : LongInt;
Curr_sect : LongInt;
i : Integer;
prev_diff : Int64;
time_unit : Int64;
prev_time : Int64;
new_time : Int64;
microsec_conv_ratio : Extended;
microsec_elasped_time : Extended;
Out_CD_cap_mech_st : T_pub_CD_cap_mech_st;
Begin
QueryPerformanceFrequency(time_unit);
//Conversion ratio for converting to micro seconds.
microsec_conv_ratio:=time_unit/1000000;
Form1.SCSI.MMC1_any_link.Do_sense10_CD_cap_mech_st_out(Out_CD_cap_mech_st);
If Form1.SCSI.SPC_any_link.Get_is_sendcmd_OK Then
Begin
Form1.MSR_form.MSRProgressForm.LBL_curr_read_speed.Caption:=IntToStr(Out_CD_cap_mech_st.CurrReadSpeed);
End;
Curr_sect:=First_sector;
Repeat
//Convert positive LBA sector to MMCLBA (MMC style LBA) sector
If Curr_sect>=404850 Then
HSA_sector:=Curr_sect-450000
Else
HSA_sector:=Curr_sect;
Form1.MSR_form.MSRProgressForm.Sect_reading_disp_Lbl.Caption:=IntToStr(Curr_sect);
Case command_to_MSR Of
0:
Begin
QueryPerformanceCounter(prev_time);
Form1.SCSI.MMC1_any_link.Do_readCD_byFormat_CDB12(HSA_sector,
1,
MMC_SECTORTYPE_ANY,
MMC_READCD_SYNC_ALLHDR_USERDATA_EDCECC,
SubChSelMode);
QueryPerformanceCounter(new_time);
End;
1:
Begin
QueryPerformanceCounter(prev_time);
Form1.SCSI.SBC_any_link.Do_seek_CDB10(HSA_sector);
QueryPerformanceCounter(new_time);
End
End;
{If Form1.SCSI.SPC_any_link.Get_is_sendcmd_OK Then
Begin
s:='1,';
End
Else
Begin
s:='0,';
End;}
microsec_elasped_time:=(new_time-prev_time)/microsec_conv_ratio;
s:=FloatToStrF(microsec_elasped_time, ffFixed, 18, 2);
If save_speed Then
Begin
Form1.SCSI.MMC1_any_link.Do_sense10_CD_cap_mech_st_out(Out_CD_cap_mech_st);
If Form1.SCSI.SPC_any_link.Get_is_sendcmd_OK Then
Begin
s:=s+','+IntToStr(Out_CD_cap_mech_st.CurrReadSpeed);
End;
End;
elasped_times_str.Add(s);
Curr_sect:=Curr_sect+1;
Until (Curr_sect>Last_sector) Or Terminated;
End;
end.