freetype CRANE == { ToDepositBelt, ToFeedBelt, cIdle }
typealias GRIPPER == FLOAT
static function OnDepositBelt == 0.9230
static function SafeDistanceFromFeedBelt == 0.0
static function OnFeedBelt == 0.6593
dynamic function CraneHorizontalMot : CRANE
initially cIdle
dynamic function CraneVerticalMot : UP_DOWN
initially udIdle
dynamic function CraneMagnet : ON_OFF
initially Off
output function GripperOverDepositBelt : BOOL
output function GripperOverFeedBelt : BOOL
output function GripperVerticalPos : GRIPPER
derived relation WaitingToUnloadDepositBelt ==
GripperOverDepositBelt and GripperVerticalPos >= OnDepositBelt and
CraneHorizontalMot = cIdle and CraneVerticalMot = udIdle and
CraneMagnet = Off
derived relation WaitingToLoadFeedBelt ==
GripperOverFeedBelt and GripperVerticalPos = SafeDistanceFromFeedBelt
and CraneHorizontalMot = cIdle and CraneVerticalMot = udIdle and
CraneMagnet = On
transition WAITING_DB ==
if WaitingToUnloadDepositBelt and PieceAtDepositBeltEnd
then CraneMagnet := On
endif
transition UNLOADING_DB ==
if CraneVerticalMot = udIdle and GripperVerticalPos >= OnDepositBelt and
CraneMagnet = On
then CraneVerticalMot := Up
endif
if CraneVerticalMot = Up and GripperVerticalPos = SafeDistanceFromFeedBelt
then CraneVerticalMot := udIdle
CraneHorizontalMot := ToFeedBelt
PieceAtDepositBeltEnd := false
endif
transition MOVING_FB ==
if CraneHorizontalMot = ToFeedBelt and GripperOverFeedBelt
then CraneHorizontalMot := cIdle
endif
transition WAITING_FB ==
if WaitingToLoadFeedBelt and FeedBeltFree
then CraneVerticalMot := Down
endif
transition LOADING_FB ==
if CraneVerticalMot = Down and GripperVerticalPos >= OnFeedBelt
and GripperOverFeedBelt
then CraneVerticalMot := udIdle
CraneMagnet := Off
endif
if CraneVerticalMot = udIdle and GripperVerticalPos >= OnFeedBelt
and GripperOverFeedBelt and CraneHorizontalMot = cIdle
and CraneMagnet = Off
then CraneHorizontalMot := ToDepositBelt
FeedBeltFree := false
endif
transition MOVING_DB ==
if CraneHorizontalMot = ToDepositBelt and GripperOverDepositBelt
then CraneHorizontalMot := cIdle
CraneVerticalMot := Down
endif
if GripperOverDepositBelt and
CraneVerticalMot = Down and GripperVerticalPos >= OnDepositBelt
then CraneVerticalMot := udIdle
endif