firmware-base/cli-ts/ast/PIDController.json

1670 lines
59 KiB
JSON

{
"type": "translation_unit",
"children": [
{
"type": "preproc_ifdef",
"children": [
{
"type": "#ifndef",
"text": "#ifndef"
},
{
"type": "identifier",
"text": "PIDCONTROLLER_H"
},
{
"type": "preproc_def",
"children": [
{
"type": "#define",
"text": "#define"
},
{
"type": "identifier",
"text": "PIDCONTROLLER_H"
}
]
},
{
"type": "preproc_ifdef",
"children": [
{
"type": "#ifdef",
"text": "#ifdef"
},
{
"type": "identifier",
"text": "ENABLE_PID"
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "system_lib_string",
"text": "<Component.h>"
}
]
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "string_literal",
"children": [
{
"type": "\"",
"text": "\""
},
{
"type": "string_content",
"text": "config-modbus.h"
},
{
"type": "\"",
"text": "\""
}
]
}
]
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "system_lib_string",
"text": "<enums.h>"
}
]
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "system_lib_string",
"text": "<max6675.h>"
}
]
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "system_lib_string",
"text": "<PID_v1.h>"
},
{
"type": "comment",
"text": "// From br3ttb/PID library\r"
}
]
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "system_lib_string",
"text": "<PID_AutoTune_v0.h>"
},
{
"type": "comment",
"text": "// From br3ttb/PID Autotune Library\r"
}
]
},
{
"type": "comment",
"text": "// Define Autotune Status Enum (aligned with Modbus register)\r"
},
{
"type": "enum_specifier",
"children": [
{
"type": "enum",
"text": "enum"
},
{
"type": "type_identifier",
"text": "AutotuneStatus"
},
{
"type": ":",
"text": ":"
},
{
"type": "primitive_type",
"text": "uint8_t"
},
{
"type": "enumerator_list",
"children": [
{
"type": "{",
"text": "{"
},
{
"type": "enumerator",
"children": [
{
"type": "identifier",
"text": "AUTOTUNE_OFF"
},
{
"type": "=",
"text": "="
},
{
"type": "number_literal",
"text": "0"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "enumerator",
"children": [
{
"type": "identifier",
"text": "AUTOTUNE_RUNNING"
},
{
"type": "=",
"text": "="
},
{
"type": "number_literal",
"text": "1"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "enumerator",
"children": [
{
"type": "identifier",
"text": "AUTOTUNE_FINISHED_OK"
},
{
"type": "=",
"text": "="
},
{
"type": "number_literal",
"text": "2"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "enumerator",
"children": [
{
"type": "identifier",
"text": "AUTOTUNE_FAILED"
},
{
"type": "=",
"text": "="
},
{
"type": "number_literal",
"text": "3"
}
]
},
{
"type": "}",
"text": "}"
}
]
}
]
},
{
"type": ";",
"text": ";"
},
{
"type": "class_specifier",
"children": [
{
"type": "class",
"text": "class"
},
{
"type": "type_identifier",
"text": "PIDController"
},
{
"type": "base_class_clause",
"children": [
{
"type": ":",
"text": ":"
},
{
"type": "access_specifier",
"children": [
{
"type": "public",
"text": "public"
}
]
},
{
"type": "type_identifier",
"text": "Component"
}
]
},
{
"type": "field_declaration_list",
"children": [
{
"type": "{",
"text": "{"
},
{
"type": "access_specifier",
"children": [
{
"type": "public",
"text": "public"
}
]
},
{
"type": ":",
"text": ":"
},
{
"type": "declaration",
"children": [
{
"type": "function_declarator",
"children": [
{
"type": "identifier",
"text": "PIDController"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "primitive_type",
"text": "uint8_t"
},
{
"type": "identifier",
"text": "id"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_qualifier",
"children": [
{
"type": "const",
"text": "const"
}
]
},
{
"type": "primitive_type",
"text": "char"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "name"
}
]
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "primitive_type",
"text": "int8_t"
},
{
"type": "identifier",
"text": "thermoDO"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "primitive_type",
"text": "int8_t"
},
{
"type": "identifier",
"text": "thermoCS"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "primitive_type",
"text": "int8_t"
},
{
"type": "identifier",
"text": "thermoCLK"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "primitive_type",
"text": "int8_t"
},
{
"type": "identifier",
"text": "outputPin"
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "declaration",
"children": [
{
"type": "function_declarator",
"children": [
{
"type": "destructor_name",
"children": [
{
"type": "~",
"text": "~"
},
{
"type": "identifier",
"text": "PIDController"
}
]
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "sized_type_specifier",
"children": [
{
"type": "short",
"text": "short"
}
]
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "setup"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": ")",
"text": ")"
}
]
},
{
"type": "virtual_specifier",
"children": [
{
"type": "override",
"text": "override"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "sized_type_specifier",
"children": [
{
"type": "short",
"text": "short"
}
]
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "loop"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": ")",
"text": ")"
}
]
},
{
"type": "virtual_specifier",
"children": [
{
"type": "override",
"text": "override"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "sized_type_specifier",
"children": [
{
"type": "short",
"text": "short"
}
]
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "mb_tcp_read"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "sized_type_specifier",
"children": [
{
"type": "short",
"text": "short"
}
]
},
{
"type": "identifier",
"text": "address"
}
]
},
{
"type": ")",
"text": ")"
}
]
},
{
"type": "virtual_specifier",
"children": [
{
"type": "override",
"text": "override"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "sized_type_specifier",
"children": [
{
"type": "short",
"text": "short"
}
]
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "mb_tcp_write"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "sized_type_specifier",
"children": [
{
"type": "short",
"text": "short"
}
]
},
{
"type": "identifier",
"text": "address"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "sized_type_specifier",
"children": [
{
"type": "short",
"text": "short"
}
]
},
{
"type": "identifier",
"text": "value"
}
]
},
{
"type": ")",
"text": ")"
}
]
},
{
"type": "virtual_specifier",
"children": [
{
"type": "override",
"text": "override"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "mb_tcp_register"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "ModbusTCP"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "manager"
}
]
}
]
},
{
"type": ")",
"text": ")"
}
]
},
{
"type": "virtual_specifier",
"children": [
{
"type": "override",
"text": "override"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "access_specifier",
"children": [
{
"type": "private",
"text": "private"
}
]
},
{
"type": ":",
"text": ":"
},
{
"type": "comment",
"text": "// MAX6675 Thermocouple Sensor\r"
},
{
"type": "field_declaration",
"children": [
{
"type": "type_identifier",
"text": "MAX6675"
},
{
"type": "field_identifier",
"text": "thermocouple"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "int8_t"
},
{
"type": "field_identifier",
"text": "_thermoDO"
},
{
"type": ",",
"text": ","
},
{
"type": "field_identifier",
"text": "_thermoCS"
},
{
"type": ",",
"text": ","
},
{
"type": "field_identifier",
"text": "_thermoCLK"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "comment",
"text": "// PID Controller\r"
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "double"
},
{
"type": "field_identifier",
"text": "_setpoint"
},
{
"type": ",",
"text": ","
},
{
"type": "field_identifier",
"text": "_input"
},
{
"type": ",",
"text": ","
},
{
"type": "field_identifier",
"text": "_output"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "double"
},
{
"type": "field_identifier",
"text": "_kp"
},
{
"type": ",",
"text": ","
},
{
"type": "field_identifier",
"text": "_ki"
},
{
"type": ",",
"text": ","
},
{
"type": "field_identifier",
"text": "_kd"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "type_identifier",
"text": "PID"
},
{
"type": "field_identifier",
"text": "_pid"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "comment",
"text": "// PID Autotune\r"
},
{
"type": "field_declaration",
"children": [
{
"type": "type_identifier",
"text": "PID_ATune"
},
{
"type": "field_identifier",
"text": "_aTune"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "bool"
},
{
"type": "field_identifier",
"text": "_autotuning"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "type_identifier",
"text": "AutotuneStatus"
},
{
"type": "field_identifier",
"text": "_autotuneStatus"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "double"
},
{
"type": "field_identifier",
"text": "_aTuneStartValue"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "comment",
"text": "// Where the output was when AT started\r"
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "double"
},
{
"type": "field_identifier",
"text": "_aTuneNoiseBand"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "sized_type_specifier",
"children": [
{
"type": "unsigned",
"text": "unsigned"
},
{
"type": "primitive_type",
"text": "int"
}
]
},
{
"type": "field_identifier",
"text": "_aTuneLookbackSec"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "double"
},
{
"type": "field_identifier",
"text": "_lastKp"
},
{
"type": ",",
"text": ","
},
{
"type": "field_identifier",
"text": "_lastKi"
},
{
"type": ",",
"text": ","
},
{
"type": "field_identifier",
"text": "_lastKd"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "comment",
"text": "// Store results from autotune\r"
},
{
"type": "comment",
"text": "// Output Control\r"
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "int8_t"
},
{
"type": "field_identifier",
"text": "_outputPin"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "sized_type_specifier",
"children": [
{
"type": "unsigned",
"text": "unsigned"
},
{
"type": "long",
"text": "long"
}
]
},
{
"type": "field_identifier",
"text": "_windowStartTime"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "type_qualifier",
"children": [
{
"type": "const",
"text": "const"
}
]
},
{
"type": "sized_type_specifier",
"children": [
{
"type": "unsigned",
"text": "unsigned"
},
{
"type": "long",
"text": "long"
}
]
},
{
"type": "field_identifier",
"text": "_windowSize"
},
{
"type": "=",
"text": "="
},
{
"type": "number_literal",
"text": "1000"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "comment",
"text": "// PID cycle time (e.g., 1 second)\r"
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "bool"
},
{
"type": "field_identifier",
"text": "_pidModeAuto"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "comment",
"text": "// true = AUTO, false = MANUAL\r"
},
{
"type": "comment",
"text": "// Helper methods\r"
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "updateTemperature"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "runAutotune"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "applyOutput"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "setPIDMode"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "primitive_type",
"text": "bool"
},
{
"type": "identifier",
"text": "autoMode"
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "startAutotune"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "cancelAutotune"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "finishAutotune"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "primitive_type",
"text": "bool"
},
{
"type": "identifier",
"text": "success"
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "double"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "scalePIDParam"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "primitive_type",
"text": "uint16_t"
},
{
"type": "identifier",
"text": "modbusValue"
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "uint16_t"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "unscalePIDParam"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "primitive_type",
"text": "double"
},
{
"type": "identifier",
"text": "pidValue"
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "comment",
"text": "// Error handling\r"
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "bool"
},
{
"type": "field_identifier",
"text": "_sensorError"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "}",
"text": "}"
}
]
}
]
},
{
"type": ";",
"text": ";"
},
{
"type": "#endif",
"text": "#endif"
}
]
},
{
"type": "comment",
"text": "// ENABLE_PID\r"
},
{
"type": "#endif",
"text": "#endif"
}
]
},
{
"type": "comment",
"text": "// PIDCONTROLLER_H "
}
]
}