Jump to content

JusJJ

Members
  • Content Count

    16
  • Joined

  • Last visited

Posts posted by JusJJ


  1. It is an old, huge industrial compressed air system. It is divided into sectors with a total of 42 devices, valves, dryers, coolers etc.
    Some devices automatically go into sleep mode because whole system can only work at full power momentarily. Each device is controlled via an ethernet converter and, since it draws the operating voltage directly from the actuator in question, it is of course not possible to contact it.
    Now, if you need to adjust an individual device to change settings in some sector, it's easier to see directly which devices are in use than to go through them one by one.



  2. I have a reconnection problem in an android application,using Indy TidTcpClient and TIdThreadComponent.
    I've tried both the Delphi bundled and the latest Indy version.

     

    At the beginning, the program goes through the IP addresses of the available devices.

    Read and write routines work without problems, but when you try to change the IP address, almost without exception the program freezes. Sometimes it takes a few seconds, sometimes a few minutes before the program responds and about every ten times the program stops responding completely. In Windows, changing the IP address works reasonably well, but sometimes it also freezes.

     

    Receiving works...:

    try
        StartChar := TCPSocket.IOHandler.ReadChar;
        if StartChar = '%' then
        begin
          Data := TCPSocket.IOHandler.ReadLn('&');
          Payload := Data;
          TCPSocket.IOHandler.ReadBytes(ChecksumBytes, 4);
          ReceivedChecksum := BytesToString(ChecksumBytes);
          CalculatedChecksum := CRC16(Payload);
          if ReceivedChecksum = CalculatedChecksum then
          begin
            TThread.Queue(nil,
              procedure
              var
                i: Integer;
              begin
               HandleData;
              end);
          end
          else
          begin
              TThread.Queue(nil,
              procedure
              begin
               HandleChecksumError;
              end);
          end;
        end;
      except
        on E: Exception do
        begin
          TThread.Queue(nil,
            procedure
            begin
             HandleException;
            end);
          ReceiveThread.Terminate;
    	  end;

    ...but changing IP fails: 

    procedure IpSelectF.IPBtnClick(Sender: TObject);
    Var
      Btn: TButton;
      NewIp: string;
    begin
      if Sender is TButton then
      begin
        Btn := TButton(Sender);
        if AvailableIP[Btn.Tag] then
        begin
          TTask.Run(
            procedure
            begin
              try
                if Assigned(MainF.ReceiveThread) and MainF.ReceiveThread.Active then
                begin
                  MainF.ReceiveThread.Stop;
                  MainF.ReceiveThread.WaitFor;  
                end;
                if MainF.TCPSocket.Connected then
                  MainF.TCPSocket.Disconnect;
                NewIp := '192.168.1.' + IntToStr(Btn.Tag);
                MainF.TCPSocket.Host := NewIp;
                try
                  MainF.TCPSocket.ConnectTimeout := 3000; 
                  MainF.TCPSocket.Connect;
                  if MainF.TCPSocket.Connected then
                  begin
                    TThread.Queue(nil,
                      procedure
                      begin
                        MainF.ReceiveThread.Start;
                        ShowAlertDialog('Connected to ' + NewIp);
                      end
                    );
                  end
                  else
                  begin
                    TThread.Queue(nil,
                      procedure
                      begin
                        ShowAlertDialog('Connection to ' + NewIp + ' failed.');
                      end
                    );
                  end;
                except
                  on E: Exception do
                  begin
                    TThread.Queue(nil,
                      procedure
                      begin
                        ShowAlertDialog('Failed to connect to ' + NewIp + ': ' + E.Message);
                      end
                    );
                  end;
                end;
              except
                on E: Exception do
                begin
                  TThread.Queue(nil,
                    procedure
                    begin
                      ShowAlertDialog('Error during IP switch: ' + E.Message);
                    end
                  );
                end;
              end;
            end
          ); 
        end;
      end;	  

     


  3. Hi,

     

    I have a problem with TGridPanelLayout in android. Instead of spanning 2 cols, TStringgrid span just 1 col. It works perfectly in windows but not in android. Delphi version is 11CE. 


  4. Is it somehow possible to change the background color and remove borders of the (string)grid in FMX?

    I would like to align the data in a 4 x 10 grid but only keep the text visible and hide background and borders.


  5. Hi,

    Is there a way to prevent drawing outside the canvas?
    If, for example, I have a rectangular shape on which I draw an ellipse and I want to limit the drawing to the area of the shape.

    procedure TForm1.shapePaint(Sender: TObject; Canvas: TCanvas;
      const ARect: TRectF);
      var
      x,y :integer;
      circle : TRectF;
    begin
    
        x:=round(shape.Width/2);
        y:=round(shape.Width/2);
    
        circle:=TRectF.Create(x-190,y-190,x+100,y+100);
        shape.Canvas.Stroke.Color:=TAlphaColors.Black;
        shape.Canvas.DrawEllipse(circle,50);
    end;

    Now part of it is also drawn outside the shape.

    form.jpg


  6. Hi,

     

    I haven't used Delphi since version 6 but I thought now to try it again after a long break. So I downloaded community edition but noticed that floating form designer has disappeared.

    I remember it was easy to design a gui in the past but now it is really difficult.

    Is there any way to get a form designer full screen size? 

×