LibMachine

Git Source

Functions

process

Routes the input products to functions handeling the specific machine type, returning the output products.

function process(MACHINE_TYPE _machineType, Product[] memory _inputs)
    internal
    view
    returns (Product[] memory _output);

Parameters

NameTypeDescription
_machineTypeMACHINE_TYPEThe type of the machine to process the products.
_inputsProduct[]An array of products to be processed.

Returns

NameTypeDescription
_outputProduct[]An array of resultant products after processing.

splitter

Splits a single input product into two output products of equal amount.

function splitter(Product memory _input) internal pure returns (Product[] memory _outputs);

Parameters

NameTypeDescription
_inputProductProduct to be processed.

Returns

NameTypeDescription
_outputsProduct[]An array containing two products

mixer

Mixes two input products, transforming them into a single output product based on a recipe

Amount returned will be the lowest of the two inputs

function mixer(Product[] memory _inputs) internal view returns (Product[] memory _outputs);

Parameters

NameTypeDescription
_inputsProduct[]An array of products

Returns

NameTypeDescription
_outputsProduct[]An array of products

defaultMachine

Processes a singleinput product through a specified machine type, creating one ot two output product.

function defaultMachine(MACHINE_TYPE _machineType, Product memory _input)
    internal
    view
    returns (Product[] memory _outputs);

Parameters

NameTypeDescription
_machineTypeMACHINE_TYPEThe type of machine to process the input product.
_inputProductInput product

Returns

NameTypeDescription
_outputsProduct[]An array of output products

getLowestAmountProduct

function getLowestAmountProduct(Product memory _A, Product memory _B)
    internal
    pure
    returns (Product memory _lowestAmountProduct);