diff --git a/src/ComMainForm.dcu b/src/ComMainForm.dcu index 53fd9c8..69cf473 100644 Binary files a/src/ComMainForm.dcu and b/src/ComMainForm.dcu differ diff --git a/src/ComMainForm.dfm b/src/ComMainForm.dfm index 4a08017..87c9558 100644 Binary files a/src/ComMainForm.dfm and b/src/ComMainForm.dfm differ diff --git a/src/ComMainForm.pas b/src/ComMainForm.pas index 27f32e1..a06b96b 100644 --- a/src/ComMainForm.pas +++ b/src/ComMainForm.pas @@ -107,9 +107,11 @@ TMainForm = class(TForm) sSpeedButton7: TsSpeedButton; vFitBtn: TsSpeedButton; sSpeedButton6: TsSpeedButton; + SOTSlider: TsSlider; procedure FormShow(Sender: TObject); procedure FormCreate(Sender: TObject); procedure OpenClose(Sender: TObject); + function GetAppDir: string; procedure Settings(Sender: TObject); procedure SliderChange(Sender: TObject); procedure ResizeIconMouseDown(Sender: TObject; Button: TMouseButton; @@ -127,28 +129,28 @@ TMainForm = class(TForm) procedure ShrinkBtnClick(Sender: TObject); procedure ComPortRxChar(Sender: TObject; Count: Integer); procedure PopExportClick(Sender: TObject); - procedure SaveToLog(SessionDate: string; Port: string; DataLine: string); procedure PopClearClick(Sender: TObject); procedure emulationComboCloseUp(Sender: TObject); procedure ComPortException(Sender: TObject; TComException: TComExceptions; ComportMessage: string; WinError: Int64; WinMessage: string); procedure ErrorTimmerTimer(Sender: TObject); - function RemoveEscapeCodes(const InputStr: string): string; procedure AutoClick(Sender: TObject); procedure AutoLogBtnClick(Sender: TObject); procedure LogDirBtnClick(Sender: TObject); procedure ExspandBtnClick(Sender: TObject); procedure vFitBtnClick(Sender: TObject); + procedure SOTSliderSliderChange(Sender: TObject); + function GetComTerminal(idx: integer): TComTerminal; private { Private declarations } FResizing: Boolean; FStartY: Integer; function GetLocalVersion: string; - function GetAppDir: string; + function GetConnectBtn(idx: integer): TsButton; function GetComPort(idx: integer): TComPort; - function GetComTerminal(idx: integer): TComTerminal; + function GetComSlider(idx: integer): TsSlider; function GetCompanel(idx: integer): tPanel; function GetComLabel(idx: integer): TsLabel; @@ -168,16 +170,16 @@ TMainForm = class(TForm) VisAry: array[0..5] of bool; LogAry: array[0..5] of bool; RxAry: array[0..5] of string; - ConfigFile, SessionDate: string; + ConfigFile, LogDir, SessionDate: string; AutoLogOn: boolean; + implementation -uses Clipbrd; +uses Clipbrd, SaveLog; {$R *.DFM} - function TMainForm.GetLocalVersion: string; var VerInfoSize: DWORD; @@ -274,7 +276,6 @@ procedure TMainForm.UpdateFont(); procedure TMainForm.UpdateEmulation(); var x: integer; CustomComTerminal: TCustomComTerminal; - begin for x := 0 to 5 do begin @@ -305,59 +306,6 @@ procedure TMainForm.ResizeIconMouseUp(Sender: TObject; Button: TMouseButton; end; ///////////////////////////////////////////////////////////////////////////// -function PosEx(const SubStr, S: string; Offset: Integer = 1): Integer; -var - i: Integer; -begin - Result := 0; - for i := Offset to Length(S) - Length(SubStr) + 1 do - if Copy(S, i, Length(SubStr)) = SubStr then - begin - Result := i; - Break; - end; -end; -///////////////////////////////////////////////////////////////////////////// - -function TMainForm.RemoveEscapeCodes(const InputStr: string): string; -var - EscapeCodeStart, EscapeCodeEnd: Integer; -begin - Result := InputStr; - EscapeCodeStart := Pos(#27, Result); - while EscapeCodeStart > 0 do - begin - EscapeCodeEnd := PosEx('m', Result, EscapeCodeStart); - if EscapeCodeEnd > 0 then - Delete(Result, EscapeCodeStart, EscapeCodeEnd - EscapeCodeStart + 1); - EscapeCodeStart := PosEx(#27, Result, EscapeCodeStart); - end; -end; - -///////////////////////////////////////////////////////////////////////////// - -procedure TMainForm.SaveToLog(SessionDate: string; Port: string; DataLine: string); -var - fFile: TextFile; - Filename: string; -begin - DataLine := StringReplace(DataLine, #10, '', [rfReplaceAll, rfIgnoreCase]); - DataLine := StringReplace(DataLine, #13, '', [rfReplaceAll, rfIgnoreCase]); - DataLine := RemoveEscapeCodes(DataLine); - - Filename := GetAppDir + 'Logs\' + SessionDate + Port + '.txt'; - AssignFile(fFile, Filename); - if FileExists(Filename) <> true then - Rewrite(fFile) - else - Append(fFile); - WriteLn(fFile, DataLine); - CloseFile(fFile) -end; - - -///////////////////////////////////////////////////////////////////////////// - procedure TMainForm.LoadConfig(Filename: string); var IniFile: TIniFile; @@ -417,6 +365,7 @@ procedure TMainForm.SaveConfig(Filename: string); IniFile.Free; end; end; + ///////////////////////////////////////////////////////////////////////////// procedure TMainForm.FormCreate(Sender: TObject); @@ -428,7 +377,6 @@ procedure TMainForm.FormCreate(Sender: TObject); ///////////////////////////////////////////////////////////////////////////// procedure TMainForm.UpDateStatusBar(); -var x: integer; begin StatusBar.Panels[7].Width := Width - 880; end; @@ -441,6 +389,7 @@ procedure TMainForm.FormShow(Sender: TObject); begin AutoLogOn := false; ConfigFile := GetAppDir + 'config.ini'; + LogDir := GetAppDir + 'Logs\'; LoadConfig(ConfigFile); UpDateStatusBar(); UpdateEmulation(); @@ -457,6 +406,7 @@ procedure TMainForm.FormShow(Sender: TObject); SessionDate := FormatDateTime('yyyy-mm-dd-hh-nn-', Now()); end; + ///////////////////////////////////////////////////////////////////////////// procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction); @@ -467,6 +417,7 @@ procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction); GetComPort(x).close; SaveConfig(ConfigFile); end; + ///////////////////////////////////////////////////////////////////////////// procedure TMainForm.FormResize(Sender: TObject); @@ -475,7 +426,8 @@ procedure TMainForm.FormResize(Sender: TObject); ComTerminalResize(nil); UpDateStatusBar(); end; - ///////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////// procedure TMainForm.AutoClick(Sender: TObject); var ChkSender, CheckBox: TsCheckBox; @@ -488,7 +440,6 @@ procedure TMainForm.AutoClick(Sender: TObject); end; end; - ///////////////////////////////////////////////////////////////////////////// procedure TMainForm.AutoLogBtnClick(Sender: TObject); @@ -569,7 +520,6 @@ procedure TMainForm.OpenClose(Sender: TObject); Timer0.Enabled := True; end; end; - // AutoBtn.SetFocus; end; end; @@ -587,8 +537,6 @@ procedure TMainForm.ComPortException(Sender: TObject; else Statusbar.Panels[7].Text := 'ERROR : ' + ComportMessage + ' (' + IntToStr(WinError) + ')'; ErrorTimmer.Enabled := True; end; - // abort; - end; ///////////////////////////////////////////////////////////////////////////// @@ -633,8 +581,7 @@ procedure TMainForm.ResizeIconMouseMove(Sender: TObject; Shift: TShiftState; ///////////////////////////////////////////////////////////////////////////// procedure TMainForm.ComTerminalResize(Sender: TObject); -var - x: integer; +//var x: integer; begin // for x := 0 to 5 do // GetComTerminal(x).Rows := (GetCompanel(x).Height div GetComTerminal(x).Font.Size) - 6; @@ -653,7 +600,8 @@ procedure TMainForm.FontSelectCloseUp(Sender: TObject); end; ///////////////////////////////////////////////////////////////////////////// - procedure TMainForm.vFitBtnClick(Sender: TObject); + +procedure TMainForm.vFitBtnClick(Sender: TObject); var x, HeadFoot, PHeight: integer; DivCount: integer; @@ -679,34 +627,31 @@ procedure TMainForm.FontSelectCloseUp(Sender: TObject); AutoSize := false; end; update; - end; ///////////////////////////////////////////////////////////////////////////// + procedure TMainForm.ExspandBtnClick(Sender: TObject); var - x, HeadFoot, PHeight: integer; - DivCount, MHeight: integer; + x, HeadFoot: integer; + MHeight: integer; begin - if (Height > Screen.WorkAreaHeight) then Height := Screen.WorkAreaHeight; - if (Width > Screen.WorkAreaWidth) then Width := Screen.WorkAreaWidth; - DivCount := 0; - MHeight :=0; + if (Height > Screen.WorkAreaHeight) then Height := Screen.WorkAreaHeight; + if (Width > Screen.WorkAreaWidth) then Width := Screen.WorkAreaWidth; + MHeight := 0; for x := 0 to 5 do begin if (VisAry[x] = true) then begin - MHeight := MHeight + GetCompanel(x).Height; - DivCount := DivCount + 1; + MHeight := MHeight + GetCompanel(x).Height; end; - end; HeadFoot := MenuPanel.Height + StatusBar.Height; - MainForm.ClientHeight:= MHeight + HeadFoot; + MainForm.ClientHeight := MHeight + HeadFoot; if (Height > Screen.WorkAreaHeight) then begin -vFitBtn.Click; + vFitBtn.Click; end; @@ -718,55 +663,58 @@ procedure TMainForm.ExspandBtnClick(Sender: TObject); procedure TMainForm.ShrinkBtnClick(Sender: TObject); var x, HeadFoot, PHeight: integer; - DivCount, MHeight: integer; + MHeight: integer; begin - if (Height > Screen.WorkAreaHeight) then Height := Screen.WorkAreaHeight; - if (Width > Screen.WorkAreaWidth) then Width := Screen.WorkAreaWidth; - DivCount := 0; - MHeight :=0; + if (Height > Screen.WorkAreaHeight) then Height := Screen.WorkAreaHeight; + if (Width > Screen.WorkAreaWidth) then Width := Screen.WorkAreaWidth; + MHeight := 0; for x := 0 to 5 do begin if (VisAry[x] = true) then - MHeight := MHeight + GetCompanel(x).Height; + MHeight := MHeight + GetCompanel(x).Height; end; HeadFoot := MenuPanel.Height + StatusBar.Height; - MainForm.ClientHeight:= MHeight + HeadFoot; + MainForm.ClientHeight := MHeight + HeadFoot; if (Height < Screen.WorkAreaHeight) then begin - AutoSize := true; -AutoSize := false; + AutoSize := true; + AutoSize := false; end; - - update; - end; ///////////////////////////////////////////////////////////////////////////// procedure TMainForm.ComPortRxChar(Sender: TObject; Count: Integer); var - Str: string; + Str, Portstr: string; ComSender: tComPort; + Tag: integer; begin ComSender := Sender as tComPort; + Tag := ComSender.Tag; GetComPort(ComSender.Tag).ReadStr(Str, Count); - + Portstr := GetComPort(ComSender.Tag).Port; RxAry[ComSender.Tag] := RxAry[ComSender.Tag] + Str; - if ((Pos(#0, RxAry[ComSender.Tag]) > 0) or (Pos(#13 + #10, RxAry[ComSender.Tag]) > 0)) then + if ((Pos(#0, RxAry[Tag]) > 0) or (Pos(#13 + #10, RxAry[Tag]) > 0)) then begin - StatusBar.Panels[ComSender.Tag + 1].Text := GetComPort(ComSender.Tag).Port + ': ' + IntToStr(Length(RxAry[ComSender.Tag])) + ' Bytes recv'; + StatusBar.Panels[Tag + 1].Text := Portstr + ': ' + IntToStr(Length(RxAry[Tag])) + ' Bytes recv'; if (TimeSlider.SliderOn) then begin - RxAry[ComSender.Tag] := FormatDateTime('hh:nn:ss.zzz', Now()) + ' : ' + RxAry[ComSender.Tag]; + RxAry[Tag] := FormatDateTime('hh:nn:ss.zzz', Now()) + ' : ' + RxAry[Tag]; end; - GetComTerminal(ComSender.Tag).WriteStr(RxAry[ComSender.Tag]); + GetComTerminal(Tag).WriteStr(RxAry[Tag]); - if (LogAry[ComSender.Tag]) then SaveToLog(SessionDate, GetComPort(ComSender.Tag).Port, RxAry[ComSender.Tag]); - RxAry[ComSender.Tag] := ''; + if (LogAry[Tag]) then + begin + TLogSaveThread.Create(Portstr, RxAry[Tag], Tag); + StatusBar.Panels[Tag + 1].Text := 'Saving'; + end; + + RxAry[Tag] := ''; end; end; ///////////////////////////////////////////////////////////////////////////// @@ -812,9 +760,17 @@ procedure TMainForm.PopClearClick(Sender: TObject); end; + ///////////////////////////////////////////////////////////////////////////// +procedure TMainForm.SOTSliderSliderChange(Sender: TObject); +begin + if (SOTSlider.SliderOn) then + SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NoMove or SWP_NoSize) + else + SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NoMove or SWP_NoSize); +end; - + ///////////////////////////////////////////////////////////////////////////// end. diff --git a/src/MultiCOM.dof b/src/MultiCOM.dof index 1f573e5..9b1ded1 100644 --- a/src/MultiCOM.dof +++ b/src/MultiCOM.dof @@ -65,7 +65,7 @@ IncludeVerInfo=1 AutoIncBuild=0 MajorVer=1 MinorVer=0 -Release=5 +Release=6 Build=0 Debug=0 PreRelease=0 @@ -77,7 +77,7 @@ CodePage=1252 [Version Info Keys] CompanyName=Brian Canning FileDescription=MultCOM, 6 port serial Monitoring -FileVersion=1.0.5.0 +FileVersion=1.0.6.0 InternalName= LegalCopyright= LegalTrademarks= diff --git a/src/MultiCOM.dpr b/src/MultiCOM.dpr index a432a1a..e1ee8e9 100644 --- a/src/MultiCOM.dpr +++ b/src/MultiCOM.dpr @@ -2,7 +2,8 @@ program MultiCom; uses Forms, - ComMainForm in 'ComMainForm.pas' {MainForm}; + ComMainForm in 'ComMainForm.pas' {MainForm}, + SaveLog in 'SaveLog.pas'; {$R *.RES} diff --git a/src/MultiCOM.dsk b/src/MultiCOM.dsk index 53160d4..fa20079 100644 --- a/src/MultiCOM.dsk +++ b/src/MultiCOM.dsk @@ -1,14 +1,14 @@ [Closed Files] -File_0=SourceModule,'C:\Program Files (x86)\Borland\Delphi6\Installed Packages\ComPort-Library\Source\CPortEsc.pas',0,1,1,18,1,0,0 -File_1=SourceModule,'C:\Program Files (x86)\Borland\Delphi6\Installed Packages\ComPort-Library\Source\CPortCtl.pas',0,1,2129,1,2139,0,0 -File_2=SourceModule,'C:\Program Files (x86)\Borland\Delphi6\Installed Packages\ComPort-Library\Source\CPort.pas',0,1,2017,1,2027,0,0 -File_3=SourceModule,'c:\program files (x86)\borland\delphi6\source\rtl\Win\Windows.pas',0,1,28672,22,28689,0,0 -File_4=SourceModule,'c:\program files (x86)\borland\delphi6\source\vcl\Dialogs.pas',0,1,299,34,317,0,0 -File_5=SourceModule,'c:\program files (x86)\borland\delphi6\source\vcl\Controls.pas',0,1,118,7,130,0,0 -File_6=SourceModule,'C:\Program Files (x86)\Borland\Delphi6\Packages\comport411f\Source\CPort.pas',0,1,1904,30,1907,0,0 -File_7=SourceModule,'C:\Program Files (x86)\Borland\Delphi6\Installed Packages\sButton.pas',0,1,1201,1,1218,0,0 -File_8=SourceModule,'C:\Program Files (x86)\Borland\Delphi6\Packages\comport411f\Source\CPortEsc.pas',0,1,91,1,102,0,0 -File_9=SourceModule,'C:\Program Files (x86)\Borland\Delphi6\Installed Packages\acnt_reg12\sSkinProvider.pas',0,1,7766,1,7828,0,0 +File_0=SourceModule,'D:\Delphi\MultiCOM\SaveLog.pas',0,1,46,19,4,0,0 +File_1=SourceModule,'C:\Program Files (x86)\Borland\Delphi6\Installed Packages\ComPort-Library\Source\CPortCtl.pas',0,1,2044,1,2061,0,0 +File_2=SourceModule,'C:\Program Files (x86)\Borland\Delphi6\Installed Packages\ComPort-Library\Source\CPortEsc.pas',0,1,78,1,102,0,0 +File_3=SourceModule,'c:\program files (x86)\borland\delphi6\source\vcl\Controls.pas',0,1,7685,1,7702,0,0 +File_4=SourceModule,'C:\Program Files (x86)\Borland\Delphi6\Installed Packages\ComPort-Library\Source\CPort.pas',0,1,776,1,790,0,0 +File_5=SourceModule,'c:\program files (x86)\borland\delphi6\source\rtl\Win\Windows.pas',0,1,28672,22,28689,0,0 +File_6=SourceModule,'c:\program files (x86)\borland\delphi6\source\vcl\Dialogs.pas',0,1,299,34,317,0,0 +File_7=SourceModule,'C:\Program Files (x86)\Borland\Delphi6\Packages\comport411f\Source\CPort.pas',0,1,1904,30,1907,0,0 +File_8=SourceModule,'C:\Program Files (x86)\Borland\Delphi6\Installed Packages\sButton.pas',0,1,1201,1,1218,0,0 +File_9=SourceModule,'C:\Program Files (x86)\Borland\Delphi6\Packages\comport411f\Source\CPortEsc.pas',0,1,91,1,102,0,0 [Modules] Module0=D:\Delphi\MultiCOM\ComMainForm.pas @@ -40,24 +40,24 @@ State=0 Left=275 Top=110 Width=1306 -Height=742 +Height=734 MaxLeft=-1 MaxTop=-1 ClientWidth=1290 -ClientHeight=703 -LeftPanelSize=202 +ClientHeight=695 +LeftPanelSize=140 LeftPanelClients=CodeExplorer@EditWindow0 LeftPanelData=000004000000000000000000000000000000000000000000000100000000000000000C000000436F64654578706C6F726572FFFFFFFF RightPanelSize=0 -BottomPanelSize=251 +BottomPanelSize=0 BottomPanelClients=MessageView@EditWindow0 -BottomPanelData=00000400000000000A0500000000000002FB000000000000000100000000000000000000000001000000000A0500000000000001000000000A0500000B0000004D65737361676556696577FFFFFFFF +BottomPanelData=00000400010000000B0000004D657373616765566965770A050000000000000224010000000000000100000000000000000000000001000000000A0500000000000001000000000A0500000000000001000000000A0500000000000001000000000A0500000000000001000000000A0500000000000001000000000A0500000000000001000000000A0500000000000001000000000A0500000B0000004D65737361676556696577FFFFFFFF [View0] Module=D:\Delphi\MultiCOM\ComMainForm.pas -CursorX=23 -CursorY=286 -TopLine=274 +CursorX=58 +CursorY=16 +TopLine=760 LeftCol=1 [Watches] @@ -148,20 +148,20 @@ Create=1 Visible=1 State=0 Left=0 -Top=181 +Top=233 Width=266 -Height=521 +Height=469 MaxLeft=-1 MaxTop=-1 ClientWidth=266 -ClientHeight=521 +ClientHeight=469 TBDockHeight=527 LRDockWidth=266 Dockable=1 SplitPos=131 ArrangeBy=Name -SelectedItem=OnRxChar -ExpandedItems=AnimEffects.FormShow,AnimEffects.Minimizing,Font,FormHeader,MenuAnimation,SkinningRules,Timeouts +SelectedItem=OnMouseMove +ExpandedItems=AnimEffects.FormShow,AnimEffects.Minimizing,BoundLabel,Events,FlowControl,FormHeader,MenuAnimation,SkinningRules,Timeouts HiddenCategories= [WatchWindow] @@ -266,11 +266,11 @@ State=0 Left=0 Top=12 Width=266 -Height=153 +Height=205 MaxLeft=-1 MaxTop=-1 ClientWidth=266 -ClientHeight=153 +ClientHeight=205 TBDockHeight=352 LRDockWidth=266 Dockable=1 @@ -352,29 +352,29 @@ Visible=1 State=0 Left=0 Top=12 -Width=202 -Height=437 +Width=140 +Height=683 MaxLeft=-1 MaxTop=-1 -ClientWidth=202 -ClientHeight=437 +ClientWidth=140 +ClientHeight=683 TBDockHeight=305 -LRDockWidth=202 +LRDockWidth=140 Dockable=1 [MessageView@EditWindow0] Create=1 -Visible=1 +Visible=0 State=0 Left=12 Top=0 Width=1278 -Height=251 +Height=292 MaxLeft=-1 MaxTop=-1 ClientWidth=1278 -ClientHeight=251 -TBDockHeight=251 +ClientHeight=292 +TBDockHeight=292 LRDockWidth=443 Dockable=1 @@ -398,5 +398,5 @@ TBDockHeight=741 LRDockWidth=282 Dockable=1 DockClients=ObjectTree,PropertyInspector -DockSiteData=0000040000000000BE02000000000000010A010000000000000100000000A90000000E0000004F626A65637454726565566965770100000000BE0200001100000050726F7065727479496E73706563746F72FFFFFFFF +DockSiteData=0000040000000000BE02000000000000010A010000000000000100000000DD0000000E0000004F626A65637454726565566965770100000000BE0200001100000050726F7065727479496E73706563746F72FFFFFFFF diff --git a/src/MultiCOM.res b/src/MultiCOM.res index e03cbe8..5a0b023 100644 Binary files a/src/MultiCOM.res and b/src/MultiCOM.res differ diff --git a/src/SaveLog.dcu b/src/SaveLog.dcu new file mode 100644 index 0000000..97bfb37 Binary files /dev/null and b/src/SaveLog.dcu differ diff --git a/src/SaveLog.pas b/src/SaveLog.pas new file mode 100644 index 0000000..e0e4831 --- /dev/null +++ b/src/SaveLog.pas @@ -0,0 +1,61 @@ +unit SaveLog; +interface +uses + Classes, SyncObjs; + +type + TLogSaveThread = class(TThread) + private + FTag: integer; + FPort: string; + FDataLine: string; + FCriticalSection: TCriticalSection; + protected + procedure Execute; override; + public + constructor Create(const Port, DataLine: string; Tag: integer); + destructor Destroy; override; + end; + +implementation + +uses ComMainForm; + +constructor TLogSaveThread.Create(const Port, DataLine: string; Tag: integer); +begin + inherited Create(True); + FTag := Tag; + FPort := Port; + FDataLine := DataLine; + FCriticalSection := TCriticalSection.Create; + Resume; +end; + + ///////////////////////////////////////////////////////////////////////////// + +destructor TLogSaveThread.Destroy; +begin + FCriticalSection.Free; + inherited Destroy; +end; + + ///////////////////////////////////////////////////////////////////////////// + +procedure TLogSaveThread.Execute; +var + fFile: TextFile; + Filename: string; + FileStream: TFileStream; +begin + Filename := LogDir + SessionDate + FPort + '.txt'; + try + FileStream := TFileStream.Create(FileName, fmCreate); + Mainform.GetComTerminal(FTag).SaveToStream(FileStream); + finally + FileStream.Free; // Free the stream + end; +end; + +end. + + \ No newline at end of file