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:28] m.chlupac |
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 ===== | ||
| ==== C# ==== | ==== C# ==== | ||
| + | |||
| + | {{ : | ||
| === Download === | === Download === | ||
| - | {{ : | + | {{ : |
| + | {{ : | ||
| === Code === | === Code === | ||
| Line 138: | Line 147: | ||
| }</ | }</ | ||
| + | <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 160: | Line 245: | ||
| <code matlab> | <code matlab> | ||
| - | help MerbonDatabase.supported_function_name | + | help MervisDatabase.supported_function_name |
| </ | </ | ||
| Line 169: | Line 254: | ||
| <code matlab MervisDB_GetData_example.m> | <code matlab MervisDB_GetData_example.m> | ||
| % Instance of Mervis DB | % Instance of Mervis DB | ||
| - | mervisDB = MerbonDatabase(' | + | mervisDB = MervisDatabase(' |
| % Time interval definition | % Time interval definition | ||
| Line 183: | 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 | ||