This example implements a realtime random signal generator including custom functions to start or stop generating signal



#this variable defines a display rate of the signal generator

displayRate = 0


#add Start/Stop custom commands to the context menu

function getCustomActions( )

       return ["Start", "Stop"];

end


#react to Start/Stop custom commands by setting display rate accordingly

function customAction( action :: String )

       if( action == "Start")

               global displayRate = 100

       elseif ( action == "Stop")

               global displayRate = 0

       end

end


#generate signal

function update( output_signal:: SigviewSignalWindow )

  if( displayRate == 0 )

       return false

  end

       

  output_signal.samples = rand(-1000:1000, 1000 )

  output_signal.samplingRate = 1

  return true

end


#provide update interval by using internal display rate variable

function getUpdateIntervalMSec( )

       return displayRate;

end