1
0
mirror of https://github.com/mbirth/cm2010.git synced 2024-12-24 03:14: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
Left = 195
Top = 109
Width = 721
Width = 716
Height = 477
Caption =
'Charge Manager 2010 --- (c)2003 by Markus Birth <mbirth@webwrite' +
@ -185,46 +185,163 @@ object Form1: TForm1
Height = 73
Caption = 'COM Status'
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
Left = 72
Top = 24
Width = 101
Left = 30
Top = 16
Width = 71
Height = 13
Caption = 'Last event character:'
Caption = 'Last character:'
end
object L_Time: TLabel
Left = 80
Top = 40
Left = 110
Top = 16
Width = 73
Height = 13
Alignment = taCenter
AutoSize = False
Caption = 'hh:mm:ss'
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
object Edit1: TEdit
Left = 64
@ -333,7 +450,7 @@ object Form1: TForm1
object StatusBar: TStatusBar
Left = 0
Top = 431
Width = 713
Width = 708
Height = 19
Panels = <>
SimplePanel = True
@ -474,6 +591,38 @@ object Form1: TForm1
OnChange = GraphDelayCtrlChange
OnKeyDown = GraphDelayCtrlKeyDown
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
Left = 664
Top = 112
@ -501,9 +650,6 @@ object Form1: TForm1
OnAfterOpen = ComPortAfterOpen
OnAfterClose = ComPortAfterClose
OnRxChar = ComPortRxChar
OnCTSChange = ComPortCTSChange
OnDSRChange = ComPortDSRChange
OnRLSDChange = ComPortRLSDChange
OnRxFlag = ComPortRxFlag
Left = 160
Top = 120

View File

@ -4,16 +4,13 @@ interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, CPort, ComCtrls, IniFiles;
Dialogs, ExtCtrls, StdCtrls, CPort, ComCtrls, IniFiles, CPortCtl, DateUtils;
type
TForm1 = class(TForm)
COMSettings: TButton;
MultiButt: TButton;
GroupBox1: TGroupBox;
L_CTS: TLabel;
L_DSR: TLabel;
L_RLSD: TLabel;
Label1: TLabel;
L_Time: TLabel;
Edit1: TEdit;
@ -57,14 +54,29 @@ type
Label13: TLabel;
DelayTimer: TTimer;
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 MultiButtClick(Sender: TObject);
procedure ComPortAfterOpen(Sender: TObject);
procedure ComPortAfterClose(Sender: TObject);
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 FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
@ -95,11 +107,15 @@ implementation
{$R *.dfm}
type
TRecords = array[1..4]of String[34];
TBuf = array[0..33] of char;
const
CRLF: string = Chr(13) + Chr(10);
var
Slot: array[1..4] of String[34];
Slot: TRecords;
GraphPos: array[1..4,1..2] of byte;
GraphCol: array[1..4] of TColor;
GraphDelay: integer = 60;
@ -109,6 +125,7 @@ var
LSlot: byte = 1;
Logging: boolean = false;
LastEvent: TDateTime = 0;
f1,f2,f3,f4: file of byte;
procedure TForm1.COMSettingsClick(Sender: TObject);
begin
@ -183,6 +200,43 @@ begin
GetMinutes := Ord(Slot[s][7]);
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;
var t: string;
begin
@ -428,6 +482,37 @@ begin
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);
const linespace: integer = 50; // horizontal helping lines (50 = 0,5V)
minspace: integer = 30; // vertical helping lines (30 = 30min)
@ -542,14 +627,34 @@ begin
LastEvent := now;
// Sync := '';
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);
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
DoGraphDisp(Image1, 1);
DoGraphDisp(Image1, 2);
@ -557,36 +662,21 @@ begin
DoGraphDisp(Image1, 4);
GraphTime := 0;
end;
if (LSlot=1) then Inc(GraphTime);
if (LSlot=1) then begin
Inc(GraphTime);
DoStatDisp(D_Stat);
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;
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);
end;
end;
procedure TForm1.ComPortCTSChange(Sender: TObject; OnOff: Boolean);
begin
L_CTS.Enabled := OnOff;
end;
procedure TForm1.ComPortDSRChange(Sender: TObject; OnOff: Boolean);
begin
L_DSR.Enabled := OnOff;
end;
procedure TForm1.ComPortRLSDChange(Sender: TObject; OnOff: Boolean);
begin
L_RLSD.Enabled := OnOff;
end;
procedure TForm1.ComPortRxFlag(Sender: TObject);
begin
L_Time.Caption := TimeToStr(time);
@ -595,7 +685,7 @@ end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if ComPort.Connected then ComPort.Close;
if ComPort.Connected then ComPort.Close;
SaveSettings;
end;
@ -688,24 +778,66 @@ begin
Form1.LogButton.Caption := 'Start logging';
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);
begin
StartStopCheck;
if (L1.Checked) then begin
AssignFile(f1,'Slot01_'+GetDateTimeString()+'.log');
Rewrite(f1);
end else begin
CloseFile(f1);
end;
end;
procedure TForm1.L2Click(Sender: TObject);
begin
StartStopCheck;
if (L2.Checked) then begin
AssignFile(f2,'Slot02_'+GetDateTimeString()+'.log');
Rewrite(f2);
end else begin
CloseFile(f2);
end;
end;
procedure TForm1.L3Click(Sender: TObject);
begin
StartStopCheck;
if (L3.Checked) then begin
AssignFile(f3,'Slot03_'+GetDateTimeString()+'.log');
Rewrite(f3);
end else begin
CloseFile(f3);
end;
end;
procedure TForm1.L4Click(Sender: TObject);
begin
StartStopCheck;
if (L4.Checked) then begin
AssignFile(f4,'Slot04_'+GetDateTimeString()+'.log');
Rewrite(f4);
end else begin
CloseFile(f4);
end;
end;
procedure TForm1.GraphDelayBarChange(Sender: TObject);
@ -740,5 +872,6 @@ begin
end;
end;
end.

View File

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

View File

@ -7,9 +7,21 @@ Port=COM1
BaudRate=9600
DataBits=8
StopBits=1
Parity.Bits=None
FlowControl=Software
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]
1.Color=16711680
@ -17,3 +29,35 @@ Parity=None
3.Color=32768
4.Color=16711935
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.