![]() |
Re: Bit Operations (Bit in HEX)
Liste der Anhänge anzeigen (Anzahl: 1)
Hmm. Wenn Du willst kannst Du ja die neuste Release näher anschauen.
Ich hab mal das Test.d2v-file mit meiner Routine bis Zeile 16 gescannt. Der erste Wert ist der HEX-Wert, den ich parse. HEXTOINT ist der gleiche Wert umgewandelt in Integer. Danach zurück zu String.
Code:
Zum Vergleichen verwende ich:
Bit1 - HEX: 92 HEXTOINT: 146 INTTOSTR: 2
Bit6 - HEX: f2 HEXTOINT: 242 INTTOSTR: 64 Bit1 - HEX: f2 HEXTOINT: 242 INTTOSTR: 2 Bit6 - HEX: e2 HEXTOINT: 226 INTTOSTR: 64 Bit1 - HEX: e2 HEXTOINT: 226 INTTOSTR: 2 Bit6 - HEX: f2 HEXTOINT: 242 INTTOSTR: 64 Bit1 - HEX: f2 HEXTOINT: 242 INTTOSTR: 2 Bit6 - HEX: f2 HEXTOINT: 242 INTTOSTR: 64 Bit1 - HEX: f2 HEXTOINT: 242 INTTOSTR: 2 Bit6 - HEX: e2 HEXTOINT: 226 INTTOSTR: 64 Bit1 - HEX: e2 HEXTOINT: 226 INTTOSTR: 2 Bit6 - HEX: f2 HEXTOINT: 242 INTTOSTR: 64 Bit1 - HEX: f2 HEXTOINT: 242 INTTOSTR: 2 Bit6 - HEX: f2 HEXTOINT: 242 INTTOSTR: 64 Bit1 - HEX: f2 HEXTOINT: 242 INTTOSTR: 2 Bit6 - HEX: e2 HEXTOINT: 226 INTTOSTR: 64 Bit1 - HEX: e2 HEXTOINT: 226 INTTOSTR: 2 Bit6 - HEX: f2 HEXTOINT: 242 INTTOSTR: 64 Bit1 - HEX: f2 HEXTOINT: 242 INTTOSTR: 2 Bit6 - HEX: f2 HEXTOINT: 242 INTTOSTR: 64 Bit1 - HEX: f2 HEXTOINT: 242 INTTOSTR: 2 Bit6 - HEX: e2 HEXTOINT: 226 INTTOSTR: 64 Bit1 - HEX: e2 HEXTOINT: 226 INTTOSTR: 2 Bit6 - HEX: 72 HEXTOINT: 114 INTTOSTR: 64 Bit1 - HEX: 72 HEXTOINT: 114 INTTOSTR: 2
Delphi-Quellcode:
Ich hoffe ich bin nun auf dem Richtigen Weg.
begin
value:=GetTok(temp, tempi, ' '); if hextoint(value) and $40 > 0 then begin thirtytwo:=thirtytwo+1; memo1.lines.add('Bit6 - HEX: '+value+' HEXTOINT: '+inttostr(hextoint(value))+' INTTOSTR: '+inttostr($40)); end; if hextoint(value) and $02 > 0 then begin wo:=two+1; memo1.lines.add('Bit1 - HEX: '+value+' HEXTOINT: '+inttostr(hextoint(value))+' INTTOSTR: '+inttostr($02)); end; if hextoint(value) and $01 > 0 then begin zero:=zero+1; memo1.lines.add('Bit0 - HEX: '+value+' HEXTOINT: '+inttostr(hextoint(value))+' INTTOSTR: '+inttostr($01)); end; if thirtytwo > 0 then checkbox1.checked:=true else checkbox1.checked:=false; if two > zero then radiobutton1.checked:=true else radiobutton2.checked:=true; if checkbox3.checked=true then if i > strtoint(edit14.text) then exit; end; Hier noch mal ein Test.d2v-file: |
Re: Bit Operations (Bit in HEX)
Ich habe mir deinen Quelltext mal angesehen. Speziell hat mich interessiert, warum du mit meiner Routine CheckLines nicht zurecht kommst. Das liegt daran, dass du die Routine nicht korrekt an deine Bedürfnisse angepasst hattest. Deine Schleifensteuerung ist auch jetzt nicht auf die Verwendung meines Codes abgestimmt. CheckLines verarbeitet alle Zeilen in einem Rutsch. Willst du eine zeilenweise Verarbeitung, dann musst du den Code umbauen. Ich habe dir die Routine mal als FSM an die Testdatei angepasst:
Delphi-Quellcode:
marabu
function CheckLines(lines: TSTrings): Cardinal;
type TState = (stUndefined, stHeader1, stHeader2, stData); var i, j: Integer; s: TStrings; state: TState; begin state := stUndefined; Result := 0; s := TStringList.Create; for i := 0 to Pred(lines.Count) do begin case state of stUndefined: if AnsiStartsText('DGIndex', lines[i]) then Inc(state); stHeader1, stHeader2: if lines[i] = '' then Inc(state); stData: if lines[i] = '' then state := stUndefined else begin s.DelimitedText := lines[i]; for j := 6 to Pred(s.Count) do Result := Result + Ord(TestBit(HexToInt(s[j]), strtoint(form1.Edit15.text))) end; end; end; s.Free; end; |
Re: Bit Operations (Bit in HEX)
Liste der Anhänge anzeigen (Anzahl: 1)
@Marabu:
Ich hab nun Deine modifizierte Function eingebaut. Nun müsste man nur die Auswertung diskutieren. Wenn ich $02 für Bit1 eingebe erhalte ich folgendes Ergebnis: BitX 1 $02 BitX 1 $02 BitX 1 $02 BitX 1 $02 Somit müsste bit1 enthalten sein. Auch bei bit6 mit $40 kommt das gleiche Ergebnis: BitX 1 $40 BitX 1 $40 BitX 1 $40 BitX 1 $40 Nur bei bit0 was RFF simbolisiert kommt ein anderes: BitX 3173 $01 BitX 3173 $01 BitX 3173 $01 BitX 3173 $01 also müsste der Wert 3173 falsch sein. bei $64 käme z.B. folgendes raus: BitX 2380 $64 BitX 2380 $64 BitX 2380 $64 BitX 2380 $64 $10 & $08 hingegen lieften folgendes: BitX 0 $10 BitX 0 $10 BitX 0 $10 BitX 0 $10 BitX 0 $08 BitX 0 $08 BitX 0 $08 BitX 0 $08 Eins und Null währen mir klar. 1 für enthalten. 0 für nicht enthalten. Was haben aber die anderen Werte zu sagen? Deine Function hab ich mit folgendem Code ausgeführt:
Delphi-Quellcode:
Ich hab mal Version8 gecodet. Kannst Du nochmal einen abschließend Blick drauf werfen? Deine Routine ist echt schneller als meine ;)begin Application.ProcessMessages; thirtytwo2 := CheckLines(memo.lines); Progressbar1.position:=i; memo1.lines.add('BitX '+inttostr(thirtytwo2)+' '+edit15.text); end |
Re: Bit Operations (Bit in HEX)
Um Missverständnissen vorzubeugen: mein Code ist nicht auf Performanz ausgelegt - Tuning für das Verarbeiten großer Datenmengen steht da gewiss noch aus. 1 und 0 stehen gewiss nicht für vorhanden und nicht vorhanden, sondern sind Zähler für das Vorkommen eines bestimmten Bits in einem Datenabschnitt. Wie kommt es zur Ausgabe von BitX 1 $02 viermal hintereinander? Liegt das immer noch an deinem Rahmenprogramm, welches nicht auf die Verwendung von CheckLines() ausgelegt war? Oder hast du eine Datei mit vier DGIndex-Abschnitten? Die Ausgabe BitX 3173 $01 hat die Bedeutung Bit 0 war im entsprechenden Datenabschnitt 3173-mal gesetzt.
marabu |
Re: Bit Operations (Bit in HEX)
@marabu: Dann müsste ich es ja total anders auslesen.
Einen den ich kenne hat folgendes geschrieben: Zitat:
|
Re: Bit Operations (Bit in HEX)
Liste der Anhänge anzeigen (Anzahl: 1)
Delphi-Quellcode:
Ich hab mal die marabu routine angepasst. Nun kommen andere Werte raus, da er nun auch die Bit0 zählt. Laut DGIndex ist das D2V aber TFF und nicht BFF.
{D2VParse v8
forty2 :=0; forty2 := CheckLines(memo.lines,$40); if forty2=1 then begin forty:=forty+1; memo1.lines.add('Bit6 found - '+inttostr(forty)); end; forty2 :=0; forty2 := CheckLines(memo.lines,$02); if forty2=1 then begin two:=two+1; memo1.lines.add('Bit2 found - '+inttostr(two)); end; forty2 :=0; forty2 := CheckLines(memo.lines,$01); if forty2=1 then begin zero:=zero+1; memo1.lines.add('Bit0 found - '+inttostr(zero)); end; D2VParse v9} forty2 :=0; forty2 := CheckLines(memo.lines,$40); if forty2>0 then begin forty:=forty+forty2; memo1.lines.add('Bit6 found - '+inttostr(forty)); end; forty2 :=0; forty2 := CheckLines(memo.lines,$02); if forty2>0 then begin two:=two+forty2; memo1.lines.add('Bit1 found - '+inttostr(two)); end; forty2 :=0; forty2 := CheckLines(memo.lines,$01); if forty2>0 then begin zero:=zero+forty2; memo1.lines.add('Bit0 found - '+inttostr(zero)); end; ![]() |
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:57 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz