|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716 |
- module COperationScenariosMain
- use CIActionReference
- implicit none
- public
- procedure (ActionVoid), pointer :: UpdateUnityPtr
- contains
-
- ! subroutine OperationScenarios_Setup()
- ! use CSimulationVariables
- ! implicit none
- ! call OnSimulationInitialization%Add(OperationScenarios_Init)
- ! call OnSimulationStop%Add(OperationScenarios_Init)
- ! !call OnOperationScenariosStep%Add(OperationScenarios_Step)
- ! !call OnOperationScenariosOutput%Add(OperationScenarios_Output)
- ! call OnOperationScenariosMain%Add(OperationScenariosMainBody)
- ! end subroutine
-
- ! subroutine OperationScenarios_Init
- ! use COperationScenariosSettings, OperationScenariosInitialization => Initialization
- ! implicit none
- ! call OperationScenariosInitialization()
- ! end subroutine OperationScenarios_Init
-
- subroutine OperationScenarios_Step
- use CSimulationVariables
- use CKellyConnectionEnum
- use CElevatorConnectionEnum
- use CCloseKellyCockLedNotification
- use CCloseSafetyValveLedNotification
- use CFillMouseHoleLedNotification
- use CIrIBopLedNotification
- use CIrSafetyValveLedNotification
- use CLatchLedNotification
- use COpenKellyCockLedNotification
- use COpenSafetyValveLedNotification
- use CSlipsNotification
- use CSwingLedNotification
- use CTongNotification
- use CUnlatchLedNotification
- use CInstallFillupHeadPermission
- use CInstallMudBucketPermission
- use CIrIbopPermission
- use CIrSafetyValvePermission
- use CRemoveFillupHeadPermission
- use CRemoveMudBucketPermission
- use CHookHeight
- use CIbopHeight
- use CNearFloorConnection
- use CSafetyValveHeight
- use CSlackOff
- use CStandRack
- use CStringPressure
- use CZeroStringSpeed
- use CUnityInputs, only: &
- Get_ElevatorConnectionPossible, &
- Get_JointConnectionPossible, &
- Get_ElevatorPickup, &
- Get_NearFloorPosition, &
- Get_SingleSetInMouseHole
- use CBucketEnum
- use CElevatorEnum
- use CHeadEnum
- use CIbopEnum
- use CKellyEnum
- use CMouseHoleEnum
- use COperationConditionEnum
- use CSafetyValveEnum
- use CSlipsEnum
- use CSwingEnum
- use CTongEnum
- use CStringUpdate
- use CFlowPipeDisconnectEnum
- use CFlowKellyDisconnectEnum
- use CFillupHeadPermission
- use CSwingDrillPermission
- use CSwingOffPermission
- use CSwingTiltPermission
- use CTdsStemJointHeight
- use CTdsConnectionModesEnum
- use CTdsElevatorModesEnum
- use CTdsSpineEnum
- use CTdsSwingEnum
- use CTdsTongEnum
- use CTdsBackupClamp
- use CTdsIbopLedNotification
- use CTdsPowerLedNotification
- use CTdsTorqueWrenchLedNotification
-
- implicit none
-
- call Evaluate_KellyConnection()
- call Evaluate_ElevatorConnection()
-
- call Evaluate_CloseKellyCockLed()
- call Evaluate_CloseSafetyValveLed()
- call Evaluate_FillMouseHoleLed()
- call Evaluate_IrIBopLed()
- call Evaluate_IrSafetyValveLed()
- call Evaluate_LatchLed()
- call Evaluate_OpenKellyCockLed()
- call Evaluate_OpenSafetyValveLed()
- call Evaluate_SlipsNotification()
- call Evaluate_SwingLed()
- call Evaluate_TongNotification()
- call Evaluate_UnlatchLed()
-
- call Evaluate_InstallFillupHeadPermission()
- call Evaluate_InstallMudBucketPermission()
- call Evaluate_IrIbopPermission()
- call Evaluate_IrSafetyValvePermission()
- call Evaluate_RemoveFillupHeadPermission()
- call Evaluate_RemoveMudBucketPermission()
-
- call Evaluate_MudBucket()
- call Evaluate_Elevator()
- call Evaluate_FillupHead()
- call Evaluate_Ibop()
- call Evaluate_Kelly()
- call Evaluate_MouseHole()
- call Evaluate_MouseHole()
- call Evaluate_OperationCondition()
- call Evaluate_SafetyValve()
- call Evaluate_Slips()
- call Evaluate_Swing()
- call Evaluate_Tong()
-
- call Evaluate_StringUpdate()
-
- call Evaluate_FlowKellyDisconnect()
- call Evaluate_FlowPipeDisconnect()
-
- !if(Get_FillMouseHoleLed()) then
- ! call Set_MouseHole(MOUSE_HOLE_FILL)
- !else
- ! if((Get_KellyConnection() == KELLY_CONNECTION_SINGLE .or.&
- ! Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE) .and.&
- ! Get_HookHeight() >= 95.0 ) then
- ! call Set_MouseHole(MOUSE_HOLE_NEUTRAL)
- ! else
- ! call Set_MouseHole(MOUSE_HOLE_EMPTY)
- ! endif
- !endif
-
-
-
-
-
-
-
-
- !topdrive
- call Evaluate_TdsElevatorModes()
- call Evaluate_TdsConnectionModes()
- call Evaluate_SwingTiltPermission()
- call Evaluate_SwingOffPermission()
- call Evaluate_SwingDrillPermission()
- call Evaluate_FillupHeadPermission()
- call Evaluate_TdsTong()
- call Evaluate_TdsBackupClamp()
- call Evaluate_TdsSwing()
- call Evaluate_TdsSpine()
-
- call Evaluate_PowerLed()
- call Evaluate_IbopLed()
-
- call Evaluate_TorqueWrenchLed()
-
- end subroutine OperationScenarios_Step
-
- subroutine OperationScenarios_Output
- implicit none
- end subroutine OperationScenarios_Output
-
- subroutine OperationScenariosMainBody
- use CSimulationVariables
-
- use CKellyConnectionEnum
- use CElevatorConnectionEnum
-
- use CCloseKellyCockLedNotification
- use CCloseSafetyValveLedNotification
- use CFillMouseHoleLedNotification
- use CIrIBopLedNotification
- use CIrSafetyValveLedNotification
- use CLatchLedNotification
- use COpenKellyCockLedNotification
- use COpenSafetyValveLedNotification
- use CSlipsNotification
- use CSwingLedNotification
- use CTongNotification
- use CUnlatchLedNotification
-
- use CInstallFillupHeadPermission
- use CInstallMudBucketPermission
- use CIrIbopPermission
- use CIrSafetyValvePermission
- use CRemoveFillupHeadPermission
- use CRemoveMudBucketPermission
-
- use CHookHeight
- use CIbopHeight
- use CNearFloorConnection
- use CSafetyValveHeight
- use CSlackOff
- use CStandRack
- use CStringPressure
- use CZeroStringSpeed
-
- use CUnityInputs, only: &
- Get_ElevatorConnectionPossible, &
- Get_JointConnectionPossible, &
- Get_ElevatorPickup, &
- Get_NearFloorPosition, &
- Get_SingleSetInMouseHole
-
- use CBucketEnum
- use CElevatorEnum
- use CHeadEnum
- use CIbopEnum
- use CKellyEnum
- use CMouseHoleEnum
- use COperationConditionEnum
- use CSafetyValveEnum
- use CSlipsEnum
- use CSwingEnum
- use CTongEnum
-
- use CStringUpdate
-
- use CFlowPipeDisconnectEnum
- use CFlowKellyDisconnectEnum
-
-
- use CFillupHeadPermission
- use CSwingDrillPermission
- use CSwingOffPermission
- use CSwingTiltPermission
- use CTdsStemJointHeight
- use CTdsConnectionModesEnum
- use CTdsElevatorModesEnum
- use CTdsSpineEnum
- use CTdsSwingEnum
- use CTdsTongEnum
- use CTdsBackupClamp
-
- use CTdsIbopLedNotification
- use CTdsPowerLedNotification
-
- use CTdsTorqueWrenchLedNotification
-
- implicit none
- loop1: do
- call Evaluate_KellyConnection()
- call Evaluate_ElevatorConnection()
-
- call Evaluate_CloseKellyCockLed()
- call Evaluate_CloseSafetyValveLed()
- call Evaluate_FillMouseHoleLed()
- call Evaluate_IrIBopLed()
- call Evaluate_IrSafetyValveLed()
- call Evaluate_LatchLed()
- call Evaluate_OpenKellyCockLed()
- call Evaluate_OpenSafetyValveLed()
- call Evaluate_SlipsNotification()
- call Evaluate_SwingLed()
- call Evaluate_TongNotification()
- call Evaluate_UnlatchLed()
-
- call Evaluate_InstallFillupHeadPermission()
- call Evaluate_InstallMudBucketPermission()
- call Evaluate_IrIbopPermission()
- call Evaluate_IrSafetyValvePermission()
- call Evaluate_RemoveFillupHeadPermission()
- call Evaluate_RemoveMudBucketPermission()
-
- call Evaluate_MudBucket()
- call Evaluate_Elevator()
- call Evaluate_FillupHead()
- call Evaluate_Ibop()
- call Evaluate_Kelly()
- call Evaluate_MouseHole()
- call Evaluate_MouseHole()
- call Evaluate_OperationCondition()
- call Evaluate_SafetyValve()
- call Evaluate_Slips()
- call Evaluate_Swing()
- call Evaluate_Tong()
-
- call Evaluate_StringUpdate()
-
- call Evaluate_FlowKellyDisconnect()
- call Evaluate_FlowPipeDisconnect()
-
- !if(Get_FillMouseHoleLed()) then
- ! call Set_MouseHole(MOUSE_HOLE_FILL)
- !else
- ! if((Get_KellyConnection() == KELLY_CONNECTION_SINGLE .or.&
- ! Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE) .and.&
- ! Get_HookHeight() >= 95.0 ) then
- ! call Set_MouseHole(MOUSE_HOLE_NEUTRAL)
- ! else
- ! call Set_MouseHole(MOUSE_HOLE_EMPTY)
- ! endif
- !endif
-
-
-
-
-
-
-
-
- !topdrive
- call Evaluate_TdsElevatorModes()
- call Evaluate_TdsConnectionModes()
- call Evaluate_SwingTiltPermission()
- call Evaluate_SwingOffPermission()
- call Evaluate_SwingDrillPermission()
- call Evaluate_FillupHeadPermission()
- call Evaluate_TdsTong()
- call Evaluate_TdsBackupClamp()
- call Evaluate_TdsSwing()
- call Evaluate_TdsSpine()
-
- call Evaluate_PowerLed()
- call Evaluate_IbopLed()
-
- call Evaluate_TorqueWrenchLed()
-
- !if (IsStopped==.true.) exit loop1
- if(IsStopped) call Quit()
- call sleepqq(100)
- enddo loop1
- end subroutine OperationScenariosMainBody
-
-
-
-
- subroutine SubscribeUpdateUnity(a)
- !DEC$ ATTRIBUTES DLLEXPORT :: SubscribeUpdateUnity
- !DEC$ ATTRIBUTES ALIAS: 'SubscribeUpdateUnity' :: SubscribeUpdateUnity
- implicit none
- procedure (ActionVoid) :: a
- UpdateUnityPtr => a
- end subroutine
-
- subroutine UpdateUnity()
- implicit none
- if(associated(UpdateUnityPtr)) call UpdateUnityPtr()
- end subroutine
-
- subroutine PreProcessingSnapshot
- !DEC$ ATTRIBUTES DLLEXPORT :: PreProcessingSnapshot
- !DEC$ ATTRIBUTES ALIAS: 'PreProcessingSnapshot' :: PreProcessingSnapshot
- use CSwingEnumVariables
- use CSlipsEnumVariables
- use CHookVariables
- use CTongEnumVariables
- use CHoistingVariables
- use CKellyConnectionEnumVariables
- use CElevatorConnectionEnumVariables
- use COperationConditionEnumVariables
- use CMouseHoleEnumVariables
- implicit none
-
- if(DriveType == Kelly_DriveType) then ! kelly mode
-
-
- if(Get_OperationCondition() == OPERATION_DRILL) then
-
- if(Get_KellyConnection() == KELLY_CONNECTION_NOTHING) then
- call Kelly_ConnectionNothing()
-
- elseif (Get_KellyConnection() == KELLY_CONNECTION_STRING) then
- call Kelly_ConnectionString()
-
- elseif (Get_KellyConnection() == KELLY_CONNECTION_SINGLE) then
- call Kelly_ConnectionSingle()
-
- endif
-
- elseif (Get_OperationCondition() == OPERATION_TRIP) then
-
- if(Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING) then
- call Elevator_ConnectionNothing()
-
- elseif (Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING) then
- call Elevator_ConnectionString()
-
- elseif (Get_ElevatorConnection() == ELEVATOR_CONNECTION_STAND) then
- call Elevator_ConnectionStand()
-
- elseif (Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE) then
- call Elevator_ConnectionSingle()
-
- endif
-
-
- endif
-
-
-
-
- else ! Topdrive mode
- !
- endif
-
- ! final adjustments
- call Update_MouseHole_From_Snapshot()
-
- end subroutine PreProcessingSnapshot
-
-
-
-
- subroutine Kelly_ConnectionNothing
- use CSwingEnumVariables
- use CSlipsEnumVariables
- use CHookVariables
- implicit none
-
- call Set_HookHeight(75.0)
- call sleep(1)
-
- ! first wait for unity to get to starting point
- loop1: do
- if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
- call sleepqq(100)
- enddo loop1
- call sleep(1)
-
- !TODO: possibly goto a position to activate swing
-
- ! goto preferred swing position
- if(Swing_S == SWING_MOUSE_HOLE_END) then
- call Set_Swing(SWING_MOUSE_HOLE_BEGIN)
- call UpdateUnity()
- loop2: do
- if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop2
- call sleepqq(100)
- enddo loop2
- elseif (Swing_S == SWING_RAT_HOLE_END) then
- call Set_Swing(SWING_RAT_HOLE_BEGIN)
- call UpdateUnity()
- loop3: do
- if(Get_Swing() == SWING_RAT_HOLE_END) exit loop3
- call sleepqq(100)
- enddo loop3
- !elseif (Swing_S == SWING_WELL_END) then
- ! call Set_Swing(SWING_WELL_BEGIN)
- ! call UpdateUnity()
- ! loop4: do
- ! if(Get_Swing() == SWING_WELL_END) exit loop4
- ! call sleepqq(100)
- ! enddo loop4
- endif
- call sleep(3)
-
- ! move to final hook height
- call Update_HookHeight_From_Snapshot()
- call sleep(3)
-
- end subroutine Kelly_ConnectionNothing
-
-
-
-
-
- subroutine Kelly_ConnectionString
- use CSwingEnumVariables
- use CSlipsEnumVariables
- use CHookVariables
- use CTongEnumVariables
- implicit none
-
- call Set_HookHeight(75.0)
- call sleep(1)
-
- ! first wait for unity to get to starting point
- loop1: do
- if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
- call sleepqq(100)
- enddo loop1
- call sleep(1)
-
- ! goto connection to string position
- call Set_HookHeight_S(66.7)
- call sleep(1)
-
- ! start tong makeup
- call Set_Tong(TONG_MAKEUP_BEGIN)
- call UpdateUnity()
- loop2: do
- if(Get_Tong() == TONG_MAKEUP_END) exit loop2
- call sleepqq(100)
- enddo loop2
- call sleepqq(100)
-
- ! release slips
- call Set_Slips(SLIPS_UNSET_BEGIN)
- call UpdateUnity()
- loop3: do
- if(Get_Slips() == SLIPS_UNSET_END) exit loop3
- call sleepqq(100)
- enddo loop3
- call sleepqq(100)
-
- ! move to final hook height
- call Update_HookHeight_From_Snapshot()
- call sleep(3)
-
-
- ! put slips to saved position
- if(Slips_S == SLIPS_SET_END) then
-
- call Set_Slips(SLIPS_SET_BEGIN)
- call UpdateUnity()
- loop4: do
- if(Get_Slips() == SLIPS_SET_END) exit loop4
- call sleepqq(100)
- enddo loop4
- call sleep(1)
- endif
-
-
- end subroutine Kelly_ConnectionString
-
-
-
-
- subroutine Kelly_ConnectionSingle
- use CSwingEnumVariables
- use CSlipsEnumVariables
- use CTongEnumVariables
- use CHookVariables
- implicit none
-
- call Set_HookHeight(75.0)
- call sleep(1)
-
- ! first wait for unity to get to starting point
- loop1: do
- if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
- call sleepqq(100)
- enddo loop1
- call sleep(1)
-
-
- ! goto swing mouse hole position
- call Set_HookHeight_S(70.0)
- call sleep(1)
-
- ! swing mouse hole
- call Set_Swing(SWING_MOUSE_HOLE_BEGIN)
- call UpdateUnity()
- loop2: do
- if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop2
- call sleepqq(100)
- enddo loop2
- call sleepqq(100)
-
-
- ! goto makeup pipe location
- call Set_HookHeight_S(65.0)
- call sleep(1)
-
-
- ! start tong makeup
- call Set_Tong(TONG_MAKEUP_BEGIN)
- call UpdateUnity()
- loop3: do
- if(Get_Tong() == TONG_MAKEUP_END) exit loop3
- call sleepqq(100)
- enddo loop3
- call sleepqq(100)
-
-
-
- if (Swing_S == SWING_WELL_END) then ! already in mouse hole
-
- ! goto swing location
- call Set_HookHeight_S(98.0)
- call sleep(1)
-
- ! goto preferred swing position
- call Set_Swing(SWING_WELL_BEGIN)
- call UpdateUnity()
- loop4: do
- if(Get_Swing() == SWING_WELL_END) exit loop4
- call sleepqq(100)
- enddo loop4
- call sleep(2)
-
- endif
-
-
- ! move to final hook height
- call Update_HookHeight_From_Snapshot()
- call sleep(3)
-
- end subroutine Kelly_ConnectionSingle
-
-
-
-
-
-
- subroutine Elevator_ConnectionNothing
- use CSwingEnumVariables
- use CSlipsEnumVariables
- use CHookVariables
- use CKellyEnumVariables
- implicit none
-
- call Set_HookHeight(75.0)
- call sleep(1)
-
- ! first wait for unity to get to starting point
- loop1: do
- if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
- call sleepqq(100)
- enddo loop1
- call sleep(1)
-
-
- !TODO: possibly goto a position to activate swing
-
- !! first goto mouse hole
- !call Set_Swing(SWING_MOUSE_HOLE_BEGIN)
- !call UpdateUnity()
- !loop2: do
- ! if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop2
- ! call sleepqq(100)
- !enddo loop2
- !call sleep(1)
- !
- !! then goto rat hole
- !call Set_Swing(SWING_RAT_HOLE_BEGIN)
- !call UpdateUnity()
- !loop3: do
- ! if(Get_Swing() == SWING_RAT_HOLE_END) exit loop3
- ! call sleepqq(100)
- !enddo loop3
- !call sleep(1)
-
- ! kelly back
- call Set_Kelly(KELLY_REMOVE)
- call sleepqq(100)
-
-
-
- ! goto preferred swing position
- if(Swing_S == SWING_MOUSE_HOLE_END) then
- call Set_Swing(SWING_MOUSE_HOLE_BEGIN)
- call UpdateUnity()
- loop4: do
- if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop4
- call sleepqq(100)
- enddo loop4
- elseif (Swing_S == SWING_RAT_HOLE_END) then
- call Set_Swing(SWING_RAT_HOLE_BEGIN)
- call UpdateUnity()
- loop5: do
- if(Get_Swing() == SWING_RAT_HOLE_END) exit loop5
- call sleepqq(100)
- enddo loop5
- elseif (Swing_S == SWING_WELL_END) then
- call Set_Swing(SWING_WELL_BEGIN)
- call UpdateUnity()
- loop6: do
- if(Get_Swing() == SWING_WELL_END) exit loop6
- call sleepqq(100)
- enddo loop6
- endif
- call sleepqq(100)
-
-
-
- ! move to final hook height
- call Update_HookHeight_From_Snapshot()
- call sleep(3)
-
- end subroutine Elevator_ConnectionNothing
-
-
-
-
-
- subroutine Elevator_ConnectionString
- implicit none
- end subroutine Elevator_ConnectionString
-
-
-
-
-
-
-
- subroutine Elevator_ConnectionStand
- implicit none
- end subroutine Elevator_ConnectionStand
-
-
-
-
-
-
- subroutine Elevator_ConnectionSingle
- implicit none
- end subroutine Elevator_ConnectionSingle
-
-
-
-
-
- end module COperationScenariosMain
|