161 lines
5.6 KiB
C++
161 lines
5.6 KiB
C++
#include "cdutils_core.h"
|
|
#include "cdutils_k_parser.h"
|
|
#include "piconfig.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 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\
|
|
";
|
|
|
|
|
|
int __Core_Initializer__::count_(0);
|
|
Core * __Core_Initializer__::__instance__(0);
|
|
|
|
|
|
__Core_Initializer__::__Core_Initializer__() {
|
|
count_++;
|
|
if (count_ > 1) return;
|
|
//piCout << "create PIInit";
|
|
__instance__ = new Core();
|
|
}
|
|
|
|
|
|
__Core_Initializer__::~__Core_Initializer__() {
|
|
count_--;
|
|
if (count_ > 1) return;
|
|
//piCout << "delete PIInit";
|
|
if (__instance__ != 0) {
|
|
delete __instance__;
|
|
__instance__ = 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
Core::Core(const char * conf) {
|
|
CONNECTU(&connection, dataReceivedEvent, this, dataReceived);
|
|
PIString s(conf);
|
|
connection.configureFromString(&s);
|
|
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");
|
|
k_.section(10)[5] = KType(5, "8", "2*2*2", "88");
|
|
k_.section(10).section(50)[100] = KType(100, "8", "2*2*2", "88");
|
|
k_.section(11)[3] = KType(3, "1", "1", "88");
|
|
k_.section(11)[4] = KType(4, "0", "0", "88");
|
|
k_.section(11)[6] = KType(6, "0", "0", "88");*/
|
|
//piCout << s;
|
|
}
|
|
|
|
|
|
void Core::k_rec(const PIByteArray & data) {
|
|
|
|
}
|
|
|
|
|
|
void Core::x_rec(const PIByteArray & data) {
|
|
|
|
}
|
|
|
|
|
|
void Core::c_rec(const PIByteArray & data) {
|
|
|
|
}
|
|
|
|
|
|
void Core::k_write(PIIODevice * d) {
|
|
k_.write(d, PIString());
|
|
}
|
|
|
|
|
|
void Core::k_read(PIIODevice * d) {
|
|
PIConfig conf(d, PIIODevice::ReadOnly);
|
|
k_.read(&(conf.rootEntry()));
|
|
}
|
|
|
|
|
|
void Core::k_parse(PIIODevice * d) {
|
|
k_ = KParser::parse(d);
|
|
}
|
|
|
|
|
|
void Core::k_update(PIIODevice * d) {
|
|
KSection uk = k_;
|
|
k_parse(d);
|
|
bool kn = false;
|
|
if (!uk.isEmpty())
|
|
if (!uk.isSameStructure(k_)) {
|
|
piCout << "ask for save names";
|
|
K_KeepNamesRequest(&kn);
|
|
}
|
|
uk.update(k_, kn);
|
|
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 Core::K_Send() {
|
|
piCoutObj << "K_Send";
|
|
}
|
|
|
|
|
|
void Core::K_Request() {
|
|
piCoutObj << "K_Request";
|
|
|
|
}
|