-2

大家好。

首先,我使用的是 Delphi 7,计算机通过 USB 端口连接到“Velleman 零件编号 VM116”,并且我有两个 DMX LED 灯连接到控制器的 DMX 输出。

我已将 K8062d.dll 库与可执行文件放在同一个文件夹中,但我还没有接近让灯响应。困难在于它应该像馅饼一样简单,考虑到我不得不让我的 24 通道照明台来控制我的灯的麻烦,这个控制器应该就像把一个形状放到一个表格上一样简单。

无论如何,这是示例代码...

unit chaser_control;

interface

type
  rgb=(
    c_red,
    c_green,
    c_blue);

  dmx_offset:array[rgb] of integer=(
    1,
    2,
    3);

  dmx_class=class(tobject)

    constructor create;
    destructor demolish;

    procedure initialise;
    procedure finish;

    procedure set_channel(
      can_dmx:integer;
      channel:rgb;
      c:integer);

  end;

var
  can:dmx_class;

implementation

// these four external procedures are all that is necessary to address and
// write to any of the 512 DMX channels in the chain

procedure StartDevice; stdcall; external 'K8062d.dll';
procedure SetData(Channel: Longint ; Data: Longint); stdcall; external 'K8062d.dll';
procedure SetChannelCount(Count: Longint); stdcall; external 'K8062d.dll';
procedure StopDevice; stdcall; external 'K8062d.dll';

  //
  // dmx control
  //

constructor dmx_class.create;
begin
  inherited;

  // the dmx controller is started once when this class is instantiated
  initialise;
end;

destructor dmx_class.demolish;
begin
  // the dmx controller is closed down when this class is destroyed
  finish;

  inherited;
end;

procedure dmx_class.initialise;
begin
  // call the device DLL
  StartDevice;

  // allocate 5 channels for led can [two channels are not used]
  SetChannelCount(5);

  // make sure that channel 1 is set to zero [i never use this channel, 
  // on the lighting desk it is set to zero]
  SetData(1,0);
end;

procedure dmx_class.finish;
begin
  // this procedure is called once

  StopDevice;
end;

  //
  // can control
  //

procedure dmx_class.set_channel(
  can_dmx:integer;
  channel:rgb;
  c:integer);
var
  l1,l2:longint;
begin
  // l1 and l2 are longint variables as the arguments passed to the 
  // DLL are longint even though the data is actually 8 bit

  l1:=can_dmx+dmx_offset[channel];
  l2:=c;
  SetData(l1,l2);
end;

begin
  // example call to change the green channel on a can with dmx address 1
  // simply assume that 'can' is not created automatically at startup
  can:=dmx_class.create;
  can.set_channel(1,c_green,240);
  // and so on
  can.free;
end.

当绿色通道设置为 240 时,没有任何反应,灯光很好,因为它们可以从灯光台控制,就像我说的那样,我也使用 MIDI 显示控制编写的其他软件。然而,显示控制的问题在于它仅限于 7 位,这就是我需要这个新设备工作的原因。

TIA

安德鲁

4

2 回答 2

3
  1. 您应该使用Destroy; override;而不是demolish(以便能够调用can.Free)。

  2. 你试过用cdecl代替stdcall吗?

  3. 我怀疑调用dmx_class.finish = StopDevice会停止设备 - 所以你需要在退出应用程序之前等待某些事情发生:也许设备关闭得太快以至于你看不到它工作。

于 2012-01-20T15:22:38.263 回答
0

好的,我从 Velleman 那里得到了答案,您还必须在与您的应用程序相同的文件夹中包含 K8062e.exe 和 FASTTime32.dll 以及 K8062D.dll。安德鲁

于 2014-02-24T18:24:52.743 回答