西门子 PLC 先入先出编程方法

西门子 PLC 先入先出的编程方法

泛型方法, 先入先出 避免使用 For 循环,

可以 对任意数据类型 进行 先入先出, 优化的区域和非优化的区域 都可以


REGION BLOCK INFO HEADER

//===============================================================================

// Dang

//-------------------------------------------------------------------------------

// Title: FC_FIFO V1.0

// Comment/Function: Sort the Array

// Library/Family:

// Author:

// Tested with: S7-PLCSIM V2.0 SP1

// Engineering: TIA Portal V15.1

// Restrictions: ENO disabled - error handling done with error and status

// Requirements: PLC (S7-1200 / S7-1500)

//-------------------------------------------------------------------------------

// Change log table:

// Version | Date | Expert in charge | Changes applied

//----------|------------|------------------------|------------------------------

// 09.00.00 25.7.2021 dangguodong

// Set version to V1.0.0

// array must be start with zreo

//==============================================================================

END_REGION

REGION init the result


#"FC_FIFO_V2.0" := FALSE;

#State := #Program_No_Excute;


END_REGION

REGION Check the DataContainer , if not array will be return

IF NOT IS_ARRAY(#DataContainer)

THEN

#State := #Data_Type_Wrong;

RETURN;

END_IF;


END_REGION

REGION Check the DataContainer , If DataContainer is not correct point or length is 1 , no need sort

IF IS_NULL(#DataContainer)

OR CountOfElements(#DataContainer) <= 1

THEN

#State := #Data_Type_Wrong;

RETURN;

END_IF;


END_REGION

REGION move the data container shift


#State :=INT_TO_WORD( MOVE_BLK_VARIANT(SRC := #DataContainer, COUNT := CountOfElements(#DataContainer) - 1, SRC_INDEX := 0, DEST_INDEX := 1, DEST => #DataContainer));


IF #State <> 16#0

THEN

RETURN;

END_IF;


END_REGION

REGION result ok

#"FC_FIFO_V2.0" := TRUE;

#State := #NO_Error;

END_REGION

展开阅读全文

页面更新:2024-04-23

标签:方法   数据类型   区域

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top