git-svn-id: svn://db.shs.com.ru/libs@112 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -1,72 +1,68 @@
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_k_parser.h"
|
||||
#include "piconfig.h"
|
||||
#include "cdutils_protocol.h"
|
||||
#include "piiodevice.h"
|
||||
#include "piiostring.h"
|
||||
#include "pifile.h"
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
const char Core::app_config[] =
|
||||
"include = cd_ip.conf\n\
|
||||
port_rec = 2\n\
|
||||
port_send = 1\n\
|
||||
[connection]\n\
|
||||
device.c = eth://UDP:127.0.0.1:3610${port_rec}:127.0.0.1:3610${port_send} #s\n\
|
||||
device.c.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.k = eth://UDP:127.0.0.1:2610${port_rec}:127.0.0.1:2610${port_send} #s\n\
|
||||
device.k.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.x = eth://UDP:127.0.0.1:1610${port_rec}:127.0.0.1:1610${port_send} #s\n\
|
||||
device.x.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.c_eth = eth://UDP:${ip_app}:3610${port_rec}:${ip_pult}:3610${port_send} #s\n\
|
||||
device.c_eth.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.k_eth = eth://UDP:${ip_app}:2610${port_rec}:${ip_pult}:2610${port_send} #s\n\
|
||||
device.k_eth.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.x_eth = eth://UDP:${ip_app}:1610${port_rec}:${ip_pult}:1610${port_send} #s\n\
|
||||
device.x_eth.disconnectTimeout = 3.00000000 #f\n\
|
||||
channel.0.from = c_eth #s\n\
|
||||
channel.0.to = c #s\n\
|
||||
channel.1.from = k_eth #s\n\
|
||||
channel.1.to = k #s\n\
|
||||
channel.2.from = x_eth #s\n\
|
||||
channel.2.to = x #s\n\
|
||||
[]\n\
|
||||
connectionmodel = AAAWNHja7ZbfShtBFMa/Xf9UrYLSXnqhErxrdSNYKBRXEMQbEVGhBBRJgob4J6SxSZBC38ELb32UBR/AV/ARfAP9MjmzyQ7TGGkaGzeznMycmTNnZn/zLRkAH5HGOc74ZNkqIac8YBhwLlk7tEHUi1trP7KwHqCN+AhLLeYHpqC7HEeFqbLygJal3XHfPjxE2/kX69UxYK32en62vnqwIXvJwOr7m1JLvPZZ3tGmBR0ErSNYXY20gbuPvxl/eSaKuxxY/RC/xPfxdwb/3u8o7u+w+iF+ie/j7wj+IBXFH+zD6mvcOr7L+PXW3xz+nIH7KLD6If4c+urvIP6qgb96Y/VD/NW/xa/W5rj7SeImg2Jg5nRlji7M4dwJk1U9jzaOAz4lVFHgHUuOsjEHo9IXnrceXJe+cbXQGQ5xak3wgTYG9ZPnSlmudWykuo7sJ8OYn7zppa3pDnS6PUn1FQt8dnkYW2wncMmpBYblUcEv9iSxDA+LrM3RAi5wwhzNUZ6xtW+Rtzzl9TPTGtOAkSAlCeZpc5yc48cQvdPusK+G7pzbKVlST6gT90ciX9Rgk8TnZdIYyigyWUntEGrHRbYPkWkIq0k0CfSCaCqvIRqvLdF48RONX7jvBdGkX0M0S22JZik2opk1RaP/Ev8gmttOimalTdG816fsElE0xdULxJLSabatYvEoii/4zGOvm2fIpdV4jISi7zH/uVDy3RVK8hmhJGMolAR6QSiV7grFe0YoMbivPAGq7YwD\n\
|
||||
";
|
||||
const char CDCore::app_config[] =
|
||||
"include = cd_ip.conf\n\
|
||||
port_rec = 2\n\
|
||||
port_send = 1\n\
|
||||
[connection]\n\
|
||||
device.cd = eth://UDP:127.0.0.1:2616${port_rec}:127.0.0.1:2616${port_send} #s\n\
|
||||
device.cd.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.cd_eth = eth://UDP:${ip_app}:2616${port_rec}:${ip_pult}:2616${port_send} #s\n\
|
||||
device.cd_eth.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.cd_mcast = eth://UDP:0.0.0.0:2616${port_rec}:234.1.1.1:2616${port_send}:mcast:234.1.1.1 #s\n\
|
||||
device.cd_mcast.disconnectTimeout = 3.00000000 #f\n\
|
||||
channel.0.from = cd_eth #s\n\
|
||||
channel.0.to = cd #s\n\
|
||||
channel.1.from = cd_mcast #s\n\
|
||||
channel.1.to = cd #s\n\
|
||||
[]\n\
|
||||
connectionmodel = AAAM2Xja7VXLTttAFD12QpsikKjUSixYlLbKEpIUtVIlVEfqhk2FWuiGRRolUYtoHgrmpYiv6IItf8AveMMH9E/YsG6Ph3sde5hGoQoblLGuPHfunTPjc49nADxDA110+LTYC7FrPCAPeAO+vZu+aX7c/8PGd45WCJC0OGcfT6FDnmfSTPtwhZFt3HjgDs/Qtu5jPbZHtI/x50XfIzMQbdwEolbg9INP4ku++myPaUtCHYRaT2j1ldIh3VP60/Qff8vSfXLu9BP6JX9K/0TVH6jqVe22P1X/fao/oddWu/paDs1vBf9Jv/EZ91clbyHqv7BL6sscDOd4v4WTqs6jzaHGJ8QJerxlpJSpdZ7IWFJvDW7I2JxZqIM62k6A57RZmMQGmlyrxdV+WGBnmR01mXPI267hBKwp4FeBeo9VPtssxyb7rzHg1B7T9nCMU45U8BZlWuVWtIcD/CRGOqtsbW09851tXsHN0UTlLIAdASjSXnLyLn+H7L2+xbGYvC63Ezqg543egkLmn8qnRF6USbM4Qp9godkhzI777Ne5bCIt/5UtGz2o/yGby0nKpjqmbOa1ynkjmyzIrzvIZUeBPjvlUmbh32EFJbGyJZhR8YcvlS+3TpjhqeWSyvUkpbI9plSWtcKLcsK05beOJVEnhaEFfHEH+RwpeMcpn1JKGqWMNOL+G6wZyahlpdVOtufKfbDS+guLke9O\n\
|
||||
";
|
||||
|
||||
const char Core::pult_config[] =
|
||||
"include = cd_ip.conf\n\
|
||||
port_rec = 1\n\
|
||||
port_send = 2\n\
|
||||
[connection]\n\
|
||||
device.c = eth://UDP:127.0.0.1:3610${port_rec}:127.0.0.1:3610${port_send} #s\n\
|
||||
device.c.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.k = eth://UDP:127.0.0.1:2610${port_rec}:127.0.0.1:2610${port_send} #s\n\
|
||||
device.k.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.x = eth://UDP:127.0.0.1:1610${port_rec}:127.0.0.1:1610${port_send} #s\n\
|
||||
device.x.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.c_eth = eth://UDP:${ip_pult}:3610${port_rec}:${ip_app}:3610${port_send} #s\n\
|
||||
device.c_eth.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.k_eth = eth://UDP:${ip_pult}:2610${port_rec}:${ip_app}:2610${port_send} #s\n\
|
||||
device.k_eth.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.x_eth = eth://UDP:${ip_pult}:1610${port_rec}:${ip_app}:1610${port_send} #s\n\
|
||||
device.x_eth.disconnectTimeout = 3.00000000 #f\n\
|
||||
[]\n\
|
||||
connectionmodel = AAAWNHja7ZbfShtBFMa/Xf9UrYLSXnqhErxrdSNYKBRXEMQbEVGhBBRJgob4J6SxSZBC38ELb32UBR/AV/ARfAP9MjmzyQ7TGGkaGzeznMycmTNnZn/zLRkAH5HGOc74ZNkqIac8YBhwLlk7tEHUi1trP7KwHqCN+AhLLeYHpqC7HEeFqbLygJal3XHfPjxE2/kX69UxYK32en62vnqwIXvJwOr7m1JLvPZZ3tGmBR0ErSNYXY20gbuPvxl/eSaKuxxY/RC/xPfxdwb/3u8o7u+w+iF+ie/j7wj+IBXFH+zD6mvcOr7L+PXW3xz+nIH7KLD6If4c+urvIP6qgb96Y/VD/NW/xa/W5rj7SeImg2Jg5nRlji7M4dwJk1U9jzaOAz4lVFHgHUuOsjEHo9IXnrceXJe+cbXQGQ5xak3wgTYG9ZPnSlmudWykuo7sJ8OYn7zppa3pDnS6PUn1FQt8dnkYW2wncMmpBYblUcEv9iSxDA+LrM3RAi5wwhzNUZ6xtW+Rtzzl9TPTGtOAkSAlCeZpc5yc48cQvdPusK+G7pzbKVlST6gT90ciX9Rgk8TnZdIYyigyWUntEGrHRbYPkWkIq0k0CfSCaCqvIRqvLdF48RONX7jvBdGkX0M0S22JZik2opk1RaP/Ev8gmttOimalTdG816fsElE0xdULxJLSabatYvEoii/4zGOvm2fIpdV4jISi7zH/uVDy3RVK8hmhJGMolAR6QSiV7grFe0YoMbivPAGq7YwD\n\
|
||||
";
|
||||
const char CDCore::pult_config[] =
|
||||
"include = cd_ip.conf\n\
|
||||
port_rec = 1\n\
|
||||
port_send = 2\n\
|
||||
[connection]\n\
|
||||
device.cd = eth://UDP:127.0.0.1:2616${port_rec}:127.0.0.1:2616${port_send} #s\n\
|
||||
device.cd.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.cd_eth = eth://UDP:${ip_app}:2616${port_rec}:${ip_pult}:2616${port_send} #s\n\
|
||||
device.cd_eth.disconnectTimeout = 3.00000000 #f\n\
|
||||
device.cd_mcast = eth://UDP:0.0.0.0:2616${port_rec}:234.1.1.1:2616${port_send}:mcast:234.1.1.1 #s\n\
|
||||
device.cd_mcast.disconnectTimeout = 3.00000000 #f\n\
|
||||
channel.0.from = cd_eth #s\n\
|
||||
channel.0.to = cd #s\n\
|
||||
channel.1.from = cd_mcast #s\n\
|
||||
channel.1.to = cd #s\n\
|
||||
[]\n\
|
||||
connectionmodel = AAAM2Xja7VXLTttAFD12QpsikKjUSixYlLbKEpIUtVIlVEfqhk2FWuiGRRolUYtoHgrmpYiv6IItf8AveMMH9E/YsG6Ph3sde5hGoQoblLGuPHfunTPjc49nADxDA110+LTYC7FrPCAPeAO+vZu+aX7c/8PGd45WCJC0OGcfT6FDnmfSTPtwhZFt3HjgDs/Qtu5jPbZHtI/x50XfIzMQbdwEolbg9INP4ku++myPaUtCHYRaT2j1ldIh3VP60/Qff8vSfXLu9BP6JX9K/0TVH6jqVe22P1X/fao/oddWu/paDs1vBf9Jv/EZ91clbyHqv7BL6sscDOd4v4WTqs6jzaHGJ8QJerxlpJSpdZ7IWFJvDW7I2JxZqIM62k6A57RZmMQGmlyrxdV+WGBnmR01mXPI267hBKwp4FeBeo9VPtssxyb7rzHg1B7T9nCMU45U8BZlWuVWtIcD/CRGOqtsbW09851tXsHN0UTlLIAdASjSXnLyLn+H7L2+xbGYvC63Ezqg543egkLmn8qnRF6USbM4Qp9godkhzI777Ne5bCIt/5UtGz2o/yGby0nKpjqmbOa1ynkjmyzIrzvIZUeBPjvlUmbh32EFJbGyJZhR8YcvlS+3TpjhqeWSyvUkpbI9plSWtcKLcsK05beOJVEnhaEFfHEH+RwpeMcpn1JKGqWMNOL+G6wZyahlpdVOtufKfbDS+guLke9O\n\
|
||||
";
|
||||
|
||||
|
||||
int __Core_Initializer__::count_(0);
|
||||
Core * __Core_Initializer__::__instance__(0);
|
||||
CDCore * __Core_Initializer__::__instance__(0);
|
||||
|
||||
|
||||
__Core_Initializer__::__Core_Initializer__() {
|
||||
count_++;
|
||||
//piCout << "try create Core" << count_;
|
||||
if (count_ > 1) return;
|
||||
//piCout << "create Core";
|
||||
__instance__ = new Core();
|
||||
__instance__ = new CDCore();
|
||||
}
|
||||
|
||||
|
||||
__Core_Initializer__::~__Core_Initializer__() {
|
||||
count_--;
|
||||
//piCout << "try delete Core" << count_;
|
||||
if (count_ > 0) return;
|
||||
//piCout << "delete Core";
|
||||
if (__instance__ != 0) {
|
||||
@@ -78,11 +74,13 @@ __Core_Initializer__::~__Core_Initializer__() {
|
||||
|
||||
|
||||
|
||||
Core::Core(const char * conf) {
|
||||
CDCore::CDCore(const char * conf) {
|
||||
CONNECTU(&connection, dataReceivedEvent, this, dataReceived);
|
||||
PIString s(conf);
|
||||
connection.configureFromString(&s);
|
||||
datatr.setPacketSize(960);
|
||||
connection.start();
|
||||
|
||||
/*k_[1] = KType(1, "123", "120+3", "comment");
|
||||
k_[2] = KType(2, "1", "2", "comm");
|
||||
k_[4] = KType(4, "-0.6", "-6/10", "mment");
|
||||
@@ -95,39 +93,39 @@ Core::Core(const char * conf) {
|
||||
}
|
||||
|
||||
|
||||
void Core::k_rec(const PIByteArray & data) {
|
||||
void CDCore::k_rec(const PIByteArray & data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Core::x_rec(const PIByteArray & data) {
|
||||
void CDCore::x_rec(const PIByteArray & data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Core::c_rec(const PIByteArray & data) {
|
||||
void CDCore::c_rec(const PIByteArray & data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Core::k_write(PIIODevice * d) {
|
||||
void CDCore::k_write(PIIODevice * d) {
|
||||
k_.write(d, PIString());
|
||||
}
|
||||
|
||||
|
||||
void Core::k_read(PIIODevice * d) {
|
||||
void CDCore::k_read(PIIODevice * d) {
|
||||
PIConfig conf(d, PIIODevice::ReadOnly);
|
||||
k_.read(&(conf.rootEntry()));
|
||||
}
|
||||
|
||||
|
||||
void Core::k_parse(PIIODevice * d) {
|
||||
k_ = KParser::parse(d);
|
||||
void CDCore::k_parse(PIIODevice * d) {
|
||||
k_ = CDParser::parse(d, CDType::cdK);
|
||||
}
|
||||
|
||||
|
||||
void Core::k_update(PIIODevice * d) {
|
||||
KSection uk = k_;
|
||||
void CDCore::k_update(PIIODevice * d) {
|
||||
CDSection uk = k_;
|
||||
k_parse(d);
|
||||
bool kn = false;
|
||||
if (!uk.isEmpty())
|
||||
@@ -136,26 +134,33 @@ void Core::k_update(PIIODevice * d) {
|
||||
K_KeepNamesRequest(&kn);
|
||||
}
|
||||
uk.update(k_, kn);
|
||||
piCout << k_.count() << uk.count();
|
||||
//piCout << k_.count() << uk.count();
|
||||
k_ = uk;
|
||||
}
|
||||
|
||||
|
||||
void CDUtils::Core::dataReceived(const PIString & from, const PIByteArray & data) {
|
||||
piCout << from << data;
|
||||
if (data.size_s() < 4) return;
|
||||
if (from == "k") k_rec(data);
|
||||
if (from == "x") x_rec(data);
|
||||
if (from == "c") c_rec(data);
|
||||
void CDUtils::CDCore::dataReceived(const PIString & from, const PIByteArray & data) {
|
||||
piCout << from << data.size();
|
||||
if (from == "cd") {
|
||||
datatr.received(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Core::K_Send() {
|
||||
void CDCore::K_Send() {
|
||||
piCoutObj << "K_Send";
|
||||
PIString s;
|
||||
PIIOString ios(&s);
|
||||
k_write(&ios);
|
||||
ios.close();
|
||||
//PIByteArray ba = PIByteArray::fromString(s);
|
||||
PIFile pf("k.txt", PIIODevice::ReadWrite);
|
||||
pf.write(s.toUTF8());
|
||||
//k_write(&pf);
|
||||
piCout << pf.readLine();
|
||||
}
|
||||
|
||||
|
||||
void Core::K_Request() {
|
||||
void CDCore::K_Request() {
|
||||
piCoutObj << "K_Request";
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user