Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from mll-lab/fixes_for_handling
Browse files Browse the repository at this point in the history
feat: Add predefined classes that implement `Rack`- and `LiquidClass`…
  • Loading branch information
simbig authored Jul 25, 2022
2 parents 58be197 + 8738be4 commit 09e4ba9
Show file tree
Hide file tree
Showing 27 changed files with 360 additions and 168 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## v2.0.0

### Added

- Add predefined classes that implement `Rack`- and `LiquidClass`-interface
- Add `fileName`-method on `TecanProtocol`

### Breaking

- delete superfluous semicolon after TipMask
- `PositionLocation` returns `$rack->name`
- `BarcodeLocation` does not return `$rack->name`
- Move `Rack`- and `LiquidClass`-interface to subdirectory
- Change signature of `TransferWithAutoWash`-class

## v1.1.0

### Added
Expand Down
7 changes: 6 additions & 1 deletion src/Tecan/BasicCommands/Aspirate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

namespace Mll\LiquidHandlingRobotics\Tecan\BasicCommands;

use Mll\LiquidHandlingRobotics\Tecan\LiquidClass;
use Mll\LiquidHandlingRobotics\Tecan\LiquidClass\LiquidClass;
use Mll\LiquidHandlingRobotics\Tecan\Location\Location;

final class Aspirate extends BasicPipettingActionCommand implements Command
{
/**
* @param float $volume Floating point values are accepted and do not cause an error,
* but they will be rounded before being used. In such cases, it is recommended to use
* integer calculations to avoid unexpected results.
*/
public function __construct(float $volume, Location $location, LiquidClass $liquidClass)
{
$this->volume = $volume;
Expand Down
6 changes: 3 additions & 3 deletions src/Tecan/BasicCommands/BasicPipettingActionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mll\LiquidHandlingRobotics\Tecan\BasicCommands;

use Mll\LiquidHandlingRobotics\Tecan\LiquidClass;
use Mll\LiquidHandlingRobotics\Tecan\LiquidClass\LiquidClass;
use Mll\LiquidHandlingRobotics\Tecan\Location\Location;

abstract class BasicPipettingActionCommand implements PipettingActionCommand
Expand All @@ -17,7 +17,7 @@ abstract class BasicPipettingActionCommand implements PipettingActionCommand

abstract public static function commandLetter(): string;

public function toString(): string
public function formatToString(): string
{
return
static::commandLetter() . ';'
Expand All @@ -29,7 +29,7 @@ public function toString(): string
. $this->volume . ';'
. $this->liquidClass->name() . ';'
. ';' // tipType
. $this->getTipMask() . ';'
. $this->getTipMask()
;
}

Expand Down
7 changes: 1 addition & 6 deletions src/Tecan/BasicCommands/BreakCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@

final class BreakCommand implements Command
{
public static function commandLetter(): string
public function formatToString(): string
{
return 'B;';
}

public function toString(): string
{
return static::commandLetter();
}
}
4 changes: 1 addition & 3 deletions src/Tecan/BasicCommands/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@

interface Command
{
public static function commandLetter(): string;

public function toString(): string;
public function formatToString(): string;
}
9 changes: 7 additions & 2 deletions src/Tecan/BasicCommands/Dispense.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

namespace Mll\LiquidHandlingRobotics\Tecan\BasicCommands;

use Mll\LiquidHandlingRobotics\Tecan\LiquidClass;
use Mll\LiquidHandlingRobotics\Tecan\LiquidClass\LiquidClass;
use Mll\LiquidHandlingRobotics\Tecan\Location\Location;

final class Dispense extends BasicPipettingActionCommand implements Command
{
public function __construct(int $volume, Location $location, LiquidClass $liquidClass)
/**
* @param float $volume Floating point values are accepted and do not cause an error,
* but they will be rounded before being used. In such cases, it is recommended to use
* integer calculations to avoid unexpected results.
*/
public function __construct(float $volume, Location $location, LiquidClass $liquidClass)
{
$this->volume = $volume;
$this->location = $location;
Expand Down
7 changes: 1 addition & 6 deletions src/Tecan/BasicCommands/Wash.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@

final class Wash implements Command
{
public static function commandLetter(): string
public function formatToString(): string
{
return 'W;';
}

public function toString(): string
{
return static::commandLetter();
}
}
22 changes: 10 additions & 12 deletions src/Tecan/CustomCommand/TransferWithAutoWash.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Mll\LiquidHandlingRobotics\Tecan\BasicCommands\Aspirate;
use Mll\LiquidHandlingRobotics\Tecan\BasicCommands\Dispense;
use Mll\LiquidHandlingRobotics\Tecan\BasicCommands\PipettingActionCommand;
use Mll\LiquidHandlingRobotics\Tecan\BasicCommands\Wash;
use Mll\LiquidHandlingRobotics\Tecan\LiquidClass\LiquidClass;
use Mll\LiquidHandlingRobotics\Tecan\Location\Location;
use Mll\LiquidHandlingRobotics\Tecan\TecanProtocol;

final class TransferWithAutoWash implements PipettingActionCommand
Expand All @@ -13,25 +16,20 @@ final class TransferWithAutoWash implements PipettingActionCommand

private Dispense $dispense;

public function __construct(Aspirate $aspirate, Dispense $dispense)
public function __construct(float $volume, LiquidClass $liquidClass, Location $aspirateLocation, Location $dispenseLocation)
{
$this->aspirate = $aspirate;
$this->dispense = $dispense;
$this->aspirate = new Aspirate($volume, $aspirateLocation, $liquidClass);
$this->dispense = new Dispense($volume, $dispenseLocation, $liquidClass);
}

public static function commandLetter(): string
{
return 'W;';
}

public function toString(): string
public function formatToString(): string
{
return
$this->aspirate->toString()
$this->aspirate->formatToString()
. TecanProtocol::WINDOWS_NEW_LINE
. $this->dispense->toString()
. $this->dispense->formatToString()
. TecanProtocol::WINDOWS_NEW_LINE
. static::commandLetter();
. (new Wash())->formatToString();
}

public function setTipMask(int $tipMask): void
Expand Down
18 changes: 18 additions & 0 deletions src/Tecan/LiquidClass/CustomLiquidClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php declare(strict_types=1);

namespace Mll\LiquidHandlingRobotics\Tecan\LiquidClass;

final class CustomLiquidClass implements LiquidClass
{
private string $name;

public function __construct(string $name)
{
$this->name = $name;
}

public function name(): string
{
return $this->name;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);

namespace Mll\LiquidHandlingRobotics\Tecan;
namespace Mll\LiquidHandlingRobotics\Tecan\LiquidClass;

interface LiquidClass
{
Expand Down
28 changes: 28 additions & 0 deletions src/Tecan/LiquidClass/MllLiquidClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php declare(strict_types=1);

namespace Mll\LiquidHandlingRobotics\Tecan\LiquidClass;

use BenSampo\Enum\Enum;

/**
* @method static static DNA_DILUTION()
* @method static static DNA_DILUTION_WATER()
* @method static static TRANSFER_PCR_PRODUKT()
* @method static static TRANSFER_MASTERMIX_MP()
* @method static static TRANSFER_TEMPLATE()
*/
final class MllLiquidClass extends Enum implements LiquidClass
{
public const DNA_DILUTION = 'DNA_Dilution';
public const DNA_DILUTION_WATER = 'DNA_Dilution_Water';
public const TRANSFER_PCR_PRODUKT = 'Transfer_PCR_Produkt';
public const TRANSFER_MASTERMIX_MP = 'Transfer_Mastermix_MP';
public const TRANSFER_TEMPLATE = 'Transfer_Template'; // DNA-templates and BUFFER!

public function name(): string
{
assert(is_string($this->value));

return $this->value;
}
}
6 changes: 3 additions & 3 deletions src/Tecan/Location/BarcodeLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mll\LiquidHandlingRobotics\Tecan\Location;

use Mll\LiquidHandlingRobotics\Tecan\Rack;
use Mll\LiquidHandlingRobotics\Tecan\Rack\Rack;

final class BarcodeLocation implements Location
{
Expand All @@ -26,9 +26,9 @@ public function position(): ?string
return null;
}

public function rackName(): string
public function rackName(): ?string
{
return $this->rack->name();
return null;
}

public function rackType(): string
Expand Down
4 changes: 2 additions & 2 deletions src/Tecan/Location/PositionLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mll\LiquidHandlingRobotics\Tecan\Location;

use Mll\LiquidHandlingRobotics\Tecan\Rack;
use Mll\LiquidHandlingRobotics\Tecan\Rack\Rack;

final class PositionLocation implements Location
{
Expand All @@ -28,7 +28,7 @@ public function position(): string

public function rackName(): ?string
{
return null;
return $this->rack->name();
}

public function rackType(): string
Expand Down
26 changes: 26 additions & 0 deletions src/Tecan/Rack/CustomRack.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php declare(strict_types=1);

namespace Mll\LiquidHandlingRobotics\Tecan\Rack;

final class CustomRack implements Rack
{
private string $name;

private string $type;

public function __construct(string $name, string $type)
{
$this->type = $type;
$this->name = $name;
}

public function name(): string
{
return $this->name;
}

public function type(): string
{
return $this->type;
}
}
63 changes: 63 additions & 0 deletions src/Tecan/Rack/MllLabWareRack.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php declare(strict_types=1);

namespace Mll\LiquidHandlingRobotics\Tecan\Rack;

use BenSampo\Enum\Enum;
use Exception;

/**
* @method static static A()
* @method static static MP_CDNA()
* @method static static MP_SAMPLE()
* @method static static MP_WATER()
* @method static static FLUID_X()
* @method static static MM()
* @method static static DEST_LC()
* @method static static DEST_PCR()
* @method static static DEST_TAQMAN()
*/
final class MllLabWareRack extends Enum implements Rack
{
public const A = 'A';
public const MP_CDNA = 'MPCDNA';
public const MP_SAMPLE = 'MPSample';
public const MP_WATER = 'MPWasser';
public const FLUID_X = 'FluidX';
public const MM = 'MM';
public const DEST_LC = 'DestLC';
public const DEST_PCR = 'DestPCR';
public const DEST_TAQMAN = 'DestTaqMan';

public function type(): string
{
switch ($this->value) {
case self::A:
return 'Eppis 24x0.5 ml Cooled';
case self::MP_CDNA:
return 'MP cDNA';
case self::MP_SAMPLE:
return 'MP Microplate';
case self::MP_WATER:
return 'Trough 300ml MCA Portrait';
case self::FLUID_X:
return '96FluidX';
case self::MM:
return 'Eppis 32x1.5 ml Cooled';
case self::DEST_LC:
return '96 Well MP LightCycler480';
case self::DEST_PCR:
return '96 Well PCR ABI semi-skirted';
case self::DEST_TAQMAN:
return '96 Well PCR TaqMan';
default:
throw new Exception('Type not defined for ' . $this->value);
}
}

public function name(): string
{
assert(is_string($this->value));

return $this->value;
}
}
2 changes: 1 addition & 1 deletion src/Tecan/Rack.php → src/Tecan/Rack/Rack.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);

namespace Mll\LiquidHandlingRobotics\Tecan;
namespace Mll\LiquidHandlingRobotics\Tecan\Rack;

interface Rack
{
Expand Down
Loading

0 comments on commit 09e4ba9

Please sign in to comment.