Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Garmin Xero C1 Pro chrono
#80
Code:
?# # Notes: Requires Java # # Copy entire folder from google drive # https://drive.google.com/drive/folders/1fb_MCyteiMZrcL-gj7DJXlCn-Y_LsGkO?usp=drive_link # Connect Garmin Xero C1 Pro to Computer # Run the script (right click + run with powershell) # Navigate to the .FIT files on the device in the pop up and select them, press "Open" button # Name the sessions when prompted in terminal window. Spaces are OK, dont include .txt # # # # Created by ZenEffect cls Add-Type -AssemblyName System.Windows.Forms #ripped this part off of a google search. It creates function for the pop up window to select files function Select-File { [CmdletBinding()] param( [Parameter(ParameterSetName="Single")] [Parameter(ParameterSetName="Multi")] [Parameter(ParameterSetName="Save")] [string]$StartingFolder = [environment]::getfolderpath("mydocuments"), [Parameter(ParameterSetName="Single")] [Parameter(ParameterSetName="Multi")] [Parameter(ParameterSetName="Save")] [string]$NameFilter = "All Files (*.*)|*.*", [Parameter(ParameterSetName="Single")] [Parameter(ParameterSetName="Multi")] [Parameter(ParameterSetName="Save")] [switch]$AllowAnyExtension, [Parameter(Mandatory=$true,ParameterSetName="Save")] [switch]$Save, [Parameter(Mandatory=$true,ParameterSetName="Multi")] [Alias("Multi")] [switch]$AllowMulti ) if ($Save) { $Dialog = New-Object -TypeName System.Windows.Forms.SaveFileDialog } else { $Dialog = New-Object -TypeName System.Windows.Forms.OpenFileDialog if ($AllowMulti) { $Dialog.Multiselect = $true } } if ($AllowAnyExtension) { $NameFilter = $NameFilter + "|All Files (*.*)|*.*" } $Dialog.Filter = $NameFilter $Dialog.InitialDirectory = $StartingFolder [void]($Dialog.ShowDialog()) $Dialog.FileNames } # .FIT file to .CSV - Copies to a "fit_temp" folder first for processing. Does not interact with device except to copy the files to computer first. $fit = (Select-File -StartingFolder "C:\" -NameFilter "Garmin FIT Files (*.fit)|*.fit" -AllowMulti) copy $fit .\fit_Temp $fit_temp = get-childitem -Path .\fit_temp | select-object fullname foreach ($fitfile in $fit_temp) { $fit3 = $fitfile.fullname $fit2 = "`"$fit3`"" # sends the selected files to the bat file that came with the Garmin SDK. Only modification to the .BAT was to remove the "Pause" at the end. FIT files # are processed into CSV by some Garmin SDK Java magic. start-process -filepath '.\java\fittocsv.bat' -argumentlist $fit2 -wait } # gets list of newly created .csv from fit_temp directory for processing $items = get-childitem -Path .\fit_temp\*.csv | select fullname foreach ($item in $items) { # Gets shot data and calculates standard deviation $csv1 = $item.fullname | import-csv $csv_data = $csv1 | where 'type' -eq 'data' | where 'local number' -eq 4 $measured = $csv_data.'value 2' | measure-object -average $newNumbers = 0 ForEach ($number in $csv_data) { $newNumbers += [Math]::Pow(($number.'value 2' - $measured.Average), 2) } $stdDev = [math]::Sqrt($($newNumbers / ($measured.Count - 1))) $stdDevp = [math]::Sqrt($($newNumbers / ($measured.Count))) $stddev_fps=$stddev / 304.79999025 $stddevp_fps=$stddevp / 304.79999025 # Begin CSV to TXT file processing foreach ($csv in $csv1) { $time = (([System.DateTimeOffset]::FromUnixTimeSeconds($time_hack)).DateTime.ToLocalTime()).ToString("s") $type = $csv.type $localnumber = $csv."local number" if ($type -eq "Data" -and $localnumber -eq "3") { $min = ($csv."Value 2" / 304.79999025) $max = ($csv."Value 3" / 304.79999025) $average = ($csv."Value 4" / 304.79999025) $shots = $csv."Value 6" $time_hack=([int]$csv."Value 1" + [int]631065600) $time = (([System.DateTimeOffset]::FromUnixTimeSeconds($time_hack)).DateTime.ToLocalTime()).ToString("s") $extreme_spread= ($max - $min) Write-host "Session Time/Date:" $time Write-host "# of Shots:", $shots Write-host " " Write-host "Min:", $min Write-host "Max:", $max Write-host "Average:", $average Write-host " " write-host "Standard Deviation:", $stddev_fps write-host "Population Standard Deviation:", $stddevp_fps Write-host "Extreme Spread:", $extreme_spread write-host " " write-host " " $Session_name = Read-Host -Prompt "Enter Session Name" Write-output "Session Time/Date: $time" | out-file -filepath .\Results\$Session_name.txt -Append Write-output "Session Name: $session_name" | out-file -filepath .\Results\$Session_name.txt -Append Write-output "# of Shots: $shots" | out-file -filepath .\Results\$Session_name.txt -Append Write-output "Min: $min" | out-file -filepath .\Results\$Session_name.txt -Append Write-output "Max: $max" | out-file -filepath .\Results\$Session_name.txt -Append Write-output "Average: $average" | out-file -filepath .\Results\$Session_name.txt -Append Write-Output "Standard Deviation: $stddev_fps" | out-file -filepath .\Results\$Session_name.txt -Append Write-Output "Population Standard Deviation: $stddevp_fps" | out-file -filepath .\Results\$Session_name.txt -Append Write-output "Extreme Spread: $extreme_spread" | out-file -filepath .\Results\$Session_name.txt -Append Write-output " " | out-file -filepath .\Results\$Session_name.txt -Append $newNumbers = 0 cls } if ($type -eq "Data" -and $localnumber -eq "4") { $shot_num = $csv.'Value 3' $speed = ($csv.'Value 2' / 304.79999025) $time_hack1=([int]$csv."value 1" + [int]631065600) $time1 = (([System.DateTimeOffset]::FromUnixTimeSeconds($time_hack1)).DateTime.ToLocalTime()).ToString("s") Write-output " " | out-file -filepath .\Results\$Session_name.txt -Append Write-output "Shot #: $shot_num" | out-file -filepath .\Results\$Session_name.txt -Append Write-output "Speed: $speed" | out-file -filepath .\Results\$Session_name.txt -Append Write-output "Time of Shot: $time1" | out-file -filepath .\Results\$Session_name.txt -Append Write-output " " | out-file -filepath .\Results\$Session_name.txt -Append } } } # cleanup actions move-item -path .\fit_temp\*.csv -destination .\results\ move-item .\fit_temp\*.fit -destination .\fit_backup

