⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dps2spc3.lst

📁 pROFIBUS 从站源程序 SPC3 pROFIBUS 从站源程序 SPC3
💻 LST
📖 第 1 页 / 共 4 页
字号:
 215   2      
 216   2                       for(i = step; i < count; i++)
 217   2                       {
 218   3                              if(aux_len[0] < lensx[i])
 219   3                              {
 220   4                                 aux_len[0] = lensx[i];
 221   4                              }
 222   3                       }
 223   2                       aux_len[0] = aux_len[0]*(count - step + 1);
 224   2                       /* determine total len for AUX-buffer 2;关于AUX-buf见PDF29*/
 225   2                       aux_len[1] = 0;
 226   2      
 227   2                       for(i = 0; i < step; i++)
 228   2                       {
 229   3                              if(aux_len[1] < lensx[i])
 230   3                              {
 231   4                                 aux_len[1] = lensx[i];
 232   4                              }
 233   3                       }
 234   2                       aux_len[1] = aux_len[1] * (step + 1);
 235   2      
 236   2                       if((aux_len[0] + aux_len[1]) < min_len)
 237   2                       {
 238   3                              /* neue Minimal-Laenge gefunden */
 239   3                              min_len = aux_len[0] + aux_len[1];
 240   3                              min_step = step;
C51 COMPILER V7.02b   DPS2SPC3                                                             11/01/2004 20:51:04 PAGE 5   

 241   3                       }
 242   2                }
 243   1      
 244   1                /*calculation of len for AUX-buffer 1;计算AUX-buffer 1长度 *
 245   1                aux_len[0] = 0;
 246   1      
 247   1                for(i = min_step; i < count; i++)
 248   1                {
 249   1                       if(aux_len[0] < lensx[i])
 250   1                       {
 251   1                              aux_len[0] = lensx[i];
 252   1                       }
 253   1                }
 254   1                /*  setup lens for AUX-buffer 1 */
 255   1                for(i = min_step; i < count; i++)
 256   1                {
 257   2                       lens[pos[i]] = aux_len[0];
 258   2                }
 259   1                /*  calculation of len for AUX-buffer 2;计算AUX-buffer 2长度*/
 260   1                aux_len[1] = 0;
 261   1      
 262   1                for(i = 0; i < min_step; i++)
 263   1                {
 264   2                       if(aux_len[1] < lensx[i])
 265   2                       {
 266   3                              aux_len[1] = lensx[i];
 267   3                       }
 268   2                }
 269   1                /*  setup lens for AUX-buffer 2 */
 270   1                /*  setup assignment-list */
 271   1                *assign = 0;    /* $initial all buffers assigned to AUX-buffer 1 */
 272   1      
 273   1                for(i = 0; i < min_step; i++)
 274   1                {
 275   2                       lens[pos[i]] = aux_len[1];
 276   2                       *assign |= 0x01 << pos[i];/*左移pos[i];即与AUX-buffer 2相关的标上1*/
 277   2                }
 278   1                return min_len;/*返回总长度值*/
 279   1         }
 280             /* Ende assign_aux_buf */
 281          
 282          #ifdef _C166
                #pragma global
              #endif
 285          
 286          /*~
 287          dps2_calculate_inp_outp_len()
 288            主调user_dps_reset 见.U*/
 289             /*
 290             +------------------------------------------------------------------------+
 291             | Funktion:  d p s 2 _ c a l c u l a t e _ i n p _ o u t p _ l e n  $    |
 292             +------------------------------------------------------------------------+
 293             | Description:                                                           |
 294             |  This function calculates the Input/Outputdata-lens based on the       |
 295             |  specified config-data and returns a pointer to the calculated lens.   |
 296             |(original from DPS).根据特定组态数据计算I/O数据长度,并返回算出的长度指针|
 297             +------------------------------------------------------------------------+
 298             | parameters:                                                            |
 299             |  -cfg_ptr: pointer to config-data  组态数据指针                        |
 300             |  -cfg_len: config-data len         组态数据长度                        |
 301             |                                                                        |
 302             | return value:                                                          |
C51 COMPILER V7.02b   DPS2SPC3                                                             11/01/2004 20:51:04 PAGE 6   

 303             |  -pointer to lens                                                      |
 304             +------------------------------------------------------------------------+
 305             */
 306             DPS2_IO_DATA_LEN SPC3_DATA_ATTR *dps2_calculate_inp_outp_len (UBYTE
 307             SPC3_PTR_ATTR* cfg_ptr, UWORD cfg_len)/* 返回值类型.Hp5 */
 308             {
 309   1                UBYTE temp_inp_data_len;
 310   1                UBYTE temp_outp_data_len;
 311   1                UBYTE length;
 312   1                UBYTE count;
 313   1                UBYTE specific_data_length;
 314   1                UBYTE result_ok;
 315   1      
 316   1                result_ok = TRUE;
 317   1                temp_inp_data_len  = 0;
 318   1                temp_outp_data_len = 0;
 319   1            
 320   1            count=1 ;     /* $ 添加  */
 321   1                if ((cfg_len > 0) && (cfg_len <= dps2_binit.cfg_buf_len))
 322   1                {
 323   2                       for ( ; (cfg_len > 0) && result_ok; cfg_len -= count)
 324   2                       {
 325   3                              count = 0;
 326   3      
 327   3                              if (*cfg_ptr & DPS_CFG_IS_BYTE_FORMAT)/* DPS_CFG_IS_BYTE_FORMAT即30H */
 328   3                              {
 329   4                                 count++;
 330   4      
 331   4                                 /* cfg_ptr points to ID-byte, CFG_BF means "CFG_IS_BYTE_FORMAT" */
 332   4                     length = (UBYTE)((*cfg_ptr & DPS_CFG_BF_LENGTH) + 1);/* DPS_…即0FH */
 333   4      
 334   4                             if (*cfg_ptr & DPS_CFG_LENGTH_IS_WORD_FORMAT)/*DPS_CFG…为40H*/
 335   4                                 {
 336   5                                        length *= 2;
 337   5                                 }
 338   4                                 if (*cfg_ptr & DPS_CFG_BF_OUTP_EXIST)    /* DPS_CFG_BF_OUTP_EXIST为20H */
 339   4                                 {
 340   5                                        temp_outp_data_len = temp_outp_data_len + length;
 341   5                                 }
 342   4                                 if (*cfg_ptr & DPS_CFG_BF_INP_EXIST)     /* DPS_CFG_BF_INP_EXIST为10H */
 343   4                                 {
 344   5                                        temp_inp_data_len = temp_inp_data_len + length;
 345   5                                 }
 346   4                                 cfg_ptr++;
 347   4                              }
 348   3                              else
 349   3                              {
 350   4                                 /* cfg_ptr points to the headerbyte of special ID-format */
 351   4                                 /* CFG_SF means "CFG_IS_SPECIAL_FORMAT" 特殊参数模式*/
 352   4                                 if (*cfg_ptr & DPS_CFG_SF_OUTP_EXIST)   /* DPS_CFG_SF_OUTP_EXIST为80H */
 353   4                                 {
 354   5                                        count++;          /* next byte contains the length of outp_data */
 355   5                                                                                        
 356   5                                        length = (UBYTE)((*(cfg_ptr + count) & DPS_CFG_SF_LENGTH) +1);
 357   5                                                                         /* DPS_CFG_SF_LENGTH为3fH */
 358   5      
 359   5                                        if (*(cfg_ptr + count) & DPS_CFG_LENGTH_IS_WORD_FORMAT)    
 360   5                                        {                      /* DPS_CFG_LENGTH_IS_WORD_FORMAT为40H */
 361   6                                              temp_outp_data_len = temp_outp_data_len + (UBYTE)(2*length);
 362   6                                        }
 363   5                                        else
 364   5                                        {
C51 COMPILER V7.02b   DPS2SPC3                                                             11/01/2004 20:51:04 PAGE 7   

 365   6                                               temp_outp_data_len = temp_outp_data_len + length;
 366   6                                        }
 367   5                                 }
 368   4                                 if (*cfg_ptr & DPS_CFG_SF_INP_EXIST)  /*DPS_CFG_SF_INP_EXIST为40H*/
 369   4                                 {
 370   5                                        count++;             /* next byte contains the length of inp_data */
 371   5      
 372   5                        length = (UBYTE)((*(cfg_ptr + count) & DPS_CFG_SF_LENGTH) +1); /* DPS_CFG_SF_LENGTH为3fH
             - */
 373   5      
 374   5                                        if (*(cfg_ptr + count) & DPS_CFG_LENGTH_IS_WORD_FORMAT) 
 375   5                                        {                      /* DPS_CFG_LENGTH_IS_WORD_FORMAT为40H */
 376   6                                               temp_inp_data_len = temp_inp_data_len + (UBYTE)(2*length);
 377   6                                        }
 378   5                                        else
 379   5                                        {
 380   6                                               temp_inp_data_len = temp_inp_data_len + length;
 381   6                                        }
 382   5                                 }
 383   4                                 specific_data_length = (UBYTE)(*cfg_ptr & DPS_CFG_BF_LENGTH); 
 384   4                                                            /* DPS_CFG_BF_LENGTH为0fH */
 385   4                                 if (specific_data_length != 15)
 386   4                                 {
 387   5                                        count = (UBYTE)(count + 1 + specific_data_length);
 388   5                                        cfg_ptr = cfg_ptr + count;
 389   5                                 }
 390   4                                 else
 391   4                                 {
 392   5                                        result_ok = FALSE;
 393   5                                 }
 394   4                              }
 395   3                       }
 396   2      
 397   2                       if ( (cfg_len != 0) ||
 398   2                                      (
 399   2                                      (((UWORD)temp_inp_data_len + 7) & 0xfff8 +
 400   2                                      ((UWORD)temp_outp_data_len + 7) & 0xfff8)
 401   2                                      > dps2_binit.din_dout_buf_len) )
 402   2                       {
 403   3                              result_ok = FALSE;
 404   3                       }
 405   2                }
 406   1                else
 407   1                {
 408   2                       result_ok = FALSE;
 409   2                }
 410   1                if (result_ok)
 411   1                {
 412   2                       io_data_len.inp_data_len  = temp_inp_data_len;
 413   2                       io_data_len.outp_data_len = temp_outp_data_len;
 414   2                       return (&io_data_len);
 415   2                }
 416   1                else
 417   1                {
 418   2                       return ((DPS2_IO_DATA_LEN *) 0);
 419   2                }
 420   1         }
 421          
 422          
 423          /*~
 424          dps2_buf_init()      主调.Hp8 图Z3
 425          ~*/
C51 COMPILER V7.02b   DPS2SPC3                                                             11/01/2004 20:51:04 PAGE 8   

 426             /*
 427             +------------------------------------------------------------------------+
 428             | Function:  d p s 2 _ b u f _ i n i t ( )                               |
 429             +------------------------------------------------------------------------+
 430             | Description:                                                           |
 431             |  The specified lens are checked. If they are ok, the neccesarry         |
 432             |  memory is calculated. If there is enough memory, the buffers are      |
 433             |  armed.(检查设定参数,计算所需存储空间;如空间足够,存储buf定位设置完成)  |
 434             |  In dps2_buf_len the amount of used Memory is stored.                  |
 435             |  (dps2_buf_len储存使用的总空间, )                                        |

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -