Ich habe ein Problem mit Schlitz vom Schwimmertyp. Es gibt eine Vorlage in meiner Wissensdatenbank-Datei:CLIPS & clipsmm: Schlitz vom Schwimmertyp
(deftemplate test
(slot slot1 (type INTEGER) (default 10))
(slot slot2 (type FLOAT) (default 4.0))
)
Ich benutze clipsmm für die Integration CLIPS mit Qt-Anwendung. Ich behaupte Tatsache, auf diese Weise:
CLIPS::Fact::pointer fact;
QString fact_str = "(test (slot1 15) (slot2 4.3))";
fact = env.assert_fact(Std(fact_str)); //Std() translates QString into std::string
Diese Tatsache Tagesordnung gesetzt wird, aber slot2 Wert = 4,0 statt 4,3:
<== Activation 0 start:
<== f-0 (initial-fact)
:== ?answer ==> 0 <== 0 //this is global
==> Activation 0 start:
==> f-0 (initial-fact)
Start!
==> f-1 (test (slot1 15) (slot2 4.0))
Wenn ich „XClips Expert System“ verwenden ist alles gut und slot2 hat Wert = 4,3. Was mache ich falsch?
UPD. Ich habe die environment.cpp auf diese Weise:
Fact::pointer Environment::assert_fact(const std::string& factstring)
{
void* clips_fact = EnvAssertString(m_cobj, const_cast<char*>(factstring.c_str()));
std::cout << "factstring =" << factstring << std::endl; //std::cout is added
if (clips_fact)
return Fact::create(*this, clips_fact);
else
return Fact::pointer();
}
und es wird korrekt angezeigt: "factstring = (Test (slot1 15) (slot2 4.3))"
UPD2. Ich versuchte Tat auf diese Weise hinzuzufügen:
CLIPS::Template::pointer temp;
temp = env.get_template(Std("test"));
CLIPS::Fact::pointer f1;
f1 = CLIPS::Fact::create(env, temp);
CLIPS::Value v1 = CLIPS::Value(15);
CLIPS::Value v2 = CLIPS::Value(4.3);
f1->set_slot(Std("slot1"), v1);
f1->set_slot(Std("slot2"), v2);
env.assert_fact(f1);
und bekam ein solches Ergebnis:
==> f-2 (test (slot1 15) (slot2 4,3.0))
Ich arbeite unter Linux (OpenSuse 13.2), verwende CLIPS 6.30.0-2.6, clipsmm-0.3.4, Qt 4.8.6 – lebendig
Haben Sie in der clipsmm assert_fact-Methode in environment.cpp verifiziert, dass der konvertierte String an EnvAssertString übergeben wurde ist gültig? –
Ja, ich habe die Frage aktualisiert. Mit der konvertierten Zeichenfolge scheint alles in Ordnung zu sein. – lebendig