git-svn-id: svn://db.shs.com.ru/pip@420 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -65,6 +65,9 @@ public:
|
||||
void setTimeout(double sec) {timeout_ = sec; diag.setDisconnectTimeout(sec);}
|
||||
double timeout() const {return timeout_;}
|
||||
|
||||
void setCRCEnabled(bool en = true) {crc_enabled = en;}
|
||||
bool isCRCEnabled() const {return crc_enabled;}
|
||||
|
||||
const PIString & stateString() const {return state_string;}
|
||||
llong bytesAll() const {return bytes_all;}
|
||||
llong bytesCur() const {return bytes_cur;}
|
||||
@@ -89,19 +92,18 @@ public:
|
||||
EVENT1(sendRequest, PIByteArray &, data)
|
||||
|
||||
protected:
|
||||
void buildSession(PIVector<Part> parts);
|
||||
virtual PIByteArray buildPacket(Part fi) = 0;
|
||||
virtual void receivePart(Part fi, PIByteArray ba, PIByteArray pheader) = 0;
|
||||
virtual PIByteArray customHeader() {return PIByteArray();}
|
||||
bool send_process();
|
||||
|
||||
uint packet_header_size, part_header_size;
|
||||
bool break_, is_sending, is_receiving, is_pause;
|
||||
PIString state_string;
|
||||
llong bytes_all, bytes_cur;
|
||||
|
||||
void buildSession(PIVector<Part> parts);
|
||||
virtual PIByteArray buildPacket(Part fi) = 0;
|
||||
virtual void receivePart(Part fi, PIByteArray ba, PIByteArray pheader) = 0;
|
||||
virtual PIByteArray customHeader() {return PIByteArray();}
|
||||
bool send_process();
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
enum PacketType {pt_Unknown, pt_Data, pt_ReplySuccess, pt_ReplyInvalid, pt_Break, pt_Start, pt_Pause};
|
||||
|
||||
# pragma pack(push,1)
|
||||
@@ -114,6 +116,15 @@ private:
|
||||
friend PIByteArray & operator >>(PIByteArray & s, PIBaseTransfer::StartRequest & v);
|
||||
friend PIByteArray & operator <<(PIByteArray & s, const PIBaseTransfer::StartRequest & v);
|
||||
|
||||
void processData(int id, PIByteArray &data);
|
||||
PIByteArray build_packet(int id);
|
||||
int checkSession();
|
||||
void sendBreak(int session_id);
|
||||
void sendReply(PacketType reply);
|
||||
bool getStartRequest();
|
||||
bool finish_send(bool ok);
|
||||
void finish_receive(bool ok, bool quet = false);
|
||||
|
||||
static const uint signature;
|
||||
int packet_size, packets_count;
|
||||
double timeout_;
|
||||
@@ -127,15 +138,7 @@ private:
|
||||
PIMutex mutex_session;
|
||||
PIMutex mutex_send;
|
||||
PIMutex mutex_header;
|
||||
|
||||
void processData(int id, PIByteArray &data);
|
||||
PIByteArray build_packet(int id);
|
||||
int checkSession();
|
||||
void sendBreak(int session_id);
|
||||
void sendReply(PacketType reply);
|
||||
bool getStartRequest();
|
||||
bool finish_send(bool ok);
|
||||
void finish_receive(bool ok, bool quet = false);
|
||||
bool crc_enabled;
|
||||
};
|
||||
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIBaseTransfer::PacketHeader & v) {s << v.sig << v.type << v.session_id << v.id << v.crc; return s;}
|
||||
|
||||
Reference in New Issue
Block a user