Browse Source

version 51

    - BUG: clicking "new row" with active row at the end of the table, two rows will be added
	- BUG: The last empty row will only show command 0. Data is not be set. 
	- BUG: on Export the field names are no correctly padded
	- BUG: on "new file" changes of the actual file will not be saved
	- FEATURE: loading and saving of input presets, adding PRG and SEL Buttons to preset
Wilfried Klaas 6 năm trước cách đây
mục cha
commit
02c79c72fd
9 tập tin đã thay đổi với 336 bổ sung56 xóa
  1. 146 0
      README.md
  2. 4 4
      SPS_EMU.000
  3. 1 1
      SPS_EMU.001
  4. 1 1
      SPS_EMU.044
  5. 1 1
      SPS_Emu.lpi
  6. BIN
      SPS_Emu.lsu
  7. 0 1
      SPS_Emu.xml
  8. 28 3
      ugui.lfm
  9. 155 45
      ugui.pas

+ 146 - 0
README.md

@@ -1 +1,147 @@
 SPS_Emulator
 SPS_Emulator
+
+
+version history
+
+Version 0.2.1.51
+    - BUG: clicking "new row" with active row at the end of the table, two rows will be added
+	- BUG: The last empty row will only show command 0. Data is not be set. 
+	- BUG: on Export the field names are no correctly padded
+	- BUG: on "new file" changes of the actual file will not be saved
+	- FEATURE: loading and saving of input presets, adding PRG and SEL Buttons to preset
+	
+10.11.2018 Version 0.2.1.50
+
+    adding visual tone control for SPS Version 0.8
+
+10.11.2018 Version 0.2.1.48
+
+    adding new internals: page and delay
+    Bug: Servo indicator shown in Holtec mode.
+
+08.11.2018 Version 0.2.1.47
+
+    neue Webseitenadresse eingebaut
+    Icon und Text start/stoppen geändert
+    aktuelle Lazarus Version
+    bei der Auswahl von COM Port und Arduino Pfad wird dieser aus der Registry vorbesetzt
+    zus. Servoanzeige mit Strich
+
+05.12.2013 Version 0.2.1.45
+
+    Feature: Internationalisierung. Das Programm steht nun in deutsch und englisch zur Verfügung. Es schaltet sich je nach Sprachversion des Betriebssystems automatisch um.
+
+05.12.2013 Version 0.2.1.44
+
+Herzlich Dank an Herrn Oehme, durch den ich folgende Bug beseitigen konnte .
+
+    Die Internet-Verbindung im Eröffnungsbildschirm klappt nicht – Anzeige “keine Verb.”
+
+Lösung: Die WebAdresse hat sich geändert.
+
+    Im “Skip if”-Befehl fehlen S_SEL=0/S_PRG=0/S_SEL=1/S_PRG=1 (betrifft nur TPS Holtec).
+
+Lösung: Befehle nachgetragen.
+
+    Der “Return”-Befehl für TPS Holtec und TPS ATMega8 funktioniert nicht – RAdr lautet immer 0
+
+Lösung: Bug gefixed.
+
+09.03.2013 Version 0.2.1.43
+
+Durch die tatenreiche Mithilfe von Herrn Chvatal (Amateurtfunk-Rufzeichen: OE1GCA) habe ich folgende Bug beseitigen können. Hiermit möchte ich allen, die mir bisher eine Rückmeldung gegeben haben vielen Dank sagen.
+
+    Die beiden Taster SEL und PRG waren vertauscht.
+    In der Holtek und ATMEga 8 Version gibt es nur ein Ebene für den Subroutinen Call. Bei meinen beiden Versionen (ATTiny84 und Arduino gibt es davon 8, d.h. ich kann 8 Aufrufebenen verwenden.) Das berücksichtigt jetzt auch der Emulator.
+    Das A-Register ist in der Holtect und der ATMega8 Version immer nur 4 Bit breit. ATTiny84 und Arduino-Version verarbeiten aber 8-Bit. Auch das berücksichtigt nun der Emulator.
+
+05.03.2013 Version 0.2.1.41
+
+    Der Call Befehl springt jetzt auch dahin, wo er hin soll.
+
+03.10.2012 Version 0.2.1.38
+
+    Emulator kann nun auch direkt eine HEX Datei zum Upload erzeugen. Diese liegt im gleichen Verzeichniss wie das TPS Programm und hat die den gleichen Namen, aber die Endung .hex
+
+25.9.2012 Version 0.2.1.36
+
+    Bug beim Push und Pop im Emulator. (Nur ArduinoSPS)
+    Stackanzeige für Push/Pop A.
+
+25.9.2012 Version 0.2.1.35
+
+    Anzeige der Rücksprungadresse bei Call/Sub.
+    Automatischer Updatecheck.
+    Shortcuts für die Buttons. (z.B. fürs Debuggen F8, F9, F5)
+
+24.9.2012 Version 0.2.1.29
+
+    Bug beim Zuweisen der Servos im Bytemodus behoben. (Nur ArduinoSPS)
+    Wertebereich der Servos im Bytemodus angepasst. 0= 0° und 255= 180°.
+
+22.9.2012 Version 0.2.1.28
+
+    Beim Laden einer neuen Datei wird nun auch der alte Quelltext gelöscht.
+    Bei Änderungen an der aktuellen Datei und Aufruf des Ladens wird nun gefragt, ob man die Änerungen speichern möchte. (Leider erst nach der Auswahl der zu ladenden Datei…)
+
+21.9.2012 Version 0.2.1.26
+
+    Reset der Eingabewerte (R Button).
+    Nullwert von RC.# auf 8 geändert.
+
+20.9.2012 Version 0.2.1.23
+
+    Die Taster PRG und SEL fehlten in der Eingabemaske.
+    Speichern von definierten Eingabewerten möglich. (Einfach rechte Maustaste auf den jeweiligen Button und schon wird das gesamte Eingabeset auf diesen Button gespeichert.)
+
+20.9.2012 Version 0.2.1.22
+
+    Neue Befehle der ArduinoSPS implementiert.
+    Textfenster nun mit Copyfunktion. (STRG-C)
+    Kleinere Fixes im Bereich der erweiterten Befehle der ArduinoSPS
+    Bei der Programmausführung kann nun auch die Aktualisierung des Quelltextfensters abgeschaltet werden. Dadurch wird eine deutlich höhere Ausführungsgeschwindigkeit erreicht.
+
+20.9.2012 Version 0.2.1.20
+
+    Neue Spalte mit der Befehlsbeschreibung. Gespeicherte Programm sind davon unberührt.
+    Neben der Position wird nun auch die Größe des Programmfensters gespeichert. Ebenso wie die Spaltenbreiten.
+    Uploadfenster wird jetzt zentriert über dem Programmfenster.
+    Kleinere Fixes.
+
+18.9.2012 Version 0.2.1.19
+
+    Namensgebung der TPS angepasst. Ausgänge 1..4 und Eingänge 1..4 (statt 0..3) Gespeicherte Programm sind davon völlig unberührt.
+
+18.9.2012 Version 0.2.1.18
+
+    kleinere Bugs behoben.
+    Wertebereich der ADC und RC Felder erweitert. (Den DIV 16 hab ich da jetzt mal durch einen AND $0F ersetzt, somit werden nun bei den Befehlen 69 Und 6A nur das untere Nibble berücksichtigt.)
+    HOLTEC Version mit 2. ADC
+
+Vielen Dank an Herrn R.Beesner für das Melden der Bugs.
+
+18.9.2012 Version 0.2.1.16
+
+    kleinere Bugs behoben.
+    Abfrage beim Verlassen bei geänderter Datei.
+    Speichknopf speichert bei geladener Datei automatisch.
+    InfoScreen eingebaut.
+
+17.9.2012 Version 0.1.1.11
+
+    kleinere Bugs behoben.
+    Upload auf den Arduino eingebaut. (Verwendet die in der Arduino Installation vorhandene AVRDude Versionen)
+
+14.9.2012 Version 0.1.1.7
+
+    kleinere Bugs behoben.
+    Zeilen löschen und einfügen.
+    speichert auch die Version des Controllers mit in die Datei.
+    Implementierung weiterer Funktionen.
+
+14.9.2012 Version 0.1.1.6
+
+    Drag und Drop für Dateien eingeführt. Man kann jetzt aus dem Explorer einfach die zu editierende Datei auf das Programm droppen.
+    Start mit Datei. Man kann das Programm direkt mit einer Datei starten. Somit ist es jetzt auch möglich, die SPS als Editor für tps-Dateien im Windows Explorer zu setzen.
+    Button „Neu“ erzeugt eine neue leere Session.
+

