Differences
This shows you the differences between two versions of the page.
en:mervis-db:10-api [2017/07/13 16:36] m.chlupac |
en:mervis-db:10-api [2021/04/08 13:04] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== API ====== | ||
- | |||
- | Mervis DB supports open [[https:// | ||
- | * {{ : | ||
- | |||
- | Contact [[: | ||
- | |||
- | |||
- | ===== List of supported functions ===== | ||
- | |||
- | ^Function^Description| | ||
- | ^SaveData|Save one or multiple records from one or multiple variables| | ||
- | ^GetData/ | ||
- | ^GetParticularData/ | ||
- | ^GetVariables|Get the list of variables.| | ||
- | ^GetAllVariables| | | ||
- | ^ServerAlive|Obsolete| | ||
- | ^DeleteVariables| | | ||
- | ^DeleteData| | | ||
- | ^EnsureVariables| | | ||
- | ^GetTransformedData/ | ||
- | ^GetServerVersion| | | ||
- | ^GetVariableStats|Obsolete| | ||
- | ^GetVariableStatsAsync|Obsolete| | ||
- | ^CheckCredentials| | | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ===== Examples ===== | ||
- | |||
- | ==== C# ==== | ||
- | FIXME | ||
- | |||
- | ==== Matlab ==== | ||
- | |||
- | {{ : | ||
- | |||
- | === Supported functions === | ||
- | ^Function^Description| | ||
- | ^SaveData|Save one or multiple records from one or multiple variables| | ||
- | ^GetData|Read one or multiple records from one or multiple variables.| | ||
- | ^GetDataUnmerged|Read one or multiple records from one or multiple variables. Allow more setting options than GetData function| | ||
- | ^GetDataOrigin|Read data exactly as are stored in the database.| | ||
- | ^DeleteVariable|Delete entire variable or some certain interval.| | ||
- | ^GetRequiredTimestamp|Get time stamp depending on input options.| | ||
- | |||
- | === Toolbox === | ||
- | |||
- | |||
- | You need to import specialized toolbox to communicate with Mervis DB from Matlab: | ||
- | * {{ : | ||
- | * There is a help available for all toolbox functions. To display the help use: <code matlab> | ||
- | |||
- | === Code === | ||
- | |||
- | <code matlab MervisDB_GetData_example.m> | ||
- | mervisDB = MerbonDatabase(' | ||
- | |||
- | % Time interval definition | ||
- | from = localMatlab2utcMatlab(datenum(2017, | ||
- | to = localMatlab2utcMatlab(datenum(2017, | ||
- | samplePeriod = 5*60; % 5 minutes | ||
- | outputTimeZone = ' | ||
- | |||
- | % Specifying varibles to download | ||
- | varKeys1 = {' | ||
- | ' | ||
- | varKeys2 = {' | ||
- | ' | ||
- | |||
- | variable1 = MerbonDbVariable(varKeys1); | ||
- | variable2 = MerbonDbVariable(varKeys2); | ||
- | |||
- | arrayOfVarKeys = [variable1; variable2]; % array of MerbonDbVariables objects | ||
- | |||
- | % help for function getData | ||
- | help MerbonDatabase.getData | ||
- | |||
- | % Download required data | ||
- | [data, time] = db.getData(arrayOfVarKeys, | ||
- | |||
- | % Get all variables with defined keys | ||
- | allVaribales = db.getAllVars(varKeys1);</ | ||
- | |||
- | |||
- | ==== PHP ==== | ||
- | |||
- | |||
- | |||
- | <code php MervisDB_GetData_example.php><? | ||
- | /* | ||
- | Mervis DB PHP example - getdata | ||
- | */ | ||
- | try { | ||
- | | ||
- | $soapClient = new SoapClient(' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | )); | ||
- | $soapClient-> | ||
- | | ||
- | $credentials = array( | ||
- | ' | ||
- | ' | ||
- | ); | ||
- | | ||
- | $utcTZ | ||
- | $utcFrom = new DateTime(' | ||
- | $utcTo | ||
- | | ||
- | $valOffset = 0; | ||
- | $valCount | ||
- | $varOffset = 0; | ||
- | $varCount | ||
- | | ||
- | | ||
- | $variablesKey = array( | ||
- | array( | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ), | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ) | ||
- | ), | ||
- | array( | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ), | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ) | ||
- | ) | ||
- | ); | ||
- | | ||
- | | ||
- | echo " | ||
- | | ||
- | $counter = 0; | ||
- | | ||
- | do { | ||
- | $response | ||
- | $valOffset = 0; | ||
- | do { | ||
- | $response | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | )); | ||
- | $valOffset = $response-> | ||
- | $varOffset = $response-> | ||
- | | ||
- | | ||
- | foreach ($response-> | ||
- | foreach ($varArray-> | ||
- | { | ||
- | if ($kvp-> | ||
- | echo " | ||
- | $counter++; | ||
- | } | ||
- | } | ||
- | | ||
- | | ||
- | if (isset($varArray-> | ||
- | foreach ($varArray-> | ||
- | echo " | ||
- | } | ||
- | } else { | ||
- | echo " | ||
- | } | ||
- | | ||
- | } | ||
- | | ||
- | } while ($response-> | ||
- | } while ($response-> | ||
- | } | ||
- | catch (Exception $e) { | ||
- | print_r($e); | ||
- | } | ||
- | ?></ | ||
- | |||