build 200222. enhanced memory cell comparison event condition

This commit is contained in:
tmj-fstate
2020-02-23 03:44:45 +01:00
parent 4e9eabbcfe
commit e4502217e5
11 changed files with 249 additions and 84 deletions

View File

@@ -31,18 +31,18 @@ void TMemCell::UpdateValues( std::string const &szNewText, double const fNewValu
{ // dodawanie wartości
if( TestFlag( CheckMask, basic_event::flags::text ) )
szText += szNewText;
if (TestFlag(CheckMask, basic_event::flags::value_1))
if (TestFlag(CheckMask, basic_event::flags::value1))
fValue1 += fNewValue1;
if (TestFlag(CheckMask, basic_event::flags::value_2))
if (TestFlag(CheckMask, basic_event::flags::value2))
fValue2 += fNewValue2;
}
else
{
if( TestFlag( CheckMask, basic_event::flags::text ) )
szText = szNewText;
if (TestFlag(CheckMask, basic_event::flags::value_1))
if (TestFlag(CheckMask, basic_event::flags::value1))
fValue1 = fNewValue1;
if (TestFlag(CheckMask, basic_event::flags::value_2))
if (TestFlag(CheckMask, basic_event::flags::value2))
fValue2 = fNewValue2;
}
if (TestFlag(CheckMask, basic_event::flags::text))
@@ -118,8 +118,11 @@ void TMemCell::PutCommand( TController *Mech, glm::dvec3 const *Loc ) const
Mech->PutCommand(szText, fValue1, fValue2, Loc);
}
bool TMemCell::Compare( std::string const &szTestText, double const fTestValue1, double const fTestValue2, int const CheckMask ) const {
// porównanie zawartości komórki pamięci z podanymi wartościami
bool TMemCell::Compare( std::string const &szTestText, double const fTestValue1, double const fTestValue2, int const CheckMask,
comparison_operator const TextOperator, comparison_operator const Value1Operator, comparison_operator const Value2Operator,
comparison_pass const Pass ) const {
// porównanie zawartości komórki pamięci z podanymi wartościami
/*
if( TestFlag( CheckMask, basic_event::flags::text ) ) {
// porównać teksty
auto range = szTestText.find( '*' );
@@ -137,8 +140,39 @@ bool TMemCell::Compare( std::string const &szTestText, double const fTestValue1,
}
}
// tekst zgodny, porównać resztę
return ( ( !TestFlag( CheckMask, basic_event::flags::value_1 ) || ( fValue1 == fTestValue1 ) )
&& ( !TestFlag( CheckMask, basic_event::flags::value_2 ) || ( fValue2 == fTestValue2 ) ) );
return ( ( !TestFlag( CheckMask, basic_event::flags::value1 ) || ( fValue1 == fTestValue1 ) )
&& ( !TestFlag( CheckMask, basic_event::flags::value2 ) || ( fValue2 == fTestValue2 ) ) );
*/
bool checkpassed { false };
bool checkfailed { false };
if( TestFlag( CheckMask, basic_event::flags::text ) ) {
// porównać teksty
auto range = szTestText.find( '*' );
auto const result { (
range == std::string::npos ?
compare( szText, szTestText, TextOperator ) :
compare( szText.substr( 0, range ), szTestText.substr( 0, range ), TextOperator ) ) };
checkpassed |= result;
checkfailed |= ( !result );
}
if( TestFlag( CheckMask, basic_event::flags::value1 ) ) {
auto const result { compare( fValue1, fTestValue1, TextOperator ) };
checkpassed |= result;
checkfailed |= ( !result );
}
if( TestFlag( CheckMask, basic_event::flags::value2 ) ) {
auto const result { compare( fValue2, fTestValue2, TextOperator ) };
checkpassed |= result;
checkfailed |= ( !result );
}
switch( Pass ) {
case comparison_pass::all: { return ( checkfailed == false ); }
case comparison_pass::any: { return ( checkpassed == true ); }
case comparison_pass::none: { return ( checkpassed == false ); }
default: { return false; }
}
};
bool TMemCell::IsVelocity() const