工控之家

 找回密码
加入工控之家

高手帮忙解读下STL

[复制链接]
发表于 2012-7-10 22:55:13 | 显示全部楼层 |阅读模式
This is the main handler of the MMI profile container

Parameters : fb_in_offset   First byte in the input container
             fb_out_offset  First byte in the output container
             db_address     Number of the database to use
             con_len        Length of container in bytes (min.32)  

Example : The terminal is configured to be on input and output byte 64,
          32 bytes allocated  and database to communcate with is 51:
          fb_in_offset  = 64
          fb_out_offset = 64
          db_address    = 51
          con_len       = 32

The function block handles one complete container in one scan. If read index,
FC111 is called.
If write index, FC112 is called.
Note that the control byte is not set until next scan, to avoid timing problems



      L     #fb_in_offset               // Incontainer start address
      T     MW   496                    // Remember incontainer start
      T     MW   500

      L     #fb_in_offset               // Incontainer start address
      SLD   3                           //
      LAR1  
      L     IB [AR1,P#0.0]              // Get the proper control byte from inp.container
      T     MB   486                    // Store it

      L     #fb_out_offset              // Outcontainer start address
      T     MW   498                    // Store it
      T     MW   502

      L     #m_110                      // Previous input control byte
      T     MB   479                    // Store it

      L     0
      T     MB   474                    // Clear error code

      A     M    479.0
      R     M    479.0                  // Clear error flag

      A     M    486.6                  // Terminal present ?
      JC    WEI1                        //
      L     1                           // Error 1 : Comm error
      JU    FEH                         //

WEI1: A     M    486.5                  // Does the terminal toggle the toggle bit ?
      AN    M    486.5
      L     S5T#2S                      // Timeout timer
      SD    \"Terminal timeout\"
      AN    \"Terminal timeout\"
      JC    WEI2
      L     2                           // Error 2 : Terminal not in RUN
      JU    FEH

WEI2: A     M    486.7                  // Test if new container
      A     M    479.7                  // Compare old container byte with the new one
      O     
      AN    M    486.7
      AN    M    479.7
      JC    ENDE                        // No new container

      A     M    486.7                  // Pulse
      =     M    479.7

      L     MW   498                    // Outcontainer pointer
      L     4
      +I   
      T     MW   498                    // First data position : 4

      L     MW   496                    // Incontainer pointer
      L     4
      +I   
      T     MW   496                    // First index position : 4
//   
LOOP: NOP   0
      L     MW   496                    // Incontainer pointer
      ITD   
      SLD   3
      T     MD   504                    // Make it double word
      L     IB [MD 504]                 // Get first index byte
      T     MB   486                    // Store it
      L     MB   486
      L     0
      ==I   
      JC    DONE                        // Jump out if index is 0

      A     M    486.7                  // Is it a read index ?
      JC    ANK1
      CALL  \"READ INDEX OP PANEL\"       // Then call read index function
       DataBase:=#db_address
ANK1: NOP   0
      L     MB   478                    // Check return value from FC111
      L     0
      ==I   
      JC    WEI3                        // Was there an error return ?
      AN    M    479.0
      S     M    479.0                  // Then, set error bit
      L     MB   478
      JU    FEH                         // Jump to error
WEI3: AN    M    486.7                  // Is it a write index ?
      JC    WEI4
      CALL  \"WRITE INDEX OP PANEL\"      // Then call write index function
       DataBase:=#db_address
      L     MB   478                    // Check return value from FC112
      L     0
      ==I   
      JC    WEI4                        // Was there an error return ?
      AN    M    479.0
      S     M    479.0                  // Then set error bit
      L     MB   478                    //
      JU    FEH                         // Jump to error
WEI4: L     MW   496                    // Check if incontainer is done
      L     MW   500
      -I   
      L     #con_len
您需要登录后才可以回帖 登录 | 加入工控之家

本版积分规则

QQ|手机版|小黑屋|Archiver|工控之家 ( 鲁ICP备12015736号-1 )

GMT+8, 2024-5-19 18:18 , Processed in 0.084808 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表