浏览代码

First Demo

master
mahmood19227 1年前
父节点
当前提交
2c7ef98a69
共有 58 个文件被更改,包括 3123 次插入683 次删除
  1. +1
    -1
      .vscode/launch.json
  2. +1
    -1
      CSharp/BasicInputs/WellProfile/CCasingLinerChoke.f90
  3. +82
    -0
      CSharp/BasicInputs/WellProfile/CCasingLinerChoke.i90
  4. +7
    -6
      CSharp/OperationScenarios/Common/COperationScenariosMain.f90
  5. +7
    -6
      CSharp/OperationScenarios/Common/COperationScenariosMain.i90
  6. +2
    -2
      CSharp/OperationScenarios/Common/OperationScenarios.f90
  7. +2
    -2
      CSharp/OperationScenarios/Common/OperationScenarios.i90
  8. +1
    -0
      CSharp/OperationScenarios/Enums/CTdsElevatorModesEnum.f90
  9. +332
    -0
      CSharp/OperationScenarios/Enums/CTdsElevatorModesEnum.i90
  10. +133
    -0
      CSharp/OperationScenarios/Notifications/CSlipsNotification.i90
  11. +1
    -0
      CSharp/OperationScenarios/Notifications/CSwingLedNotification.f90
  12. +122
    -0
      CSharp/OperationScenarios/Notifications/CSwingLedNotification.i90
  13. +2
    -2
      CSharp/OperationScenarios/Notifications/CTongNotification.f90
  14. +286
    -0
      CSharp/OperationScenarios/Notifications/CTongNotification.i90
  15. +1
    -0
      CSharp/OperationScenarios/Notifications/CUnlatchLedNotification.f90
  16. +216
    -0
      CSharp/OperationScenarios/Notifications/CUnlatchLedNotification.i90
  17. +86
    -0
      CSharp/OperationScenarios/Permissions/CIrSafetyValvePermission.i90
  18. +26
    -78
      CSharp/OperationScenarios/Unity/CUnityInputs.f90
  19. +469
    -0
      CSharp/OperationScenarios/Unity/CUnityInputs.i90
  20. +1
    -190
      CSharp/OperationScenarios/Unity/CUnityOutputs.f90
  21. +1
    -178
      CSharp/OperationScenarios/Unity/CUnityOutputs.i90
  22. +288
    -0
      CSharp/OperationScenarios/Unity/UnityModule.f90
  23. +277
    -0
      CSharp/OperationScenarios/Unity/UnityModule.i90
  24. +1
    -0
      CSharp/OperationScenarios/UnitySignals/CTdsSpineEnum.f90
  25. +3
    -2
      CSharp/OperationScenarios/UnitySignals/CTdsSpineEnum.i90
  26. +1
    -0
      CSharp/OperationScenarios/UnitySignals/UnitySignals.f90
  27. +1
    -0
      CSharp/OperationScenarios/UnitySignals/UnitySignals.i90
  28. +143
    -0
      CSharp/OperationScenarios/UnitySignals/UnitySignalsVariables.i90
  29. +159
    -0
      Common/DynamicLogicalArray.i90
  30. +2
    -1
      Equipments/BopStack/LOSS_INPUTS.f90
  31. +2
    -1
      Equipments/BopStack/LOSS_INPUTS.i90
  32. +2
    -4
      Equipments/MudSystem/Circulation_Code_Select.f90
  33. +147
    -0
      Equipments/MudSystem/Circulation_Code_Select.i90
  34. +1
    -3
      Equipments/MudSystem/Disconnecting_Pipe.f90
  35. +1
    -3
      Equipments/MudSystem/Disconnecting_Pipe.i90
  36. +1
    -2
      Equipments/MudSystem/MudSystem.f90
  37. +1
    -2
      Equipments/MudSystem/MudSystem.i90
  38. +1
    -2
      Equipments/MudSystem/MudSystemStartup.f90
  39. +1
    -2
      Equipments/MudSystem/MudSystemStartup.i90
  40. +1
    -4
      Equipments/RotaryTable/RTable_INPUTS.f90
  41. +1
    -4
      Equipments/RotaryTable/RTable_Inputs.i90
  42. +4
    -4
      Makefile
  43. +20
    -21
      Redis/Redis_Interface.f90
  44. +20
    -21
      Redis/Redis_Interface.i90
  45. +6
    -0
      Simulation/SimulationVariables.f90
  46. +6
    -0
      Simulation/SimulationVariables.i90
  47. 二进制
     
  48. +14
    -9
      SimulationCore2.f90
  49. +42
    -0
      SimulationCore2.i90
  50. +34
    -33
      Simulator.f90
  51. +34
    -33
      Simulator.i90
  52. +12
    -2
      Text1.txt
  53. +3
    -10
      TorqueDrag/TD_Forces/TD_HookLoadCalculation.f90
  54. +3
    -10
      TorqueDrag/TD_Forces/TD_HookLoadCalculation.i90
  55. +3
    -1
      config-remote.json
  56. +34
    -42
      helper.ipynb
  57. +0
    -1
      redisContent.json
  58. +75
    -0
      simulatorManager.py

+ 1
- 1
.vscode/launch.json 查看文件

@@ -30,7 +30,7 @@
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/SimulationCore2",
"args": ["Config-local.json"],
"args": ["aberama.iran.liara.ir","32815","4YKFnubfFFjfh4yTK7b0Rg9X","test","5"],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"externalConsole": false,


+ 1
- 1
CSharp/BasicInputs/WellProfile/CCasingLinerChoke.f90 查看文件

@@ -40,7 +40,7 @@ module CCasingLinerChoke
use json_module,IK =>json_ik
type(json_value),pointer :: parent
type(json_core) :: json
type(json_value),pointer :: p,pitems,pitem,pval,pbit
type(json_value),pointer :: p,pitem
call json%get(parent,'CasingLinerChoke',p)


+ 82
- 0
CSharp/BasicInputs/WellProfile/CCasingLinerChoke.i90 查看文件

@@ -0,0 +1,82 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/BasicInputs/WellProfile/CCasingLinerChoke.f90"
module CCasingLinerChoke
use SimulationVariables
use json_module
implicit none
public
contains
subroutine CasingLinerChokeToJson(parent)

type(json_value),pointer :: parent
type(json_core) :: json
type(json_value),pointer :: p

! 1. create new node
call json%create_object(p,'CasingLinerChoke')
! 2. add member of data type to new node
! call StringConfigurationToJson(p)
! call FormationToJson(p)
call json%add(p,"CasingDepth",data%Configuration%CasingLinerChoke%CasingDepth)
call json%add(p,"CasingId",data%Configuration%CasingLinerChoke%CasingId)
call json%add(p,"CasingOd",data%Configuration%CasingLinerChoke%CasingOd)
call json%add(p,"CasingWeight",data%Configuration%CasingLinerChoke%CasingWeight)
call json%add(p,"CasingCollapsePressure",data%Configuration%CasingLinerChoke%CasingCollapsePressure)
call json%add(p,"CasingTensileStrength",data%Configuration%CasingLinerChoke%CasingTensileStrength)
call json%add(p,"LinerTopDepth",data%Configuration%CasingLinerChoke%LinerTopDepth)
call json%add(p,"LinerLength",data%Configuration%CasingLinerChoke%LinerLength)
call json%add(p,"LinerId",data%Configuration%CasingLinerChoke%LinerId)
call json%add(p,"LinerOd",data%Configuration%CasingLinerChoke%LinerOd)
call json%add(p,"LinerWeight",data%Configuration%CasingLinerChoke%LinerWeight)
call json%add(p,"LinerCollapsePressure",data%Configuration%CasingLinerChoke%LinerCollapsePressure)
call json%add(p,"LinerTensileStrength",data%Configuration%CasingLinerChoke%LinerTensileStrength)
call json%add(p,"OpenHoleId",data%Configuration%CasingLinerChoke%OpenHoleId)
call json%add(p,"OpenHoleLength",data%Configuration%CasingLinerChoke%OpenHoleLength)
! 3. add new node to parent
call json%add(parent,p)
end subroutine

subroutine CasingLinerChokeFromJson(parent)
use json_module,IK =>json_ik
type(json_value),pointer :: parent
type(json_core) :: json
type(json_value),pointer :: p,pitem

call json%get(parent,'CasingLinerChoke',p)

call json%get(p,"CasingDepth",pitem)
call json%get(pitem,data%Configuration%CasingLinerChoke%CasingDepth)
call json%get(p,"CasingId",pitem)
call json%get(pitem,data%Configuration%CasingLinerChoke%CasingId)
call json%get(p,"CasingOd",pitem)
call json%get(pitem,data%Configuration%CasingLinerChoke%CasingOd)
call json%get(p,"CasingWeight",pitem)
call json%get(pitem,data%Configuration%CasingLinerChoke%CasingWeight)
call json%get(p,"CasingCollapsePressure",pitem)
call json%get(pitem,data%Configuration%CasingLinerChoke%CasingCollapsePressure)
call json%get(p,"CasingTensileStrength",pitem)
call json%get(pitem,data%Configuration%CasingLinerChoke%CasingTensileStrength)
call json%get(p,"LinerTopDepth",pitem)
call json%get(pitem,data%Configuration%CasingLinerChoke%LinerTopDepth)
call json%get(p,"LinerLength",pitem)
call json%get(pitem,data%Configuration%CasingLinerChoke%LinerLength)
call json%get(p,"LinerId",pitem)
call json%get(pitem,data%Configuration%CasingLinerChoke%LinerId)
call json%get(p,"LinerOd",pitem)
call json%get(pitem,data%Configuration%CasingLinerChoke%LinerOd)
call json%get(p,"LinerWeight",pitem)
call json%get(pitem,data%Configuration%CasingLinerChoke%LinerWeight)
call json%get(p,"LinerCollapsePressure",pitem)
call json%get(pitem,data%Configuration%CasingLinerChoke%LinerCollapsePressure)
call json%get(p,"LinerTensileStrength",pitem)
call json%get(pitem,data%Configuration%CasingLinerChoke%LinerTensileStrength)
call json%get(p,"OpenHoleId",pitem)
call json%get(pitem,data%Configuration%CasingLinerChoke%OpenHoleId)
call json%get(p,"OpenHoleLength",pitem)
call json%get(pitem,data%Configuration%CasingLinerChoke%OpenHoleLength)

end subroutine


end module CCasingLinerChoke

+ 7
- 6
CSharp/OperationScenarios/Common/COperationScenariosMain.f90 查看文件

@@ -36,14 +36,15 @@ module COperationScenariosMain
! use CStandRack
! use CStringPressure
! use CZeroStringSpeed
use CUnityInputs, only: &
Get_ElevatorConnectionPossible, &
Get_JointConnectionPossible, &
Get_ElevatorPickup, &
Get_NearFloorPosition, &
Get_SingleSetInMouseHole
! use CUnityInputs, only: &
! Get_ElevatorConnectionPossible, &
! Get_JointConnectionPossible, &
! Get_ElevatorPickup, &
! Get_NearFloorPosition, &
! Get_SingleSetInMouseHole
! use CBucketEnum
! use UnitySignalsModule
use UnityModule
use CElevatorEnum
! use CHeadEnum
use CIbopEnum


+ 7
- 6
CSharp/OperationScenarios/Common/COperationScenariosMain.i90 查看文件

@@ -37,14 +37,15 @@ module COperationScenariosMain
! use CStandRack
! use CStringPressure
! use CZeroStringSpeed
use CUnityInputs, only: &
Get_ElevatorConnectionPossible, &
Get_JointConnectionPossible, &
Get_ElevatorPickup, &
Get_NearFloorPosition, &
Get_SingleSetInMouseHole
! use CUnityInputs, only: &
! Get_ElevatorConnectionPossible, &
! Get_JointConnectionPossible, &
! Get_ElevatorPickup, &
! Get_NearFloorPosition, &
! Get_SingleSetInMouseHole
! use CBucketEnum
! use UnitySignalsModule
use UnityModule
use CElevatorEnum
! use CHeadEnum
use CIbopEnum


+ 2
- 2
CSharp/OperationScenarios/Common/OperationScenarios.f90 查看文件

@@ -8,8 +8,8 @@ module OperationScenariosModule
use SimulationVariables
use PermissionsModule
! use SoftwareInputsVariables
use CUnityInputs
use CUnityOutputs, only: GetRotaryRpm
! use CUnityInputs
use UnityModule
use UnitySignalVariables
use UnitySignalsModule
use PermissionsModule


+ 2
- 2
CSharp/OperationScenarios/Common/OperationScenarios.i90 查看文件

@@ -9,8 +9,8 @@ module OperationScenariosModule
use SimulationVariables
use PermissionsModule
! use SoftwareInputsVariables
use CUnityInputs
use CUnityOutputs, only: GetRotaryRpm
! use CUnityInputs
use UnityModule
use UnitySignalVariables
use UnitySignalsModule
use PermissionsModule


+ 1
- 0
CSharp/OperationScenarios/Enums/CTdsElevatorModesEnum.f90 查看文件

@@ -1,5 +1,6 @@
module CTdsElevatorModesEnum
use OperationScenariosModule
use UnityModule
implicit none
contains


+ 332
- 0
CSharp/OperationScenarios/Enums/CTdsElevatorModesEnum.i90 查看文件

@@ -0,0 +1,332 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/OperationScenarios/Enums/CTdsElevatorModesEnum.f90"
module CTdsElevatorModesEnum
use OperationScenariosModule
use UnityModule
implicit none
contains
subroutine Evaluate_TdsElevatorModes()
use CCommon, only: SetStandRack
implicit none
if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
# 14



!TOPDRIVE-CODE=7
if (Get_Elevator() == ELEVATOR_LATCH_STRING_END .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_NOTHING .and.&
Get_TdsSwing() == TDS_SWING_OFF_END ) then
call Set_TdsElevatorModes(TDS_ELEVATOR_LATCH_STRING)
call Set_Elevator(ELEVATOR_NEUTRAL)
return
end if
!TOPDRIVE-CODE=8
if (Get_HookHeight() <= (TL() + TJH() - data%State%OperationScenario%ECG) .and.&
Get_ElevatorPickup() == .false. .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STRING) then
call Set_TdsElevatorModes(TDS_ELEVATOR_LATCH_STRING)
return
end if


!TOPDRIVE-CODE=9
if (Get_ElevatorPickup() .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_STRING) then
call Set_TdsElevatorModes(TDS_ELEVATOR_CONNECTION_STRING)
return
end if
!TOPDRIVE-CODE=10
if (Get_Elevator() == ELEVATOR_UNLATCH_STRING_END .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_STRING) then
call Set_TdsElevatorModes(TDS_ELEVATOR_CONNECTION_NOTHING)
call Set_Elevator(ELEVATOR_NEUTRAL)
return
end if
!TOPDRIVE-CODE=11
if (Get_Elevator() == ELEVATOR_UNLATCH_STRING_END .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_STRING .and.&
Get_TdsConnectionModes() == TDS_CONNECTION_STRING) then
call Set_TdsElevatorModes(TDS_ELEVATOR_CONNECTION_NOTHING)
call Set_Elevator(ELEVATOR_NEUTRAL)
return
end if
!TOPDRIVE-CODE=12
if (Get_Elevator() == ELEVATOR_LATCH_STAND_END .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_NOTHING) then
call Set_TdsElevatorModes(TDS_ELEVATOR_CONNECTION_STAND)
call Set_Elevator(ELEVATOR_NEUTRAL)
call SetStandRack(Get_StandRack() - 1)
return
end if
!TOPDRIVE-CODE=13
if (Get_Elevator() == ELEVATOR_UNLATCH_STAND_END .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STAND) then
call Set_TdsElevatorModes(TDS_ELEVATOR_CONNECTION_NOTHING)
call Set_Elevator(ELEVATOR_NEUTRAL)
call SetStandRack(Get_StandRack() + 1)
return
end if
!TOPDRIVE-CODE=14
if (Get_Elevator() == ELEVATOR_LATCH_SINGLE_END .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_NOTHING .and.&
Get_TdsSwing() == TDS_SWING_TILT_END .and.&
Get_FillMouseHoleLed()) then
call Set_TdsElevatorModes(TDS_ELEVATOR_CONNECTION_SINGLE)
call Set_Elevator(ELEVATOR_NEUTRAL)
call Set_UnlatchLed(.true.)
call Set_FillMouseHoleLed(.false.)
call Set_MouseHole(MOUSE_HOLE_NEUTRAL)
return
end if
!TOPDRIVE-CODE=15
if (Get_Elevator() == ELEVATOR_UNLATCH_SINGLE_END .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_SINGLE .and.&
Get_TdsSwing() == TDS_SWING_TILT_END .and.&
Get_FillMouseHoleLed() == .false.) then
call Set_TdsElevatorModes(TDS_ELEVATOR_CONNECTION_NOTHING)
call Set_Elevator(ELEVATOR_NEUTRAL)
call Set_UnlatchLed(.false.)
call Set_FillMouseHoleLed(.true.)
call Set_MouseHole(MOUSE_HOLE_NEUTRAL)
return
end if
!TOPDRIVE-CODE=16
if (Get_HookHeight() <= (TL() + NFC() + data%State%OperationScenario%PL - data%State%OperationScenario%ECG) .and.&
Get_Tong() == TONG_BREAKOUT_END .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_STRING .and.&
Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING) then
call Set_TdsElevatorModes(TDS_ELEVATOR_LATCH_SINGLE)
call Set_Tong(TONG_NEUTRAL)
call Set_StringUpdate(STRING_UPDATE_REMOVE_SINGLE)
return
end if
!TOPDRIVE-CODE=17
if (Get_HookHeight() <= (TL() + NFC() + data%State%OperationScenario%PL - data%State%OperationScenario%ECG) .and.&
Get_Tong() == TONG_BREAKOUT_END .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STRING .and.&
Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING) then
call Set_TdsElevatorModes(TDS_ELEVATOR_CONNECTION_SINGLE)
call Set_Tong(TONG_NEUTRAL)
call Set_StringUpdate(STRING_UPDATE_REMOVE_SINGLE)
return
end if
!TOPDRIVE-CODE=18
if (Get_ElevatorPickup() .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_SINGLE) then
call Set_TdsElevatorModes(TDS_ELEVATOR_CONNECTION_SINGLE)
return
end if
!TOPDRIVE-CODE=19
if (Get_HookHeight() <= (TL() + NFC() + data%State%OperationScenario%PL - data%State%OperationScenario%ECG) .and.&
Get_ElevatorPickup() == .false. .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_SINGLE) then
call Set_TdsElevatorModes(TDS_ELEVATOR_LATCH_SINGLE)
return
end if
!TOPDRIVE-CODE=20
if (Get_Tong() == TONG_MAKEUP_END .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_SINGLE) then
call Set_TdsElevatorModes(TDS_ELEVATOR_CONNECTION_STRING)
call Set_Tong(TONG_NEUTRAL)
call Set_StringUpdate(STRING_UPDATE_ADD_SINGLE)
return
end if
!TOPDRIVE-CODE=21
if (Get_Tong() == TONG_MAKEUP_END .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_SINGLE) then
call Set_TdsElevatorModes(TDS_ELEVATOR_LATCH_STRING)
call Set_Tong(TONG_NEUTRAL)
call Set_StringUpdate(STRING_UPDATE_ADD_SINGLE)
return
end if
!TOPDRIVE-CODE=22
if (Get_HookHeight() <= (TL() + NFC() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG) .and.&
Get_Tong() == TONG_BREAKOUT_END .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_STRING .and.&
Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING) then
call Set_TdsElevatorModes(TDS_ELEVATOR_LATCH_STAND)
call Set_Tong(TONG_NEUTRAL)
call Set_StringUpdate(STRING_UPDATE_REMOVE_STAND)
return
end if
!TOPDRIVE-CODE=23
if (Get_HookHeight() <= (TL() + NFC() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG) .and.&
Get_Tong() == TONG_BREAKOUT_END .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STRING .and.&
Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING) then
call Set_TdsElevatorModes(TDS_ELEVATOR_CONNECTION_STAND)
call Set_Tong(TONG_NEUTRAL)
call Set_StringUpdate(STRING_UPDATE_REMOVE_STAND)
return
end if
!TOPDRIVE-CODE=24
if (Get_ElevatorPickup() .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_STAND) then
call Set_TdsElevatorModes(TDS_ELEVATOR_CONNECTION_STAND)
return
end if
!TOPDRIVE-CODE=25
if (Get_HookHeight() <= (TL() + NFC() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG) .and.&
Get_ElevatorPickup() == .false. .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STAND) then
call Set_TdsElevatorModes(TDS_ELEVATOR_LATCH_STAND)
return
end if
!TOPDRIVE-CODE=26
if (Get_Tong() == TONG_MAKEUP_END .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STAND) then
call Set_TdsElevatorModes(TDS_ELEVATOR_CONNECTION_STRING)
call Set_Tong(TONG_NEUTRAL)
call Set_StringUpdate(STRING_UPDATE_ADD_STAND)
return
end if
!TOPDRIVE-CODE=27
if (Get_Tong() == TONG_MAKEUP_END .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_STAND) then
call Set_TdsElevatorModes(TDS_ELEVATOR_LATCH_STRING)
call Set_Tong(TONG_NEUTRAL)
call Set_StringUpdate(STRING_UPDATE_ADD_STAND)
return
end if

