changed up the way it loads files so it processes them 1 at a time instead of im not sure how to explain it... shoving it all in a giant pile and trying to sort from there wasnt working..
ES and SD are added though the numbers are suspect on SD... need to see what they are doing and how to get them to align. my math is good, but im not sure if i chose the "right" SD equation (i see there are 2?)
TXT output file now looks like this:
Session Time: 2004-01-13T17:18:43
# of Shots: 5
Min: 2627.82816804897
Max: 2678.33341900837
Average: 2650.3905047287
Standard Deviation: 18.7458957133989
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
SOMEONE PLEASE CHECK MY MATH PLEASE PRETTY PLEASE
Code:
cls
Add-Type -AssemblyName System.Windows.Forms
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 = (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`""
start-process -filepath '.\java\fittocsv.bat' -argumentlist $fit2 -wait
}
move-item -path .\fit_temp\*.csv -destination .\results\
$items = get-childitem -Path .\Results\*.csv | select fullname
foreach ($item in $items)
{
$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)))
$stddev_fps=$stddev / 304.79999025
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=$csv."Value 1"
$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 "Extreme Spread:", $extreme_spread
write-host " "
write-host " "
$Session_name = Read-Host -Prompt "Enter Session Name"
Write-output "Session Time: $time" | 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 "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=$csv."value 1"
$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
}
}
}
remove-item .\fit_temp\*.fitES and SD are added though the numbers are suspect on SD... need to see what they are doing and how to get them to align. my math is good, but im not sure if i chose the "right" SD equation (i see there are 2?)
TXT output file now looks like this:
Session Time: 2004-01-13T17:18:43
# of Shots: 5
Min: 2627.82816804897
Max: 2678.33341900837
Average: 2650.3905047287
Standard Deviation: 18.7458957133989
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
SOMEONE PLEASE CHECK MY MATH PLEASE PRETTY PLEASE

