-
Notifications
You must be signed in to change notification settings - Fork 0
/
ControlSlot.ps1
39 lines (34 loc) · 968 Bytes
/
ControlSlot.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[Int16]
$Mode,
[Parameter(Mandatory=$true)]
[String]
$Slots
)
#Ensure this module is installed
Import-Module newtonsoft.json
#Ensure this module is in the same directory
Import-Module ".\Folding@Home.psm1"
#Connect to local instance
$session = Connect-FoldingInstance -addr "127.0.0.1" -port 36330
if($session.Connected -eq $false){
#Break; connection failed
Exit 233
}
$status = Convert-StatusModeEnumToString($Mode)
if($status -ne ""){
foreach($slot in $Slots.Split(",")){
$cmd = $status + " " + $slot
#Send status command
Send-Command -session $session -cmd $cmd
#Sleep to give time for processing
Start-Sleep -Seconds 1
}
}else{
#Break; invalid mode parameter passed by user
Exit 87
}
#Dispose of used resources, disconnect from the instance
Disconnect-FoldingInstance($session)