endif
if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
# 318

endif
end subroutine
subroutine Subscribe_TdsElevatorModes()
use CDrillingConsoleVariables
use SimulationVariables
use SimulationVariables
implicit none
end subroutine
end module CTdsElevatorModesEnum

+ 133
- 0
CSharp/OperationScenarios/Notifications/CSlipsNotification.i90 查看文件

@@ -0,0 +1,133 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/OperationScenarios/Notifications/CSlipsNotification.f90"
module CSlipsNotification
use OperationScenariosModule
implicit none
contains
subroutine Evaluate_SlipsNotification()
implicit none
if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
# 15

!TOPDRIVE-CODE=28
if (Get_ZeroStringSpeed() .and.&
GetRotaryRpm() == 0.0d0 .and.&
Get_Slips() == SLIPS_UNSET_END .and.&
Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 6.0) then
call Set_SlipsNotification(.true.)
return
end if
!TOPDRIVE-CODE=29
if (Get_ZeroStringSpeed() .and.&
GetRotaryRpm() == 0.0d0 .and.&
(Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STRING .or.&
Get_TdsConnectionModes() == TDS_CONNECTION_STRING) .and.&
Get_Slips() == SLIPS_SET_END .and.&
Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 6.0) then
call Set_SlipsNotification(.true.)
return
end if

endif
if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
# 58


!OPERATION-CODE=53
if (Get_ZeroStringSpeed() .and.&
GetRotaryRpm() == 0.0d0 .and.&
!Get_KellyConnection() == KELLY_CONNECTION_STRING
Get_Slips() == SLIPS_UNSET_END .and.&
Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 6.0) then
call Set_SlipsNotification(.true.)
return
end if
!OPERATION-CODE=77
if (Get_ZeroStringSpeed() .and.&
GetRotaryRpm() == 0.0d0 .and.&
Get_Slips() == SLIPS_SET_END .and.&
Get_IsKellyBushingSetInTable() == .false. .and.&
Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 6.0 .and.&
(Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING .or. Get_KellyConnection() == KELLY_CONNECTION_STRING)) then
call Set_SlipsNotification(.true.)
return
end if
!if (Get_OperationCondition() == OPERATION_DRILL .and.&
! Get_ZeroStringSpeed() .and.&
! Get_SlackOff() .and.&
! Get_KellyConnection() == KELLY_CONNECTION_STRING) then
! call Set_SlipsNotification(.true.)
! return
!end if
!
!
!if (Get_OperationCondition() == OPERATION_TRIP .and.&
! Get_ZeroStringSpeed() .and.&
! Get_NearFloorConnection() >= 21 .and. Get_NearFloorConnection() <= 25 .and.&
! Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING) then
! call Set_SlipsNotification(.true.)
! return
!end if
call Set_SlipsNotification(.false.)

endif
end subroutine
! subroutine Subscribe_SlipsNotification()
! implicit none
! call OnOperationConditionChange%Add(Evaluate_SlipsNotification)
! call OnSlackOffChange%Add(Evaluate_SlipsNotification)
! call OnZeroStringSpeedChange%Add(Evaluate_SlipsNotification)
! call OnNearFloorConnectionChange%Add(Evaluate_SlipsNotification)
! call data%State%OperationScenario%OnElevatorConnectionChange%Add(Evaluate_SlipsNotification)
! call OnKellyConnectionChange%Add(Evaluate_SlipsNotification)
! call OnSlipsChange%Add(Evaluate_SlipsNotification)
! end subroutine
end module CSlipsNotification

+ 1
- 0
CSharp/OperationScenarios/Notifications/CSwingLedNotification.f90 查看文件

@@ -1,5 +1,6 @@
module CSwingLedNotification
use OperationScenariosModule
use UnityModule
implicit none
contains


+ 122
- 0
CSharp/OperationScenarios/Notifications/CSwingLedNotification.i90 查看文件

@@ -0,0 +1,122 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/OperationScenarios/Notifications/CSwingLedNotification.f90"
module CSwingLedNotification
use OperationScenariosModule
use UnityModule
implicit none
contains
subroutine Evaluate_SwingLed()
implicit none
if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
# 17




endif
if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
# 34



!OPERATION-CODE=22
if (Get_OperationCondition() == OPERATION_TRIP .and.&
Get_HookHeight() >= (data%State%OperationScenario%HL + Get_NearFloorConnection()) .and. Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%LG) .and.&
Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING .and.&
Get_JointConnectionPossible() == .false. .and.&
(Get_Swing() /= SWING_WELL_BEGIN .and.&
Get_Swing() /= SWING_MOUSE_HOLE_BEGIN .and.&
Get_Swing() /= SWING_RAT_HOLE_BEGIN) .and.&
Get_Slips() == SLIPS_SET_END) then
call Set_SwingLed(.true.)
return
end if
!OPERATION-CODE=23
if (Get_OperationCondition() == OPERATION_TRIP .and.&
Get_HookHeight() >= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%PL) .and. Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%LG + data%State%OperationScenario%PL) .and.&
Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE .and.&
Get_JointConnectionPossible() == .false. .and.&
(Get_Swing() /= SWING_WELL_BEGIN .and.&
Get_Swing() /= SWING_MOUSE_HOLE_BEGIN .and.&
Get_Swing() /= SWING_RAT_HOLE_BEGIN) .and.&
Get_Slips() == SLIPS_SET_END) then
call Set_SwingLed(.true.)
return
end if
!OPERATION-CODE=24
if (Get_OperationCondition() == OPERATION_DRILL .and.&
Get_HookHeight() >= (data%State%OperationScenario%HKL + Get_NearFloorConnection()) .and. Get_HookHeight() <= (data%State%OperationScenario%HKL + Get_NearFloorConnection() + data%State%OperationScenario%LG) .and.&
Get_JointConnectionPossible() == .false. .and.&
Get_KellyConnection() == KELLY_CONNECTION_NOTHING .and.&
(Get_Swing() /= SWING_WELL_BEGIN .and.&
Get_Swing() /= SWING_MOUSE_HOLE_BEGIN .and.&
Get_Swing() /= SWING_RAT_HOLE_BEGIN) .and.&
Get_Slips() == SLIPS_SET_END) then
call Set_SwingLed(.true.)
return
end if
!OPERATION-CODE=25
if (Get_OperationCondition() == OPERATION_DRILL .and.&
Get_HookHeight() >= (data%State%OperationScenario%HKL + Get_NearFloorConnection() + data%State%OperationScenario%PL) .and. Get_HookHeight() <= (data%State%OperationScenario%HKL + Get_NearFloorConnection() + data%State%OperationScenario%LG + data%State%OperationScenario%PL) .and.&
Get_KellyConnection() == KELLY_CONNECTION_SINGLE .and.&
Get_JointConnectionPossible() == .false. .and.&
(Get_Swing() /= SWING_WELL_BEGIN .and.&
Get_Swing() /= SWING_MOUSE_HOLE_BEGIN .and.&
Get_Swing() /= SWING_RAT_HOLE_BEGIN) .and.&
Get_Slips() == SLIPS_SET_END) then
call Set_SwingLed(.true.)
return
end if
call Set_SwingLed(.false.)
endif
end subroutine
! subroutine Subscribe_SwingLed()
! implicit none
! call OnOperationConditionChange%Add(Evaluate_SwingLed)
! call OnHookHeightChange%Add(Evaluate_SwingLed)
! call OnElevatorConnectionChange%Add(Evaluate_SwingLed)
! call OnKellyConnectionChange%Add(Evaluate_SwingLed)
! call OnSwingChange%Add(Evaluate_SwingLed)
! call OnSlipsChange%Add(Evaluate_SwingLed)
! call OnFillMouseHoleLedChange%Add(Evaluate_SwingLed)
! end subroutine
end module CSwingLedNotification

+ 2
- 2
CSharp/OperationScenarios/Notifications/CTongNotification.f90 查看文件

@@ -273,8 +273,8 @@ module CTongNotification
! call data%State%unitySignals%OnOperationConditionChange%Add(Evaluate_TongNotification)
! ! call softwareInputs%OnHookHeightChange%Add(Evaluate_TongNotification)
! call UnityInputs%OnJointConnectionPossibleChange%Add(Evaluate_TongNotification)
! call UnityInputs%OnSingleSetInMouseHoleChange%Add(Evaluate_TongNotification)
! call data%Equipments%UnityInputs%OnJointConnectionPossibleChange%Add(Evaluate_TongNotification)
! call data%Equipments%UnityInputs%OnSingleSetInMouseHoleChange%Add(Evaluate_TongNotification)
! call data%State%OperationScenario%OnElevatorConnectionChange%Add(Evaluate_TongNotification)
! call KellyConnectionEnum%OnKellyConnectionChange%Add(Evaluate_TongNotification)
! call data%State%unitySignals%OnSwingChange%Add(Evaluate_TongNotification)


+ 286
- 0
CSharp/OperationScenarios/Notifications/CTongNotification.i90 查看文件

@@ -0,0 +1,286 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/OperationScenarios/Notifications/CTongNotification.f90"
module CTongNotification
use OperationScenariosModule
implicit none
contains
subroutine Evaluate_TongNotification()
implicit none
if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
# 16




!TOPDRIVE-CODE=50
if (((Get_HookHeight() >= (TL() + data%State%OperationScenario%PL - data%State%OperationScenario%ECG + NFC() - data%State%OperationScenario%RE) .and. Get_HookHeight() <= (TL() + NFC() + data%State%OperationScenario%PL - data%State%OperationScenario%ECG + data%State%OperationScenario%TG)) .or.&
(Get_HookHeight() >= (TL() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + NFC() - data%State%OperationScenario%RE) .and. Get_HookHeight() <= (TL() + NFC() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + data%State%OperationScenario%TG))).and.&
GetRotaryRpm() == 0.0d0 .and.&
Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 6.0 .and.&
((Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
Get_Tong() /= TONG_MAKEUP_BEGIN) .or.&
Get_Tong() == TONG_NEUTRAL ) .and.&
(Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_STRING .or. Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STRING) .and.&
Get_TdsSwing() == TDS_SWING_OFF_END .and.&
Get_Slips() == SLIPS_SET_END) then
call Set_TongNotification(.true.)
return
end if





