我不能得到一个'Velleman零件号VM116'来跟我的DMX灯说话

时间:2012-01-20 15:04:15

标签: delphi usb midi light led

各位大家好。

首先,我使用的是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控制编写的软件说的那样。然而,show控制的问题是它限制为7位,这就是我需要这个新设备工作的原因。

TIA

安德鲁

2 个答案:

答案 0 :(得分:3)

  1. 您应该使用Destroy; override;代替demolish(以便能够呼叫can.Free)。

  2. 您是否尝试使用cdecl代替stdcall

  3. 我怀疑调用dmx_class.finish = StopDevice会停止设备 - 因此您需要在退出应用程序之前等待某些事情发生:可能设备已关闭太快以至于您看不到它正常工作。

答案 1 :(得分:0)

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