+ 4 - 4
SPS_EMU.000

@@ -2,9 +2,9 @@
 LSUTextFile=1
 LSUTextFile=1
 Copyrigth=MCS Media Computer Software
 Copyrigth=MCS Media Computer Software
 [LSUInfo]
 [LSUInfo]
-CompileDate=10.11.2018
-CompileTime=23:51:02
+CompileDate=14.11.2018
+CompileTime=11:50:41
 Name=Wilfried Klaas
 Name=Wilfried Klaas
-LSUBinFile=E:\daten\sourcen\pascal\SPS_TPS_Emulator\SPS_Emu.lsu
-LSUTextFile=E:\daten\sourcen\pascal\SPS_TPS_Emulator\SPS_Emu.
+LSUBinFile=E:\daten\git-sourcen\SPS_Emulator\SPS_Emu.lsu
+LSUTextFile=E:\daten\git-sourcen\SPS_Emulator\SPS_Emu.
 RegString=
 RegString=

+ 1 - 1
SPS_EMU.001

@@ -150,7 +150,7 @@ ID_SPS_STOPPED=PLC stopped
 ID_SPS_PROGRAMMING=programming PLC
 ID_SPS_PROGRAMMING=programming PLC
 
 
 [hexfile]
 [hexfile]
-ID_START_LINE=Addr   BD   Instruction   Data      Comment  
+ID_START_LINE=Addr   BD   Inst.    Data      Comment  
 
 
 [MessagesMSG]
 [MessagesMSG]
 ID_MB_WARNINGT=Warning
 ID_MB_WARNINGT=Warning