!TOPDRIVE-CODE=51
if (GetRotaryRpm() == 0.0d0 .and.&
Get_JointConnectionPossible() .and.&
(Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
(Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_SINGLE .or. Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_SINGLE) .and.&
Get_TdsSwing() == TDS_SWING_OFF_END .and.&
Get_Slips() == SLIPS_SET_END) then
call Set_TongNotification(.true.)
return
end if


!TOPDRIVE-CODE=52
if (GetRotaryRpm() == 0.0d0 .and.&
Get_JointConnectionPossible() .and.&
(Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
(Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_STAND .or. Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STAND) .and.&
Get_TdsSwing() == TDS_SWING_OFF_END .and.&
Get_Slips() == SLIPS_SET_END) then
call Set_TongNotification(.true.)
return
end if





endif
if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
# 92


!OPERATION-CODE=44
if (Get_OperationCondition() == OPERATION_DRILL .and.&
!((Get_HookHeight() >= 65.0 .and. Get_HookHeight() <= 70.0) .or.&
! (Get_HookHeight() >= 96.0 .and. Get_HookHeight() <= 101.0)).and.&
((Get_HookHeight() >= (data%State%OperationScenario%HKL + Get_NearFloorConnection() - data%State%OperationScenario%RE) .and. Get_HookHeight() <= (data%State%OperationScenario%HKL + Get_NearFloorConnection() + data%State%OperationScenario%TG)) .or.&
(Get_HookHeight() >= (data%State%OperationScenario%HKL + Get_NearFloorConnection() + data%State%OperationScenario%PL -data%State%OperationScenario%RE) .and. Get_HookHeight() <= (data%State%OperationScenario%HKL + Get_NearFloorConnection() + data%State%OperationScenario%TG + data%State%OperationScenario%PL))).and.&
GetRotaryRpm() == 0.0d0 .and.&
Get_KellyConnection() == KELLY_CONNECTION_STRING .and.&
Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 6.0 .and.&
Get_Swing() == SWING_WELL_END .and.&
(Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
Get_Slips() == SLIPS_SET_END) then
call Set_TongNotification(.true.)
return
end if
!OPERATION-CODE=45
if (Get_OperationCondition() == OPERATION_DRILL .and.&
Get_HookHeight() >= 66 .and. Get_HookHeight() <= 69 .and.&
Get_KellyConnection() == KELLY_CONNECTION_SINGLE .and.&
(Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
Get_Swing() == SWING_MOUSE_HOLE_END) then
call Set_TongNotification(.true.)
return
end if
!OPERATION-CODE=46
if (Get_OperationCondition() == OPERATION_DRILL .and.&
Get_JointConnectionPossible() .and.&
Get_KellyConnection() == KELLY_CONNECTION_NOTHING .and.&
(Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
Get_Swing() == SWING_MOUSE_HOLE_END) then
call Set_TongNotification(.true.)
return
end if
!OPERATION-CODE=47
if (Get_OperationCondition() == OPERATION_DRILL .and.&
GetRotaryRpm() == 0.0d0 .and.&
Get_JointConnectionPossible() .and.&
Get_KellyConnection() == KELLY_CONNECTION_NOTHING .and.&
(Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
Get_Swing() == SWING_WELL_END .and.&
Get_Slips() == SLIPS_SET_END) then
call Set_TongNotification(.true.)
return
end if
!OPERATION-CODE=48
if (Get_OperationCondition() == OPERATION_DRILL .and.&
GetRotaryRpm() == 0.0d0 .and.&
Get_JointConnectionPossible() .and.&
Get_KellyConnection() == KELLY_CONNECTION_SINGLE .and.&
(Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
Get_Swing() == SWING_WELL_END .and.&
Get_Slips() == SLIPS_SET_END) then
call Set_TongNotification(.true.)
return
end if
!OPERATION-CODE=50
if (Get_OperationCondition() == OPERATION_TRIP .and.&
((Get_HookHeight() >= (data%State%OperationScenario%HL + data%State%OperationScenario%PL - data%State%OperationScenario%ECG + Get_NearFloorConnection() - data%State%OperationScenario%RE) .and. Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%PL - data%State%OperationScenario%ECG + data%State%OperationScenario%TG)) .or.&
(Get_HookHeight() >= (data%State%OperationScenario%HL + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + Get_NearFloorConnection() - data%State%OperationScenario%RE) .and. Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%TG - data%State%OperationScenario%ECG + data%State%OperationScenario%SL))).and.&
Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 6.0 .and.&
GetRotaryRpm() == 0.0d0 .and.&
Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING .and.&
(Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
Get_Swing() == SWING_WELL_END .and.&
Get_Slips() == SLIPS_SET_END) then
call Set_TongNotification(.true.)
return
end if
!OPERATION-CODE=51
if (Get_OperationCondition() == OPERATION_TRIP .and.&
GetRotaryRpm() == 0.0d0 .and.&
Get_JointConnectionPossible() .and.&
Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE .and.&
(Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
Get_Swing() == SWING_WELL_END .and.&
Get_Slips() == SLIPS_SET_END) then
call Set_TongNotification(.true.)
return
end if
!OPERATION-CODE=52
if (Get_OperationCondition() == OPERATION_TRIP .and.&
GetRotaryRpm() == 0.0d0 .and.&
Get_JointConnectionPossible() .and.&
Get_ElevatorConnection() == ELEVATOR_CONNECTION_STAND .and.&
(Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
Get_Swing() == SWING_WELL_END .and.&
Get_Slips() == SLIPS_SET_END) then
call Set_TongNotification(.true.)
return
end if
!if (Get_OperationCondition() == OPERATION_DRILL .and.&
! Get_KellyConnection() == KELLY_CONNECTION_STRING .and.&
! Get_Swing() == SWING_WELL_END .and.&
! Get_Slips() == SLIPS_SET_END) then
!
! call Set_TongNotification(.true.)
! return
!end if
!
call Set_TongNotification(.false.)

endif
end subroutine
! subroutine Subscribe_TongNotification()
! implicit none
! call data%State%unitySignals%OnOperationConditionChange%Add(Evaluate_TongNotification)
! ! call softwareInputs%OnHookHeightChange%Add(Evaluate_TongNotification)
! call data%Equipments%UnityInputs%OnJointConnectionPossibleChange%Add(Evaluate_TongNotification)
! call data%Equipments%UnityInputs%OnSingleSetInMouseHoleChange%Add(Evaluate_TongNotification)
! call data%State%OperationScenario%OnElevatorConnectionChange%Add(Evaluate_TongNotification)
! call KellyConnectionEnum%OnKellyConnectionChange%Add(Evaluate_TongNotification)
! call data%State%unitySignals%OnSwingChange%Add(Evaluate_TongNotification)
! call data%State%unitySignals%OnSlipsChange%Add(Evaluate_TongNotification)
! end subroutine
end module CTongNotification

+ 1
- 0
CSharp/OperationScenarios/Notifications/CUnlatchLedNotification.f90 查看文件

@@ -1,5 +1,6 @@
module CUnlatchLedNotification
use OperationScenariosModule
use UnityModule
use CLog4
implicit none
contains


+ 216
- 0
CSharp/OperationScenarios/Notifications/CUnlatchLedNotification.i90 查看文件

@@ -0,0 +1,216 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/OperationScenarios/Notifications/CUnlatchLedNotification.f90"
module CUnlatchLedNotification
use OperationScenariosModule
use UnityModule
use CLog4
implicit none
contains
subroutine Evaluate_UnlatchLed()
use CCommon
implicit none
if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
# 16




!TOPDRIVE-CODE=47
if (Get_HookHeight() <= (TL() + NFC() - data%State%OperationScenario%ECG) .and.&
Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 6.0 .and.&
(Get_Elevator() /= ELEVATOR_LATCH_STRING_BEGIN .and.&
Get_Elevator() /= ELEVATOR_UNLATCH_STRING_BEGIN .and.&
Get_Elevator() /= ELEVATOR_LATCH_STAND_BEGIN .and.&
Get_Elevator() /= ELEVATOR_UNLATCH_STAND_BEGIN .and.&
Get_Elevator() /= ELEVATOR_LATCH_SINGLE_BEGIN .and.&
Get_Elevator() /= ELEVATOR_UNLATCH_SINGLE_BEGIN) .and.&
Get_ElevatorPickup() == .false. .and.&
(Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_STRING .or. Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STRING) .and.&
Get_TdsSwing() == TDS_SWING_OFF_END .and.&
Get_Slips() == SLIPS_SET_END) then
call Set_UnlatchLed(.true.)
return
end if




!TOPDRIVE-CODE=48
if ((Get_HookHeight() >= (TL() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + NFC()) .and. Get_HookHeight() <= (TL() + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + NFC() + data%State%OperationScenario%TG)) .and.&
GetStandRack() > 80 .and.&
Get_JointConnectionPossible() == .false. .and.&
(Get_Elevator() /= ELEVATOR_LATCH_STRING_BEGIN .and.&
Get_Elevator() /= ELEVATOR_UNLATCH_STRING_BEGIN .and.&
Get_Elevator() /= ELEVATOR_LATCH_STAND_BEGIN .and.&
Get_Elevator() /= ELEVATOR_UNLATCH_STAND_BEGIN .and.&
Get_Elevator() /= ELEVATOR_LATCH_SINGLE_BEGIN .and.&
Get_Elevator() /= ELEVATOR_UNLATCH_SINGLE_BEGIN) .and.&
Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STAND .and.&
Get_TdsSwing() == TDS_SWING_OFF_END .and.&
Get_Slips() == SLIPS_SET_END) then
call Set_UnlatchLed(.true.)
return
end if






!TOPDRIVE-CODE=49
if ((Get_HookHeight() >= TL() .and. Get_HookHeight() <= (TL() + NFC() + data%State%OperationScenario%SG)) .and.&
(Get_Elevator() /= ELEVATOR_LATCH_STRING_BEGIN .and.&
Get_Elevator() /= ELEVATOR_UNLATCH_STRING_BEGIN .and.&
Get_Elevator() /= ELEVATOR_LATCH_STAND_BEGIN .and.&
Get_Elevator() /= ELEVATOR_UNLATCH_STAND_BEGIN .and.&
Get_Elevator() /= ELEVATOR_LATCH_SINGLE_BEGIN .and.&
Get_Elevator() /= ELEVATOR_UNLATCH_SINGLE_BEGIN) .and.&
(Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STRING .or. Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_SINGLE) .and.&
Get_TdsSwing() == TDS_SWING_TILT_END .and.&
Get_FillMouseHoleLed() == .false.) then
call Set_UnlatchLed(.true.)
return
end if








endif
if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
# 99




!OPERATION-CODE=40
if (Get_OperationCondition() == OPERATION_TRIP .and.&
Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() - data%State%OperationScenario%ECG) .and.&
Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 6.0 .and.&
(Get_Elevator() /= ELEVATOR_LATCH_STRING_BEGIN .and.&
Get_Elevator() /= ELEVATOR_UNLATCH_STRING_BEGIN .and.&
Get_Elevator() /= ELEVATOR_LATCH_STAND_BEGIN .and.&
Get_Elevator() /= ELEVATOR_UNLATCH_STAND_BEGIN .and.&
Get_Elevator() /= ELEVATOR_LATCH_SINGLE_BEGIN .and.&
Get_Elevator() /= ELEVATOR_UNLATCH_SINGLE_BEGIN) .and.&
!Get_Elevator() == ELEVATOR_LATCH_STRING_END .and.&
(Get_ElevatorConnection() == ELEVATOR_LATCH_STRING) .and.&
!(Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING .or. Get_ElevatorConnection() == ELEVATOR_LATCH_STRING) .and.&
!Get_LatchLed() == .false.
Get_Swing() == SWING_WELL_END .and.&
Get_Slips() == SLIPS_SET_END ) then
call Set_UnlatchLed(.true.)
!call Set_LatchLed(.false.)
return
end if
!OPERATION-CODE=41
if (Get_OperationCondition() == OPERATION_TRIP .and.&
Get_HookHeight() >= (data%State%OperationScenario%HL + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + Get_NearFloorConnection()) .and. Get_HookHeight() <= (data%State%OperationScenario%HL + data%State%OperationScenario%SL - data%State%OperationScenario%ECG + Get_NearFloorConnection() + data%State%OperationScenario%LG) .and.&
!Get_HookHeight() >= (HL + Get_NearFloorConnection() + SL + RE) .and. Get_HookHeight() <= (HL + Get_NearFloorConnection() + SL + LG) .and.&
(Get_Elevator() /= ELEVATOR_LATCH_STRING_BEGIN .and.&
Get_Elevator() /= ELEVATOR_UNLATCH_STRING_BEGIN .and.&
Get_Elevator() /= ELEVATOR_LATCH_STAND_BEGIN .and.&
Get_Elevator() /= ELEVATOR_UNLATCH_STAND_BEGIN .and.&
Get_Elevator() /= ELEVATOR_LATCH_SINGLE_BEGIN .and.&
Get_Elevator() /= ELEVATOR_UNLATCH_SINGLE_BEGIN) .and.&
Get_StandRack() < 80 .and.&
Get_JointConnectionPossible() == .false. .and.&
!Get_Elevator() == ELEVATOR_UNLATCH_STAND_END .and.&
!Get_LatchLed() == .false.
Get_ElevatorConnection() == ELEVATOR_CONNECTION_STAND .and.&
Get_Swing() == SWING_WELL_END .and.&
Get_Slips() == SLIPS_SET_END) then
call Set_UnlatchLed(.true.)
!call Set_LatchLed(.false.)
return
end if
!OPERATION-CODE=42
if (Get_OperationCondition() == OPERATION_TRIP .and.&
Get_HookHeight() >= data%State%OperationScenario%HL .and. Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%SG) .and.&
(Get_Elevator() /= ELEVATOR_LATCH_STRING_BEGIN .and.&
Get_Elevator() /= ELEVATOR_UNLATCH_STRING_BEGIN .and.&
Get_Elevator() /= ELEVATOR_LATCH_STAND_BEGIN .and.&
Get_Elevator() /= ELEVATOR_UNLATCH_STAND_BEGIN .and.&
Get_Elevator() /= ELEVATOR_LATCH_SINGLE_BEGIN .and.&
Get_Elevator() /= ELEVATOR_UNLATCH_SINGLE_BEGIN) .and.&
!Get_Elevator() == ELEVATOR_UNLATCH_SINGLE_END .and.&
Get_Swing() == SWING_MOUSE_HOLE_END .and.&
!Get_LatchLed() == .false. .and.&
Get_FillMouseHoleLed() == .false.) then
call Set_UnlatchLed(.true.)
!call Set_LatchLed(.false.)
return
end if
!call Log_4('OPERATION-CODE=43-OPERATION_DRILL=', Get_OperationCondition() == OPERATION_DRILL)
!call Log_4('OPERATION-CODE=43-Get_HookHeight=', Get_HookHeight() >= 27.41)
!call Log_4('OPERATION-CODE=43-Get_Swing()=', Get_Swing() == SWING_RAT_HOLE_END)
!call Log_4('OPERATION-CODE=43-Get_LatchLed()=', Get_LatchLed() == .false.)
!OPERATION-CODE=43
if (Get_OperationCondition() == OPERATION_DRILL .and.&
Get_HookHeight() >= 27.41 .and.&
!Get_LatchLed() == .false.
Get_Swing() == SWING_RAT_HOLE_END) then
!call Log_4('OPERATION-CODE=43-call Set_UnlatchLed(.true.)')
call Set_UnlatchLed(.true.)
!call Set_LatchLed(.false.)
return
end if
call Set_UnlatchLed(.false.)

endif
end subroutine
! subroutine Subscribe_UnlatchLed()
! implicit none
! !**call data%State%unitySignals%OnOperationConditionChange%Add(Evaluate_UnlatchLed)
! ! call softwareInputs%OnHookHeightChange%Add(Evaluate_UnlatchLed)
! ! call softwareInputs%OnStandRackChanged%Add(Evaluate_UnlatchLed)
! call data%State%OperationScenario%OnElevatorConnectionChange%Add(Evaluate_UnlatchLed)
! !**call data%State%unitySignals%OnSwingChange%Add(Evaluate_UnlatchLed)
! !**call data%State%unitySignals%OnSlipsChange%Add(Evaluate_UnlatchLed)
! !**call data%State%notifications%OnLatchLedChange%Add(Evaluate_UnlatchLed)
! !**call data%State%notifications%OnFillMouseHoleLedChange%Add(Evaluate_UnlatchLed)
! end subroutine
end module CUnlatchLedNotification

+ 86
- 0
CSharp/OperationScenarios/Permissions/CIrSafetyValvePermission.i90 查看文件

@@ -0,0 +1,86 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/OperationScenarios/Permissions/CIrSafetyValvePermission.f90"
module CIrSafetyValvePermission
use OperationScenariosModule
implicit none
contains
subroutine Evaluate_IrSafetyValvePermission()
use TD_DrillStemComponents
use CStudentStationVariables!!, only: data%State%StudentStation%FillupHeadInstallation
implicit none
if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
# 17




!TOPDRIVE-CODE=55
if (GetRotaryRpm() == 0.0d0 .and.&
(Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 10.0) .and.&
Get_JointConnectionPossible() == .false. .and.&
Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING .and.&
data%State%StudentStation%FillupHeadInstallation == .false.) then
call Set_IrSafetyValvePermission(.true.)
return
end if



endif
if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
# 46



!OPERATION-CODE=57
if (Get_OperationCondition() == OPERATION_TRIP .and.&
GetRotaryRpm() == 0.0d0 .and.&
!(Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING .or. Get_ElevatorConnection() == ELEVATOR_LATCH_STRING) .and.&
!Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 10.0 .and.&
data%State%TD_String%TopJointHeight >= 3.0 .and. data%State%TD_String%TopJointHeight <= 10.0 .and.&
!Get_SafetyValveHeight() >= 22.0 .and. Get_SafetyValveHeight() <= 35.0 .and.&
Get_JointConnectionPossible() == .false. .and.&
Get_FillupHead() == FILLUP_HEAD_REMOVE .and.&
Get_Swing() == SWING_WELL_END) then
call Set_IrSafetyValvePermission(.true.)
return
end if
call Set_IrSafetyValvePermission(.false.)
endif
end subroutine
subroutine Subscribe_IrSafetyValvePermission()
implicit none
! imp me...
end subroutine
end module CIrSafetyValvePermission

+ 26
- 78
CSharp/OperationScenarios/Unity/CUnityInputs.f90 查看文件

@@ -32,8 +32,6 @@ module CUnityInputs
! type(VoidEventHandlerCollection) :: OnTdsConnectionPossibleChange
! type(VoidEventHandlerCollection) :: OnTdsStemInChange
end type UnityInputsType
type(UnityInputsType)::UnityInputs
contains
@@ -303,25 +301,21 @@ module CUnityInputs
! implicit none
! logical, intent(in) :: v
! #ifdef ExcludeExtraChanges
! if(UnityInputs%ElevatorConnectionPossible == v) return
! if(data%Equipments%UnityInputs%ElevatorConnectionPossible == v) return
! #endif
! UnityInputs%ElevatorConnectionPossible = v
! !**call UnityInputs%OnElevatorConnectionPossibleChange%RunAll()
! data%Equipments%UnityInputs%ElevatorConnectionPossible = v
! !**call data%Equipments%UnityInputs%OnElevatorConnectionPossibleChange%RunAll()
! #ifdef deb
! print*, 'ElevatorConnectionPossible=', UnityInputs%ElevatorConnectionPossible
! print*, 'ElevatorConnectionPossible=', data%Equipments%UnityInputs%ElevatorConnectionPossible
! #endif
! end subroutine
logical function Get_ElevatorConnectionPossible()
implicit none
Get_ElevatorConnectionPossible = UnityInputs%ElevatorConnectionPossible
end function
! logical function Get_ElevatorConnectionPossible_WN()
! !DEC$ ATTRIBUTES DLLEXPORT :: Get_ElevatorConnectionPossible_WN
! !DEC$ ATTRIBUTES ALIAS: 'Get_ElevatorConnectionPossible_WN' :: Get_ElevatorConnectionPossible_WN
! implicit none
! Get_ElevatorConnectionPossible_WN = UnityInputs%ElevatorConnectionPossible
! Get_ElevatorConnectionPossible_WN = data%Equipments%UnityInputs%ElevatorConnectionPossible
! !Get_ElevatorConnectionPossible_WN = .true.
! end function
@@ -338,26 +332,22 @@ module CUnityInputs
! implicit none
! logical, intent(in) :: v
! #ifdef ExcludeExtraChanges
! if(UnityInputs%JointConnectionPossible == v) return
! if(data%Equipments%UnityInputs%JointConnectionPossible == v) return
! #endif
! UnityInputs%JointConnectionPossible = v
! !**call UnityInputs%OnJointConnectionPossibleChange%RunAll()
! data%Equipments%UnityInputs%JointConnectionPossible = v
! !**call data%Equipments%UnityInputs%OnJointConnectionPossibleChange%RunAll()
! #ifdef deb
! print*, 'JointConnectionPossible=', UnityInputs%JointConnectionPossible
! print*, 'JointConnectionPossible=', data%Equipments%UnityInputs%JointConnectionPossible
! #endif
! end subroutine
logical function Get_JointConnectionPossible()
implicit none
Get_JointConnectionPossible = UnityInputs%JointConnectionPossible
end function
! logical function Get_JointConnectionPossible_WN()
! !DEC$ ATTRIBUTES DLLEXPORT :: Get_JointConnectionPossible_WN
! !DEC$ ATTRIBUTES ALIAS: 'Get_JointConnectionPossible_WN' :: Get_JointConnectionPossible_WN
! implicit none
! Get_JointConnectionPossible_WN = UnityInputs%JointConnectionPossible
! Get_JointConnectionPossible_WN = data%Equipments%UnityInputs%JointConnectionPossible
! end function
@@ -370,25 +360,20 @@ module CUnityInputs
! implicit none
! logical, intent(in) :: v
! #ifdef ExcludeExtraChanges
! if(UnityInputs%IsKellyBushingSetInTable == v) return
! if(data%Equipments%UnityInputs%IsKellyBushingSetInTable == v) return
! #endif
! UnityInputs%IsKellyBushingSetInTable = v
! !**call UnityInputs%OnIsKellyBushingSetInTableChange%RunAll()
! data%Equipments%UnityInputs%IsKellyBushingSetInTable = v
! !**call data%Equipments%UnityInputs%OnIsKellyBushingSetInTableChange%RunAll()
! #ifdef deb
! print*, 'IsKellyBushingSetInTable=', UnityInputs%IsKellyBushingSetInTable
! print*, 'IsKellyBushingSetInTable=', data%Equipments%UnityInputs%IsKellyBushingSetInTable
! #endif
! end subroutine
logical function Get_IsKellyBushingSetInTable()
implicit none
Get_IsKellyBushingSetInTable = UnityInputs%IsKellyBushingSetInTable
end function
! logical function Get_IsKellyBushingSetInTable_WN()
! !DEC$ ATTRIBUTES DLLEXPORT :: Get_IsKellyBushingSetInTable_WN
! !DEC$ ATTRIBUTES ALIAS: 'Get_IsKellyBushingSetInTable_WN' :: Get_IsKellyBushingSetInTable_WN
! implicit none
! Get_IsKellyBushingSetInTable_WN = UnityInputs%IsKellyBushingSetInTable
! Get_IsKellyBushingSetInTable_WN = data%Equipments%UnityInputs%IsKellyBushingSetInTable
! end function
@@ -403,26 +388,22 @@ module CUnityInputs
! implicit none
! logical, intent(in) :: v
! #ifdef ExcludeExtraChanges
! if(UnityInputs%ElevatorPickup == v) return
! if(data%Equipments%UnityInputs%ElevatorPickup == v) return
! #endif
! UnityInputs%ElevatorPickup = v
! !**call UnityInputs%OnElevatorPickupChange%RunAll()
! data%Equipments%UnityInputs%ElevatorPickup = v
! !**call data%Equipments%UnityInputs%OnElevatorPickupChange%RunAll()
! #ifdef deb
! print*, 'ElevatorPickup =', UnityInputs%ElevatorPickup
! print*, 'ElevatorPickup =', data%Equipments%UnityInputs%ElevatorPickup
! #endif
! end subroutine
logical function Get_ElevatorPickup()
implicit none
Get_ElevatorPickup = UnityInputs%ElevatorPickup
end function
! logical function Get_ElevatorPickup_WN()
! !DEC$ ATTRIBUTES DLLEXPORT :: Get_ElevatorPickup_WN
! !DEC$ ATTRIBUTES ALIAS: 'Get_ElevatorPickup_WN' :: Get_ElevatorPickup_WN
! implicit none
! Get_ElevatorPickup_WN = UnityInputs%ElevatorPickup
! Get_ElevatorPickup_WN = data%Equipments%UnityInputs%ElevatorPickup
! end function
@@ -431,18 +412,6 @@ module CUnityInputs
subroutine Set_NearFloorPosition(v)
implicit none
logical, intent(in) :: v
#ifdef ExcludeExtraChanges
if(UnityInputs%NearFloorPosition == v) return
#endif
UnityInputs%NearFloorPosition = v
!**call UnityInputs%OnNearFloorPositionChange%RunAll()
#ifdef deb
print*, 'NearFloorPosition =', UnityInputs%NearFloorPosition
#endif
end subroutine
! subroutine Set_NearFloorPosition_WN(v)
! !DEC$ ATTRIBUTES DLLEXPORT :: Set_NearFloorPosition_WN
@@ -452,17 +421,13 @@ module CUnityInputs
! call Set_NearFloorPosition(v)
! end subroutine
logical function Get_NearFloorPosition()
implicit none
Get_NearFloorPosition = UnityInputs%NearFloorPosition
end function
! logical function Get_NearFloorPosition_WN()
! !DEC$ ATTRIBUTES DLLEXPORT :: Get_NearFloorPosition_WN
! !DEC$ ATTRIBUTES ALIAS: 'Get_NearFloorPosition_WN' :: Get_NearFloorPosition_WN
! implicit none
! Get_NearFloorPosition_WN = UnityInputs%NearFloorPosition
! Get_NearFloorPosition_WN = data%Equipments%UnityInputs%NearFloorPosition
! end function
@@ -479,38 +444,21 @@ module CUnityInputs
! implicit none
! logical, intent(in) :: v
! #ifdef ExcludeExtraChanges
! if(UnityInputs%SingleSetInMouseHole == v) return
! if(data%Equipments%UnityInputs%SingleSetInMouseHole == v) return
! #endif
! UnityInputs%SingleSetInMouseHole = v
! !**call UnityInputs%OnSingleSetInMouseHoleChange%RunAll()
! data%Equipments%UnityInputs%SingleSetInMouseHole = v
! !**call data%Equipments%UnityInputs%OnSingleSetInMouseHoleChange%RunAll()
! #ifdef deb
! print*, 'singleSetInMouseHole=', UnityInputs%SingleSetInMouseHole
! print*, 'singleSetInMouseHole=', data%Equipments%UnityInputs%SingleSetInMouseHole
! #endif
! end subroutine
logical function Get_SingleSetInMouseHole()
implicit none
Get_SingleSetInMouseHole = UnityInputs%SingleSetInMouseHole
end function
logical function Get_TdsConnectionPossible()
implicit none
Get_TdsConnectionPossible = UnityInputs%TdsConnectionPossible
end function
logical function Get_TdsStemIn()
implicit none
Get_TdsStemIn = UnityInputs%TdsStemIn
end function
! logical function Get_TdsStemIn_WN()
! !DEC$ ATTRIBUTES DLLEXPORT :: Get_TdsStemIn_WN
! !DEC$ ATTRIBUTES ALIAS: 'Get_TdsStemIn_WN' :: Get_TdsStemIn_WN
! implicit none
! Get_TdsStemIn_WN = UnityInputs%TdsStemIn
! Get_TdsStemIn_WN = data%Equipments%UnityInputs%TdsStemIn
! !Get_TdsStemIn_WN = .true.
! end function


+ 469
- 0
CSharp/OperationScenarios/Unity/CUnityInputs.i90 查看文件

@@ -0,0 +1,469 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/OperationScenarios/Unity/CUnityInputs.f90"
module CUnityInputs
! use CVoidEventHandlerCollection
implicit none
type :: UnityInputsType
logical :: ElevatorConnectionPossible
logical :: JointConnectionPossible
logical :: IsKellyBushingSetInTable
logical :: ElevatorPickup
logical :: NearFloorPosition
logical :: SingleSetInMouseHole
logical :: TdsConnectionPossible
logical :: TdsStemIn
! private :: ElevatorConnectionPossible
! private :: JointConnectionPossible
! private :: IsKellyBushingSetInTable
! private :: ElevatorPickup
! private :: NearFloorPosition
! private :: SingleSetInMouseHole
! private :: TdsConnectionPossible
! private :: TdsStemIn
! public
! type(VoidEventHandlerCollection) :: OnElevatorConnectionPossibleChange
! type(VoidEventHandlerCollection) :: OnJointConnectionPossibleChange
! type(VoidEventHandlerCollection) :: OnIsKellyBushingSetInTableChange
! type(VoidEventHandlerCollection) :: OnElevatorPickupChange
! type(VoidEventHandlerCollection) :: OnNearFloorPositionChange
! type(VoidEventHandlerCollection) :: OnSingleSetInMouseHoleChange
! type(VoidEventHandlerCollection) :: OnTdsConnectionPossibleChange
! type(VoidEventHandlerCollection) :: OnTdsStemInChange
end type UnityInputsType
contains
! Input routines
! subroutine Set_OutOfMouseHole(v)
! !DEC$ ATTRIBUTES DLLEXPORT :: Set_OutOfMouseHole
! !DEC$ ATTRIBUTES ALIAS: 'Set_OutOfMouseHole' :: Set_OutOfMouseHole
! implicit none
! logical, intent(in) :: v
! !#ifdef ExcludeExtraChanges
! ! if(OutOfMouseHole == v) return
! !#endif
! ! OutOfMouseHole = v
! ! call OnOutOfMouseHoleChange%RunAll()
! !#ifdef deb
! ! print*, 'OutOfMouseHole=', OutOfMouseHole
! !#endif
! end subroutine
! !logical function Get_OutOfMouseHole()
! ! implicit none
! ! Get_OutOfMouseHole = OutOfMouseHole
! !end function
! subroutine Set_Unlatch(v)
! !DEC$ ATTRIBUTES DLLEXPORT :: Set_Unlatch
! !DEC$ ATTRIBUTES ALIAS: 'Set_Unlatch' :: Set_Unlatch
! implicit none
! logical, intent(in) :: v
! !#ifdef ExcludeExtraChanges
! ! if(Unlatch == v) return
! !#endif
! ! Unlatch = v
! ! call OnUnlatchChange%RunAll()
! !#ifdef deb
! ! print*, 'Unlatch=', Unlatch
! !#endif
! end subroutine
! !logical function Get_Unlatch()
! ! implicit none
! ! Get_Unlatch = Unlatch
! !end function
! subroutine Set_Latch(v)
! !DEC$ ATTRIBUTES DLLEXPORT :: Set_Latch
! !DEC$ ATTRIBUTES ALIAS: 'Set_Latch' :: Set_Latch
! implicit none
! logical, intent(in) :: v
! !#ifdef ExcludeExtraChanges
! ! if(Latch == v) return
! !#endif
! ! Latch = v
! ! call OnLatchChange%RunAll()
! !#ifdef deb
! ! print*, 'Latch=', Latch
! !#endif
! end subroutine
! !logical function Get_Latch()
! ! implicit none
! ! Get_Latch = Latch
! !end function
! subroutine Set_SlipsUnSet(v)
! !DEC$ ATTRIBUTES DLLEXPORT :: Set_SlipsUnSet
! !DEC$ ATTRIBUTES ALIAS: 'Set_SlipsUnSet' :: Set_SlipsUnSet
! implicit none
! logical, intent(in) :: v
! !#ifdef ExcludeExtraChanges
! ! if(SlipsUnSet == v) return
! !#endif
! ! SlipsUnSet = v
! ! call OnSlipsUnSetChange%RunAll()
! !#ifdef deb
! ! print*, 'SlipsUnSet=', SlipsUnSet
! !#endif
! end subroutine
! !logical function Get_SlipsUnSet()
! ! implicit none
! ! Get_SlipsUnSet = SlipsUnSet
! !end function
! subroutine Set_SlipsSet(v)
! !DEC$ ATTRIBUTES DLLEXPORT :: Set_SlipsSet
! !DEC$ ATTRIBUTES ALIAS: 'Set_SlipsSet' :: Set_SlipsSet
! implicit none
! logical, intent(in) :: v
! !#ifdef ExcludeExtraChanges
! ! if(SlipsSet == v) return
! !#endif
! ! SlipsSet = v
! ! call OnSlipsSetChange%RunAll()
! !#ifdef deb
! ! print*, 'SlipsSet=', SlipsSet
! !#endif
! end subroutine
! !logical function Get_SlipsSet()
! ! implicit none
! ! Get_SlipsSet = SlipsSet
! !end function
! subroutine Set_BreakupTong(v)
! !DEC$ ATTRIBUTES DLLEXPORT :: Set_BreakupTong
! !DEC$ ATTRIBUTES ALIAS: 'Set_BreakupTong' :: Set_BreakupTong
! implicit none
! logical, intent(in) :: v
! !#ifdef ExcludeExtraChanges
! ! if(BreakupTong == v) return
! !#endif
! ! BreakupTong = v
! ! call OnBreakupTongChange%RunAll()
! !#ifdef deb
! ! print*, 'BreakupTong=', BreakupTong
! !#endif
! end subroutine
! !logical function Get_BreakupTong()
! ! implicit none
! ! Get_BreakupTong = BreakupTong
! !end function
! subroutine Set_MakeupTong(v)
! !DEC$ ATTRIBUTES DLLEXPORT :: Set_MakeupTong
! !DEC$ ATTRIBUTES ALIAS: 'Set_MakeupTong' :: Set_MakeupTong
! implicit none
! logical, intent(in) :: v
! !#ifdef ExcludeExtraChanges
! ! if(MakeupTong == v) return
! !#endif
! ! MakeupTong = v
! ! call OnMakeupTongChange%RunAll()
! !#ifdef deb
! ! print*, 'MakeupTong=', MakeupTong
! !#endif
! end subroutine
! !logical function Get_MakeupTong()
! ! implicit none
! ! Get_MakeupTong = MakeupTong
! !end function
! subroutine Set_NewHookHeight(v)
! !DEC$ ATTRIBUTES DLLEXPORT :: Set_NewHookHeight
! !DEC$ ATTRIBUTES ALIAS: 'Set_NewHookHeight' :: Set_NewHookHeight
! implicit none
! real(8), intent(in) :: v
! !#ifdef ExcludeExtraChanges
! ! if(NewHookHeight == v) return
! !#endif
! ! NewHookHeight = v
! ! call OnNewHookHeightChange%RunAll()
! !#ifdef deb
! ! print*, 'NewHookHeight=', NewHookHeight
! !#endif
! end subroutine
! !real(8) function Get_NewHookHeight()
! ! implicit none
! ! Get_NewHookHeight = NewHookHeight
! !end function
! subroutine Set_ElevatorConnectionPossible(v)
! !DEC$ ATTRIBUTES DLLEXPORT :: Set_ElevatorConnectionPossible
! !DEC$ ATTRIBUTES ALIAS: 'Set_ElevatorConnectionPossible' :: Set_ElevatorConnectionPossible
! implicit none
! logical, intent(in) :: v
! #ifdef ExcludeExtraChanges
! if(data%Equipments%UnityInputs%ElevatorConnectionPossible == v) return
! #endif
! data%Equipments%UnityInputs%ElevatorConnectionPossible = v
! !**call data%Equipments%UnityInputs%OnElevatorConnectionPossibleChange%RunAll()
! #ifdef deb
! print*, 'ElevatorConnectionPossible=', data%Equipments%UnityInputs%ElevatorConnectionPossible
! #endif
! end subroutine
! logical function Get_ElevatorConnectionPossible_WN()
! !DEC$ ATTRIBUTES DLLEXPORT :: Get_ElevatorConnectionPossible_WN
! !DEC$ ATTRIBUTES ALIAS: 'Get_ElevatorConnectionPossible_WN' :: Get_ElevatorConnectionPossible_WN
! implicit none
! Get_ElevatorConnectionPossible_WN = data%Equipments%UnityInputs%ElevatorConnectionPossible
! !Get_ElevatorConnectionPossible_WN = .true.
! end function

! subroutine Set_JointConnectionPossible(v)
! !DEC$ ATTRIBUTES DLLEXPORT :: Set_JointConnectionPossible
! !DEC$ ATTRIBUTES ALIAS: 'Set_JointConnectionPossible' :: Set_JointConnectionPossible
! implicit none
! logical, intent(in) :: v
! #ifdef ExcludeExtraChanges
! if(data%Equipments%UnityInputs%JointConnectionPossible == v) return
! #endif
! data%Equipments%UnityInputs%JointConnectionPossible = v
! !**call data%Equipments%UnityInputs%OnJointConnectionPossibleChange%RunAll()
! #ifdef deb
! print*, 'JointConnectionPossible=', data%Equipments%UnityInputs%JointConnectionPossible
! #endif
! end subroutine
! logical function Get_JointConnectionPossible_WN()
! !DEC$ ATTRIBUTES DLLEXPORT :: Get_JointConnectionPossible_WN
! !DEC$ ATTRIBUTES ALIAS: 'Get_JointConnectionPossible_WN' :: Get_JointConnectionPossible_WN
! implicit none
! Get_JointConnectionPossible_WN = data%Equipments%UnityInputs%JointConnectionPossible
! end function
! subroutine Set_IsKellyBushingSetInTable(v)
! !DEC$ ATTRIBUTES DLLEXPORT :: Set_IsKellyBushingSetInTable
! !DEC$ ATTRIBUTES ALIAS: 'Set_IsKellyBushingSetInTable' :: Set_IsKellyBushingSetInTable
! implicit none
! logical, intent(in) :: v
! #ifdef ExcludeExtraChanges
! if(data%Equipments%UnityInputs%IsKellyBushingSetInTable == v) return
! #endif
! data%Equipments%UnityInputs%IsKellyBushingSetInTable = v
! !**call data%Equipments%UnityInputs%OnIsKellyBushingSetInTableChange%RunAll()
! #ifdef deb
! print*, 'IsKellyBushingSetInTable=', data%Equipments%UnityInputs%IsKellyBushingSetInTable
! #endif
! end subroutine
! logical function Get_IsKellyBushingSetInTable_WN()
! !DEC$ ATTRIBUTES DLLEXPORT :: Get_IsKellyBushingSetInTable_WN
! !DEC$ ATTRIBUTES ALIAS: 'Get_IsKellyBushingSetInTable_WN' :: Get_IsKellyBushingSetInTable_WN
! implicit none
! Get_IsKellyBushingSetInTable_WN = data%Equipments%UnityInputs%IsKellyBushingSetInTable
! end function

! subroutine Set_ElevatorPickup(v)
! !DEC$ ATTRIBUTES DLLEXPORT :: Set_ElevatorPickup
! !DEC$ ATTRIBUTES ALIAS: 'Set_ElevatorPickup' :: Set_ElevatorPickup
! implicit none
! logical, intent(in) :: v
! #ifdef ExcludeExtraChanges
! if(data%Equipments%UnityInputs%ElevatorPickup == v) return
! #endif
! data%Equipments%UnityInputs%ElevatorPickup = v
! !**call data%Equipments%UnityInputs%OnElevatorPickupChange%RunAll()
! #ifdef deb
! print*, 'ElevatorPickup =', data%Equipments%UnityInputs%ElevatorPickup
! #endif
! end subroutine
! logical function Get_ElevatorPickup_WN()
! !DEC$ ATTRIBUTES DLLEXPORT :: Get_ElevatorPickup_WN
! !DEC$ ATTRIBUTES ALIAS: 'Get_ElevatorPickup_WN' :: Get_ElevatorPickup_WN
! implicit none
! Get_ElevatorPickup_WN = data%Equipments%UnityInputs%ElevatorPickup
! end function
! subroutine Set_NearFloorPosition_WN(v)
! !DEC$ ATTRIBUTES DLLEXPORT :: Set_NearFloorPosition_WN
! !DEC$ ATTRIBUTES ALIAS: 'Set_NearFloorPosition_WN' :: Set_NearFloorPosition_WN
! implicit none
! logical, intent(in) :: v
! call Set_NearFloorPosition(v)
! end subroutine
! logical function Get_NearFloorPosition_WN()
! !DEC$ ATTRIBUTES DLLEXPORT :: Get_NearFloorPosition_WN
! !DEC$ ATTRIBUTES ALIAS: 'Get_NearFloorPosition_WN' :: Get_NearFloorPosition_WN
! implicit none
! Get_NearFloorPosition_WN = data%Equipments%UnityInputs%NearFloorPosition
! end function

! subroutine Set_SingleSetInMouseHole(v)
! !DEC$ ATTRIBUTES DLLEXPORT :: Set_SingleSetInMouseHole
! !DEC$ ATTRIBUTES ALIAS: 'Set_SingleSetInMouseHole' :: Set_SingleSetInMouseHole
! implicit none
! logical, intent(in) :: v
! #ifdef ExcludeExtraChanges
! if(data%Equipments%UnityInputs%SingleSetInMouseHole == v) return
! #endif
! data%Equipments%UnityInputs%SingleSetInMouseHole = v
! !**call data%Equipments%UnityInputs%OnSingleSetInMouseHoleChange%RunAll()
! #ifdef deb
! print*, 'singleSetInMouseHole=', data%Equipments%UnityInputs%SingleSetInMouseHole
! #endif
! end subroutine
! logical function Get_TdsStemIn_WN()
! !DEC$ ATTRIBUTES DLLEXPORT :: Get_TdsStemIn_WN
! !DEC$ ATTRIBUTES ALIAS: 'Get_TdsStemIn_WN' :: Get_TdsStemIn_WN
! implicit none
! Get_TdsStemIn_WN = data%Equipments%UnityInputs%TdsStemIn
! !Get_TdsStemIn_WN = .true.
! end function
end module CUnityInputs

+ 1
- 190
CSharp/OperationScenarios/Unity/CUnityOutputs.f90 查看文件

@@ -1,6 +1,6 @@
module CUnityOutputs
implicit none
type :: UnityOutputsType
type :: UnityOutputsType
real(8) :: KellyHoseVibrationRate
real(8) :: BlowoutFromStringPercent
real(8) :: Pedal
@@ -14,7 +14,6 @@ module CUnityOutputs
logical :: FlowKellyDisconnect
logical :: FlowPipeDisconnect
end type UnityOutputsType
type(UnityOutputsType):: UnityOutputs
contains
@@ -35,192 +34,4 @@ module CUnityOutputs
subroutine Set_BlowoutFromString(v)
implicit none
logical, intent (in) :: v
UnityOutputs%BlowoutFromString = v
#ifdef deb
print*, 'BlowoutFromString=', v
#endif
end subroutine
logical function Get_BlowoutFromString()
implicit none
Get_BlowoutFromString = UnityOutputs%BlowoutFromString
end function
subroutine Set_BlowoutFromAnnular(v)
implicit none
logical, intent (in) :: v
UnityOutputs%BlowoutFromAnnular = v
#ifdef deb
print*, 'BlowoutFromAnnular=', v
#endif
end subroutine
logical function Get_BlowoutFromAnnular()
implicit none
Get_BlowoutFromAnnular = UnityOutputs%BlowoutFromAnnular
end function
subroutine Set_FlowFromReturnLine(v)
implicit none
logical, intent (in) :: v
UnityOutputs%FlowFromReturnLine = v
#ifdef deb
print*, 'FlowFromReturnLine=', v
#endif
end subroutine
logical function Get_FlowFromReturnLine()
implicit none
Get_FlowFromReturnLine = UnityOutputs%FlowFromReturnLine
end function
subroutine Set_FlowFromKelly(v)
implicit none
real, intent (in) :: v
UnityOutputs%FlowFromKelly = v
#ifdef deb
print*, 'FlowFromKelly=', v
#endif
end subroutine
real function Get_FlowFromKelly()
implicit none
Get_FlowFromKelly = UnityOutputs%FlowFromKelly
end function
subroutine Set_FlowFromFillupHead(v)
implicit none
real, intent (in) :: v
UnityOutputs%FlowFromFillupHead = v
#ifdef deb
print*, 'FlowFromFillupHead=', v
#endif
end subroutine
real function Get_FlowFromFillupHead()
implicit none
Get_FlowFromFillupHead = UnityOutputs%FlowFromFillupHead
end function
subroutine Set_FlowKellyDisconnect(v)
implicit none
logical, intent (in) :: v
UnityOutputs%FlowKellyDisconnect = v
#ifdef deb
print*, 'FlowKellyDisconnect=', v
#endif
end subroutine
logical function Get_FlowKellyDisconnect()
implicit none
Get_FlowKellyDisconnect = UnityOutputs%FlowKellyDisconnect
end function
subroutine Set_FlowPipeDisconnect(v)
implicit none
logical, intent (in) :: v
UnityOutputs%FlowPipeDisconnect = v
#ifdef deb
print*, 'FlowPipeDisconnect=', v
#endif
end subroutine
logical function Get_FlowPipeDisconnect()
implicit none
Get_FlowPipeDisconnect = UnityOutputs%FlowPipeDisconnect
end function
subroutine Set_BlowoutFromStringPercent(v)
implicit none
real(8), intent (in) :: v
UnityOutputs%BlowoutFromStringPercent = v
#ifdef deb
print*, 'BlowoutFromStringPercent=', v
#endif
end subroutine
real(8) function GetBlowoutFromStringPercent()
implicit none
GetBlowoutFromStringPercent = UnityOutputs%BlowoutFromStringPercent
end function
subroutine Calc_KellyHoseVibrationRate(spm1, spm2)
use CScaleRange
implicit none
real(8), intent (in) :: spm1, spm2
real :: total
total = (spm1 + spm2)/2
UnityOutputs%KellyHoseVibrationRate = ScaleRange(total, 0.0, 10.0, 0.0, 120.0)
#ifdef deb
print*, 'KellyHoseVibrationRate=', UnityOutputs%KellyHoseVibrationRate
#endif
end subroutine
real(8) function GetKellyHoseVibrationRate()
implicit none
GetKellyHoseVibrationRate = UnityOutputs%KellyHoseVibrationRate
end function
subroutine Set_Pedal(v)
implicit none
real(8), intent (in) :: v
UnityOutputs%Pedal = v
#ifdef deb
print*, 'Pedal=', v
#endif
end subroutine
real(8) function GetPedal()
implicit none
GetPedal = UnityOutputs%Pedal
end function
subroutine Set_FlowRate(v)
implicit none
real(8), intent (in) :: v
UnityOutputs%FlowRate = v
#ifdef deb
print*, 'FlowRate=', v
#endif
end subroutine
real(8) function GetFlowRate()
implicit none
GetFlowRate = UnityOutputs%FlowRate
end function
subroutine Set_RotaryRpm(v)
implicit none
real(8), intent (in) :: v
UnityOutputs%RotaryRpm = v
#ifdef deb
print*, 'RotaryRpm=', v
#endif
end subroutine
real(8) function GetRotaryRpm()
implicit none
GetRotaryRpm = UnityOutputs%RotaryRpm
end function
end module CUnityOutputs

+ 1
- 178
CSharp/OperationScenarios/Unity/CUnityOutputs.i90 查看文件

@@ -1,7 +1,7 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/OperationScenarios/Unity/CUnityOutputs.f90"
module CUnityOutputs
implicit none
type :: UnityOutputsType
type :: UnityOutputsType
real(8) :: KellyHoseVibrationRate
real(8) :: BlowoutFromStringPercent
real(8) :: Pedal
@@ -15,7 +15,6 @@ module CUnityOutputs
logical :: FlowKellyDisconnect
logical :: FlowPipeDisconnect
end type UnityOutputsType
type(UnityOutputsType):: UnityOutputs

contains

@@ -36,180 +35,4 @@ module CUnityOutputs
subroutine Set_BlowoutFromString(v)
implicit none
logical, intent (in) :: v
UnityOutputs%BlowoutFromString = v
# 44

end subroutine
logical function Get_BlowoutFromString()
implicit none
Get_BlowoutFromString = UnityOutputs%BlowoutFromString
end function
subroutine Set_BlowoutFromAnnular(v)
implicit none
logical, intent (in) :: v
UnityOutputs%BlowoutFromAnnular = v
# 58

end subroutine
logical function Get_BlowoutFromAnnular()
implicit none
Get_BlowoutFromAnnular = UnityOutputs%BlowoutFromAnnular
end function
subroutine Set_FlowFromReturnLine(v)
implicit none
logical, intent (in) :: v
UnityOutputs%FlowFromReturnLine = v
# 76

end subroutine
logical function Get_FlowFromReturnLine()
implicit none
Get_FlowFromReturnLine = UnityOutputs%FlowFromReturnLine
end function
subroutine Set_FlowFromKelly(v)
implicit none
real, intent (in) :: v
UnityOutputs%FlowFromKelly = v
# 92

end subroutine
real function Get_FlowFromKelly()
implicit none
Get_FlowFromKelly = UnityOutputs%FlowFromKelly
end function
subroutine Set_FlowFromFillupHead(v)
implicit none
real, intent (in) :: v
UnityOutputs%FlowFromFillupHead = v
# 110

end subroutine
real function Get_FlowFromFillupHead()
implicit none
Get_FlowFromFillupHead = UnityOutputs%FlowFromFillupHead
end function
subroutine Set_FlowKellyDisconnect(v)
implicit none
logical, intent (in) :: v
UnityOutputs%FlowKellyDisconnect = v
# 129

end subroutine
logical function Get_FlowKellyDisconnect()
implicit none
Get_FlowKellyDisconnect = UnityOutputs%FlowKellyDisconnect
end function
subroutine Set_FlowPipeDisconnect(v)
implicit none
logical, intent (in) :: v
UnityOutputs%FlowPipeDisconnect = v
# 146

end subroutine
logical function Get_FlowPipeDisconnect()
implicit none
Get_FlowPipeDisconnect = UnityOutputs%FlowPipeDisconnect
end function
subroutine Set_BlowoutFromStringPercent(v)
implicit none
real(8), intent (in) :: v
UnityOutputs%BlowoutFromStringPercent = v
# 160

end subroutine
real(8) function GetBlowoutFromStringPercent()
implicit none
GetBlowoutFromStringPercent = UnityOutputs%BlowoutFromStringPercent
end function
subroutine Calc_KellyHoseVibrationRate(spm1, spm2)
use CScaleRange
implicit none
real(8), intent (in) :: spm1, spm2
real :: total
total = (spm1 + spm2)/2
UnityOutputs%KellyHoseVibrationRate = ScaleRange(total, 0.0, 10.0, 0.0, 120.0)
# 177

end subroutine
real(8) function GetKellyHoseVibrationRate()
implicit none
GetKellyHoseVibrationRate = UnityOutputs%KellyHoseVibrationRate
end function
subroutine Set_Pedal(v)
implicit none
real(8), intent (in) :: v
UnityOutputs%Pedal = v
# 191

end subroutine
real(8) function GetPedal()
implicit none
GetPedal = UnityOutputs%Pedal
end function
subroutine Set_FlowRate(v)
implicit none
real(8), intent (in) :: v
UnityOutputs%FlowRate = v
# 205

end subroutine
real(8) function GetFlowRate()
implicit none
GetFlowRate = UnityOutputs%FlowRate
end function
subroutine Set_RotaryRpm(v)
implicit none
real(8), intent (in) :: v
UnityOutputs%RotaryRpm = v
# 219

end subroutine
real(8) function GetRotaryRpm()
implicit none
GetRotaryRpm = UnityOutputs%RotaryRpm
end function
end module CUnityOutputs

+ 288
- 0
CSharp/OperationScenarios/Unity/UnityModule.f90 查看文件

@@ -0,0 +1,288 @@
module UnityModule
use SimulationVariables
implicit none
contains
subroutine UnityInputsFromJson(parent)
use json_module,IK =>json_ik
type(json_value),pointer :: parent
type(json_core) :: json
type(json_value),pointer :: p,pval

call json%get(parent,'Unity',p)

call json%get(p,'ElevatorConnectionPossible',pval)
call json%get(pval,data%Equipments%UnityInputs%ElevatorConnectionPossible)
call json%get(p,'JointConnectionPossible',pval)
call json%get(pval,data%Equipments%UnityInputs%JointConnectionPossible)
call json%get(p,'IsKellyBushingSetInTable',pval)
call json%get(pval,data%Equipments%UnityInputs%IsKellyBushingSetInTable)
call json%get(p,'ElevatorPickup',pval)
call json%get(pval,data%Equipments%UnityInputs%ElevatorPickup)
call json%get(p,'NearFloorPosition',pval)
call json%get(pval,data%Equipments%UnityInputs%NearFloorPosition)
call json%get(p,'SingleSetInMouseHole',pval)
call json%get(pval,data%Equipments%UnityInputs%SingleSetInMouseHole)
call json%get(p,'TdsConnectionPossible',pval)
call json%get(pval,data%Equipments%UnityInputs%TdsConnectionPossible)
call json%get(p,'TdsStemIn',pval)
call json%get(pval,data%Equipments%UnityInputs%TdsStemIn)
end subroutine

subroutine UnityOutputsToJson(parent)
type(json_value),pointer :: parent
type(json_core) :: json
type(json_value),pointer :: p

! 1. create new node
call json%create_object(p,'Unity')
! 2. add member of data type to new node
call json%add(p,"KellyHoseVibrationRate",data%Equipments%UnityOutputs%KellyHoseVibrationRate)
call json%add(p,"BlowoutFromStringPercent",data%Equipments%UnityOutputs%BlowoutFromStringPercent)
call json%add(p,"Pedal",data%Equipments%UnityOutputs%Pedal)
call json%add(p,"FlowRate",data%Equipments%UnityOutputs%FlowRate)
call json%add(p,"RotaryRpm",data%Equipments%UnityOutputs%RotaryRpm)
call json%add(p,"BlowoutFromString",data%Equipments%UnityOutputs%BlowoutFromString)
call json%add(p,"BlowoutFromAnnular",data%Equipments%UnityOutputs%BlowoutFromAnnular)
call json%add(p,"FlowFromReturnLine",data%Equipments%UnityOutputs%FlowFromReturnLine)
call json%add(p,"FlowFromKelly",data%Equipments%UnityOutputs%FlowFromKelly)
call json%add(p,"FlowFromFillupHead",data%Equipments%UnityOutputs%FlowFromFillupHead)
call json%add(p,"FlowKellyDisconnect",data%Equipments%UnityOutputs%FlowKellyDisconnect)
call json%add(p,"FlowPipeDisconnect",data%Equipments%UnityOutputs%FlowPipeDisconnect)
! 3. add new node to parent
call json%add(parent,p)
end subroutine

logical function Get_ElevatorPickup()
Get_ElevatorPickup = data%Equipments%UnityInputs%ElevatorPickup
end function

logical function Get_IsKellyBushingSetInTable()
Get_IsKellyBushingSetInTable = data%Equipments%UnityInputs%IsKellyBushingSetInTable
end function
logical function Get_JointConnectionPossible()
Get_JointConnectionPossible = data%Equipments%UnityInputs%JointConnectionPossible
end function
logical function Get_ElevatorConnectionPossible()
implicit none
Get_ElevatorConnectionPossible = data%Equipments%UnityInputs%ElevatorConnectionPossible
end function
logical function Get_NearFloorPosition()
Get_NearFloorPosition = data%Equipments%UnityInputs%NearFloorPosition
end function
subroutine Set_NearFloorPosition(v)
implicit none
logical, intent(in) :: v
! #ifdef ExcludeExtraChanges
! if(data%Equipments%UnityInputs%NearFloorPosition == v) return
! #endif
data%Equipments%UnityInputs%NearFloorPosition = v
!**call data%Equipments%UnityInputs%OnNearFloorPositionChange%RunAll()
if(logging>4) then
print*, 'NearFloorPosition =', data%Equipments%UnityInputs%NearFloorPosition
endif
end subroutine

logical function Get_SingleSetInMouseHole()
Get_SingleSetInMouseHole = data%Equipments%UnityInputs%SingleSetInMouseHole
end function

logical function Get_TdsConnectionPossible()
Get_TdsConnectionPossible = data%Equipments%UnityInputs%TdsConnectionPossible
end function

logical function Get_TdsStemIn()
Get_TdsStemIn = data%Equipments%UnityInputs%TdsStemIn
end function

subroutine Set_BlowoutFromString(v)
implicit none
logical, intent (in) :: v
data%Equipments%UnityOutputs%BlowoutFromString = v
#ifdef deb
print*, 'BlowoutFromString=', v
#endif
end subroutine

logical function Get_BlowoutFromString()
implicit none
Get_BlowoutFromString = data%Equipments%UnityOutputs%BlowoutFromString
end function

subroutine Set_BlowoutFromAnnular(v)
implicit none
logical, intent (in) :: v
data%Equipments%UnityOutputs%BlowoutFromAnnular = v
#ifdef deb
print*, 'BlowoutFromAnnular=', v
#endif
end subroutine

logical function Get_BlowoutFromAnnular()
implicit none
Get_BlowoutFromAnnular = data%Equipments%UnityOutputs%BlowoutFromAnnular
end function





subroutine Set_FlowFromReturnLine(v)
implicit none
logical, intent (in) :: v
data%Equipments%UnityOutputs%FlowFromReturnLine = v
#ifdef deb
print*, 'FlowFromReturnLine=', v
#endif
end subroutine

logical function Get_FlowFromReturnLine()
implicit none
Get_FlowFromReturnLine = data%Equipments%UnityOutputs%FlowFromReturnLine
end function



subroutine Set_FlowFromKelly(v)
implicit none
real, intent (in) :: v
data%Equipments%UnityOutputs%FlowFromKelly = v
#ifdef deb
print*, 'FlowFromKelly=', v
#endif
end subroutine

real function Get_FlowFromKelly()
implicit none
Get_FlowFromKelly = data%Equipments%UnityOutputs%FlowFromKelly
end function





subroutine Set_FlowFromFillupHead(v)
implicit none
real, intent (in) :: v
data%Equipments%UnityOutputs%FlowFromFillupHead = v
#ifdef deb
print*, 'FlowFromFillupHead=', v
#endif
end subroutine

real function Get_FlowFromFillupHead()
implicit none
Get_FlowFromFillupHead = data%Equipments%UnityOutputs%FlowFromFillupHead
end function






subroutine Set_FlowKellyDisconnect(v)
implicit none
logical, intent (in) :: v
data%Equipments%UnityOutputs%FlowKellyDisconnect = v
#ifdef deb
print*, 'FlowKellyDisconnect=', v
#endif
end subroutine

logical function Get_FlowKellyDisconnect()
implicit none
Get_FlowKellyDisconnect = data%Equipments%UnityOutputs%FlowKellyDisconnect
end function




subroutine Set_FlowPipeDisconnect(v)
implicit none
logical, intent (in) :: v
data%Equipments%UnityOutputs%FlowPipeDisconnect = v
#ifdef deb
print*, 'FlowPipeDisconnect=', v
#endif
end subroutine

logical function Get_FlowPipeDisconnect()
implicit none
Get_FlowPipeDisconnect = data%Equipments%UnityOutputs%FlowPipeDisconnect
end function

subroutine Set_BlowoutFromStringPercent(v)
implicit none
real(8), intent (in) :: v
data%Equipments%UnityOutputs%BlowoutFromStringPercent = v
#ifdef deb
print*, 'BlowoutFromStringPercent=', v
#endif
end subroutine

real(8) function GetBlowoutFromStringPercent()
implicit none
GetBlowoutFromStringPercent = data%Equipments%UnityOutputs%BlowoutFromStringPercent
end function

subroutine Calc_KellyHoseVibrationRate(spm1, spm2)
use CScaleRange
implicit none
real(8), intent (in) :: spm1, spm2
real :: total
total = (spm1 + spm2)/2
data%Equipments%UnityOutputs%KellyHoseVibrationRate = ScaleRange(total, 0.0, 10.0, 0.0, 120.0)
#ifdef deb
print*, 'KellyHoseVibrationRate=', data%Equipments%UnityOutputs%KellyHoseVibrationRate
#endif
end subroutine

real(8) function GetKellyHoseVibrationRate()
implicit none
GetKellyHoseVibrationRate = data%Equipments%UnityOutputs%KellyHoseVibrationRate
end function

subroutine Set_Pedal(v)
implicit none
real(8), intent (in) :: v
data%Equipments%UnityOutputs%Pedal = v
#ifdef deb
print*, 'Pedal=', v
#endif
end subroutine

real(8) function GetPedal()
implicit none
GetPedal = data%Equipments%UnityOutputs%Pedal
end function

subroutine Set_FlowRate(v)
implicit none
real(8), intent (in) :: v
data%Equipments%UnityOutputs%FlowRate = v
#ifdef deb
print*, 'FlowRate=', v
#endif
end subroutine


real(8) function GetFlowRate()
implicit none
GetFlowRate = data%Equipments%UnityOutputs%FlowRate
end function
subroutine Set_RotaryRpm(v)
implicit none
real(8), intent (in) :: v
data%Equipments%UnityOutputs%RotaryRpm = v
#ifdef deb
print*, 'RotaryRpm=', v
#endif
end subroutine

real(8) function GetRotaryRpm()
implicit none
GetRotaryRpm = data%Equipments%UnityOutputs%RotaryRpm
end function

end module UnityModule

+ 277
- 0
CSharp/OperationScenarios/Unity/UnityModule.i90 查看文件

@@ -0,0 +1,277 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/OperationScenarios/Unity/UnityModule.f90"
module UnityModule
use SimulationVariables
implicit none
contains
subroutine UnityInputsFromJson(parent)
use json_module,IK =>json_ik
type(json_value),pointer :: parent
type(json_core) :: json
type(json_value),pointer :: p,pval

call json%get(parent,'Unity',p)

call json%get(p,'ElevatorConnectionPossible',pval)
call json%get(pval,data%Equipments%UnityInputs%ElevatorConnectionPossible)
call json%get(p,'JointConnectionPossible',pval)
call json%get(pval,data%Equipments%UnityInputs%JointConnectionPossible)
call json%get(p,'IsKellyBushingSetInTable',pval)
call json%get(pval,data%Equipments%UnityInputs%IsKellyBushingSetInTable)
call json%get(p,'ElevatorPickup',pval)
call json%get(pval,data%Equipments%UnityInputs%ElevatorPickup)
call json%get(p,'NearFloorPosition',pval)
call json%get(pval,data%Equipments%UnityInputs%NearFloorPosition)
call json%get(p,'SingleSetInMouseHole',pval)
call json%get(pval,data%Equipments%UnityInputs%SingleSetInMouseHole)
call json%get(p,'TdsConnectionPossible',pval)
call json%get(pval,data%Equipments%UnityInputs%TdsConnectionPossible)
call json%get(p,'TdsStemIn',pval)
call json%get(pval,data%Equipments%UnityInputs%TdsStemIn)
end subroutine

subroutine UnityOutputsToJson(parent)
type(json_value),pointer :: parent
type(json_core) :: json
type(json_value),pointer :: p

! 1. create new node
call json%create_object(p,'Unity')
! 2. add member of data type to new node
call json%add(p,"KellyHoseVibrationRate",data%Equipments%UnityOutputs%KellyHoseVibrationRate)
call json%add(p,"BlowoutFromStringPercent",data%Equipments%UnityOutputs%BlowoutFromStringPercent)
call json%add(p,"Pedal",data%Equipments%UnityOutputs%Pedal)
call json%add(p,"FlowRate",data%Equipments%UnityOutputs%FlowRate)
call json%add(p,"RotaryRpm",data%Equipments%UnityOutputs%RotaryRpm)
call json%add(p,"BlowoutFromString",data%Equipments%UnityOutputs%BlowoutFromString)
call json%add(p,"BlowoutFromAnnular",data%Equipments%UnityOutputs%BlowoutFromAnnular)
call json%add(p,"FlowFromReturnLine",data%Equipments%UnityOutputs%FlowFromReturnLine)
call json%add(p,"FlowFromKelly",data%Equipments%UnityOutputs%FlowFromKelly)
call json%add(p,"FlowFromFillupHead",data%Equipments%UnityOutputs%FlowFromFillupHead)
call json%add(p,"FlowKellyDisconnect",data%Equipments%UnityOutputs%FlowKellyDisconnect)
call json%add(p,"FlowPipeDisconnect",data%Equipments%UnityOutputs%FlowPipeDisconnect)
! 3. add new node to parent
call json%add(parent,p)
end subroutine

logical function Get_ElevatorPickup()
Get_ElevatorPickup = data%Equipments%UnityInputs%ElevatorPickup
end function

logical function Get_IsKellyBushingSetInTable()
Get_IsKellyBushingSetInTable = data%Equipments%UnityInputs%IsKellyBushingSetInTable
end function
logical function Get_JointConnectionPossible()
Get_JointConnectionPossible = data%Equipments%UnityInputs%JointConnectionPossible
end function
logical function Get_ElevatorConnectionPossible()
implicit none
Get_ElevatorConnectionPossible = data%Equipments%UnityInputs%ElevatorConnectionPossible
end function
logical function Get_NearFloorPosition()
Get_NearFloorPosition = data%Equipments%UnityInputs%NearFloorPosition
end function
subroutine Set_NearFloorPosition(v)
implicit none
logical, intent(in) :: v
! #ifdef ExcludeExtraChanges
! if(data%Equipments%UnityInputs%NearFloorPosition == v) return
! #endif
data%Equipments%UnityInputs%NearFloorPosition = v
!**call data%Equipments%UnityInputs%OnNearFloorPositionChange%RunAll()
if(logging>4) then
print*, 'NearFloorPosition =', data%Equipments%UnityInputs%NearFloorPosition
endif
end subroutine

logical function Get_SingleSetInMouseHole()
Get_SingleSetInMouseHole = data%Equipments%UnityInputs%SingleSetInMouseHole
end function

logical function Get_TdsConnectionPossible()
Get_TdsConnectionPossible = data%Equipments%UnityInputs%TdsConnectionPossible
end function

logical function Get_TdsStemIn()
Get_TdsStemIn = data%Equipments%UnityInputs%TdsStemIn
end function

subroutine Set_BlowoutFromString(v)
implicit none
logical, intent (in) :: v
data%Equipments%UnityOutputs%BlowoutFromString = v
# 105

end subroutine

logical function Get_BlowoutFromString()
implicit none
Get_BlowoutFromString = data%Equipments%UnityOutputs%BlowoutFromString
end function

subroutine Set_BlowoutFromAnnular(v)
implicit none
logical, intent (in) :: v
data%Equipments%UnityOutputs%BlowoutFromAnnular = v
# 119

end subroutine

logical function Get_BlowoutFromAnnular()
implicit none
Get_BlowoutFromAnnular = data%Equipments%UnityOutputs%BlowoutFromAnnular
end function





subroutine Set_FlowFromReturnLine(v)
implicit none
logical, intent (in) :: v
data%Equipments%UnityOutputs%FlowFromReturnLine = v
# 137

end subroutine

logical function Get_FlowFromReturnLine()
implicit none
Get_FlowFromReturnLine = data%Equipments%UnityOutputs%FlowFromReturnLine
end function



subroutine Set_FlowFromKelly(v)
implicit none
real, intent (in) :: v
data%Equipments%UnityOutputs%FlowFromKelly = v
# 153

end subroutine

real function Get_FlowFromKelly()
implicit none
Get_FlowFromKelly = data%Equipments%UnityOutputs%FlowFromKelly
end function





subroutine Set_FlowFromFillupHead(v)
implicit none
real, intent (in) :: v
data%Equipments%UnityOutputs%FlowFromFillupHead = v
# 171

end subroutine

real function Get_FlowFromFillupHead()
implicit none
Get_FlowFromFillupHead = data%Equipments%UnityOutputs%FlowFromFillupHead
end function






subroutine Set_FlowKellyDisconnect(v)
implicit none
logical, intent (in) :: v
data%Equipments%UnityOutputs%FlowKellyDisconnect = v
# 190

end subroutine

logical function Get_FlowKellyDisconnect()
implicit none
Get_FlowKellyDisconnect = data%Equipments%UnityOutputs%FlowKellyDisconnect
end function




subroutine Set_FlowPipeDisconnect(v)
implicit none
logical, intent (in) :: v
data%Equipments%UnityOutputs%FlowPipeDisconnect = v
# 207

end subroutine

logical function Get_FlowPipeDisconnect()
implicit none
Get_FlowPipeDisconnect = data%Equipments%UnityOutputs%FlowPipeDisconnect
end function

subroutine Set_BlowoutFromStringPercent(v)
implicit none
real(8), intent (in) :: v
data%Equipments%UnityOutputs%BlowoutFromStringPercent = v
# 221

end subroutine

real(8) function GetBlowoutFromStringPercent()
implicit none
GetBlowoutFromStringPercent = data%Equipments%UnityOutputs%BlowoutFromStringPercent
end function

subroutine Calc_KellyHoseVibrationRate(spm1, spm2)
use CScaleRange
implicit none
real(8), intent (in) :: spm1, spm2
real :: total
total = (spm1 + spm2)/2
data%Equipments%UnityOutputs%KellyHoseVibrationRate = ScaleRange(total, 0.0, 10.0, 0.0, 120.0)
# 238

end subroutine

real(8) function GetKellyHoseVibrationRate()
implicit none
GetKellyHoseVibrationRate = data%Equipments%UnityOutputs%KellyHoseVibrationRate
end function

subroutine Set_Pedal(v)
implicit none
real(8), intent (in) :: v
data%Equipments%UnityOutputs%Pedal = v
# 252

end subroutine

real(8) function GetPedal()
implicit none
GetPedal = data%Equipments%UnityOutputs%Pedal
end function

subroutine Set_FlowRate(v)
implicit none
real(8), intent (in) :: v
data%Equipments%UnityOutputs%FlowRate = v
# 266

end subroutine


real(8) function GetFlowRate()
implicit none
GetFlowRate = data%Equipments%UnityOutputs%FlowRate
end function
subroutine Set_RotaryRpm(v)
implicit none
real(8), intent (in) :: v
data%Equipments%UnityOutputs%RotaryRpm = v
# 280

end subroutine

real(8) function GetRotaryRpm()
implicit none
GetRotaryRpm = data%Equipments%UnityOutputs%RotaryRpm
end function

end module UnityModule

+ 1
- 0
CSharp/OperationScenarios/UnitySignals/CTdsSpineEnum.f90 查看文件

@@ -1,5 +1,6 @@
module CTdsSpineEnum
use OperationScenariosModule
use UnityModule
use UnitySignalsModule !for CTdsConnectionModesEnum, only:Get_TdsConnectionModes
implicit none
contains


+ 3
- 2
CSharp/OperationScenarios/UnitySignals/CTdsSpineEnum.i90 查看文件

@@ -1,6 +1,7 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/OperationScenarios/UnitySignals/CTdsSpineEnum.f90"
module CTdsSpineEnum
use OperationScenariosModule
use UnityModule
use UnitySignalsModule !for CTdsConnectionModesEnum, only:Get_TdsConnectionModes
implicit none
contains
@@ -9,7 +10,7 @@ module CTdsSpineEnum
implicit none
if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
# 13
# 14


!TOPDRIVE-CODE=83
@@ -47,7 +48,7 @@ module CTdsSpineEnum
if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
# 52
# 53

endif


+ 1
- 0
CSharp/OperationScenarios/UnitySignals/UnitySignals.f90 查看文件

@@ -433,6 +433,7 @@ end function
subroutine Evaluate_TdsConnectionModes()
use CUnityInputs
use SimulationVariables
use UnityModule
implicit none
if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then


+ 1
- 0
CSharp/OperationScenarios/UnitySignals/UnitySignals.i90 查看文件

@@ -423,6 +423,7 @@ end function
subroutine Evaluate_TdsConnectionModes()
use CUnityInputs
use SimulationVariables
use UnityModule
implicit none
if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then


+ 143
- 0
CSharp/OperationScenarios/UnitySignals/UnitySignalsVariables.i90 查看文件

@@ -0,0 +1,143 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/OperationScenarios/UnitySignals/UnitySignalsVariables.f90"
module UnitySignalVariables
! use CVoidEventHandlerCollection
! use CIntegerEventHandlerCollection

type:: UnitySignalsType
integer :: MudBucket = 0
integer :: Elevator = 0
integer :: FillupHead = 0
integer :: Ibop = 0
integer :: Kelly = 0
integer :: MouseHole = 0
integer :: OperationCondition = 0
integer :: SafetyValve = 0
integer :: operation = 0
integer :: Slips = 0
integer :: Slips_S = 0
integer :: Swing = 0
integer :: Swing_S = 0
integer :: TdsBackupClamp = 0
integer :: TdsSpine = 0
integer :: TdsSwing = 0
integer :: TdsTong = 0
integer :: Tong = 0
integer :: Tong_S = 0
integer :: TdsConnectionModes = 0
integer :: TdsElevatorModes = 0

end type UnitySignalsType

enum, bind(c)
enumerator TONG_NEUTRAL
enumerator TONG_BREAKOUT_BEGIN
enumerator TONG_BREAKOUT_END
enumerator TONG_MAKEUP_BEGIN
enumerator TONG_MAKEUP_END

enumerator TDS_SWING_NEUTRAL
enumerator TDS_SWING_OFF_BEGIN
enumerator TDS_SWING_OFF_END
enumerator TDS_SWING_DRILL_BEGIN
enumerator TDS_SWING_DRILL_END
enumerator TDS_SWING_TILT_BEGIN
enumerator TDS_SWING_TILT_END

enumerator TDS_SPINE_NEUTRAL
enumerator TDS_SPINE_CONNECT_BEGIN
enumerator TDS_SPINE_CONNECT_END
enumerator TDS_SPINE_DISCONNECT_BEGIN
enumerator TDS_SPINE_DISCONNECT_END

enumerator BACKUP_CLAMP_OFF_END
enumerator BACKUP_CLAMP_OFF_BEGIN
enumerator BACKUP_CLAMP_FW_BEGIN
enumerator BACKUP_CLAMP_FW_END

enumerator SWING_NEUTRAL
enumerator SWING_MOUSE_HOLE_BEGIN
enumerator SWING_MOUSE_HOLE_END
enumerator SWING_RAT_HOLE_BEGIN
enumerator SWING_RAT_HOLE_END
enumerator SWING_WELL_BEGIN
enumerator SWING_WELL_END
end enum
enum, bind(c)
enumerator TDS_TONG_BREAKOUT_END
enumerator TDS_TONG_BREAKOUT_BEGIN
enumerator TDS_TONG_MAKEUP_BEGIN
enumerator TDS_TONG_MAKEUP_END

enumerator SAFETY_VALVE_NEUTRAL
enumerator SAFETY_VALVE_REMOVE
enumerator SAFETY_VALVE_INSTALL

end enum
enum, bind(c)
enumerator OPERATION_DRILL
enumerator OPERATION_TRIP
end enum
enum, bind(c)
enumerator SLIPS_NEUTRAL
enumerator SLIPS_SET_BEGIN
enumerator SLIPS_SET_END
enumerator SLIPS_UNSET_BEGIN
enumerator SLIPS_UNSET_END

enumerator MOUSE_HOLE_NEUTRAL
enumerator MOUSE_HOLE_FILL
enumerator MOUSE_HOLE_EMPTY

enumerator KELLY_NEUTRAL
enumerator KELLY_INSTALL
enumerator KELLY_REMOVE

!enumerator FILLUP_HEAD_NEUTRAL
enumerator FILLUP_HEAD_REMOVE
enumerator FILLUP_HEAD_INSTALL

enumerator ELEVATOR_NEUTRAL
enumerator ELEVATOR_LATCH_STRING_BEGIN
enumerator ELEVATOR_LATCH_STRING_END
enumerator ELEVATOR_UNLATCH_STRING_BEGIN
enumerator ELEVATOR_UNLATCH_STRING_END
enumerator ELEVATOR_LATCH_STAND_BEGIN
enumerator ELEVATOR_LATCH_STAND_END
enumerator ELEVATOR_UNLATCH_STAND_BEGIN
enumerator ELEVATOR_UNLATCH_STAND_END
enumerator ELEVATOR_LATCH_SINGLE_BEGIN
enumerator ELEVATOR_LATCH_SINGLE_END
enumerator ELEVATOR_UNLATCH_SINGLE_BEGIN
enumerator ELEVATOR_UNLATCH_SINGLE_END

!enumerator MUD_BUCKET_NEUTRAL
enumerator MUD_BUCKET_REMOVE
enumerator MUD_BUCKET_INSTALL

!enumerator IBOP_NEUTRAL
enumerator IBOP_REMOVE
enumerator IBOP_INSTALL

enumerator TDS_CONNECTION_NOTHING
enumerator TDS_CONNECTION_STRING
enumerator TDS_CONNECTION_SPINE
enumerator TDS_ELEVATOR_CONNECTION_NOTHING
enumerator TDS_ELEVATOR_CONNECTION_STRING
enumerator TDS_ELEVATOR_CONNECTION_SINGLE
enumerator TDS_ELEVATOR_CONNECTION_STAND
enumerator TDS_ELEVATOR_LATCH_STRING
enumerator TDS_ELEVATOR_LATCH_SINGLE
enumerator TDS_ELEVATOR_LATCH_STAND
end enum

contains

end module UnitySignalVariables

+ 159
- 0
Common/DynamicLogicalArray.i90 查看文件

@@ -0,0 +1,159 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/Common/DynamicLogicalArray.f90"
module DynamicLogicalArray
implicit none
public
type, public :: DynamicLogicalArrayType
logical, allocatable :: Array(:)
contains
procedure :: First => First
procedure :: Last => Last
procedure :: Length => Length
procedure :: Add => Add
procedure :: AddToFirst => AddToFirst
procedure :: AddTo => AddTo
procedure :: Remove => Remove
procedure :: Empty => Empty
end type DynamicLogicalArrayType
private::First,Last,Length

contains
logical function First(this)
implicit none
class(DynamicLogicalArrayType), intent(in) :: this
if(allocated(this%Array) .and. size(this%Array) > 0) then
First = this%Array(1)
return
end if
First = 0
end function
logical function Last(this)
implicit none
class(DynamicLogicalArrayType), intent(in) :: this
if(allocated(this%Array) .and. size(this%Array) > 0) then
Last = this%Array(size(this%Array))
return
end if
Last = 0
end function
integer function Length(this)
implicit none
class(DynamicLogicalArrayType), intent(in) :: this
if(allocated(this%Array)) then
Length = size(this%Array)
return
end if
Length = 0
end function
subroutine AddToFirst(this, value)
implicit none
class(DynamicLogicalArrayType), intent(inout) :: this
logical, allocatable :: tempArr(:)
logical, intent(in) :: value
integer :: i, isize
if(allocated(this%Array)) then
isize = size(this%Array)
allocate(tempArr(isize+1))
tempArr(1) = value
do i=2,isize+1
tempArr(i) = this%Array(i-1)
end do
deallocate(this%Array)
call move_alloc(tempArr, this%Array)
else
allocate(this%Array(1))
this%Array(1) = value
end if
end subroutine
subroutine AddTo(this, index, value)
implicit none
class(DynamicLogicalArrayType), intent(inout) :: this
logical, allocatable :: tempArr(:)
integer, intent(in) :: index
logical, intent(in) :: value
integer :: i, isize
if(index <= 0) return
if(index > size(this%Array)) then
call this%Add(value)
return
endif
if(allocated(this%Array)) then
isize = size(this%Array)
allocate(tempArr(isize+1))
tempArr(:index-1) = this%Array(:index-1)
tempArr(index) = value
tempArr(index+1:) = this%Array(index:)
deallocate(this%Array)
call move_alloc(tempArr, this%Array)
end if
end subroutine
subroutine Add(this, value)
implicit none
class(DynamicLogicalArrayType), intent(inout) :: this
logical, allocatable :: tempArr(:)
logical, intent(in) :: value
integer :: i, isize
if(allocated(this%Array)) then
isize = size(this%Array)
allocate(tempArr(isize+1))
do i=1,isize
tempArr(i) = this%Array(i)
end do
tempArr(isize+1) = value
deallocate(this%Array)
call move_alloc(tempArr, this%Array)
else
allocate(this%Array(1))
this%Array(1) = value
end if
end subroutine
subroutine Empty(this)
implicit none
class(DynamicLogicalArrayType), intent(inout) :: this
if(allocated(this%Array)) deallocate(this%Array)
end subroutine
subroutine Remove(this, index)
implicit none
class(DynamicLogicalArrayType), intent(inout) :: this
integer, intent(in) :: index
logical, allocatable :: tempArr(:)
integer :: i
logical :: found
if(index <= 0 .or. index > size(this%Array)) return
if(.not.allocated(this%Array))return
allocate(tempArr(size(this%Array)-1))
found = .false.
do i=1, size(this%Array)
if(i==index) then
found = .true.
cycle
end if
if(found) then
tempArr(i-1) = this%Array(i)
else
tempArr(i) = this%Array(i)
endif
end do
deallocate(this%Array)
call move_alloc(tempArr, this%Array)
end subroutine
end module DynamicLogicalArray

+ 2
- 1
Equipments/BopStack/LOSS_INPUTS.f90 查看文件

@@ -1,5 +1,6 @@
SUBROUTINE DEALLOCATE_ARRAYS()
use SimulationVariables
use UnityModule
implicit none
!===========================================================================
! RAMLINE MINOR LOSSES INPUT
@@ -553,7 +554,7 @@ data%State%Pumps%DELTAV_AIR=data%State%Pumps%QAIR*data%State%RamLine%DeltaT_BOP/
USE CEquipmentsConstants
! use CSimulationVariables
use SimulationVariables !@
use CUnityOutputs
use UnityModule
implicit none
integer ramtype, I
real H_RAMBOP


+ 2
- 1
Equipments/BopStack/LOSS_INPUTS.i90 查看文件

@@ -1,6 +1,7 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/Equipments/BopStack/LOSS_INPUTS.f90"
SUBROUTINE DEALLOCATE_ARRAYS()
use SimulationVariables
use UnityModule
implicit none
!===========================================================================
! RAMLINE MINOR LOSSES INPUT
@@ -554,7 +555,7 @@ data%State%Pumps%DELTAV_AIR=data%State%Pumps%QAIR*data%State%RamLine%DeltaT_BOP/
USE CEquipmentsConstants
! use CSimulationVariables
use SimulationVariables !@
use CUnityOutputs
use UnityModule
implicit none
integer ramtype, I
real H_RAMBOP


+ 2
- 4
Equipments/MudSystem/Circulation_Code_Select.f90 查看文件

@@ -1,15 +1,13 @@
subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver
use KickVARIABLESModule
USE MudSystemVARIABLES
use SimulationVariables !@@@
use SimulationVariables !@@@
USE TD_DrillStemComponents
Use CUnityInputs
Use CUnityOutputs
use OperationScenariosModule
use UTUBEVARSModule
use sROP_Variables
use PressureDisplayVARIABLESModule
use UnityModule



+ 147
- 0
Equipments/MudSystem/Circulation_Code_Select.i90 查看文件

@@ -0,0 +1,147 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/Equipments/MudSystem/Circulation_Code_Select.f90"
subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver
use KickVARIABLESModule
USE MudSystemVARIABLES
use SimulationVariables !@@@
USE TD_DrillStemComponents
use OperationScenariosModule
use UTUBEVARSModule
use sROP_Variables
use PressureDisplayVARIABLESModule
use UnityModule

implicit none
Integer i,KickNumber
!NewInfluxNumber = NoGasPocket
data%State%MudSystem%Flow_timeCounter= data%State%MudSystem%Flow_timeCounter+1
!if (ChokePanelStrokeResetSwitch == 1) then
! Flow_timeCounter= 0
!endif
!write(*,*) 'Flow_timeCounter' , Flow_timeCounter
!===========================Shoe Lost===============================

call ShoeLostSub
!===================================================================
data%State%MudSystem%iLoc= 1 ! will be changed in KickFlux and Migration or Pump and TripIn (save OP Mud data)
!KickMigration_2SideBit= .false.
Call Set_FlowPipeDisconnect(.false.)
Call Set_FlowKellyDisconnect(.false.)
call ElementsCreation

if (data%State%MUD(8)%Q > 0.0) call FillingWell_By_BellNipple ! Filling Well Through BellNipple ( Path j11 )
!if (data%State%MUD(10)%Q > 0.0) call FillingWell_By_Pumps ! Filling Well Through Pumps ( Path j19 )
!write(*,*) 'TD_RemoveVolume,Get_JointConnectionPossible=' , TD_RemoveVolume,Get_JointConnectionPossible()
if (data%State%TD_Vol%RemoveVolume > 0.) call DisconnectingPipe !! .and. Get_JointConnectionPossible() == .false.) call DisconnectingPipe
IF (KickVARIABLES%KickFlux .AND. NOT(KickVARIABLES%KickOffBottom)) THEN
call Kick_Influx
endif
IF ( data%State%MudSystem%NewInfluxNumber > 0 ) THEN
call Kick_Migration
endif
! ============================ must be after migration ==============================

DO KickNumber= data%State%MudSystem%NewInfluxNumber-KickVARIABLES%NoGasPocket+1 , data%State%MudSystem%NewInfluxNumber
! FINDING NEW KICK LOCATIONS:
data%State%MudSystem%Ann_KickLoc= 0
data%State%MudSystem%Op_KickLoc= 0
data%State%MudSystem%ChokeLine_KickLoc= 0
do i = 1, data%State%MudSystem%Ann_MudOrKick%Length ()
if (data%State%MudSystem%Ann_MudOrKick%Array(i) == KickNumber) then
data%State%MudSystem%Ann_KickLoc = i
exit
endif
end do

do i = 1, data%State%MudSystem%Op_MudOrKick%Length ()
if (data%State%MudSystem%Op_MudOrKick%Array(i) == KickNumber) then
data%State%MudSystem%Op_KickLoc = i
exit
endif
end do
do i = 1, data%State%MudSystem%ChokeLine_MudOrKick%Length ()
if (data%State%MudSystem%ChokeLine_MudOrKick%Array(i) == KickNumber) then
data%State%MudSystem%ChokeLine_KickLoc = i
exit
endif
end do
! ============================ must be after migration-end ===========================
IF (ALLOCATED(GasPocketWeight%Array) .and. KickNumber == data%State%MudSystem%NewInfluxNumber .AND. NOT(KickVARIABLES%KickOffBottom) .AND. data%State%MudSystem%WellHeadIsOpen) THEN

cycle
ELSE IF (ALLOCATED(GasPocketWeight%Array)) THEN
if (((GasPocketDeltaVol%Array(data%State%MudSystem%NewInfluxNumber - KickNumber + 1) > 0.0 .AND. data%State%MudSystem%WellHeadIsOpen) .or. data%State%MudSystem%Kickexpansion_DueToMudLost) ) call Kick_Expansion
if ((GasPocketDeltaVol%Array(data%State%MudSystem%NewInfluxNumber - KickNumber + 1) < 0.0 ) .OR. data%State%MudSystem%WellHeadIsOpen == .FALSE.) CALL Kick_Contraction

ENDIF
ENDDO
data%State%MudSystem%KickNumber = KickNumber
data%State%MudSystem%LostInTripOutIsDone= .false.
if( data%State%MudSystem%DeltaVolumeOp >= 0.0 .and. Get_KellyConnection()==KELLY_CONNECTION_STRING) then
!write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp
call Pump_and_TripIn
elseif (data%State%MudSystem%DeltaVolumeOp < 0.0) then
! when we have Utube and tripping out simultaneously, it uses "TripOut_and_Pump" subroutine, and then Utube code is done
! "Utube" and "Pump_and_TripIn" subroutines, not to be used simultaneously because "Utube" code supports trip in
call TripOut_and_Pump
endif
data%State%MudSystem%WellOutletDensity= data%State%MudSystem%Ann_Density%Last() ! (ppg) used in MudSystem
if (data%State%MUD(4)%Q > 0.) then ! ( j4 > 0 ) ! THIS CIRCULATION CODE IS JUST FOR LINE J4, AND NOT NEEDED FOR LINE J18
call ChokeLineMud
endif
call Choke_GasSound
!WRITE(*,*) 'CIRCU-Ann_Saved_MudDischarged_Volume' , Ann_Saved_MudDischarged_Volume
!****Utube is called in Plot Subroutine****
Call Instructor_CirculationMud_Edit
call PlotFinalMudElements
data%State%MudSystem%MudChecked= .true.
data%State%MudSystem%UtubePossibility= .true.
!WRITE(*,*) '***********************************************************************'
end subroutine CirculationCodeSelect

+ 1
- 3
Equipments/MudSystem/Disconnecting_Pipe.f90 查看文件

@@ -3,9 +3,7 @@ subroutine DisconnectingPipe ! is called in subroutine CirculationCodeSelect
Use GeoElements_FluidModule
USE CMudPropertiesVariables
USE MudSystemVARIABLES
use SimulationVariables !@@@
use SimulationVariables
use SimulationVariables !@
! !use CTanks
!@use ConfigurationVariables, TripTankVolume2 => data%Equipments%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity
USE sROP_Other_Variables
@@ -13,7 +11,7 @@ use SimulationVariables !@@@
use KickVARIABLESModule
USE TD_DrillStemComponents
use OperationScenariosModule
Use CUnityOutputs
Use UnityModule
USE CManifolds
implicit none


+ 1
- 3
Equipments/MudSystem/Disconnecting_Pipe.i90 查看文件

@@ -4,9 +4,7 @@ subroutine DisconnectingPipe ! is called in subroutine CirculationCodeSelect
Use GeoElements_FluidModule
USE CMudPropertiesVariables
USE MudSystemVARIABLES
use SimulationVariables !@@@
use SimulationVariables
use SimulationVariables !@
! !use CTanks
!@use ConfigurationVariables, TripTankVolume2 => data%Equipments%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity
USE sROP_Other_Variables
@@ -14,7 +12,7 @@ use SimulationVariables !@@@
use KickVARIABLESModule
USE TD_DrillStemComponents
use OperationScenariosModule
Use CUnityOutputs
Use UnityModule
USE CManifolds
implicit none


+ 1
- 2
Equipments/MudSystem/MudSystem.f90 查看文件

@@ -1,7 +1,6 @@
module MudSystemModule
USE MudSystemVARIABLES
use SimulationVariables !@@@
use PressureDisplayVARIABLESModule
USE FricPressDropVarsModule
USE Fluid_Flow_Startup_Vars
@@ -9,7 +8,6 @@ use SimulationVariables !@@@
USE CManifolds
use CPumpsVariables
use CPumps
USE CUnityOutputs
use CWarnings
use DynamicIntegerArray,only: DynamicIntegerArrayType
use CError
@@ -18,6 +16,7 @@ use SimulationVariables !@@@
use SimulationVariables
use CStudentStationVariables !, PitGainLossReset=>PitGainLossZero
use MudPropertiesModule
use UnityModule
implicit none


+ 1
- 2
Equipments/MudSystem/MudSystem.i90 查看文件

@@ -2,7 +2,6 @@
module MudSystemModule
USE MudSystemVARIABLES
use SimulationVariables !@@@
use PressureDisplayVARIABLESModule
USE FricPressDropVarsModule
USE Fluid_Flow_Startup_Vars
@@ -10,7 +9,6 @@ use SimulationVariables !@@@
USE CManifolds
use CPumpsVariables
use CPumps
USE CUnityOutputs
use CWarnings
use DynamicIntegerArray,only: DynamicIntegerArrayType
use CError
@@ -19,6 +17,7 @@ use SimulationVariables !@@@
use SimulationVariables
use CStudentStationVariables !, PitGainLossReset=>PitGainLossZero
use MudPropertiesModule
use UnityModule
implicit none


+ 1
- 2
Equipments/MudSystem/MudSystemStartup.f90 查看文件

@@ -1,13 +1,12 @@
SUBROUTINE NormalCirculation_StartUp() ! is called in module FluidFlowMain
USE MudSystemVARIABLES
use SimulationVariables !@@@
use CTanks
use SimulationVariables
USE CMudPropertiesVariables
Use GeoElements_FluidModule
use KickVARIABLESModule
Use CUnityOutputs
Use UnityModule
Use CShoeVariables
use SimulationVariables


+ 1
- 2
Equipments/MudSystem/MudSystemStartup.i90 查看文件

@@ -2,13 +2,12 @@
SUBROUTINE NormalCirculation_StartUp() ! is called in module FluidFlowMain
USE MudSystemVARIABLES
use SimulationVariables !@@@
use CTanks
use SimulationVariables
USE CMudPropertiesVariables
Use GeoElements_FluidModule
use KickVARIABLESModule
Use CUnityOutputs
Use UnityModule
Use CShoeVariables
use SimulationVariables


+ 1
- 4
Equipments/RotaryTable/RTable_INPUTS.f90 查看文件

@@ -2,15 +2,12 @@ subroutine RTable_INPUTS
use CDrillingConsoleVariables
use SimulationVariables
use SimulationVariables
! use CSimulationVariables
use UnitySignalsModule
! use CTdsElevatorModesEnumVariables
use CHoistingVariables
use SimulationVariables
use SimulationVariables !@
use TD_DrillStemComponents
use CUnityInputs
use UnityModule
use CWarnings
use UnitySignalVariables
use UnitySignalsModule


+ 1
- 4
Equipments/RotaryTable/RTable_Inputs.i90 查看文件

@@ -3,15 +3,12 @@ subroutine RTable_INPUTS
use CDrillingConsoleVariables
use SimulationVariables
use SimulationVariables
! use CSimulationVariables
use UnitySignalsModule
! use CTdsElevatorModesEnumVariables
use CHoistingVariables
use SimulationVariables
use SimulationVariables !@
use TD_DrillStemComponents
use CUnityInputs
use UnityModule
use CWarnings
use UnitySignalVariables
use UnitySignalsModule


+ 4
- 4
Makefile 查看文件

@@ -54,7 +54,8 @@ VPATH = \
TorqueDrag/TD_Forces/TD_ViscousDragForce \
TorqueDrag/TD_Modules \
TorqueDrag/TD_StartUp \
Redis
Redis \
.
FC = ifort
TOP_DIR = .
@@ -263,6 +264,7 @@ SRCS_F =\
Equipments/TopDrive/TopDrive_Outputs.f90 \
Equipments/Drawworks/DWFixModeMotion.f90 \
CSharp/Equipments/ControlPanels/CBopControlPanel.f90 \
CSharp/OperationScenarios/Unity/UnityModule.f90 \
CSharp/OperationScenarios/UnitySignals/UnitySignals.f90 \
CSharp/BasicInputs/RigSpecifications/CPumps.f90 \
CSharp/Equipments/ControlPanels/CChokeManifold.f90 \
@@ -377,9 +379,7 @@ SRCS_F =\
TorqueDrag/TD_MainCalculations.f90 \
FluidFlow/Well_Pressure_Data_Transfer.f90 \
Equipments/MudSystem/Plot_Final_Mud_Elements.f90 \
FluidFlow/Fluid_Flow_Solver.f90\
# SimulationCore2.f90 \
FluidFlow/Fluid_Flow_Solver.f90
OBJS_T1 = $(patsubst %.f90,%.o,$(SRCS_F))


+ 20
- 21
Redis/Redis_Interface.f90 查看文件

@@ -33,31 +33,30 @@ Module RedisInterface
contains
SUBROUTINE initConnection(configFilename,status)
use json_module
SUBROUTINE initConnection(address,port,password, datakey,status)
use iso_c_binding, only: c_null_char,c_char
character(len=*) :: configFilename
! use json_module
character(len=*) :: password,address,datakey
integer::port,status
type(json_file) :: jsonfile
type(json_value),pointer :: jsonvalue,jsonvalue2
type(json_core) :: jsoncore
character(len=:),allocatable :: password,address,datakey
character(len=:),allocatable::c_address,c_password,c_datakey
! type(json_file) :: jsonfile
! type(json_value),pointer :: jsonvalue,jsonvalue2
! type(json_core) :: jsoncore
call jsonfile%initialize()
print *,"Initilized: simulation with ",configFilename
call jsonfile%load_file(configFilename);
if (jsonfile%failed()) then
print *,"can not open config file: ",configFilename ;
stop
endif
! print *,"file read"
call jsonfile%json_file_get_root(jsonvalue)
call jsoncore%get(jsonvalue,'redis',jsonvalue2)
call jsoncore%get(jsonvalue2,"address",address);
call jsoncore%get(jsonvalue2,"port",port);
call jsoncore%get(jsonvalue2,"password",password);
call jsoncore%get(jsonvalue2,"datakey",datakey);
! call jsonfile%initialize()
! print *,"Initilized: simulation with ",configFilename
! call jsonfile%load_file(configFilename);
! if (jsonfile%failed()) then
! print *,"can not open config file: ",configFilename ;
! stop
! endif
! ! print *,"file read"
! call jsonfile%json_file_get_root(jsonvalue)
! call jsoncore%get(jsonvalue,'redis',jsonvalue2)
! call jsoncore%get(jsonvalue2,"address",address);
! call jsoncore%get(jsonvalue2,"port",port);
! call jsoncore%get(jsonvalue2,"password",password);
! call jsoncore%get(jsonvalue2,"datakey",datakey);
c_datakey = datakey//c_null_char
c_password = password//c_null_char


+ 20
- 21
Redis/Redis_Interface.i90 查看文件

@@ -34,31 +34,30 @@ Module RedisInterface

contains

SUBROUTINE initConnection(configFilename,status)
use json_module
SUBROUTINE initConnection(address,port,password, datakey,status)
use iso_c_binding, only: c_null_char,c_char
character(len=*) :: configFilename
! use json_module
character(len=*) :: password,address,datakey
integer::port,status
type(json_file) :: jsonfile
type(json_value),pointer :: jsonvalue,jsonvalue2
type(json_core) :: jsoncore
character(len=:),allocatable :: password,address,datakey
character(len=:),allocatable::c_address,c_password,c_datakey
! type(json_file) :: jsonfile
! type(json_value),pointer :: jsonvalue,jsonvalue2
! type(json_core) :: jsoncore

call jsonfile%initialize()
print *,"Initilized: simulation with ",configFilename
call jsonfile%load_file(configFilename);
if (jsonfile%failed()) then
print *,"can not open config file: ",configFilename ;
stop
endif
! print *,"file read"
call jsonfile%json_file_get_root(jsonvalue)
call jsoncore%get(jsonvalue,'redis',jsonvalue2)
call jsoncore%get(jsonvalue2,"address",address);
call jsoncore%get(jsonvalue2,"port",port);
call jsoncore%get(jsonvalue2,"password",password);
call jsoncore%get(jsonvalue2,"datakey",datakey);
! call jsonfile%initialize()
! print *,"Initilized: simulation with ",configFilename
! call jsonfile%load_file(configFilename);
! if (jsonfile%failed()) then
! print *,"can not open config file: ",configFilename ;
! stop
! endif
! ! print *,"file read"
! call jsonfile%json_file_get_root(jsonvalue)
! call jsoncore%get(jsonvalue,'redis',jsonvalue2)
! call jsoncore%get(jsonvalue2,"address",address);
! call jsoncore%get(jsonvalue2,"port",port);
! call jsoncore%get(jsonvalue2,"password",password);
! call jsoncore%get(jsonvalue2,"datakey",datakey);

c_datakey = datakey//c_null_char
c_password = password//c_null_char


+ 6
- 0
Simulation/SimulationVariables.f90 查看文件

@@ -2,6 +2,8 @@ module SimulationVariables
use Constants
use json_module
use CUnityInputs
use CUnityOutputs
use COperationScenariosVariables
use CStringConfigurationVariables
use CFormationVariables
@@ -86,6 +88,7 @@ module SimulationVariables
Type(PathGenerationType)::Path
! Type(WellSurveyDataType)::WellSurveyData
Type(MudPropertiesType)::Mud
end type ConfigurationType
type EquipmentControlType
@@ -101,6 +104,9 @@ module SimulationVariables
Type(DrillingWatchType)::DrillingWatch
Type(TankType)::Tank
type(DownHoleType):: DownHole
type(UnityInputsType)::UnityInputs
type(UnityOutputsType):: UnityOutputs
end type EquipmentControlType
type SimulationStateType


+ 6
- 0
Simulation/SimulationVariables.i90 查看文件

@@ -3,6 +3,8 @@ module SimulationVariables
use Constants
use json_module
use CUnityInputs
use CUnityOutputs
use COperationScenariosVariables
use CStringConfigurationVariables
use CFormationVariables
@@ -87,6 +89,7 @@ module SimulationVariables
Type(PathGenerationType)::Path
! Type(WellSurveyDataType)::WellSurveyData
Type(MudPropertiesType)::Mud
end type ConfigurationType
type EquipmentControlType
@@ -102,6 +105,9 @@ module SimulationVariables
Type(DrillingWatchType)::DrillingWatch
Type(TankType)::Tank
type(DownHoleType):: DownHole

type(UnityInputsType)::UnityInputs
type(UnityOutputsType):: UnityOutputs
end type EquipmentControlType

type SimulationStateType


二进制
查看文件


+ 14
- 9
SimulationCore2.f90 查看文件

@@ -17,20 +17,25 @@ program SimulationCore2
use RedisInterface
!use testRedisModule
implicit none
character(len=50)::configFilename = "config-local.json"
character(len=100) :: redis_host,redis_password, sim_id, temp
integer :: redis_port, log_level, stat
! Variables
! Body of SimulationCore2
! print *, 'Hello World'
! call read_variables()
if(command_argument_count()>0) then
call get_command_argument(1, configFilename)
if(command_argument_count()/=5) then
print *, "Simulator Program must have 5 parameter: redis_host,redisPort,redis_password, sim_id,log_level"
stop
endif
! print *,"config-file at SimCore= ",configFilename
! call initSimulation()
call simulate(configFilename)
! Initialise the json_file object.
! call testRedis()
! pause
call get_command_argument(1, redis_host)
call get_command_argument(2, temp)
read(temp,*,iostat=stat) redis_port
call get_command_argument(3, redis_password)
call get_command_argument(4, sim_id)
call get_command_argument(5, temp)
read(temp,*,iostat=stat) log_level
call simulate(trim(redis_host),redis_port,trim(redis_password), trim(sim_id),log_level)
end program SimulationCore2

+ 42
- 0
SimulationCore2.i90 查看文件

@@ -0,0 +1,42 @@
# 1 "/mnt/c/Projects/VSIM/SimulationCore2/SimulationCore2.f90"
! SimulationCore2.f90
!
! FUNCTIONS:
! SimulationCore2 - Entry point of console application.
!
!****************************************************************************
!
! PROGRAM: SimulationCore2
!
! PURPOSE: Entry point for the console application.
!
!****************************************************************************

program SimulationCore2
use Simulator
use RedisInterface
!use testRedisModule
implicit none
character(len=100) :: redis_host,redis_password, sim_id, temp
integer :: redis_port, log_level, stat
! Variables

! Body of SimulationCore2
! print *, 'Hello World'
! call read_variables()
if(command_argument_count()/=5) then
print *, "Simulator Program must have 5 parameter: redis_host,redisPort,redis_password, sim_id,log_level"
stop
endif
call get_command_argument(1, redis_host)
call get_command_argument(2, temp)
read(temp,*,iostat=stat) redis_port
call get_command_argument(3, redis_password)
call get_command_argument(4, sim_id)
call get_command_argument(5, temp)
read(temp,*,iostat=stat) log_level

call simulate(trim(redis_host),redis_port,trim(redis_password), trim(sim_id),log_level)
end program SimulationCore2


+ 34
- 33
Simulator.f90 查看文件

@@ -48,11 +48,9 @@ module Simulator
use COtherProblems
use CPumpProblems
use CRotaryProblems
use OperationScenariosModule
use PermissionsModule
use UnitySignalsModule
use CBopControlPanel
use CChokeControlPanel
use CChokeManifold
@@ -63,6 +61,7 @@ module Simulator
use CTopDrivePanel
use DrillingWatchModule
use CTanks
use UnityModule
implicit none
type(json_file) :: jsonfile
@@ -80,17 +79,18 @@ module Simulator
contains
subroutine Simulate(configFilename)
character(*)::configFilename
integer::t0,t1,t2,t3,t_read=0,t_write=0,t_exec=0,i,status
subroutine Simulate(redis_host,redis_port,redis_password, sim_id,log_level)
character(len=*) :: redis_host,redis_password, sim_id
integer::t0,t1,t2,t3,t_read=0,t_write=0,t_exec=0,i,status,redis_port,log_level
integer,dimension(12)::t,t_modules
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
do i=1,size(t_modules)
t_modules(i)=0
end do
call initSimulation(configFilename)
call initConnection(configFilename,status)
logging = log_level
! call initSimulation(configFilename)
call initConnection(redis_host,redis_port,redis_password, sim_id,status)
if (status<0) then
print *,"Can not init connection to redis."
stop
@@ -221,29 +221,29 @@ module Simulator
print *,"Total Time =",t_read+t_write+t_exec
end subroutine Simulate
subroutine initSimulation(configFilename)
use json_module
use iso_c_binding, only: c_null_char,c_char
character(len=*) :: configFilename
! type(json_file) :: jsonfile
type(json_value),pointer :: jsonvalue
type(json_core) :: jsoncore
! logical :: is_found
! character(len=:),allocatable :: password,address,datakey
! character(len=:),allocatable::c_address,c_password,c_datakey
call jsonfile%initialize()
! print *,"init simulation with ",configFilename
call jsonfile%load_file(configFilename);
if (jsonfile%failed()) then
print *,"can not open config file: ",configFilename ;
stop
endif
! print *,"file read"
call jsonfile%json_file_get_root(jsonvalue)
call jsoncore%get(jsonvalue,'logging',logging)
print *,"logging=",logging
end subroutine
! subroutine initSimulation(configFilename)
! use json_module
! use iso_c_binding, only: c_null_char,c_char
! character(len=*) :: configFilename
! ! type(json_file) :: jsonfile
! type(json_value),pointer :: jsonvalue
! type(json_core) :: jsoncore
! ! logical :: is_found
! ! character(len=:),allocatable :: password,address,datakey
! ! character(len=:),allocatable::c_address,c_password,c_datakey
! call jsonfile%initialize()
! ! print *,"init simulation with ",configFilename
! call jsonfile%load_file(configFilename);
! if (jsonfile%failed()) then
! print *,"can not open config file: ",configFilename ;
! stop
! endif
! ! print *,"file read"
! call jsonfile%json_file_get_root(jsonvalue)
! call jsoncore%get(jsonvalue,'logging',logging)
! print *,"logging=",logging
! end subroutine
subroutine write_variables()
use CAccumulator
@@ -455,7 +455,8 @@ module Simulator
call CasingLinerChokeToJson(p)
call PathGenerationToJson(p)
! call WellSurveyDataToJson(p)
call MudPropertiesToJson(p)
call MudPropertiesToJson(p)
call UnityOutputsToJson(p)
! 3. add new node to parent
call json%add(parent,p)
@@ -635,7 +636,7 @@ module Simulator
call CasingLinerChokeFromJson(p)
call PathGenerationFromJson(p)
call MudPropertiesFromJson(p)
call UnityInputsFromJson(p)
! 3. add new node to parent
call json%add(parent,p)
end subroutine


+ 34
- 33
Simulator.i90 查看文件

@@ -49,11 +49,9 @@ module Simulator
use COtherProblems
use CPumpProblems
use CRotaryProblems

use OperationScenariosModule
use PermissionsModule
use UnitySignalsModule

use CBopControlPanel
use CChokeControlPanel
use CChokeManifold
@@ -64,6 +62,7 @@ module Simulator
use CTopDrivePanel
use DrillingWatchModule
use CTanks
use UnityModule

implicit none
type(json_file) :: jsonfile
@@ -81,17 +80,18 @@ module Simulator
contains

subroutine Simulate(configFilename)
character(*)::configFilename
integer::t0,t1,t2,t3,t_read=0,t_write=0,t_exec=0,i,status
subroutine Simulate(redis_host,redis_port,redis_password, sim_id,log_level)
character(len=*) :: redis_host,redis_password, sim_id
integer::t0,t1,t2,t3,t_read=0,t_write=0,t_exec=0,i,status,redis_port,log_level
integer,dimension(12)::t,t_modules
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

do i=1,size(t_modules)
t_modules(i)=0
end do
call initSimulation(configFilename)
call initConnection(configFilename,status)
logging = log_level
! call initSimulation(configFilename)
call initConnection(redis_host,redis_port,redis_password, sim_id,status)
if (status<0) then
print *,"Can not init connection to redis."
stop
@@ -222,29 +222,29 @@ module Simulator
print *,"Total Time =",t_read+t_write+t_exec
end subroutine Simulate

subroutine initSimulation(configFilename)
use json_module
use iso_c_binding, only: c_null_char,c_char
character(len=*) :: configFilename
! type(json_file) :: jsonfile
type(json_value),pointer :: jsonvalue
type(json_core) :: jsoncore
! logical :: is_found
! character(len=:),allocatable :: password,address,datakey
! character(len=:),allocatable::c_address,c_password,c_datakey
call jsonfile%initialize()
! print *,"init simulation with ",configFilename
call jsonfile%load_file(configFilename);
if (jsonfile%failed()) then
print *,"can not open config file: ",configFilename ;
stop
endif
! print *,"file read"
call jsonfile%json_file_get_root(jsonvalue)
call jsoncore%get(jsonvalue,'logging',logging)
print *,"logging=",logging
end subroutine
! subroutine initSimulation(configFilename)
! use json_module
! use iso_c_binding, only: c_null_char,c_char
! character(len=*) :: configFilename
! ! type(json_file) :: jsonfile
! type(json_value),pointer :: jsonvalue
! type(json_core) :: jsoncore
! ! logical :: is_found
! ! character(len=:),allocatable :: password,address,datakey
! ! character(len=:),allocatable::c_address,c_password,c_datakey
! call jsonfile%initialize()
! ! print *,"init simulation with ",configFilename
! call jsonfile%load_file(configFilename);
! if (jsonfile%failed()) then
! print *,"can not open config file: ",configFilename ;
! stop
! endif
! ! print *,"file read"
! call jsonfile%json_file_get_root(jsonvalue)
! call jsoncore%get(jsonvalue,'logging',logging)
! print *,"logging=",logging
! end subroutine

subroutine write_variables()
use CAccumulator
@@ -456,7 +456,8 @@ module Simulator
call CasingLinerChokeToJson(p)
call PathGenerationToJson(p)
! call WellSurveyDataToJson(p)
call MudPropertiesToJson(p)
call MudPropertiesToJson(p)
call UnityOutputsToJson(p)

! 3. add new node to parent
call json%add(parent,p)
@@ -636,7 +637,7 @@ module Simulator
call CasingLinerChokeFromJson(p)
call PathGenerationFromJson(p)
call MudPropertiesFromJson(p)
call UnityInputsFromJson(p)
! 3. add new node to parent
call json%add(parent,p)
end subroutine


+ 12
- 2
Text1.txt 查看文件

@@ -1,2 +1,12 @@
logical :: AnnDrillMud
logical :: AnnCirculateMud
real(8) :: KellyHoseVibrationRate
real(8) :: BlowoutFromStringPercent
real(8) :: Pedal
real(8) :: FlowRate
real(8) :: RotaryRpm
logical :: BlowoutFromString
logical :: BlowoutFromAnnular
logical :: FlowFromReturnLine
real :: FlowFromKelly
real :: FlowFromFillupHead
logical :: FlowKellyDisconnect
logical :: FlowPipeDisconnect

+ 3
- 10
TorqueDrag/TD_Forces/TD_HookLoadCalculation.f90 查看文件

@@ -1,27 +1,20 @@
subroutine TD_HookLoadCalculation
Use TD_DrillStemComponents
use SimulationVariables !@
use SimulationVariables !@
use SimulationVariables !@
Use TD_StringConnectionData
use SimulationVariables !@, only: Drawworks
use CDataDisplayConsole
use SimulationVariables
use CHoistingVariables
use SimulationVariables
! Use CSlipsEnumVariables
use UnitySignalVariables
use UnitySignalsModule
use UnitySignalsModule
Use CBopStackVariables
use SimulationVariables
Use CUnityInputs
Use UnityModule
implicit none
Integer :: i , kk
Real(8) :: TD_eConst=0.98d0 , TD_SumWeight
Real(8) :: TD_SumWeight !,TD_eConst=0.98d0


+ 3
- 10
TorqueDrag/TD_Forces/TD_HookLoadCalculation.i90 查看文件

@@ -2,27 +2,20 @@
subroutine TD_HookLoadCalculation
Use TD_DrillStemComponents
use SimulationVariables !@
use SimulationVariables !@
use SimulationVariables !@
Use TD_StringConnectionData
use SimulationVariables !@, only: Drawworks
use CDataDisplayConsole
use SimulationVariables
use CHoistingVariables
use SimulationVariables
! Use CSlipsEnumVariables
use UnitySignalVariables
use UnitySignalsModule
use UnitySignalsModule
Use CBopStackVariables
use SimulationVariables
Use CUnityInputs
Use UnityModule
implicit none
Integer :: i , kk
Real(8) :: TD_eConst=0.98d0 , TD_SumWeight
Real(8) :: TD_SumWeight !,TD_eConst=0.98d0


+ 3
- 1
config-remote.json 查看文件

@@ -5,5 +5,7 @@
"password":"4YKFnubfFFjfh4yTK7b0Rg9X",
"datakey":"data"
},
"logging":4
"logging":4,
"process_name": "SimulationCore2",
"work_dir" : "/mnt/c/Projects/VSIM/SimulationCore2"
}

+ 34
- 42
helper.ipynb 查看文件

@@ -877,31 +877,18 @@
},
{
"cell_type": "code",
"execution_count": 51,
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1-(0, 1)\n",
"1-(1, 3)\n",
"1-(2, 3)\n",
"1-(3, 5)\n",
"2-(0, 1)\n",
"2-(1, 3)\n",
"2-(2, 3)\n",
"2-(3, 5)\n"
"assets={'USDT': {'Total': '5858.36917324', 'Free': 3879.35}, 'BUSD': {'Total': '-156.01984572', 'Free': 3877.23}}\n"
]
}
],
"source": [
"l = [1,3,3,5]\n",
"for a in enumerate(l):\n",
" print(f\"1-{a}\")\n",
"for a in enumerate(l):\n",
" print(f\"2-{a}\")"
]
"source": []
},
{
"attachments": {},
@@ -920,16 +907,28 @@
"name": "stdout",
"output_type": "stream",
"text": [
"\t\tcall json%get(p,'AnnDrillMud',pval)\n",
"\t\tcall json%get(pval,data%Equipments%DownHole%AnnDrillMud)\n",
"\t\tcall json%get(p,'AnnCirculateMud',pval)\n",
"\t\tcall json%get(pval,data%Equipments%DownHole%AnnCirculateMud)\n"
"\t\tcall json%get(p,'ElevatorConnectionPossible',pval)\n",
"\t\tcall json%get(pval,data%Equipments%UnityInputs%ElevatorConnectionPossible)\n",
"\t\tcall json%get(p,'JointConnectionPossible',pval)\n",
"\t\tcall json%get(pval,data%Equipments%UnityInputs%JointConnectionPossible)\n",
"\t\tcall json%get(p,'IsKellyBushingSetInTable',pval)\n",
"\t\tcall json%get(pval,data%Equipments%UnityInputs%IsKellyBushingSetInTable)\n",
"\t\tcall json%get(p,'ElevatorPickup',pval)\n",
"\t\tcall json%get(pval,data%Equipments%UnityInputs%ElevatorPickup)\n",
"\t\tcall json%get(p,'NearFloorPosition',pval)\n",
"\t\tcall json%get(pval,data%Equipments%UnityInputs%NearFloorPosition)\n",
"\t\tcall json%get(p,'SingleSetInMouseHole',pval)\n",
"\t\tcall json%get(pval,data%Equipments%UnityInputs%SingleSetInMouseHole)\n",
"\t\tcall json%get(p,'TdsConnectionPossible',pval)\n",
"\t\tcall json%get(pval,data%Equipments%UnityInputs%TdsConnectionPossible)\n",
"\t\tcall json%get(p,'TdsStemIn',pval)\n",
"\t\tcall json%get(pval,data%Equipments%UnityInputs%TdsStemIn)\n"
]
}
],
"source": [
"pattern=\"\"\"\t\tcall json%get(p,'@@@',pval)\n",
"\t\tcall json%get(pval,data%Equipments%DownHole%@@@)\"\"\"\n",
"\t\tcall json%get(pval,data%Equipments%UnityInputs%@@@)\"\"\"\n",
"\n",
"input = open(\"Text1.txt\")\n",
"lines = input.readlines()\n",
@@ -981,37 +980,30 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"call json%add(p,\"AnnalusFluidsCount\",data%Equipments%DownHole%AnnalusFluidsCount)\n",
"call json%add(p,\"StringFluidsCount\",data%Equipments%DownHole%StringFluidsCount)\n",
"call json%add(p,\"AnnalusFluids(:)\",data%Equipments%DownHole%AnnalusFluids(:))\n",
"call json%add(p,\"StringFluids(:)\",data%Equipments%DownHole%StringFluids(:))\n",
"call json%add(p,\"\",data%Equipments%DownHole%)\n",
"call json%add(p,\"StringCount\",data%Equipments%DownHole%StringCount)\n",
"call json%add(p,\"String(:)\",data%Equipments%DownHole%String(:))\n",
"call json%add(p,\"\",data%Equipments%DownHole%)\n",
"call json%add(p,\"BopElements(:)\",data%Equipments%DownHole%BopElements(:))\n",
"call json%add(p,\"\",data%Equipments%DownHole%)\n",
"call json%add(p,\"DrillPipePressure\",data%Equipments%DownHole%DrillPipePressure)\n",
"call json%add(p,\"CasingPressure\",data%Equipments%DownHole%CasingPressure)\n",
"call json%add(p,\"ShoePressure\",data%Equipments%DownHole%ShoePressure)\n",
"call json%add(p,\"BottomHolePressure\",data%Equipments%DownHole%BottomHolePressure)\n",
"call json%add(p,\"FormationPressure\",data%Equipments%DownHole%FormationPressure)\n",
"call json%add(p,\"InfluxRate\",data%Equipments%DownHole%InfluxRate)\n",
"call json%add(p,\"KickVolume\",data%Equipments%DownHole%KickVolume)\n",
"call json%add(p,\"SecondKickVolume\",data%Equipments%DownHole%SecondKickVolume)\n",
"call json%add(p,\"PermeabilityExposedHeight\",data%Equipments%DownHole%PermeabilityExposedHeight)\n"
"call json%add(p,\"KellyHoseVibrationRate\",data%Equipments%UnityOutputs%KellyHoseVibrationRate)\n",
"call json%add(p,\"BlowoutFromStringPercent\",data%Equipments%UnityOutputs%BlowoutFromStringPercent)\n",
"call json%add(p,\"Pedal\",data%Equipments%UnityOutputs%Pedal)\n",
"call json%add(p,\"FlowRate\",data%Equipments%UnityOutputs%FlowRate)\n",
"call json%add(p,\"RotaryRpm\",data%Equipments%UnityOutputs%RotaryRpm)\n",
"call json%add(p,\"BlowoutFromString\",data%Equipments%UnityOutputs%BlowoutFromString)\n",
"call json%add(p,\"BlowoutFromAnnular\",data%Equipments%UnityOutputs%BlowoutFromAnnular)\n",
"call json%add(p,\"FlowFromReturnLine\",data%Equipments%UnityOutputs%FlowFromReturnLine)\n",
"call json%add(p,\"FlowFromKelly\",data%Equipments%UnityOutputs%FlowFromKelly)\n",
"call json%add(p,\"FlowFromFillupHead\",data%Equipments%UnityOutputs%FlowFromFillupHead)\n",
"call json%add(p,\"FlowKellyDisconnect\",data%Equipments%UnityOutputs%FlowKellyDisconnect)\n",
"call json%add(p,\"FlowPipeDisconnect\",data%Equipments%UnityOutputs%FlowPipeDisconnect)\n"
]
}
],
"source": [
"precode = \"\"\"call json%add(p,\"\",data%Equipments%DownHole%\"\"\"\n",
"precode = \"\"\"call json%add(p,\"\",data%Equipments%UnityOutputs%\"\"\"\n",
"input = open(\"Text1.txt\")\n",
"lines = input.readlines()\n",
"for line in lines:\n",


+ 0
- 1
redisContent.json 查看文件

@@ -942,4 +942,3 @@
}
}
}


