import { NodeCG } from "nodecg-types/types/server" ; import { requireService } from "nodecg-io-core" ; import { ArtNetServiceClient } from "nodecg-io-artnet" ; module . exports = function ( nodecg ) { nodecg . log . info ( "Sample bundle for Art-Net started" ) ; const service = requireService < ArtNetServiceClient > ( nodecg , "artnet" ) ; let value = 0 ; let timeout = undefined ; service ?. onAvailable ( ( client ) => { nodecg . log . info ( "Art-Net console has been updated, setting up interval for sending test payloads." ) ; client . onDMX ( ( dmx ) => { nodecg . log . info ( dmx . universe , dmx . data ) ; } ) ; timeout = setInterval ( ( ) => { if ( ++ value > 255 ) value = 0 ; for ( let universe = 0 ; universe < 8 ; universe ++ ) { client . send ( universe , Array ( 512 ) . fill ( value ) ) ; } } , 800 ) ; } ) ; service ?. onUnavailable ( ( ) => { if ( timeout ) { clearInterval ( timeout ) ; value = 0 ; } nodecg . log . info ( "Art-Net console has been unset." ) ; } ) ; } ;