/
Program.cs
66 lines (59 loc) · 1.74 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using ClearScada.Client;
using System.Security;
namespace InsertHistoricData
{
class Program
{
static void Main()
{
string user = "s";
string pass = "s";
ClearScada.Client.Simple.Connection connection;
var node = new ClearScada.Client.ServerNode(ClearScada.Client.ConnectionType.Standard, "127.0.0.1", 5481);
connection = new ClearScada.Client.Simple.Connection("Utility");
connection.Connect(node);
var spassword = new System.Security.SecureString();
foreach (var c in pass) spassword.AppendChar(c);
connection.LogOn(user, spassword);
// Insert point name here
ClearScada.Client.Simple.DBObject PointObj = connection.GetObject("New Analog Point");
DateTime now = DateTime.UtcNow;
// Add a value
Object[] p1 = new Object[4];
p1[0] = 1;
p1[1] = 192;
p1[2] = now;
p1[3] = 1;
PointObj.Aggregates["Historic"].InvokeMethod("LoadDataValue", p1);
// Various calls to read values back
Object[] p2 = new Object[5];
p2[0] = now.AddSeconds(-1);
p2[1] = now.AddSeconds(1);
p2[2] = 0;
p2[3] = true;
p2[4] = "All";
object r = PointObj.Aggregates["Historic"].InvokeMethod("RawValue", p2);
Console.WriteLine(r);
Object[] p3 = new Object[6];
p3[0] = now.AddSeconds(-1);
p3[1] = now.AddSeconds(1);
p3[2] = 0;
p3[3] = 1;
p3[4] = true;
p3[5] = "All";
object [] k = (object [])PointObj.Aggregates["Historic"].InvokeMethod("RawValues", p3);
Console.WriteLine(k[0]);
Object[] p4 = new Object[6];
p4[0] = now.AddSeconds(-1);
p4[1] = "2S";
p4[2] = 0;
p4[3] = 1;
p4[4] = true;
p4[5] = "All";
object[] q = (object[])PointObj.Aggregates["Historic"].InvokeMethod("RawValuesRange", p4);
Console.WriteLine(q[0]);
Console.ReadKey();
}
}
}