git-svn-id: svn://db.shs.com.ru/pip@260 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2016-09-08 04:59:52 +00:00
parent 3983ee1648
commit a37211aad3
6 changed files with 26 additions and 3 deletions

View File

@@ -233,7 +233,7 @@ PISystemTime PISystemTime::current(bool precise_but_not_system) {
sft.dwHighDateTime = ft.dwHighDateTime - __pi_ftjan1970.dwHighDateTime;
if (ft.dwLowDateTime < __pi_ftjan1970.dwLowDateTime) {
sft.dwLowDateTime = ft.dwLowDateTime + (0xFFFFFFFF - __pi_ftjan1970.dwLowDateTime);
sft.dwHighDateTime++;
sft.dwHighDateTime--;
} else
sft.dwLowDateTime = ft.dwLowDateTime - __pi_ftjan1970.dwLowDateTime;
ullong lt = ullong(sft.dwHighDateTime) * 0x100000000U + ullong(sft.dwLowDateTime);

View File

@@ -80,6 +80,16 @@ bool PIBinaryLog::openDevice() {
if (path().isEmpty() && mode_ == WriteOnly) {
setPath(getLogfilePath());
}
if (path().isEmpty() && mode_ == ReadOnly) {
PIDir ld(logDir());
if (ld.isExists()) {
PIVector<PIFile::FileInfo> es = ld.allEntries();
piForeachC(PIFile::FileInfo &i, es) {
if (i.extension() == "binlog" && i.isFile())
setPath(i.path);
}
}
}
if (!file.open(path(), mode_)) {
piCoutObj << "Error: Can't open file" << path();
return false;
@@ -129,6 +139,8 @@ bool PIBinaryLog::closeDevice() {
bool PIBinaryLog::threadedRead(uchar *readed, int size) {
// piCout << "binlog threaded read";
if (!canRead() || isEnd()) return PIIODevice::threadedRead(readed, size);
is_thread_ok = false;
PISystemTime pt;
double delay;
@@ -136,6 +148,8 @@ bool PIBinaryLog::threadedRead(uchar *readed, int size) {
case PlayRealTime:
pt = PISystemTime::current() - startlogtime;
if (is_started) {
if ((lastrecord.timestamp - pt).toSeconds() > 100. || (lastrecord.timestamp - pt).toSeconds() < -100.)
piCoutObj << PISystemTime::current() << startlogtime << pt << lastrecord.timestamp << (lastrecord.timestamp - pt);
if (lastrecord.timestamp > pt)
(lastrecord.timestamp - pt).sleep();
} else {

View File

@@ -1073,6 +1073,7 @@ void __DevicePool_threadReadDP(void * ddp) {
if (dd->dev == 0) {piMSleep(100); return;}
PIByteArray ba;
ba = dd->dev->read(dd->dev->threadedReadBufferSize());
// dd->dev->threadedRead(ba.data(), ba.size());
if (ba.isEmpty()) {piMSleep(10); return;}
dd->dev->threadedRead(ba.data(), ba.size_s());
//piCout << "Readed from" << dd->dev->path() << Hex << ba;

View File

@@ -319,3 +319,10 @@ PIString PIIODevice::normalizeFullPath(const PIString & full_path) {
nfp_cache[full_path] = ret;
return ret;
}
bool PIIODevice::threadedRead(uchar *readed, int size) {
// piCout << "iodevice threaded read";
if (ret_func_ != 0) return ret_func_(ret_data_, readed, size);
return true;
}

View File

@@ -46,6 +46,7 @@ typedef bool (*ReadRetFunc)(void * , uchar * , int );
#endif
class PIP_EXPORT PIIODevice: public PIThread
{
PIOBJECT_SUBCLASS(PIIODevice, PIThread)
@@ -293,7 +294,7 @@ protected:
virtual bool closeDevice() {return true;} // use path_, type_, opened_, init_ variables
//! Function executed when thread read some data, default implementation execute external slot "ret_func_"
virtual bool threadedRead(uchar * readed, int size) {if (ret_func_ != 0) return ret_func_(ret_data_, readed, size); return true;}
virtual bool threadedRead(uchar * readed, int size);
//! Reimplement to configure your device with parameters of full unambiguous string. Default implementation does nothing

View File

@@ -623,7 +623,7 @@ int PISerial::read(void * read_to, int max_size) {
if (!canRead()) return -1;
if (sending) return -1;
// piCoutObj << "com event ...";
WaitCommEvent(PRIVATE->hCom, 0, 0);
//WaitCommEvent(PRIVATE->hCom, 0, 0);
// piCoutObj << "read ...";
ReadFile(PRIVATE->hCom, read_to, max_size, &PRIVATE->readed, 0);
// piCoutObj << "read ok";