Cicode Programming Reference > Cicode Function Categories > Fuzzy Logic Functions Introduction > FuzzyOpen

FuzzyOpen

This function loads a *.FTR file, allocates memory and creates a handle for this fuzzy instance. To use the FuzzyTech functions you need to be a registered user of one or more of the following fuzzyTech products: fuzzyTECH Online Edition, fuzzyTECH Precompiler Edition, or fuzzyTECH for Business PlusC. And you need to only use fuzzyTECH to generate the *.FTR file for FTRUN.

The application needs to call the FuzzyClose function to delete each fuzzy instance handle returned by the FuzzyOpen function.

Syntax

FuzzyOpen(sFile)

sFile:

Specifies the filename of the .FTR file to load.

Return Value

The handle to the fuzzy instance, or -1 if the function cannot complete the operation. Use IsError() to find the error number.

Related Functions

FuzzyClose, FuzzyGetShellValue, FuzzySetShellValue, FuzzyGetCodeValue, FuzzySetCodeValue, FuzzyTrace.

Example

INT hFuzzy;
INT NoHitFlag;
INT Status;
REAL MemOutput;
// open the Fuzzy Tech runtime instance
hFuzzy = FuzzyOpen ("C:\Program Files\Citect\CitectSCADA 7.10\bin\traffic.ftr");
Status = IsError();
IF hFuzzy <> -1 THEN
MemOutput = PLCOutput;
WHILE Status = 0 DO
FuzzySetShellValue(hFuzzy, 0, 42.0);
FuzzySetShellValue(hFuzzy, 1, 3.14150);
MemOutput = FuzzyGetShellValue(hFuzzy, 2, NoHitFlag);
Status = IsError();
// Only write to PLC if output changes.
// This reduces load on PLC communication.
IF MemOutput <> PLCOutput THEN
PLCOutput = MemOutput;
END
SleepMS(500);
END
FuzzyClose(hFuzzy);
END

See Also

FuzzyTech Functions