-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathProgram.cs
38 lines (33 loc) · 987 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OPC_HDA_Client
{
class Program
{
static void Main(string[] args)
{
string serverName = "Matrikon.OPC.Simulation.1";
var hdac = OPCHDA.Client();
hdac.Connect(serverName);
// Add item id
hdac.AddItem("Random.Int1");
// Read raw data
DateTime start = DateTime.Now;
DateTime end = start.AddDays(1);
DataTable dt = hdac.ReadRaw(start, end, 32, true);
foreach (DataRow dr in dt.Rows)
{
Console.WriteLine(String.Format("{0} {1} {2}",
dr["TimeStamp"].ToString(),
dr["Value"].ToString(),
dr["Quality"].ToString()));
}
hdac.Disconnect();
Console.ReadLine();
}
}
}