📄 gsmctrfr.pas
字号:
procedure TGSMCentralForm.SpeedButton3Click(Sender: TObject);
var MakeActive: Boolean;
begin
ShowModemLog;
try
MakeActive:=Boolean((Sender as TControl).Tag);
if MakeActive then
begin
GSMDataModule.GSM.COMDevice.Close;
SetConfiguration;
end;
GSMDataModule.Active:=MakeActive;
finally
HideModemLog;
end;
end;
procedure TGSMCentralForm.IndNetRegStatusClick(Sender: TObject);
var
Sg: TStrings;
I: Integer;
begin
CheckGSMActive;
with GSMDataModule do
begin
Sg:= TStringList.Create;
try
if GSM.SendATCommand('AT+CSQ', atrCode+atrParams+atrATResponse, Sg) = 0 then
begin
I:= 1;
I:= StrToNum(ExtractParam(Sg[0], I));
if I = 99 then begin
IndNetRegStatus.Caption:= '?';
I:= 0;
end
else IndNetRegStatus.Caption:= Format('%d dBm', [2*I + (-113)]);
end;
finally
Sg.Free;
end;
end;
end;
procedure TGSMCentralForm.StatusLineOnHint;
begin
StatusBar.SimpleText:= GetLongHint(Application.Hint);
end;
procedure TGSMCentralForm.StatusBarClick(Sender: TObject);
begin
with StatusBar do
SimpleText:= GetShortHint(Hint);
end;
procedure TGSMCentralForm.SpeedButton1Click(Sender: TObject);
begin
ShowModemLog;
try
GSMDataModule.GSM.SwitchOff;
finally
HideModemLog;
end;
end;
procedure TGSMCentralForm.FormShow(Sender: TObject);
begin
GetConfiguration;
fLastSMSKind:= -MaxInt;
SMSKind.ItemIndex:= 0;
AdjustSMSKind;
if IsThereCmd('START', clUpcase) then
SpeedButton3Click(SpeedButton3);
StatusBarClick(nil);
end;
procedure TGSMCentralForm.ModemLogKeyPress(Sender: TObject; var Key: Char);
begin
if not GSMDataModule.GSM.Active then
begin
GSMDataModule.GSM.COMDevice.Close;
SetConfiguration;
end;
GSMDataModule.GSM.COMDevice.Open;
GSMDataModule.GSM.COMDevice.Send(Key);
Key:= #0;
end;
procedure TGSMCentralForm.ShowModemLog;
begin
if AutoShowModemLog.Checked then
begin
FSaveActivePage:= PageControl1.ActivePage;
PageControl1.ActivePage:= TabSheet7;
Application.ProcessMessages;
end;
end;
procedure TGSMCentralForm.HideModemLog;
begin
if AutoShowModemLog.Checked then
begin
PageControl1.ActivePage:= FSaveActivePage;
end;
end;
procedure TGSMCentralForm.GetConfiguration;
begin
with GSMDataModule,GSM do
begin
ModemComboBox.ItemIndex := Ord(Equipment);
SCAEdit.Text := SCA;
PINEdit.Text := PIN;
Self.SMSFormat.ItemIndex := SMSFormat;
CatchSMSMT.Checked := uindSMSDeliver in UnsolicitedIndication;
CatchSMSCB.Checked := uindCellBroadcast in UnsolicitedIndication;
CatchSMSDS.Checked := uindSMSStatusReport in UnsolicitedIndication;
OnlyIndication.Checked := uindOnlyIndication in UnsolicitedIndication;
ComPort.Text:= ComDevice.DeviceName;
BaudRate.Text:= IntToStr(BaudRate2Int(Comm1.Baudrate));
SMSLogCheckBox.Checked := SMSLogFile <> NO_LOG_FILE;
GSMLogCheckBox.Checked := GSMLogFile <> NO_LOG_FILE;
SMSLogSaveDialog.FileName := SMSLogFile;
GSMLogSaveDialog.FileName := GSMLogFile;
end;
end;
procedure TGSMCentralForm.SetConfiguration;
var
B: TBaudRate;
begin
with GSMDataModule,GSM do
begin
Equipment := TGSMEquipment(ModemComboBox.ItemIndex);
SCA := SCAEdit.Text;
PIN := PINEdit.Text;
SMSFormat:= Self.SMSFormat.ItemIndex;
UnsolicitedIndication:= [];
if CatchSMSMT.Checked then
UnsolicitedIndication:= UnsolicitedIndication+[uindSMSDeliver];
if CatchSMSCB.Checked then
UnsolicitedIndication:= UnsolicitedIndication+[uindCellBroadcast];
if CatchSMSDS.Checked then
UnsolicitedIndication:= UnsolicitedIndication+[uindSMSStatusReport];
if OnlyIndication.Checked then
UnsolicitedIndication:= UnsolicitedIndication+[uindOnlyIndication];
ComDevice.DeviceName:= ComPort.Text;
if Int2BaudRate(StrToIntDef(BaudRate.Text, 0), B) then
Comm1.BaudRate:= B;
if SMSLogCheckBox.Checked then
SMSLogFile := SMSLogSaveDialog.FileName
else
SMSLogFile := NO_LOG_FILE;
if GSMLogCheckBox.Checked then
GSMLogFile := GSMLogSaveDialog.FileName
else
GSMLogFile := NO_LOG_FILE;
self.Caption:= Format(CaptionStr, [GSMEquipmentLongName[Equipment]]);
end;
end;
procedure TGSMCentralForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
// SetConfiguration;
end;
procedure TGSMCentralForm.SMSLOGCheckBoxClick(Sender: TObject);
begin
SMSLogButton.Enabled := SMSLogCheckBox.Checked
end;
procedure TGSMCentralForm.GSMLOGCheckBoxClick(Sender: TObject);
begin
GSMLogButton.Enabled := GSMLogCheckBox.Checked
end;
procedure TGSMCentralForm.SMSLogButtonClick(Sender: TObject);
begin
if SMSLogCheckBox.Checked then
SMSLogSaveDialog.Execute;
end;
procedure TGSMCentralForm.GSMLogButtonClick(Sender: TObject);
begin
if GSMLogCheckBox.Checked then
GSMLogSaveDialog.Execute;
end;
procedure TGSMCentralForm.SMSKindChange(Sender: TObject);
begin
AdjustSMSKind;
end;
procedure TGSMCentralForm.AdjustSMSKind;
begin
if fSMSKindLock <> 0 then
Exit;
Inc(fSMSKindLock);
try
if SMSKind.ItemIndex <> FLastSMSKind then
begin
SMSKind2.Enabled:= SMSKind.ItemIndex > 0;
if SMSKind.ItemIndex = 1 then
SMSKind2.Items.Text:= 'Picture'#13#10'vCard'#13#10'Logo'#13#10'CLI'#13#10'Melody'
else if SMSKind.ItemIndex = 2 then
SMSKind2.Items.Text:= 'Picture (small)'#13#10'Picture (large)'#13#10'Picture (variable)'#13#10'Animation (small)'#13#10'Animation (large)'#13#10'Melody'#13#10'Long text only'
else if SMSKind.ItemIndex = 3 then
SMSKind2.Items.Text:= 'Bitmap'#13#10'MIDI sound'
else if SMSKind.ItemIndex = 4 then
SMSKind2.Items.Text:= 'Service Indication'#13#10'Service load'#13#10'Cache operation'
else
SMSKind2.Items.Text:= #13#10;
FLastSMSKind:= SMSKind.ItemIndex;
SMSKind2.ItemIndex:= 0;
DCS.Enabled:= SMSKind.ItemIndex <= 2;
Spec.Enabled:= SMSKind.ItemIndex = 0;
DeliveryNotification.Enabled:= DCS.Enabled or (SMSKind.ItemIndex = 4);
FLastSMSKind2:= -MaxInt;
end;
if SMSKind2.ItemIndex <> FLastSMSKind2 then
begin
case SMSKind.ItemIndex of
0:
begin
FSmartMessage:= nil;
FEMS:= nil;
FWapPush:= nil;
PictureGB.Visible:= False;
vCardGB.Visible:= False;
MelodyGB.Visible:= False;
SEOGB.Visible:= False;
WapPushGB.Visible:= False;
Message.Enabled:= True;
end;
1:
begin
FEMS:= nil;
FWapPush:= nil;
case SMSKind2.ItemIndex of
0: FSmartMessage:= TSMOTABitmap;
1: FSmartMessage:= TSMvCard;
2: FSmartMessage:= TSMOperatorLogo;
3: FSmartMessage:= TSMCLIIcon;
4: FSmartMessage:= TSMRingingTone;
end;
PictureGB.Visible:= (FSmartMessage = TSMMultipartMessage) or (FSmartMessage.InheritsFrom(TSMOTABitmap));
PictureOperator.Enabled:= FSmartMessage = TSMOperatorLogo;
vCardGB.Visible:= FSmartMessage = TSMvCard;
SEOGB.Visible:= False;
WapPushGB.Visible:= False;
PictureNumAnimations.Enabled:= False;
PictureNumAnimations.Text:= '0';
PictureHeight.Enabled:= True;
PictureWidth.Enabled:= PictureHeight.Enabled;
MelodyGB.Visible:= FSmartMessage.InheritsFrom(TSMRingingTone);
Message.Enabled:= fSmartMessage = TSMOTABitmap;
end;
2:
begin
FSmartMessage:= nil;
case SMSKind2.ItemIndex of
0: FEMS:= TEMSPictureSmall;
1: FEMS:= TEMSPictureLarge;
2: FEMS:= TEMSPictureVariable;
3: FEMS:= TEMSAnimationSmall;
4: FEMS:= TEMSAnimationLarge;
5: FEMS:= TEMSSoundUserDef;
6: FEMS:= TEMSObject;
end;
FWapPush:= nil;
PictureGB.Visible:= FEMS.InheritsFrom(TEMSPicture) or FEMS.InheritsFrom(TEMSAnimation);
vCardGB.Visible:= False;
SEOGB.Visible:= False;
WapPushGB.Visible:= False;
PictureNumAnimations.Enabled:= False;
PictureHeight.Enabled:= FEMS = TEMSPictureVariable;
PictureWidth.Enabled:= PictureHeight.Enabled;
PictureOperator.Enabled:= False;
MelodyGB.Visible:= FEMS.InheritsFrom(TEMSSoundUserDef);
Message.Enabled:= True;
if FEMS.InheritsFrom(TEMSPicture) then
begin
with FEMS.Create as TEMSPicture do
try
PictureHeight.Text:= IntToStr(Height);
PictureWidth.Text:= IntToStr(Width);
PictureNumAnimations.Text:= '1';
finally
Free;
end;
end
else if FEMS.InheritsFrom(TEMSAnimation) then
begin
with FEMS.Create as TEMSAnimation do
try
PictureHeight.Text:= IntToStr(Height);
PictureWidth.Text:= IntToStr(Width);
PictureNumAnimations.Text:= '4';
finally
Free;
end;
end
end;
3:
begin
FSmartMessage:= nil;
FEMS:= nil;
FWapPush:= nil;
PictureGB.Visible:= False;
vCardGB.Visible:= False;
MelodyGB.Visible:= False;
SEOGB.Visible:= True;
WapPushGB.Visible:= False;
Message.Enabled:= False;
SEOPicture.Visible:= SMSKind2.ItemIndex = 0;
SEOMidi.Visible:= SMSKind2.ItemIndex = 1;
case SMSKind2.ItemIndex of
0:
begin
SEOFileName.Text:= fSEOPictureFileName;
end;
1:
begin
SEOFileName.Text:= SEOMidi.FileName;
end;
end;
AdjustSEO;
end;
4: // WAP Push
begin
FSmartMessage:= nil;
FEMS:= nil;
case SMSKind2.ItemIndex of
0: FWapPush:= TWapServiceIndication;
1: FWapPush:= TWapServiceLoad;
2: FWapPush:= TWapCacheOperation;
end;
PictureGB.Visible:= False;
vCardGB.Visible:= False;
MelodyGB.Visible:= False;
SEOGB.Visible:= False;
WapPushGB.Visible:= True;
Message.Enabled:= SMSKind2.ItemIndex = 0;
WPSIPanel.Visible:= SMSKind2.ItemIndex = 0;
WPSLPanel.Visible:= SMSKind2.ItemIndex = 1;
WPCOPanel.Visible:= SMSKind2.ItemIndex = 2;
end;
end;
AdjustPicture;
end;
Blink.Enabled:= Message.Enabled;
finally
Dec(fSMSKindLock);
end;
end;
const
CellSize = 5;
procedure TGSMCentralForm.AdjustPicture;
begin
Picture.Width:= CellSize*(StrToIntDef(PictureNumAnimations.Text, 0)+Byte(SMSKind.ItemIndex=1))*StrToIntDef(PictureWidth.Text, 0);
Picture.Height:= CellSize*StrToIntDef(PictureHeight.Text, 0);
Picture.Repaint;
fPictureBitmap.Width:= Max(Picture.Width, fPictureBitmap.Width);
fPictureBitmap.Height:= Max(Picture.Height, fPictureBitmap.Height);
end;
procedure TGSMCentralForm.FormDestroy(Sender: TObject);
begin
fPictureBitmap.Free;
end;
procedure TGSMCentralForm.PicturePaint(Sender: TObject);
var
A, X, Y, X1: Integer;
const
BackColor: array[Boolean] of TColor = ($00FFFF80, $0080FF00);
begin
with Picture.Canvas do
begin
X1:= 0;
for A:= 1 to StrToIntDef(PictureNumAnimations.Text, 0)+Byte(SMSKind.ItemIndex=1) do
begin
Pen.Mode:= pmCopy;
Brush.Color:= BackColor[A and 1 <> 0];
Brush.Style:= bsSolid;
Pen.Style:= psClear;
Rectangle(X1*CellSize, 0, (X1+StrToIntDef(PictureWidth.Text, 0))*CellSize, Picture.Height);
Brush.Color:= clBlack;
for X:= 0 to StrToIntDef(PictureWidth.Text, 0)-1 do
begin
for Y:= 0 to StrToIntDef(PictureHeight.Text, 0)-1 do
begin
if not fPictureBitmap.Empty and (fPictureBitmap.Canvas.Pixels[X1, Y] <> clWhite) then
Rectangle(X1*CellSize, Y*CellSize, (X1+1)*CellSize, (Y+1)*CellSize);
end;
Inc(X1);
end;
end;
Pen.Style:= psSolid;
Pen.Color:= clWhite;
Pen.Width:= 1;
Y:= 0;
while Y <= Picture.Height do
begin
MoveTo(0, Y);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -