git-svn-id: svn://db.shs.com.ru/pip@260 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -233,7 +233,7 @@ PISystemTime PISystemTime::current(bool precise_but_not_system) {
|
|||||||
sft.dwHighDateTime = ft.dwHighDateTime - __pi_ftjan1970.dwHighDateTime;
|
sft.dwHighDateTime = ft.dwHighDateTime - __pi_ftjan1970.dwHighDateTime;
|
||||||
if (ft.dwLowDateTime < __pi_ftjan1970.dwLowDateTime) {
|
if (ft.dwLowDateTime < __pi_ftjan1970.dwLowDateTime) {
|
||||||
sft.dwLowDateTime = ft.dwLowDateTime + (0xFFFFFFFF - __pi_ftjan1970.dwLowDateTime);
|
sft.dwLowDateTime = ft.dwLowDateTime + (0xFFFFFFFF - __pi_ftjan1970.dwLowDateTime);
|
||||||
sft.dwHighDateTime++;
|
sft.dwHighDateTime--;
|
||||||
} else
|
} else
|
||||||
sft.dwLowDateTime = ft.dwLowDateTime - __pi_ftjan1970.dwLowDateTime;
|
sft.dwLowDateTime = ft.dwLowDateTime - __pi_ftjan1970.dwLowDateTime;
|
||||||
ullong lt = ullong(sft.dwHighDateTime) * 0x100000000U + ullong(sft.dwLowDateTime);
|
ullong lt = ullong(sft.dwHighDateTime) * 0x100000000U + ullong(sft.dwLowDateTime);
|
||||||
|
|||||||
@@ -80,6 +80,16 @@ bool PIBinaryLog::openDevice() {
|
|||||||
if (path().isEmpty() && mode_ == WriteOnly) {
|
if (path().isEmpty() && mode_ == WriteOnly) {
|
||||||
setPath(getLogfilePath());
|
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_)) {
|
if (!file.open(path(), mode_)) {
|
||||||
piCoutObj << "Error: Can't open file" << path();
|
piCoutObj << "Error: Can't open file" << path();
|
||||||
return false;
|
return false;
|
||||||
@@ -129,6 +139,8 @@ bool PIBinaryLog::closeDevice() {
|
|||||||
|
|
||||||
|
|
||||||
bool PIBinaryLog::threadedRead(uchar *readed, int size) {
|
bool PIBinaryLog::threadedRead(uchar *readed, int size) {
|
||||||
|
// piCout << "binlog threaded read";
|
||||||
|
if (!canRead() || isEnd()) return PIIODevice::threadedRead(readed, size);
|
||||||
is_thread_ok = false;
|
is_thread_ok = false;
|
||||||
PISystemTime pt;
|
PISystemTime pt;
|
||||||
double delay;
|
double delay;
|
||||||
@@ -136,6 +148,8 @@ bool PIBinaryLog::threadedRead(uchar *readed, int size) {
|
|||||||
case PlayRealTime:
|
case PlayRealTime:
|
||||||
pt = PISystemTime::current() - startlogtime;
|
pt = PISystemTime::current() - startlogtime;
|
||||||
if (is_started) {
|
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)
|
if (lastrecord.timestamp > pt)
|
||||||
(lastrecord.timestamp - pt).sleep();
|
(lastrecord.timestamp - pt).sleep();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1073,6 +1073,7 @@ void __DevicePool_threadReadDP(void * ddp) {
|
|||||||
if (dd->dev == 0) {piMSleep(100); return;}
|
if (dd->dev == 0) {piMSleep(100); return;}
|
||||||
PIByteArray ba;
|
PIByteArray ba;
|
||||||
ba = dd->dev->read(dd->dev->threadedReadBufferSize());
|
ba = dd->dev->read(dd->dev->threadedReadBufferSize());
|
||||||
|
// dd->dev->threadedRead(ba.data(), ba.size());
|
||||||
if (ba.isEmpty()) {piMSleep(10); return;}
|
if (ba.isEmpty()) {piMSleep(10); return;}
|
||||||
dd->dev->threadedRead(ba.data(), ba.size_s());
|
dd->dev->threadedRead(ba.data(), ba.size_s());
|
||||||
//piCout << "Readed from" << dd->dev->path() << Hex << ba;
|
//piCout << "Readed from" << dd->dev->path() << Hex << ba;
|
||||||
|
|||||||
@@ -319,3 +319,10 @@ PIString PIIODevice::normalizeFullPath(const PIString & full_path) {
|
|||||||
nfp_cache[full_path] = ret;
|
nfp_cache[full_path] = ret;
|
||||||
return 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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ typedef bool (*ReadRetFunc)(void * , uchar * , int );
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
class PIP_EXPORT PIIODevice: public PIThread
|
class PIP_EXPORT PIIODevice: public PIThread
|
||||||
{
|
{
|
||||||
PIOBJECT_SUBCLASS(PIIODevice, PIThread)
|
PIOBJECT_SUBCLASS(PIIODevice, PIThread)
|
||||||
@@ -293,7 +294,7 @@ protected:
|
|||||||
virtual bool closeDevice() {return true;} // use path_, type_, opened_, init_ variables
|
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_"
|
//! 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
|
//! Reimplement to configure your device with parameters of full unambiguous string. Default implementation does nothing
|
||||||
|
|||||||
@@ -623,7 +623,7 @@ int PISerial::read(void * read_to, int max_size) {
|
|||||||
if (!canRead()) return -1;
|
if (!canRead()) return -1;
|
||||||
if (sending) return -1;
|
if (sending) return -1;
|
||||||
// piCoutObj << "com event ...";
|
// piCoutObj << "com event ...";
|
||||||
WaitCommEvent(PRIVATE->hCom, 0, 0);
|
//WaitCommEvent(PRIVATE->hCom, 0, 0);
|
||||||
// piCoutObj << "read ...";
|
// piCoutObj << "read ...";
|
||||||
ReadFile(PRIVATE->hCom, read_to, max_size, &PRIVATE->readed, 0);
|
ReadFile(PRIVATE->hCom, read_to, max_size, &PRIVATE->readed, 0);
|
||||||
// piCoutObj << "read ok";
|
// piCoutObj << "read ok";
|
||||||
|
|||||||
Reference in New Issue
Block a user