Jump to content
View in the app

A better way to browse. Learn more.

Tinkerunity

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Geschrieben

Moin aus Hamburg.

 

Ich habe folgendes Problem :

 

ich erstelle Objekte vom Typ TBrickMaster, TBrickAnalogOut, AnalogIn ... im Ereignis On Create des Formulars

var
  HOST : String;
  PORT : Word;
  EnumBrick : array[1..128] of TEnumerateB;
  EnumCount : Word;
  ipcon : TIPConnection;
  ma : array[1..8] of TBrickMaster;
  mb : array[1..8] of TBrickDC;
  aa : array[1..8] of TBrickletAnalogIn;
  ab : array[1..8] of TBrickletAnalogInV2;
  ac : array[1..8] of TBrickletAnalogOut;
  ad : array[1..8] of TBrickletAnalogOutV2;
  ae : array[1..8] of TBrickletIndustrialDual020mA;
  da : array[1..8] of TBrickletIO4;
  db : array[1..8] of TBrickletIO16;

procedure TfrmMain.FormCreate(Sender: TObject);
var
  i : Integer;
begin
  frmMain.ClientWidth := 1008;
  frmMain.ClientHeight := 730;
  Log := TStringList.Create;
  Log.Add(DateTimeToStr(Now) + ' Programm started');
  HOST := 'localhost';
  PORT := 4223;
  EnumCount := 0;

  ipcon := TIPConnection.Create;

  ma[1] := TBrickMaster.Create('6qY3SC', ipcon);
  ma[2] := TBrickMaster.Create('6JKRPw', ipcon);

  ab[1] := TBrickletAnalogInV2.Create('vfA', ipcon);
  ac[1] := TBrickletAnalogOut.Create('hPy', ipcon);
  ac[2] := TBrickletAnalogOut.Create('ikS', ipcon);
  ad[1] := TBrickletAnalogOutV2.Create('vn2', ipcon);
  ae[1] := TBrickletIndustrialDual020mA.Create('saE', ipcon);
  db[1] := TBrickletIO16.Create('snY', ipcon);

  ipcon.Connect('localhost', 4223);

 

soweit so gut.

 

Im Ereignis OnClose setze ich einige Einstellungen zurück und gebe die

Objekte wieder frei :

 

procedure TfrmMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  SetIO16PortsToZero(1); // alle Ausgänge auf HIGH
  SetAnalogesToZero; // Analog Ausgänge auf 0V
  
  ab[1].Free;
  ac[2].Free;
  ac[1].Free;
  ad[1].Free;
  ae[1].Free;
  db[1].Free;
  ma[2].Free;
  ma[1].Free;

  Delay(100);
  ipcon.Destroy;
  Delay(100);
  Log.Free;
end;

 

dies funktioniert auch einwandfrei, solange ich von einem Bricklet-Typ

nur ein Objekt erzeuge. benutze ich zwei Objekte vom z.B. Typ

TBrickletAnalogOut

gibt's eine Exception bei der Freigabe bzw. Destroy von ipcon

an folgender Stelle :

 

Unit IPConnection

procedure TIPConnection.Disconnect;
var callback_: PCallbackContext; meta: TByteArray;
begin
  callback_ := nil;
  socketMutex.Acquire;
  try
    autoReconnectAllowed := false;
    if (autoReconnectPending) then begin
      { Abort pending auto-reconnect }
      autoReconnectPending := false;
    end
    else begin
      if (not IsConnected) then begin
        raise ENotConnectedException.Create('Not connected');
      end;
      DisconnectUnlocked;
      SetLength(pendingData, 0);
    end;
    { Destroy callback thread }
    callback_ := callback;
    callback := nil;
  finally
    socketMutex.Release;
  end;
  if (callback_ <> nil) then begin
    { Do this outside of socketMutex to allow calling (dis-)connect from
      the callbacks while blocking on the WaitFor call here }
    SetLength(meta, 2);
    meta[0] := IPCON_CALLBACK_DISCONNECTED;
    meta[1] := IPCON_DISCONNECT_REASON_REQUEST;
    callback_^.queue.Enqueue(IPCON_QUEUE_KIND_META, meta);
    if (not callback_^.thread.IsCurrent) then begin
      callback_^.queue.Enqueue(IPCON_QUEUE_KIND_EXIT, nil);
      callback_^.thread.WaitFor;
      callback_^.thread.Destroy; <-------------- hier tritt der Fehler auf
    end
    else begin
      callback_^.queue.Enqueue(IPCON_QUEUE_KIND_DESTROY_AND_EXIT, nil);
    end;
  end;
end;

 

kennt jemand das Problem bzw. hat eine Lösung ?

 

Geschrieben
  • Autor

jupp, läuft

 

und auch ein ipcon.Disconnect - was eigentlich

vor das ipcon.Destroy gehört - wird akzeptiert.

 

Danke

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.