+ 75
- 0
simulatorManager.py 查看文件

@@ -0,0 +1,75 @@
import sys
import redis
import json
import time
import subprocess
import psutil

if __name__=='__main__':
if len(sys.argv)<=1:
configFN = 'config-remote.json'
else:
configFN = sys.argv[1]

f = open(configFN)
config = json.load(f)

redis_address = config['redis']['address']
redis_password = config['redis']['password']
redis_port = config['redis']['port']
log_level = config['logging']
work_dir = config['work_dir']
process_name = config['process_name']

r = redis.Redis(host=redis_address, port=redis_port, decode_responses=True,password=redis_password)
runnings = []
while True:
sims = r.get('Simulations')
sims = json.loads(sims)
for sim in sims:
simulation_id = sim['Id']
process_exists = False
for proc in psutil.process_iter(['pid', 'name', 'cmdline']):
if proc.info['name'] == process_name and len(proc.info['cmdline']) > 1 and proc.info['cmdline'][1] == simulation_id:
process_exists = True
break
if not process_exists:
subprocess.Popen(['./SimulationCore2', simulation_id], cwd=work_dir)

time.sleep(1)




# Connect to Redis server
redis_host = 'localhost' # Replace with your Redis server's host
redis_port = 6379 # Replace with your Redis server's port
redis_client = redis.Redis(host=redis_host, port=redis_port)
if redis_client is None:
print(f"Can not connect to {redis_host}.\nExiting...")
exit(1)
# Main loop
while True:
# Retrieve array from Redis
simulations = redis_client.lrange('simulations', 0, -1)
# Check each entry in the array
for entry in simulations:
simulation_id = entry.decode()
# Check if 'SimulationCore2' process with specific parameter is running
process_name = 'SimulationCore2'
process_exists = False
for proc in psutil.process_iter(['pid', 'name', 'cmdline']):
if proc.info['name'] == process_name and len(proc.info['cmdline']) > 1 and proc.info['cmdline'][1] == simulation_id:
process_exists = True
break
if not process_exists:
# Run 'SimulationCore2' process with specific parameter
printf(f"Starting new simulator process for {simulation_id}")
subprocess.Popen(['./SimulationCore2', simulation_id], cwd='/path/to/SimulationCore2/directory')
# Wait for 1 second before checking again
time.sleep(1)

正在加载...
取消
保存