1
0
mirror of https://github.com/mbirth/cm2010.git synced 2024-12-26 03:24:07 +00:00

modified CM2010.dfm

modified   CM2010.pas
modified   CM2010Project.dof
modified   CM2010Project.ini
+ TComPort-LEDs
+ ProgressBar according to Byte 03/Lo
+ LOGGING! (1 min = 60x34 Bytes = 2.040 Bytes; 1 hour = 122.400 Bytes)
* Optimizations
i Added some INI-Entries for future CM2020 support
This commit is contained in:
mbirth 2004-12-08 08:58:36 +00:00
parent e3e529c26b
commit 4e5a946cb4
4 changed files with 403 additions and 80 deletions

View File

@ -1,7 +1,7 @@
object Form1: TForm1 object Form1: TForm1
Left = 195 Left = 195
Top = 109 Top = 109
Width = 721 Width = 716
Height = 477 Height = 477
Caption = Caption =
'Charge Manager 2010 --- (c)2003 by Markus Birth <mbirth@webwrite' + 'Charge Manager 2010 --- (c)2003 by Markus Birth <mbirth@webwrite' +
@ -185,46 +185,163 @@ object Form1: TForm1
Height = 73 Height = 73
Caption = 'COM Status' Caption = 'COM Status'
TabOrder = 2 TabOrder = 2
object L_CTS: TLabel
Left = 8
Top = 20
Width = 44
Height = 13
Caption = 'CTS high'
Enabled = False
end
object L_DSR: TLabel
Left = 8
Top = 36
Width = 46
Height = 13
Caption = 'DSR high'
Enabled = False
end
object L_RLSD: TLabel
Left = 8
Top = 52
Width = 52
Height = 13
Caption = 'RLSD high'
Enabled = False
end
object Label1: TLabel object Label1: TLabel
Left = 72 Left = 30
Top = 24 Top = 16
Width = 101 Width = 71
Height = 13 Height = 13
Caption = 'Last event character:' Caption = 'Last character:'
end end
object L_Time: TLabel object L_Time: TLabel
Left = 80 Left = 110
Top = 40 Top = 16
Width = 73 Width = 73
Height = 13 Height = 13
Alignment = taCenter
AutoSize = False AutoSize = False
Caption = 'hh:mm:ss' Caption = 'hh:mm:ss'
end end
object ComLed1: TComLed
Left = 0
Top = 32
Width = 25
Height = 25
ComPort = ComPort
LedSignal = lsConn
Kind = lkYellowLight
end
object ComLed2: TComLed
Left = 24
Top = 32
Width = 25
Height = 25
ComPort = ComPort
LedSignal = lsCTS
Kind = lkBlueLight
end
object ComLed3: TComLed
Left = 48
Top = 32
Width = 25
Height = 25
ComPort = ComPort
LedSignal = lsDSR
Kind = lkRedLight
end
object ComLed4: TComLed
Left = 88
Top = 32
Width = 25
Height = 25
ComPort = ComPort
LedSignal = lsRing
Kind = lkPurpleLight
end
object ComLed5: TComLed
Left = 112
Top = 32
Width = 25
Height = 25
ComPort = ComPort
LedSignal = lsRLSD
Kind = lkRedLight
end
object ComLed6: TComLed
Left = 144
Top = 32
Width = 25
Height = 25
ComPort = ComPort
LedSignal = lsRx
Kind = lkGreenLight
end
object ComLed7: TComLed
Left = 160
Top = 32
Width = 25
Height = 25
ComPort = ComPort
LedSignal = lsTx
Kind = lkRedLight
end
object Label14: TLabel
Left = 150
Top = 54
Width = 13
Height = 13
Caption = 'Rx'
end
object Label15: TLabel
Left = 167
Top = 54
Width = 12
Height = 13
Caption = 'Tx'
end
object Label16: TLabel
Left = 114
Top = 56
Width = 21
Height = 10
Caption = 'RLSD'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -8
Font.Name = 'Small Fonts'
Font.Style = []
ParentFont = False
end
object Label17: TLabel
Left = 92
Top = 56
Width = 17
Height = 10
Caption = 'Ring'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -8
Font.Name = 'Small Fonts'
Font.Style = []
ParentFont = False
end
object Label18: TLabel
Left = 52
Top = 56
Width = 17
Height = 10
Caption = 'DSR'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -8
Font.Name = 'Small Fonts'
Font.Style = []
ParentFont = False
end
object Label19: TLabel
Left = 28
Top = 56
Width = 16
Height = 10
Caption = 'CTS'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -8
Font.Name = 'Small Fonts'
Font.Style = []
ParentFont = False
end
object Label20: TLabel
Left = 3
Top = 56
Width = 19
Height = 10
Caption = 'Conn'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -8
Font.Name = 'Small Fonts'
Font.Style = []
ParentFont = False
end
end end
object Edit1: TEdit object Edit1: TEdit
Left = 64 Left = 64
@ -333,7 +450,7 @@ object Form1: TForm1
object StatusBar: TStatusBar object StatusBar: TStatusBar
Left = 0 Left = 0
Top = 431 Top = 431
Width = 713 Width = 708
Height = 19 Height = 19
Panels = <> Panels = <>
SimplePanel = True SimplePanel = True
@ -474,6 +591,38 @@ object Form1: TForm1
OnChange = GraphDelayCtrlChange OnChange = GraphDelayCtrlChange
OnKeyDown = GraphDelayCtrlKeyDown OnKeyDown = GraphDelayCtrlKeyDown
end end
object PB_1: TProgressBar
Left = 344
Top = 176
Width = 49
Height = 8
Smooth = True
TabOrder = 24
end
object PB_2: TProgressBar
Left = 344
Top = 248
Width = 49
Height = 8
Smooth = True
TabOrder = 25
end
object PB_3: TProgressBar
Left = 544
Top = 176
Width = 49
Height = 8
Smooth = True
TabOrder = 26
end
object PB_4: TProgressBar
Left = 544
Top = 248
Width = 49
Height = 8
Smooth = True
TabOrder = 27
end
object ColorDialog: TColorDialog object ColorDialog: TColorDialog
Left = 664 Left = 664
Top = 112 Top = 112
@ -501,9 +650,6 @@ object Form1: TForm1
OnAfterOpen = ComPortAfterOpen OnAfterOpen = ComPortAfterOpen
OnAfterClose = ComPortAfterClose OnAfterClose = ComPortAfterClose
OnRxChar = ComPortRxChar OnRxChar = ComPortRxChar
OnCTSChange = ComPortCTSChange
OnDSRChange = ComPortDSRChange
OnRLSDChange = ComPortRLSDChange
OnRxFlag = ComPortRxFlag OnRxFlag = ComPortRxFlag
Left = 160 Left = 160
Top = 120 Top = 120

