-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_off_flat_values.cpp
executable file
·122 lines (95 loc) · 4.15 KB
/
read_off_flat_values.cpp
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//#pragma warning( disable : 4996 )
// standard include header files
#include "stdio.h"
#include "irisao.mirrors.h"
typedef struct
{
char dserial[512];
char mserial[512];
char dumpfile[512];
} Arguments;
int main (int argc, char* argv[])
{
Arguments arguments = {"\0", "\0", "\0"};
FILE* stream = NULL;
// handle parsing the command line arguments
try
{
// display the application version and copyright information
#ifdef __x86_64
printf("Iris AO, Flatten Utility 64bit [Version 1.0.2.4]\n");
#else
printf("Iris AO, Flatten Utility 32bit [Version 1.0.2.4]\n");
#endif
printf("Copyright (C) 2015 Iris AO, Inc. All rights reserved.\n\n");
// verify the required mirror serial number command line argument was supplied
if ((argc < 2) || (sscanf(argv[1], "%s", arguments.mserial) == 0))
{
// notify the user an invalid mirror serial number command line argument was supplied
printf("ERROR: Invalid mirror serial number command line argument.\n");
// throw an invalid argument exception to terminate execution
throw InvalidArgument;
}
// verify the required driver serial number command line argument was supplied
if ((argc < 3) || (sscanf(argv[2], "%s", arguments.dserial) == 0))
{
// notify the user an invalid driver serial number command line argument was supplied
printf("ERROR: Invalid driver serial number command line argument.\n");
// throw an invalid argument exception to terminate execution
throw InvalidArgument;
}
// check if the optional dumpfile command line argument was supplied
if ((argc < 4) || (sscanf(argv[3], "%s", arguments.dumpfile) != 0))
{
// open a new dump file for writing modal position values to
stream = fopen(arguments.dumpfile, "w");
}
try
{
MirrorPosition position;
//SegmentNumber segment = 0;
// connect to the specified mirror device
MirrorHandle mirror = MirrorConnect(arguments.mserial, arguments.dserial, false);
// notify the user that the mirror is being flattened
printf("Flattening mirror segments.\n\n");
// send the mirror position values to the driver box
MirrorCommand(mirror, MirrorInitSettings);
// initialize the segment iteration segment number
SegmentNumber segment = 0;
// iterate over each segment available for the current mirror
while (MirrorIterate(mirror, segment))
{
// get the current segment position value
GetMirrorPosition(mirror, segment, &position);
// print the current segment mirror position values
printf("%f %f %f\n", position.z, position.xgrad, position.ygrad);
}
// notify the user that the mirror can be released
printf("Mirror Flattened. Press \"Enter\" to release connection.\n");
getchar();
// release the specified mirror device connection
MirrorRelease(mirror);
// notify the user that the mirror connection has been released
printf("Mirror connection has been released.\n\n");
}
catch (...)
{
// check if a dumpfile stream was opened
if (stream)
{
// close the specified dumpfile stream
fclose(stream);
}
return -1;
}
}
catch (...)
{
// display the application command line argument usage information
printf("\nUsage IrisAO.Utility.Modals.exe <mserial> <dserial> <number> <value> [dumpfile]\n\n");
printf(" mserial: \"Required mirror serial number\"\n");
printf(" dserial: \"Required driver serial number\"\n");
printf(" dumpfile: \"Optional dumpfile filename.\"\n");
}
return 0;
}