Embedded Software

Embedded Software

Topics related to SCADE Suite, SCADE Display, SCADE One and more.

Why local variable “has no definition” when it is already defined in actions?

    • fdtsaid
      Subscriber

      In scade language reference, there is an example as following :

       


      node StateMachine_1(bI1: bool) 
        returns (bO1: bool default = true; iO2: int16 default = 0; bO3: bool default = false)
      let
        automaton SM1 
          initial state ST1 
          unless if bI1 resume ST2;
          sig sig1;
          var iV1: int16; 
          let
            iV1 = 10;
            emit 'sig1;
            bO1 = 'sig1;
            iO2 = iV1 -> pre iO2 + 2; 
          tel

       

          state ST2 
          sig sig1; 
          var bV1: bool; // err: V1 has no definition
          until if true do 
                        let
                          emit 'sig1;
                          bV1 = 'sig1;
                          bO3 = bV1; 
                        tel
                    restart ST1; 
        returns ..;
      tel

       

      When compile the program using kcg, error "V1 has no definition" occurs. But V1 will be always defined in transition action every time entering state ST2. How to understand this error? 

    • Benjamin Descorps
      Ansys Employee

      Hello,

      Indeed, definition of state2 is incorrect. The until clause is not put at the right place. Is here the correct piece of code:

      state ST2
        sig sig1;
        var bV1: bool;
        let
               bV1 = 'sig1;
               bO3 = bV1;
        tel
      until if true do emit 'sig1;
      restart ST1; 

      We will fix the example in the Reference Manual in the next SCADE version.

      Benjamin

Viewing 1 reply thread
  • You must be logged in to reply to this topic.