⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testlearnedobj.cpp

📁 机器人程序
💻 CPP
字号:
/// tests looking for a learned object


#include <stdio.h>
#include <windows.h>
#include "maviscomm.h"
#include "Mavis.h"
#include "MavisErr.h"

// mavis proper
Mavis * pMavis       = NULL;
HANDLE  hMavisThread = NULL;

// mavis client
HINSTANCE    mavisLib     = NULL;
LOOKONCEPROC procLookOnce = NULL;

// function prototypes
DWORD WINAPI RunMavis(LPVOID lpThreadData);


int main(int argc, char** argv)
{
	// initialize Mavis
	try
	{
		pMavis = new Mavis();
	}
	catch(MavisErr& e)
	{
		string msg = "Error: ";
		msg += e.getMsg();
		cout << msg << endl;
		return -1;
	}
	catch(...) {
		cout << "Can't initialize Mavis - unknown error\n";
		return -1;
	}

	// run Mavis in its own thread
	hMavisThread = CreateThread(
		NULL,          //default security attributes
		0,             //default stack size
		RunMavis,      //thread function
		NULL,          //the thread data
		0,             //default creation flags
		NULL           //thread id variable
	);


	// load the communications dll
	try
	{
		mavisLib = LoadLibrary("mavisclient");
		if(NULL == mavisLib) throw MavisErr( "can't load mavisclient.dll" );

		procLookOnce = (LOOKONCEPROC)GetProcAddress(mavisLib, LOOKONCEPROC_NAME);
		if(NULL == procLookOnce)
			throw MavisErr( "can't access mavisclient.dll method for LOOKONCEPROC" );
	}
	catch(MavisErr& e)
	{
		string msg = "Error: ";
		msg += e.getMsg();
		cout << msg << endl;
		goto cleanup;
	}


	// do look once
	CtlData_t       ctlData;
	ObjLoc_t        objLoc;
	ctlData.objId = 100;
	procLookOnce(ctlData.objId, &objLoc);
	//procLookOnce(ctlData.objId, &objLoc);
	//procLookOnce(ctlData.objId, &objLoc);
	//procLookOnce(ctlData.objId, &objLoc);
	//procLookOnce(ctlData.objId, &objLoc);
	//procLookOnce(ctlData.objId, &objLoc);
	//procLookOnce(ctlData.objId, &objLoc);


cleanup:
	if(mavisLib) FreeLibrary(mavisLib);
	if(pMavis)
	{
		pMavis->stop();
		Sleep(60L);
		if(hMavisThread) CloseHandle(hMavisThread);
		delete pMavis;
	}

	return 0;
}


////////////
// thread function to run mavis
//
DWORD WINAPI RunMavis(LPVOID lpThreadData)
{
	if(pMavis) pMavis->run();
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -