/
mms_client_example3.c
51 lines (37 loc) · 1.07 KB
/
mms_client_example3.c
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
#include <stdlib.h>
#include <stdio.h>
#include "mms_client_connection.h"
int main(int argc, char** argv) {
char* hostname;
char* variable;
int tcpPort = 102;
// char varname; //variable for searching with just the name
variable = argv[1];
if (argc > 2)
hostname = argv[2];
else
hostname = "localhost";
if (argc > 3)
tcpPort = atoi(argv[3]);
// if (argc > 4)
// varname = atoi(argv[4]); // varname is the 4th command given when client is run
MmsConnection con = MmsConnection_create();
MmsError error;
if (!MmsConnection_connect(con, &error, hostname, tcpPort)) {
printf("MMS connect failed!\n");
goto exit;
}
else
printf("MMS connected.\n\n");
//MmsValue* value = MmsConnection_readVariable(con, &error, "simpleIOGenericIO", variable);
MmsValue* value = IedConnection_readObject(con, &error, "SampleIEDDevice1/MMXN1.Vol.mag.f");
if (value == NULL)
printf("reading value failed!\n");
else {
float fval = MmsValue_toFloat(value);
printf("read float value: %f\n", fval);
MmsValue_delete(value);
}
exit:
MmsConnection_destroy(con);
}