This is an old revision of the document!


API

Mervis DB supports open SOAP API.

Contact technical support for other non-public APIs that can be used for your projects.

FunctionDescription
SaveDataSave one or multiple records from one or multiple variables
GetData/GetDataAsyncRead one or multiple records from one or multiple variables.
GetParticularData/GetParticulatDataAsyncOptimized method for reading of “special” data - last value, last value after certain time moment etc.
GetVariablesGet the list of variables.
GetAllVariables
ServerAliveObsolete
DeleteVariables
DeleteData
EnsureVariables
GetTransformedData/GetTransformedDataAsync
GetServerVersion
GetVariableStatsObsolete
GetVariableStatsAsyncObsolete
CheckCredentials

FIXME

FIXME

<?php
/*
Mervis DB PHP example - getdata
*/
 
 
try
{
 
  $soapClient = new SoapClient('./wsdl/RcWareDbAccess.wsdl.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'=>'XXXXXXXXX', 'Password'=>'YYYYYYYY');
 
  $utcTZ = new DateTimezone('UTC'); //all time realted values are expected in UTC
 
  $utcFrom =  new DateTime('-1hour', $utcTZ ); //
  $utcTo =  new DateTime('now', $utcTZ ); //
 
  $valOffset = 0;
  $valCount = 20; //how many values should be returned in one request at most
  $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'=>'BBBBBBBBBB')),
                    );
 
 
  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;
 
 
      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, "\n";
          }
        }
        else
        {
          echo "empty\n";
        }
 
      }
 
    } while($response->nextValueOffset != -1);//-1 - no more data available
 
    echo "---- {$counter}\n";
    $varOffset = $response->nextVariableOffset;
 
  } while ($response->nextVariableOffset != -1); //-1 - no more data available
}
catch (Exception $e)
{
  print_r($e);
}
 
 
?>
  • © Energocentrum Plus, s.r.o. 2017 - 2025