フロートタイプのスロットに問題があります。CLIPS&clipsmm:フロートタイプのスロット
(deftemplate test
(slot slot1 (type INTEGER) (default 10))
(slot slot2 (type FLOAT) (default 4.0))
)
私はQtのアプリケーションとの統合クリップのclipsmmを使用します。私の知識ベースファイルのテンプレートがあります。この事実は、議題に追加され
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
が、値= 4.0ではなく4.3スロット2があります:私は実際にこの方法を主張
<== 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))
を私は「XCLIPSエキスパートシステム」を使用している場合は、すべてが良く、SLOT2が持っています値= 4.3。何が間違っていますか?
UPD。
UPD2 "()4.3 SLOT2()テスト(SLOT1 15)factstring =" を:私はenvironment.cppをこのように変更:
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();
}
をし、それが正しく表示されます。
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);
と、このような結果だ:私は実際にこの方法を追加しようとした私はかなりそれを理解していないが、以下が助け
==> f-2 (test (slot1 15) (slot2 4,3.0))
私はLinux(OpenSuse 13.2)で動作し、CLIPS 6.30.0-2.6、clipsmm-0.3.4、Qt 4.8.6を使用します。 – lebendig
environment.cppのclipsmm assert_factメソッドで、変換された文字列がEnvAssertString有効ですか? –
はい、質問を更新しました。変換された文字列であれば問題はないようです。 – lebendig