question

Yokota T avatar image
0 Likes"
Yokota T asked Yokota T commented

Why does TaskExecuter Class have beginOffsetDefault() method?

Hello all,

I am currently reading the Module Development page.

However, I do not understand why the TaskExecuter class has two methods, beginOffset() and beginOffsetDefault().

As shown in the code below, it appears that beginOffsetDefault() is provided to override beginOffset() and hook a specific process.

double MyTaskExecuter::beginOffset(double endspeed, treenode item)
{
    if (xOnly) {
    offsetloc[1] = 0;
    offsetloc[2] = 0;
    }

    return beginOffsetDefault(endspeed, item);
}

However, I am not sure how it differs from "return __super::beginOffset();"

Thank you in advance for your assistance.


FlexSim 23.1.1
module sdkdll
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered Yokota T commented

The beginOffsetDefault() function causes "normal" offset travel to occur. By defining this as a function, we are able to avoid repeating code. The TaskExecuter, Operator, Transporter, and Elevator all call this function.

The difference between this function and calling __super::beginOffset() is that TaskExecuter::beginOffset() sometimes modifies the z component of the travel destination. Not all sub classes need that modification, but they do need the rest of the logic in beginOffsetDefault().

Suppose you override the Operator class. Your MyOperator::beginOffset() method, you cannot call __super::beginOffset(), because that would call Operator::beginOffset(), not TaskExecuter::beginOffset(). By creating the beginOffsetDefault() method, base classes can call that method without worrying about any logic added by intermediate classes.

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Yokota T avatar image Yokota T commented ·

Thank you for your reply. I understand now. I only considered the case where the inheritance relationship is simple.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.