-
Notifications
You must be signed in to change notification settings - Fork 0
/
WasatchDemo.pas
151 lines (129 loc) · 3.81 KB
/
WasatchDemo.pas
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
unit WasatchDemo;
// ************************************************************************ //
//
// Delphi Demo application for control of Wasatch Photonics spectrometers,
// using the WasatchNET.tlb type library.
//
// Sample code created 07/2018 with Embarcadero Delphi XE 5
// by Dr. Friedrich Menges from Spectroscopy Ninja.
// http://spectroscopy.ninja
//
// Feel free to re-use code as needed.
// Will also run with Delphi Community Edition 10.2.
//
// ************************************************************************ //
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, SWasatchHW, VclTee.TeeGDIPlus,
Vcl.StdCtrls, VCLTee.TeEngine, VCLTee.Series, Vcl.ExtCtrls, VCLTee.TeeProcs,
VCLTee.Chart, Vcl.Buttons, Vcl.Samples.Spin;
type
TMainWin = class(TForm)
Chart1: TChart;
Panel1: TPanel;
Series1: TFastLineSeries;
Button1: TButton;
GroupBox1: TGroupBox;
sbRunAcquisition: TSpeedButton;
ComboBox1: TComboBox;
seIntegrationTime: TSpinEdit;
seScanAveraging: TSpinEdit;
seBoxCar: TSpinEdit;
seTECSetpoint: TSpinEdit;
seLaserPower: TSpinEdit;
cbLaserOn: TCheckBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure ComboBox1Select(Sender: TObject);
procedure seIntegrationTimeChange(Sender: TObject);
procedure seTECSetpointChange(Sender: TObject);
procedure seLaserPowerChange(Sender: TObject);
procedure cbLaserOnClick(Sender: TObject);
procedure sbRunAcquisitionClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure seScanAveragingChange(Sender: TObject);
procedure seBoxCarChange(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
Connected,
ParamsDone,
Acquiring: Boolean;
Deviceindex: Integer;
end;
var
MainWin: TMainWin;
implementation
{$R *.dfm}
procedure TMainWin.Button1Click(Sender: TObject);
begin
RefreshWasatchDeviceList;
Combobox1.ItemIndex := 0;
Deviceindex := ComboBox1.ItemIndex;
Connected := ConnectWasatch(Deviceindex);
UpdateMemo;
end;
procedure TMainWin.cbLaserOnClick(Sender: TObject);
begin
RunLaserWasatch(cbLaserOn.Checked);
end;
procedure TMainWin.ComboBox1Select(Sender: TObject);
begin
Deviceindex:=ComboBox1.ItemIndex;
Connected:=false;
Connected:=ConnectWasatch(Deviceindex);
UpdateMemo;
end;
procedure TMainWin.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if Connected then
DisConnectWasatch;
end;
procedure TMainWin.seBoxCarChange(Sender: TObject);
begin
SetBoxCarWidthWasatch(seBoxCar.Value);
end;
procedure TMainWin.seIntegrationTimeChange(Sender: TObject);
begin
SetExposureTimeWasatch(Deviceindex, seIntegrationTime.Value);
end;
procedure TMainWin.seTECSetpointChange(Sender: TObject);
begin
SetTemperatureWasatch(seTECSetpoint.Value);
end;
procedure TMainWin.sbRunAcquisitionClick(Sender: TObject);
begin
if Connected then
begin
Acquiring:=not Acquiring;
if Acquiring then
sbRunAcquisition.Caption:='Stop'
else
sbRunAcquisition.Caption:='Run';
repeat
GetScanWasatch(Deviceindex);
Application.ProcessMessages;
until not Acquiring;
end
else
begin
sbRunAcquisition.Caption:='Run';
Acquiring:=false;
end;
end;
procedure TMainWin.seLaserPowerChange(Sender: TObject);
begin
SetLaserPowerWasatch(seLaserPower.Value);
end;
procedure TMainWin.seScanAveragingChange(Sender: TObject);
begin
SetScanAveragingWasatch(seScanAveraging.Value);
end;
end.