<?php

include_once(dirname(__FILE__).'/Measure.php');
include_once(dirname(__FILE__).'/Graph.php');
include_once(dirname(__FILE__).'/Main.php');

class ModuleTimeMeasure extends Module
{
  function __construct(System $System)
  {
    parent::__construct($System);
    $this->Name = 'TimeMeasure';
    $this->Version = '1.0';
    $this->Creator = 'Chronos';
    $this->License = 'GNU/GPLv3';
    $this->Description = 'Time measure of custom values, char';
    $this->Dependencies = array(ModuleUser::GetName());
    $this->Models = array(Measure::GetClassName());
  }

  function DoStart(): void
  {
    $this->System->RegisterPage(['grafy'], 'PageMeasure');
    $this->System->RegisterPage(['grafy', 'graf.png'], 'PageGraph');
    $this->System->RegisterPage(['grafy', 'add.php'], 'PageMeasureAddValue');
    $this->System->FormManager->RegisterClass('Measure', array(
      'Title' => 'Měření',
      'Table' => 'Measure',
      'Items' => array(
        'Name' => array('Type' => 'String', 'Caption' => 'Zkratka', 'Default' => 'measure'),
        'Title' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => 'Měření'),
        'Description' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => 'Měření veličiny'),
        'Unit' => array('Type' => 'String', 'Caption' => 'Jednotka', 'Default' => ''),
        'Continuity' => array('Type' => 'Boolean', 'Caption' => 'Spojitost', 'Default' => '0'),
        'Period' => array('Type' => 'Integer', 'Caption' => 'Perioda měření', 'Default' => '60'),
        'PermissionAdd' => array('Type' => 'String', 'Caption' => 'Oprávnění k měření', 'Default' => 'localhost.localdomain'),
        'PermissionView' => array('Type' => 'String', 'Caption' => 'Oprávnění k prohlížení', 'Default' => 'all'),
        'Enabled' => array('Type' => 'Boolean', 'Caption' => 'Povolení', 'Default' => '1'),
        'DataType' => array('Type' => 'String', 'Caption' => 'Typ datových položek', 'Default' => 'int'),
        'DataTable' => array('Type' => 'String', 'Caption' => 'Tabulka měřených dat', 'Default' => 'data'),
      ),
    ));
  }
}