+ 1 - 1
SPS_EMU.044

@@ -150,7 +150,7 @@ ID_SPS_STOPPED=PLC stopped
 ID_SPS_PROGRAMMING=programming PLC
 ID_SPS_PROGRAMMING=programming PLC
 
 
 [hexfile]
 [hexfile]
-ID_START_LINE=Addr   BD   Instruction   Data      Comment  
+ID_START_LINE=Addr   BD   Inst.    Data      Comment  
 
 
 [MessagesMSG]
 [MessagesMSG]
 ID_MB_WARNINGT=Warning
 ID_MB_WARNINGT=Warning

+ 1 - 1
SPS_Emu.lpi

@@ -22,7 +22,7 @@
       <AutoIncrementBuild Value="True"/>
       <AutoIncrementBuild Value="True"/>
       <MinorVersionNr Value="2"/>
       <MinorVersionNr Value="2"/>
       <RevisionNr Value="1"/>
       <RevisionNr Value="1"/>
-      <BuildNr Value="50"/>
+      <BuildNr Value="51"/>
       <Language Value="0407"/>
       <Language Value="0407"/>
       <StringTable CompanyName="MCS" FileDescription="TPS/SPS Emulator" InternalName="SPS_EMU" LegalCopyright="MCS (C) Wilfried Klaas" OriginalFilename="SPS_EMU.exe" ProductName="TPS/SPS Emulator" ProductVersion="0.2"/>
       <StringTable CompanyName="MCS" FileDescription="TPS/SPS Emulator" InternalName="SPS_EMU" LegalCopyright="MCS (C) Wilfried Klaas" OriginalFilename="SPS_EMU.exe" ProductName="TPS/SPS Emulator" ProductVersion="0.2"/>
     </VersionInfo>
     </VersionInfo>

BIN
SPS_Emu.lsu


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 1
SPS_Emu.xml


+ 28 - 3
ugui.lfm

@@ -417,6 +417,16 @@ object Form1: TForm1
           Caption = 'R'
           Caption = 'R'
           OnClick = tbResetClick
           OnClick = tbResetClick
         end
         end
+        object tbPreLoad: TToolButton
+          Left = 3
+          Top = 209
+          Action = acPresetLoad
+        end
+        object tbPreSave: TToolButton
+          Left = 3
+          Top = 232
+          Action = acPresetSave
+        end
       end
       end
     end
     end
     object GroupBox3: TGroupBox
     object GroupBox3: TGroupBox
@@ -1096,6 +1106,21 @@ object Form1: TForm1
       ImageIndex = 52
       ImageIndex = 52
       OnExecute = acHexFileExecute
       OnExecute = acHexFileExecute
     end
     end
+    object acPresetLoad: TFileOpen
+      Category = 'File'
+      Caption = 'L'
+      Dialog.DefaultExt = '.ini'
+      Dialog.Filter = 'Ini Files|*.ini|all files|*.*'
+      ShortCut = 16463
+      OnAccept = acPresetLoadAccept
+    end
+    object acPresetSave: TFileSaveAs
+      Category = 'File'
+      Caption = 'S'
+      Dialog.DefaultExt = '.ini'
+      Dialog.Filter = 'ini files|*.ini|all files|*.*'
+      OnAccept = acPresetSaveAccept
+    end
   end
   end
   object ImageList1: TImageList
   object ImageList1: TImageList
     Height = 20
     Height = 20
@@ -5626,15 +5651,15 @@ object Form1: TForm1
   end
   end
   object SaveHexFile: TSaveDialog
   object SaveHexFile: TSaveDialog
     Title = 'ID_SAVE_HEX'
     Title = 'ID_SAVE_HEX'
-    DefaultExt = '.tps'
+    DefaultExt = '.hex'
     left = 584
     left = 584
     top = 496
     top = 496
   end
   end
   object ImageList2: TImageList
   object ImageList2: TImageList
     Height = 32
     Height = 32
     Width = 32
     Width = 32
