-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathMFF10x_example.cpp
98 lines (75 loc) · 2.24 KB
/
MFF10x_example.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
//
// C++ example for Thorlabs MFF10X Filter Flippers
//2023 - 10 - 02
//2023 - 10 - 02
//C++20
//Kinesis version 1.14.41
//=======================
//This example goes over connecting to the device, moveing between states and disconnecting from the Console
//
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
// Include device-specific header file.
#include "ThorLabs.MotionControl.FilterFlipper.h"
int main()
{
// Uncomment this line (and TLI_UnitializeSimulations at the bottom of the page)
// If you are using a simulated device
//TLI_InitializeSimulations();
// Change this line to reflect your device's serial number
int serialNo = 37007009;
char testSerialNo[16];
sprintf_s(testSerialNo, "%d", serialNo);
// Build list of connected device
if (TLI_BuildDeviceList() == 0)
{
// get device list size
short n = TLI_GetDeviceListSize();
// get MFF serial numbers
char serialNos[100];
TLI_GetDeviceListByTypeExt(serialNos, 100, 37);
// output list of matching devices
{
char* searchContext = nullptr;
char* p = strtok_s(serialNos, ",", &searchContext);
while (p != nullptr)
{
TLI_DeviceInfo deviceInfo;
// get device info from device
TLI_GetDeviceInfo(p, &deviceInfo);
// get strings from device info structure
char desc[65];
strncpy_s(desc, deviceInfo.description, 64);
desc[64] = '\0';
char serialNo[9];
strncpy_s(serialNo, deviceInfo.serialNo, 8);
serialNo[8] = '\0';
// output
printf("Found Device %s=%s : %s\r\n", p, serialNo, desc);
p = strtok_s(nullptr, ",", &searchContext);
}
}
// Open device.
if (FF_Open(testSerialNo) == 0)
{
// Start the device polling.
FF_StartPolling(testSerialNo, 200);
Sleep(300);
FF_ClearMessageQueue(testSerialNo);
FF_Home(testSerialNo);
printf("Device %s homing\r\n", testSerialNo);
FF_MoveToPosition(testSerialNo, FF_Positions::Position2);
Sleep(2000);
FF_MoveToPosition(testSerialNo, FF_Positions::Position1);
Sleep(2000);
printf("Device %s current position is %d\r\n", testSerialNo, FF_GetPosition(testSerialNo));
// stop polling
FF_StopPolling(testSerialNo);
// close device
FF_Close(testSerialNo);
// TLI_UninitializeSimulations();
}
}
}