Commit dbe1f291 authored by Pavel Vainerman's avatar Pavel Vainerman

(IOBase): дореализовал вспомогательные различные вспомогательные функуции.

parent 548db385
......@@ -197,6 +197,8 @@ class Calibration
// список надо отсортировать по x!
typedef std::vector<Part> PartsVec;
inline std::string getName(){ return myname; }
protected:
long minRaw, maxRaw, minVal, maxVal, rightVal, leftVal, rightRaw, leftRaw;
......
......@@ -132,6 +132,8 @@ struct IOBase
ft10 // срабатывание на переход "1-->0"
};
friend std::ostream& operator<<( std::ostream& os, const FrontType& f );
bool front; // флаг работы по фронту
FrontType front_type;
bool front_prev_state;
......@@ -142,7 +144,7 @@ struct IOBase
IOController::IOStateList::iterator ioit;
UniSetTypes::uniset_rwmutex val_lock; /*!< блокировка на время "работы" со значением */
friend std::ostream& operator<<(std::ostream& os, IOBase& inf );
friend std::ostream& operator<<(std::ostream& os, const IOBase& inf );
static void processingFasAI( IOBase* it, float new_val, const std::shared_ptr<SMInterface>& shm, bool force );
static void processingAsAI( IOBase* it, long new_val, const std::shared_ptr<SMInterface>& shm, bool force );
......
#include "Configuration.h"
#include "Extensions.h"
#include "UniSetTypes.h"
#include "IOBase.h"
// -----------------------------------------------------------------------------
using namespace std;
......@@ -9,7 +10,38 @@ using namespace UniSetTypes;
std::ostream& operator<<( std::ostream& os, IOBase& inf )
{
return os << "(" << inf.si.id << ")" << uniset_conf()->oind->getMapName(inf.si.id)
<< " default=" << inf.defval << " safety=" << inf.safety;
<< " default=" << inf.defval
<< " safety=" << inf.safety
<< " stype=" << inf.stype
<< " calibration=" << inf.cal
<< " cdiagram=" << ( inf.cdiagram ? inf.cdiagram->getName() : "null" )
<< " breaklim=" << inf.breaklim
<< " value=" << inf.value
<< " craw=" << inf.craw
<< " cprev" << inf.cprev
<< " nofilter=" << inf.nofilter
<< " f_median=" << inf.f_median
<< " f_ls=" << inf.f_ls
<< " f_filter_iir=" << inf.f_filter_iir
<< " ignore=" << inf.ignore
<< " invert=" << inf.invert
<< " noprecision=" << inf.noprecision
<< " calcrop=" << inf.calcrop
<< " debounce_pause=" << inf.debounce_pause
<< " debounce_state=" << inf.debounce_state
<< " ondelay_state=" << inf.ondelay_state
<< " offdelay_state=" << inf.offdelay_state
<< " d_id=" << uniset_conf()->oind->getMapName(inf.d_id)
<< " d_value=" << inf.d_value
<< " d_off_value=" << inf.d_off_value
<< " d_iotype=" << inf.d_iotype
<< " t_ai=" << inf.t_ai
<< " ti=" << inf.ti
<< " front=" << inf.front
<< " front_type=" << inf.front_type
<< " front_prev_state=" << inf.front_prev_state
<< " front_state=" << inf.front_state
<< " rawdata=" << inf.rawdata;
}
// -----------------------------------------------------------------------------
IOBase::~IOBase()
......@@ -667,3 +699,25 @@ bool IOBase::initItem( IOBase* b, UniXML::iterator& it, const std::shared_ptr<SM
return true;
}
// -----------------------------------------------------------------------------
std::ostream& operator<<( std::ostream& os, const IOBase::FrontType& f )
{
switch(f)
{
case IOBase::ft01:
os << "(ft01)[0-->1]";
break;
case IOBase::ft10:
os << "(ft10)[1-->0]";
break;
case IOBase::ftUnknown:
default:
os << "ftUnknown";
break;
}
return os;
}
// -----------------------------------------------------------------------------
......@@ -488,10 +488,9 @@ TEST_CASE("IOBase with SM","[iobase][extensions]")
WARN("IOBase with SM: Not all tests implemented!");
// ignore
// ioinvert
// asDO (!)
// asDI (!)
// iofront
// UndefinedState
// threshold_ai
// processingThreshold
}
// -----------------------------------------------------------------------------
......@@ -82,6 +82,7 @@ namespace UniSetTypes
UniversalIO::IOType getIOType( const std::string& s );
std::ostream& operator<<( std::ostream& os, const UniversalIO::IOType t );
std::ostream& operator<<( std::ostream& os, const IONotifyController_i::ThresholdInfo& ti );
/*! Команды для управления лампочками */
enum LampCommand
......@@ -224,14 +225,14 @@ namespace UniSetTypes
// ---------------------------------------------------------------
// Калибровка
std::ostream& operator<<( std::ostream& os, const IOController_i::CalibrateInfo c );
std::ostream& operator<<( std::ostream& os, const IOController_i::CalibrateInfo& c );
// Функции калибровки значений
// raw - преобразуемое значение
// rawMin - минимальная граница исходного диапазона
// rawMax - максимальная граница исходного диапазона
// calMin - минимальная граница калиброванного диапазона
// calMin - минимальная граница калиброванного диапазона
// raw - преобразуемое значение
// rawMin - минимальная граница исходного диапазона
// rawMax - максимальная граница исходного диапазона
// calMin - минимальная граница калиброванного диапазона
// calMin - минимальная граница калиброванного диапазона
// limit - обрезать итоговое значение по границам
float fcalibrate(float raw, float rawMin, float rawMax, float calMin, float calMax, bool limit=true );
long lcalibrate(long raw, long rawMin, long rawMax, long calMin, long calMax, bool limit=true );
......
......@@ -331,13 +331,6 @@ std::ostream& UniSetTypes::operator<<( std::ostream& os, const UniversalIO::IOTy
return os << "UnknownIOType";
}
// ------------------------------------------------------------------------------------------
std::ostream& UniSetTypes::operator<<( std::ostream& os, const IOController_i::CalibrateInfo c )
{
return os << " rmin=" << c.minRaw << " rmax=" << c.maxRaw
<< " cmin=" << c.minCal << " cmax=" << c.maxCal
<< " precision=" << c.precision;
}
// ------------------------------------------------------------------------------------------
bool UniSetTypes::check_filter( UniXML::iterator& it, const std::string& f_prop, const std::string& f_val )
{
if( f_prop.empty() )
......@@ -410,3 +403,29 @@ char* UniSetTypes::uni_strdup( const string& src )
return d;
}
// -------------------------------------------------------------------------
std::ostream& UniSetTypes::operator<<( std::ostream& os, const IOController_i::CalibrateInfo& c )
{
os << "[ rmin=" << c.minRaw
<< " rmax=" << c.maxRaw
<< " cmin=" << c.minCal
<< " cmax=" << c.maxCal
<< " prec=" << c.precision
<< " ]";
return os;
}
// -------------------------------------------------------------------------
std::ostream& UniSetTypes::operator<<( std::ostream& os, const IONotifyController_i::ThresholdInfo& ti )
{
os << "[ id=" << ti.id
<< " hilim=" << ti.hilimit
<< " lowlim=" << ti.lowlimit
<< " state=" << ti.state
<< " tv_sec=" << ti.tv_sec
<< " tv_usec=" << ti.tv_usec
<< " invert=" << ti.invert
<< " ]";
return os;
}
// -------------------------------------------------------------------------
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