|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563 |
- module UnitySignalsModule
- use UnitySignalVariables
- use SimulationVariables
- use RedisInterface
- contains
-
- subroutine UnitySignalsToJson(parent)
- type(json_value),pointer :: parent
- type(json_value),pointer :: p
- type(json_core) :: jsoncore
-
- call jsoncore%create_object(p,'UnitySignals')
-
- call jsoncore%add(p,"MudBucket",data%State%unitySignals%MudBucket)
- call jsoncore%add(p,"Elevator",data%State%unitySignals%Elevator)
- call jsoncore%add(p,"FillupHead",data%State%unitySignals%FillupHead)
- call jsoncore%add(p,"Ibop",data%State%unitySignals%Ibop)
- call jsoncore%add(p,"Kelly",data%State%unitySignals%Kelly)
- call jsoncore%add(p,"MouseHole",data%State%unitySignals%MouseHole)
- call jsoncore%add(p,"OperationCondition",data%State%unitySignals%OperationCondition)
- call jsoncore%add(p,"SafetyValve",data%State%unitySignals%SafetyValve)
- call jsoncore%add(p,"operation",data%State%unitySignals%operation)
- call jsoncore%add(p,"Slips",data%State%unitySignals%Slips)
- call jsoncore%add(p,"Slips_S",data%State%unitySignals%Slips_S)
- call jsoncore%add(p,"Swing",data%State%unitySignals%Swing)
- call jsoncore%add(p,"Swing_S",data%State%unitySignals%Swing_S)
- call jsoncore%add(p,"TdsBackupClamp",data%State%unitySignals%TdsBackupClamp)
- call jsoncore%add(p,"TdsSpine",data%State%unitySignals%TdsSpine)
- call jsoncore%add(p,"TdsSwing",data%State%unitySignals%TdsSwing)
- call jsoncore%add(p,"TdsTong",data%State%unitySignals%TdsTong)
- call jsoncore%add(p,"Tong",data%State%unitySignals%Tong)
- call jsoncore%add(p,"Tong_S",data%State%unitySignals%Tong_S)
- call jsoncore%add(p,"TdsConnectionModes",data%State%unitySignals%TdsConnectionModes)
- call jsoncore%add(p,"TdsElevatorModes",data%State%unitySignals%TdsElevatorModes)
-
- call jsoncore%add(parent,p)
- end subroutine
-
- subroutine UnitySignalsFromJson(jsonfile)
- type(json_file)::jsonfile
- logical::found
-
- call jsonfile%get('UnitySignals.MudBucket',data%State%unitySignals%MudBucket,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%MudBucket")
- call jsonfile%get('UnitySignals.Elevator',data%State%unitySignals%Elevator,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%Elevator")
- call jsonfile%get('UnitySignals.FillupHead',data%State%unitySignals%FillupHead,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%FillupHead")
- call jsonfile%get('UnitySignals.Ibop',data%State%unitySignals%Ibop,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%Ibop")
- call jsonfile%get('UnitySignals.Kelly',data%State%unitySignals%Kelly,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%Kelly")
- call jsonfile%get('UnitySignals.MouseHole',data%State%unitySignals%MouseHole,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%MouseHole")
- call jsonfile%get('UnitySignals.OperationCondition',data%State%unitySignals%OperationCondition,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%OperationCondition")
- call jsonfile%get('UnitySignals.SafetyValve',data%State%unitySignals%SafetyValve,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%SafetyValve")
- call jsonfile%get('UnitySignals.operation',data%State%unitySignals%operation,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%operation")
- call jsonfile%get('UnitySignals.Slips',data%State%unitySignals%Slips,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%Slips")
- call jsonfile%get('UnitySignals.Slips_S',data%State%unitySignals%Slips_S,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%Slips_S")
- call jsonfile%get('UnitySignals.Swing',data%State%unitySignals%Swing,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%Swing")
- call jsonfile%get('UnitySignals.Swing_S',data%State%unitySignals%Swing_S,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%Swing_S")
- call jsonfile%get('UnitySignals.TdsBackupClamp',data%State%unitySignals%TdsBackupClamp,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%TdsBackupClamp")
- call jsonfile%get('UnitySignals.TdsSpine',data%State%unitySignals%TdsSpine,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%TdsSpine")
- call jsonfile%get('UnitySignals.TdsSwing',data%State%unitySignals%TdsSwing,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%TdsSwing")
- call jsonfile%get('UnitySignals.TdsTong',data%State%unitySignals%TdsTong,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%TdsTong")
- call jsonfile%get('UnitySignals.Tong',data%State%unitySignals%Tong,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%Tong")
- call jsonfile%get('UnitySignals.Tong_S',data%State%unitySignals%Tong_S,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%Tong_S")
- call jsonfile%get('UnitySignals.TdsConnectionModes',data%State%unitySignals%TdsConnectionModes,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%TdsConnectionModes")
- call jsonfile%get('UnitySignals.TdsElevatorModes',data%State%unitySignals%TdsElevatorModes,found)
- if ( .not. found ) call logg(4,"Not found: unitySignals%TdsElevatorModes")
-
- end subroutine
-
- subroutine Set_TdsElevatorModes(v)
- implicit none
- integer , intent(in) :: v
- #ifdef ExcludeExtraChanges
- if(data%State%unitySignals%TdsElevatorModes == v) return
- #endif
- data%State%unitySignals%TdsElevatorModes = v
- !**call TdsElevatorModesEnum%OnTdsElevatorModesChange%RunAll()
- end subroutine
-
- integer function Get_TdsElevatorModes()
- implicit none
- Get_TdsElevatorModes = data%State%unitySignals%TdsElevatorModes
- end function
-
- subroutine Set_Ibop_Install()
- implicit none
- call Set_Ibop(IBOP_INSTALL)
- end subroutine
-
- subroutine Set_Ibop_Remove()
- implicit none
- call Set_Ibop(IBOP_REMOVE)
- end subroutine
-
- subroutine Set_Tong(v)
- implicit none
- integer , intent(in) :: v
- if(data%State%unitySignals%Tong == v) return
- data%State%unitySignals%Tong = v
- if(print_log) print*, 'Tong=', data%State%unitySignals%Tong
- if(data%State%unitySignals%Tong==TONG_MAKEUP_BEGIN) call publishMessageToChannel("TONG_MAKEUP_BEGIN")
- if(data%State%unitySignals%Tong==TONG_BREAKOUT_BEGIN) call publishMessageToChannel("TONG_BREAKOUT_BEGIN")
- !**call data%State%unitySignals%OnTongChange%RunAll()
- end subroutine
-
- integer function Get_Tong()
- implicit none
- Get_Tong = data%State%unitySignals%Tong
- end function
-
-
- subroutine Set_TdsTong(v)
- implicit none
- integer , intent(in) :: v
- #ifdef ExcludeExtraChanges
- if(data%State%unitySignals%TdsTong == v) return
- #endif
- data%State%unitySignals%TdsTong = v
- #ifdef deb
- if(print_log) print*, 'TdsTong=', data%State%unitySignals%TdsTong
- #endif
- !**call data%State%unitySignals%OnTdsTongChange%RunAll()
- end subroutine
-
- integer function Get_TdsTong()
- implicit none
- Get_TdsTong = data%State%unitySignals%TdsTong
- end function
-
-
- subroutine Set_TdsSwing(v)
- implicit none
- integer , intent(in) :: v
- #ifdef ExcludeExtraChanges
- if(data%State%unitySignals%TdsSwing == v) return
- #endif
- data%State%unitySignals%TdsSwing = v
- #ifdef deb
- if(print_log) print*, 'TdsSwing=', data%State%unitySignals%TdsSwing
- #endif
- !**call data%State%unitySignals%OnTdsSwingChange%RunAll()
- end subroutine
-
- integer function Get_TdsSwing()
- implicit none
- Get_TdsSwing = data%State%unitySignals%TdsSwing
- end function
-
-
- subroutine Set_TdsSpine(v)
- implicit none
- integer , intent(in) :: v
- #ifdef ExcludeExtraChanges
- if(data%State%unitySignals%TdsSpine == v) return
- #endif
- data%State%unitySignals%TdsSpine = v
- #ifdef deb
- if(print_log) print*, 'TdsSpine=', data%State%unitySignals%TdsSpine
- #endif
- !**call data%State%unitySignals%OnTdsSpineChange%RunAll()
- end subroutine
-
- integer function Get_TdsSpine()
- implicit none
- Get_TdsSpine = data%State%unitySignals%TdsSpine
- end function
-
-
- subroutine Set_TdsBackupClamp(v)
- implicit none
- integer , intent(in) :: v
- #ifdef ExcludeExtraChanges
- if(data%State%unitySignals%TdsBackupClamp == v) return
- #endif
- data%State%unitySignals%TdsBackupClamp = v
- #ifdef deb
- if(print_log) print*, 'TdsBackupClamp=', data%State%unitySignals%TdsBackupClamp
- #endif
- !**call data%State%unitySignals%OnTdsBackupClampChange%RunAll()
- end subroutine
-
- integer function Get_TdsBackupClamp()
- implicit none
- Get_TdsBackupClamp = data%State%unitySignals%TdsBackupClamp
- end function
-
-
- subroutine Set_Swing(v)
- implicit none
- integer , intent(in) :: v
- #ifdef ExcludeExtraChanges
- if(data%State%unitySignals%Swing == v) return
- #endif
- data%State%unitySignals%Swing = v
- #ifdef deb
- if(print_log) print*, 'Swing=', data%State%unitySignals%Swing
- #endif
- !**call data%State%unitySignals%OnSwingChange%RunAll()
- end subroutine
-
- integer function Get_Swing()
- implicit none
- Get_Swing = data%State%unitySignals%Swing
- end function
-
- !//TODO: apparently every thing is started here for slips
- subroutine Set_Slips(v)
- implicit none
- integer , intent(in) :: v
- if(data%State%unitySignals%Slips == v) return
- data%State%unitySignals%Slips = v
- if(print_log) print*, 'Slips=', data%State%unitySignals%Slips
- if(v==SLIPS_SET_BEGIN) call publishMessageToChannel("SLIPS_SET_BEGIN")
- if(v==SLIPS_UNSET_BEGIN) call publishMessageToChannel("SLIPS_UNSET_BEGIN")
- !**call data%State%unitySignals%OnSlipsChange%RunAll()
- end subroutine
-
- integer function Get_Slips()
- implicit none
- Get_Slips = data%State%unitySignals%Slips
- end function
-
- subroutine Set_Operation(i)
- implicit none
- integer, intent (in) :: i
- data%State%unitySignals%operation = i
- end subroutine
-
- subroutine Set_SafetyValve(v)
- implicit none
- integer , intent(in) :: v
- #ifdef ExcludeExtraChanges
- if(data%State%unitySignals%SafetyValve == v) return
- #endif
- data%State%unitySignals%SafetyValve = v
- #ifdef deb
- if(data%State%unitySignals%SafetyValve == SAFETY_VALVE_NEUTRAL) then
- if(print_log) print*, 'SafetyValve=SAFETY_VALVE_NEUTRAL'
- else if (data%State%unitySignals%SafetyValve == SAFETY_VALVE_INSTALL) then
- if(print_log) print*, 'SafetyValve=SAFETY_VALVE_INSTALL'
- else if (data%State%unitySignals%SafetyValve == SAFETY_VALVE_INSTALL) then
- if(print_log) print*, 'SafetyValve=SAFETY_VALVE_REMOVE'
- endif
- #endif
- !**call data%State%unitySignals%OnSafetyValveChange%RunAll()
- end subroutine
-
- integer function Get_SafetyValve()
- implicit none
- Get_SafetyValve = data%State%unitySignals%SafetyValve
- end function
-
- subroutine Set_SafetyValve_Install()
- implicit none
- call Set_SafetyValve(SAFETY_VALVE_INSTALL)
- end subroutine
-
- subroutine Set_SafetyValve_Remove()
- implicit none
- call Set_SafetyValve(SAFETY_VALVE_REMOVE)
- end subroutine
-
-
- subroutine Set_OperationCondition(v)
- ! use CKellyEnumVariables
- implicit none
- integer , intent(in) :: v
- #ifdef ExcludeExtraChanges
- if(data%State%unitySignals%OperationCondition == v) return
- #endif
- data%State%unitySignals%OperationCondition = v
- #ifdef deb
- if(print_log) print*, 'OperationCondition=', data%State%unitySignals%OperationCondition
- #endif
- !**call data%State%unitySignals%OnOperationConditionChange%RunAll()
- !**call data%State%unitySignals%OnOperationConditionChangeInt%RunAll(data%State%unitySignals%OperationCondition)
- end subroutine
-
- integer function Get_OperationCondition()
- implicit none
- Get_OperationCondition = data%State%unitySignals%OperationCondition
- end function
-
- subroutine Evaluate_OperationCondition()
- implicit none
- end subroutine
-
-
- subroutine Set_MouseHole(v)
- implicit none
- integer , intent(in) :: v
- #ifdef ExcludeExtraChanges
- if(data%State%unitySignals%MouseHole == v) return
- #endif
- !call sleep(2)
- data%State%unitySignals%MouseHole = v
- #ifdef deb
- if(print_log) print*, 'MouseHole=', data%State%unitySignals%MouseHole
- #endif
- !**call data%State%unitySignals%OnMouseHoleChange%RunAll()
- end subroutine
-
- integer function Get_MouseHole()
- implicit none
- Get_MouseHole = data%State%unitySignals%MouseHole
- end function
-
-
-
- subroutine Set_Kelly(v)
- implicit none
- integer , intent(in) :: v
- #ifdef ExcludeExtraChanges
- if(data%State%unitySignals%Kelly == v) return
- #endif
- data%State%unitySignals%Kelly = v
- #ifdef deb
- if(print_log) print*, 'Kelly=', data%State%unitySignals%Kelly
- #endif
- !**call data%State%unitySignals%OnKellyChange%RunAll()
- end subroutine
-
- integer function Get_Kelly()
- implicit none
- Get_Kelly = data%State%unitySignals%Kelly
- end function
-
-
- subroutine Set_Ibop(v)
- implicit none
- integer , intent(in) :: v
- #ifdef ExcludeExtraChanges
- if(data%State%unitySignals%Ibop == v) return
- #endif
- data%State%unitySignals%Ibop = v
- #ifdef deb
- if(print_log) print*, 'Ibop=', data%State%unitySignals%Ibop
- #endif
- !**call data%State%unitySignals%OnIbopChange%RunAll()
- end subroutine
-
- integer function Get_Ibop()
- implicit none
- Get_Ibop = data%State%unitySignals%Ibop
- end function
-
-
- subroutine Set_FillupHead(v)
- use CManifolds, only: ToggleFillupHead
- implicit none
- integer , intent(in) :: v
- #ifdef ExcludeExtraChanges
- if(data%State%unitySignals%FillupHead == v) return
- #endif
- data%State%unitySignals%FillupHead = v
-
- if (data%State%unitySignals%FillupHead == FILLUP_HEAD_INSTALL) then
- call ToggleFillupHead(.true.)
- else if (data%State%unitySignals%FillupHead == FILLUP_HEAD_REMOVE) then
- call ToggleFillupHead(.false.)
- endif
-
- #ifdef deb
- if(print_log) print*, 'FillupHead=', data%State%unitySignals%FillupHead
- #endif
- !**call data%State%unitySignals%OnFillupHeadChange%RunAll()
- end subroutine
-
- integer function Get_FillupHead()
- implicit none
- Get_FillupHead = data%State%unitySignals%FillupHead
- end function
-
- subroutine Evaluate_FillupHead()
- use CHoistingVariables
- use SimulationVariables
- use CStudentStationVariables!, only: data%State%StudentStation%FillupHeadInstallation
- implicit none
-
- if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
- #ifdef OST
- if(print_log) print*, 'Evaluate_FillupHead=TopDrive'
- #endif
- endif
-
-
-
-
-
-
- if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
- #ifdef OST
- if(print_log) print*, 'Evaluate_FillupHead=Kelly'
- #endif
- endif
-
-
- if (Get_FillupHead() == FILLUP_HEAD_INSTALL) then
- data%State%StudentStation%FillupHeadInstallation = .true.
- else if (Get_FillupHead() == FILLUP_HEAD_REMOVE) then
- data%State%StudentStation%FillupHeadInstallation = .false.
- endif
-
- end subroutine
-
-
- subroutine Set_Elevator(v)
- implicit none
- integer , intent(in) :: v
- #ifdef ExcludeExtraChanges
- if(data%State%unitySignals%Elevator == v) return
- #endif
- data%State%unitySignals%Elevator = v
- #ifdef deb
- if(print_log) print*, 'Elevator=', data%State%unitySignals%Elevator
- #endif
- !**call data%State%unitySignals%OnElevatorChange%RunAll()
- end subroutine
-
- integer function Get_Elevator()
- implicit none
- Get_Elevator = data%State%unitySignals%Elevator
- end function
-
-
-
- subroutine Set_MudBucket(v)
- use CManifolds, only: ToggleMudBox
- implicit none
- integer , intent(in) :: v
- #ifdef ExcludeExtraChanges
- if(data%State%unitySignals%MudBucket == v) return
- #endif
- data%State%unitySignals%MudBucket = v
- if (data%State%unitySignals%MudBucket == MUD_BUCKET_INSTALL) then
- call ToggleMudBox(.true.)
- else if (data%State%unitySignals%MudBucket == MUD_BUCKET_REMOVE) then
- call ToggleMudBox(.false.)
- endif
- #ifdef deb
- if(print_log) print*, 'MudBucket=', data%State%unitySignals%MudBucket
- #endif
- !**call data%State%unitySignals%OnMudBucketChange%RunAll()
- end subroutine
-
- integer function Get_MudBucket()
- implicit none
- Get_MudBucket = data%State%unitySignals%MudBucket
- end function
-
- subroutine Evaluate_MudBucket()
- use CStudentStationVariables!, only: data%State%StudentStation%MudBoxInstallation
- implicit none
-
- if (Get_MudBucket() == MUD_BUCKET_INSTALL) then
- data%State%StudentStation%MudBoxInstallation = .true.
- else if (Get_MudBucket() == MUD_BUCKET_REMOVE) then
- data%State%StudentStation%MudBoxInstallation = .false.
- endif
-
- end subroutine
-
-
- !! Moved from CTdsConnectionModeEnum
-
- subroutine Set_TdsConnectionModes(v)
- use CManifolds, Only: KellyConnected, KellyDisconnected
- implicit none
- integer , intent(in) :: v
- #ifdef ExcludeExtraChanges
- if(data%State%unitySignals%TdsConnectionModes == v) return
- #endif
- data%State%unitySignals%TdsConnectionModes = v
-
- if(data%State%unitySignals%TdsConnectionModes == TDS_CONNECTION_NOTHING) then
- call KellyDisconnected()
- else
- call KellyConnected()
- endif
-
- #ifdef deb
- if(print_log) print*, 'data%State%unitySignals%TdsConnectionModes=', data%State%unitySignals%TdsConnectionModes
- #endif
- !**call data%State%unitySignals%OnTdsConnectionModesChange%RunAll()
- end subroutine
-
- integer function Get_TdsConnectionModes()
- use SimulationVariables
- implicit none
- Get_TdsConnectionModes = data%State%unitySignals%TdsConnectionModes
- end function
-
- subroutine Evaluate_TdsConnectionModes()
- use CUnityInputs
- use SimulationVariables
- use UnityModule
- implicit none
-
- if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
-
- !TOPDRIVE-CODE=3
- if (Get_TdsStemIn() .and.&
- Get_TdsSpine() == TDS_SPINE_CONNECT_END .and.&
- !TopDriveDrillTorqueState == TdsMu_SPINE
- Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING) then
- call Set_TdsConnectionModes(TDS_CONNECTION_SPINE)
- return
- end if
-
- !TOPDRIVE-CODE=4
- if (Get_TdsTong() == TDS_TONG_MAKEUP_END .and.&
- Get_TdsConnectionModes() == TDS_CONNECTION_SPINE ) then
-
- call Set_TdsConnectionModes(TDS_CONNECTION_STRING)
- data%Equipments%TopDrivePanel%TopDriveTorqueWrenchLed = LED_OFF
- return
- end if
-
- !TOPDRIVE-CODE=5
- if (Get_TdsTong() == TDS_TONG_BREAKOUT_END .and.&
- Get_TdsConnectionModes() == TDS_CONNECTION_STRING ) then
-
- call Set_TdsConnectionModes(TDS_CONNECTION_SPINE)
- data%Equipments%TopDrivePanel%TopDriveTorqueWrenchLed = LED_OFF
- return
- end if
-
- !TOPDRIVE-CODE=6
- if (Get_TdsSpine() == TDS_SPINE_DISCONNECT_END .and.&
- !Get_TdsStemIn() == .false. .and.&
- Get_TdsConnectionModes() == TDS_CONNECTION_SPINE) then
-
- call Set_TdsConnectionModes(TDS_CONNECTION_NOTHING)
- return
- end if
-
- endif
-
- ! if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
- ! if(print_log) print*, 'Evaluate_TdsConnectionModes=Kelly'
- ! endif
-
- end subroutine
-
- end module UnitySignalsModule
|