Merge branch 'master' into pisteampackerconfig
# Conflicts: # libs/client_server/piclientserver_server.cpp # libs/crypt/picrypt.cpp # libs/io_utils/pistreampacker.cpp # main.cpp
This commit is contained in:
@@ -21,9 +21,12 @@
|
||||
|
||||
#include "piliterals_time.h"
|
||||
#include "pitime.h"
|
||||
#include "pitranslator.h"
|
||||
|
||||
|
||||
const uint PIBaseTransfer::signature = 0x54424950;
|
||||
|
||||
|
||||
PIBaseTransfer::PIBaseTransfer(): crc(standardCRC_16()), diag(false) {
|
||||
header.sig = signature;
|
||||
crc_enabled = true;
|
||||
@@ -96,7 +99,7 @@ void PIBaseTransfer::received(PIByteArray data) {
|
||||
data >> h;
|
||||
PacketType pt = (PacketType)h.type;
|
||||
if (!h.check_sig()) {
|
||||
piCoutObj << "invalid packet signature";
|
||||
piCoutObj << "invalid packet signature"_tr("PIBaseTransfer");
|
||||
diag.received(data.size(), false);
|
||||
return;
|
||||
} else
|
||||
@@ -119,7 +122,7 @@ void PIBaseTransfer::received(PIByteArray data) {
|
||||
ccrc = 0;
|
||||
if (rcrc != ccrc) {
|
||||
header.id = h.id;
|
||||
piCoutObj << "invalid CRC";
|
||||
piCoutObj << "invalid CRC"_tr("PIBaseTransfer");
|
||||
sendReply(pt_ReplyInvalid);
|
||||
} else {
|
||||
mutex_session.lock();
|
||||
@@ -170,9 +173,9 @@ void PIBaseTransfer::received(PIByteArray data) {
|
||||
if (send_up > 20 && send_up > packets_count * 2) packets_count += piMaxi(packets_count / 10, 1);
|
||||
// piCoutObj << packets_count;
|
||||
} else
|
||||
piCoutObj << "invalid reply id";
|
||||
piCoutObj << "invalid reply id"_tr("PIBaseTransfer");
|
||||
mutex_session.unlock();
|
||||
// piCoutObj << "Done Packet" << h.id;
|
||||
// piCoutObj << "Done Packet" << h.id;
|
||||
}
|
||||
if (is_receiving && h.id == 0) {
|
||||
if (pt == pt_ReplySuccess) {
|
||||
@@ -213,7 +216,7 @@ void PIBaseTransfer::received(PIByteArray data) {
|
||||
}
|
||||
if (is_receiving) {
|
||||
if (header.session_id != h.session_id) {
|
||||
piCoutObj << "restart receive";
|
||||
piCoutObj << "restart receive"_tr("PIBaseTransfer");
|
||||
mutex_header.unlock();
|
||||
finish_receive(false, true);
|
||||
} else {
|
||||
@@ -344,7 +347,7 @@ bool PIBaseTransfer::send_process() {
|
||||
mutex_send.unlock();
|
||||
if (break_) return finish_send(false);
|
||||
}
|
||||
// piCoutObj << "send done, checking";
|
||||
// piCoutObj << "send done, checking";
|
||||
PITimeMeasurer rtm;
|
||||
int prev_chk = 0;
|
||||
mutex_send.lock();
|
||||
@@ -516,7 +519,7 @@ bool PIBaseTransfer::getStartRequest() {
|
||||
diag.sended(ba.size_s());
|
||||
sendRequest(ba);
|
||||
if (break_) return false;
|
||||
// piCoutObj << replies[0];
|
||||
// piCoutObj << replies[0];
|
||||
mutex_session.lock();
|
||||
if (replies[0] == pt_ReplySuccess) {
|
||||
state_string = "send permited!";
|
||||
@@ -532,7 +535,7 @@ bool PIBaseTransfer::getStartRequest() {
|
||||
|
||||
|
||||
void PIBaseTransfer::processData(int id, PIByteArray & data) {
|
||||
// piCoutObj << "received packet" << id << ", size" << data.size();
|
||||
// piCoutObj << "received packet" << id << ", size" << data.size();
|
||||
if (id < 1 || id > replies.size_s()) return;
|
||||
if (!session[id - 1].isEmpty()) {
|
||||
header.id = id;
|
||||
@@ -595,7 +598,7 @@ PIByteArray PIBaseTransfer::build_packet(int id) {
|
||||
hdr << header;
|
||||
mutex_header.unlock();
|
||||
ret.insert(0, hdr);
|
||||
// piCoutObj << "Send Packet" << header.id << ret.size();
|
||||
// piCoutObj << "Send Packet" << header.id << ret.size();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "piiostream.h"
|
||||
#include "piliterals_time.h"
|
||||
#include "pitime.h"
|
||||
#include "pitranslator.h"
|
||||
|
||||
/** \class PIConnection
|
||||
* \brief Complex Input/Output point
|
||||
@@ -142,7 +143,7 @@ bool PIConnection::configure(PIConfig & conf, const PIString & name_) {
|
||||
// piCout << name_list << flt_list << chk_set;
|
||||
chk_set.remove("");
|
||||
if (!chk_set.isEmpty()) {
|
||||
piCoutObj << "Error," << chk_set.toVector() << "names assigned to both devices and filters!";
|
||||
piCoutObj << "Error,"_tr("PIConnection") << chk_set.toVector() << "names assigned to both devices and filters!"_tr("PIConnection");
|
||||
return false;
|
||||
}
|
||||
PIMap<PIString, PIString> dev_aliases;
|
||||
@@ -238,7 +239,7 @@ bool PIConnection::configure(PIConfig & conf, const PIString & name_) {
|
||||
}
|
||||
setDebug(pdebug);
|
||||
for (const PIString & f: filter_fails) {
|
||||
piCoutObj << "\"addFilter\" error: no such device \"" << f << "\"!";
|
||||
piCoutObj << "\"addFilter\" error: no such device \"%1\"!"_tr("PIConnection").arg(f);
|
||||
}
|
||||
for (const PIConfig::Entry * e: cb) {
|
||||
PIString f(e->getValue("from").value()), t(e->getValue("to").value());
|
||||
@@ -469,7 +470,7 @@ PIPacketExtractor * PIConnection::addFilter(const PIString & name_, const PIStri
|
||||
if (extractors.value(full_path, nullptr)) pe = extractors.value(full_path, nullptr)->extractor;
|
||||
if (pe) dev = pe;
|
||||
if (!dev) {
|
||||
piCoutObj << "\"addFilter\" error: no such device or filter \"" << full_path << "\"!";
|
||||
piCoutObj << "\"addFilter\" error: no such device or filter \"%1\"!"_tr("PIConnection").arg(full_path);
|
||||
return nullptr;
|
||||
}
|
||||
if (!e) {
|
||||
@@ -508,7 +509,7 @@ PIPacketExtractor * PIConnection::addFilter(PIPacketExtractor * filter, const PI
|
||||
if (pe) {
|
||||
dev = pe;
|
||||
} else {
|
||||
piCoutObj << "\"addFilter\" error: no such device or filter \"" << full_path << "\"!";
|
||||
piCoutObj << "\"addFilter\" error: no such device or filter \"%1\"!"_tr("PIConnection").arg(full_path);
|
||||
return nullptr;
|
||||
}
|
||||
if (!e) {
|
||||
@@ -739,7 +740,7 @@ void PIConnection::addSender(const PIString & name_, const PIString & full_path_
|
||||
}
|
||||
PIIODevice * dev = devByString(full_path_name);
|
||||
if (!dev) {
|
||||
piCoutObj << "\"addSender\" error: no such device \"" << full_path_name << "\"!";
|
||||
piCoutObj << "\"addSender\" error: no such device \"%1\"!"_tr("PIConnection").arg(full_path_name);
|
||||
return;
|
||||
}
|
||||
if (!s->isRunning() && start_) {
|
||||
@@ -899,7 +900,7 @@ int PIConnection::writeByFullPath(const PIString & full_path, const PIByteArray
|
||||
PIIODevice * dev = __device_pool__->device(fp);
|
||||
// piCout << "SEND" << full_path << fp;
|
||||
if (!dev) {
|
||||
piCoutObj << "No such full path \"" << full_path << "\"!";
|
||||
piCoutObj << "No such full path \"%1\"!"_tr("PIConnection").arg(full_path);
|
||||
return -1;
|
||||
}
|
||||
return write(dev, data);
|
||||
@@ -909,7 +910,7 @@ int PIConnection::writeByFullPath(const PIString & full_path, const PIByteArray
|
||||
int PIConnection::writeByName(const PIString & name_, const PIByteArray & data) {
|
||||
PIIODevice * dev = deviceByName(name_);
|
||||
if (!dev) {
|
||||
piCoutObj << "No such device \"" << name_ << "\"!";
|
||||
piCoutObj << "No such device \"%1\"!"_tr("PIConnection").arg(name_);
|
||||
return -1;
|
||||
}
|
||||
return write(dev, data);
|
||||
@@ -918,12 +919,12 @@ int PIConnection::writeByName(const PIString & name_, const PIByteArray & data)
|
||||
|
||||
int PIConnection::write(PIIODevice * dev, const PIByteArray & data) {
|
||||
if (!dev) {
|
||||
piCoutObj << "Null Device!";
|
||||
piCoutObj << "Null Device!"_tr("PIConnection");
|
||||
return -1;
|
||||
}
|
||||
if (!dev->isOpened()) return -1;
|
||||
if (!dev->canWrite()) {
|
||||
piCoutObj << "Device \"" << dev->constructFullPath() << "\" can`t write!";
|
||||
piCoutObj << "Device \"%1\" can`t write!"_tr("PIConnection").arg(dev->constructFullPath());
|
||||
return -1;
|
||||
}
|
||||
int ret = dev->write(data);
|
||||
@@ -982,7 +983,7 @@ PIIODevice * PIConnection::DevicePool::addDevice(PIConnection * parent, const PI
|
||||
// piCout << "new device" << fp;
|
||||
dd->dev = PIIODevice::createFromFullPath(fp);
|
||||
if (!dd->dev) {
|
||||
piCoutObj << "Error: can`t create device \"" << fp << "\"!"; //:" << errorString();
|
||||
piCoutObj << "Error: can`t create device \"%1\"!"_tr("PIConnection").arg(fp);
|
||||
return nullptr;
|
||||
}
|
||||
dd->dev->setProperty("__fullPath__", fp);
|
||||
@@ -1258,7 +1259,7 @@ void PIConnection::unboundExtractor(PIPacketExtractor * pe) {
|
||||
void PIConnection::packetExtractorReceived(const uchar * data, int size) {
|
||||
PIString from(emitter() ? emitter()->name() : PIString());
|
||||
PIIODevice * cd = (PIIODevice *)emitter();
|
||||
// piCout << "packetExtractorReceived" << from << cd;
|
||||
// piCout << "packetExtractorReceived" << from << cd;
|
||||
if (cd) {
|
||||
PIVector<PIPacketExtractor *> be(bounded_extractors.value(cd));
|
||||
// piCout << be << (void*)data << size;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "pidiagnostics.h"
|
||||
|
||||
#include "piliterals_time.h"
|
||||
#include "pitranslator.h"
|
||||
|
||||
|
||||
/** \class PIDiagnostics
|
||||
@@ -40,7 +41,7 @@
|
||||
|
||||
|
||||
PIDiagnostics::State::State() {
|
||||
receive_speed = send_speed = PIString::readableSize(0) + "/s";
|
||||
receive_speed = send_speed = PIString::readableSize(0) + PITranslator::tr("/s", "PIDiag");
|
||||
}
|
||||
|
||||
|
||||
@@ -151,6 +152,7 @@ void PIDiagnostics::sended(int size) {
|
||||
|
||||
|
||||
void PIDiagnostics::tick(int) {
|
||||
auto speed_sec = "/s"_tr("PIDiag");
|
||||
mutex_state.lock();
|
||||
// piCoutObj << "lock";
|
||||
int tcnt_recv = 0;
|
||||
@@ -176,8 +178,8 @@ void PIDiagnostics::tick(int) {
|
||||
cur_state.sended_bytes_per_sec = ullong(double(send.bytes_ok) / its);
|
||||
}
|
||||
// piCoutObj << "tick" << recv.cnt_ok << send.cnt_ok;
|
||||
cur_state.receive_speed = PIString::readableSize(cur_state.received_bytes_per_sec) + "/s";
|
||||
cur_state.send_speed = PIString::readableSize(cur_state.sended_bytes_per_sec) + "/s";
|
||||
cur_state.receive_speed = PIString::readableSize(cur_state.received_bytes_per_sec) + speed_sec;
|
||||
cur_state.send_speed = PIString::readableSize(cur_state.sended_bytes_per_sec) + speed_sec;
|
||||
int arc = recv.cnt_ok + recv.cnt_fail;
|
||||
float good_percents = 0.f;
|
||||
if (arc > 0) good_percents = (float)recv.cnt_ok / arc * 100.f;
|
||||
@@ -195,7 +197,7 @@ void PIDiagnostics::tick(int) {
|
||||
diag = PIDiagnostics::Good;
|
||||
}
|
||||
if ((tcnt_send + tcnt_recv) != 0) {
|
||||
// piCoutObj << tcnt_recv << tcnt_send;
|
||||
// piCoutObj << tcnt_recv << tcnt_send;
|
||||
history_rec.dequeue();
|
||||
history_send.dequeue();
|
||||
Entry e;
|
||||
@@ -223,7 +225,7 @@ PIDiagnostics::Entry PIDiagnostics::calcHistory(PIQueue<Entry> & hist, int & cnt
|
||||
if (!hist[i].empty) cnt++;
|
||||
}
|
||||
e.empty = false;
|
||||
// piCoutObj << hist.size() << cnt;
|
||||
// piCoutObj << hist.size() << cnt;
|
||||
return e;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user