为基于 plc 的电机分配优先级的问题
Issue in assigning priority to plc based motor
我想为数组中的每个元素分配一个唯一的优先级,但在下面的代码片段中,我为具有相同工作时间值的元素重复了相同的优先级 m
。如何为每个元素设置唯一的优先级?
// assign priority number according to working times
#m := 0;
FOR #m := 0 TO 10 DO
FOR #l := 0 TO 10 DO
IF #OrderedList[#m] = #WorkingTimes[#l]."Time" THEN
#WorkingTimes[#l].Priority := #m;
END_IF;
END_FOR;
END_FOR;
设置一些默认优先级,然后在更新元素时退出内部 FOR
循环
// assign priority number according to working times
FOR l := 0 to 10 DO
WorkingTimes[l].Priority := -1;
END_FOR;
FOR m := 0 TO 10 DO
FOR l := 0 TO 10 DO
IF OrderedList[m] = WorkingTimes[l].Time AND WorkingTimes[l].Priority = -1 THEN
WorkingTimes[l].Priority := m;
EXIT;
END_IF;
END_FOR;
END_FOR;
我还没有测试过这个,但这个概念应该可行。
我想为数组中的每个元素分配一个唯一的优先级,但在下面的代码片段中,我为具有相同工作时间值的元素重复了相同的优先级 m
。如何为每个元素设置唯一的优先级?
// assign priority number according to working times
#m := 0;
FOR #m := 0 TO 10 DO
FOR #l := 0 TO 10 DO
IF #OrderedList[#m] = #WorkingTimes[#l]."Time" THEN
#WorkingTimes[#l].Priority := #m;
END_IF;
END_FOR;
END_FOR;
设置一些默认优先级,然后在更新元素时退出内部 FOR
循环
// assign priority number according to working times
FOR l := 0 to 10 DO
WorkingTimes[l].Priority := -1;
END_FOR;
FOR m := 0 TO 10 DO
FOR l := 0 TO 10 DO
IF OrderedList[m] = WorkingTimes[l].Time AND WorkingTimes[l].Priority = -1 THEN
WorkingTimes[l].Priority := m;
EXIT;
END_IF;
END_FOR;
END_FOR;
我还没有测试过这个,但这个概念应该可行。