Updated - fixed processing logic so it processes the csv from the temp directory and not results, moved the copied .fit files to backup rather than delete, created empty directory "fit_backups" for backups of raw device data to hard drive. not asking, this is happening and you will thank me later for it.

updated in drive as well.

my apologies for derailing this thread with nerd sh!t but, i think im at the point with this script where i dont really care to improve it. Its about time to redo-it all using 1 little nugget that I used to calculate the SD. I can do this a lot cleaner if I load everything into an array then just have it output the raw csv, a text file, and a "corrected' csv at the same time. User interface would not change.

chose powershell because everyone with a PC has it already. also, afik.. nobody else has tackled this "issue" as completely as I have until now... so.... FIRST!

Maybe ill work on patching in a cleaned up CSV later this week, but for now I like where its at.

The SD imnusing is using the -1 method I believe... more google-fu and not enough caring about math to make the formula myself, just modify the inputs for my needs.



*edit*

The SD differences was driving me up the wall. Added population SD (both are calculated and shown/recorded)

Updated google drive + the above code block. Text file now outputs like this, ill investigate the time bug:


Session Time/Date: 2004-01-16T11:13:36
Session Name: Berf
# of Shots: 5
Min: 2627.82816804897
Max: 2678.33341900837
Average: 2650.3905047287
Standard Deviation: 18.7458957133989
Population Standard Deviation: 16.7668388457128
Extreme Spread: 50.5052509594034


Shot #: 1
Speed: 2653.21202712867
Time of Shot: 2004-01-16T11:16:12


Shot #: 2
Speed: 2678.33341900837
Time of Shot: 2004-01-16T11:16:22


Shot #: 3
Speed: 2652.38197460868
Time of Shot: 2004-01-16T11:16:29


Shot #: 4
Speed: 2627.82816804897
Time of Shot: 2004-01-16T11:16:39


Shot #: 5
Speed: 2640.20021568882
Time of Shot: 2004-01-16T11:16:48
Reply


