Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:mervis-db:10-api [2017/07/13 17:21] m.kulvejt |
en:mervis-db:10-api [2024/05/08 10:42] (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# ==== | ||
- | FIXME | + | {{ : |
+ | |||
+ | === Download === | ||
+ | |||
+ | |||
+ | {{ : | ||
+ | {{ : | ||
+ | |||
+ | === Code === | ||
+ | |||
+ | |||
+ | <code csharp MervisDB_GetData_Example.cs> | ||
+ | using System; | ||
+ | using System.Linq; | ||
+ | using System.Threading.Tasks; | ||
+ | using MervisDb_GetData_Example.MervisDbService; | ||
+ | |||
+ | namespace MervisDb_GetData_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, | ||
+ | // The client is automatically generated from the WSDL file available here: https:// | ||
+ | // | ||
+ | using(HistoryDbAccessClient client = new HistoryDbAccessClient(" | ||
+ | // Authentication credetials in the database. | ||
+ | | ||
+ | Name = " | ||
+ | }; | ||
+ | |||
+ | // Specification of the variables through Key-Value. | ||
+ | // Here we use 2 variables. | ||
+ | | ||
+ | new KeyValuePair[] { | ||
+ | new KeyValuePair { | ||
+ | Key = " | ||
+ | }, new KeyValuePair { | ||
+ | Key = " | ||
+ | } | ||
+ | }, | ||
+ | new KeyValuePair[] { | ||
+ | new KeyValuePair { | ||
+ | Key = " | ||
+ | }, new KeyValuePair { | ||
+ | Key = " | ||
+ | } | ||
+ | } | ||
+ | }; | ||
+ | |||
+ | // From-To dates. The dates must be specified in the UTC time zone. | ||
+ | | ||
+ | | ||
+ | |||
+ | // Retrieving the data goes through cycling of values and variables. The server returns recommended values needed for the the next cycle. | ||
+ | int variableOffset = 0; // the offset of the variable | ||
+ | int variableCount = 10; // maximal number of variables returned in one request | ||
+ | int valueOffset; | ||
+ | int valueCount = 1000; // maximal values in on request | ||
+ | |||
+ | | ||
+ | |||
+ | do { | ||
+ | valueOffset = 0; | ||
+ | do { | ||
+ | // Execute the request. | ||
+ | var result = await client.GetDataAsyncAsync(credentials, | ||
+ | |||
+ | // Check the return code. " | ||
+ | if (!result.ReturnCode.StartsWith(" | ||
+ | Console.WriteLine(" | ||
+ | } | ||
+ | |||
+ | // Cycle through the data and print it out. | ||
+ | | ||
+ | Console.WriteLine(" | ||
+ | | ||
+ | }))); | ||
+ | |||
+ | foreach(var value in valRecord.Vals) { | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | |||
+ | | ||
+ | | ||
+ | } | ||
+ | while (valueOffset != -1); | ||
+ | } | ||
+ | while (variableOffset != -1); | ||
+ | } | ||
+ | }); | ||
+ | |||
+ | | ||
+ | |||
+ | try { | ||
+ | task.Wait(); | ||
+ | } catch (Exception exc) { | ||
+ | Console.WriteLine(" | ||
+ | } | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | } | ||
+ | } | ||
+ | }</ | ||
+ | |||
+ | <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, | ||
+ | // The client is automatically generated from the WSDL file available here: https:// | ||
+ | // | ||
+ | using (HistoryDbAccessClient client = new HistoryDbAccessClient(" | ||
+ | { | ||
+ | // Authentication credetials in the database. | ||
+ | Credentials credentials = new Credentials { Name = " | ||
+ | |||
+ | // Adding records... | ||
+ | List< | ||
+ | |||
+ | DateTime utcTimeStamp = new DateTime(2018, | ||
+ | |||
+ | // Each value is stored in a ValueRecord structure | ||
+ | ValueRecord rec = new ValueRecord(); | ||
+ | |||
+ | rec.UtcTimeStamp = utcTimeStamp; | ||
+ | rec.HistoryValueType = HistoryValueType.Double; | ||
+ | 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[] // | ||
+ | { | ||
+ | new KeyValuePair { IsKey = true, Key = " | ||
+ | new KeyValuePair { IsKey = true, Key = " | ||
+ | new KeyValuePair { IsKey = false, Key = " | ||
+ | new KeyValuePair { IsKey = false, Key = " | ||
+ | new KeyValuePair { IsKey = false, Key = " | ||
+ | new KeyValuePair { IsKey = false, Key = " | ||
+ | new KeyValuePair { IsKey = false, Key = " | ||
+ | }; | ||
+ | |||
+ | records.Add(rec); | ||
+ | |||
+ | // Save data method returns the number of stored records | ||
+ | int recordsSaved = await client.SaveDataAsync(credentials, | ||
+ | |||
+ | Console.WriteLine(" | ||
+ | } | ||
+ | }); | ||
+ | |||
+ | Console.WriteLine(" | ||
+ | |||
+ | try | ||
+ | { | ||
+ | task.Wait(); | ||
+ | } | ||
+ | catch (Exception exc) | ||
+ | { | ||
+ | Console.WriteLine(" | ||
+ | } | ||
+ | |||
+ | Console.WriteLine(" | ||
+ | Console.ReadLine(); | ||
+ | } | ||
+ | } | ||
+ | }</ | ||
==== Matlab ==== | ==== Matlab ==== | ||
Line 53: | Line 245: | ||
<code matlab> | <code matlab> | ||
- | help MerbonDatabase.supported_function_name | + | help MervisDatabase.supported_function_name |
</ | </ | ||
=== Code === | === Code === | ||
- | MervisDB_GetData_example.m | ||
- | <code matlab> | + | |
+ | <code matlab | ||
% Instance of Mervis DB | % Instance of Mervis DB | ||
- | mervisDB = MerbonDatabase(' | + | mervisDB = MervisDatabase(' |
% Time interval definition | % Time interval definition | ||
Line 76: | Line 268: | ||
' | ' | ||
- | variable1 = MerbonDbVariable(varKeys1); % Create | + | variable1 = MervisDbVariable(varKeys1); % Create |
- | variable2 = MerbonDbVariable(varKeys2); | + | variable2 = MervisDbVariable(varKeys2); |
- | arrayOfVarKeys = [variable1; variable2]; % array of MerbonDbVariables | + | arrayOfVarKeys = [variable1; variable2]; % array of MervisDbVariables |
% help for function getData | % help for function getData | ||
- | help MerbonDatabase.getData | + | help MervisDatabase.getData |
% Download required data | % Download required data | ||
Line 93: | Line 285: | ||
==== PHP ==== | ==== PHP ==== | ||
- | MervisDB_GetData_example.php | + | === Code === |
- | <code php> | + | < |
<?php | <?php | ||
/* | /* |