View File

@ -4,16 +4,13 @@ interface
uses uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, CPort, ComCtrls, IniFiles; Dialogs, ExtCtrls, StdCtrls, CPort, ComCtrls, IniFiles, CPortCtl, DateUtils;
type type
TForm1 = class(TForm) TForm1 = class(TForm)
COMSettings: TButton; COMSettings: TButton;
MultiButt: TButton; MultiButt: TButton;
GroupBox1: TGroupBox; GroupBox1: TGroupBox;
L_CTS: TLabel;
L_DSR: TLabel;
L_RLSD: TLabel;
Label1: TLabel; Label1: TLabel;
L_Time: TLabel; L_Time: TLabel;
Edit1: TEdit; Edit1: TEdit;
@ -57,14 +54,29 @@ type
Label13: TLabel; Label13: TLabel;
DelayTimer: TTimer; DelayTimer: TTimer;
ComPort: TComPort; ComPort: TComPort;
PB_1: TProgressBar;
PB_2: TProgressBar;
PB_3: TProgressBar;
PB_4: TProgressBar;
ComLed1: TComLed;
ComLed2: TComLed;
ComLed3: TComLed;
ComLed4: TComLed;
ComLed5: TComLed;
ComLed6: TComLed;
ComLed7: TComLed;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
Label20: TLabel;
procedure COMSettingsClick(Sender: TObject); procedure COMSettingsClick(Sender: TObject);
procedure MultiButtClick(Sender: TObject); procedure MultiButtClick(Sender: TObject);
procedure ComPortAfterOpen(Sender: TObject); procedure ComPortAfterOpen(Sender: TObject);
procedure ComPortAfterClose(Sender: TObject); procedure ComPortAfterClose(Sender: TObject);
procedure ComPortRxChar(Sender: TObject; Count: Integer); procedure ComPortRxChar(Sender: TObject; Count: Integer);
procedure ComPortCTSChange(Sender: TObject; OnOff: Boolean);
procedure ComPortDSRChange(Sender: TObject; OnOff: Boolean);
procedure ComPortRLSDChange(Sender: TObject; OnOff: Boolean);
procedure ComPortRxFlag(Sender: TObject); procedure ComPortRxFlag(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
@ -95,11 +107,15 @@ implementation
{$R *.dfm} {$R *.dfm}
type
TRecords = array[1..4]of String[34];
TBuf = array[0..33] of char;
const const
CRLF: string = Chr(13) + Chr(10); CRLF: string = Chr(13) + Chr(10);
var var
Slot: array[1..4] of String[34]; Slot: TRecords;
GraphPos: array[1..4,1..2] of byte; GraphPos: array[1..4,1..2] of byte;
GraphCol: array[1..4] of TColor; GraphCol: array[1..4] of TColor;
GraphDelay: integer = 60; GraphDelay: integer = 60;
@ -109,6 +125,7 @@ var
LSlot: byte = 1; LSlot: byte = 1;
Logging: boolean = false; Logging: boolean = false;
LastEvent: TDateTime = 0; LastEvent: TDateTime = 0;
f1,f2,f3,f4: file of byte;
procedure TForm1.COMSettingsClick(Sender: TObject); procedure TForm1.COMSettingsClick(Sender: TObject);
begin begin
@ -183,6 +200,43 @@ begin
GetMinutes := Ord(Slot[s][7]); GetMinutes := Ord(Slot[s][7]);
end; end;
function GetProgress(s: byte): byte;
begin
Result := 0;
if (ShowHex(Ord(Slot[s][3]))[2]<>'0') then begin
case ShowHex(Ord(Slot[s][2]))[2] of
'8': case ShowHex(Ord(Slot[s][3]))[2] of
'5': Result := 50;
'7','8': Result := 100;
end;
'9': case ShowHex(Ord(Slot[s][3]))[2] of
'6': Result := 50;
'7','8': Result := 100;
end;
'a': case ShowHex(Ord(Slot[s][3]))[2] of
'4': Result := 33;
'5': Result := 66;
'7','8': Result := 100;
end;
'b': case ShowHex(Ord(Slot[s][3]))[2] of
'3': Result := 25;
'4': Result := 50;
'5': Result := 75;
'7','8': Result := 100;
end;
'c': case ShowHex(Ord(Slot[s][3]))[2] of
'1': Result := 16;
'2': Result := 33;
'3': Result := 50;
'4': Result := 66;
'5': Result := 83;
'7','8': Result := 100;
end;
'd','e','f': Result := 100;
end;
end else Result := 0;
end;
function FormatCaps(c: dword): string; function FormatCaps(c: dword): string;
var t: string; var t: string;
begin begin
@ -428,6 +482,37 @@ begin
end; end;
end; end;
function MakeBuf(s: integer): TBuf;
var i: integer;
begin
for i:=1 to 34 do Result[i-1] := Slot[s][i];
end;
procedure DoLog(s: byte);
var Buf: TBuf;
begin
with Form1 do begin
case s of
1: if L1.Checked then begin
Buf := MakeBuf(1);
BlockWrite(f1,Buf,34);
end;
2: if L2.Checked then begin
Buf := MakeBuf(2);
BlockWrite(f2,Buf,34);
end;
3: if L3.Checked then begin
Buf := MakeBuf(3);
BlockWrite(f3,Buf,34);
end;
4: if L4.Checked then begin
Buf := MakeBuf(4);
BlockWrite(f4,Buf,34);
end;
end;
end;
end;
procedure GraphClear(Image: TImage); procedure GraphClear(Image: TImage);
const linespace: integer = 50; // horizontal helping lines (50 = 0,5V) const linespace: integer = 50; // horizontal helping lines (50 = 0,5V)
minspace: integer = 30; // vertical helping lines (30 = 30min) minspace: integer = 30; // vertical helping lines (30 = 30min)
@ -542,14 +627,34 @@ begin
LastEvent := now; LastEvent := now;
// Sync := ''; // Sync := '';
end; end;
case LSlot of
1: begin
Edit1.Text := BuildHex(Slot[1]);
DoDisplay(1, D_1);
PB_1.Position := GetProgress(1);
DoLog(1);
end;
2: begin
Edit2.Text := BuildHex(Slot[2]);
DoDisplay(2, D_2);
PB_2.Position := GetProgress(2);
DoLog(2);
end;
3: begin
Edit3.Text := BuildHex(Slot[3]);
DoDisplay(3, D_3);
PB_3.Position := GetProgress(3);
DoLog(3);
end;
4: begin
Edit4.Text := BuildHex(Slot[4]);
DoDisplay(4, D_4);
PB_4.Position := GetProgress(4);
DoLog(4);
end;
end;
Inc(LSlot); Inc(LSlot);
if LSlot>4 then LSlot := 1; if LSlot>4 then LSlot := 1;
case LSlot of
1: R_1.Checked := true;
2: R_2.Checked := true;
3: R_3.Checked := true;
4: R_4.Checked := true;
end;
if (LSlot=1) AND (GraphTime>=GraphDelay) then begin if (LSlot=1) AND (GraphTime>=GraphDelay) then begin
DoGraphDisp(Image1, 1); DoGraphDisp(Image1, 1);
DoGraphDisp(Image1, 2); DoGraphDisp(Image1, 2);
@ -557,34 +662,19 @@ begin
DoGraphDisp(Image1, 4); DoGraphDisp(Image1, 4);
GraphTime := 0; GraphTime := 0;
end; end;
if (LSlot=1) then Inc(GraphTime); if (LSlot=1) then begin
end; Inc(GraphTime);
end;
Edit1.Text := BuildHex(Slot[1]);
DoDisplay(1, D_1);
Edit2.Text := BuildHex(Slot[2]);
DoDisplay(2, D_2);
Edit3.Text := BuildHex(Slot[3]);
DoDisplay(3, D_3);
Edit4.Text := BuildHex(Slot[4]);
DoDisplay(4, D_4);
DoStatDisp(D_Stat); DoStatDisp(D_Stat);
end; end;
case LSlot of
1: R_1.Checked := true;
2: R_2.Checked := true;
3: R_3.Checked := true;
4: R_4.Checked := true;
end;
end; end;
procedure TForm1.ComPortCTSChange(Sender: TObject; OnOff: Boolean);
begin
L_CTS.Enabled := OnOff;
end; end;
procedure TForm1.ComPortDSRChange(Sender: TObject; OnOff: Boolean);
begin
L_DSR.Enabled := OnOff;
end; end;
procedure TForm1.ComPortRLSDChange(Sender: TObject; OnOff: Boolean);
begin
L_RLSD.Enabled := OnOff;
end; end;
procedure TForm1.ComPortRxFlag(Sender: TObject); procedure TForm1.ComPortRxFlag(Sender: TObject);
@ -688,24 +778,66 @@ begin
Form1.LogButton.Caption := 'Start logging'; Form1.LogButton.Caption := 'Start logging';
end; end;
function GetDateTimeString(): string;
var y,m,d,h,i,s,ms: word;
begin
DecodeDateTime(now,y,m,d,h,i,s,ms);
Result := '';
Result := Result + IntToStr(y);
if (m<10) then Result := Result + '0';
Result := Result + IntToStr(m);
if (d<10) then Result := Result + '0';
Result := Result + IntToStr(d);
if (h<10) then Result := Result + '0';
Result := Result + IntToStr(h);
if (i<10) then Result := Result + '0';
Result := Result + IntToStr(i);
if (s<10) then Result := Result + '0';
Result := Result + IntToStr(s);
end;
procedure TForm1.L1Click(Sender: TObject); procedure TForm1.L1Click(Sender: TObject);
begin begin
StartStopCheck; StartStopCheck;
if (L1.Checked) then begin
AssignFile(f1,'Slot01_'+GetDateTimeString()+'.log');
Rewrite(f1);
end else begin
CloseFile(f1);
end;
end; end;
procedure TForm1.L2Click(Sender: TObject); procedure TForm1.L2Click(Sender: TObject);
begin begin
StartStopCheck; StartStopCheck;
if (L2.Checked) then begin
AssignFile(f2,'Slot02_'+GetDateTimeString()+'.log');
Rewrite(f2);
end else begin
CloseFile(f2);
end;
end; end;
procedure TForm1.L3Click(Sender: TObject); procedure TForm1.L3Click(Sender: TObject);
begin begin
StartStopCheck; StartStopCheck;
if (L3.Checked) then begin
AssignFile(f3,'Slot03_'+GetDateTimeString()+'.log');
Rewrite(f3);
end else begin
CloseFile(f3);
end;
end; end;
procedure TForm1.L4Click(Sender: TObject); procedure TForm1.L4Click(Sender: TObject);
begin begin
StartStopCheck; StartStopCheck;
if (L4.Checked) then begin
AssignFile(f4,'Slot04_'+GetDateTimeString()+'.log');
Rewrite(f4);
end else begin
CloseFile(f4);
end;
end; end;
procedure TForm1.GraphDelayBarChange(Sender: TObject); procedure TForm1.GraphDelayBarChange(Sender: TObject);
@ -740,5 +872,6 @@ begin
end; end;
end; end;
end. end.

View File

@ -115,7 +115,7 @@ AutoIncBuild=1
MajorVer=1 MajorVer=1
MinorVer=0 MinorVer=0
Release=0 Release=0
Build=4 Build=5
Debug=0 Debug=0
PreRelease=1 PreRelease=1
Special=0 Special=0
@ -126,7 +126,7 @@ CodePage=1252
[Version Info Keys] [Version Info Keys]
CompanyName=Markus Birth <mbirth@webwriters.de> CompanyName=Markus Birth <mbirth@webwriters.de>
FileDescription= FileDescription=
FileVersion=1.0.0.4 FileVersion=1.0.0.5
InternalName=CM2010 InternalName=CM2010
LegalCopyright= LegalCopyright=
LegalTrademarks= LegalTrademarks=

View File

@ -7,9 +7,21 @@ Port=COM1
BaudRate=9600 BaudRate=9600
DataBits=8 DataBits=8
StopBits=1 StopBits=1
Parity.Bits=None
FlowControl=Software
Parity=None Parity=None
Parity.Check=0
Parity.Replace=0
Parity.ReplaceChar=0
FlowControl=None
FlowControl.DTR=1
FlowControl.RTS=0
FlowControl.DSRSensitivity=0
FlowControl.OutCTSFlow=0
FlowControl.OutDSRFlow=0
FlowControl.TxContinueOnXoff=0
FlowControl.XoffChar=19
FlowControl.XonChar=17
FlowControl.XonXoffIn=0
FlowControl.XonXoffOut=0
[Slots] [Slots]
1.Color=16711680 1.Color=16711680
@ -17,3 +29,35 @@ Parity=None
3.Color=32768 3.Color=32768
4.Color=16711935 4.Color=16711935
GraphDelay=75 GraphDelay=75
;BELOW HERE IS FOR FUTURE ONLY
[Models]
cm2010="Charge Manager 2010"
cm2020="Charge Manager 2020"
[Model.cm2010]
Slots=4
RecordLength=34
Byte.SlotNo=1
Byte.Disp=2L
Byte.BattType=3H
Byte.Progress=3L
Byte.Counter=5
Byte.Hours=6
Byte.Minutes=7
Byte.Current=14-15
Byte.Voltage=16-17
Byte.CCap=18-20
Byte.DCap=21-23
Byte.Resi=33-34
[Model.cm2020]
Slots=10
RecordLength=22
Byte.SlotNo=1
Byte.Disp=4L
Byte.Progress=5L
Byte.CCap=6-8
Byte.DCap=9-11
Byte.