You are here: Forum Home → ANT+ Forums → ANT+ Simulation Tools → Thread
# This scripts sets up a bike power sensor to transmit the specified
# range of sweeping values. Refer to the sesnsorSimulation module for additional
# details on the sweeping mechanism
import clr
clr.AddReference('ANT+ProfileLib')
from AntPlus.Profiles.BikePower import TorqueEffectivenessAndPedalSmoothnessPage
from AntPlus.Profiles.Common import RequestDataPage, Common
from sensorSimulation import sweeper
from System.Timers import Timer
import System
eventTimer = Timer(1000) # convert time to milliseconds
sweepTE = sweeper()
sweepPS = sweeper()
tePsObj = TorqueEffectivenessAndPedalSmoothnessPage()
# 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
sweepTE.minValue = 120.0 # Minimum value in sweeping range, in Watts
sweepTE.maxValue = 190.0 # Maximum value in sweeping range in Watts
sweepTE.sweepTime = 60.0 # Time to sweep between the minimum and maximum values, in seconds
sweepTE.constantTime = 2.0 # Time to spend at a constant speed in the minimum and maximum values, in seconds
tePsObj.LeftTorqueEffectiveness = sweepTE.minValue
tePsObj.RightTorqueEffectiveness = sweepTE.minValue
# 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
sweepPS.minValue = 115.0 # Minimum value in sweeping range, in Watts
sweepPS.maxValue = 187.0 # Maximum value in sweeping range in Watts
sweepPS.sweepTime = 60.0 # Time to sweep between the minimum and maximum values, in seconds
sweepPS.constantTime = 3.0 # Time to spend at a constant speed in the minimum and maximum values, in seconds
tePsObj.LeftCombinedPedalSmoothness = sweepPS.minValue
tePsObj.RightPedalSmoothness = sweepPS.minValue
def update(sender, args):
tePsObj.LeftTorqueEffectiveness = sweepTE.getNextValue()
tePsObj.RightTorqueEffectiveness = simulator.LeftTorqueEffectiveness
tePsObj.LeftCombinedPedalSmoothness = sweepPS.getNextValue()
tePsObj.RightPedalSmoothness = simulator.LeftCombinedPedalSmoothness
def stopScript():
sweepTE.stop()
sweepPS.stop()
eventTimer.Stop()
simulator.TurnOff()
eventTimer.Elapsed += update
simulator.TurnOn()
eventTimer.Start()
sweepTE.start()
sweepPS.start()