【发布时间】:2022-06-14 21:38:48
【问题描述】:
如何确定指针索引成员的类型。 我打算用:
TYPE DUT_DemoStruct :
STRUCT
Member_1: BOOL;
Member_2: INT;
END_STRUCT
END_TYPE
PROGRAM Prg_Main
VAR
DemoStructPointer:
Obj_DemoStruct1: DUT_DemoStruct ;
Obj_DemoStruct2: DUT_DemoStruct ;
Obj_DemoStruct3: DUT_DemoStruct ;
Demo_INT: INT;
Index: INT;
_pointer: POINTER TO DUT_DemoStruct;
END_VAR
FOR Index:=0 TO 5 DO
IF _pointer[Index] THEN //whether the _pointer[Index] (pointer index member) is of type DUT_DemoStruct
_pointer[Index].Member_1:=TRUE;
END_IF;
END_FOR;
另外,你们有CheckPointer的申请案例吗?
编辑:2022-06-05
这是为了更好的实现HMSD(Hierarchical Master-Slave Distribution)框架的约定部分。例如,状态的批量初始化。例如:如果要实现类Step对象的批量初始化,只需将第一个Step的指针传递给初始化函数,该函数会自动根据第一个指针向下搜索,直到找到一个对象不属于 Step 类并停止搜索。这个过程需要自动化。要实现这样的功能,需要指针的索引,并确定指针索引成员的类型。理想代码:
FUNCTION_BLOCK Exe_PalletShuttle EXTENDS Frame.Base_LocalScope
VAR
{attribute 'hide'}pointer_Step: POINTER TO Frame.Base_Step;
{attribute 'hide'}step_Start: Frame.Base_Step;
{attribute 'hide'}step_StartRecharg: Frame.Base_Step;
{attribute 'hide'}step_LengthwaysMove_Start: Frame.Base_Step;
{attribute 'hide'}step_LiftShuttleCyd_PutDown: Frame.Base_Step;
{attribute 'hide'}step_LengthwaysMove_GoTarget: Frame.Base_Step;
{attribute 'hide'}step_LengthwaysMove_End: Frame.Base_Step;
{attribute 'hide'}step_WidthwaysMove_Start: Frame.Base_Step;
{attribute 'hide'}step_LiftShuttleCyd_Uplift: Frame.Base_Step;
{attribute 'hide'}step_WidthwaysMove_GoTarget: Frame.Base_Step;
{attribute 'hide'}step_WidthwaysMove_End: Frame.Base_Step;
{attribute 'hide'}step_UpliftPallet_Start: Frame.Base_Step;
{attribute 'hide'}step_LiftPalletCyd_Uplift: Frame.Base_Step;
{attribute 'hide'}step_UpliftPallet_End: Frame.Base_Step;
{attribute 'hide'}step_PutdownPallet_Start: Frame.Base_Step;
{attribute 'hide'}step_LiftPalletCyd_Putdown: Frame.Base_Step;
{attribute 'hide'}step_PutdownPallet_End: Frame.Base_Step;
{attribute 'hide'}step_End: Frame.Base_Step;
{attribute 'hide'}VividerMark: BOOL;
{attribute 'hide'}obj_PalletLiftCyd: Frame.Device_Actuator;
{attribute 'hide'}obj_DiverterLiftCyd: Frame.Device_Actuator;
END_VAR
pointer_Step:= ADR(step_Start); InitialStepScope(FirstAdr:=pointer_Step); 感觉目前指针实现的机制,这样的功能似乎很难实现。期待收藏功能上线。
【问题讨论】:
标签: codesys