Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
en:mervis-db:10-api [2017/08/03 10:28] p.stepan |
en:mervis-db:10-api [2019/03/06 12:29] m.chlupac |
||
---|---|---|---|
Line 34: | Line 34: | ||
- | {{ : | + | {{ : |
+ | {{ : | ||
=== Code === | === Code === | ||
Line 140: | Line 141: | ||
}</ | }</ | ||
+ | <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 = true, Key = " | ||
+ | new KeyValuePair { IsKey = true, 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 ==== | ||