-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclipsthread.cpp
80 lines (70 loc) · 1.98 KB
/
clipsthread.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//---------------------------------------------------------------------------
#include <System.hpp>
#pragma hdrstop
#include "clipsthread.h"
#include <stdio.h>
#include "CLIPSBuilderMain.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
// Important: Methods and properties of objects in VCL can only be
// used in a method called using Synchronize, for example:
//
// Synchronize(&UpdateCaption);
//
// where UpdateCaption could look like:
//
// void __fastcall TClipsThread::UpdateCaption()
// {
// Form1->Caption = "Updated in a thread";
// }
//---------------------------------------------------------------------------
__fastcall TClipsThread::TClipsThread(bool CreateSuspended)
: TThread(CreateSuspended)
{
sPath="SIMPLTST.clp";
theEnv=new CLIPS::CLIPSCPPEnv();
sRouter = new ServerRouter(fCLIPSBuilder->mOutput);
theEnv->AddRouter("serverrouter", 10, sRouter);
bNewinstance=true;
bDestroy=false;
}
//---------------------------------------------------------------------------
void __fastcall TClipsThread::Execute()
{
while (!bDestroy) {
ExpertSystemRun();
}
}
//---------------------------------------------------------------------------
void __fastcall TClipsThread::AssignCommand(String Command)
{
sRouter->AssignCommand(Command);
}
//---------------------------------------------------------------------------
String __fastcall TClipsThread::ReturnStdout()
{
}
void __fastcall TClipsThread::ExpertSystemRun()
{
if (bNewinstance) {
if (FileExists(sPath)) {
theEnv->Clear();
theEnv->Load(sPath.c_str());
theEnv->Reset();
int i=0;
while ((theEnv->Run(1)!=0)&&!bDestroy)
{
i++;
}
}
bNewinstance=false;
}
}
//---------------------------------------------------------------------------
void __fastcall TClipsThread::OnTerminateThread()
{
theEnv->Clear();
delete theEnv;
delete sRouter;
}
//---------------------------------------------------------------------------