GUI für DMX-Steuerung (512 Kanäle) dynamisch erstellen

  • Hallo Leute,

    Wie Ihr dem Titel entnehmen könnt habe Ich ein kleines Problem mit der Erstellung der Gui.
    Ich habe mein DMX-Interface zum laufen bekommen, aber nun habe Ich ein Problem.

    Das Interface hat 512 Kanäle.

    Also dachte Ich mir, gut. Mach 32 Slider in eine Gui, Und 16 Buttons um die Slider mit den Kanälen zuzuweißen.
    Nur denke Ich da an die heidenarbeit, das alles in Koda zu machen.

    Könntet ihr mir da irgendwie helfen?
    Ich hätte folgende Idee:

    Spoiler anzeigen

    vllt. hat ja jemand eine Idee :)
    mfg

  • Hi,
    Beispiel mit Buttons, aber das auf Slider auszuweiten solltest du können^^

    Spoiler anzeigen
    [autoit]

    ;by Andy

    [/autoit] [autoit][/autoit] [autoit]

    $numberofbuttons = 24 ;number from 1 to 30
    Dim $buttoncontrolID[$numberofbuttons + 1]

    [/autoit] [autoit][/autoit] [autoit]

    GUICreate("test")
    For $i = 1 To $numberofbuttons ;we make an array of buttons
    $buttoncontrolID[$i] = GUICtrlCreateButton(" Button " & $i, 10 + ((($i > 10) + ($i > 20)) * 100), 30 + ($i - (($i > (($i > 20) + 1) * 10) * (($i > 20) + 1) * 10)) * 30,85,30)
    Next
    $somethingbutton=guictrlcreatebutton("do something ",310,30,80,30 )

    [/autoit] [autoit][/autoit] [autoit]

    ;here you could give the buttons an other text or color
    guictrlsetdata($buttoncontrolID[1] ,"Push!")
    GUICtrlSetColor($buttoncontrolID[1],0xFF00FF)
    guictrlsetdata($buttoncontrolID[13],"Push ME!")
    GUICtrlSetColor($buttoncontrolID[13],0x000FFF)
    guictrlsetdata($buttoncontrolID[17],"Push ME TOO!")
    GUICtrlSetColor($buttoncontrolID[17],0xFF0000)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg()
    ;ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $msg = ' & $msg & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
    Switch $msg
    Case -3 ;exit is pressed
    Exit
    case $somethingbutton
    Msgbox (0,"","Button ""do something"" is pressed")

    [/autoit] [autoit][/autoit] [autoit]

    Case $buttoncontrolID[1] To $buttoncontrolID[$numberofbuttons] ;one of the "array"-Buttons is pressed
    call ("_arraybutton_"&($numberofbuttons-($buttoncontrolID[$numberofbuttons]-$msg))) ;names oft the functions are _arraybutton_1() _arraybutton_2().....
    If @error = 0xDEAD And @extended = 0xBEEF Then MsgBox(4096, "ERROR", "Function "&"_arraybutton_"&($numberofbuttons-($buttoncontrolID[$numberofbuttons]-$msg))&" does not exist!")
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;*******************functions********************************
    func _arraybutton_1()

    [/autoit] [autoit][/autoit] [autoit]

    msgbox(0,"_arraybutton_"&($numberofbuttons-($buttoncontrolID[$numberofbuttons]-$msg)),"arraybutton pressed: "&GUICtrlRead($msg))
    endfunc
    ;
    ; here are the funcs of the buttons
    ;
    ;
    func _arraybutton_13()
    msgbox(0,"_arraybutton_"&($numberofbuttons-($buttoncontrolID[$numberofbuttons]-$msg)),"arraybutton pressed: "&GUICtrlRead($msg))
    endfunc

    [/autoit] [autoit][/autoit] [autoit]

    func _arraybutton_17()
    msgbox(0,"_arraybutton_"&($numberofbuttons-($buttoncontrolID[$numberofbuttons]-$msg)),"arraybutton pressed: "&GUICtrlRead($msg))
    endfunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit]
  • Hab schnell was gebastelt

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $hDll = DllOpen("DMX.dll")

    [/autoit] [autoit][/autoit] [autoit]

    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global $iWidth = 1200
    Global $iHeight = 400

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $iLayer = 0
    Global $aDMX[513]
    Global $tByte = DllStructCreate("Byte[510];")

    [/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate("DMX 510", $iWidth, $iHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    Global $cDummy1 = GUICtrlCreateDummy()
    For $i = 0 To 15
    GUICtrlCreateRadio($i * 16 + 1 & "-" & ($i + 1) * 16, 25 + ($iWidth - 100) / 15 * $i, 10, 50, 20, 0x1000)
    GUICtrlSetOnEvent(-1, "_SetLayer")
    Next
    For $i = 0 To 15
    GUICtrlCreateRadio($i * 16 + 257 & "-" & ($i + 1) * 16 + 256, 25 + ($iWidth - 100) / 15 * $i, 40, 50, 20, 0x1000)
    GUICtrlSetOnEvent(-1, "_SetLayer")
    Next
    GUICtrlSetState($cDummy1 + 1, $GUI_CHECKED)
    Global $cDummy2 = GUICtrlCreateDummy()

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To 15
    GUICtrlCreateLabel($i + 1, 30 + ($iWidth - 120) / 15 * $i, 90, 60, 20, BitOR(0x01, 0x0200))
    GUICtrlSetBkColor(-1, 0x008800)
    GUICtrlSetOnEvent(-1, "_SetDMXValue")
    Next
    Global $cDummy3 = GUICtrlCreateDummy()
    For $i = 0 To 15
    GUICtrlCreateSlider(30 + ($iWidth - 120) / 15 * $i, 120, 34, $iHeight - 140, BitOR(0x0002, 0x0008))
    GUICtrlSetLimit(-1, 0xFF)
    GUICtrlSetData(-1, 0xFF)
    GUICtrlSetOnEvent(-1, "_SetDMXValue")
    Next

    [/autoit] [autoit][/autoit] [autoit]

    Global $cDummy4 = GUICtrlCreateDummy()
    For $i = 0 To 15
    GUICtrlCreateProgress(70 + ($iWidth - 120) / 15 * $i, 130, 20, $iHeight - 160, BitOR(0x01, 0x04))
    Next

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While Sleep(100)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_VSCROLL($hWnd, $Msg, $wParam, $lParam)
    Local $iCode = BitAND($wParam, 0x0000FFFF)
    Local $iPos = 0xFF - BitShift($wParam, 16)
    If $iCode = 5 Then
    Local $iIDX = 0
    For $i = 1 To 16
    If $lParam = GUICtrlGetHandle($cDummy3 + $i) Then
    $iIDX = $i
    ExitLoop
    EndIf
    Next
    If $iIDX Then
    Local $iDMX = $iLayer * 16 + $iIDX
    $aDMX[$iDMX] = $iPos
    GUICtrlSetData($cDummy4 + $iIDX, $aDMX[$iDMX] / 0xFF * 100)
    _SendValueToController($iDMX, $aDMX[$iDMX])
    EndIf
    EndIf
    EndFunc ;==>WM_VSCROLL

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _SetDMXValue()
    Local $iDMX = $iLayer * 16 + (@GUI_CtrlId - $cDummy3)
    $aDMX[$iDMX] = 0xFF - GUICtrlRead(@GUI_CtrlId)
    GUICtrlSetData(@GUI_CtrlId + 17, $aDMX[$iDMX] / 0xFF * 100)
    _SendValueToController($iDMX, $aDMX[$iDMX])
    EndFunc ;==>_SetDMXValue

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _SetLayer()
    $iLayer = @GUI_CtrlId - $cDummy1 - 1
    Local $iDMX1 = $iLayer * 16
    For $i = 1 To 16
    GUICtrlSetData($cDummy2 + $i, $iDMX1 + $i)
    GUICtrlSetData($cDummy3 + $i, 0xFF - $aDMX[$iDMX1 + $i])
    GUICtrlSetData($cDummy4 + $i, $aDMX[$iDMX1 + $i] / 0xFF * 100)
    Next
    EndFunc ;==>_SetLayer

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _SendValueToController($iIDX, $iValue)
    If $iIDX < 1 Or $iIDX > 510 Then Return
    DllStructSetData($tByte, 1, $iValue, $iIDX)
    DllCall($hDll, "bool", "SetLevel", "ptr", DllStructGetPtr($tByte))
    EndFunc ;==>_SendValueToController

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    Exit
    EndFunc ;==>_Exit

    [/autoit]


    Bei größeren Scripten sollte man die Dummy-Controls jedoch anders benennen

    E