Initial commit
This commit is contained in:
70
src/Automata/State.php
Normal file
70
src/Automata/State.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Automata;
|
||||
|
||||
use Automata\Modes\G\DimensionMode;
|
||||
use Automata\Modes\G\PlaneSelection;
|
||||
use Automata\Modes\G\RadiusCompensation;
|
||||
use Automata\Modes\G\TraverseMode;
|
||||
use Automata\Modes\G\WorkCycle;
|
||||
use Automata\Modes\M\CoolantMode;
|
||||
use Automata\Modes\M\SpindleMode;
|
||||
use Automata\Modes\M\TableClampingMode;
|
||||
use Program\Word;
|
||||
|
||||
class State
|
||||
{
|
||||
public Registers $registers;
|
||||
// G
|
||||
public TraverseMode $traverseMode;
|
||||
public PlaneSelection $planeSelection;
|
||||
public RadiusCompensation $radiusCompensation;
|
||||
public DimensionMode $dimensionMode;
|
||||
public WorkCycle $workCycleSelection;
|
||||
// M
|
||||
public CoolantMode $coolantMode;
|
||||
public SpindleMode $spindleMode;
|
||||
public TableClampingMode $tableClamping;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->registers = new Registers();
|
||||
$this->traverseMode = new TraverseMode(0);
|
||||
$this->planeSelection = new PlaneSelection(17);
|
||||
$this->radiusCompensation = new RadiusCompensation(40);
|
||||
$this->dimensionMode = new DimensionMode(90);
|
||||
$this->workCycleSelection = new WorkCycle(0);
|
||||
|
||||
$this->coolantMode = new CoolantMode(9);
|
||||
$this->spindleMode = new SpindleMode(5);
|
||||
$this->tableClamping = new TableClampingMode(10);
|
||||
}
|
||||
|
||||
|
||||
public function apply(Word $word): void
|
||||
{
|
||||
if ($word->register === 'G') {
|
||||
$this->traverseMode->apply($word->value);
|
||||
$this->planeSelection->apply($word->value);
|
||||
$this->radiusCompensation->apply($word->value);
|
||||
$this->dimensionMode->apply($word->value);
|
||||
$this->workCycleSelection->apply($word->value);
|
||||
|
||||
// TODO Handle other G commands
|
||||
return;
|
||||
}
|
||||
if ($word->register === 'M') {
|
||||
$this->coolantMode->apply($word->value);
|
||||
$this->spindleMode->apply($word->value);
|
||||
$this->tableClamping->apply($word->value);
|
||||
|
||||
// TODO Handle other M commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (property_exists($this->registers, $word->register)) {
|
||||
$this->registers->{$word->register} = $word->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user