📄 sd_pei_tool_main.pas
字号:
begin
CheckBoxRec.Enabled := True;
CheckBoxCon.Enabled := True;
DestISSI_Edit.Enabled := True;
Message_Edit.Enabled := True;
DelayEdit.Enabled := True;
RepititionsEdit.Enabled := True;
end; // End of procedure TForm1.Set_buttons_after_successful_registration
//*******************************************************
//
// PROCEDURE NAME : TForm1.SendData
//
//
// PROCEDURE DESCRIPTION :-
// This procedure sends the actual data on the PEI for a
// send message command. It pulls the information needed from
// the different fields in for form.
//
//
//*******************************************************
procedure TForm1.SendData;
var
TotalPEIString, SDS_TL_TRANSFER_Str, TextStr, dummy: String;
Sent_OK: Bool;
begin
Message_Edit.AddToHist;
SDS_TL_TRANSFER_Str:=IntToHex(StrToInt(ProtocolIdentifierEdit.Text),2) + IntToHex(DeliveryByte,2) + IntToHex(RefNum,2);
TextStr:= Message_Edit.Text;
dummy:= HexStringToByteString(SDS_TL_TRANSFER_Str);
if (ProtocolIdentifierEdit.Text = '130') then
TotalPEIString := ('AT+CMGS=' + DestISSI_Edit.Text + ',1,0,' + IntToStr(((Length(dummy)+ Length(TextStr))*8)+8) + #13 + SDS_TL_TRANSFER_Str + '01' + Conv_Msg_To_Hex(TextStr) + #26)
else
TotalPEIString := ('AT+CMGS=' + DestISSI_Edit.Text + ',1,0,' + IntToStr((Length(dummy)+ Length(TextStr))*8) + #13 + SDS_TL_TRANSFER_Str + Conv_Msg_To_Hex(TextStr) + #26);
MessagesPad_Memo.Lines.Append(Get_Time() + ': Sending to: ' + DestISSI_Edit.Text + ' mes. ref.: ' + IntToHex(RefNum,2) + ' PI: ' + IntToHex(StrToInt(ProtocolIdentifierEdit.Text),2) + ' Text: ' + Message_Edit.Text);
Sent_OK := Send_PEI_Msg(TotalPEIString);
if not(Sent_OK) then
begin
Unsent_PEI_msg := TotalPEIString;
// Start CTS timer waiting to check if the radio becomes ready to receive data
Start_CTS_Timer(SEND);
end;
if (Sent_OK) then
// Trying to bypass send decoding
CTSPendingOperation := SEND;
// For now skip the workaround part
// CTSPendingOperation := NOTUSED;
RefNum:= RefNum +1;
end; // End of procedure TForm1.SendData
//*******************************************************
//
// PROCEDURE NAME : TForm1.SendButtonClick
//
//
// PROCEDURE DESCRIPTION :-
// This procedure is called when the user clicks on
// the Send button. The procedure will format an AT command
// string to be sent on the PEI based on user input fields.
//*******************************************************
procedure TForm1.SendButtonClick(Sender: TObject);
begin
if (SendButton.Caption = 'Stop') then
begin
// Stop button press: The user has requested to stop the repetitive transmission of text messages
DelayTimer.Enabled := False;
SendButton.Caption := 'Send';
end
else
begin
// Send button press
SendData();
// Check to see if the user wishes to repeat the message
if (RepititionsEdit.Value > 1) then
begin
SendButton.Caption := 'Stop';
RemainingNumOfRepitions := RepititionsEdit.Value - 1;
DelayTimer.Interval := DelayEdit.Value;
DelayTimer.Enabled := True;
end;
end;
end; // End of procedure TForm1.SendButtonClick
//*******************************************************
//
// PROCEDURE NAME : TForm1.HexStringToByteString
//
//
// PROCEDURE DESCRIPTION :-
// This procedure TBA
//
//
//
//*******************************************************
function TForm1.HexStringToByteString(StringToConvert: string): string;
var
S: string;
I: Integer;
// **********************************************************************************
function H1ToB(C: Char): Byte;
begin
case C of
'0'..'9' : H1ToB := Ord(C) - Ord('0');
'A'..'F' : H1ToB := Ord(C) - Ord('A') + 10;
'a'..'f' : H1ToB := Ord(C) - Ord('a') + 10;
else
H1ToB := 0;
end;
end;
// **********************************************************************************
begin
S := ''; I := 1;
while I <= Length(StringToConvert) do
begin
if StringToConvert[I] in ['0'..'9', 'A'..'F', 'a'..'f'] then
begin
S := S + Chr(H1ToB(StringToConvert[I]) * 16 + H1ToB(StringToConvert[I+1]));
Inc(I);
end;
Inc(I);
end;
HexStringToByteString := S;
end; // End of function TForm1.HexStringToByteString
//*******************************************************
//
// FUNCTION NAME : TForm1.Conv_Msg_To_Hex
//
//
// FUNCTION DESCRIPTION :-
// Convert Message Text To Hex and returns the converted message as a String
// Function is passed 1 parameter which is the orignal string in ASCII format.
// It then calulates the length of the string, and then for each character,
// converts to hex using ord. After each conversion, the new char in hex is
// added to the final str.
//
//
//*******************************************************
function TForm1.Conv_Msg_To_Hex(var msg_str: String): String;
var
Track_Pointer, Msg_Len:integer;
strgridasc : string;
begin
// Initialise variables
Track_Pointer := 1;
Msg_Len := Length(msg_str);
strgridasc := '';
// While loop until End of Msg Length
While(Msg_Len>0) Do
begin
strgridasc := strgridasc + IntToHex(Ord(msg_str[Track_Pointer]), 0);
Msg_Len := Msg_Len - 1;
Track_Pointer := Track_Pointer + 1;
end;
Conv_Msg_To_Hex := strgridasc;
end; // End of function TForm1.Conv_Msg_To_Hex
//*******************************************************
//
// PROCEDURE NAME : TForm1.FormCreate
//
//
// PROCEDURE DESCRIPTION :-
// This procedure is called when this program is invoked
// by the user. It initialises variables and enables/disables
// buttons appropriately.
//
//*******************************************************
procedure TForm1.FormCreate(Sender: TObject);
begin
Buffer := '';
ConnectButton.Enabled := True;
RegisterButton.Enabled := False;
DeRegister.Enabled := False;
DisconnectButton.Enabled := False;
SendButton.Enabled := False;
CheckBoxRec.Enabled := False;
CheckBoxCon.Enabled := False;
ProtocolIdentifierEdit.Enabled := False;
DestISSI_Edit.Enabled := False;
Message_Edit.Enabled := False;
DelayEdit.Enabled := False;
RepititionsEdit.Enabled := False;
DelayTimer.Enabled := False;
RefNum:= 0;
end; // End of procedure TForm1.FormCreate
//*******************************************************
//
// PROCEDURE NAME : TForm1.Button1Click
//
//
// PROCEDURE DESCRIPTION :-
// This procedure is called when the user clicks on
// the "Save Msg Window to File" button. The procedure saves
// the contents of the "Message window" to a text file.
// The filename is specified by the user.
//*******************************************************
procedure TForm1.Button1Click(Sender: TObject);
begin
if (sd.Execute) then MessagesPad_Memo.Lines.SaveToFile(sd.FileName);
end; // End of procedure TForm1.Button1Click
//*******************************************************
//
// PROCEDURE NAME : TForm1.Button2Click
//
//
// PROCEDURE DESCRIPTION :-
// This procedure is called when the user clicks on
// the "Save Log Window to File" button. The procedure saves
// the contents of the "PEI logger window" to a text file.
// The filename is specified by the user.
//*******************************************************
procedure TForm1.Button2Click(Sender: TObject);
begin
if (sd.Execute) then CommandLogger_Memo.Lines.SaveToFile(sd.FileName);
end; // End of procedure TForm1.Button2Click
//*******************************************************
//
// PROCEDURE NAME : TForm1.CheckBoxRecClick
//
//
// PROCEDURE DESCRIPTION :-
// This procedure checks whether the user has requested
// received report by checking if the user has ticked off
// the "Received TL Flag"
//
//*******************************************************
procedure TForm1.CheckBoxRecClick(Sender: TObject);
begin
if CheckBoxRec.Checked then
begin
// Set the message received report requested bit in the SDS-TL-TRANSFER
DeliveryByte := DeliveryByte or $04;
end
else
begin
// Clear the message received report requested bit in the SDS-TL-TRANSFER
DeliveryByte := DeliveryByte and $FB;
end;
end; // End of procedure TForm1.CheckBoxRecClick
//*******************************************************
//
// PROCEDURE NAME : TForm1.CheckBoxConClick
//
//
// PROCEDURE DESCRIPTION :-
// This procedure checks whether the user has requested
// received report by checking if the user has ticked off
// the "Consumed TL Flag"
//
//*******************************************************
procedure TForm1.CheckBoxConClick(Sender: TObject);
begin
if CheckBoxCon.Checked then
begin
// Set the message consumed report requested bit in the SDS-TL-TRANSFER
DeliveryByte := DeliveryByte or $08;
end
else
begin
// Clear the message consumed report requested bit in the SDS-TL-TRANSFER
DeliveryByte := DeliveryByte and $F7;
end;
end; // End of procedure TForm1.CheckBoxConClick
//*******************************************************
//
// PROCEDURE NAME : TForm1.DelayTimerTimer
//
//
// PROCEDURE DESCRIPTION :-
// This procedure is used for repetitive sending, it sends
// the short data message and keeps track of how many messages
// that are left to be sent, and restarts the timer based on the
// user entered delay between messages.
//
//*******************************************************
procedure TForm1.DelayTimerTimer(Sender: TObject);
begin
SendData();
RemainingNumOfRepitions := RemainingNumOfRepitions - 1;
DelayTimer.Interval := DelayEdit.Value;
if (RemainingNumOfRepitions = 0) then
begin
DelayTimer.Enabled := False;
SendButton.Caption := 'Send';
end;
end; // End of procedure TForm1.DelayTimerTimer
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -