-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZMQcomm.cpp
47 lines (36 loc) · 1.37 KB
/
ZMQcomm.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
// ZMQcomm.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
#include "ZMQCommunicator.h"
#include "chess_defs.h"
// this is the callback function for handling zmq input in your program
void CallbackHandler(evtmsg evt){
if (evt.type == EZ){
//std::chrono::time_point<int, std::chrono::milliseconds> zerotime = std::chrono::steady_clock::now();
//zerotime = std::chrono::steady_clock::now();
std::cout << "zero time: " << std::endl;// << std::put_time(zerotime.time_since_epoch, "%F %T") << std::e_endl;
}
if (evt.type == ET && evt.task == TQ){
if (evt.phase == e_begin) std::cout << "queen's e_begins!" << std::endl;
else if (evt.phase == e_end) std::cout << "queen's ends!" << std::endl;
}
if (evt.type == EI){ std::cout << "instruction" << std::endl; }
if (evt.type == EM){
std::cout << piecenames.at(evt.target) << " moves from " << squarenames.at(evt.from) << " to " << squarenames.at(evt.to) << std::endl;
}
}
//int _tmain(int argc, _TCHAR* argv[])
int main(int argc, char** argv)
{
ZMQCommunicator *zmqc = new ZMQCommunicator(PAIR, 1000);
zmqc->setHandler(CallbackHandler);
zmqc->Connect("127.0.0.1", "5555");
//zmqc->Connect("192.168.2.183", "5555");
zmqc->Run();
std::cout << "running, press enter to stop" << std::endl;
std::cin.ignore(); //waits for enter
zmqc->Stop();
return 0;
}