Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:mervis-db:10-api [2017/07/13 17:22]
m.kulvejt
en:mervis-db:10-api [2021/04/08 13:04]
Line 1: Line 1:
-====== API ====== 
- 
-Mervis DB supports open [[https://en.wikipedia.org/wiki/SOAP|SOAP]] API described by this WSDL: 
- 
-  * {{:en:mervis-db:mervisdb_wsdl-2017-07-12.xml|mervisdb_wsdl-2017-07-12.xml}} 
- 
-Contact [[:en:help:support|technical support]] for other non-public APIs that can be used for your projects. 
- 
-===== List of supported functions ===== 
- 
-^Function^Description| 
-^SaveData|Save one or multiple records from one or multiple variables| 
-^GetData/GetDataAsync|Read one or multiple records from one or multiple variables.| 
-^GetParticularData/GetParticulatDataAsync|Optimized method for reading of "special" data - last value, last value after certain time moment etc.| 
-^GetVariables|Get the list of variables.| 
-^GetAllVariables| | 
-^ServerAlive|Obsolete| 
-^DeleteVariables| | 
-^DeleteData| | 
-^EnsureVariables| | 
-^GetTransformedData/GetTransformedDataAsync| | 
-^GetServerVersion| | 
-^GetVariableStats|Obsolete| 
-^GetVariableStatsAsync|Obsolete| 
-^CheckCredentials| | 
- 
-===== Examples ===== 
- 
-==== C# ==== 
- 
-<code csharp> 
- 
-</code> 
- 
-==== Matlab ==== 
- 
-{{  :en:mervis-db:mervisdb_matlab_api.png?direct&800  }} 
- 
-=== 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: 
- 
-  * {{:en:mervis-db:mervisdb_matlabtoolbox.zip|mervisdb_matlabtoolbox.zip}}. 
-  * There is a help available for all toolbox functions. To display the help use: 
- 
-<code matlab> 
-help MerbonDatabase.supported_function_name 
-</code> 
- 
-=== Code === 
- 
-MervisDB_GetData_example.m 
- 
-<code matlab> 
-% Instance of Mervis DB 
-mervisDB = MerbonDatabase('username', 'password', 'dbUrl'); 
- 
-% Time interval definition 
-from = localMatlab2utcMatlab(datenum(2017, 1, 1)); %1.1.2017 in utc 
-to = localMatlab2utcMatlab(datenum(2017, 31, 1)); %31.1.2017 in utc 
-samplePeriod = 5*60; % 5 minutes 
-outputTimeZone = 'Local'; % possible 'Local' or  'Utc' parameter; 
- 
-% Specifying varibles to download 
-varKeys1 = {'DPGuid', '338E2882-D72B-4D17-A241-73E8BC30F458';... 
-            'StationName', 'XXXXXXX'}; % Keys definition of first variable 
-varKeys2 = {'DPGuid', 'CC80211D-3D29-4CC2-91A2-F69483D566B5';... 
-            'StationName', 'YYYYYYY'}; % Keys definition of second variable 
- 
-variable1 = MerbonDbVariable(varKeys1); % Create MerbonDbVariable object from defined keys 
-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, from, to, samplePeriod, outputTimeZone); 
- 
-% Get all variables with defined keys 
-allVaribales = db.getAllVars(varKeys1); 
-</code> 
- 
-==== PHP ==== 
- 
-MervisDB_GetData_example.php 
- 
-<code php> 
-<?php 
-/* 
-Mervis DB PHP example - getdata 
-*/ 
-try { 
- 
-  $soapClient = new SoapClient('./wsdl/singlewsdl.xml', array( 
-    'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, 
-    'trace' => 0, 
-    'features' => SOAP_SINGLE_ELEMENT_ARRAYS 
-  )); 
-  $soapClient->__setLocation('http://localhost:9876/RcWareDbAccess'); 
- 
-  $credentials = array( 
-    'Name' => 'XXXXXXX', 
-    'Password' => 'YYYYYYY' 
-  ); 
- 
-  $utcTZ   = new DateTimezone('UTC'); //all time realted values are expected in UTC 
-  $utcFrom = new DateTime('-120minutes', $utcTZ); // 
-  $utcTo   = new DateTime('now', $utcTZ); // 
- 
-  $valOffset = 0; 
-  $valCount  = 20; //how many values should be returned in one request at most. Recommended value: 5000 
-  $varOffset = 0; 
-  $varCount  = 4; //how many variable should be returned in on request at most 
- 
-  $variablesKey = array( 
-    array( 
-      array( 
-        'IsKey' => true, 
-        'Key' => 'DPGuid', 
-        'Value' => '338E2882-D72B-4D17-A241-73E8BC30F458' 
-      ), 
-      array( 
-        'IsKey' => true, 
-        'Key' => 'StationName', 
-        'Value' => 'AAAAAAAAAA' 
-      ) 
-    ), 
-    array( 
-      array( 
-        'IsKey' => true, 
-        'Key' => 'DPGuid', 
-        'Value' => 'CC80211D-3D29-4CC2-91A2-F69483D566B5' 
-      ), 
-      array( 
-        'IsKey' => true, 
-        'Key' => 'StationName', 
-        'Value' => 'BBBBBBB' 
-      ) 
-    ) 
-  ); 
- 
-  echo "Reading values from: {$utcFrom->format('c')} to: {$utcTo->format('c')}\n\n"; 
- 
-  $counter = 0; 
- 
-  do { 
-    $response  = null; 
-    $valOffset = 0; 
-    do { 
-      $response  = $soapClient->GetData(array( 
-        'credentials' => $credentials, 
-        'variablesKey' => $variablesKey, 
-        'utcFrom' => $utcFrom->format('Y-m-d\TH:i:s\Z'), 
-        'utcTo' => $utcTo->format('Y-m-d\TH:i:s\Z'), 
-        'valueOffset' => $valOffset, 
-        'valueCount' => $valCount, 
-        'variableCount' => $varCount, 
-        'variableOffset' => $varOffset 
-      )); 
-      $valOffset = $response->nextValueOffset; 
-      $varOffset = $response->nextVariableOffset; 
- 
-      foreach ($response->GetDataResult->Mvr as $varArray) { 
-        foreach ($varArray->Keys->KeyValuePair as $kvp) //the set of keys depends on the source of the data 
-          { 
-          if ($kvp->Key == 'DPName') { 
-            echo "\n{$kvp->Value}\n"; 
-            $counter++; 
-          } 
-        } 
- 
-        if (isset($varArray->Vals->I)) { 
-          foreach ($varArray->Vals->I as $val) { 
-            echo "  t: {$val->Ts}   Interval: {$val->Ivl}  {$valOffset} {$varOffset}\n"; 
-          } 
-        } else { 
-          echo "empty\n"; 
-        } 
- 
-      } 
- 
-    } while ($response->nextValueOffset != -1); //-1 - no more data available 
-  } while ($response->nextVariableOffset != -1); //-1 - no more data available 
-} 
-catch (Exception $e) { 
-  print_r($e); 
-} 
-?> 
-</code> 
- 
-\\ 
- 
  
  • © Energocentrum Plus, s.r.o. 2017 - 2024