Commit 6a27d830 authored by Pavel Vainerman's avatar Pavel Vainerman

Глобальный переход от microseconds --> nanoseconds

[timeval --> timespec, gettimeofday --> clock_gettime] ТРЕБУЕТСЯ КОНВЕРТИРОВАНИЕ БД! т.к. поле 'time_usec' меняется на 'time_nsec'
parent 0b8286f5
......@@ -103,8 +103,8 @@ interface IOController_i : UniSetManager_i
IOController_i::SensorInfo si;
long default_val; /*!< значение по умолчанию */
CalibrateInfo ci; /*!< калибровочные параметры */
long tv_sec; /*!< время последнего изменения датчика, секунды (gettimeofday) */
long tv_usec; /*!< время последнего изменения датчика, мксек (gettimeofday) */
unsigned long tv_sec; /*!< время последнего изменения датчика, секунды (clock_gettime(CLOCK_REALTIME) */
unsigned long tv_nsec; /*!< время последнего изменения датчика, nanosec (clock_gettime(CLOCK_REALTIME) */
UniSetTypes::ObjectId supplier; /*!< идентификатор объекта изменившего состояние датчика */
boolean dbignore; /*!< не сохранять изменения в БД */
};
......@@ -140,8 +140,10 @@ interface IOController_i : UniSetManager_i
struct ShortIOInfo
{
long value;
long tv_sec; /*!< время последнего изменения датчика, секунды (gettimeofday) */
long tv_usec; /*!< время последнего изменения датчика, мксек (gettimeofday) */
// могут быть проблеммы в 64bit-ных
unsigned long tv_sec; /*!< время последнего изменения датчика, секунды (clock_gettime(CLOCK_REALTIME) */
unsigned long tv_nsec; /*!< время последнего изменения датчика, nanosec (clock_gettime(CLOCK_REALTIME) */
UniSetTypes::ObjectId supplier; /*!< идентификатор того, кто менял датчик (последний раз) */
};
......@@ -207,8 +209,8 @@ interface IONotifyController_i : IOController_i
long hilimit; /*!< верхняя граница срабатывания */
long lowlimit; /*!< нижняя гранийа срабатывания */
ThresholdState state;
long tv_sec; /*!< время последнего изменения датчика, секунды (gettimeofday) */
long tv_usec; /*!< время последнего изменения датчика, мксек (gettimeofday) */
unsigned long tv_sec; /*!< время последнего изменения датчика, секунды (clock_gettime(CLOCK_REALTIME) */
unsigned long tv_nsec; /*!< время последнего изменения датчика, nanosec (clock_gettime(CLOCK_REALTIME) */
boolean invert; /*!< инвертированная логика */
};
......
......@@ -317,7 +317,7 @@ CXX_EXTRA_FLAGS="-Wnon-virtual-dtor -Woverloaded-virtual -Woverflow -D_GLIBCXX_U
# export
LDFLAGS="$LDFLAGS ${OMNI_LIBS} ${XML_LIBS} ${SIGC_LIBS} ${COV_LIBS} ${COMCPP_LIBS}"
# all developer liked options add to autogen.sh, please
CXXFLAGS="$CXXFLAGS -funsigned-char -std=c++11 -g -D_GNU_SOURCE ${OMNI_CFLAGS} ${XML_CFLAGS} ${SIGC_CFLAGS} ${COV_CFLAGS} ${COMCPP_CFLAGS} -I\$(top_builddir)/include $CXX_EXTRA_FLAGS"
CXXFLAGS="-I\$(top_builddir)/include $CXXFLAGS -funsigned-char -std=c++11 -g -D_GNU_SOURCE ${OMNI_CFLAGS} ${XML_CFLAGS} ${SIGC_CFLAGS} ${COV_CFLAGS} ${COMCPP_CFLAGS} $CXX_EXTRA_FLAGS"
AC_SUBST(LDFLAGS)
AC_SUBST(CXXFLAGS)
......
......@@ -106,7 +106,7 @@ void DBServer_MySQL::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
<< " WHERE sensor_id='" << cem->sensor_id << "'"
<< " AND date='" << dateToString(cem->time, "-") << " '"
<< " AND time='" << timeToString(cem->time, ":") << " '"
<< " AND time_usec='" << cem->time_usec << " '";
<< " AND time_nsec='" << cem->time_nsec << " '";
dbinfo << myname << "(update_confirm): " << data.str() << endl;
......@@ -201,7 +201,12 @@ void DBServer_MySQL::sensorInfo( const UniSetTypes::SensorMessage* si )
// если время не было выставлено (указываем время сохранения в БД)
if( !si->tm.tv_sec )
{
gettimeofday( const_cast<struct timeval*>(&si->tm), NULL);
// Выдаём CRIT, но тем не менее сохраняем в БД
dbcrit << myname << "(insert_main_history): UNKNOWN TIMESTAMP! (tm.tv_sec=0)"
<< " for sid=" << si->id
<< " supplier=" << uniset_conf()->oind->getMapName(si->supplier)
<< endl;
}
float val = (float)si->value / (float)pow10(si->ci.precision);
......@@ -209,11 +214,11 @@ void DBServer_MySQL::sensorInfo( const UniSetTypes::SensorMessage* si )
// см. DBTABLE AnalogSensors, DigitalSensors
ostringstream data;
data << "INSERT INTO " << tblName(si->type)
<< "(date, time, time_usec, sensor_id, value, node) VALUES( '"
<< "(date, time, time_nsec, sensor_id, value, node) VALUES( '"
// Поля таблицы
<< dateToString(si->sm_tv_sec, "-") << "','" // date
<< timeToString(si->sm_tv_sec, ":") << "','" // time
<< si->sm_tv_usec << "','" // time_usec
<< dateToString(si->sm_tv.tv_sec, "-") << "','" // date
<< timeToString(si->sm_tv.tv_sec, ":") << "','" // time
<< si->sm_tv.tv_nsec << "','" // time_nsec
<< si->id << "','" // sensor_id
<< val << "','" // value
<< si->node << "')"; // node
......
......@@ -87,7 +87,7 @@ CREATE TABLE `main_history` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` date NOT NULL,
`time` time NOT NULL,
`time_usec` int(10) unsigned NOT NULL,
`time_nsec` int(10) unsigned NOT NULL,
`sensor_id` int(10) unsigned NOT NULL,
`value` double NOT NULL,
`node` int(10) unsigned NOT NULL,
......@@ -102,7 +102,7 @@ CREATE TABLE `main_emergencylog` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` date NOT NULL,
`time` time NOT NULL,
`time_usec` int(10) unsigned NOT NULL,
`time_nsec` int(10) unsigned NOT NULL,
`type_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `main_emergencylog_type_id` (`type_id`),
......@@ -115,7 +115,7 @@ CREATE TABLE `main_emergencyrecords` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` date NOT NULL,
`time` time NOT NULL,
`time_usec` int(10) unsigned NOT NULL,
`time_nsec` int(10) unsigned NOT NULL,
`log_id` int(11) NOT NULL,
`sensor_id` int(10) unsigned NOT NULL,
`value` double NOT NULL,
......
......@@ -117,7 +117,7 @@ void DBServer_PostgreSQL::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
<< " WHERE sensor_id='" << cem->sensor_id << "'"
<< " AND date='" << dateToString(cem->time, "-") << " '"
<< " AND time='" << timeToString(cem->time, ":") << " '"
<< " AND time_usec='" << cem->time_usec << " '";
<< " AND time_nsec='" << cem->time_nsec << " '";
dbinfo << myname << "(update_confirm): " << data.str() << endl;
......@@ -249,23 +249,22 @@ void DBServer_PostgreSQL::sensorInfo( const UniSetTypes::SensorMessage* si )
{
try
{
#if 0
// если время не было выставлено (указываем время сохранения в БД)
struct timeval tm = si->tm;
if( !tm.tv_sec )
if( !si->tm.tv_sec )
{
struct timezone tz;
gettimeofday(&tm, &tz);
// Выдаём CRIT, но тем не менее сохраняем в БД
dbcrit << myname << "(insert_main_history): UNKNOWN TIMESTAMP! (tm.tv_sec=0)"
<< " for sid=" << si->id
<< " supplier=" << uniset_conf()->oind->getMapName(si->supplier)
<< endl;
}
#endif
// (date, time, time_usec, sensor_id, value, node)
// (date, time, time_nsec, sensor_id, value, node)
PostgreSQLInterface::Record rec =
{
dateToString(si->sm_tv_sec, "-"), // date
timeToString(si->sm_tv_sec, ":"), // time
std::to_string(si->sm_tv_usec),
dateToString(si->sm_tv.tv_sec, "-"), // date
timeToString(si->sm_tv.tv_sec, ":"), // time
std::to_string(si->sm_tv.tv_nsec),
std::to_string(si->id),
std::to_string(si->value),
std::to_string(si->node),
......
......@@ -103,7 +103,7 @@ void DBServer_SQLite::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
<< " WHERE sensor_id='" << cem->sensor_id << "'"
<< " AND date='" << dateToString(cem->time, "-") << " '"
<< " AND time='" << timeToString(cem->time, ":") << " '"
<< " AND time_usec='" << cem->time_usec << " '";
<< " AND time_nsec='" << cem->time_nsec << " '";
dbinfo << myname << "(update_confirm): " << data.str() << endl;
......@@ -184,7 +184,12 @@ void DBServer_SQLite::sensorInfo( const UniSetTypes::SensorMessage* si )
// если время не было выставлено (указываем время сохранения в БД)
if( !si->tm.tv_sec )
{
gettimeofday(const_cast<struct timeval*>(&si->tm), NULL);
// Выдаём CRIT, но тем не менее сохраняем в БД
dbcrit << myname << "(insert_main_history): UNKNOWN TIMESTAMP! (tm.tv_sec=0)"
<< " for sid=" << si->id
<< " supplier=" << uniset_conf()->oind->getMapName(si->supplier)
<< endl;
}
float val = (float)si->value / (float)pow10(si->ci.precision);
......@@ -192,11 +197,11 @@ void DBServer_SQLite::sensorInfo( const UniSetTypes::SensorMessage* si )
// см. DBTABLE AnalogSensors, DigitalSensors
ostringstream data;
data << "INSERT INTO " << tblName(si->type)
<< "(date, time, time_usec, sensor_id, value, node) VALUES( '"
<< "(date, time, time_nsec, sensor_id, value, node) VALUES( '"
// Поля таблицы
<< dateToString(si->sm_tv_sec, "-") << "','" // date
<< timeToString(si->sm_tv_sec, ":") << "','" // time
<< si->sm_tv_usec << "'," // time_usec
<< dateToString(si->sm_tv.tv_sec, "-") << "','" // date
<< timeToString(si->sm_tv.tv_sec, ":") << "','" // time
<< si->sm_tv.tv_nsec << "'," // time_nsec
<< si->id << "','" // sensor_id
<< val << "','" // value
<< si->node << "')"; // node
......
......@@ -87,7 +87,7 @@ CREATE TABLE `main_history` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` date NOT NULL,
`time` time NOT NULL,
`time_usec` int(10) unsigned NOT NULL,
`time_nsec` int(10) unsigned NOT NULL,
`sensor_id` int(10) unsigned NOT NULL,
`value` double NOT NULL,
`node` int(10) unsigned NOT NULL,
......@@ -102,7 +102,7 @@ CREATE TABLE `main_emergencylog` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` date NOT NULL,
`time` time NOT NULL,
`time_usec` int(10) unsigned NOT NULL,
`time_nsec` int(10) unsigned NOT NULL,
`type_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `main_emergencylog_type_id` (`type_id`),
......@@ -115,7 +115,7 @@ CREATE TABLE `main_emergencyrecords` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` date NOT NULL,
`time` time NOT NULL,
`time_usec` int(10) unsigned NOT NULL,
`time_nsec` int(10) unsigned NOT NULL,
`log_id` int(11) NOT NULL,
`sensor_id` int(10) unsigned NOT NULL,
`value` double NOT NULL,
......
......@@ -761,13 +761,13 @@ void SharedMemory::checkFuse( std::shared_ptr<USensorInfo>& usi, IOController* )
// return;
long value = 0;
long sm_tv_sec = 0;
long sm_tv_usec = 0;
unsigned long sm_tv_sec = 0;
unsigned long sm_tv_nsec = 0;
{
uniset_rwmutex_rlock lock(usi->val_lock);
value = usi->value;
sm_tv_sec = usi->tv_sec;
sm_tv_usec = usi->tv_usec;
sm_tv_nsec = usi->tv_nsec;
}
sminfo << myname << "(updateHistory): "
......@@ -792,7 +792,7 @@ void SharedMemory::checkFuse( std::shared_ptr<USensorInfo>& usi, IOController* )
sminfo << myname << "(updateHistory): HISTORY EVENT for " << (*it) << endl;
it->fuse_sec = sm_tv_sec;
it->fuse_usec = sm_tv_usec;
it->fuse_usec = sm_tv_nsec;
m_historySignal.emit( (*it) );
}
}
......@@ -811,7 +811,7 @@ void SharedMemory::checkFuse( std::shared_ptr<USensorInfo>& usi, IOController* )
sminfo << myname << "(updateHistory): HISTORY EVENT for " << (*it) << endl;
it->fuse_sec = sm_tv_sec;
it->fuse_usec = sm_tv_usec;
it->fuse_usec = sm_tv_nsec;
m_historySignal.emit( (*it) );
}
}
......@@ -822,7 +822,7 @@ void SharedMemory::checkFuse( std::shared_ptr<USensorInfo>& usi, IOController* )
sminfo << myname << "(updateHistory): HISTORY EVENT for " << (*it) << endl;
it->fuse_sec = sm_tv_sec;
it->fuse_usec = sm_tv_usec;
it->fuse_usec = sm_tv_nsec;
m_historySignal.emit( (*it) );
}
}
......
......@@ -85,7 +85,7 @@ struct IOBase
ti.id = UniSetTypes::DefaultObjectId;
ti.state = IONotifyController_i::NormalThreshold;
ti.tv_sec = 0;
ti.tv_usec = 0;
ti.tv_nsec = 0;
}
bool check_channel_break( long val ); /*!< проверка обрыва провода */
......
......@@ -326,8 +326,8 @@ class IOController:
{
UniSetTypes::uniset_rwmutex_rlock lock(val_lock);
sm.value = value;
sm.sm_tv_sec = tv_sec;
sm.sm_tv_usec = tv_usec;
sm.sm_tv.tv_sec = tv_sec;
sm.sm_tv.tv_nsec = tv_nsec;
sm.ci = ci;
sm.supplier = supplier;
sm.undefined = undefined;
......
......@@ -237,7 +237,7 @@ class IONotifyController:
r.lowlimit = lowlimit;
r.invert = invert;
r.tv_sec = tv_sec;
r.tv_usec = tv_usec;
r.tv_nsec = tv_nsec;
r.state = state;
return r;
}
......
......@@ -56,8 +56,7 @@ namespace UniSetTypes
ObjectId node = { UniSetTypes::DefaultObjectId }; // откуда
ObjectId supplier = { UniSetTypes::DefaultObjectId }; // от кого
ObjectId consumer = { UniSetTypes::DefaultObjectId }; // кому
struct timeval tm = { 0, 0 };
struct timespec tm = { 0, 0 };
Message( Message&& ) = default;
Message& operator=(Message&& ) = default;
......@@ -106,7 +105,7 @@ namespace UniSetTypes
if( tm.tv_sec != msg.tm.tv_sec )
return tm.tv_sec >= msg.tm.tv_sec;
return tm.tv_usec >= msg.tm.tv_usec;
return tm.tv_nsec >= msg.tm.tv_nsec;
}
inline TransportMessage transport_msg() const
......@@ -127,8 +126,7 @@ namespace UniSetTypes
bool undefined;
// время изменения состояния датчика
long sm_tv_sec;
long sm_tv_usec;
struct timespec sm_tv;
UniversalIO::IOType sensor_type;
IOController_i::CalibrateInfo ci;
......@@ -233,7 +231,7 @@ namespace UniSetTypes
ConfirmMessage(ObjectId in_sensor_id,
double in_value,
time_t in_time,
time_t in_time_usec,
time_t in_time_nsec,
time_t in_confirm,
Priority in_priority = Message::Medium);
......@@ -245,7 +243,7 @@ namespace UniSetTypes
ObjectId sensor_id; /* ID датчика */
double value; /* значение датчика */
time_t time; /* время, когда датчик получил сигнал */
time_t time_usec; /* время в микросекундах */
time_t time_nsec; /* время в наносекундах */
time_t confirm; /* время, когда произошло квитирование */
bool broadcast;
......
......@@ -539,7 +539,7 @@ std::ostream& UniSetTypes::operator<<( std::ostream& os, const IONotifyControlle
<< " lowlim=" << ti.lowlimit
<< " state=" << ti.state
<< " tv_sec=" << ti.tv_sec
<< " tv_usec=" << ti.tv_usec
<< " tv_nsec=" << ti.tv_nsec
<< " invert=" << ti.invert
<< " ]";
......@@ -549,7 +549,7 @@ std::ostream& UniSetTypes::operator<<( std::ostream& os, const IONotifyControlle
std::ostream& UniSetTypes::operator<<( std::ostream& os, const IOController_i::ShortIOInfo& s )
{
os << setw(10) << dateToString(s.tv_sec)
<< " " << setw(8) << timeToString(s.tv_sec) << "." << s.tv_usec
<< " " << setw(8) << timeToString(s.tv_sec) << "." << s.tv_nsec
<< " [ value=" << s.value << " supplier=" << s.supplier << " ]";
return os;
......
......@@ -304,12 +304,10 @@ void IOController::localSetValue( std::shared_ptr<USensorInfo>& usi,
usi->value = (blocked ? usi->d_off_value : value);
// запоминаем время изменения
struct timeval tm = { 0 };
tm.tv_sec = 0;
tm.tv_usec = 0;
gettimeofday(&tm, NULL);
struct timespec tm;
::clock_gettime(CLOCK_REALTIME, &tm);
usi->tv_sec = tm.tv_sec;
usi->tv_usec = tm.tv_usec;
usi->tv_nsec = tm.tv_nsec;
}
} // unlock
......@@ -376,12 +374,10 @@ void IOController::ioRegistration( std::shared_ptr<USensorInfo>& usi, bool force
IOStateList::mapped_type ai = usi;
// запоминаем начальное время
struct timeval tm;
tm.tv_sec = 0;
tm.tv_usec = 0;
gettimeofday(&tm, NULL);
struct timespec tm;
::clock_gettime(CLOCK_REALTIME, &tm);
ai->tv_sec = tm.tv_sec;
ai->tv_usec = tm.tv_usec;
ai->tv_nsec = tm.tv_nsec;
ai->value = ai->default_val;
ai->supplier = getId();
......@@ -426,8 +422,6 @@ void IOController::logging( UniSetTypes::SensorMessage& sm )
try
{
// struct timezone tz;
// gettimeofday(&sm.tm,&tz);
ObjectId dbID = uniset_conf()->getDBServer();
// значит на этом узле нет DBServer-а
......@@ -701,7 +695,7 @@ IOController_i::ShortIOInfo IOController::getChangedTime( UniSetTypes::ObjectId
uniset_rwmutex_rlock lock(s->val_lock);
i.value = s->value;
i.tv_sec = s->tv_sec;
i.tv_usec = s->tv_usec;
i.tv_nsec = s->tv_nsec;
i.supplier = s->supplier;
return i;
}
......
......@@ -316,8 +316,8 @@ void IONotifyController::localSetValue( std::shared_ptr<IOController::USensorInf
sm.priority = (Message::Priority)usi->priority;
sm.supplier = sup_id; // owner_id
sm.sensor_type = usi->type;
sm.sm_tv_sec = usi->tv_sec;
sm.sm_tv_usec = usi->tv_usec;
sm.sm_tv.tv_sec = usi->tv_sec;
sm.sm_tv.tv_nsec = usi->tv_nsec;
sm.ci = usi->ci;
} // unlock
......@@ -648,12 +648,10 @@ bool IONotifyController::addThreshold( ThresholdExtList& lst, ThresholdInfoExt&&
addConsumer(ti.clst, ci);
// запоминаем начальное время
struct timeval tm;
tm.tv_sec = 0;
tm.tv_usec = 0;
gettimeofday(&tm, NULL);
struct timespec tm;
::clock_gettime(CLOCK_REALTIME, &tm);
ti.tv_sec = tm.tv_sec;
ti.tv_usec = tm.tv_usec;
ti.tv_nsec = tm.tv_nsec;
lst.emplace_back( std::move(ti) );
return true;
......@@ -716,10 +714,8 @@ void IONotifyController::checkThreshold( std::shared_ptr<IOController::USensorIn
SensorMessage sm(std::move(usi->makeSensorMessage()));
// текущее время
struct timeval tm;
tm.tv_sec = 0;
tm.tv_usec = 0;
gettimeofday(&tm, NULL);
struct timespec tm;
::clock_gettime(CLOCK_REALTIME, &tm);
{
uniset_rwmutex_rlock l(ti->mut);
......@@ -761,9 +757,8 @@ void IONotifyController::checkThreshold( std::shared_ptr<IOController::USensorIn
// запоминаем время изменения состояния
it->tv_sec = tm.tv_sec;
it->tv_usec = tm.tv_usec;
sm.sm_tv_sec = tm.tv_sec;
sm.sm_tv_usec = tm.tv_usec;
it->tv_nsec = tm.tv_nsec;
sm.sm_tv = tm;
// если порог связан с датчиком, то надо его выставить
if( it->sid != UniSetTypes::DefaultObjectId )
......@@ -889,7 +884,7 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( UniSetTy
res->tlist[k].lowlimit = it2.lowlimit;
res->tlist[k].state = it2.state;
res->tlist[k].tv_sec = it2.tv_sec;
res->tlist[k].tv_usec = it2.tv_usec;
res->tlist[k].tv_nsec = it2.tv_nsec;
k++;
}
......@@ -943,7 +938,7 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList()
(*res)[i].tlist[k].lowlimit = it2.lowlimit;
(*res)[i].tlist[k].state = it2.state;
(*res)[i].tlist[k].tv_sec = it2.tv_sec;
(*res)[i].tlist[k].tv_usec = it2.tv_usec;
(*res)[i].tlist[k].tv_nsec = it2.tv_nsec;
k++;
}
......
......@@ -3,7 +3,7 @@
############################################################################
noinst_LTLIBRARIES = libProcesses.la
libProcesses_la_CXXFLAGS = $(SIGC_CFLAGS) $(EV_CFLAGS)
libProcesses_la_CXXFLAGS = -I$(top_builddir)/include $(SIGC_CFLAGS) $(EV_CFLAGS)
libProcesses_la_LIBADD = $(SIGC_LIBS) $(EV_LIBS)
libProcesses_la_SOURCES = IOController_iSK.cc IOController.cc IONotifyController.cc \
NCRestorer.cc NCRestorer_XML.cc EventLoopServer.cc CommonEventLoop.cc
......
......@@ -19,6 +19,7 @@
*/
// --------------------------------------------------------------------------
#include <chrono>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
......@@ -56,21 +57,9 @@ namespace UniSetTypes
supplier(DefaultObjectId),
consumer(DefaultObjectId)
{
tm.tv_sec = 0;
tm.tv_usec = 0;
gettimeofday(&tm, NULL);
::clock_gettime(CLOCK_REALTIME, &tm);
}
/*
template<class In>
TransportMessage Message::transport(const In &msg)
{
TransportMessage tmsg;
assert(sizeof(UniSetTypes::RawDataOfTransportMessage)>=sizeof(msg));
memcpy(&tmsg.data,&msg,sizeof(msg));
return tmsg;
}
*/
//--------------------------------------------------------------------------------------------
VoidMessage::VoidMessage( const TransportMessage& tm ):
......@@ -95,10 +84,8 @@ namespace UniSetTypes
threshold(false),
tid(UniSetTypes::DefaultThresholdId)
{
type = Message::SensorInfo;
sm_tv_sec = tm.tv_sec;
sm_tv_usec = tm.tv_usec;
type = Message::SensorInfo;
sm_tv = tm; // или инициализировать нулём ?
ci.minRaw = 0;
ci.maxRaw = 0;
ci.minCal = 0;
......@@ -120,8 +107,7 @@ namespace UniSetTypes
type = Message::SensorInfo;
this->priority = priority;
this->consumer = consumer;
sm_tv_sec = tm.tv_sec;
sm_tv_usec = tm.tv_usec;
sm_tv = tm;
}
SensorMessage::SensorMessage(const VoidMessage* msg):
......@@ -212,13 +198,13 @@ namespace UniSetTypes
ConfirmMessage::ConfirmMessage( UniSetTypes::ObjectId in_sensor_id,
double in_value,
time_t in_time,
time_t in_time_usec,
time_t in_time_nsec,
time_t in_confirm,
Priority in_priority ):
sensor_id(in_sensor_id),
value(in_value),
time(in_time),
time_usec(in_time_usec),
time_nsec(in_time_nsec),
confirm(in_confirm),
broadcast(false),
route(false)
......
......@@ -111,8 +111,8 @@ void SMonitor::sensorInfo( const SensorMessage* si )
cout << "(" << setw(6) << si->id << "):"
<< "[(" << std::right << setw(5) << si->supplier << ")"
<< std::left << setw(20) << s_sup << "] "
<< std::right << setw(8) << timeToString(si->sm_tv_sec, ":")
<< "(" << setw(6) << si->sm_tv_usec << "): "
<< std::right << setw(8) << timeToString(si->sm_tv.tv_sec, ":")
<< "(" << setw(6) << si->sm_tv.tv_nsec << "): "
<< std::right << setw(45) << conf->oind->getMapName(si->id)
<< " value:" << std::right << setw(9) << si->value
<< " fvalue:" << std::right << setw(12) << ( (float)si->value / pow(10.0, si->ci.precision) ) << endl;
......@@ -128,7 +128,7 @@ void SMonitor::sensorInfo( const SensorMessage* si )
else
cmd << conf->getBinDir() << script;
cmd << " " << si->id << " " << si->value << " " << si->sm_tv_sec << " " << si->sm_tv_usec;
cmd << " " << si->id << " " << si->value << " " << si->sm_tv.tv_sec << " " << si->sm_tv.tv_nsec;
int ret = system(cmd.str().c_str());
int res = WEXITSTATUS(ret);
......
......@@ -190,12 +190,12 @@ TEST_CASE("ConfirmMessage", "[basic][message types][ConfirmMessage]" )
ObjectId sid = 1;
double val = 100;
time_t t_sec = 10;
time_t t_usec = 300;
time_t t_nsec = 300;
time_t t_confirm = 10;
SECTION("Default consturctor")
{
ConfirmMessage cm(sid, val, t_sec, t_usec, t_confirm);
ConfirmMessage cm(sid, val, t_sec, t_nsec, t_confirm);
CHECK( cm.type == Message::Confirm );
CHECK( cm.priority == Message::Medium );
CHECK( cm.node == conf->getLocalNode() );
......@@ -204,7 +204,7 @@ TEST_CASE("ConfirmMessage", "[basic][message types][ConfirmMessage]" )
REQUIRE( cm.sensor_id == sid );
REQUIRE( cm.value == val );
REQUIRE( cm.time == t_sec );
REQUIRE( cm.time_usec == t_usec );
REQUIRE( cm.time_nsec == t_nsec );
REQUIRE( cm.confirm == t_confirm );
CHECK( cm.broadcast == false );
CHECK( cm.route == false );
......@@ -212,11 +212,11 @@ TEST_CASE("ConfirmMessage", "[basic][message types][ConfirmMessage]" )
SECTION("Transport ConfirmMessage")
{
ConfirmMessage cm(sid, val, t_sec, t_usec, t_confirm);
ConfirmMessage cm(sid, val, t_sec, t_nsec, t_confirm);
REQUIRE( cm.sensor_id == sid );
REQUIRE( cm.value == val );
REQUIRE( cm.time == t_sec );
REQUIRE( cm.time_usec == t_usec );
REQUIRE( cm.time_nsec == t_nsec );
REQUIRE( cm.confirm == t_confirm );
auto tm = cm.transport_msg();
......@@ -228,7 +228,7 @@ TEST_CASE("ConfirmMessage", "[basic][message types][ConfirmMessage]" )
REQUIRE( cm2.sensor_id == sid );
REQUIRE( cm2.value == val );
REQUIRE( cm2.time == t_sec );
REQUIRE( cm2.time_usec == t_usec );
REQUIRE( cm2.time_nsec == t_nsec );
REQUIRE( cm2.confirm == t_confirm );
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment