Open topic with navigation
#SYMBOL_NAME "Rane HAL Level Processor"
#DEFAULT_VOLATILE
analog_input CONTROL_NUM;
analog_input LEVEL;
buffer_input FROM_DSP$[255];
analog_output LEVEL_fb;
string_output TO_DSP$;
integer controlNum, prevLevel, nextLevel;
integer nextChar, startIndex, endIndex;
string line[255];
change FROM_DSP$
{
do
{
nextChar = getc(FROM_DSP$);
line = line + chr(nextChar);
if (nextChar = 0x0D)
{
startIndex = find("<L&", line);
if (startIndex)
{
startIndex = startIndex + 3;
endIndex = find("&", line, startIndex);
controlNum = atoi(mid(line, startIndex, endIndex));
if (controlNum = CONTROL_NUM)
{
startIndex = endIndex;
endIndex = find(">", line, startIndex);
nextLevel = atoi(mid(line, startIndex, endIndex));
if (nextLevel != prevLevel)
{
prevLevel = nextLevel;
LEVEL_fb = nextLevel * 65535/1000;
}
}
}
line = "";
}
} until (len(FROM_DSP$) = 0);
}
change LEVEL
{
LEVEL_fb = LEVEL;
nextLevel = LEVEL * 1000/65535;
if (nextLevel != prevLevel)
{
prevLevel = nextLevel;
TO_DSP$ = "<L&" + itoa(CONTROL_NUM) + "&" + itoa(nextLevel) + ">";
}
}
Open topic with navigation