Messages In This Thread
Garmin Xero C1 Pro chrono - by jasper2408 - 10-27-2023, 07:22 PM
Garmin Xero C1 Pro chrono - by Timitus - 10-27-2023, 07:27 PM
Garmin Xero C1 Pro chrono - by Old Bob - 10-28-2023, 12:19 AM
Garmin Xero C1 Pro chrono - by jasper2408 - 10-28-2023, 12:30 AM
Garmin Xero C1 Pro chrono - by Old Bob - 10-28-2023, 12:56 AM
Garmin Xero C1 Pro chrono - by jasper2408 - 10-28-2023, 01:23 AM
Garmin Xero C1 Pro chrono - by Old Bob - 10-28-2023, 01:56 AM
Garmin Xero C1 Pro chrono - by jasper2408 - 10-28-2023, 12:26 PM
Garmin Xero C1 Pro chrono - by SDW - 10-28-2023, 07:13 PM
Garmin Xero C1 Pro chrono - by SDW - 10-28-2023, 07:29 PM
Garmin Xero C1 Pro chrono - by mtnlvr - 10-28-2023, 09:56 PM
Garmin Xero C1 Pro chrono - by jasper2408 - 10-28-2023, 11:09 PM
Garmin Xero C1 Pro chrono - by jasper2408 - 10-29-2023, 01:24 PM
Garmin Xero C1 Pro chrono - by jasper2408 - 10-31-2023, 12:02 PM
Garmin Xero C1 Pro chrono - by CJW - 11-01-2023, 02:56 AM
Garmin Xero C1 Pro chrono - by Klem - 11-01-2023, 10:03 AM
Garmin Xero C1 Pro chrono - by biodsl - 11-01-2023, 10:28 AM
Garmin Xero C1 Pro chrono - by jasper2408 - 11-01-2023, 03:16 PM
Garmin Xero C1 Pro chrono - by biodsl - 11-01-2023, 04:09 PM
Garmin Xero C1 Pro chrono - by Legionnaire - 11-01-2023, 04:17 PM
Garmin Xero C1 Pro chrono - by jasper2408 - 11-01-2023, 04:24 PM
Garmin Xero C1 Pro chrono - by Klem - 11-01-2023, 10:47 PM
Garmin Xero C1 Pro chrono - by jasper2408 - 11-01-2023, 11:47 PM
Garmin Xero C1 Pro chrono - by SDW - 11-02-2023, 03:24 PM
Garmin Xero C1 Pro chrono - by jasper2408 - 11-04-2023, 05:14 PM
Garmin Xero C1 Pro chrono - by Klem - 11-05-2023, 07:44 AM
Garmin Xero C1 Pro chrono - by lazyengineer - 12-29-2023, 05:20 PM
Garmin Xero C1 Pro chrono - by mtnlvr - 12-29-2023, 07:47 PM
Garmin Xero C1 Pro chrono - by lazyengineer - 12-30-2023, 04:57 AM
Garmin Xero C1 Pro chrono - by jasper2408 - 12-30-2023, 03:13 PM
Garmin Xero C1 Pro chrono - by Cowdog - 12-30-2023, 04:02 PM
Garmin Xero C1 Pro chrono - by stonehog - 12-30-2023, 06:57 PM
Garmin Xero C1 Pro chrono - by mtnlvr - 12-30-2023, 09:08 PM
Garmin Xero C1 Pro chrono - by jasper2408 - 12-31-2023, 03:09 PM
Garmin Xero C1 Pro chrono - by mtnlvr - 12-31-2023, 03:57 PM
Garmin Xero C1 Pro chrono - by SDW - 01-01-2024, 06:48 PM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-01-2024, 07:38 PM
Garmin Xero C1 Pro chrono - by jasper2408 - 01-01-2024, 07:49 PM
Garmin Xero C1 Pro chrono - by SDW - 01-07-2024, 02:50 PM
Garmin Xero C1 Pro chrono - by SDW - 01-07-2024, 03:04 PM
Garmin Xero C1 Pro chrono - by Klem - 01-07-2024, 11:07 PM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-07-2024, 11:12 PM
Garmin Xero C1 Pro chrono - by natebonebusta - 01-07-2024, 11:44 PM
Garmin Xero C1 Pro chrono - by mtnlvr - 01-08-2024, 12:05 AM
Garmin Xero C1 Pro chrono - by Klem - 01-08-2024, 12:23 AM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-08-2024, 01:36 AM
Garmin Xero C1 Pro chrono - by mtnlvr - 01-08-2024, 02:30 AM
Garmin Xero C1 Pro chrono - by lazyengineer - 01-08-2024, 03:46 AM
Garmin Xero C1 Pro chrono - by SDW - 01-08-2024, 03:51 AM
Garmin Xero C1 Pro chrono - by SDW - 01-08-2024, 03:33 PM
Garmin Xero C1 Pro chrono - by SDW - 01-08-2024, 07:14 PM
Garmin Xero C1 Pro chrono - by Klem - 01-14-2024, 01:00 AM
Garmin Xero C1 Pro chrono - by SDW - 01-15-2024, 03:25 PM
Garmin Xero C1 Pro chrono - by grayfox - 01-15-2024, 04:05 PM
Garmin Xero C1 Pro chrono - by 37L1 - 01-15-2024, 04:39 PM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-15-2024, 04:49 PM
Garmin Xero C1 Pro chrono - by lazyengineer - 01-15-2024, 05:16 PM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-15-2024, 05:21 PM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-15-2024, 10:52 PM
Garmin Xero C1 Pro chrono - by SDW - 01-16-2024, 03:48 PM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-16-2024, 05:39 PM
Garmin Xero C1 Pro chrono - by mtnlvr - 01-16-2024, 06:15 PM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-16-2024, 07:29 PM
Garmin Xero C1 Pro chrono - by grayfox - 01-16-2024, 08:19 PM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-16-2024, 08:58 PM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-16-2024, 11:45 PM
Garmin Xero C1 Pro chrono - by grayfox - 01-17-2024, 01:31 AM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-17-2024, 02:58 AM
Garmin Xero C1 Pro chrono - by grayfox - 01-17-2024, 03:11 AM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-17-2024, 03:44 AM
Garmin Xero C1 Pro chrono - by lazyengineer - 01-17-2024, 05:07 AM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-17-2024, 06:03 AM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-17-2024, 04:57 PM
Garmin Xero C1 Pro chrono - by jasper2408 - 01-17-2024, 10:37 PM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-17-2024, 10:38 PM
Garmin Xero C1 Pro chrono - by Klem - 01-17-2024, 10:45 PM
Garmin Xero C1 Pro chrono - by jasper2408 - 01-17-2024, 10:47 PM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-17-2024, 10:58 PM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-17-2024, 11:39 PM
Garmin Xero C1 Pro chrono - by grayfox - 01-18-2024, 01:25 AM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-18-2024, 01:51 AM
Garmin Xero C1 Pro chrono - by jasper2408 - 01-18-2024, 10:06 AM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-18-2024, 04:36 PM
Garmin Xero C1 Pro chrono - by SDW - 01-18-2024, 05:55 PM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-18-2024, 06:02 PM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-18-2024, 06:18 PM
Garmin Xero C1 Pro chrono - by SDW - 01-18-2024, 06:49 PM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-18-2024, 08:31 PM
Garmin Xero C1 Pro chrono - by SDW - 01-18-2024, 10:45 PM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-18-2024, 10:58 PM
Garmin Xero C1 Pro chrono - by SDW - 01-18-2024, 11:04 PM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-18-2024, 11:10 PM
Garmin Xero C1 Pro chrono - by SDW - 01-18-2024, 11:49 PM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-19-2024, 12:18 AM
Garmin Xero C1 Pro chrono - by grayfox - 01-19-2024, 12:34 AM
Garmin Xero C1 Pro chrono - by SDW - 01-19-2024, 12:40 AM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-19-2024, 12:57 AM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-19-2024, 01:08 AM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-19-2024, 02:51 AM
Garmin Xero C1 Pro chrono - by SDW - 01-19-2024, 04:45 AM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-19-2024, 06:43 AM
Garmin Xero C1 Pro chrono - by Steve Matthew - 01-19-2024, 09:03 AM
Garmin Xero C1 Pro chrono - by jasper2408 - 01-19-2024, 09:47 AM
Garmin Xero C1 Pro chrono - by Zeneffect - 01-19-2024, 10:29 PM
Garmin Xero C1 Pro chrono - by Popeye212 - 01-20-2024, 11:15 PM
Garmin Xero C1 Pro chrono - by jasper2408 - 01-21-2024, 02:57 PM
Garmin Xero C1 Pro chrono - by jasper2408 - 02-23-2024, 08:04 PM
Garmin Xero C1 Pro chrono - by Klem - 01-08-2024, 06:28 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)