'I am not familiar with Modelica language. here is my question: I have two Real type variables K and A, they are used to compute outputs of the model, and at each timestep I want to update K and A to recalculate the output. How can I do this?'
The model from your link https://openmodelica.org/forum/default-topic/2339-modelica-variable-behavior can be rewritten to something like that does that (except I haven't tested with OpenModelica). This indicates that you should always include code - as this was not at all clear from your description.
model TimeVarTest
Modelica.SIunits.Time timeVar(start = 0);
Modelica.SIunits.Time timeOut(start = 0);
Modelica.Blocks.Tables.CombiTable1Ds tableVar(table = [0,0;1,0.5]);
Integer state(start = 0);
algorithm
if state == 0 then
// Action
tableVar.u := time-timeVar;
// Transition
end if;
when pre(state)==0 and time - timeVar > 1 then
state := 1;
timeVar := time;
end when;
if state == 1 then
// Action
tableVar.u := 1;
// Transition
end if;
when pre(state)==1 and time - timeVar > 2 then
state := 0;
timeVar := time;
end when;
equation
timeOut = tableVar.y[1];
annotation (
experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-06, Interval = 0.1));
end TimeVarTest;