I put the header file into the workspace in a folder called source and tried around a bit.
Got the list devices Command working. I cant figure out how to move the machine tho
- Code: Select all
#include <cstdio>
#include <windows.h>
#include <iostream>
#include "source/UC100.h"
typedef int (__stdcall *AddLinMoveFP)(double, double, double, double, double, double, double, double);
typedef int (*ListDevicesFP)(int*);
typedef int (*SetEstopSettingFP)(int, bool);
typedef int (*SetEstopStateFP)();
typedef int(* DeviceInfoFP)(int, int*, int*);
typedef int(* OpenFP)(int);
typedef int(*GetStatusFP)(Stat *SStat);
typedef int(*StopFP)();
int main() {
// load the UC100 DLL
HINSTANCE hGetProcLib = LoadLibrary(R"(C:\UCCNC\API\DLL\UC100.dll)");
if (!hGetProcLib) {
printf("could not load the dynamic library\n");
return 1;
}
// get the function we want, ListDevices in this example
AddLinMoveFP linMove = (AddLinMoveFP)GetProcAddress(hGetProcLib, "AddLinearMoveRel");
ListDevicesFP listDevices = (ListDevicesFP) GetProcAddress(hGetProcLib, "ListDevices");
SetEstopSettingFP SetEstopSetting = (SetEstopSettingFP) GetProcAddress(hGetProcLib, "SetEstopSetting");
OpenFP Open = (OpenFP) GetProcAddress(hGetProcLib, "Open");
GetStatusFP GetStatus = (GetStatusFP) GetProcAddress(hGetProcLib, "GetStatus");
StopFP Stop = (StopFP) GetProcAddress(hGetProcLib, "Stop");
SetEstopStateFP SetEstopState = (SetEstopStateFP) GetProcAddress(hGetProcLib, "SetEstopState");
if (!linMove) {
printf("could not locate the function\n");
return 1;
}
// call the DLL function
int x = 0;
Stat res_stat;
int r2 = listDevices(&x);
int r4 = Open(1);
//int r6 = Stop();
//int r3 = SetEstopSetting(11, false);
int r5 = GetStatus(&res_stat);
//int r = linMove(1000, 1000, 1000, 0, 0, 0, 1000, 8);
int id1 = linMove(0, 0, 0, 0, 0, 0, 500, 9);
int id2 = linMove(50, 0, 0, 0, 0, 0, 500, 9);
std::cout << "ID1: " << id1 << " ID2: " << id2 << std::endl;
FreeLibrary(hGetProcLib);
std::cout << "Device count: " << x << std::endl;
std::cout << "estop: " << res_stat.Estop << std::endl;
std::cout << "Idle: " << res_stat.Idle << std::endl;
//printf("%d\n", r4);
return 0;
}