<?php

    function placePic($posY, $posX, $pic, $size, $title) {
        echo '<div title="' . $title . '" style="position:absolute; top:' . $posY . 'px; left:' . $posX . 'px">';
        echo '<img src="pics/' . $pic . '" width="' . $size . '" height="' . $size . '">';
        echo '</div>';
    }

    function placePicXY($posY, $posX, $pic, $sizex, $sizey, $title) {
        echo '<div title="' . $title . '" style="position:absolute; top:' . $posY . 'px; left:' . $posX . 'px">';
        echo '<img src="pics/' . $pic . '" width="' . $sizex . '" height="' . $sizey . '">';
        echo '</div>';
    }

    function placePicWithLink($posY, $posX, $pic, $size, $title, $link) {
        echo '<a href="https://adei-katrin.kaas.kit.edu/adei/#module=graph&db_server=virtual&db_name=srctree&db_group=-3&control_group=-3&db_mask=all&experiment=-&window=86400&module=graph&virtual=srctree&srctree=' . $link . '" target="_blank">';
        placePic($posY, $posX, $pic, $size, $title);
        echo '</a>';
    }

    function placeText($posY, $posX, $text, $width, $size, $color) {
        echo '<div align="center" style="width:' . $width . 'px; position:absolute; top:' . $posY . 'px; left:' . $posX . 'px">';
        echo '<font size="' . $size . '" color="' . $color . '"><b>';
        echo $text;
        echo '</b></font></div>';
    }

    function placeTextWithLink($posY, $posX, $text, $width, $size, $color, $title, $link) {
        echo '<div title="' . $title . '" align="center" style="width:' . $width . 'px; position:absolute; top:' . $posY . 'px; left:' . $posX . 'px">';
        echo '<a href="https://adei-katrin.kaas.kit.edu/adei/#module=graph&db_server=virtual&db_name=srctree&db_group=-3&control_group=-3&db_mask=all&experiment=-&window=86400&module=graph&virtual=srctree&srctree=' . $link . '" target="_blank">';
        echo '<font size="' . $size . '" color="' . $color . '"><b>';
        echo $text;
        echo '</b></font></a></div>';
    }

    function placeTextLeftWithLink($posY, $posX, $text, $width, $size, $color, $title, $link) {
        echo '<div title="' . $title . '" align="left" style="width:' . $width . 'px; position:absolute; top:' . $posY . 'px; left:' . $posX . 'px">';
        echo '<a href="https://adei-katrin.kaas.kit.edu/adei/#module=graph&db_server=virtual&db_name=srctree&db_group=-3&control_group=-3&db_mask=all&experiment=-&window=86400&module=graph&virtual=srctree&srctree=' . $link . '" target="_blank">';
        echo '<font size="' . $size . '" color="' . $color . '"><b>';
        echo $text;
        echo '</b></font></a></div>';
    }

    function placeTextWithWebsiteLink($posY, $posX, $text, $width, $size, $color, $title, $link) {
        echo '<div title="' . $title . '" align="center" style="width:' . $width . 'px; position:absolute; top:' . $posY . 'px; left:' . $posX . 'px">';
        echo '<a href=' . $link . ' target="_blank">';
        echo '<font size="' . $size . '" color="' . $color . '"><b>';
        echo $text;
        echo '</b></font></a></div>';
    }

    function placeTextLeftWithWebsiteLink($posY, $posX, $text, $width, $size, $color, $title, $link) {
        echo '<div title="' . $title . '" align="left" style="width:' . $width . 'px; position:absolute; top:' . $posY . 'px; left:' . $posX . 'px">';
        echo '<a href=' . $link . ' target="_blank">';
        echo '<font size="' . $size . '" color="' . $color . '"><b>';
        echo $text;
        echo '</b></font></a></div>';
    }

    function placeBox($posY, $posX, $text, $width, $size, $color) {
        echo '<div align="center" style="background-color:' . $color . '; border-style:solid; border-width:2px; border-color:#000000; width:' . $width . 'px; position:absolute; top:' . $posY . 'px; left:' . $posX . 'px">';
        echo '<font size="' . $size . '" color=#000000><b>';
        echo $text;
        echo '</b></font></div>';
    }

    function placeBoxRight($posY, $posX, $text, $width, $size, $color) {
        echo '<div align="right" style="background-color:' . $color . '; border-style:solid; border-width:2px; border-color:#000000; width:' . $width . 'px; position:absolute; top:' . $posY . 'px; left:' . $posX . 'px">';
        echo '<font size="' . $size . '" color=#000000><b>';
        echo $text;
        echo '</b></font></div>';
    }

    function getValveStatus($value) {
        $value = decbin($value);
        $value = substr("00000000000", 0, 11 - strlen($value)) . $value;
        if (substr($value, 3, 1) == 1) return 1;
        else if (substr($value, 2, 1) == 1) return 0;
        else return -1;
    }

?>
