github.com/gkstretton/dark/services/goo@v0.0.0-20231114224855-2d1a2074d446/actor/executor/executor_collection.go (about)

     1  package executor
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/gkstretton/asol-protos/go/machinepb"
     7  )
     8  
     9  type collectionExecutor struct {
    10  	vialNo int
    11  	volUl  int
    12  }
    13  
    14  func NewCollectionExecutor(vialNo, volUl int) *collectionExecutor {
    15  	return &collectionExecutor{
    16  		vialNo,
    17  		volUl,
    18  	}
    19  }
    20  
    21  func (e *collectionExecutor) Preempt() {}
    22  
    23  func (e *collectionExecutor) PredictOutcome(state *machinepb.StateReport) *machinepb.StateReport {
    24  	state.CollectionRequest.Completed = true
    25  	state.CollectionRequest.RequestNumber++
    26  	state.CollectionRequest.VialNumber = uint64(e.vialNo)
    27  	state.CollectionRequest.VolumeUl = float32(e.volUl)
    28  
    29  	state.PipetteState.VolumeTargetUl = float32(e.volUl)
    30  	state.PipetteState.VialHeld = uint32(e.vialNo)
    31  	state.PipetteState.Spent = false
    32  
    33  	return state
    34  }
    35  
    36  func (e *collectionExecutor) Execute(c chan *machinepb.StateReport) {
    37  	collect(e.vialNo, e.volUl)
    38  	<-conditionWaiter(c, func(sr *machinepb.StateReport) bool {
    39  		return sr.CollectionRequest.Completed
    40  	})
    41  }
    42  
    43  func (e *collectionExecutor) String() string {
    44  	return fmt.Sprintf("collectionExecutor (vialNo: %d, volUl: %d)", e.vialNo, e.volUl)
    45  }