Hello Jesus,
It's hard to know the exact problem without looking the model. But is seems that the result file is corrupted when simulating.
I have attached a few examples of how to use the delay operator. I also included an example on how to delay discrete variables and get more accurate timing. This method is much better when delaying for example triggering signals for thyristors.
 model DelayExamples
 
   Real x(start = 10);
   Real fixedDelay,variableDelay;
   Real y;
   discrete Real z;
   discrete Real discreteDelay,discreteDelay_future,discreteDelay_time;
   parameter Real delay_z = 1;
 equation
  der(x) = -x;
  y = if time < 3 then 0.5 else 1;
  /*---Delaying continuous variables----*/
  /* Fixed delay:
       delay(exp,delayTime)
  */
  fixedDelay = delay(x, 1);
  /* Variable delay:
       delay(exp,delayTime,maxDelay)
       NOTE: variable delays require ti specify the maximum delay
  */
  variableDelay = delay(x, y, 1);
  /*---Delaying discrete variables---*/
  /* This is equivalent to:
        discreteDelay=delay(z,delay_z)
     but it's more precise and do not miss the event
  */
  when x < 0.5 then  // at time 0.5 z changes
    z = 1;
    discreteDelay_future = 1;            // sets the future value for the delayed variable
    discreteDelay_time = time + delay_z; // sets the time at which the delayed variable has to change
  end when;
  when time > discreteDelay_time then
      discreteDelay = discreteDelay_future;  // when time reaches the time of change set the value
  end when;
end DelayExamples;
Leonardo