Autor Beitrag
tobkin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Di 18.10.11 08:53 
Servus @All,

ich bin dabei einen Encoder von Phidgets zu testen. Sie stellen auf der HP auch Ressourcen zu allen möglichen Sprachen zur Verfügung.
Leider funktioniert es aber nicht, und ich bekomme zu allen aufrufen die auf die Phidget21COM_TLB zugreifen den Fehler E2018.
Woran kann dieses liegen?
mfg
Tobias




Quelltext:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
unit Encoder;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, OleCtrls, Phidget21COM_TLB, ComCtrls, ComObj, ActiveX;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label4: TLabel;
    TrackBar1: TTrackBar;
    procedure PhidgetEncoderPositionChange(ASender: TObject; Index, Time,
      EncoderDisplacement: Integer);
    procedure PhidgetEncoderDetach(Sender: TObject);
    procedure PhidgetEncoderAttach(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  TrackBar1.Frequency := 50;
  TrackBar1.Min := -1000;
  TrackBar1.Max := 1000;
  Label2.Caption := 'Unattached';
  Label4.Caption := '';
  PhidgetEncoder.Open(-1);
  PhidgetEncoder.WaitForAttachment(3000);

end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  PhidgetEncoder.Enabled[0] := False;
  PhidgetEncoder.Close;

end;

procedure TForm1.PhidgetEncoderAttach(Sender: TObject);
begin
  Label2.Caption := 'Attached';
  PhidgetEncoder.Enabled[0] := True;
  PhidgetEncoder.EncoderPosition[0] := 0;
  TrackBar1.Position := 0;
end;

procedure TForm1.PhidgetEncoderDetach(Sender: TObject);
begin
  Label2.Caption := 'Unattached';
end;

procedure TForm1.PhidgetEncoderPositionChange(ASender: TObject; Index, Time,
  EncoderDisplacement: Integer);
begin
  TrackBar1.Position := TrackBar1.Position + EncoderDisplacement;
  Label4.Caption := IntToStr(PhidgetEncoder.EncoderPosition[0]);
end;

end.


Moderiert von user profile iconMartok: Delphi-Tags hinzugefügt
Einloggen, um Attachments anzusehen!
Horschdware
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 744
Erhaltene Danke: 54

Win XP Pro, Win 7 Pro x64
Delphi 7, Delphi XE, C++ Builder 5, SAP R/3
BeitragVerfasst: Di 18.10.11 09:10 
Ich würde sagen, du musst auch eine Instanz dieses Encoders anlegen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
interface
type TForm1 = class(TForm)
  private
    PhidgetEncoder : TPhidgetEncoder;
  ...

end;
...

implementation
procedure TForm1.FormCreate(Sender: TObject);
begin
  TrackBar1.Frequency := 50;
  TrackBar1.Min := -1000;
  TrackBar1.Max := 1000;
  Label2.Caption := 'Unattached';
  Label4.Caption := '';
  PhidgetEncoder := TPhidgetEncoder.Create(...);
  PhidgetEncoder.Open(-1);
  PhidgetEncoder.WaitForAttachment(3000);

end;


PS: Freigeben nicht vergessen
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Destroy;
begin
  PhidgetEncoder.free;
end;

_________________
Delphi: XE - OS: Windows 7 Professional x64
tobkin Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Di 18.10.11 10:57 
Servus,

danke die folgende Zeile war es.

user profile iconHorschdware hat folgendes geschrieben Zum zitierten Posting springen:
Ich würde sagen, du musst auch eine Instanz dieses Encoders anlegen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
interface
type TForm1 = class(TForm)
  private
    PhidgetEncoder : TPhidgetEncoder;



Jetzt habe ich das nächste Problem, er öffnet das Gerät "Hardwaremässig" nicht, d.H. ich hänge mit einer Zugriffverletzung.

Da schaue ich aber jetzt ersteinmal wieder selber.

Danke vorerst.
Tobias

Moderiert von user profile iconNarses: Beiträge zusammengefasst.

Bin etwas weiter...

Es scheint als ob das ActiveX Object nicht "gestartet" ist.

Aber was genau meinen Sie mit diesem Test:

Zitat:

Before you can use the Phidget, you must declare and initialize its ActiveX object. The simplest
method is to place the control from the ActiveX component tab on to your form. For this tutorial,
create a PhidgetInterfaceKit control (PhidgetInterfaceKit1) and then add a text edit field to the form
for the purpose of capturing simple output.


Stehe gerade etwas auf dem Schlauch.

Gruß
Tobias