Skip to content

Commit

Permalink
Merge branch '#79-Add-PWR-SCS-Profile'
Browse files Browse the repository at this point in the history
  • Loading branch information
WouterJD committed Jun 14, 2020
2 parents 3949815 + 489a392 commit 7e2a2d5
Show file tree
Hide file tree
Showing 9 changed files with 402 additions and 52 deletions.
3 changes: 3 additions & 0 deletions StartUp/ExplorAnt.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
del ExplorAnt*.log
..\pythoncode\ExplorAnt.py -d127
pause
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
del *.log
del FortiusANT*.log
rem No = 0x00 # 0
rem Application = 0x01 # 1
rem Function = 0x02 # 2
rem Data1 = 0x04 # 4 antDongle
rem Data2 = 0x08 # 8 usbTrainer
rem Multiprocessing = 0x10 # 16
rem ..\pythoncode\FortiusAnt.py -g -a -A -H0 -s -P -d7
..\pythoncode\FortiusAnt.py -g -a -s -d127
..\pythoncode\FortiusAnt.py -g -a -A -H0 -s -P -d0
pause
44 changes: 43 additions & 1 deletion pythoncode/ExplorAnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ def __init__(self, Channel, DeviceType, DeviceNumber, DeviceTypeID, Transmission
AntDongle.SlaveTrainer_ChannelConfig(clv.fe)
logfile.Console ('FE slave channel %s opened; listening to master device %s' % (ant.channel_FE_s, clv.fe))

if clv.scs > 0:
AntDongle.SlaveSCS_ChannelConfig(clv.scs)
logfile.Console ('SCS slave channel %s opened; listening to master device %s' % (ant.channel_SCS_s, clv.scs))

if clv.vtx > 0:
AntDongle.SlaveVTX_ChannelConfig(clv.vtx)
logfile.Console ('VTX slave channel %s opened; listening to master device %s' % (ant.channel_VTX_s, 0))
Expand Down Expand Up @@ -378,6 +382,8 @@ def __init__(self, Channel, DeviceType, DeviceNumber, DeviceTypeID, Transmission
FE_page80_done = False
FE_page81_done = False

SCS_s_count = 0

VTX_UsingVirtualSpeed, VTX_Power, VTX_Speed, VTX_CalibrationState, VTX_Cadence = 0,0,0,0,0
VTX_S1, VTX_S2, VTX_Serial, VTX_Alarm = 0,0,0,0
VTX_Major, VTX_Minor, VTX_Build = 0,0,0
Expand Down Expand Up @@ -564,6 +570,41 @@ def __init__(self, Channel, DeviceType, DeviceNumber, DeviceTypeID, Transmission
logfile.Console ("FE Page=%s SWrevision=%s.%s Serial#=%s" % \
(DataPageNumber, FE_SWrevisionMain, FE_SWrevisionSupp, FE_SerialNumber))

#-------------------------------------------------------
# SCS_s = Heart rate Monitor Display
# We are slave, listening to a master (Speed Cadence Sensor)
#-------------------------------------------------------
if Channel == ant.channel_SCS_s:
SCS_s_count += 1
if SCS_s_count > 99: SCS_s_count= 0

#---------------------------------------------------
# Only one Data page for SCS! msgUnpage_SCS
#---------------------------------------------------
Unknown = False
EventTime, CadenceRevolutionCount, _EventTime, \
SpeedRevolutionCount = ant.msgUnpage_SCS(info)

try:
_ = pEventTime
except:
pass
else:
if EventTime != pEventTime:
cadence = 60 * (CadenceRevolutionCount - pCadenceRevolutionCount) * 1024 / \
(EventTime - pEventTime)
cadence = int(cadence)

speed = (SpeedRevolutionCount - pSpeedRevolutionCount) * 2.096 * 3.600 / \
(EventTime - pEventTime)
print ('EventTime=%5s (%5s) CadenceRevolutionCount=%5s (%5s) Cadence=%3s EventTime=%5s SpeedRevolutionCount=%5s Speed=%4.1f' % \
(EventTime, EventTime - pEventTime, \
CadenceRevolutionCount, CadenceRevolutionCount - pCadenceRevolutionCount, \
cadence, _EventTime, SpeedRevolutionCount, speed))
pCadenceRevolutionCount = CadenceRevolutionCount
pSpeedRevolutionCount = SpeedRevolutionCount
pEventTime = EventTime

#-------------------------------------------------------
# VTX_s = Tacx i-Vortex trainer
# We are slave, listening to a master (the real trainer)
Expand Down Expand Up @@ -707,9 +748,10 @@ def __init__(self, Channel, DeviceType, DeviceNumber, DeviceTypeID, Transmission
)

else:
logfile.Console ("HRM#=%2s hr=%3s FE-C#=%2s Speed=%4s Cadence=%3s Power=%3s hr=%3s VTX ID=%s Speed=%4s Cadence=%3s Target=%s" % \
logfile.Console ("HRM#=%2s hr=%3s FE-C#=%2s Speed=%4s Cadence=%3s Power=%3s hr=%3s SCS#=%2s VTX ID=%s Speed=%4s Cadence=%3s Target=%s" % \
(HRM_s_count, HRM_HeartRate, \
FE_s_count, FE_Speed, FE_Cadence, FE_Power, FE_HeartRate, \
SCS_s_count, \
VTX_VortexID, VTX_Speed, VTX_Cadence, Power
)\
)
Expand Down
54 changes: 45 additions & 9 deletions pythoncode/FortiusAntBody.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#-------------------------------------------------------------------------------
# Version info
#-------------------------------------------------------------------------------
__version__ = "2020-05-27"
__version__ = "2020-06-12"
# 2020-06-12 Added: BikePowerProfile and SpeedAndCadenceSensor final
# 2020-06-11 Added: BikePowerProfile (master)
# 2020-06-09 Added: SpeedAndCadenceSensor (master)
# 2020-05-27 Added: msgPage71_CommandStatus handled -- and tested
# 2020-05-24 i-Vortex adjustments
# - in manual mode, ANTdongle must be present as well, so that
Expand Down Expand Up @@ -167,8 +170,10 @@
from datetime import datetime

import antDongle as ant
import antHRM as hrm
import antFE as fe
import antHRM as hrm
import antPWR as pwr
import antSCS as scs
import debug
from FortiusAntGui import mode_Power, mode_Grade
import logfile
Expand Down Expand Up @@ -544,9 +549,23 @@ def Tacx2DongleSub(self, Restart):
#-------------------------------------------------------------------
AntDongle.SlaveVHU_ChannelConfig(0)

if clv.scs != None:
AntDongle.SlaveSCS_ChannelConfig(clv.scs) # Create ANT+ slave channel for SCS
# 0: auto pair, nnn: defined SCS
if True:
#-------------------------------------------------------------------
# Create ANT+ master channel for PWR
#-------------------------------------------------------------------
AntDongle.PWR_ChannelConfig(ant.channel_PWR)

if clv.scs == None:
#-------------------------------------------------------------------
# Create ANT+ master channel for SCS
#-------------------------------------------------------------------
AntDongle.SCS_ChannelConfig(ant.channel_SCS)
else:
#-------------------------------------------------------------------
# Create ANT+ slave channel for SCS
# 0: auto pair, nnn: defined SCS
#-------------------------------------------------------------------
AntDongle.SlaveSCS_ChannelConfig(clv.scs)
pass

if not clv.gui: logfile.Console ("Ctrl-C to exit")
Expand Down Expand Up @@ -668,8 +687,10 @@ def Tacx2DongleSub(self, Restart):
# Initialize antHRM and antFE module
#---------------------------------------------------------------------------
if debug.on(debug.Function): logfile.Write('Tacx2Dongle; initialize ANT')
hrm.Initialize()
fe.Initialize()
hrm.Initialize()
pwr.Initialize()
scs.Initialize()

#---------------------------------------------------------------------------
# Initialize CycleTime: fast for PedalStrokeAnalysis
Expand Down Expand Up @@ -713,8 +734,8 @@ def Tacx2DongleSub(self, Restart):
# Hook for future development
#-------------------------------------------------------------------
# if clv.scs == None:
# SpeedKmh = SpeedKmhT
# Cadence = CadenceT
# SpeedKmh = SpeedKmhSCS
# Cadence = CadenceSCS

#-------------------------------------------------------------------
# If NO HRM defined, use the HeartRate from the trainer
Expand Down Expand Up @@ -794,6 +815,21 @@ def Tacx2DongleSub(self, Restart):
if clv.hrm == None and TacxTrainer.HeartRate > 0:
messages.append(hrm.BroadcastHeartrateMessage(HeartRate))

#---------------------------------------------------------------
# Broadcast Bike Power message
#---------------------------------------------------------------
if True:
messages.append(pwr.BroadcastMessage( \
TacxTrainer.CurrentPower, TacxTrainer.Cadence))

#---------------------------------------------------------------
# Broadcast Speed and Cadence Sensor message
#---------------------------------------------------------------
if clv.scs == None:
messages.append(scs.BroadcastMessage( \
TacxTrainer.PedalEchoTime, TacxTrainer.PedalEchoCount, \
TacxTrainer.VirtualSpeedKmh, TacxTrainer.Cadence))

#---------------------------------------------------------------
# Broadcast TrainerData message to the CTP (Trainer Road, ...)
#---------------------------------------------------------------
Expand Down Expand Up @@ -1105,7 +1141,7 @@ def Tacx2DongleSub(self, Restart):
if debug.on(debug.Data2): logfile.Write ("Sleep(%4.2f) to fill %s seconds done." % (SleepTime, CycleTime) )
else:
if ElapsedTime > CycleTime * 2 and debug.on(debug.Any):
logfile.Console ("Tacx2Dongle; Processing time %5.3f is %5.3f longer than planned %5.3f (seconds)" % (ElapsedTime, SleepTime * -1, CycleTime) )
logfile.Write ("Tacx2Dongle; Processing time %5.3f is %5.3f longer than planned %5.3f (seconds)" % (ElapsedTime, SleepTime * -1, CycleTime) )
pass

EventCounter += 1 # Increment and ...
Expand Down
5 changes: 3 additions & 2 deletions pythoncode/FortiusAntGui.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#-------------------------------------------------------------------------------
# Version info
#-------------------------------------------------------------------------------
WindowTitle = "Fortius Antifier v3.1.1"
__version__ = "2020-05-24"
WindowTitle = "Fortius Antifier v3.2"
__version__ = "2020-06-12"
# 2020-05-12 Version 3.2 with SCS and PWR profile
# 2020-05-24 Initial GUI messages made more general
# TargetResistance not displayed when zero (for i-Vortex)
# 2020-05-15 Window title adjusted to version 3.0, comment on teeth.
Expand Down
Loading

0 comments on commit 7e2a2d5

Please sign in to comment.