-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
81 lines (70 loc) · 2.15 KB
/
main.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
#include <iostream>
#include "CDispatcher.h"
#include "serialport.h"
#include "common.h"
#include "czblog.hpp"
bool bExit=false;
CDispatcher *CD=NULL;
void ShowEndDevices(void)
{
if(!CD) return;
std::cout << "EndDevice List" << std::endl;
std::vector<std::string> vctED= CD->getZBEDListNames();
BOOST_FOREACH(std::string str,vctED){
std::cout << str << std::endl;
}
std::cout << std::endl;
}
void ShowChannels(void)
{
std::vector<std::string> edNameList = CD->getZBEDListNames();
BOOST_FOREACH(std::string str, edNameList){
CZBEndDevicePtr czbed = CD->getZBEndDeviceByName(str);
std::vector<std::string> channels = czbed->getChannelNames();
BOOST_FOREACH(std::string str_channel,channels){
std::cout << str << ":" << str_channel << std::endl;
}
}
}
void ProcessLine(const std::string &_line)
{
std::vector<std::string> token = tokenize(_line," ");
if(token.empty()) return;
if(token.size()>1)
{
std::cout << "tokenized command detected:" << std::endl;
BOOST_FOREACH(std::string str, token){
std::cout << str << std::endl;
}
}
if(token[0].compare("exit")==0) bExit=true;
if(token[0].compare("show_ed")==0) ShowEndDevices();
if(token[0].compare("show_channels")==0) ShowChannels();
}
int main(void)
{
//LOG = new CZBLog();
LOG.set_log_file("log.txt");
LOG.set_data_file("data.txt");
LOG.set_save_data(true);
LOG.set_save_log(true);
// .
SerialPort.SetDevice("/dev/ttyUSB0");
CD = new CDispatcher();
SerialPort.addDataCallBack(boost::bind(&CDispatcher::CheckAndAddRawFrames,CD,_1));
SerialPort.addDataCallBack(boost::bind(&CZBLog::LOGDATA,&LOG,_1));
//SerialPort.addDataCallBack(boost::bind(ShowVectorUINT8,_1));
SerialPort.OpenSerialPort();
//char line[1024];
while(!bExit)
{
//memset(line,0,1024);
//std::cout << ">";
//std::cin.getline(line,1024);
//std::cout << "command: " << std::string(line) << std::endl;
//ProcessLine(std::string(line));
usleep(10000);
}
//multithread safe delete :)
exit(EXIT_SUCCESS);
}