Skip to content

Commit

Permalink
Merge pull request #138 from MrPig91/MadMaxPatchwork
Browse files Browse the repository at this point in the history
Mad max patchwork
  • Loading branch information
MrPig91 authored Jun 29, 2021
2 parents 79d7d63 + 28c0271 commit 12bdb17
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 30 deletions.
6 changes: 4 additions & 2 deletions PSChiaPlotter/Private/New-UIRunspace.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,14 @@ function New-UIRunspace{
$UIHash.MainWindow.add_Closing({
Get-childItem -Path $DataHash.PrivateFunctions -File | ForEach-Object {Import-Module $_.FullName}
# end session and close runspace on window exit
$DialogResult = Show-Messagebox -Text "Closing this window will end all Chia processes" -Title "Warning!" -Icon Warning -Buttons OKCancel
$DialogResult = Show-Messagebox -Text "Do you want to end all chia plotting processes?`n`nNote - PSChiaPlotter will NOT re-load these processes upon startup!" -Title "Warning!" -Icon Warning -Buttons YesNoCancel
if ($DialogResult -eq [System.Windows.MessageBoxResult]::Cancel) {
$PSItem.Cancel = $true
}
elseif ($DialogResult -eq [System.Windows.MessageBoxResult]::Yes){
Stop-PSChiaPlotter -EndChiaProcess
}
else{
#$ScriptsHash.QueueHandle.EndInvoke($QueueHandle)
Stop-PSChiaPlotter
}
})
Expand Down
20 changes: 12 additions & 8 deletions PSChiaPlotter/Private/Stop-PSChiaPlotter.ps1
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
function Stop-PSChiaPlotter{
[CmdletBinding()]
param()
param(
[switch]$EndChiaProcess
)

$RunningQueues = $DataHash.MainViewModel.AllQueues | Where-Object Status -eq "Running"
foreach ($Queue in $RunningQueues){
$queue.Status = "Paused"
}

$ALLChiaProcesses = $DataHash.MainViewModel.CurrentRuns
foreach ($run in $ALLChiaProcesses){
try{
Stop-Process $run.ProcessID
}
catch{
Write-PSChiaPlotterLog -LogType ERROR -ErrorObject $_
if ($EndChiaProcess){
$ALLChiaProcesses = $DataHash.MainViewModel.CurrentRuns
foreach ($run in $ALLChiaProcesses){
try{
Stop-Process $run.ProcessID
}
catch{
Write-PSChiaPlotterLog -LogType ERROR -ErrorObject $_
}
}
}
$RunningRunspaces = $DataHash.Runspaces
Expand Down
68 changes: 50 additions & 18 deletions PSChiaPlotter/Public/Get-ChiaPlottingStatistic.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,55 @@ function Get-ChiaPlottingStatistic {
Process{
foreach ($log in $path){
if (Test-Path $log){
$Content = Get-Content -Path $log | Select-String "ID: ","Time for phase","Total time","Plot size","Buffer size","threads of stripe","Copy time","Copied final file from","Starting plotting progress into temporary dirs" | foreach {$_.ToString()}
foreach ($line in $Content){
switch -Wildcard ($line){
"ID: *" {$PlotID = $line.Split(' ') | select -Skip 1 -First 1}
"Plot size*" {$PlotSize = $line.split(' ') | select -Skip 3} #using select for these since indexing will error if empty
"Buffer Size*" {$BufferSize = ($line.Split(' ') | select -Skip 3).split("M") | select -First 1}
"*threads*" {$ThreadCount = $line.split(' ') | select -First 1 -Skip 1}
"*phase 1*" {$Phase_1 = $line.Split(' ') | select -First 1 -Skip 5}
"*phase 2*" {$Phase_2 = $line.Split(' ') | select -First 1 -Skip 5}
"*phase 3*" {$Phase_3 = $line.Split(' ') | select -First 1 -Skip 5}
"*phase 4*" {$phase_4 = $line.Split(' ') | select -First 1 -Skip 5}
"Total time*" {$TotalTime = $line.Split(' ') | select -First 1 -Skip 3}
"Copy time*" {$CopyTime = $line.Split(' ') | select -First 1 -Skip 3}
"Starting plotting progress into temporary dirs*" {$TempDrive = ($line.Split(' ') | select -First 1 -Skip 6).Split('\') | select -First 1 }
"Copied final file from*" {$FinalDrive = ($line.Split(' ') | select -First 1 -Skip 6).Split('\').Replace('"', '') | select -First 1}
default {Write-Information "Could not match line: $line"}
}
$Content = Get-Content -Path $log
$FirstLine = $Content | Select-Object -First 1
if ($FirstLine -like "Multi-threaded pipelined*"){
#Madmax log file
foreach ($madmaxline in $Content){
switch -Wildcard ($madmaxline){
"Plot Name:*" {
$PlotID = $madmaxline.Split("-") | Select-Object -Last 1
$PlotSize = ($madmaxline.Split("-") | Select-Object -Skip 1 -First 1).TrimStart('k')
}
"*Threads:*" {$ThreadCount = $madmaxline -split ": " | Select-Object -Last 1}
"Phase 1*" {$Phase_1 = $madmaxline.Split(' ')[3]}
"Phase 2*" {$Phase_2 = $madmaxline.Split(' ')[3]}
"Phase 3*" {$Phase_3 = $madmaxline.Split(' ')[3]}
"Phase 4*" {$Phase_4 = $madmaxline.Split(' ')[3]}
"Total*" {$TotalTime = $madmaxline.Split(' ')[5]}
"Copy*" {$CopyTime = $madmaxline.Split(',')[1].Split(' ')[2]}
"Working Directory:*" {$TempDrive = ($madmaxline -split ": " | Select-Object -Last 1).Trim().Split('\') | select -First 1}
"Working Directory 2:*" {$SecondTempDir = ($madmaxline -split ": " | Select-Object -Last 1).Split('\') | select -First 1}
"Final Directory:*" {$FinalDrive = ($madmaxline -split ": " | Select-Object -Last 1).Split('\') | select -First 1}
default {Write-Information "Could not match line: $line"}
}
} #foreach
$BufferSize = 0
}
else{
#OG log file
$ImportantLines = @("ID: ","Time for phase","Total time","Plot size","Buffer size","threads of stripe","Copy time","Copied final file from","Starting plotting progress into temporary dirs")
$ContentLines = $Content | Select-String -SimpleMatch $ImportantLines | ForEach-Object {$_.ToString()}
foreach ($line in $ContentLines){
switch -Wildcard ($line){
"ID: *" {$PlotID = $line.Split(' ') | select -Skip 1 -First 1}
"Plot size*" {$PlotSize = $line.split(' ') | select -Skip 3} #using select for these since indexing will error if empty
"Buffer Size*" {$BufferSize = ($line.Split(' ') | select -Skip 3).split("M") | select -First 1}
"*threads*" {$ThreadCount = $line.split(' ') | select -First 1 -Skip 1}
"*phase 1*" {$Phase_1 = $line.Split(' ') | select -First 1 -Skip 5}
"*phase 2*" {$Phase_2 = $line.Split(' ') | select -First 1 -Skip 5}
"*phase 3*" {$Phase_3 = $line.Split(' ') | select -First 1 -Skip 5}
"*phase 4*" {$phase_4 = $line.Split(' ') | select -First 1 -Skip 5}
"Total time*" {$TotalTime = $line.Split(' ') | select -First 1 -Skip 3}
"Copy time*" {$CopyTime = $line.Split(' ') | select -First 1 -Skip 3}
"Starting plotting progress into temporary dirs*" {$TempDrive = ($line.Split(' ') | select -First 1 -Skip 6).Split('\') | select -First 1 }
"Copied final file from*" {$FinalDrive = ($line.Split(' ') | select -First 1 -Skip 6).Split('\').Replace('"', '') | select -First 1}
default {Write-Information "Could not match line: $line"}
}
} #foreach
$SecondTempDir = $null
} #if/else

[PSCustomObject]@{
PSTypeName = "PSChiaPlotter.ChiaPlottingStatistic"
PlotId = $PlotID
Expand All @@ -42,8 +73,9 @@ function Get-ChiaPlottingStatistic {
"Time_Started" = (Get-Item -Path $log).CreationTime
"Temp_drive" = $TempDrive
"Final_drive" = $FinalDrive
"SecondTemp_Directory" = $SecondTempDir
}
Clear-Variable -Name "PlotID","PlotSize","BufferSize","ThreadCount","Phase_1","Phase_2","Phase_3","Phase_4","TotalTime","CopyTime","FinalDrive","TempDrive" -ErrorAction SilentlyContinue
Clear-Variable -Name "PlotID","PlotSize","BufferSize","ThreadCount","Phase_1","Phase_2","Phase_3","Phase_4","TotalTime","CopyTime","FinalDrive","TempDrive","FirstLine","SecondTempDir" -ErrorAction SilentlyContinue
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions PSChiaPlotter/WPFWindows/NewJobWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Window
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Expand Down Expand Up @@ -656,14 +656,15 @@
<Label Content="Pool Public Key:" HorizontalAlignment="Right" Grid.Column="1" Grid.Row="3" />
<CheckBox Content="Alternative Plotter Path: " IsThreeState="False"
Grid.Column="1" Grid.Row="4"
x:Name="AlternativePlotterCheckbox"
IsChecked="{Binding Path=NewChiaJob.InitialChiaParameters.AlternativePlotterEnabled}"
HorizontalAlignment="Right" VerticalAlignment="Center"
ToolTip="The full path to the alternative plotter .exe file" />

<TextBox x:Name="PoolContractAddressTextBox" Grid.Row="1" Grid.Column="2" Text="{Binding Path=NewChiaJob.InitialChiaParameters.PoolContractAddress}" VerticalAlignment="Center" HorizontalContentAlignment="Left" IsEnabled="{Binding ElementName=PoolContractAddressCheckbox, Path=IsChecked}"/>
<TextBox x:Name="FarmerPublicKeyTextBox" Grid.Row="2" Grid.Column="2" Text="{Binding Path=NewChiaJob.InitialChiaParameters.FarmerPublicKey}" VerticalAlignment="Center" HorizontalContentAlignment="Left"/>
<TextBox x:Name="PoolPublicKeyTextBox" Grid.Row="3" Grid.Column="2" Text="{Binding Path=NewChiaJob.InitialChiaParameters.PoolPublicKey}" VerticalAlignment="Center" HorizontalContentAlignment="Left" Style="{StaticResource PoolKey}"/>
<TextBox x:Name="AlternativePlotterTextBox" Grid.Row="4" Grid.Column="2" Text="{Binding Path=NewChiaJob.InitialChiaParameters.AlternativePlotterPath}" VerticalAlignment="Center" HorizontalContentAlignment="Left" />
<TextBox x:Name="AlternativePlotterTextBox" Grid.Row="4" Grid.Column="2" Text="{Binding Path=NewChiaJob.InitialChiaParameters.AlternativePlotterPath}" VerticalAlignment="Center" HorizontalContentAlignment="Left" IsEnabled="{Binding ElementName=AlternativePlotterCheckbox, Path=IsChecked}" />
</Grid>
</GroupBox>
</Grid>
Expand Down

0 comments on commit 12bdb17

Please sign in to comment.