Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

You are here: Forum Home → ANT+ Forums → ANT+ Simulation Tools → Thread

   

SimulANT+ update did not call

Rank

Total Posts: 29

Joined 0

PM

Hi,
I am new to this tool, I don't want to use sweeper to produce the hear rate data. I want to use my heart rate sequence, so I comment out the sweepBpm code. However, the update method seems never call.
By the way, how can we print string to the Output area.
My code is list as below, any suggestion will be appreciate.
Best regards,
tony

# This scripts sets up a heart rate sensor to transmit the specified
# range of sweeping values. Refer to the sesnsorSimulation module for additional
# details on the sweeping mechanism
from sensorSimulation import sweeper
from System.Timers import Timer
eventTimer = Timer(1000) # convert time to milliseconds
sweepBpm = sweeper()

# SWEEP CONFIGURATION - Modify the values in the following four lines to change the sweep characteristics
# Make sure that all of these are doubles (use a decimal point!) so that calculations are accurate
#sweepBpm.minValue = 71.0 # Minimum value in sweeping range, in bpm
#sweepBpm.maxValue = 71.0 # Maximum value in sweeping range in bpm
#sweepBpm.sweepTime = 1.0 # Time to sweep between the minimum and maximum values, in seconds
#sweepBpm.constantTime = 5.0 # Time to spend at a constant speed in the minimum and maximum values, in seconds

#simulator.HeartRate = sweepBpm.minValue
hr = [71.0,72.0,74.0,71.0]

icount = 0
simulator.HeartRate = hr[icount]


def update(sender, args):
icount=icount+1
simulator.HeartRate = hr[icount%4]

def stopScript():
#sweepBpm.stop()
eventTimer.Stop()
simulator.TurnOff()

eventTimer.Elapsed += update
simulator.TurnOn()
eventTimer.Start()
#sweepBpm.start()      
Avatar
RankRankRankRank

Total Posts: 662

Joined 2012-10-09

PM

Hello,

As documented in the scripting interface help file, in the section "Writing SimulANT+ Scripts" you can add messages to the event log using the logScriptEvent function.

Are you sure update is not being called? From your code, it looks like you are missing "global" when trying to increment icount.
http://infohost.nmt.edu/tcc/help/pubs/python/web/global-statement.html