Simulation Core
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

528 righe
16 KiB

  1. # 1 "/home/admin/SimulationCore2/CSharp/OperationScenarios/UnitySignals/UnitySignals.f90"
  2. module UnitySignalsModule
  3. use UnitySignalVariables
  4. use SimulationVariables
  5. use RedisInterface
  6. contains
  7. subroutine UnitySignalsToJson(parent)
  8. type(json_value),pointer :: parent
  9. type(json_value),pointer :: p
  10. type(json_core) :: jsoncore
  11. call jsoncore%create_object(p,'UnitySignals')
  12. call jsoncore%add(p,"MudBucket",data%State%unitySignals%MudBucket)
  13. call jsoncore%add(p,"Elevator",data%State%unitySignals%Elevator)
  14. call jsoncore%add(p,"FillupHead",data%State%unitySignals%FillupHead)
  15. call jsoncore%add(p,"Ibop",data%State%unitySignals%Ibop)
  16. call jsoncore%add(p,"Kelly",data%State%unitySignals%Kelly)
  17. call jsoncore%add(p,"MouseHole",data%State%unitySignals%MouseHole)
  18. call jsoncore%add(p,"OperationCondition",data%State%unitySignals%OperationCondition)
  19. call jsoncore%add(p,"SafetyValve",data%State%unitySignals%SafetyValve)
  20. call jsoncore%add(p,"operation",data%State%unitySignals%operation)
  21. call jsoncore%add(p,"Slips",data%State%unitySignals%Slips)
  22. call jsoncore%add(p,"Slips_S",data%State%unitySignals%Slips_S)
  23. call jsoncore%add(p,"Swing",data%State%unitySignals%Swing)
  24. call jsoncore%add(p,"Swing_S",data%State%unitySignals%Swing_S)
  25. call jsoncore%add(p,"TdsBackupClamp",data%State%unitySignals%TdsBackupClamp)
  26. call jsoncore%add(p,"TdsSpine",data%State%unitySignals%TdsSpine)
  27. call jsoncore%add(p,"TdsSwing",data%State%unitySignals%TdsSwing)
  28. call jsoncore%add(p,"TdsTong",data%State%unitySignals%TdsTong)
  29. call jsoncore%add(p,"Tong",data%State%unitySignals%Tong)
  30. call jsoncore%add(p,"Tong_S",data%State%unitySignals%Tong_S)
  31. call jsoncore%add(p,"TdsConnectionModes",data%State%unitySignals%TdsConnectionModes)
  32. call jsoncore%add(p,"TdsElevatorModes",data%State%unitySignals%TdsElevatorModes)
  33. call jsoncore%add(parent,p)
  34. end subroutine
  35. subroutine UnitySignalsFromJson(jsonfile)
  36. type(json_file)::jsonfile
  37. logical::found
  38. call jsonfile%get('UnitySignals.MudBucket',data%State%unitySignals%MudBucket,found)
  39. if ( .not. found ) call logg(4,"Not found: unitySignals%MudBucket")
  40. call jsonfile%get('UnitySignals.Elevator',data%State%unitySignals%Elevator,found)
  41. if ( .not. found ) call logg(4,"Not found: unitySignals%Elevator")
  42. call jsonfile%get('UnitySignals.FillupHead',data%State%unitySignals%FillupHead,found)
  43. if ( .not. found ) call logg(4,"Not found: unitySignals%FillupHead")
  44. call jsonfile%get('UnitySignals.Ibop',data%State%unitySignals%Ibop,found)
  45. if ( .not. found ) call logg(4,"Not found: unitySignals%Ibop")
  46. call jsonfile%get('UnitySignals.Kelly',data%State%unitySignals%Kelly,found)
  47. if ( .not. found ) call logg(4,"Not found: unitySignals%Kelly")
  48. call jsonfile%get('UnitySignals.MouseHole',data%State%unitySignals%MouseHole,found)
  49. if ( .not. found ) call logg(4,"Not found: unitySignals%MouseHole")
  50. call jsonfile%get('UnitySignals.OperationCondition',data%State%unitySignals%OperationCondition,found)
  51. if ( .not. found ) call logg(4,"Not found: unitySignals%OperationCondition")
  52. call jsonfile%get('UnitySignals.SafetyValve',data%State%unitySignals%SafetyValve,found)
  53. if ( .not. found ) call logg(4,"Not found: unitySignals%SafetyValve")
  54. call jsonfile%get('UnitySignals.operation',data%State%unitySignals%operation,found)
  55. if ( .not. found ) call logg(4,"Not found: unitySignals%operation")
  56. call jsonfile%get('UnitySignals.Slips',data%State%unitySignals%Slips,found)
  57. if ( .not. found ) call logg(4,"Not found: unitySignals%Slips")
  58. call jsonfile%get('UnitySignals.Slips_S',data%State%unitySignals%Slips_S,found)
  59. if ( .not. found ) call logg(4,"Not found: unitySignals%Slips_S")
  60. call jsonfile%get('UnitySignals.Swing',data%State%unitySignals%Swing,found)
  61. if ( .not. found ) call logg(4,"Not found: unitySignals%Swing")
  62. call jsonfile%get('UnitySignals.Swing_S',data%State%unitySignals%Swing_S,found)
  63. if ( .not. found ) call logg(4,"Not found: unitySignals%Swing_S")
  64. call jsonfile%get('UnitySignals.TdsBackupClamp',data%State%unitySignals%TdsBackupClamp,found)
  65. if ( .not. found ) call logg(4,"Not found: unitySignals%TdsBackupClamp")
  66. call jsonfile%get('UnitySignals.TdsSpine',data%State%unitySignals%TdsSpine,found)
  67. if ( .not. found ) call logg(4,"Not found: unitySignals%TdsSpine")
  68. call jsonfile%get('UnitySignals.TdsSwing',data%State%unitySignals%TdsSwing,found)
  69. if ( .not. found ) call logg(4,"Not found: unitySignals%TdsSwing")
  70. call jsonfile%get('UnitySignals.TdsTong',data%State%unitySignals%TdsTong,found)
  71. if ( .not. found ) call logg(4,"Not found: unitySignals%TdsTong")
  72. call jsonfile%get('UnitySignals.Tong',data%State%unitySignals%Tong,found)
  73. if ( .not. found ) call logg(4,"Not found: unitySignals%Tong")
  74. call jsonfile%get('UnitySignals.Tong_S',data%State%unitySignals%Tong_S,found)
  75. if ( .not. found ) call logg(4,"Not found: unitySignals%Tong_S")
  76. call jsonfile%get('UnitySignals.TdsConnectionModes',data%State%unitySignals%TdsConnectionModes,found)
  77. if ( .not. found ) call logg(4,"Not found: unitySignals%TdsConnectionModes")
  78. call jsonfile%get('UnitySignals.TdsElevatorModes',data%State%unitySignals%TdsElevatorModes,found)
  79. if ( .not. found ) call logg(4,"Not found: unitySignals%TdsElevatorModes")
  80. end subroutine
  81. subroutine Set_TdsElevatorModes(v)
  82. implicit none
  83. integer , intent(in) :: v
  84. # 93
  85. data%State%unitySignals%TdsElevatorModes = v
  86. !**call TdsElevatorModesEnum%OnTdsElevatorModesChange%RunAll()
  87. end subroutine
  88. integer function Get_TdsElevatorModes()
  89. implicit none
  90. Get_TdsElevatorModes = data%State%unitySignals%TdsElevatorModes
  91. end function
  92. subroutine Set_Ibop_Install()
  93. implicit none
  94. call Set_Ibop(IBOP_INSTALL)
  95. end subroutine
  96. subroutine Set_Ibop_Remove()
  97. implicit none
  98. call Set_Ibop(IBOP_REMOVE)
  99. end subroutine
  100. subroutine Set_Tong(v)
  101. implicit none
  102. integer , intent(in) :: v
  103. if(data%State%unitySignals%Tong == v) return
  104. data%State%unitySignals%Tong = v
  105. if(print_log) print*, 'Tong=', data%State%unitySignals%Tong
  106. if(data%State%unitySignals%Tong==TONG_MAKEUP_BEGIN) call publishMessageToChannel("TONG_MAKEUP_BEGIN")
  107. if(data%State%unitySignals%Tong==TONG_BREAKOUT_BEGIN) call publishMessageToChannel("TONG_BREAKOUT_BEGIN")
  108. !**call data%State%unitySignals%OnTongChange%RunAll()
  109. end subroutine
  110. integer function Get_Tong()
  111. implicit none
  112. Get_Tong = data%State%unitySignals%Tong
  113. end function
  114. subroutine Set_TdsTong(v)
  115. implicit none
  116. integer , intent(in) :: v
  117. # 135
  118. data%State%unitySignals%TdsTong = v
  119. # 139
  120. !**call data%State%unitySignals%OnTdsTongChange%RunAll()
  121. end subroutine
  122. integer function Get_TdsTong()
  123. implicit none
  124. Get_TdsTong = data%State%unitySignals%TdsTong
  125. end function
  126. subroutine Set_TdsSwing(v)
  127. implicit none
  128. integer , intent(in) :: v
  129. # 154
  130. data%State%unitySignals%TdsSwing = v
  131. # 158
  132. !**call data%State%unitySignals%OnTdsSwingChange%RunAll()
  133. end subroutine
  134. integer function Get_TdsSwing()
  135. implicit none
  136. Get_TdsSwing = data%State%unitySignals%TdsSwing
  137. end function
  138. subroutine Set_TdsSpine(v)
  139. implicit none
  140. integer , intent(in) :: v
  141. # 173
  142. data%State%unitySignals%TdsSpine = v
  143. # 177
  144. !**call data%State%unitySignals%OnTdsSpineChange%RunAll()
  145. end subroutine
  146. integer function Get_TdsSpine()
  147. implicit none
  148. Get_TdsSpine = data%State%unitySignals%TdsSpine
  149. end function
  150. subroutine Set_TdsBackupClamp(v)
  151. implicit none
  152. integer , intent(in) :: v
  153. # 192
  154. data%State%unitySignals%TdsBackupClamp = v
  155. # 196
  156. !**call data%State%unitySignals%OnTdsBackupClampChange%RunAll()
  157. end subroutine
  158. integer function Get_TdsBackupClamp()
  159. implicit none
  160. Get_TdsBackupClamp = data%State%unitySignals%TdsBackupClamp
  161. end function
  162. subroutine Set_Swing(v)
  163. implicit none
  164. integer , intent(in) :: v
  165. # 211
  166. data%State%unitySignals%Swing = v
  167. # 215
  168. !**call data%State%unitySignals%OnSwingChange%RunAll()
  169. end subroutine
  170. integer function Get_Swing()
  171. implicit none
  172. Get_Swing = data%State%unitySignals%Swing
  173. end function
  174. !//TODO: apparently every thing is started here for slips
  175. subroutine Set_Slips(v)
  176. implicit none
  177. integer , intent(in) :: v
  178. if(data%State%unitySignals%Slips == v) return
  179. data%State%unitySignals%Slips = v
  180. if(print_log) print*, 'Slips=', data%State%unitySignals%Slips
  181. if(v==SLIPS_SET_BEGIN) call publishMessageToChannel("SLIPS_SET_BEGIN")
  182. if(v==SLIPS_UNSET_BEGIN) call publishMessageToChannel("SLIPS_UNSET_BEGIN")
  183. !**call data%State%unitySignals%OnSlipsChange%RunAll()
  184. end subroutine
  185. integer function Get_Slips()
  186. implicit none
  187. Get_Slips = data%State%unitySignals%Slips
  188. end function
  189. subroutine Set_Operation(i)
  190. implicit none
  191. integer, intent (in) :: i
  192. data%State%unitySignals%operation = i
  193. end subroutine
  194. subroutine Set_SafetyValve(v)
  195. implicit none
  196. integer , intent(in) :: v
  197. # 252
  198. data%State%unitySignals%SafetyValve = v
  199. # 262
  200. !**call data%State%unitySignals%OnSafetyValveChange%RunAll()
  201. end subroutine
  202. integer function Get_SafetyValve()
  203. implicit none
  204. Get_SafetyValve = data%State%unitySignals%SafetyValve
  205. end function
  206. subroutine Set_SafetyValve_Install()
  207. implicit none
  208. call Set_SafetyValve(SAFETY_VALVE_INSTALL)
  209. end subroutine
  210. subroutine Set_SafetyValve_Remove()
  211. implicit none
  212. call Set_SafetyValve(SAFETY_VALVE_REMOVE)
  213. end subroutine
  214. subroutine Set_OperationCondition(v)
  215. ! use CKellyEnumVariables
  216. implicit none
  217. integer , intent(in) :: v
  218. # 288
  219. data%State%unitySignals%OperationCondition = v
  220. # 292
  221. !**call data%State%unitySignals%OnOperationConditionChange%RunAll()
  222. !**call data%State%unitySignals%OnOperationConditionChangeInt%RunAll(data%State%unitySignals%OperationCondition)
  223. end subroutine
  224. integer function Get_OperationCondition()
  225. implicit none
  226. Get_OperationCondition = data%State%unitySignals%OperationCondition
  227. end function
  228. subroutine Evaluate_OperationCondition()
  229. implicit none
  230. end subroutine
  231. subroutine Set_MouseHole(v)
  232. implicit none
  233. integer , intent(in) :: v
  234. # 312
  235. !call sleep(2)
  236. data%State%unitySignals%MouseHole = v
  237. # 317
  238. !**call data%State%unitySignals%OnMouseHoleChange%RunAll()
  239. end subroutine
  240. integer function Get_MouseHole()
  241. implicit none
  242. Get_MouseHole = data%State%unitySignals%MouseHole
  243. end function
  244. subroutine Set_Kelly(v)
  245. implicit none
  246. integer , intent(in) :: v
  247. # 333
  248. data%State%unitySignals%Kelly = v
  249. # 337
  250. !**call data%State%unitySignals%OnKellyChange%RunAll()
  251. end subroutine
  252. integer function Get_Kelly()
  253. implicit none
  254. Get_Kelly = data%State%unitySignals%Kelly
  255. end function
  256. subroutine Set_Ibop(v)
  257. implicit none
  258. integer , intent(in) :: v
  259. # 352
  260. data%State%unitySignals%Ibop = v
  261. # 356
  262. !**call data%State%unitySignals%OnIbopChange%RunAll()
  263. end subroutine
  264. integer function Get_Ibop()
  265. implicit none
  266. Get_Ibop = data%State%unitySignals%Ibop
  267. end function
  268. subroutine Set_FillupHead(v)
  269. use CManifolds, only: ToggleFillupHead
  270. implicit none
  271. integer , intent(in) :: v
  272. # 372
  273. data%State%unitySignals%FillupHead = v
  274. if (data%State%unitySignals%FillupHead == FILLUP_HEAD_INSTALL) then
  275. call ToggleFillupHead(.true.)
  276. else if (data%State%unitySignals%FillupHead == FILLUP_HEAD_REMOVE) then
  277. call ToggleFillupHead(.false.)
  278. endif
  279. # 383
  280. !**call data%State%unitySignals%OnFillupHeadChange%RunAll()
  281. end subroutine
  282. integer function Get_FillupHead()
  283. implicit none
  284. Get_FillupHead = data%State%unitySignals%FillupHead
  285. end function
  286. subroutine Evaluate_FillupHead()
  287. use CHoistingVariables
  288. use SimulationVariables
  289. use CStudentStationVariables!, only: data%State%StudentStation%FillupHeadInstallation
  290. implicit none
  291. if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
  292. # 401
  293. endif
  294. if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
  295. # 412
  296. endif
  297. if (Get_FillupHead() == FILLUP_HEAD_INSTALL) then
  298. data%State%StudentStation%FillupHeadInstallation = .true.
  299. else if (Get_FillupHead() == FILLUP_HEAD_REMOVE) then
  300. data%State%StudentStation%FillupHeadInstallation = .false.
  301. endif
  302. end subroutine
  303. subroutine Set_Elevator(v)
  304. implicit none
  305. integer , intent(in) :: v
  306. # 430
  307. data%State%unitySignals%Elevator = v
  308. # 434
  309. !**call data%State%unitySignals%OnElevatorChange%RunAll()
  310. end subroutine
  311. integer function Get_Elevator()
  312. implicit none
  313. Get_Elevator = data%State%unitySignals%Elevator
  314. end function
  315. subroutine Set_MudBucket(v)
  316. use CManifolds, only: ToggleMudBox
  317. implicit none
  318. integer , intent(in) :: v
  319. # 451
  320. data%State%unitySignals%MudBucket = v
  321. if (data%State%unitySignals%MudBucket == MUD_BUCKET_INSTALL) then
  322. call ToggleMudBox(.true.)
  323. else if (data%State%unitySignals%MudBucket == MUD_BUCKET_REMOVE) then
  324. call ToggleMudBox(.false.)
  325. endif
  326. # 460
  327. !**call data%State%unitySignals%OnMudBucketChange%RunAll()
  328. end subroutine
  329. integer function Get_MudBucket()
  330. implicit none
  331. Get_MudBucket = data%State%unitySignals%MudBucket
  332. end function
  333. subroutine Evaluate_MudBucket()
  334. use CStudentStationVariables!, only: data%State%StudentStation%MudBoxInstallation
  335. implicit none
  336. if (Get_MudBucket() == MUD_BUCKET_INSTALL) then
  337. data%State%StudentStation%MudBoxInstallation = .true.
  338. else if (Get_MudBucket() == MUD_BUCKET_REMOVE) then
  339. data%State%StudentStation%MudBoxInstallation = .false.
  340. endif
  341. end subroutine
  342. !! Moved from CTdsConnectionModeEnum
  343. subroutine Set_TdsConnectionModes(v)
  344. use CManifolds, Only: KellyConnected, KellyDisconnected
  345. implicit none
  346. integer , intent(in) :: v
  347. # 490
  348. data%State%unitySignals%TdsConnectionModes = v
  349. if(data%State%unitySignals%TdsConnectionModes == TDS_CONNECTION_NOTHING) then
  350. call KellyDisconnected()
  351. else
  352. call KellyConnected()
  353. endif
  354. # 501
  355. !**call data%State%unitySignals%OnTdsConnectionModesChange%RunAll()
  356. end subroutine
  357. integer function Get_TdsConnectionModes()
  358. use SimulationVariables
  359. implicit none
  360. Get_TdsConnectionModes = data%State%unitySignals%TdsConnectionModes
  361. end function
  362. subroutine Evaluate_TdsConnectionModes()
  363. use CUnityInputs
  364. use SimulationVariables
  365. use UnityModule
  366. implicit none
  367. if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
  368. !TOPDRIVE-CODE=3
  369. if (Get_TdsStemIn() .and.&
  370. Get_TdsSpine() == TDS_SPINE_CONNECT_END .and.&
  371. !TopDriveDrillTorqueState == TdsMu_SPINE
  372. Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING) then
  373. call Set_TdsConnectionModes(TDS_CONNECTION_SPINE)
  374. return
  375. end if
  376. !TOPDRIVE-CODE=4
  377. if (Get_TdsTong() == TDS_TONG_MAKEUP_END .and.&
  378. Get_TdsConnectionModes() == TDS_CONNECTION_SPINE ) then
  379. call Set_TdsConnectionModes(TDS_CONNECTION_STRING)
  380. data%Equipments%TopDrivePanel%TopDriveTorqueWrenchLed = LED_OFF
  381. return
  382. end if
  383. !TOPDRIVE-CODE=5
  384. if (Get_TdsTong() == TDS_TONG_BREAKOUT_END .and.&
  385. Get_TdsConnectionModes() == TDS_CONNECTION_STRING ) then
  386. call Set_TdsConnectionModes(TDS_CONNECTION_SPINE)
  387. data%Equipments%TopDrivePanel%TopDriveTorqueWrenchLed = LED_OFF
  388. return
  389. end if
  390. !TOPDRIVE-CODE=6
  391. if (Get_TdsSpine() == TDS_SPINE_DISCONNECT_END .and.&
  392. !Get_TdsStemIn() == .false. .and.&
  393. Get_TdsConnectionModes() == TDS_CONNECTION_SPINE) then
  394. call Set_TdsConnectionModes(TDS_CONNECTION_NOTHING)
  395. return
  396. end if
  397. endif
  398. ! if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
  399. ! if(print_log) print*, 'Evaluate_TdsConnectionModes=Kelly'
  400. ! endif
  401. end subroutine
  402. end module UnitySignalsModule