7.12.2010 - bug fixes in PIString, all classes now based on PIString
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "piprotocol.h"
|
||||
|
||||
|
||||
PIProtocol::PIProtocol(string devName, int speed, void * headerPtr, int headerSize, void * dataPtr, int dataSize) {
|
||||
PIProtocol::PIProtocol(PIString devName, int speed, void * headerPtr, int headerSize, void * dataPtr, int dataSize) {
|
||||
init();
|
||||
type = PIProtocol::Serial;
|
||||
serial = new PISerial(devName, this, received);
|
||||
@@ -15,7 +15,7 @@ PIProtocol::PIProtocol(string devName, int speed, void * headerPtr, int headerSi
|
||||
}
|
||||
|
||||
|
||||
PIProtocol::PIProtocol(string ip, int port, void * dataPtr, int dataSize) {
|
||||
PIProtocol::PIProtocol(PIString ip, int port, void * dataPtr, int dataSize) {
|
||||
init();
|
||||
type = PIProtocol::Ethernet;
|
||||
ether = new PIEthernet(ip, port, this, received);
|
||||
@@ -49,7 +49,7 @@ void PIProtocol::init() {
|
||||
}
|
||||
|
||||
|
||||
void PIProtocol::setDevice(const string & dev_ip, int speed_port) {
|
||||
void PIProtocol::setDevice(const PIString & dev_ip, int speed_port) {
|
||||
if (type == PIProtocol::Serial) {
|
||||
serial->setDevice(dev_ip);
|
||||
serial->setSpeed(speed_port);
|
||||
@@ -124,11 +124,11 @@ void PIProtocol::calc_diag() {
|
||||
last_packets[pckt_cnt] = cur_pckt;
|
||||
pckt_cnt++;
|
||||
} else {
|
||||
packets[last_packets.back()]--;
|
||||
packets[(int)last_packets.back()]--;
|
||||
last_packets.pop_back();
|
||||
last_packets.push_front(cur_pckt);
|
||||
}
|
||||
packets[cur_pckt]++;
|
||||
packets[(int)cur_pckt]++;
|
||||
cur_pckt = 0;
|
||||
float good_percents;
|
||||
good_percents = (float)packets[1] / pckt_cnt * 100.0f;
|
||||
@@ -148,7 +148,7 @@ void PIProtocol::calc_freq() {
|
||||
if (last_freq.size() >= pckt_cnt_max) last_freq.pop_front();
|
||||
last_freq.push_back(tf);
|
||||
tf = last_freq[0];
|
||||
for (int i = 1; i < last_freq.size(); ++i)
|
||||
for (uint i = 1; i < last_freq.size(); ++i)
|
||||
tf += last_freq[i];
|
||||
integralFreq = tf / last_freq.size();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user