-    left = 627
-    top = 499
+    left = 616
+    top = 496
     Bitmap = {
     Bitmap = {
       4C6969010000200000002000000080804000808040007C7C3EFF484824FF1A1A
       4C6969010000200000002000000080804000808040007C7C3EFF484824FF1A1A
       0DFF040402FF040402FF1A1A0DFF484824FF7C7C3EFF80804000808040008080
       0DFF040402FF040402FF1A1A0DFF484824FF7C7C3EFF80804000808040008080

+ 155 - 45
ugui.pas

@@ -9,7 +9,7 @@ interface
 uses
 uses
   Windows, Classes, SysUtils, FileUtil, SdpoSerial, Forms, Controls, Graphics, Dialogs,
   Windows, Classes, SysUtils, FileUtil, SdpoSerial, Forms, Controls, Graphics, Dialogs,
   Grids, ExtCtrls, Menus, ComCtrls, ActnList, StdActns, LCLProc, StdCtrls, Spin,
   Grids, ExtCtrls, Menus, ComCtrls, ActnList, StdActns, LCLProc, StdCtrls, Spin,
-  XMLPropStorage, uSPS, LCLType, Buttons, types, MCSWINAPI, Math;
+  XMLPropStorage, uSPS, LCLType, Buttons, types, MCSWINAPI, Math, fpjson, jsonparser;
 
 
 type
 type
 
 
@@ -38,6 +38,8 @@ type
     EditDelay: TLabeledEdit;
     EditDelay: TLabeledEdit;
     EditPage: TLabeledEdit;
     EditPage: TLabeledEdit;
     EditRAdr: TLabeledEdit;
     EditRAdr: TLabeledEdit;
+    acPresetLoad: TFileOpen;
+    acPresetSave: TFileSaveAs;
     GroupBox4: TGroupBox;
     GroupBox4: TGroupBox;
     ImageList2: TImageList;
     ImageList2: TImageList;
     Label3: TLabel;
     Label3: TLabel;
@@ -94,6 +96,8 @@ type
     StatusBar1: TStatusBar;
     StatusBar1: TStatusBar;
     StringGrid1: TStringGrid;
     StringGrid1: TStringGrid;
     tbPrg: TToggleBox;
     tbPrg: TToggleBox;
+    tbPreLoad: TToolButton;
+    tbPreSave: TToolButton;
     tbSel: TToggleBox;
     tbSel: TToggleBox;
     Timer1: TTimer;
     Timer1: TTimer;
     ToolBar1: TToolBar;
     ToolBar1: TToolBar;
@@ -126,6 +130,8 @@ type
     ToolButton7: TToolButton;
     ToolButton7: TToolButton;
     ToolButton8: TToolButton;
     ToolButton8: TToolButton;
     ToolButton9: TToolButton;
     ToolButton9: TToolButton;
+    TOpenDialogPreset: TOpenDialog;
+    TSaveDialogPreset: TSaveDialog;
     XMLPropStorage1: TXMLPropStorage;
     XMLPropStorage1: TXMLPropStorage;
     procedure acDeleteRowExecute(Sender: TObject);
     procedure acDeleteRowExecute(Sender: TObject);
     procedure acExitExecute(Sender: TObject);
     procedure acExitExecute(Sender: TObject);
@@ -137,6 +143,8 @@ type
     procedure acNewExecute(Sender: TObject);
     procedure acNewExecute(Sender: TObject);
     procedure acNewRowExecute(Sender: TObject);
     procedure acNewRowExecute(Sender: TObject);
     procedure acNextStepExecute(Sender: TObject);
     procedure acNextStepExecute(Sender: TObject);
+    procedure acPresetLoadAccept(Sender: TObject);
+    procedure acPresetSaveAccept(Sender: TObject);
     procedure acShowHexFileExecute(Sender: TObject);
     procedure acShowHexFileExecute(Sender: TObject);
     procedure acStopExecute(Sender: TObject);
     procedure acStopExecute(Sender: TObject);
     procedure acThisStepExecute(Sender: TObject);
     procedure acThisStepExecute(Sender: TObject);
@@ -155,8 +163,7 @@ type
     procedure StringGrid1EditingDone(Sender: TObject);
     procedure StringGrid1EditingDone(Sender: TObject);
     procedure StringGrid1Selection(Sender: TObject; aCol, aRow: integer);
     procedure StringGrid1Selection(Sender: TObject; aCol, aRow: integer);
     procedure tbPreset1Click(Sender: TObject);
     procedure tbPreset1Click(Sender: TObject);
-    procedure tbPreset1ContextPopup(Sender: TObject; MousePos: TPoint;
-      var Handled: boolean);
+    procedure tbPreset1ContextPopup(Sender: TObject; MousePos: TPoint; var Handled: boolean);
     procedure tbResetClick(Sender: TObject);
     procedure tbResetClick(Sender: TObject);
     procedure Timer1Timer(Sender: TObject);
     procedure Timer1Timer(Sender: TObject);
   private
   private
@@ -165,6 +172,9 @@ type
     stopit: boolean;
     stopit: boolean;
     activeFile: string;
     activeFile: string;
     dirty: boolean;
     dirty: boolean;
+    procedure saveSection(filename: string; key: string);
+    procedure loadSection(filename: string; key: string);
+
     procedure loadFile(filename: string);
     procedure loadFile(filename: string);
     procedure programSps;
     procedure programSps;
     procedure nextStep;
     procedure nextStep;
@@ -180,6 +190,8 @@ type
     procedure makeHexFile(fileName: string);
     procedure makeHexFile(fileName: string);
     procedure setCaption;
     procedure setCaption;
     procedure addHeaderText;
     procedure addHeaderText;
+    procedure loadPreset(filename: string);
+    procedure savePreset(filename: string);
   public
   public
     { public declarations }
     { public declarations }
   end;
   end;
@@ -190,7 +202,7 @@ var
 implementation
 implementation
 
 
 uses MCSAbout, uTextUi, uSelectCom, MCSTools, MCSStrings, synaser,
 uses MCSAbout, uTextUi, uSelectCom, MCSTools, MCSStrings, synaser,
-  MCSIO, mcsintelhex, fpjson, MCSLSU;
+  MCSIO, mcsintelhex, MCSLSU, MCSIniFiles;
 
 
 {$R *.lfm}
 {$R *.lfm}
 
 
@@ -396,8 +408,8 @@ begin
     begin
     begin
       if (StringGrid1.Cells[1, x] <> '') then
       if (StringGrid1.Cells[1, x] <> '') then
       begin
       begin
-        line := StringGrid1.Cells[0, x] + ',' + StringGrid1.Cells[1, x] +
-          ',' + StringGrid1.Cells[2, x] + ',"' + StringGrid1.Cells[4, x] + '"';
+        line := StringGrid1.Cells[0, x] + ',' + StringGrid1.Cells[1, x] + ',' +
+          StringGrid1.Cells[2, x] + ',"' + StringGrid1.Cells[4, x] + '"';
         Writeln(f, line);
         Writeln(f, line);
       end;
       end;
     end;
     end;
@@ -465,33 +477,42 @@ end;
 
 
 procedure TForm1.acNewExecute(Sender: TObject);
 procedure TForm1.acNewExecute(Sender: TObject);
 begin
 begin
-  StringGrid1.RowCount := 2;
-  StringGrid1.Clean;
-  addHeaderText();
-  renumberGrid();
-  activeFile := '';
-  setCaption();
-  setDirty(False);
+  if (checkDirty()) then
+  begin
+    StringGrid1.RowCount := 2;
+    StringGrid1.Clean;
+    addHeaderText();
+    renumberGrid();
+    activeFile := '';
+    setCaption();
+    setDirty(False);
+  end;
 end;
 end;
 
 
 procedure TForm1.acNewRowExecute(Sender: TObject);
 procedure TForm1.acNewRowExecute(Sender: TObject);
 var
 var
   myPos: integer;
   myPos: integer;
   i, x: integer;
   i, x: integer;
+  eot: boolean;
 begin
 begin
   myPos := StringGrid1.Row;
   myPos := StringGrid1.Row;
+  if (myPos = StringGrid1.RowCount - 1) then
+    eot := True;
   StringGrid1.RowCount := StringGrid1.RowCount + 1;
   StringGrid1.RowCount := StringGrid1.RowCount + 1;
-  for i := StringGrid1.RowCount - 2 downto myPos do
+  if (not eot) then
   begin
   begin
+    for i := StringGrid1.RowCount - 2 downto myPos do
+    begin
+      for x := 1 to StringGrid1.ColCount - 1 do
+      begin
+        StringGrid1.Cells[x, i + 1] := StringGrid1.Cells[x, i];
+      end;
+    end;
     for x := 1 to StringGrid1.ColCount - 1 do
     for x := 1 to StringGrid1.ColCount - 1 do
     begin
     begin
-      StringGrid1.Cells[x, i + 1] := StringGrid1.Cells[x, i];
+      StringGrid1.Cells[x, myPos] := '';
     end;
     end;
   end;
   end;
-  for x := 1 to StringGrid1.ColCount - 1 do
-  begin
-    StringGrid1.Cells[x, myPos] := '';
-  end;
   renumberGrid();
   renumberGrid();
 end;
 end;
 
 
@@ -528,6 +549,22 @@ begin
   selectAddress(sps.getAddress());
   selectAddress(sps.getAddress());
 end;
 end;
 
 
+procedure TForm1.acPresetLoadAccept(Sender: TObject);
+var
+  filename: string;
+begin
+  filename := (Sender as TFileOpen).Dialog.FileName;
+  loadPreset(filename);
+end;
+
+procedure TForm1.acPresetSaveAccept(Sender: TObject);
+var
+  filename: string;
+begin
+  filename := (Sender as TFileSaveAs).Dialog.FileName;
+  savePreset(filename);
+end;
+
 procedure TForm1.nextStep;
 procedure TForm1.nextStep;
 begin
 begin
   if (not sps.isActive()) then
   if (not sps.isActive()) then
@@ -628,8 +665,7 @@ begin
         tmp := tmp + '0';
         tmp := tmp + '0';
       line := line + tmp;
       line := line + tmp;
 
 
-      line := line + '      ' + StringGrid1.Cells[3, x] + '   ,"' +
-        StringGrid1.Cells[4, x] + '"';
+      line := line + '      ' + StringGrid1.Cells[3, x] + '   ,"' + StringGrid1.Cells[4, x] + '"';
       list.add(line);
       list.add(line);
     end;
     end;
   end;
   end;
@@ -721,8 +757,7 @@ begin
     begin
     begin
       KeyName := 'SOFTWARE\WOW6432Node\Arduino';
       KeyName := 'SOFTWARE\WOW6432Node\Arduino';
       StringValue := 'Install_Dir';
       StringValue := 'Install_Dir';
-      Res := RegistryReadString(HKEY_LOCAL_MACHINE, WideString(KeyName),
-        WideString(StringValue));
+      Res := RegistryReadString(HKEY_LOCAL_MACHINE, WideString(KeyName), WideString(StringValue));
       if Res <> '' then
       if Res <> '' then
       begin
       begin
         line := string(Res);
         line := string(Res);
@@ -808,8 +843,7 @@ var
 begin
 begin
   if (dirty) then
   if (dirty) then
   begin
   begin
-    i := MCSLSU.LSUAutoMsgBox('Messages', 'SAVE_CHANGES', MB_ICONQUESTION or
-      MB_YESNOCANCEL);
+    i := MCSLSU.LSUAutoMsgBox('Messages', 'SAVE_CHANGES', MB_ICONQUESTION or MB_YESNOCANCEL);
     if (i = mrYes) then
     if (i = mrYes) then
     begin
     begin
       saveFile(activeFile);
       saveFile(activeFile);
@@ -834,21 +868,37 @@ end;
 procedure TForm1.checkPresets;
 procedure TForm1.checkPresets;
 begin
 begin
   if XMLPropStorage1.ReadBoolean('preset_1.set', False) then
   if XMLPropStorage1.ReadBoolean('preset_1.set', False) then
-    tbPreset1.Caption := '1*';
+    tbPreset1.Caption := '1*'
+  else
+    tbPreset1.Caption := '1';
   if XMLPropStorage1.ReadBoolean('preset_2.set', False) then
   if XMLPropStorage1.ReadBoolean('preset_2.set', False) then
-    tbPreset2.Caption := '2*';
+    tbPreset2.Caption := '2*'
+  else
+    tbPreset2.Caption := '2';
   if XMLPropStorage1.ReadBoolean('preset_3.set', False) then
   if XMLPropStorage1.ReadBoolean('preset_3.set', False) then
-    tbPreset3.Caption := '3*';
+    tbPreset3.Caption := '3*'
+  else
+    tbPreset3.Caption := '3';
   if XMLPropStorage1.ReadBoolean('preset_4.set', False) then
   if XMLPropStorage1.ReadBoolean('preset_4.set', False) then
-    tbPreset4.Caption := '4*';
+    tbPreset4.Caption := '4*'
+  else
+    tbPreset4.Caption := '4';
   if XMLPropStorage1.ReadBoolean('preset_5.set', False) then
   if XMLPropStorage1.ReadBoolean('preset_5.set', False) then
-    tbPreset5.Caption := '5*';
+    tbPreset5.Caption := '5*'
+  else
+    tbPreset5.Caption := '5';
   if XMLPropStorage1.ReadBoolean('preset_6.set', False) then
   if XMLPropStorage1.ReadBoolean('preset_6.set', False) then
-    tbPreset6.Caption := '6*';
+    tbPreset6.Caption := '6*'
+  else
+    tbPreset6.Caption := '6';
   if XMLPropStorage1.ReadBoolean('preset_7.set', False) then
   if XMLPropStorage1.ReadBoolean('preset_7.set', False) then
-    tbPreset7.Caption := '7*';
+    tbPreset7.Caption := '7*'
+  else
+    tbPreset7.Caption := '7';
   if XMLPropStorage1.ReadBoolean('preset_8.set', False) then
   if XMLPropStorage1.ReadBoolean('preset_8.set', False) then
-    tbPreset8.Caption := '8*';
+    tbPreset7.Caption := '8*'
+  else
+    tbPreset7.Caption := '8';
 end;
 end;
 
 
 procedure TForm1.makeHexFile(fileName: string);
 procedure TForm1.makeHexFile(fileName: string);
@@ -893,8 +943,7 @@ begin
   end
   end
   else
   else
   begin
   begin
-    Caption := MCSLSU.GetLSUText('form1Captions', 'ID_CAPTION', lsuCode) +
-      ':' + ExtractFileName(activeFile);
+    Caption := MCSLSU.GetLSUText('form1Captions', 'ID_CAPTION', lsuCode) + ':' + ExtractFileName(activeFile);
   end;
   end;
 
 
 end;
 end;
@@ -909,8 +958,7 @@ begin
     StringGrid1.Columns[i].Title.Caption :=
     StringGrid1.Columns[i].Title.Caption :=
       MCSLSU.GetLSUText('form1Captions', StringGrid1.Columns[i].Title.Caption, lsuCode);
       MCSLSU.GetLSUText('form1Captions', StringGrid1.Columns[i].Title.Caption, lsuCode);
   end;
   end;
-  StringGrid1.Cells[0, 0] := MCSLSU.GetLSUText('form1Captions',
-    'ID_GRID_STORAGE', lsuCode);
+  StringGrid1.Cells[0, 0] := MCSLSU.GetLSUText('form1Captions', 'ID_GRID_STORAGE', lsuCode);
   StringGrid1.Repaint;
   StringGrid1.Repaint;
 end;
 end;
 
 
@@ -1050,8 +1098,7 @@ begin
   begin
   begin
     x := StringGrid1.Row;
     x := StringGrid1.Row;
     StringGrid1.Cells[3, x] :=
     StringGrid1.Cells[3, x] :=
-      sps.getCommandText(HexToInt(StringGrid1.Cells[1, x]),
-      HexToInt(StringGrid1.Cells[2, x]));
+      sps.getCommandText(HexToInt(StringGrid1.Cells[1, x]), HexToInt(StringGrid1.Cells[2, x]));
     setDirty(True);
     setDirty(True);
   end;
   end;
 end;
 end;
@@ -1066,6 +1113,61 @@ begin
   end;
   end;
 end;
 end;
 
 
+procedure TForm1.loadPreset(filename : string);
+var
+  x: integer;
+  key: string;
+begin
+  for x := 1 to 8 do
+  begin
+    key := 'preset_' + IntToStr(x);
+    loadSection(filename, key);
+  end;
+  checkPresets;
+end;
+
+procedure TForm1.savePreset(filename : string);
+var
+  x: integer;
+  key: string;
+begin
+  for x := 1 to 8 do
+  begin
+    key := 'preset_' + IntToStr(x);
+    saveSection(filename, key);
+  end;
+end;
+
+procedure TForm1.saveSection(filename: string; key: string);
+begin
+  WriteIniBool(key, 'set', XMLPropStorage1.ReadBoolean(key + '.set', False), filename);
+  WriteIniBool(key, 'prg', XMLPropStorage1.ReadBoolean(key + '.prg', False), filename);
+  WriteIniBool(key, 'sel', XMLPropStorage1.ReadBoolean(key + '.sel', False), filename);
+  WriteIniBool(key, 'input1', XMLPropStorage1.ReadBoolean(key + '.input1', False), filename);
+  WriteIniBool(key, 'input2', XMLPropStorage1.ReadBoolean(key + '.input2', False), filename);
+  WriteIniBool(key, 'input3', XMLPropStorage1.ReadBoolean(key + '.input3', False), filename);
+  WriteIniBool(key, 'input4', XMLPropStorage1.ReadBoolean(key + '.input4', False), filename);
+  WriteIniInteger(key, 'adc1', XMLPropStorage1.ReadInteger(key + '.adc1', 0), filename);
+  WriteIniInteger(key, 'adc2', XMLPropStorage1.ReadInteger(key + '.adc2', 0), filename);
+  WriteIniInteger(key, 'rc1', XMLPropStorage1.ReadInteger(key + '.rc1', 0), filename);
+  WriteIniInteger(key, 'rc2', XMLPropStorage1.ReadInteger(key + '.rc2', 0), filename);
+end;
+
+procedure TForm1.loadSection(filename: string; key: string);
+begin
+  XMLPropStorage1.WriteBoolean(key + '.set', ReadIniBool(key, 'set', False, filename));
+  XMLPropStorage1.WriteBoolean(key + '.prg', ReadIniBool(key, 'prg', False, filename));
+  XMLPropStorage1.WriteBoolean(key + '.sel', ReadIniBool(key, 'sel', False, filename));
+  XMLPropStorage1.WriteBoolean(key + '.input1', ReadIniBool(key, 'input1', False, filename));
+  XMLPropStorage1.WriteBoolean(key + '.input2', ReadIniBool(key, 'input2', False, filename));
+  XMLPropStorage1.WriteBoolean(key + '.input3', ReadIniBool(key, 'input3', False, filename));
+  XMLPropStorage1.WriteBoolean(key + '.input4', ReadIniBool(key, 'input4', False, filename));
+  XMLPropStorage1.WriteInteger(key + '.adc1', ReadIniInteger(key, 'adc1', 0, filename));
+  XMLPropStorage1.WriteInteger(key + '.adc2', ReadIniInteger(key, 'adc2', 0, filename));
+  XMLPropStorage1.WriteInteger(key + '.rc1', ReadIniInteger(key, 'rc1', 0, filename));
+  XMLPropStorage1.WriteInteger(key + '.rc2', ReadIniInteger(key, 'rc2', 0, filename));
+end;
+
 procedure TForm1.tbPreset1Click(Sender: TObject);
 procedure TForm1.tbPreset1Click(Sender: TObject);
 var
 var
   key: string;
   key: string;
@@ -1094,6 +1196,8 @@ begin
   if Sender = tbPreset8 then
   if Sender = tbPreset8 then
     key := 'preset_8';
     key := 'preset_8';
 
 
+  tbSel.Checked := XMLPropStorage1.ReadBoolean(key + '.prg', tbSel.Checked);
+  tbPrg.Checked := XMLPropStorage1.ReadBoolean(key + '.sel', tbPrg.Checked);
   Din1.Checked := XMLPropStorage1.ReadBoolean(key + '.input1', Din1.Checked);
   Din1.Checked := XMLPropStorage1.ReadBoolean(key + '.input1', Din1.Checked);
   Din2.Checked := XMLPropStorage1.ReadBoolean(key + '.input2', Din2.Checked);
   Din2.Checked := XMLPropStorage1.ReadBoolean(key + '.input2', Din2.Checked);
   Din3.Checked := XMLPropStorage1.ReadBoolean(key + '.input3', Din3.Checked);
   Din3.Checked := XMLPropStorage1.ReadBoolean(key + '.input3', Din3.Checked);
@@ -1104,8 +1208,7 @@ begin
   RC2.Value := XMLPropStorage1.ReadInteger(key + '.rc2', RC2.Value);
   RC2.Value := XMLPropStorage1.ReadInteger(key + '.rc2', RC2.Value);
 end;
 end;
 
 
-procedure TForm1.tbPreset1ContextPopup(Sender: TObject; MousePos: TPoint;
-  var Handled: boolean);
+procedure TForm1.tbPreset1ContextPopup(Sender: TObject; MousePos: TPoint; var Handled: boolean);
 var
 var
   key: string;
   key: string;
 begin
 begin
@@ -1134,6 +1237,8 @@ begin
     key := 'preset_8';
     key := 'preset_8';
 
 
   XMLPropStorage1.WriteBoolean(key + '.set', True);
   XMLPropStorage1.WriteBoolean(key + '.set', True);
+  XMLPropStorage1.WriteBoolean(key + '.prg', tbPrg.Checked);
+  XMLPropStorage1.WriteBoolean(key + '.sel', tbSel.Checked);
   XMLPropStorage1.WriteBoolean(key + '.input1', Din1.Checked);
   XMLPropStorage1.WriteBoolean(key + '.input1', Din1.Checked);
   XMLPropStorage1.WriteBoolean(key + '.input2', Din2.Checked);
   XMLPropStorage1.WriteBoolean(key + '.input2', Din2.Checked);
   XMLPropStorage1.WriteBoolean(key + '.input3', Din3.Checked);
   XMLPropStorage1.WriteBoolean(key + '.input3', Din3.Checked);
@@ -1147,6 +1252,8 @@ end;
 
 
 procedure TForm1.tbResetClick(Sender: TObject);
 procedure TForm1.tbResetClick(Sender: TObject);
 begin
 begin
+  tbPrg.Checked := False;
+  tbSel.Checked := False;
   Din1.Checked := False;
   Din1.Checked := False;
   Din2.Checked := False;
   Din2.Checked := False;
   Din3.Checked := False;
   Din3.Checked := False;
@@ -1171,8 +1278,8 @@ begin
   if (InfoBox.newVersion) then
   if (InfoBox.newVersion) then
   begin
   begin
     MCSLabel.Font.Color := clred;
     MCSLabel.Font.Color := clred;
-    MCSLabel.Hint := InfoBox.versionHint + chr($0a) + chr($0d) +
-      MCSLSU.GetLSUText('form1Captions', 'ID_CLICK_HERE', lsuCode);
+    MCSLabel.Hint := InfoBox.versionHint + chr($0a) + chr($0d) + MCSLSU.GetLSUText(
+      'form1Captions', 'ID_CLICK_HERE', lsuCode);
   end;
   end;
   MCSLabel.Caption := InfoBox.versionText;
   MCSLabel.Caption := InfoBox.versionText;
 end;
 end;
@@ -1185,9 +1292,12 @@ begin
   for x := 1 to i - 1 do
   for x := 1 to i - 1 do
   begin
   begin
     StringGrid1.Cells[0, x] := '0x' + inttohex(x - 1, 2);
     StringGrid1.Cells[0, x] := '0x' + inttohex(x - 1, 2);
+    if (StringGrid1.Cells[1, x] = '') then
+      StringGrid1.Cells[1, x] := '0';
+    if (StringGrid1.Cells[2, x] = '') then
+      StringGrid1.Cells[2, x] := '0';
     StringGrid1.Cells[3, x] :=
     StringGrid1.Cells[3, x] :=
-      sps.getCommandText(HexToInt(StringGrid1.Cells[1, x]),
-      HexToInt(StringGrid1.Cells[2, x]));
+      sps.getCommandText(HexToInt(StringGrid1.Cells[1, x]), HexToInt(StringGrid1.Cells[2, x]));
   end;
   end;
 end;
 end;
 
 

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác