Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:mervis-db:10-api [2017/07/13 17:25]
m.chlupac [C#]
en:mervis-db:10-api [2021/04/08 13:04] (current)
Line 24: Line 24:
 ^GetVariableStatsAsync|Obsolete| ^GetVariableStatsAsync|Obsolete|
 ^CheckCredentials| | ^CheckCredentials| |
 +
 +===== Object Properties =====
 +  * (UTC)TimeStamp - UTC time stamp of the record
 +  * GoodThrough - UTC time stamp of the end of validity of particular record
 +  * Interval - period of time (in seconds) when next value should be recorded
 +
  
 ===== Examples ===== ===== Examples =====
Line 29: Line 35:
 ==== C# ==== ==== C# ====
  
-{{ :en:mervis-db:mervisdb_getdata_example.zip |}}+{{ :en:mervis-db:mervis_db_csharp.png?direct&800 |}} 
 + 
 +=== Download === 
 + 
 + 
 +{{ :en:mervis-db:mervisdb_getdata_example.zip |}}\\ 
 +{{ :en:mervis-db:mervisdb_savedata_example.zip |}} 
 + 
 +=== Code === 
  
 <code csharp MervisDB_GetData_Example.cs> <code csharp MervisDB_GetData_Example.cs>
Line 132: Line 147:
 }</code> }</code>
  
 +<code csharp MervisDB_SaveData_Example.cs>
 +using System;
 +using System.Collections.Generic;
 +using System.Threading.Tasks;
 +using MervisDb_SaveData_Example.MervisDbService;
 +
 +namespace MervisDb_SaveData_Example
 +{
 + class Program
 + {
 + static void Main(string[] args)
 + {
 + //
 + // Demo of asynchronous methods.
 + //
 + var task = Task.Run(async () =>
 + {
 + //
 + // Create access to the real server.
 + // Without SSL connections, you have to remove binding parameters "<security mode="Transport"/>" in the App.config.
 + // The client is automatically generated from the WSDL file available here: https://kb.mervis.info/doku.php/en:mervis-db:10-api
 + //
 + using (HistoryDbAccessClient client = new HistoryDbAccessClient("HistoryAccess", "https://localhost:9876/RcWareDbAccess"))
 + {
 + // Authentication credetials in the database.
 + Credentials credentials = new Credentials { Name = "XXXX", Password = "YYYY" };
 +
 + // Adding records...
 + List<ValueRecord> records = new List<ValueRecord>();
 +
 + DateTime utcTimeStamp = new DateTime(2018, 1, 1, 12, 0, 0, DateTimeKind.Utc);
 +
 + // Each value is stored in a ValueRecord structure
 + ValueRecord rec = new ValueRecord();
 +
 + rec.UtcTimeStamp = utcTimeStamp;                // time stamp of the value, UTC date time must be used
 + rec.HistoryValueType = HistoryValueType.Double; // type of the value
 + rec.DoubleValue = 23.4;                         // value itself
 + rec.Interval = 60.0;                            // sampling period in seconds. When the difference of timestamps of subsequent values if greater than 1.1 multiple of the interval, the data should be considered incomplete.
 + rec.Keys = new KeyValuePair[] // identification of the variable. At least one key-value pair must be "IsKey" to identify a variable.
 + {
 + new KeyValuePair { IsKey = true, Key = "Root", Value = "Building A"},
 +                                                new KeyValuePair { IsKey = true, Key = "Guid", Value = "T26549821654"},
 + new KeyValuePair { IsKey = false, Key = "Level1", Value = "Floor 1"},
 + new KeyValuePair { IsKey = false, Key = "Level2", Value = "Room 7"},
 + new KeyValuePair { IsKey = false, Key = "Name", Value = "Temperature"},
 + new KeyValuePair { IsKey = false, Key = "Description", Value = "Temperature in the room 7"},
 + new KeyValuePair { IsKey = false, Key = "Unit", Value = "°C"},
 + };
 +
 + records.Add(rec);
 +
 + // Save data method returns the number of stored records
 + int recordsSaved = await client.SaveDataAsync(credentials, records.ToArray());
 +
 + Console.WriteLine("Records saved: {0}", recordsSaved);
 + }
 + });
 +
 + Console.WriteLine("DB communication is running in background");
 +
 + try
 + {
 + task.Wait();
 + }
 + catch (Exception exc)
 + {
 + Console.WriteLine("Exception: {0}", exc.ToString());
 + }
 +
 + Console.WriteLine("DB communication finished");
 +
 + Console.ReadLine();
 + }
 + }
 +}</code>
 ==== Matlab ==== ==== Matlab ====
  
Line 154: Line 245:
  
 <code matlab> <code matlab>
-help MerbonDatabase.supported_function_name+help MervisDatabase.supported_function_name
 </code> </code>
  
 === Code === === Code ===
  
-MervisDB_GetData_example.m 
  
-<code matlab>+ 
 +<code matlab MervisDB_GetData_example.m>
 % Instance of Mervis DB % Instance of Mervis DB
-mervisDB = MerbonDatabase('username', 'password', 'dbUrl');+mervisDB = MervisDatabase('username', 'password', 'dbUrl');
  
 % Time interval definition % Time interval definition
Line 177: Line 268:
             'StationName', 'YYYYYYY'}; % Keys definition of second variable             'StationName', 'YYYYYYY'}; % Keys definition of second variable
  
-variable1 = MerbonDbVariable(varKeys1); % Create MerbonDbVariable object from defined keys +variable1 = MervisDbVariable(varKeys1); % Create MervisDbVariable object from defined keys 
-variable2 = MerbonDbVariable(varKeys2);+variable2 = MervisDbVariable(varKeys2);
  
-arrayOfVarKeys = [variable1; variable2]; % array of MerbonDbVariables objects+arrayOfVarKeys = [variable1; variable2]; % array of MervisDbVariables objects
  
 % help for function getData % help for function getData
-help MerbonDatabase.getData+help MervisDatabase.getData
  
 % Download required data % Download required data
Line 194: Line 285:
 ==== PHP ==== ==== PHP ====
  
-MervisDB_GetData_example.php+=== Code === 
  
-<code php>+<code php MervisDB_GetData_example.php>
 <?php <?php
 /* /*
  • © Energocentrum Plus, s.r.o. 2017 - 2024