Filtering received Data : only One

Started by abak, April 14, 2025, 02:15:37 PM

Previous topic - Next topic

abak

Good morning Experts,

I have an electronic scale connected to the PC via RS232. I managed to retrieve Data like described on the Demo
C:\ProgramData\nrCommLib\Demos\Signals

I receive three variables on a Memo (Terminal) permanently :  Price, Weight, and Total.
How do I filter the data to only receive only one variable (Weight) on the Memo?

Thank you.

Roman Novgorodov

Hello

Please show the sample of data flow.
Better if you will try Demos\Codes\codes_demo.dpr project.

It shows real values (byte codes) of incoming data.

Roman Novgordov
DeepSoftware
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

abak

#2
Thank you Roman,


1- With Demos\Codes\signals_demo.dpr,  I get Data like this :
0.00
0/ kg
0.305kg

and its repeat permanently (in Memo1 = Terminal) :
0.00
0/ kg
0.305kg
0.00
0/ kg
0.305kg
0.00
0/ kg
0.305kg


2- With Demos\Signals\codes_demo.dpr,  I get Data like this (a little wacky) :
 
  0.30  0.00

  0/ kg5kg
 
  0.30  0.00

  0/ kg5kg
 
  0.30  0.00
  0/ kg

  0.305kg
  Memo1
รพ  0.00
254 32 32 32 48 46 48 48 13 10 32 32 32 48 46 51 48 53 107 103 13 10 32 32 32 32 32 32 48 47 32 107 103 13 10 32 32 32 48 46 48 48 13 10 32 32 32 48 46 51 48 53 107 103 13 10 32 32 32 32 32 32 48 47 32 107 103 13 10 32 32 32 48 46 48 48 13 10 32 32 32 48 46 51 48 53 107 103 13 10 32 32 32 32 32 32 48 47 32 107 103 13 10 32


3- So, i prefered the first project : signals_demo.dpr
as i can threat the Strings and get only the weight :  xxx/kg
After that, I will clear the Memo1.Clear.

Done.
Many Thx.

__________

Here is my Threatment function :

function fct_ Weight(List:TStrings):Single;
var L:TStringList;
    i:byte;
    ch:string;

/* Terminal Memo1 contain 3 variables :
/* 0.00
/* 1.250Kg
/* 0.00 / Kg

begin
  ch:='0';

  L:=TStringList.Create;
  try
    L.AddStrings(List);

    if L.Count>0 then
    begin
      for i := 0 to L.Count-1 do
      begin

        /*1. Exclude the Price : 0.00 / Kg
        if Pos('/',L[i])<>0 then continue

        /*2. Exclure Total :  0.00
        else if (Pos('kg',L[i])=0) and
            (Pos('KG',L[i])=0) and
            (Pos('Kg',L[i])=0) then continue

         else
         begin
          ch:=L[i];
          break;
         end;
       end;

     end;


  finally
    L.Free;
  end;

  /*Keep only numbers :  Delete Kg
  UTraitementChaine.TraitementChaineNumerique(ch);
  result:=StrToFloat(ch);

end;