1. New to Christmas lighting? Get started with the AusChristmasLighting 101 Manual:
    auschristmaslighting.com/wiki/AusChristmasLighting-101

Triks-C/LTC batch file launch script

Discussion in 'xLights (Nutcracker)' started by jaredo, Nov 30, 2013.

  1. jaredo

    jaredo if (blink==true){ doFlash(); }

    Joined:
    Feb 16, 2011
    Messages:
    22
    Likes Received:
    5
    Location:
    Rockhampton
    Find Me On:
    I'm slyfox04 @ DIYC forums. Just FYI, didn't steal this post :) .

    I've recently made the switch to xLights for my scheduling after 2 horror years of Vixen 2.1 program scheduling dramas (the ol' com port X denied issue).
    The current version 3.2.9 is quite cool, I like how playlists can be randomized :D . I Last used 2012c.

    Anyway, I use a LedTriks board powered by a Triks-C. In Vixen I use the launcher to run a basic loop of "Tune to XX.X FM" and display the currently playing track of each sequence.
    I needed to be able to do this under xLights also, so I dug around the documentation for the Scripting and come up with a relatively easy way to do it.

    Hopefully this is of use to someone in the future :).

    Your batch files (I recommend using these to launch LTC and supply the LED file argument),
    * should have a filename that's the same as your xLight sequence minus the '.xseq' extension
    * optionally have _LTC in the filename.

    eg. 2013-TSO_Siberian_Sleigh_Ride_LTC.bat
    Which has this inside it, paths are as example only (I run everything from C:\ root to avoid issues), tskill part of windows (XP and Win 7, AFIAK) and is used to kill of existing LTC processes so the new one we launch
    can get the com port.
    Code:
    tskill LTC
    tskill LTC
    c:\LTC\LTC.exe c:\LTC\2013-TSO_Siberian_Sleigh_Ride_LTC.led <any additional arguments here>
    The entire script is below for your perusal, line 500 onwards just works out the filename of the batch file, then jumps back to the main block (line 200) to execute the sequence and EXEC the batch file
    Most of this is auto generated by xLights (if you go Playlists -> Custom Script), I've marked the blocks where possible with 'GENERATED'
    I've highlights my modifications so you can see them.

    NOTE: This script repeats, randomizes, and skips first item in the playlist

    Lines modified:
    221 -> print out what batch file we'll launch
    223 -> EXEC batch file, modify path as necessary
    to suite your environment

    370 -> jump to line 500 to work out batch file name
    371 -> just a remark to remind me what the old code was


    500 -> onwards works out the batch file name

    Code:
    100 REM *
    101 REM * Created: 11/29/13 14:23:41
    102 REM * Random: on
    103 REM * Repeat: on
    104 REM * First Item Once: on
    105 REM * Last Item Once: off
    106 REM * Launches LTC for the current playing item
    107 REM *
    
    110 LET ListName$="xseq_set_1"
    120 SETPLAYLIST ListName$
    130 ONPLAYBACKEND 140
    131 PRINT "At:", FORMATDATETIME$(NOW,5)
    132 PRINT "Playing:",ITEMNAME$(1)
    133 PLAYITEM 1
    134 WAIT
    
    140 ONPLAYBACKEND 300
    170 IF PLAYLISTSIZE-1>1 THEN 176
    172 PRINT "ERROR: not enough items in playlist to support random playback"
    174 GOTO 400
    176 LET LastItemPlayed=-1
    178 DIM PLAYED(PLAYLISTSIZE)
    180 FOR I=1 TO PLAYLISTSIZE
    182 LET PLAYED(I)=0
    184 NEXT I
    186 LET PlayCount=0
    188 GOTO 300
    
    200 REM * GENERATED - MODIFIED
    201 REM * Play item NextItem
    202 REM *
    210 LET LastItemPlayed=NextItem
    211 PRINT STRING$(5,"*")
    215 PRINT "At:", FORMATDATETIME$(NOW,5)
    220 PRINT "Playing:",ITEMNAME$(NextItem)
    221 PRINT "LTC Launch:","C:\LTC\"+LtcBatchList$(NextItem)+".bat"
    222 PRINT STRING$(10,"*")
    223 EXEC "CMD /C ""C:\LTC\"+LtcBatchList$(NextItem)+".bat"""
    230 PLAYITEM NextItem
    240 WAIT
    
    300 REM * GENERATED
    301 REM * Jump here at end of song or sequence
    302 REM *
    310 IF SECONDSREMAINING <= 0 THEN 400
    320 IF PlayCount>=PLAYLISTSIZE-1 THEN 180
    330 LET NextItem=RND(PLAYLISTSIZE-1)+2
    340 IF PLAYED(NextItem)>0 THEN 330
    345 IF LastItemPlayed=NextItem THEN 330
    350 LET PLAYED(NextItem)=1
    360 LET PlayCount=PlayCount+1
    361 PRINT STRING$(10,"*")
    370 GOTO 500
    371 REM GOTO 200 - Orignial statement
    
    400 REM * GENERATED
    401 REM Reached scheduled end time, goodnight
    402 REM *
    490 LIGHTSOFF
    
    500 REM * JARED - Custom
    501 REM * Work out what LTC batch file to exec
    502 REM * Your LED batch filenames should be <sequence name>_LTC.bat
    503 REM *
    504 DIM LtcBatchList$(PLAYLISTSIZE)
    505 LET LtcItemName$=ITEMNAME$(NextItem)
    506 PRINT "LTCItemName: ",LtcItemName$
    
    540 LET LtcNameOffset=INSTR(LtcItemName$,".xseq",1)-1
    541 PRINT "LTC_OFFSET:",LtcNameOffset
    
    550 LET LtcBatchList$(NextItem)=LEFT$(LtcItemName$, LtcNameOffset) + "_LTC"
    
    561 PRINT "BatchName:",LtcBatchList$(NextItem)
    
    580 REM Jump back to line 200 to play item and exec ltc batch
    590 GOTO 200
     

Share This Page